소스 검색

TrackballControls: Fix multi-touch in `onTouchEnd()`. (#24631)

* Fix camera runaway after zoom gesture

problem is observed on mobile phone, when lifting one finger after multitouch gesture, the camera will change dramatically as if swiped from that position to where first finger is

* Update TrackballControls.js

Co-authored-by: Michael Herzog <[email protected]>
Xiaolin Pu 2 년 전
부모
커밋
9e12fd1fac
1개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 14 2
      examples/jsm/controls/TrackballControls.js

+ 14 - 2
examples/jsm/controls/TrackballControls.js

@@ -700,8 +700,20 @@ class TrackballControls extends EventDispatcher {
 
 				case 2:
 					_state = STATE.TOUCH_ZOOM_PAN;
-					_moveCurr.copy( getMouseOnCircle( event.pageX - _movePrev.x, event.pageY - _movePrev.y ) );
-					_movePrev.copy( _moveCurr );
+
+					for ( let i = 0; i < _pointers.length; i ++ ) {
+
+						if ( _pointers[ i ].pointerId !== event.pointerId ) {
+
+							const position = _pointerPositions[ _pointers[ i ].pointerId ];
+							_moveCurr.copy( getMouseOnCircle( position.x, position.y ) );
+							_movePrev.copy( _moveCurr );
+							break;
+
+						}
+
+					}
+
 					break;
 
 			}