User-scaling of AR Content

Hi… could someone point me in the right direction for the best/preferred method of adding a facility for users to resize AR content in their space via pinch and zoom?

Many thanks, in advance, for any advice or links to tutorials (happy to learn :slightly_smiling_face: ).

Original Post on Discord

by user 908977119781060648

No tips from me but I started working on an example for this ages ago but have been too busy to finish it :frowning_with_open_mouth:

by user 103054507105067008

Cheers for the reply @ROBYER1… and no worries, I’ll keep hunting around and post up here if I come across a good/workable/robust solution :slightly_smiling_face:

by user 908977119781060648

i have worked on something like this recently: ``` if(this.context.input.getTouchesPressedCount() >= 2){

            let newPosition0 = this.context.input.getPointerPosition(0);
            let newPosition1 = this.context.input.getPointerPosition(1);
            let oldPosition0 = this.context.input.getPointerPositionLastFrame(0);
            let oldPosition1 = this.context.input.getPointerPositionLastFrame(1);

            if(oldPosition1 && oldPosition0 && newPosition0 && newPosition1){

                //rotating
                let oldVector = new Vector2;
                let newVector = new Vector2;

                oldVector = oldVector.subVectors(oldPosition0, oldPosition1);
                newVector = newVector.subVectors(newPosition0, newPosition1);

                let oldangle = oldVector.angle();
                let newangle = newVector.angle();
                let angle = oldangle-newangle;
                angle = (angle*180/Math.PI)/(this.slowDownRotation);

                if(angle >= 1 || angle <= -1){
                    angle = 0;
                }else{
                    this.gameObject.rotateY(angle);
                    //console.log("AR rotation change: ("+ angle + ")");
                }
                // scaling
                let oldDistance = oldPosition0.distanceTo(oldPosition1);
                let newDistance = newPosition0?.distanceTo(newPosition1);
                let scaleChange = newDistance/oldDistance;

                if(scaleChange>= 1.1 || scaleChange <= 0.9){//not to much of a change (mainly because sometimes scale 0)
                    scaleChange == 1;
                }else{
                    this.gameObject.scale.multiplyScalar(scaleChange);
                    //console.log("AR scale change: ("+ scaleChange+ ")");
                }
            }
        }

*by user 253912725917401089*

Nice, thanks for sharing!
We’re planning to improve the whole AR UX situation in the near future :slightly_smiling_face:

Big thanks @Titan. It’s much appreciated :slightly_smiling_face::+1:

by user 908977119781060648

Hi… just checking in to ask, did something like this ever get built into Needle?

If not, it’d be a ‘very nice to have’ at some point :sparkles: :rocket: Unless it already exists but I’ve missed it somehow? Which is entirely possible :sweat_smile:

by user 908977119781060648

Hi frannie, it’s not builtin yet but we agree :slightly_smiling_face: