@livx.cc/native-kit 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/web-adapter.ts +7 -1
package/package.json
CHANGED
package/src/core/web-adapter.ts
CHANGED
|
@@ -332,9 +332,15 @@ export class WebAdapter implements NativeKitAdapter {
|
|
|
332
332
|
last = now;
|
|
333
333
|
const a = e.accelerationIncludingGravity;
|
|
334
334
|
const r = e.rotationRate;
|
|
335
|
+
// Map DOM → kit contract. Two corrections vs the raw event, BOTH load-bearing:
|
|
336
|
+
// 1. UNITS: the DOM reports rotationRate in deg/s; the kit contract (and both native
|
|
337
|
+
// handlers — CoreMotion + Android TYPE_GYROSCOPE) is rad/s. Convert, or web is 57× off.
|
|
338
|
+
// 2. AXES: DOM alpha/beta/gamma are the rates about Z/X/Y respectively — NOT x/y/z in
|
|
339
|
+
// order. So rx=beta, ry=gamma, rz=alpha; a naive alpha→rx puts the Z-rate on X.
|
|
340
|
+
const toRad = (d?: number | null) => (d == null ? undefined : (d * Math.PI) / 180);
|
|
335
341
|
this.emit('motion.data', {
|
|
336
342
|
ax: a?.x ?? 0, ay: a?.y ?? 0, az: a?.z ?? 0,
|
|
337
|
-
rx: r?.
|
|
343
|
+
rx: toRad(r?.beta), ry: toRad(r?.gamma), rz: toRad(r?.alpha),
|
|
338
344
|
});
|
|
339
345
|
};
|
|
340
346
|
window.addEventListener('devicemotion', this.motionHandler);
|