Skip to content

Commit

Permalink
Revert commit 1ab3489: Add iOS world-accurate alpha orientation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
richtr committed Mar 29, 2014
1 parent bb3b840 commit 25dcddc
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions js/DeviceOrientationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ var DeviceOrientationController = function( object, domElement ) {

this.updateDeviceMove = function() {

var adjustedAlpha;

var alpha, beta, gamma, orient;

var objQuat; // when we use quaternions
Expand All @@ -331,20 +329,9 @@ var DeviceOrientationController = function( object, domElement ) {

return function() {

if (this.freeze) return;

// iOS world-accurate 'alpha' fix
try {
adjustedAlpha = this.deviceOrientation.webkitCompassAccuracy !== undefined
&& this.deviceOrientation.webkitCompassAccuracy !== null
&& this.deviceOrientation.webkitCompassAccuracy !== -1
? 360 - (this.deviceOrientation.webkitCompassHeading || 360)
: this.deviceOrientation.alpha;
} catch ( e ) {
adjustedAlpha = this.deviceOrientation.alpha;
}
if ( this.freeze ) return;

alpha = THREE.Math.degToRad( adjustedAlpha || 0 ); // Z
alpha = THREE.Math.degToRad( this.deviceOrientation.alpha || 0 ); // Z
beta = THREE.Math.degToRad( this.deviceOrientation.beta || 0 ); // X'
gamma = THREE.Math.degToRad( this.deviceOrientation.gamma || 0 ); // Y''
orient = THREE.Math.degToRad( this.screenOrientation || 0 ); // O
Expand Down

4 comments on commit 25dcddc

@richtr
Copy link
Owner Author

@richtr richtr commented on 25dcddc Mar 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has been reverted because while this did provide a compass oriented alpha value, it does not account for value changes that occur in the beta and gamma angles as the alpha heading trips around its poles. For example when webkitCompassHeading changes from 350 to 10, the values of beta and gamma are not the same in both cases. Relative changes are need to all 3 readings to ensure the coordinate-frame stays accurate which I'm unsure how we could do right now.

Problem can be re-created by re-adding this code and running on an iOS device to observe pole swinging.

@richtr
Copy link
Owner Author

@richtr richtr commented on 25dcddc Mar 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of fixing this, we could apply the delta between alpha and webkitCompassHeading later on in the process when we are constructing our Quaternion / Matrix based representations of device orientation.

@austinmayer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update on this by chance?

@code-matt
Copy link

@code-matt code-matt commented on 25dcddc Jan 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

360 - (this.deviceOrientation.webkitCompassHeading) seemed to do the trick for me.

Please sign in to comment.