1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * https://immersive-web.github.io/webxr/
11 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
12 interface XRSystem : EventTarget {
15 Promise<boolean> isSessionSupported(XRSessionMode mode);
16 [NewObject, NeedsCallerType]
17 Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionInit options = {});
20 attribute EventHandler ondevicechange;
29 dictionary XRSessionInit {
30 sequence<DOMString> requiredFeatures;
31 sequence<DOMString> optionalFeatures;
34 enum XRVisibilityState {
40 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
41 interface XRSession : EventTarget {
43 readonly attribute XRVisibilityState visibilityState;
44 [SameObject] readonly attribute XRRenderState renderState;
45 [SameObject] readonly attribute XRInputSourceArray inputSources;
46 readonly attribute float? frameRate;
47 readonly attribute Float32Array? supportedFrameRates;
51 undefined updateRenderState(optional XRRenderStateInit state = {});
53 Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type);
55 Promise<undefined> updateTargetFrameRate(float rate);
58 long requestAnimationFrame(XRFrameRequestCallback callback);
60 undefined cancelAnimationFrame(long handle);
63 Promise<undefined> end();
66 attribute EventHandler onend;
67 attribute EventHandler oninputsourceschange;
68 attribute EventHandler onselect;
69 attribute EventHandler onselectstart;
70 attribute EventHandler onselectend;
71 attribute EventHandler onsqueeze;
72 attribute EventHandler onsqueezestart;
73 attribute EventHandler onsqueezeend;
74 attribute EventHandler onvisibilitychange;
77 dictionary XRRenderStateInit {
80 double inlineVerticalFieldOfView;
81 XRWebGLLayer? baseLayer;
84 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
85 interface XRRenderState {
86 readonly attribute double depthNear;
87 readonly attribute double depthFar;
88 readonly attribute double? inlineVerticalFieldOfView;
89 readonly attribute XRWebGLLayer? baseLayer;
92 callback XRFrameRequestCallback = undefined (DOMHighResTimeStamp time, XRFrame frame);
94 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
96 [SameObject] readonly attribute XRSession session;
98 [Throws] XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace);
99 [Throws] XRPose? getPose(XRSpace space, XRSpace baseSpace);
102 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
103 interface XRSpace : EventTarget {
107 enum XRReferenceSpaceType {
115 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
116 interface XRReferenceSpace : XRSpace {
118 XRReferenceSpace getOffsetReferenceSpace(XRRigidTransform originOffset);
120 attribute EventHandler onreset;
123 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
124 interface XRBoundedReferenceSpace : XRReferenceSpace {
125 // TODO: Use FrozenArray once available. (Bug 1236777)
126 [Frozen, Cached, Pure]
127 readonly attribute sequence<DOMPointReadOnly> boundsGeometry;
136 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
138 readonly attribute XREye eye;
140 readonly attribute Float32Array projectionMatrix;
142 readonly attribute XRRigidTransform transform;
145 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
146 interface XRViewport {
147 readonly attribute long x;
148 readonly attribute long y;
149 readonly attribute long width;
150 readonly attribute long height;
153 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
154 interface XRRigidTransform {
156 constructor(optional DOMPointInit position = {}, optional DOMPointInit orientation = {});
157 [SameObject] readonly attribute DOMPointReadOnly position;
158 [SameObject] readonly attribute DOMPointReadOnly orientation;
160 readonly attribute Float32Array matrix;
161 [SameObject] readonly attribute XRRigidTransform inverse;
164 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
166 [SameObject] readonly attribute XRRigidTransform transform;
167 readonly attribute boolean emulatedPosition;
170 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
171 interface XRViewerPose : XRPose {
172 // TODO: Use FrozenArray once available. (Bug 1236777)
173 [Constant, Cached, Frozen]
174 readonly attribute sequence<XRView> views;
183 enum XRTargetRayMode {
189 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
190 interface XRInputSource {
191 readonly attribute XRHandedness handedness;
192 readonly attribute XRTargetRayMode targetRayMode;
193 [SameObject] readonly attribute XRSpace targetRaySpace;
194 [SameObject] readonly attribute XRSpace? gripSpace;
195 // TODO: Use FrozenArray once available. (Bug 1236777)
196 [Constant, Cached, Frozen]
197 readonly attribute sequence<DOMString> profiles;
198 // https://immersive-web.github.io/webxr-gamepads-module/
199 [SameObject] readonly attribute Gamepad? gamepad;
203 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
204 interface XRInputSourceArray {
205 iterable<XRInputSource>;
206 readonly attribute unsigned long length;
207 getter XRInputSource(unsigned long index);
210 typedef (WebGLRenderingContext or
211 WebGL2RenderingContext) XRWebGLRenderingContext;
213 dictionary XRWebGLLayerInit {
214 boolean antialias = true;
215 boolean depth = true;
216 boolean stencil = false;
217 boolean alpha = true;
218 boolean ignoreDepthValues = false;
219 double framebufferScaleFactor = 1.0;
222 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
223 interface XRWebGLLayer {
225 constructor(XRSession session,
226 XRWebGLRenderingContext context,
227 optional XRWebGLLayerInit layerInit = {});
229 readonly attribute boolean antialias;
230 readonly attribute boolean ignoreDepthValues;
232 [SameObject] readonly attribute WebGLFramebuffer? framebuffer;
233 readonly attribute unsigned long framebufferWidth;
234 readonly attribute unsigned long framebufferHeight;
237 XRViewport? getViewport(XRView view);
240 static double getNativeFramebufferScaleFactor(XRSession session);