Clamp camera rotx and fix motion
This commit is contained in:
		
							
								
								
									
										7
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								index.js
									
									
									
									
									
								
							@@ -103,8 +103,7 @@ const stuff = {
 | 
				
			|||||||
function handleKeys(params) {
 | 
					function handleKeys(params) {
 | 
				
			||||||
    const move = (forward, right) => {
 | 
					    const move = (forward, right) => {
 | 
				
			||||||
        const dir = [right, 0, -forward, 1.0];
 | 
					        const dir = [right, 0, -forward, 1.0];
 | 
				
			||||||
        const camori = params.camera.orientation;
 | 
					        const ori = se3.roty(params.camera.orientation[1]);
 | 
				
			||||||
        const ori = se3.rotxyz(...camori);
 | 
					 | 
				
			||||||
        const tf = se3.apply(ori, dir);
 | 
					        const tf = se3.apply(ori, dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (params.flying) {
 | 
					        if (params.flying) {
 | 
				
			||||||
@@ -439,6 +438,10 @@ async function main() {
 | 
				
			|||||||
        const moveListener = e => {
 | 
					        const moveListener = e => {
 | 
				
			||||||
            params.camera.orientation[1] -= e.movementX / 500;
 | 
					            params.camera.orientation[1] -= e.movementX / 500;
 | 
				
			||||||
            params.camera.orientation[0] -= e.movementY / 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 = () => {
 | 
					        const changeListener = () => {
 | 
				
			||||||
            if (document.pointerLockElement === canvas) {
 | 
					            if (document.pointerLockElement === canvas) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user