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

Add arbitrary deviceorientation.alpha bug fix to DeviceOrientationControls.js #4577

Closed
wants to merge 1 commit into from

Conversation

richtr
Copy link
Contributor

@richtr richtr commented Mar 14, 2014

iOS devices return an arbitrary alpha value anchored at 0 in the device's orientation when the user initially loads a web page.

Apple introduced DeviceOrientationEvent.webkitCompassHeading to provide more 'spec-like' behavior and this should be used instead of the non-absolute 'alpha' value (see: http://lists.w3.org/Archives/Public/public-geolocation/2011Jul/0014.html)

This patch ensures THREE.DeviceOrientationControls orients itself in the same compass direction in iOS-based browsers.

/ping @WestLangley

@WestLangley
Copy link
Collaborator

I'd hold off on this one for now, due to a host of reasons that I am yet to understand well enough to explain. :-/

See https://developer.apple.com/library/safari/documentation/SafariDOMAdditions/Reference/DeviceOrientationEventClassRef/DeviceOrientationEvent/DeviceOrientationEvent.html

The angles of rotation—the alpha, beta, and gamma properties—do not represent the real world orientation. They are defined as an offset from an arbitrary direction—typically, the direction in which the device was held when the orientation was first obtained.

Also, CompasHeading can be real-valued, yet incorrect.

A value of -1 means that the compass is not calibrated and not giving usable readings.

Also, there are some formatting problems in the PR. Use tabs only at the start of a line, and spaces only within a line.

Finally, is this pattern better?

beta = THREE.Math.degToRad( this.deviceOrientation.beta || 0  );

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

Successfully merging this pull request may close these issues.

3 participants