Jump to content

Smooth transition between camera control systems...


Recommended Posts

Hi all.

I am trying to transition between Universal and ArcRotate cameras seamlessly, but haven't been able to figure it out. I want the cameras to show the exact same scene at the time of the switch, and all I really need to change is the control system so I can go from freely flying around to orbiting an object when you select it, and then back to free flight when you deselect it.

I have a playground with two spheres you can select and the cameras automatically switch, and you can deselect them by clicking them again. As you will see, if you move the cameras around at all the switch between them gets real janky and sometimes you can't even see the spheres after a switch, even though I am trying to sync the camera positions and targets as best as I know how. I must be missing something.

Here is the PG: http://www.babylonjs-playground.com/index.html#VDZ7IF#1

Thanks a lot in advance!

Link to comment
Share on other sites

Thanks Deltakosh,

I tried your playground and it is better but it still doesn't seem to behave correctly. If you select a sphere to switch to the orbit camera, and then rotate the the camera around a fair bit, then deselect the sphere, the view changes when the camera switches again. i would like the view to stay the same. Is there any way to accomplish this?

Thanks again.

Link to comment
Share on other sites


Thank you so much. That's exactly what I needed. I looked around the documentation and tutorials to help me solve this but didn't find anything that helped. Is this an area that is not documented well or did I just not find it? I guess I am talking about the seTarget function mainly, as  I have no idea what it does differently than simply setting the target property, etc. I have the same question regarding setPosition() too.

Also, the Babylon 101 tutorials make it sound like you don't have to detach controls before switching, and why do I need to clone the position and target vectors? 



Link to comment
Share on other sites

The clone is not necessary but it is more a good habit ;)

For documentation, this specific topic you mentioned (about setTarget) could clearly be mentioned in the 101. Feel free to help us with a tiny PR on the documentation site :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...