Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js | OrbitControls | How to change center?

Tags:

three.js

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 ?

like image 720
Treize Cinq Avatar asked May 12 '16 16:05

Treize Cinq


1 Answers

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

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

like image 52
WestLangley Avatar answered Jan 04 '23 16:01

WestLangley