Skip to content

Commit

Permalink
Multitouch fixes
Browse files Browse the repository at this point in the history
* Removed unnecessary `default` case for two or more touches on `touchend` to prevent issues with 3 or more touches.
* Reset zoom distances on `case 0` and `case 1`. I couldn't combine them easily without doing a separate `if` statement.
* Simplified `case 1` action to set `_moveCurr` and `_movePrev` to the current touch position preventing camera jumping next time `touchmove` is called.

Related to issue mrdoob#7185 and pull request mrdoob#7406
  • Loading branch information
shshaw committed Oct 22, 2015
1 parent ac6b89b commit d0e2a48
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions examples/js/controls/TrackballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,22 +561,14 @@ THREE.TrackballControls = function ( object, domElement ) {

case 0:
_state = STATE.NONE;
_touchZoomDistanceStart = _touchZoomDistanceEnd = 0;
break;

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

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

var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
_panEnd.copy( getMouseOnScreen( x, y ) );
_panStart.copy( _panEnd );
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
_movePrev.copy( _moveCurr );
break;

}
Expand Down

0 comments on commit d0e2a48

Please sign in to comment.