3

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 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. I'm quite frankly surprised that my googling didn't find that function!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.