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

[FEATURE] Add support for Pointer Lock Web API #1445

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

Kurtil
Copy link
Contributor

@Kurtil Kurtil commented Apr 18, 2024

I'm developing a product in which the pointer is locked during the camera update when the first-person view is activated.

pointerLocked

On the GIF, the pointer does not move because it is locked. It lets you update the camera without moving the pointer and risking losing it in a corner of the screen.

To lock the pointer, I use the Pointer Lock WebAPI.

viewer.scene.canvas.canvas.requestPointerLock();

Issue: The mouse pan/rotate/dolly handler uses the pointer canvas position to update the camera control state but when the pointer is locked, the pointer does not move.

Solution : This PR check if the pointer is locked with document.pointerLockElement and if so, the MouseEvent<"mousemove"> movementX and movementY properties are used instead of the real pointer canvas position.

@Kurtil Kurtil changed the title add support for pointer lock Web API Feature - Add support for Pointer Lock Web API Apr 18, 2024
@xeolabs xeolabs merged commit a57bdf6 into xeokit:master Apr 18, 2024
1 of 2 checks passed
@xeolabs
Copy link
Member

xeolabs commented Apr 18, 2024

Thanks @Kurtil - could you please also add an example of how to use pointer lock? Would be great for our testing/QA - maybe copy this example: https://github.com/xeokit/xeokit-sdk/blob/master/examples/navigation/CameraControl_firstPerson_MAP.html

@Kurtil
Copy link
Contributor Author

Kurtil commented Apr 18, 2024

Ok @xeolabs , I'll add an example.

@Kurtil Kurtil deleted the patch-18 branch April 18, 2024 13:56
@xeolabs xeolabs added this to the 2.6.0 milestone Apr 21, 2024
@xeolabs xeolabs changed the title Feature - Add support for Pointer Lock Web API [FEATURE] Add support for Pointer Lock Web API Apr 21, 2024
@Kurtil
Copy link
Contributor Author

Kurtil commented Apr 22, 2024

Is this ok @xeolabs ? :) It was very simple so I do not recreate another example.

@xeolabs
Copy link
Member

xeolabs commented Apr 22, 2024

Yeah that great, thanks @Kurtil

@xeolabs
Copy link
Member

xeolabs commented Apr 22, 2024

@Kurtil I just moved the example into it's own page, just to highlight the feature a bit. It's a cool feature!
#1456

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.

None yet

2 participants