|
@@ -825,16 +825,18 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleTouchStartRotate() {
|
|
|
+ function handleTouchStartRotate( event ) {
|
|
|
|
|
|
if ( pointers.length === 1 ) {
|
|
|
|
|
|
- rotateStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
|
|
|
+ rotateStart.set( event.pageX, event.pageY );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
|
|
|
- const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
|
|
|
+ const position = getSecondPointerPosition( event );
|
|
|
+
|
|
|
+ const x = 0.5 * ( event.pageX + position.x );
|
|
|
+ const y = 0.5 * ( event.pageY + position.y );
|
|
|
|
|
|
rotateStart.set( x, y );
|
|
|
|
|
@@ -842,16 +844,18 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleTouchStartPan() {
|
|
|
+ function handleTouchStartPan( event ) {
|
|
|
|
|
|
if ( pointers.length === 1 ) {
|
|
|
|
|
|
- panStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
|
|
|
+ panStart.set( event.pageX, event.pageY );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
|
|
|
- const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
|
|
|
+ const position = getSecondPointerPosition( event );
|
|
|
+
|
|
|
+ const x = 0.5 * ( event.pageX + position.x );
|
|
|
+ const y = 0.5 * ( event.pageY + position.y );
|
|
|
|
|
|
panStart.set( x, y );
|
|
|
|
|
@@ -859,10 +863,12 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleTouchStartDolly() {
|
|
|
+ function handleTouchStartDolly( event ) {
|
|
|
+
|
|
|
+ const position = getSecondPointerPosition( event );
|
|
|
|
|
|
- const dx = pointers[ 0 ].pageX - pointers[ 1 ].pageX;
|
|
|
- const dy = pointers[ 0 ].pageY - pointers[ 1 ].pageY;
|
|
|
+ const dx = event.pageX - position.x;
|
|
|
+ const dy = event.pageY - position.y;
|
|
|
|
|
|
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
|
|
|
@@ -870,19 +876,19 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleTouchStartDollyPan() {
|
|
|
+ function handleTouchStartDollyPan( event ) {
|
|
|
|
|
|
- if ( scope.enableZoom ) handleTouchStartDolly();
|
|
|
+ if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
|
|
|
|
- if ( scope.enablePan ) handleTouchStartPan();
|
|
|
+ if ( scope.enablePan ) handleTouchStartPan( event );
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleTouchStartDollyRotate() {
|
|
|
+ function handleTouchStartDollyRotate( event ) {
|
|
|
|
|
|
- if ( scope.enableZoom ) handleTouchStartDolly();
|
|
|
+ if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
|
|
|
|
- if ( scope.enableRotate ) handleTouchStartRotate();
|
|
|
+ if ( scope.enableRotate ) handleTouchStartRotate( event );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1213,7 +1219,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
if ( scope.enableRotate === false ) return;
|
|
|
|
|
|
- handleTouchStartRotate();
|
|
|
+ handleTouchStartRotate( event );
|
|
|
|
|
|
state = STATE.TOUCH_ROTATE;
|
|
|
|
|
@@ -1223,7 +1229,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
if ( scope.enablePan === false ) return;
|
|
|
|
|
|
- handleTouchStartPan();
|
|
|
+ handleTouchStartPan( event );
|
|
|
|
|
|
state = STATE.TOUCH_PAN;
|
|
|
|
|
@@ -1245,7 +1251,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
|
|
|
|
- handleTouchStartDollyPan();
|
|
|
+ handleTouchStartDollyPan( event );
|
|
|
|
|
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
|
|
|
@@ -1255,7 +1261,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
|
|
|
|
- handleTouchStartDollyRotate();
|
|
|
+ handleTouchStartDollyRotate( event );
|
|
|
|
|
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
|
|
|
@@ -1347,7 +1353,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
function addPointer( event ) {
|
|
|
|
|
|
- pointers.push( event );
|
|
|
+ pointers.push( event.pointerId );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1357,7 +1363,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
for ( let i = 0; i < pointers.length; i ++ ) {
|
|
|
|
|
|
- if ( pointers[ i ].pointerId == event.pointerId ) {
|
|
|
+ if ( pointers[ i ] == event.pointerId ) {
|
|
|
|
|
|
pointers.splice( i, 1 );
|
|
|
return;
|
|
@@ -1385,9 +1391,9 @@ class OrbitControls extends EventDispatcher {
|
|
|
|
|
|
function getSecondPointerPosition( event ) {
|
|
|
|
|
|
- const pointer = ( event.pointerId === pointers[ 0 ].pointerId ) ? pointers[ 1 ] : pointers[ 0 ];
|
|
|
+ const pointerId = ( event.pointerId === pointers[ 0 ] ) ? pointers[ 1 ] : pointers[ 0 ];
|
|
|
|
|
|
- return pointerPositions[ pointer.pointerId ];
|
|
|
+ return pointerPositions[ pointerId ];
|
|
|
|
|
|
}
|
|
|
|