Three Js, Get The Vector3 That Pointerlockcontrolsi S Facing
Wondering if it's possible to get the way the yaw object in pointer lock controls is facing and use that as a direction for a raycaster. I've been toying around with the code, tryi
Solution 1:
Add the following to your copy of PointerLockControls
( or wait a few days for the next release):
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;
}
}();
three.js r.59
Solution 2:
Well, with the new Version it do not work. I have to add
var v = new THREE.Vector3( 0, 0, -1 );
before
v.copy( direction ).applyEuler( rotation );
because Firefox do not recognize v.
Post a Comment for "Three Js, Get The Vector3 That Pointerlockcontrolsi S Facing"