Device orientation not behaving as expected

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)

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.

Thanks! I saw you posted an issue on our github. I’ll leave the issue open so we remember to look into it. Unfortunately the team is pretty busy right now getting ready to go to SIGGRAPH so it may be a little while before we get a chance.