@types/motion-sensors-polyfill
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

Installation

npm install --save @types/motion-sensors-polyfill

Summary

This package contains type definitions for motion-sensors-polyfill (https://github.com/kenchris/sensor-polyfills).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/motion-sensors-polyfill.

export {};

type EventHandler = (event: Event) => void;

export class Sensor extends EventTarget {
    readonly activated: boolean;
    readonly hasReading: boolean;
    readonly timestamp?: DOMHighResTimeStamp | undefined;
    start(): void;
    stop(): void;
    onreading: EventHandler;
    onactivate: EventHandler;
    onerror: EventHandler;
}

interface SensorOptions {
    frequency?: number | undefined;
}

type AccelerometerLocalCoordinateSystem = "device" | "screen";

interface AccelerometerSensorOptions extends SensorOptions {
    referenceFrame?: AccelerometerLocalCoordinateSystem | undefined; // defaults to "device". IDK how to type this
}

export class Accelerometer extends Sensor {
    constructor(options?: AccelerometerSensorOptions);
    readonly x: number;
    readonly y: number;
    readonly z: number;
}

export class LinearAccelerationSensor extends Accelerometer {
    constructor(options?: AccelerometerSensorOptions);
}

export class GravitySensor extends Accelerometer {
    constructor(options?: AccelerometerSensorOptions);
}

interface GyroscopeSensorOptions extends SensorOptions {
    referenceFrame?: GyroscopeLocalCoordinateSystem | undefined; // defauts to "device"
}

type GyroscopeLocalCoordinateSystem = "device" | "screen";

export class Gyroscope extends Sensor {
    constructor(options?: GyroscopeSensorOptions);
    readonly x: number;
    readonly y: number;
    readonly z: number;
}

type OrientationSensorLocalCoordinateSystem = "device" | "screen";

interface OrientationSensorOptions extends SensorOptions {
    referenceFrame?: OrientationSensorLocalCoordinateSystem | undefined; // defaults to "device"
}

type RotationMatrixType = Float32Array | Float64Array | DOMMatrix;

export class OrientationSensor extends Sensor {
    readonly quaternion: [number, number, number, number];
    populateMatrix(matrix: RotationMatrixType): void;
}

export class RelativeOrientationSensor extends OrientationSensor {
    constructor(options?: OrientationSensorOptions);
}

export class AbsoluteOrientationSensor extends OrientationSensor {
    constructor(options?: OrientationSensorOptions);
}

Additional Details

  • Last updated: Tue, 16 Jul 2024 20:07:33 GMT
  • Dependencies: none

Credits

These definitions were written by Kevin Wylder.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/motion-sensors-polyfill

Weekly Downloads

66

Version

0.3.5

License

MIT

Unpacked Size

6.91 kB

Total Files

5

Last publish

Collaborators

  • types