I am currently working on a first-person shooter using three.js and pointerlockcontrols.
With the following code, I'm able to shoot in any horizontal direction:
var direction = new THREE.Vector3( 0, 0, -1 );
var rotation = new THREE.Euler( 0, 0, 0, "XYZ" );
var cameraDirection = new THREE.Vector3(this.game.usermodel.root.children[0].position.x, this.game.usermodel.root.children[0].rotation._x, this.game.usermodel.root.children[0].position.z);
cameraDirection.copy( direction ).applyEuler( this.game.user.rotation );
var raycaster = new THREE.Raycaster(this.game.usermodel.root.children[0].position, cameraDirection);
However, my current implementation neglects the y-axis. The following line represents the pitch rotation:
this.game.usermodel.root.children[0].rotation._x
How can I incorporate this value to allow shooting along the y-axis (vertically in any direction) as well? As it stands now, the bullet only travels in a straight line.
I appreciate any help or guidance you can provide. Thank you!