fix: only rotate on pointerlock

This commit is contained in:
stitchy 2024-12-26 01:25:50 +00:00
parent 46fbf1e289
commit b63b7d2b3f
Signed by: stitchy
SSH key fingerprint: SHA256:yz2SoxdnY67tfY5Jzb0f2v8f5W3o/IF359kbcquWip8

View file

@ -51,7 +51,9 @@ function draw(gl, program) {
TIME += 1 / 60;
gl.uniform1f(loc, TIME);
if (document.pointerLockElement) {
updateCamera(gl, program);
}
// Draw the frame recursively on next frame
gl.drawArrays(gl.TRIANGLES, 0, 6);
@ -71,8 +73,10 @@ document.addEventListener("keyup", function (event) {
});
// Mouse movement
document.addEventListener("mousemove", function (event) {
if (document.pointerLockElement) {
mouse_pos[0] += event.movementX / 800;
mouse_pos[1] += event.movementY / 800;
}
});
// Request pointer Lock