web api interface
VRDisplay
The VRDisplay interface of the WebVR API represents any VR device supported by this API. It includes generic information such as device IDs and descriptions, as well as methods for starting to present a VR scene, retrieving eye parameters and display capabilities, and other important functionality.
[!NOTE] This interface was part of the old WebVR API. It has been superseded by the WebXR Device API.
An array of all connected VR Devices can be returned by invoking the getVRDisplays() method.
Instance properties
capabilitiesRead only Deprecated- : Returns a
VRDisplayCapabilitiesobject that indicates the various capabilities of theVRDisplay.
- : Returns a
depthFarDeprecated- : Gets and sets the z-depth defining the far plane of the eye view frustum, i.e., the furthest viewable boundary of the scene.
depthNearDeprecated- : Gets and sets the z-depth defining the near plane of the eye view frustum, i.e., the nearest viewable boundary of the scene.
displayIdRead only Deprecated- : Returns an identifier for this particular VRDisplay, which is also used as an association point in the Gamepad API (see
displayId).
- : Returns an identifier for this particular VRDisplay, which is also used as an association point in the Gamepad API (see
displayNameRead only Deprecated- : Returns a human-readable name to identify the
VRDisplay.
- : Returns a human-readable name to identify the
isConnectedRead only Deprecated- : Returns a boolean value indicating whether the
VRDisplayis connected to the computer.
- : Returns a boolean value indicating whether the
isPresentingRead only Deprecated- : Returns a boolean value indicating whether the
VRDisplayis currently having content presented through it.
- : Returns a boolean value indicating whether the
stageParametersRead only Deprecated- : Returns a
VRStageParametersobject containing room-scale parameters, if theVRDisplayis capable of supporting room-scale experiences.
- : Returns a
Instance methods
getEyeParameters()Deprecated- : Returns the
VREyeParametersobject containing the eye parameters for the specified eye.
- : Returns the
getFrameData()Deprecated- : Accepts a
VRFrameDataobject and populates it with the information required to render the current frame.
- : Accepts a
getImmediatePose()Deprecated- : Returns a
VRPoseobject defining the current pose of theVRDisplay, with no prediction applied. This is no longer needed, and has been removed from the spec.
- : Returns a
getLayers()Deprecated- : Returns the layers currently being presented by the
VRDisplay.
- : Returns the layers currently being presented by the
getPose()Deprecated- : Returns a
VRPoseobject defining the future predicted pose of theVRDisplayas it will be when the current frame is actually presented. This method is deprecated — instead, you should usegetFrameData(), which also provides aVRPoseobject.
- : Returns a
resetPose()Deprecated- : Resets the pose for this
VRDisplay, treating its currentpositionandorientationas the “origin/zero” values.
- : Resets the pose for this
cancelAnimationFrame()Deprecated- : A special implementation of
cancelAnimationFramethat allows callbacks registered withrequestAnimationFrame()to be unregistered.
- : A special implementation of
requestAnimationFrame()Deprecated- : A special implementation of
requestAnimationFramecontaining a callback function that will be called every time a new frame of theVRDisplaypresentation is rendered.
- : A special implementation of
requestPresent()Deprecated- : Starts the
VRDisplaypresenting a scene.
- : Starts the
exitPresent()Deprecated- : Stops the
VRDisplaypresenting a scene.
- : Stops the
submitFrame()Deprecated- : Captures the current state of the
VRLayerInitcurrently being presented and displays it on theVRDisplay.
- : Captures the current state of the
Examples
if (navigator.getVRDisplays) {
console.log("WebVR 1.1 supported");
// Then get the displays attached to the computer
navigator.getVRDisplays().then((displays) => {
// If a display is available, use it to present the scene
if (displays.length > 0) {
vrDisplay = displays[0];
// Now we have our VRDisplay object and can do what we want with it
}
});
}
[!NOTE] You can see this complete code at raw-webgl-example.
Specifications
This interface was part of the old WebVR API that has been superseded by the WebXR Device API. It is no longer on track to becoming a standard.
Until all browsers have implemented the new WebXR APIs, it is recommended to rely on frameworks, like A-Frame, Babylon.js, or Three.js, or a polyfill, to develop WebXR applications that will work across all browsers. Read Meta’s Porting from WebVR to WebXR guide for more information.