Treize Cinq
Treize Cinq

Reputation: 425

Three.js | OrbitControls | How to change center?

In three.js How to set the center of the camera orbit ? (with OrbitControls)

Egg : I want to use

camera.lookAt(new THREE.Vector3( 100,50,200 )

and make my camera orbit around this point and not around 0,0,0

How to set ?

Upvotes: 11

Views: 11049

Answers (1)

WestLangley
WestLangley

Reputation: 104783

You can set the center of rotation for OrbitControls like so:

const controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.target.set( x, y, z );

The Vector3 target is the center of rotation, and the point the camera "looks at".

three.js r.76

Upvotes: 23

Related Questions