I am working on calculating the orientation value between two objects in three.js. My goal is to assign a value of 1 when one object is directly facing another and -1 when it is facing directly away.
Although I have the object's global position and quaternion for orientation, I am not getting the expected numbers with my current approach.
My current method involves storing the object orientation as a 3-part vector:
const lookVector = new THREE.Vector3(0,0,1);
const direction = lookVector.clone().applyMatrix4(torsoMesh.matrix);
this.lookVector = direction.sub(this.worldPosition);
Then, I use this vector to calculate the angle to another specified point:
angleTo(pointOfInterest){
const vectorToPOI = pointOfInterest.sub(this.worldPosition);
const angle = this.lookVector.angleTo(vectorToPOI);
return angle;
}