Forrest
Forrest

Reputation: 157

How to keep camera rotation pointed at origin while moving its position in three.js?

So I want to move my cameras position around in three.js, but as I move it, I want the cameras rotation to automatically update to point at the origin.

So if i have the camera set as:

 camera.position.set(25,25,25)

I would like the camera.rotation to be updated so that it is facing the world origin.

Upvotes: 0

Views: 690

Answers (1)

danlong
danlong

Reputation: 900

You can set the camera to look at or target a specific position in your scene but using the lookAt() method - https://threejs.org/docs/#api/en/core/Object3D.lookAt

In this case, setting camera.lookAt(0,0,0) will point to the centre of the 'world'.

Upvotes: 1

Related Questions