-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix rotation properties being in degrees irrespective of angleMode #6589
Conversation
src/events/acceleration.js
Outdated
|
||
let multiplier = 1; | ||
if (this._angleMode === constants.RADIANS) { | ||
multiplier = constants.PI / 180.0; | ||
} | ||
this._setProperty('rotationX', e.beta); | ||
this._setProperty('rotationY', e.gamma); | ||
this._setProperty('rotationZ', e.alpha); | ||
this._setProperty('rotationX', e.beta * multiplier); | ||
this._setProperty('rotationY', e.gamma * multiplier); | ||
this._setProperty('rotationZ', e.alpha * multiplier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an internal method to convert angles, can you see if you can use that to simplify the implementation instead? https://github.com/processing/p5.js/blob/main/src/math/trigonometry.js#L437
Ive added a new internal method, similar to the one you pointed out which converts from degrees to the current angle mode unit (since that one was missing and was needed here). |
Looks good. Thanks! |
Resolves #6565
Changes:
Fixing the incorrectly lowercased reference to
constants.RADIANS
atp5.js/src/events/acceleration.js
Line 622 in 773eb0d
This was also casuing rotation and pRotation properties being in degrees irrespective of the
_angleMode
.Changes to
_handleMotion
function were made to make it work with both degree and radian values.Changes in unit tests related to rotation were made as they expected degree values despite the default mode being radian.
The
angleMode
method in math/trigonometry.js was also changed to update pRotation properties when the mode is changed, this is needed because otherwise the units of rotation and pRotation could end up different, which may cause thedeviceTurned
event to fire incorrectly.PR Checklist
npm run lint
passes