-
-
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: Fully migrate to pointer events. #21972
Conversation
@@ -24,7 +24,8 @@ | |||
if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' ); | |||
if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' ); | |||
this.object = object; | |||
this.domElement = domElement; // Set to false to disable this control | |||
this.domElement = domElement; | |||
this.domElement.style.touchAction = 'none'; // Set to false to disable this control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is problematic.
Ideally controls set touchAction
to none
in pointerdown
and undo the change in pointerup
event listeners. Defining touchAction
is necessary to make pointermove work on mobile.
DragControls
and TransformControls
do it this way. However, this approach does not work with OrbitControls
since the class adds an event listener to contextmenu
. It seems this listener prevents the usage of the above pattern since the pointermove
event listener still aborts after a short period of time. Removing the contextmenu
listener fixes the issue. This is however no appropriate solution since preventing the context menu is important for desktop.
Adding this.domElement.style.touchAction = 'none';
in the ctor makes OrbitControls
incompatible with TransformControls
though since the latter one resets the touchAction
value in its pointerup
event listener. One possible solution is to set touchAction
to none
in the ctor of OrbitControls
, DragControls
and TransformControls
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible solution is to set touchAction to none in the ctor of OrbitControls, DragControls and TransformControls.
Added this change with the last commit 9a4099f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the best solution to me 👍
Thanks! |
Brings orbit controls up to date after mrdoob/three.js#21972
Brings orbit controls up to date after mrdoob/three.js#21972
Brings orbit controls up to date after mrdoob/three.js#21972
Brings orbit controls up to date after mrdoob/three.js#21972
Related issue: -
Description
This change removes all
touch*
listeners fromOrbitControls
and migrates the logic to pointer event listeners.Handling multi-touch with pointer events is quite different compared to touch events since a single pointer event has no access to other pointers.
This PR also removes the calls of
preventDefault()
and introduces the usage oftouchAction
instead.