diff --git a/index.js b/index.js index 91352d4..feff417 100644 --- a/index.js +++ b/index.js @@ -103,8 +103,7 @@ const stuff = { function handleKeys(params) { const move = (forward, right) => { const dir = [right, 0, -forward, 1.0]; - const camori = params.camera.orientation; - const ori = se3.rotxyz(...camori); + const ori = se3.roty(params.camera.orientation[1]); const tf = se3.apply(ori, dir); if (params.flying) { @@ -439,6 +438,10 @@ async function main() { const moveListener = e => { params.camera.orientation[1] -= e.movementX / 500; params.camera.orientation[0] -= e.movementY / 500; + + params.camera.orientation[0] = Math.min(Math.max( + params.camera.orientation[0], -Math.PI / 2 + ), Math.PI / 2); }; const changeListener = () => { if (document.pointerLockElement === canvas) {