Jump to content

angle alpha and beta for ArcRotateCamera


dav74
 Share

Recommended Posts

  • 6 months later...

Do you know what are the units of these values ?

I am trying to get the rotation angle (in degrees or radian) around Y axis so I print alpha in the console but I get values between 0 and ~12.5 for a complete circle around my target.

And it is not circular, values get bigger each time. Is there a way to normalize it ?

 

Thank you (:

Pouet--

Link to comment
Share on other sites

https://github.com/BabylonJS/Babylon.js/wiki/05-Cameras

 

Apparently we did not do a good job on the cameras tutorial.  :(

 

Yes, it IS circular.  The ArcRotateCamera, if .alpha = 0... looks down the -x axis.  If you want to go left, subtact radians.  When you get to -6.28 radians (2*-Math.PI)... you have done a complete circle to the left.  If you want to go right, add radians.  When you get to +6.28 radians (2*Math.PI)... you have done a complete circle to the right.  Experiment, experiment, experiment!  :)  .707 radians = Math.PI/4 = 45 degrees.  1.57 radians = Math.PI/2 = 90 degrees.  3.14 radians = Math.PI = 180 degrees.

 

An interesting place to start your arcRotateCamera.beta...   = Math.PI/3 ;  (about +1.05 radians)

  .beta = 0; // straight overhead
  .beta = Math.PI/2; // ground level
  .beta = Math.PI; // directly beneath

 

Have you read all of The Wingnut Chronicles?  Have you downloaded every zip he ever provided?  Have you looked at his code (free to use)?  Do you know the link to the Playpen Series Tutorials?  Have I asked enough questions?  ;)

Link to comment
Share on other sites

Yes, I tried all tutorials from the basic series.

My mistake, it is in radians. But I have tried to add a debug line and console.log(arcCamera.alpha) says when I turn around for 360 degrees, alpha is ~12.7

 

It is good now, it says ~6. don't know where the error was, sorry for useless question so.

 

Thank you for quick answer

Link to comment
Share on other sites

My pleasure.  Sometimes I use some html info-divs to help me learn things.  I keep them updated by setting their .textContent inside the scene's render loop.  (after sending the values through a rounding function called 'mr()' - my rounder.)

 

As you can tell, vector3's ARE endless, but it only takes 6.28 radians to go 360 degrees either way.  Also, notice that each value in a color3 are usually between 0 and 1, but the color3 used in tmat.diffuseColor (the torus knot) actually has a '2' in it.  For some reason, color3 values can to go from 0-5 around here.  It is one of the mysterious secrets of babylon.js.  We think maybe the framework is haunted.  :)

 

Here is a quick little demo and a zipped version of it... shows how I use them.  Mousewheel changes the radius. Hang on to orient.png ... it comes in handy, often.  Be well.

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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