-
-
Notifications
You must be signed in to change notification settings - Fork 388
Description
Pointer lock hides your cursor, and makes it so you can move your mouse "infinitely"
see https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API
Virtual mouse module currently uses clientX and clientY from the patched event. When pointer lock is on, those values stick to what they were when pointer lock was enabled, and instead movementX and movementY values are provided. (which are deltas and not absolutely values - combined with your "starting x/y" you can construct absolute values)
You can test this by setting it up so that pointer lock is turned on with a click on canvas. If you click to enable pointer lock while over a component who is emitting click events, that component will be clicked, then you can move your mouse around and click again, and the component will be clicked again.
It is possible to have your mouseX and mouseY go to any size the user desires. But if we by default just limit it to screen size, then can just generate our own mouseX and mouseY based on mouseX/Y += movementX/Y and have it so that it does not increment/decrement if on edge of screen. Then pointer lock'ed mouse's x/y values will behave same as clientX/Y and it should work with existing virtual mouse code. But maybe locking to screen size will not work with FPS controls which use pointer lock. Can do some interesting things, like wrap mouse around as in the mozilla example, or "extend beyond the page width/height" - in which case how could raycaster continue to work?
Will also need to include pointer lock browser prefixes.
Version:
- v2.x.x
- v1.x.x
Issue type:
- Bug
- Proposal/Enhancement
- Question
Tested on:
Desktop
- Chrome
- Chrome Canary
- Chrome dev-channel
- Firefox
- Opera
- Microsoft IE
- Microsoft Edge
Android
- Chrome
- Firefox
- Opera
IOS
- Chrome
- Firefox
- Opera