-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mrdoob has a tendency to put lines inbetween lines, I feel like there's too many lines to be efficient while editing his classes, so I removed them
- Loading branch information
1 parent
4bda8e1
commit fbb8665
Showing
2 changed files
with
27 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,44 @@ | ||
/** | ||
* @author mrdoob / http://mrdoob.com/ | ||
*/ | ||
|
||
THREE.PointerLockControls = function ( camera ) { | ||
|
||
THREE.PointerLockControls = function(camera) { | ||
var scope = this; | ||
|
||
camera.rotation.set( 0, 0, 0 ); | ||
|
||
camera.rotation.set(0, 0, 0); | ||
var pitchObject = new THREE.Object3D(); | ||
pitchObject.add( camera ); | ||
|
||
pitchObject.add(camera); | ||
var yawObject = new THREE.Object3D(); | ||
yawObject.position.y = 10; | ||
yawObject.add( pitchObject ); | ||
|
||
yawObject.add(pitchObject); | ||
var PI_2 = Math.PI / 2; | ||
|
||
var onMouseMove = function ( event ) { | ||
|
||
if ( scope.enabled === false ) return; | ||
|
||
var onMouseMove = function(event) { | ||
if (scope.enabled === false) | ||
return; | ||
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0; | ||
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0; | ||
|
||
yawObject.rotation.y -= movementX * 0.002; | ||
pitchObject.rotation.x -= movementY * 0.002; | ||
|
||
pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) ); | ||
|
||
pitchObject.rotation.x = Math.max(-PI_2, Math.min(PI_2, pitchObject.rotation.x)); | ||
}; | ||
|
||
this.dispose = function() { | ||
|
||
document.removeEventListener( 'mousemove', onMouseMove, false ); | ||
|
||
}; | ||
|
||
document.addEventListener( 'mousemove', onMouseMove, false ); | ||
|
||
document.removeEventListener('mousemove', onMouseMove, false); | ||
} | ||
; | ||
document.addEventListener('mousemove', onMouseMove, false); | ||
this.enabled = false; | ||
|
||
this.getObject = function () { | ||
|
||
this.getObject = function() { | ||
return yawObject; | ||
|
||
}; | ||
|
||
} | ||
; | ||
this.getDirection = function() { | ||
|
||
// assumes the camera itself is not rotated | ||
|
||
var direction = new THREE.Vector3( 0, 0, - 1 ); | ||
var rotation = new THREE.Euler( 0, 0, 0, "YXZ" ); | ||
|
||
return function( v ) { | ||
|
||
rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 ); | ||
|
||
v.copy( direction ).applyEuler( rotation ); | ||
|
||
var direction = new THREE.Vector3(0,0,-1); | ||
var rotation = new THREE.Euler(0,0,0,"YXZ"); | ||
return function(v) { | ||
rotation.set(pitchObject.rotation.x, yawObject.rotation.y, 0); | ||
v.copy(direction).applyEuler(rotation); | ||
return v; | ||
|
||
}; | ||
|
||
} | ||
; | ||
}(); | ||
|
||
}; | ||
} | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters