Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device orientation not behaving as expected #4135

Open
gk1089 opened this issue Jul 19, 2016 · 7 comments
Open

Device orientation not behaving as expected #4135

gk1089 opened this issue Jul 19, 2016 · 7 comments

Comments

@gk1089
Copy link

gk1089 commented Jul 19, 2016

I have been trying to implement the Cardboard sample code and am not getting the results as expected. I modified the code so that the Balloon were not visible (file attached)
Cardboard2.txt

Issues that I noticed are:

  • With the device (Chrome on Android) held in landscape orientation, the view pans properly if rotated around the vertical axis. i.e. I can look around and see properly.
  • I can look right down and it is fine if I look back up in the same direction.
  • Moving the device in any direction while looking down, disorients the horizon so that if I look back up in any direction other than where I initially looked down from, the horizon gets tilted.
  • Moreover, from the initial view if I try to tilt the device to look up, the view gets inverted.
  • I tried to play around with the DeviceOrientationCameraController.js file, which, I guess is where the 'under-the-hood' things are going on but the Quaternion maths was not at all easy to decipher. I really wish there were some comments over there to explain what was going on. I tried comparing it with THREEJS quaternion code, but that seemed even more tough to understand.
  • Another thing that I noticed is that in current configuration, the scene orientation is not at all dependent on the real life orientation of the device. Whichever way I hold the device while loading the code is the initial look direction. This can cause problems because it requires the device to be held perfectly vertical to ground while initializing otherwise leading to less-than-optimum experience.

I understand that this is still a nascent area for Cesium and I am willing to learn and implement it properly. Please nudge me in the right direction.

@kaktus40
Copy link
Contributor

Hello,
I didn't understand your problem but about the quaternion maybe this pull could help you (fourth bullet)? I create an example into this pull request.
Nevertheless thanks for your hack to obtain the focus in a sandcastle example.

@gk1089
Copy link
Author

gk1089 commented Jul 25, 2016

My problem is simply that the VR mode-code is not working as expected. The code you have posted is about getting Roll, Pitch, Direction information from quaternion information, which is related but not exactly what I am looking for.

What I need is to understand how I can relate quaternion information to device orientation information (Alpha, Beta, Gamma) of an Android device.

@lasalvavida
Copy link
Contributor

lasalvavida commented Jul 25, 2016

@gk1089, maybe check out the wolfram mathworld article on Euler Angles.

You can use Matrix3.fromRotationX, fromRotationY, and fromRotationZ to generate the B, C, and D matrices from the article.

Quaternion.fromRotationMatrix can make a quaternion from your resulting rotation matrix.

@kaktus40
Copy link
Contributor

kaktus40 commented Jul 26, 2016

From my pull request, it seems, you should map:

  • alpha to heading
  • gamma to pitch
  • beta to roll

see here

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 31, 2016

@bagnell do you have any insights here?

@gk1089
Copy link
Author

gk1089 commented Aug 5, 2016

Does the issue discussed in the following link have any relation to it?
#3256

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants