浏览代码

Multitouch fix for TrackballControls

Fix for #7185. After using two fingers, the camera would rapidly rotate if both fingers were not removed simultaneously. Adding in some state checks in `touchmove` and `touchend` prevents the jump from the null `_movePrev`, allowing users to quickly go from zooming and panning to rotating.
Shaw 9 年之前
父节点
当前提交
06eea8c713
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 13 4
      examples/js/controls/TrackballControls.js

+ 13 - 4
examples/js/controls/TrackballControls.js

@@ -539,7 +539,11 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 
 			case 1:
 			case 1:
 				_movePrev.copy( _moveCurr );
 				_movePrev.copy( _moveCurr );
-				_moveCurr.copy( getMouseOnCircle(  event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				if ( _state !== STATE.TOUCH_ROTATE ) {
+					_state = STATE.TOUCH_ROTATE;
+					_movePrev.copy( _moveCurr );
+				}
 				break;
 				break;
 
 
 			case 2:
 			case 2:
@@ -565,9 +569,15 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 
 		switch ( event.touches.length ) {
 		switch ( event.touches.length ) {
 
 
+			case 0:
+				_state = STATE.NONE;
+				break;
+
 			case 1:
 			case 1:
-				_movePrev.copy( _moveCurr );
-				_moveCurr.copy( getMouseOnCircle(  event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				if ( _state === STATE.TOUCH_ROTATE ) {
+					_movePrev.copy( _moveCurr );
+					_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				}
 				break;
 				break;
 
 
 			case 2:
 			case 2:
@@ -581,7 +591,6 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 
 		}
 		}
 
 
-		_state = STATE.NONE;
 		_this.dispatchEvent( endEvent );
 		_this.dispatchEvent( endEvent );
 
 
 	}
 	}