# Position issue with ArcRotateCamera on babylonjs 4

**URL:** <https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250>\
**Category:** Bugs\
**Created:** [February 8, 2019, 11:44am UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250 "2019-02-08T11:44:12Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hersir](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hersir/32/108_2.png) [@Hersir](https://forum.babylonjs.com/u/Hersir)\
**Post date:** [February 8, 2019, 11:44am UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/1 "2019-02-08T11:44:12Z")

</div>

Hi,  
encountered some issue when testing babylon 4 alpha version (25).  
Created small example but could not reproduce issue there.  
[PG](https://www.babylonjs-playground.com/index.html#3HRWMF#2)

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.

---

<div class="post-metadata">

**Author:** ![aWeirdo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aweirdo/32/52_2.png) [@aWeirdo](https://forum.babylonjs.com/u/aWeirdo)\
**Post date:** [February 8, 2019, 1:19pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/2 "2019-02-08T13:19:58Z")

</div>

Hi @Hersir

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

[https://www.babylonjs-playground.com/index.html#3HRWMF#1](https://www.babylonjs-playground.com/index.html#3HRWMF#1)

–  
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.

---

<div class="post-metadata">

**Author:** ![Hersir](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hersir/32/108_2.png) [@Hersir](https://forum.babylonjs.com/u/Hersir)\
**Post date:** [February 8, 2019, 2:17pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/3 "2019-02-08T14:17:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 8, 2019, 3:17pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/4 "2019-02-08T15:17:19Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 12, 2019, 5:13pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/5 "2019-02-12T17:13:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 14, 2019, 1:31pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/6 "2019-02-14T13:31:52Z")

</div>

Alright,

Just took some time to check it.  
[https://www.babylonjs-playground.com/index.html#3HRWMF#5](https://www.babylonjs-playground.com/index.html#3HRWMF#5)  
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 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 14, 2019, 2:59pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/7 "2019-02-14T14:59:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 14, 2019, 4:14pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/8 "2019-02-14T16:14:38Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 14, 2019, 5:17pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/9 "2019-02-14T17:17:11Z")

</div>

oh woot! yeah… Didn’t see that

Let me check what is wrong

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 14, 2019, 5:38pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/10 "2019-02-14T17:38:18Z")

</div>

Bug will be fixed with next nightly!

thanks for reporting it!

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 15, 2019, 8:02am UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/11 "2019-02-15T08:02:58Z")

</div>

Thank you !

You are the best 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 21, 2019, 4:15pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/12 "2019-02-21T16:15:38Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/1X/cba8d72de53353c40fb217b14c9d7312b36ed978.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 21, 2019, 4:15pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/13 "2019-02-21T16:15:51Z")

</div>

Keeping the discussion here:)

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 21, 2019, 6:12pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/14 "2019-02-21T18:12:23Z")

</div>

Alright,

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.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 21, 2019, 9:57pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/15 "2019-02-21T21:57:38Z")

</div>

The problem is that it was not working correctly before 🙂 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

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 22, 2019, 8:49am UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/16 "2019-02-22T08:49:57Z")

</div>

> [@Deltakosh](#):
>
> worth

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

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 22, 2019, 4:17pm UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/17 "2019-02-22T16:17:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [February 25, 2019, 9:14am UTC](https://forum.babylonjs.com/t/position-issue-with-arcrotatecamera-on-babylonjs-4/1250/18 "2019-02-25T09:14:14Z")

</div>

> [@Deltakosh](#):
>
> setTarget

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 🙂
