Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
9e12fd1fac
1 muutettua tiedostoa jossa 14 lisäystä ja 2 poistoa
  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;
 
 			}