Orientation API and device orientation

Hi!

I’m currently playing with Orientation API to retrieve the direction of a smartphone. My final goal is to be able to place this direction on a sphere.

I don’t have any problem when the smartphone is in portrait mode: alpha and beta are the right angles to use (alpha to horizontally turn the head, beta to turn it vertically). The problem is when the smartphone is in landscape mode.

The axis stay the same, and that’s the real problem: the gamma angle doesn’t cover the whole sphere, and the covered part is not the one I want (I want from the bottom to the top, gamma covers from a side to the other side).
In other words, when the smartphone is in landscape mode, I don’t see any way to know if the smartphone points to the top or to the bottom (both have the same gamma angles).

Have you any idea to do what I want to do? Don’t hesitate if you need any other information.

Hi,

That’s happening because of the default device orientation. Usually smartphones have their default orientation as portrait and tablets as landscape. This is no rule of thumbs, nor a standard, and it’s vendor specific, but generally it’s implemented that way. If you check the orientation API in mdn with a tablet and a smartphone you can see that happening. The tablet works well in landscape and the smartphone in portrait, but if you change the orientation on both devices the axis don’t update.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.