forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webvr-api.d.ts
175 lines (160 loc) · 5.38 KB
/
webvr-api.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Type definitions for WebVR API
// Project: http://mozvr.github.io/webvr-spec/webvr.html
// Definitions by: Toshiya Nakakura <https://github.com/nakakura>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../geometry-dom/geometry-dom.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare type VREye = string;
declare module WebVRApi {
export interface VRFieldOfViewReadOnly {
upDegrees: number;
rightDegrees: number;
downDegrees: number;
leftDegrees: number;
}
export interface VRFieldOfViewInit {
upDegrees: number;
rightDegrees: number;
downDegrees: number;
leftDegrees: number;
}
export interface VRFieldOfView extends VRFieldOfViewReadOnly {
constructor(upDegrees:number, rightDegrees:number, downDegrees:number, leftDegrees:number): VRFieldOfView;
upDegrees: number;
rightDegrees: number;
downDegrees: number;
leftDegrees: number;
}
export interface VRPositionState {
/**
* Monotonically increasing value that allows the author to determine if position state data been updated from the hardware.
*/
timeStamp: number;
/**
* True if the position attribute is valid. If false position MUST be null.
*/
hasPosition: boolean;
/**
* Position of the sensor at timeStamp as a 3D vector.
*/
position?: GeometryDom.DOMPoint;
/**
* Linear velocity of the sensor at timeStamp.
*/
linearVelocity?: GeometryDom.DOMPoint;
/**
* Linear acceleration of the sensor at timeStamp.
*/
linearAcceleration?: GeometryDom.DOMPoint;
/**
* True if the orientation attribute is valid. If false orientation MUST be null.
*/
hasOrientation: boolean;
/**
* Orientation of the sensor at timeStamp as a quaternion.
*/
orientation?: GeometryDom.DOMPoint;
/**
* Angular velocity of the sensor at timeStamp.
*/
angularVelocity?: GeometryDom.DOMPoint;
/**
* Angular acceleration of the sensor at timeStamp.
*/
angularAcceleration?: GeometryDom.DOMPoint;
}
export interface VREyeParameters {
/**
* Describes the minimum supported field of view for the eye.
*/
minimumFieldOfView: VRFieldOfView;
/**
* Describes the maximum supported field of view for the eye.
*/
maximumFieldOfView: VRFieldOfView;
/**
* Describes the recommended field of view for the eye.
*/
recommendedFieldOfView: VRFieldOfView;
/**
* Offset from the center of the users head to the eye in meters.
*/
eyeTranslation: GeometryDom.DOMPoint;
/**
* The current field of view for the eye, as specified by setFieldOfView.
*/
currentFieldOfView: VRFieldOfView;
/**
* Describes the viewport of a canvas into which visuals for this eye should be rendered.
*/
renderRect: GeometryDom.DOMRect;
}
export interface VRDevice {
/**
* An identifier for the distinct hardware unit that this VRDevice is a part of.
*/
hardwareUnitId: string;
/**
* An identifier for this distinct sensor/device on a physical hardware device.
*/
deviceId: string;
/**
* A user-readable name identifying the device.
*/
deviceName: string;
}
}
declare class HMDVRDevice implements WebVRApi.VRDevice {
/**
* An identifier for the distinct hardware unit that this VRDevice is a part of.
*/
hardwareUnitId: string;
/**
* An identifier for this distinct sensor/device on a physical hardware device.
*/
deviceId: string;
/**
* A user-readable name identifying the device.
*/
deviceName: string;
/**
* Return the current VREyeParameters for the given eye.
*/
getEyeParameters(whichEye: VREye): WebVRApi.VREyeParameters;
/**
* Set the field of view for both eyes. If
*/
setFieldOfView(leftFOV?: WebVRApi.VRFieldOfViewInit, rightFOV?: WebVRApi.VRFieldOfViewInit, zNear?: number, zFar?: number): void;
}
declare class PositionSensorVRDevice implements WebVRApi.VRDevice {
/**
* An identifier for the distinct hardware unit that this VRDevice is a part of.
*/
hardwareUnitId: string;
/**
* An identifier for this distinct sensor/device on a physical hardware device.
*/
deviceId: string;
/**
* A user-readable name identifying the device.
*/
deviceName: string;
/**
* Return a VRPositionState dictionary containing the state of this position sensor state for the current frame (if within a requestAnimationFrame context) or for the previous frame.
*/
getState(): WebVRApi.VRPositionState;
/**
* Return the current instantaneous sensor state.
*/
getImmediateState(): WebVRApi.VRPositionState;
/**
* Reset this sensor, treating its current position and orientation yaw as the "origin/zero" values.
*/
resetSensor(): void;
}
interface Navigator {
/**
* Return a Promise which resolves to a list of available VRDevices.
*/
getVRDevices(): Promise<Array<WebVRApi.VRDevice>>;
}