VRDisplay
WebVR API
WebVR API
The **`VRDisplay`** interface of the [WebVR API](/docs/Web/API/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](https://immersive-web.github.io/webvr/spec/1.1/). It has been superseded by the [WebXR Device API](https://immersive-web.github.io/webxr/).
An array of all connected VR Devices can be returned by invoking the Navigator.getVRDisplays() method.
## Instance properties
- VRDisplay.capabilities
- : Returns a VRDisplayCapabilities object that indicates the various capabilities of the `VRDisplay`.
- VRDisplay.depthFar
- : Gets and sets the z-depth defining the far plane of the [eye view frustum](https://en.wikipedia.org/wiki/Viewing_frustum), i.e., the furthest viewable boundary of the scene.
- VRDisplay.depthNear
- : Gets and sets the z-depth defining the near plane of the [eye view frustum](https://en.wikipedia.org/wiki/Viewing_frustum), i.e., the nearest viewable boundary of the scene.
- VRDisplay.displayId
- : Returns an identifier for this particular VRDisplay, which is also used as an association point in the [Gamepad API](/docs/Web/API/Gamepad_API) (see Gamepad.displayId).
- VRDisplay.displayName
- : Returns a human-readable name to identify the `VRDisplay`.
- VRDisplay.isConnected
- : Returns a boolean value indicating whether the `VRDisplay` is connected to the computer.
- VRDisplay.isPresenting
- : Returns a boolean value indicating whether the `VRDisplay` is currently having content presented through it.
- VRDisplay.stageParameters
- : Returns a VRStageParameters object containing room-scale parameters, if the `VRDisplay` is capable of supporting room-scale experiences.
## Instance methods
- VRDisplay.getEyeParameters()
- : Returns the VREyeParameters object containing the eye parameters for the specified eye.
- VRDisplay.getFrameData()
- : Accepts a VRFrameData object and populates it with the information required to render the current frame.
- VRDisplay.getImmediatePose()
- : Returns a VRPose object defining the current pose of the `VRDisplay`, with no prediction applied. This is no longer needed, and has been removed from the spec.
- VRDisplay.getLayers()
- : Returns the layers currently being presented by the `VRDisplay`.
- VRDisplay.getPose()
- : Returns a VRPose object defining the future predicted pose of the `VRDisplay` as it will be when the current frame is actually presented. **This method is deprecated — instead, you should use VRDisplay.getFrameData(), which also provides a VRPose object.**
- VRDisplay.resetPose()
- : Resets the pose for this `VRDisplay`, treating its current VRPose.position and VRPose.orientation as the "origin/zero" values.
- VRDisplay.cancelAnimationFrame()
- : A special implementation of Window.cancelAnimationFrame that allows callbacks registered with VRDisplay.requestAnimationFrame() to be unregistered.
- VRDisplay.requestAnimationFrame()
- : A special implementation of Window.requestAnimationFrame containing a callback function that will be called every time a new frame of the `VRDisplay` presentation is rendered.
- VRDisplay.requestPresent()
- : Starts the `VRDisplay` presenting a scene.
- VRDisplay.exitPresent()
- : Stops the `VRDisplay` presenting a scene.
- VRDisplay.submitFrame()
- : Captures the current state of the VRLayerInit currently being presented and displays it on the `VRDisplay`.
## Examples
```js
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](https://github.com/mdn/webvr-tests/blob/main/webvr/raw-webgl-example/webgl-demo.js).
## Specifications
This interface was part of the old [WebVR API](https://immersive-web.github.io/webvr/spec/1.1/#interface-vrdisplay) that has been superseded by the [WebXR Device API](https://immersive-web.github.io/webxr/). It is no longer on track to becoming a standard.
Until all browsers have implemented the new [WebXR APIs](/docs/Web/API/WebXR_Device_API/Fundamentals), it is recommended to rely on frameworks, like [A-Frame](https://aframe.io/), [Babylon.js](https://www.babylonjs.com/), or [Three.js](https://threejs.org/), or a [polyfill](https://github.com/immersive-web/webxr-polyfill), to develop WebXR applications that will work across all browsers. Read [Meta's Porting from WebVR to WebXR](https://developers.meta.com/vr/documentation/web/port-vr-xr/) guide for more information.
## Browser compatibility
## See also
- [WebVR API](/docs/Web/API/WebVR_API)
Cite this
"VRDisplay". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy