-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrbitControls: update state on pointer up #27425
Conversation
Signed-off-by: Guilherme Avila <[email protected]>
Is it possible to demonstrate this issue with a mobile phone? TBH, I have not experienced an issue in this context so far. Is there something specific I has to do in order to reproduce the unresponsiveness? |
I can definitely reproduce what this PR fixes.
Without this PR the camera no longer moves even if one finger is still touching: With this PR we are back in orbit mode: |
What mrdoob described is precisely the use case being fixed here. 👍🏽 |
@sciecode What do you think of this version? function onPointerUp( event ) {
removePointer( event );
switch ( pointers.length ) {
case 1:
if ( event.pointerType === 'touch' ) {
const pointerId = pointers[ 0 ];
const position = pointerPositions[ pointerId ];
// minimal placeholder event - allows state correction on pointer-up
onTouchStart( { pointerId: pointerId, pageX: position.x, pageY: position.y } );
}
break;
case 0:
scope.domElement.releasePointerCapture( event.pointerId );
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
scope.dispatchEvent( _endEvent );
state = STATE.NONE;
break;
}
} Your code dispatches a |
Sure, I actually wasn't certain if we should invoke an But I don't understand why we need to validate for Mouse events would never reach the case where there are more than 1 pointer active. Perhaps I misunderstood something? Hmm, I just noticed we only treat |
It just makes the code easier to understand IMHO. |
Signed-off-by: Guilherme Avila <[email protected]>
Currently, whenever a 2-touch event is in progress and only one 1 pointer is removed, the controls won't properly re-initiate the configured 1-touch event; which leads to unresponsiveness.
This PR addresses this issue, by properly re-initiating states when necessary. At first I thought this could be related to #27333. Although, I'm not too sure anymore.
If anyone with compatible devices could test, I would appreciate it. I would like to investigate that issue, but I can only speculate as to the causes without access to a device that can replicate it.
Live Example - PR
https://rawcdn.githack.com/sciecode/three.js/ec4b8f713bf4cc5238e5c66e5b5d8c66191fe5f7/examples/misc_controls_orbit.html