YCP-Swarm-Robotics-Capstone-2020-2021 / swarm-website-visualization

Visualization Software for Swarm Website
1 stars 0 forks source link

Canvas pointer lock #35

Closed Mnenmenth closed 3 years ago

Mnenmenth commented 3 years ago

The pointer lock API allows a mouse to be contained within a specific html element, which in this case is the canvas/render target. It would be good for controlling the camera without requiring constant clicking and dragging to look around.

https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API

Mnenmenth commented 3 years ago

Since the pointer lock request tied to a focus event, if the user exits the pointer lock with the escape key (or something else) then the canvas has to be come unfocused before another focus event that triggers the pointer lock event can occur.

A possible solution could be to set the pointer lock request to the canvas' onclick event instead. Something important to note with this though: Right above the render_func section in lib.rs there's a block of code that controls the camera's pitch and yaw (where it looks) with the mouse. Currently it requires that the left mouse button is held down while the mouse is moving for the camera to be able to look around, which triggers the onclick event every time.