mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #22528 - Manishearth:webxr, r=jdm,MortimerGoro
Preliminary WebXR support This implements just enough WebXR to display to 3DOF devices in immersive mode only. Couple missing things: - [ ] Handling reference spaces (even if just supporting eye-level spaces) - [x] Spec links - [ ] We enter immersive mode when baseLayer is set, but it seems like we're supposed to do this when requestSession is called (https://github.com/immersive-web/webxr/issues/453) - [ ] VR/XR should block less (https://github.com/servo/servo/issues/22505) - [x] More pref-gating - [x] `views` is a method instead of an attribute because we don't support FrozenArray <s>Once I add spec links and pref gating</s> this can be landed as-is for further experimentation. r? @jdm @MortimerGoro <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22528) <!-- Reviewable:end -->
This commit is contained in:
commit
c4a6dcfe4b
33 changed files with 1092 additions and 71 deletions
|
@ -1,11 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/webvr/#interface-navigator
|
||||
[NoInterfaceObject]
|
||||
interface VR {
|
||||
[Pref="dom.webvr.enabled"]
|
||||
Promise<sequence<VRDisplay>> getDisplays();
|
||||
//readonly attribute FrozenArray<VRDisplay> activeVRDisplays;
|
||||
};
|
30
components/script/dom/webidls/XR.webidl
Normal file
30
components/script/dom/webidls/XR.webidl
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xr-interface
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XR: EventTarget {
|
||||
// Methods
|
||||
Promise<void> supportsSessionMode(XRSessionMode mode);
|
||||
Promise<XRSession> requestSession(optional XRSessionCreationOptions parameters);
|
||||
|
||||
// Events
|
||||
// attribute EventHandler ondevicechange;
|
||||
};
|
||||
|
||||
[SecureContext]
|
||||
partial interface Navigator {
|
||||
[SameObject, Pref="dom.webxr.enabled"] readonly attribute XR xr;
|
||||
};
|
||||
|
||||
enum XRSessionMode {
|
||||
"inline",
|
||||
"immersive-vr",
|
||||
"immersive-ar"
|
||||
};
|
||||
|
||||
dictionary XRSessionCreationOptions {
|
||||
XRSessionMode mode = "inline";
|
||||
// XRPresentationContext outputContext;
|
||||
};
|
13
components/script/dom/webidls/XRFrame.webidl
Normal file
13
components/script/dom/webidls/XRFrame.webidl
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrframe-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRFrame {
|
||||
readonly attribute XRSession session;
|
||||
|
||||
XRViewerPose? getViewerPose(optional XRReferenceSpace referenceSpace);
|
||||
// XRInputPose? getInputPose(XRInputSource inputSource, optional XRReferenceSpace referenceSpace);
|
||||
};
|
8
components/script/dom/webidls/XRLayer.webidl
Normal file
8
components/script/dom/webidls/XRLayer.webidl
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrlayer-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRLayer {};
|
21
components/script/dom/webidls/XRReferenceSpace.webidl
Normal file
21
components/script/dom/webidls/XRReferenceSpace.webidl
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrreferencespace-interface
|
||||
|
||||
enum XRReferenceSpaceType {
|
||||
"stationary",
|
||||
"bounded",
|
||||
"unbounded"
|
||||
};
|
||||
|
||||
dictionary XRReferenceSpaceOptions {
|
||||
required XRReferenceSpaceType type;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRReferenceSpace : XRSpace {
|
||||
// attribute XRRigidTransform originOffset;
|
||||
// attribute EventHandler onreset;
|
||||
};
|
13
components/script/dom/webidls/XRRigidTransform.webidl
Normal file
13
components/script/dom/webidls/XRRigidTransform.webidl
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrrigidtransform-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
// [Constructor(optional DOMPointInit position, optional DOMPointInit orientation)]
|
||||
interface XRRigidTransform {
|
||||
// readonly attribute DOMPointReadOnly position;
|
||||
// readonly attribute DOMPointReadOnly orientation;
|
||||
// readonly attribute Float32Array matrix;
|
||||
};
|
45
components/script/dom/webidls/XRSession.webidl
Normal file
45
components/script/dom/webidls/XRSession.webidl
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrsession-interface
|
||||
|
||||
enum XREnvironmentBlendMode {
|
||||
"opaque",
|
||||
"additive",
|
||||
"alpha-blend",
|
||||
};
|
||||
|
||||
callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame);
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRSession : EventTarget {
|
||||
// // Attributes
|
||||
readonly attribute XRSessionMode mode;
|
||||
// readonly attribute XRPresentationContext outputContext;
|
||||
// readonly attribute XREnvironmentBlendMode environmentBlendMode;
|
||||
|
||||
attribute double depthNear;
|
||||
attribute double depthFar;
|
||||
attribute XRLayer? baseLayer;
|
||||
|
||||
// // Methods
|
||||
// Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type,
|
||||
// optional XRReferenceSpaceOptions options);
|
||||
|
||||
// FrozenArray<XRInputSource> getInputSources();
|
||||
|
||||
long requestAnimationFrame(XRFrameRequestCallback callback);
|
||||
void cancelAnimationFrame(long handle);
|
||||
|
||||
// Promise<void> end();
|
||||
|
||||
// // Events
|
||||
// attribute EventHandler onblur;
|
||||
// attribute EventHandler onfocus;
|
||||
// attribute EventHandler onend;
|
||||
// attribute EventHandler onselect;
|
||||
// attribute EventHandler oninputsourceschange;
|
||||
// attribute EventHandler onselectstart;
|
||||
// attribute EventHandler onselectend;
|
||||
};
|
10
components/script/dom/webidls/XRSpace.webidl
Normal file
10
components/script/dom/webidls/XRSpace.webidl
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrspace-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRSpace : EventTarget {
|
||||
// XRRigidTransform? getTransformTo(XRSpace other);
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrstationaryreferencespace-interface
|
||||
|
||||
enum XRStationaryReferenceSpaceSubtype {
|
||||
"eye-level",
|
||||
"floor-level",
|
||||
"position-disabled"
|
||||
};
|
||||
|
||||
dictionary XRStationaryReferenceSpaceOptions : XRReferenceSpaceOptions {
|
||||
required XRStationaryReferenceSpaceSubtype subtype;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRStationaryReferenceSpace: XRReferenceSpace {
|
||||
// readonly attribute XRStationaryReferenceSpaceSubtype subtype;
|
||||
};
|
18
components/script/dom/webidls/XRView.webidl
Normal file
18
components/script/dom/webidls/XRView.webidl
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrview-interface
|
||||
|
||||
enum XREye {
|
||||
"left",
|
||||
"right"
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRView {
|
||||
readonly attribute XREye eye;
|
||||
readonly attribute Float32Array projectionMatrix;
|
||||
readonly attribute Float32Array viewMatrix;
|
||||
// readonly attribute XRRigidTransform transform;
|
||||
};
|
14
components/script/dom/webidls/XRViewerPose.webidl
Normal file
14
components/script/dom/webidls/XRViewerPose.webidl
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrviewerpose-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRViewerPose {
|
||||
// readonly attribute XRRigidTransform transform;
|
||||
// readonly attribute FrozenArray<XRView> views;
|
||||
// workaround until we have FrozenArray
|
||||
// see https://github.com/servo/servo/issues/10427#issuecomment-449593626
|
||||
readonly attribute any views;
|
||||
};
|
13
components/script/dom/webidls/XRViewport.webidl
Normal file
13
components/script/dom/webidls/XRViewport.webidl
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrviewport-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRViewport {
|
||||
readonly attribute long x;
|
||||
readonly attribute long y;
|
||||
readonly attribute long width;
|
||||
readonly attribute long height;
|
||||
};
|
43
components/script/dom/webidls/XRWebGLLayer.webidl
Normal file
43
components/script/dom/webidls/XRWebGLLayer.webidl
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrwebgllayer-interface
|
||||
|
||||
// typedef (WebGLRenderingContext or
|
||||
// WebGL2RenderingContext) XRWebGLRenderingContext;
|
||||
|
||||
typedef WebGLRenderingContext XRWebGLRenderingContext;
|
||||
|
||||
dictionary XRWebGLLayerInit {
|
||||
boolean antialias = true;
|
||||
boolean depth = true;
|
||||
boolean stencil = false;
|
||||
boolean alpha = true;
|
||||
// double framebufferScaleFactor = 1.0;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Constructor(XRSession session,
|
||||
XRWebGLRenderingContext context,
|
||||
optional XRWebGLLayerInit layerInit),
|
||||
Pref="dom.webxr.enabled"]
|
||||
interface XRWebGLLayer : XRLayer {
|
||||
// // Attributes
|
||||
readonly attribute XRWebGLRenderingContext context;
|
||||
|
||||
readonly attribute boolean antialias;
|
||||
readonly attribute boolean depth;
|
||||
readonly attribute boolean stencil;
|
||||
readonly attribute boolean alpha;
|
||||
|
||||
// readonly attribute WebGLFramebuffer framebuffer;
|
||||
// readonly attribute unsigned long framebufferWidth;
|
||||
// readonly attribute unsigned long framebufferHeight;
|
||||
|
||||
// // Methods
|
||||
XRViewport? getViewport(XRView view);
|
||||
// void requestViewportScaling(double viewportScaleFactor);
|
||||
|
||||
// // Static Methods
|
||||
// static double getNativeFramebufferScaleFactor(XRSession session);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue