Clamp camera rotx and fix motion

This commit is contained in:
Paul Mathieu 2021-12-17 06:14:16 -08:00
parent 7503922451
commit ed43c9ea5c

View File

@ -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) {