Skip to content

Commit

Permalink
TrackballControls: Refactored touch code. See #7406.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Oct 22, 2015
1 parent 69f9617 commit c784d82
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions examples/js/controls/TrackballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ THREE.TrackballControls = function ( object, domElement ) {
_movePrev.copy( _moveCurr );
break;

case 2:
default: // 2 or more
_state = STATE.TOUCH_ZOOM_PAN;
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
Expand All @@ -519,12 +519,9 @@ THREE.TrackballControls = function ( object, domElement ) {
_panEnd.copy( _panStart );
break;

default:
_state = STATE.NONE;

}
_this.dispatchEvent( startEvent );

_this.dispatchEvent( startEvent );

}

Expand All @@ -542,7 +539,7 @@ THREE.TrackballControls = function ( object, domElement ) {
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
break;

case 2:
default: // 2 or more
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
Expand All @@ -552,9 +549,6 @@ THREE.TrackballControls = function ( object, domElement ) {
_panEnd.copy( getMouseOnScreen( x, y ) );
break;

default:
_state = STATE.NONE;

}

}
Expand All @@ -570,15 +564,13 @@ THREE.TrackballControls = function ( object, domElement ) {
break;

case 1:
_state = STATE.TOUCH_ROTATE;
_movePrev.copy( _moveCurr );
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
if ( _state !== STATE.TOUCH_ROTATE ) {
_state = STATE.TOUCH_ROTATE;
_movePrev.copy( _moveCurr );
}
break;

case 2:
default: // 2 or more
_state = STATE.TOUCH_ZOOM_PAN;
_touchZoomDistanceStart = _touchZoomDistanceEnd = 0;

var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
Expand Down

0 comments on commit c784d82

Please sign in to comment.