mirror of
https://github.com/101island/lolisland.us.git
synced 2026-03-01 19:50:02 +08:00
feat: use rotation matrix to derive acceleration ax
refs: https://www.w3.org/TR/orientation-event/#examples
This commit is contained in:
@@ -64,10 +64,7 @@ export class DeviceOrientationInteraction {
|
||||
const g = 9.8;
|
||||
const toRad = Math.PI / 180;
|
||||
|
||||
this.ax =
|
||||
alpha > 180
|
||||
? g * Math.sin((gamma - 180) * toRad)
|
||||
: g * Math.sin(gamma * toRad);
|
||||
this.ax = g * Math.sin(gamma * toRad) * Math.cos(beta * toRad);
|
||||
this.ay = g * Math.sin(beta * toRad);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user