three.js

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 ?


Solution

  • 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