To determine the orientation of a compatible device, like a smartphone or a tablet, official specifications began to describe a new API: Device Orientation. I created Sphoords to transform data retrieved by this API to spherical coordinates.
The advantage of Sphoords is that it is aimed to be browser-independant, contrary to the API itself, as its implementation can sometimes vary, which is not a good thing.
Sphoords is here to retrieve a device orientation. With it, you will be able to determine to which point the device is oriented, to know which direction it “look at”.
Sphoords returns spherical coordinates, with usual conventions: a longitude between 0 and 2π and a latitude between -π/2 and π/2. Note that, if you prefer, you also have access to the coordinates in degrees.
For the moment, I provide you two concrete examples of applications of Sphoords. The first one is the orientation support in Photo Sphere Viewer.
The second example is a more useless one. But it’s still cool. You can retrieve it in the GitHub repo, and, after all, it is not so useless as it allowed me to develop this library. Sometimes, developing the application before the library can be useful.
This example is split into two pages. The first page must be displayed on a device compatible with the Orientation API, such as a smartphone for instance. The second page can be displayed on any device. Your computer, for example.
Now, move the device displaying the first page and look at the second page. You are drawing some lines with your smartphone. Isn’t it magical?
This example retrieves the smartphone orientation and displays it in almost real time (a maximal delay of 100 milliseconds can occur) on a sphere, displayed in 3D. You can even rotate the sphere with your mouse.
Well. I don’t see any other applications than developing the library itself, but I still love it.
Currently Sphoords is far to be perfect. The biggest problem is the API itself: it’s still in development and its implementation is different following the browsers. However, it works well on Firefox for Android, Chrome and Opera. I don’t know about the others.
You can retrieve Sphoords on GitHub, in version 0.1 for now. I’ll update it when new ideas will come.
9 comments
itdx99
yz47fo
hzt43a
cwwq07
ebydlb
ji2mcv
14d7px
7c0oie
64mnj9