fix: only rotate on pointerlock
This commit is contained in:
parent
46fbf1e289
commit
b63b7d2b3f
1 changed files with 4 additions and 0 deletions
4
main.mjs
4
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
|
||||
|
|
Loading…
Reference in a new issue