From b63b7d2b3f4644069d51ea08ed34332d6502d5e9 Mon Sep 17 00:00:00 2001 From: stitchy Date: Thu, 26 Dec 2024 01:25:50 +0000 Subject: [PATCH] fix: only rotate on pointerlock --- main.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.mjs b/main.mjs index 3177ed0..ab1f019 100644 --- a/main.mjs +++ b/main.mjs @@ -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