onUpdate
onUpdate(callback: (update: RotationUpdate) => void): voidSource: main.ts:66
Registers a callback function to receive calibrated rotation updates.
By default, this automatically initiates permission checks and begins listening unless startOnInit: false was passed in setConfig. Update frequency is throttled to RotationListenerConfig.pollingRate (default: 60 FPS).
Parameters
callback((update: RotationUpdate) => void) — Function invoked on each orientation tick with a RotationUpdate.
Returns
void
Example
CODE
import { deviceRotation } from "web-orientation";
deviceRotation.onUpdate((update) => {
const { x, y, z, w } = update.quaternion;
console.log(`Quaternion: x=${x}, y=${y}, z=${z}, w=${w}`);
});