Scale your object at runtime (Lean touch)

Hello, does any one tried to scale a 3d object for example a plane at runtime by using two fingers touch

Hi @abd_almajeed_saleh,

This is definitely doable, using listeners on touch events. You can check the orbit-camera scripts, and specifically the touch-input.js script. There there is a listener to do handle zooming when using two fingers touch:

TouchInput.prototype.onTouchStartEndCancel = function(event) {    
    // We only care about the first touch for camera rotation. As the user touches the screen, 
    // we stored the current touch position
    var touches = event.touches;
    if (touches.length == 1) {
        this.lastTouchPoint.set(touches[0].x, touches[0].y);
    } else if (touches.length == 2) {
        // If there are 2 touches on the screen, then set the pinch distance
        this.lastPinchDistance = this.getPinchDistance(touches[0], touches[1]);
        this.calcMidPoint(touches[0], touches[1], this.lastPinchMidPoint);

You could easily update that code to handle scaling an entity instead of zooming in/out the camera.

1 Like