From 419f0e4117868e5c792b74b16c42cc5485e6b2c4 Mon Sep 17 00:00:00 2001 From: Erich Loftis Date: Mon, 25 Nov 2024 00:25:52 -0600 Subject: [PATCH] Delete js/FirstPersonCameraControls.js --- js/FirstPersonCameraControls.js | 101 -------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 js/FirstPersonCameraControls.js diff --git a/js/FirstPersonCameraControls.js b/js/FirstPersonCameraControls.js deleted file mode 100644 index 091094d..0000000 --- a/js/FirstPersonCameraControls.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * originally from https://github.com/mrdoob/three.js/blob/dev/examples/js/controls/PointerLockControls.js - * @author mrdoob / http://mrdoob.com/ - * - * edited by Erich Loftis (erichlof on GitHub) - * https://github.com/erichlof - * Btw, this is the most consice and elegant way to implement first person camera rotation/movement that I've ever seen - - * look at how short it is, without spaces/braces it would be around 30 lines! Way to go, mrdoob! - */ - -var FirstPersonCameraControls = function ( camera ) { - - camera.rotation.set( 0, 0, 0 ); - - var pitchObject = new THREE.Object3D(); - pitchObject.add( camera ); - - var yawObject = new THREE.Object3D(); - yawObject.add( pitchObject ); - - var movementX = 0; - var movementY = 0; - - var onMouseMove = function ( event ) { - - if (isPaused) - return; - movementX = event.movementX || event.mozMovementX || 0; - movementY = event.movementY || event.mozMovementY || 0; - - yawObject.rotation.y -= movementX * 0.0012 * cameraRotationSpeed; - pitchObject.rotation.x -= movementY * 0.001 * cameraRotationSpeed; - // clamp the camera's vertical movement (around the x-axis) to the scene's 'ceiling' and 'floor' - pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) ); - - }; - - document.addEventListener( 'mousemove', onMouseMove, false ); - - - this.getObject = function () { - - return yawObject; - - }; - - this.getYawObject = function () { - - return yawObject; - - }; - - this.getPitchObject = function () { - - return pitchObject; - - }; - - this.getDirection = function() { - - var te = pitchObject.matrixWorld.elements; - - return function( v ) { - - v.set( te[ 8 ], te[ 9 ], te[ 10 ] ).negate(); - - return v; - - }; - - }(); - - this.getUpVector = function() { - - var te = pitchObject.matrixWorld.elements; - - return function( v ) { - - v.set( te[ 4 ], te[ 5 ], te[ 6 ] ); - - return v; - - }; - - }(); - - this.getRightVector = function() { - - var te = pitchObject.matrixWorld.elements; - - return function( v ) { - - v.set( te[ 0 ], te[ 1 ], te[ 2 ] ); - - return v; - - }; - - }(); - -};