Explorar o código

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 %!s(int64=2) %!d(string=hai) anos
pai
achega
9e12fd1fac
Modificáronse 1 ficheiros con 14 adicións e 2 borrados
  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;
 
 			}