I have been searching for a solution to this particular issue and have come across two responses that are either outdated or do not provide the necessary THREE related code.
question and question
My desired outcome is to have the clicked point facing the camera!
if (intersects.length > 0) {
var point = intersects[0].point;
//console.log(point);
var a = new THREE.Vector3(0,0,1);
var b = point.normalize();
var rotationAxis = new THREE.Vector3(0, 0, 0);
rotationAxis.crossVectors(b, a);
var dot = a.dot(b);
var angle = Math.acos(dot);
var quaternion = new THREE.Quaternion();
var dest = quaternion.setFromAxisAngle(rotationAxis, angle);
sphere.setRotationFromQuaternion(dest);
}
UPDATE:
I have been attempting to translate the calculations from the first response into threejs, and while it's close, there seems to be a slight discrepancy in the rotation degrees. Could you help me pinpoint where the error lies?
Initial position - 0,0,1 https://i.sstatic.net/yAbR4.png
After clicking on a point https://i.sstatic.net/51zOt.png