Skip to content
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: Implement Pointer Events. #20161

Merged
merged 1 commit into from
Aug 23, 2020
Merged

OrbitControls: Implement Pointer Events. #20161

merged 1 commit into from
Aug 23, 2020

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Aug 23, 2020

When using mousedown, mousemove and mouseup, event.clientX and event.clientY are integers. In HiDPI (Retina) displays sometimes the cursor moves but the camera doesn't.

When using pointerdown, pointermove and pointerup (supported even in IE11) these properties are floats and manipulating the scene is snappier.

You can try the change by dragging the scene very slowly:

http://raw.githack.com/mrdoob/three.js/r119/examples/webgl_animation_cloth.html
http://raw.githack.com/mrdoob/three.js/dev/examples/webgl_animation_cloth.html

@Mugen87 We should definitely implement this in all relevant controls.

We could also use Pointer Events for touch too but we currently rely in event.touches which Pointer Events don't have.

@mrdoob mrdoob added this to the r120 milestone Aug 23, 2020
@mrdoob
Copy link
Owner Author

mrdoob commented Aug 23, 2020

/cc @WestLangley

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 23, 2020

Related issue: #4015

The difference is really noticeable 😳.

We should definitely implement this in all relevant controls.

Agreed! It should be DragControls, FirstPersonControls, EditorControls, FlyControls, PointerLockControls, TrackballControls and TransformControls.

@mrdoob mrdoob merged commit 5b96c2a into dev Aug 23, 2020
@mrdoob mrdoob deleted the controls branch August 23, 2020 17:33
@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 24, 2020

I've noticed right now that the event data movementX and movementY are still integers when using pointermove. Should we still introduce Pointer Events to PointerLockControls?

@mrdoob
Copy link
Owner Author

mrdoob commented Aug 24, 2020

movementX and movementY do not seem to work on Safari 😕

At least it the Resizer code doesn't seem to work.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 24, 2020

Yeah, I see it now too. PointerLockControls would be broken in Safari after this change. Okay, let's leave this class out for now.

@marcofugaro
Copy link
Contributor

Nice! I like this improvement.

We could also use Pointer Events for touch too but we currently rely in event.touches which Pointer Events don't have.

For Pointer Events the pattern is different, you'd have to keep track yourself of how many pointerdown events happened, say with a counter that increases when a pointerdown event happens and decreases on pointerup/pointerleave.

Read more about it here: https://stackoverflow.com/questions/50955861/detect-two-finger-touch-with-pointerevents-on-the-same-target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants