-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
104 lines (83 loc) · 2.71 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Type definitions for non-npm package W3C Generic Sensor API 1.0
// Project: https://www.w3.org/TR/generic-sensor/
// Definitions by: Kenneth Rohde Christiansen <https://github.com/kenchris>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
// Explainer: https://www.w3.org/TR/motion-sensors/
declare class SensorErrorEvent extends Event {
constructor(type: string, errorEventInitDict: SensorErrorEventInit);
readonly error: Error;
}
interface SensorErrorEventInit extends EventInit {
error: Error;
}
declare class Sensor extends EventTarget {
readonly activated: boolean;
readonly timestamp?: number; // Should be DOMHighResTimeStamp.
start(): void;
stop(): void;
onreading: (this: this, ev: Event) => any;
onactivate: (this: this, ev: Event) => any;
onerror: (this: this, ev: SensorErrorEvent) => any;
addEventListener(
type: "reading" | "activate",
listener: (this: this, ev: Event) => any,
useCapture?: boolean
): void;
addEventListener(
type: "error",
listener: (this: this, ev: SensorErrorEvent) => any,
useCapture?: boolean
): void;
}
interface SensorOptions {
frequency?: number;
}
// Accelerometer: https://www.w3.org/TR/accelerometer/
declare class Accelerometer extends Sensor {
constructor(options?: SensorOptions);
readonly x?: number;
readonly y?: number;
readonly z?: number;
}
declare class LinearAccelerationSensor extends Accelerometer {
constructor(options?: SensorOptions);
}
declare class GravitySensor extends Accelerometer {
constructor(options?: SensorOptions);
}
// Gyroscope: https://www.w3.org/TR/gyroscope/
declare class Gyroscope extends Sensor {
constructor(options?: SensorOptions);
readonly x?: number;
readonly y?: number;
readonly z?: number;
}
// Magnetometer: https://www.w3.org/TR/magnetometer/
declare class Magnetometer extends Sensor {
constructor(options?: SensorOptions);
readonly x?: number;
readonly y?: number;
readonly z?: number;
}
declare class UncalibratedMagnetometer extends Sensor {
constructor(options?: SensorOptions);
readonly x?: number;
readonly y?: number;
readonly z?: number;
readonly xBias?: number;
readonly yBias?: number;
readonly zBias?: number;
}
// Orientation Sensor: https://www.w3.org/TR/orientation-sensor/
type RotationMatrixType = Float32Array | Float64Array | DOMMatrix;
declare class OrientationSensor extends Sensor {
readonly quaternion?: number[];
populateMatrix(targetMatrix: RotationMatrixType): void;
}
declare class AbsoluteOrientationSensor extends OrientationSensor {
constructor(options?: SensorOptions);
}
declare class RelativeOrientationSensor extends OrientationSensor {
constructor(options?: SensorOptions);
}