Position issue with ArcRotateCamera on babylonjs 4

encountered some issue when testing babylon 4 alpha version (25).
Created small example but could not reproduce issue there.

So for me after updating camera target position, camera don’t update. Managed to find out that absolute position of camera target is not updated its still 0,0,0.

After trying to access it to log out it is updated and camera jumps to correct position.

This issue / fix was introduced between alpha version 2 and 3.

Any ideas ?

Thank you.

Hi @Hersir

I think you confused Mesh.CreateBox with MeshBuilder.CreateBox
The Mesh constructor doesn’t take options object.


But i’m unable to reproduce your issue, are you sure you’re using the latest alpha? (maybe browser cache?)
There was a bug in the arcRotateCamera a few days ago which was fixed.

Hi, @aWeirdo yes fixed typo, but it was not impacting anything.

I use babylon 4 alpha 25 from npm and this bug is there since babylon 4 alpha 3 from npm

I cannot repro on the PG either so this could be related to the error I fixed recently.
Can you confirm that you repro in the PG linked by @aWeirdo ?

I think I have also this issue on one of two scene after updating to the latest alpha.
The setPosition value are a bit off when they are launched from the code. If I reapply them everything is fine.

I will investigate this further tomorrow.



Just took some time to check it.
I think the issue comes from the setTarget function.

If the target is something else than a Vector3.Zero() there is some changes.
You can see what’s happening with the pg just by commenting the setTarget or not.

Hope this help :slight_smile:

So far your PG seems to work ok for me:)

You call setTarget which means that the camera is locked on a target.
Then you move it so the camera will rotate to keep the target in the center of the screen

Whate are you seeing wrong in your PG? Or waht would have you expected to see?

I use the same value with both setPosition().
We shouldn’t have a difference between the two.

If you comment setTarget() in the playground the result is the same for both setPosition call.

That’s why I thought there was a bug with the use of setTarget()

1 Like

oh woot! yeah… Didn’t see that

Let me check what is wrong

Bug will be fixed with next nightly!

thanks for reporting it!

1 Like

Thank you !

You are the best :slight_smile:

Keeping the discussion here:)


What I think is strange is that putting the same values give a different result.
But I understand the calculation you make.

Here first setting the target then the position give the expected result.

For me the setTarget should only rotate the camera, not changing it’s position.

This is a new behavior so that’s why I’m surprised as one application is not working properly because of this.
I can just set the target before the position but I’m not sure why doing one first should have an incidence to the other one if the base values are the same.

At least I have a solution, let me know what you think.

The problem is that it was not working correctly before :slight_smile: And I fixed it thus what we see now
Internally the ArcRotateCamera only has 3 values: alpha, beta and radius. If we want to keep the previous position when calling setTarget we will need to save the vector3 and not jsut the alpha, beta and radius

This is not impossible of course but not sure it is worth it

Okay, let’s leave it it that way then.
I have to rethink the way I move my cameras :p.

If you have an idea how to simplify it please let me know and I’ll add it !

I fixed the camera animation in my code.

For me when I think setTarget I expect it to work like a look at in 3ds Max.
I think it’s just because I’m used to work in a way that I expect it to work like that.
I don’t know if it’s the best method but that’s why I was surprised to see it work that way.

I don’t know if I will be the only one :slight_smile:

1 Like