Jump to content
  • Advertisement
Sign in to follow this  
kuroro_san

Prevent Camera Flip on [-90,90] rotation

Recommended Posts

So i'm using the html5 deviceorientation API to get device euler rotation values alpha, beta, gamma, and I want to use the gamma value to rotate a webgl scene on my phone.  The scene rotates fine when I move the value within that range. However, once I go beyond -90 for example (happens when I point my phone upward), the next gamma value I get is 89. This has the effect on making the scene suddenly flipping and looking down instead of 1 more degree upwards. 

Question is. Is there a way to normalize the value such that the jump from -90 to 89 is treated as looking 1 more degree upwards ?

Share this post


Link to post
Share on other sites
Advertisement

I am not sure what the value "gamma" is supposed to represent, but perhaps you can figure that out and then compute your rotation in a more direct manner, skipping the Euler angles altogether. Code that uses linear algebra instead of angles is generally simpler and more robust.

 

Edited by alvaro

Share this post


Link to post
Share on other sites

I looked at the documentation for the deviceorientation API.  You won't be able to use gamma alone.

I think you're going to have to use alpha, beta, AND gamma to construct complete rotation information.

I found this which might help, if you understand the math he's using:  https://stackoverflow.com/questions/36639182/html5-get-device-orientation-rotation-in-relative-coordinate

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!