In Javascript THREE.js, given the coordinates of the camera and the coordinates of a point (x, y, z), how would I rotate the camera to look directly at the point?
You can make the camera "look at" a world-space point by using the lookAt() method, like so:
var point = new THREE.Vector3( x, y, z );
camera.lookAt( point );
Note: This method is limited, in that it will not work correctly if the camera is a child of another rotated or translated parent object. However, if the camera has no parent, or if the camera is a child of the scene directly, then the method will work as expected.
three.js r.71
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With