Controls.target vs camera.lookAt

Hi,

I have few questions related to OrbitControls.

Before using it, I used camera.lookAt() to set direction in which camera looks.
Reading on OrbitControls, I learnt that camera.lookAt() should be replaced by controls.target.

I want to know what’s difference between these two.

I am also facing an issue with OrbitControls.
If I don’t make use of controls.target, then it becomes very difficult to zoom in to my target object.
And when I use it, zooming issue is solved but panning becomes an issue as target object doesn’t pan with rest of the scene and it is static while panning.

2 Likes

OrbitControls internally uses Object3D.lookAt() in order to look at the defined target location of focus (OrbitControls.target).

That’s the intended behavior since panning transforms the OrbitControls.target vector. Or in other words, the location of focus.

3 Likes

And does it mean that rotation and zooming also happens with focus on target?

Yes. OrbitControls ensures that the camera orbits (rotates) around the target. Zooming/dollying is also focused on the defined target vector.

2 Likes

@Mugen87 how would you adjust the center of rotation after a pan? I have tried using controls.target.set() , but the center of rotation for the object remains unchanged.

You also have to call controls.update() after changing the target.

2 Likes

Hey By the way I was looking at this thingy and I’m wondering how do you stop the auto rotate and keep the camera to stay in place whilst following the object so my movement script can work better because the camera rotates which makes my movement script going in circles when the " camera.rotation.y " code interferes with it?