The function below works perfectly for orienting objects towards the user's cursor, if the object is centered at world origin, but it does not work otherwise.
function onMouseMove( e ) {
var mouse3D = new THREE.Vector3(
( event.clientX / window.innerWidth ) * 2 - 1,
- ( event.clientY / window.innerHeight ) * 2 + 1,
0.5);
eyes.forEach(function(element, index, array) {
element.lookAt(mouse3D);
})
}
How would I go about offsetting the lookat target (mousePosition3D) to work with non world origin objects? Is there a better way of getting a bunch of randomly placed objects orienting towards the user's cursor?