I have an ArcRotate camera with position and rotation. Now I have to exchange this camera with a FreeCamera for my application. How can I convert the current position and rotation to have the same position in the FreeCamera?
Thanks for the support!
Hi bestog… welcome.
I don’t necessarily have a solution, but I did some testing in a BabylonJS Playground.
It doesn’t “switch back and forth” (toggle) very well. It only changes from arcCam to freeCam… fairly smoothly… ONCE.
I set freeCam2 parent == arcCam1, and then I set both cameras to the same lockedTarget… UNTIL the freeCam is chosen.
When freeCam selected, line 81 removes the .lockedTarget for freeCam… so its mouse-panning will work.
Control-dragging is NOT working on the arcCam, which concerns me. Perhaps I need to use the .target instead of .lockedTarget. Not sure why control-drag is failing. (control-drag slides-around the arcCam orbital target/center)
It’s something you can play-with… test, try things, save more playgrounds, and come here and talk about your new saves. I’m not a pro, so let’s watch-for wiser comments and more playgrounds (while you and I talk, if wanted).
Something like that should work:
newCamera.position = oldCamera.position.clone();
@Deltakosh And how does the conversion from freecamera to arcrotate look like?
https://www.babylonjs-playground.com/#A4HF3#16 Why not use that playground… to test “look like”?
Install deltakosh’s code into that playground, and test with RUN button. Adjust and then test more.