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?
1 Answer
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
1 Comment
hyperneutrino
Wow. I'm quite frankly surprised that my googling didn't find that function!