Switch between FreeCamera and ArcRotateCamera

Hello everyone,
I’ve made this playground for switching betweend FreeCamera and ArcRotateCamera on double click.
I am wondering if i can remove or reduce the movement exactly when the camera is being switched.
e.q. this is happening when you move camera and right after make a switch.


Here: https://www.babylonjs-playground.com/#2FY4XT#16 . Does this help? if you detach the control from the previous camera, it works as expected.

Also, a small recommendation - try avoiding using global events in the playground, since they are not removed when you execute the playground again. You can remove them on scene dispose, but why do that when all babylon observers / events are removed every time you run the scene :slight_smile:


Thank you, this is working like I needed :slight_smile:

@RaananW Also, a small recommendation - try avoiding using global events in the playground

sure, I’ll pay attention to this!

1 Like

@RaananW After testing my application I came up with another idea. Would be easy to switch camera and start with the same position?
I mean camera when being switched don’t go back to it’s old position but use the position of the second one.

of course :slight_smile:

You have the reference of both cameras exist, their position is there to use, both have a setPosition method. Would work!

1 Like


Thanks for your answer.

I’ve made this working good when switching ArcRotateCamera=> FreeCamera. I also added setTarget because I wanted to save what observer is looking at (sorry for my terminology, I am new in it :slight_smile: )

It doesn’t seem working on FreeCamera => ArcRotateCamera tho. Because the target of ArcRotateCamera becomes position of the observer and not the object.

The target of an arc rotate camera is fixed (unless you change it while using the camera). So the important thing is to use the position. The target of the old camera didn’t change, so keeping target as it is during this transition should work

1 Like