Re: Screen Orientation Feedback

On Tue, Aug 5, 2014 at 11:14 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> Hi All,
>
> I think the current interaction between the screen orientation and
> device orientation specs is really unfortunate.
>
> Any time that you use the device orientation in order to render
> something on screen, you have to do non-obvious math in order to get
> coordinates which are usable. Same thing if you want to use the device
> orientation events as input for objects which are rendered on screen.
>
> I would argue that these are the by far most common use cases for
>
> I agree that the main problem here is that the deviceorientation spec
> defined that their events should be relative to the device rather than
> to the screen. However we can still fix the problem by simply adding
>
> partial interface DeviceOrientationEvent
> {
>   readonly attribute double? screenAlpha;
>   readonly attribute double? screenBeta;
>   readonly attribute double? screenGamma;
> }
>
> No new events needs to be defined.
>
> I guess we can argue that this should be added to the
> DeviceOrientation spec, but that seems unlikely to happen in practice
> anytime soon. I think we would do developers a disservice by blaming
> procedural issues rather than trying to solve the problem.

FWIW I just published a small standalone library that removes a lot of
the inconsistency we find between different DeviceOrientation
implementations and also happens to return screen-adjusted alpha, beta
and gamma angles as you propose we provide via the DeviceOrientation
Events API directly. The library takes the raw alpha, beta, gamma
deviceorientation values provided to calculate a normalized device
rotation matrix. This matrix is then multiplied by an appropriate
screen orientation angle transformation matrix from which we can then
derive and return the screen-adjusted alpha, beta and gamma angles (or
an equivalent quaternion or rotation matrix object) back to web
developers.

The Full Tilt standalone JS library is at
https://github.com/richtr/Full-Tilt-JS. This largely builds on the
basic mathematics of DeviceOrientation presented in
http://dev.opera.com/articles/w3c-device-orientation-usage/.

>
> I think mozilla would be happy to implement such an addition to the
> DeviceOrientation event (I'm currently checking to make sure). Are
> there other UAs that have opinions (positive or negative) to such an
> addition?

I would be interested to see something like this. The math here is
definitely non-trivial and the more we can do for web developers at
the platform level the better.

Web developers shouldn't need to learn and implement complex
mathematics if they want device orientation to work *exactly the same*
when a user rotates their screen. That seems like a very obvious use
case. Removing the complexity of doing that is the main reason I have
published Full Tilt. Putting that behind the scenes in web browsers
would be even better IMO.

br/ Rich

>
> / Jonas
>

Received on Monday, 11 August 2014 13:23:01 UTC