[w3c/pointerlock] Feature Request: Allow for a pointerevent-scoped pointerlock with less restrictions (Issue #81)

The current spec does not support temporary movements with pointer lock without major usability impact.

I request some functionality similar to the [MOZ-SetCapture](https://developer.mozilla.org/en-US/docs/Web/API/Element/setCapture) event which is summarized as
> Call this method during the handling of a mousedown event to retarget all mouse events to this element until the mouse button is released or [document.releaseCapture()](https://developer.mozilla.org/en-US/docs/Web/API/Document/releaseCapture) is called.

Which would be a great feature for use in web based CAD and 3D software, where the camera movement and rotation locked only on pointerdown events and released on pointer-up.

**Example** use-case which is not usable with the current implementation in browsers today, where we invoke canvas.RequestPointerLock() on PointerDown, and document.exitPointerLock() on PointerUp:

Edge (107.0.1418.62):
![pointer-lock-on-hold](https://user-images.githubusercontent.com/3185998/205599437-b00baf25-d52f-4909-9223-2c3d95ef7073.gif)

Firefox (107.0.1):
https://user-images.githubusercontent.com/3185998/205604546-71671070-55a3-4456-a0bf-39c721b6ba1d.mp4


This is not usable as implemented today, as a (in some browsers) quite large message will overlap the screen for the duration of most drag to look events. Also pressing Esc will trigger a cooldown for re-locking the cursor which is not observable, and this makes it impossible to know when rotation with pointerlock can start again.

The **feature request** would be: 
       - Allow for requestPointerLockUntilPointerRelease() in a pointerdown event only. (Names describe my intent. Not an API proposal)
       - Avoid displaying "Press esc to exit pointer lock" which is very prominent in the current PointerLock implementations (see screenshots below)
       - If Esc was pressed to cancel pointerlock while in a "auto-release" state it should not have a timeout before a pointer lock can be established again. (This does not exist in Firefox, but is limiting in Chrome)

I think this is highly relevant to support this use-case in the pointerlock v2 spec: [ยง 9.2 Free rotation of 3D models or panning of 2D layers](https://www.w3.org/TR/pointerlock/#free-rotation-of-3d-models-or-panning-of-2d-layers)

Feel free to close this issue if its out of scope. I wrote the issue as a data point to an improvement to the spec which can be very useful in 3D scenarios, and probably other Canvas based applications.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/pointerlock/issues/81

You are receiving this because you are subscribed to this thread.

Message ID: <w3c/pointerlock/issues/81@github.com>

Received on Monday, 5 December 2022 09:49:58 UTC