|
@@ -6,6 +6,8 @@ THREE.PointerLockControls = function ( camera ) {
|
|
|
|
|
|
var scope = this;
|
|
var scope = this;
|
|
|
|
|
|
|
|
+ camera.rotation.set( 0, 0, 0 );
|
|
|
|
+
|
|
var pitchObject = new THREE.Object3D();
|
|
var pitchObject = new THREE.Object3D();
|
|
pitchObject.add( camera );
|
|
pitchObject.add( camera );
|
|
|
|
|
|
@@ -118,6 +120,25 @@ THREE.PointerLockControls = function ( camera ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ 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 );
|
|
|
|
+
|
|
|
|
+ return v;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }();
|
|
|
|
+
|
|
this.update = function ( delta ) {
|
|
this.update = function ( delta ) {
|
|
|
|
|
|
if ( scope.enabled === false ) return;
|
|
if ( scope.enabled === false ) return;
|