onUpdate

onUpdate(callback: (update: RotationUpdate) => void): void

Source: 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

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}`);
});