ArcRotateCamera updating target behaves differently when using add or addInPlace


I was updating just the target of a ArcRotateCamera, by calling: =; // where offset is a Vector3

But when doing this, the alpha and beta of the camera was also changing.

Replacing the add with addInPlace, it works as expected (alpha an beta are note changed):; // where offset is a Vector3

See the problem in playground (open the console to see the alpha/beta changing):

Using addInPlace solved my the problem, but shouldn’t using add() have the same behaviour as addInPlace() in this case? Is this a bug?

They do not have the same behavior cause target is a property internally calling into setTarget when set which is not the case when you update the values internally only.

Changing the values only will actually not update the angles which is usually the desired behavior when moving a target.

1 Like

Hi @Rafael_Ceravolo just checking in if Seb’s explanation made things clear for you :smiley:

As per my experience, I can confirm ‘setTarget’ (to set a new target with new alpha, beta and radius) should be used (and works perfectly).

Yes, It made sense.

In my case, I didn’t want the usual behaviour, I wanted to pan the camera to a new target, but keeping the same angles, so updating the target inplace worked fine.

Thanks for the followup!

1 Like