Jump to content

Quaternion ArcRotateCamera


Recommended Posts

Hey guys, 


I noticed something strange for an arc rotate camera: when there is no upperBetalimit (set to null) and no lowerBetaLimlit (set to null too), the camera doesn't go all way around, but switch on one side of the target.

Playground : http://www.babylonjs-playground.com/#9U5IW


That's because the arcrotatecamera handle its position with sin/cos of alpha/beta (thus between -1 and 1).


In one of my project, this is a no-go :/ I need a camera going all way around the target. Could it be possible to build an ArcRotateCamera with quaternion ? If yes, could you give me some pointer on how to do it ?


Thanks :)

Link to comment
Share on other sites

Oh, that's a nice task :-)


With the current ArcRotateCamera it will not be possible due to the sin(beta) calculation, exactly like you mentioned.

I think (not too sure thou) that a quaternion will not be the thing that will solve this. I believe a different approach is needed.

Right now, moving the mouse on the x and y axis only adds/decreases from the beta/alpha value. those values are used to calculate the new position. What I think would solve this is to use the camera's current direction and calculate the next step accordingly. 

Move your mouse left and right, after you rotated up 90 degrees, and you will understand what I mean - It no longer rotates left and right, it turns clockwise or counter clockwise. What I am suggesting will prevent that. Moving the mouse left will always move the camera to the left. same goes to up down and right :-)

Now, I don't know if this is possilble and how easy it is to implement, I however believe that the answers are:

1) it is possible

2) it is not that simple...


i'll give it a try when I have the time, I like those kind of challenges :-) 

Link to comment
Share on other sites

  • 2 weeks later...

Nice work Raanan ! 

The only flaw I can see is when the camera upside down, rotating to the left will make the camera go to the right.


I worked on it last week, and i used a freecamera, an hidden target and quaternion, like this : http://www.babylonjs-playground.com/#YRIPX#1

Did the work for me.


Thank you very much though !

Link to comment
Share on other sites

This version


A simple hack : http://www.babylonjs-playground.com/#LEASD#1

But i like your so much better :-) nice work!!


Hmm, for us (as devs) that's a pretty nice trick to change orientation of cam rotation when above objects, but by experience I know that people will be fooled by this and cannot be able to manipulate the orbital camera without having the feeling of "something goes wrong". Try to rotate a lot in every position possible and you'll see that sometimes the rotation suddenly stops to go opposite way, in my opinion that's not applicable for production.

Nevertheless, your first attempt is just perfect, and we should implent this one in BJS :



For people who need an orbital acting like the Temechon attempts with Free camera, well, they can use that attempt as a start point (@Alby, that could be listed in centralisation of user functions)

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