Exploring the feasibility of using the orientation of the yaw object in pointer lock controls as a direction for a raycaster. I've been experimenting with adding some basic shooter functionalities to the code. Despite trying various methods from stack overflow involving the X & Y values from the yaw object provided by the pointer controls, I haven't had any success yet. Here's my current attempt:
setupTarget: function() {
//var vector = new THREE.Vector3(game.mouse.x, game.mouse.y, 0);
var yaw = game.controls.getObject();
var pitch = game.controls.pitchObject;
var vector = new THREE.Vector3(
yaw.position.x * Math.cos(pitch.rotation.x),
yaw.position.y * Math.sin(yaw.rotation.y),
0
);
var dir = vector.sub(yaw.position).normalize();
this.ray = new THREE.Raycaster(yaw.position.clone(), dir);
}
I'm aware that it's incorrect and not functioning properly. I mistakenly mixed up some calculations for translating x & y based on rotation, which obviously doesn't apply to the target.