I am facing an issue with rotating several randomly generated boxes towards the mouse position. Even after trying to use lookAt(mouse3D)
method, the boxes do not change their rotation as expected. My goal is to have the boxes rotate towards the mouse position on the screen, rather than within the 3D space.
To obtain the mouse position, I currently use the following code:
function onDocumentMouseMove( event ) {
mouse3D = new THREE.Vector3(
( event.clientX / window.innerWidth ) * 2 - 1,
- ( event.clientY / window.innerHeight ) * 2 + 1,
camera.position.z );
}
I came across an example that might help solve my problem:
To illustrate my current approach, I have created a JSFiddle: