I'm using FlyControls.js
for my camera view
I'm trying to add a projectile
to my object
The projectile should use the angles from camera position, to crosshair/reticle position, and flow freely through 3D space
I've tried to use camera.position.angleTo(crosshair.position)
but it only returns a single float value. In 2D I'd use sin
and cos
, but 3D is different
Also, the projectile is a cylinder
, how would I rotate the cylinder to face the direction it's going?
//how to get this information?
projectile.angle = {
x: ?,
y: ?,
z: ?,
};
//how to get this information?
projectile.rotation = faceTowardsDestination;
function animate(){
//projectile movement
projectile.position.x += projectile.angle.x * projectile.speed;
projectile.position.y += projectile.angle.y * projectile.speed;
projectile.position.z += projectile.angle.z * projectile.speed;
requestAnimationFrame(animate);
}
Projectile (cylinder) should fire from spaceship, towards the crosshair point, and point towards it's destination