9
votes

I need to set the initial 'lookAt' point of the scene, that will be the center of the screen and of the control's rotation. If possible, I would prefer to set a point (or an object's position), not rotation angles.

The control is OrbitControl. If I simply set lookAt before the Control initialization, the center is restored to (0,0,0) on the first user interaction, which causes a 'gap' ...

// camera
camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 0.1, 20000);
camera.position.set(0,20,20);
camera.lookAt(new THREE.Vector3(0,10,0));

// controls
controls = new THREE.OrbitControls( camera );
controls.addEventListener( 'change', render );

How can I set the initial point in a proper way?

2

2 Answers

20
votes

Try setting the control's target and remove the camera.lookAt call:

controls.target = new THREE.Vector3(0, 10, 0);
controls.update();
13
votes

Or more directly : controls.target.set(0, 10, 0);