W3cubDocs

/Web APIs

VRDisplay

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

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 Navigator.getVRDisplays() method.

Instance properties

VRDisplay.capabilities Read only Deprecated Non-standard

Returns a VRDisplayCapabilities object that indicates the various capabilities of the VRDisplay.

VRDisplay.depthFar Deprecated Non-standard

Gets and sets the z-depth defining the far plane of the eye view frustum, i.e. the furthest viewable boundary of the scene.

VRDisplay.depthNear Deprecated Non-standard

Gets and sets the z-depth defining the near plane of the eye view frustum, i.e. the nearest viewable boundary of the scene.

VRDisplay.displayId Read only Deprecated Non-standard

Returns an identifier for this particular VRDisplay, which is also used as an association point in the Gamepad API (see Gamepad.displayId).

VRDisplay.displayName Read only Deprecated Non-standard

Returns a human-readable name to identify the VRDisplay.

VRDisplay.isConnected Read only Deprecated Non-standard

Returns a boolean value indicating whether the VRDisplay is connected to the computer.

VRDisplay.isPresenting Read only Deprecated Non-standard

Returns a boolean value indicating whether the VRDisplay is currently having content presented through it.

VRDisplay.stageParameters Read only Deprecated Non-standard

Returns a VRStageParameters object containing room-scale parameters, if the VRDisplay is capable of supporting room-scale experiences.

Instance methods

VRDisplay.getEyeParameters() Deprecated Non-standard

Returns the VREyeParameters object containing the eye parameters for the specified eye.

VRDisplay.getFrameData() Deprecated Non-standard

Accepts a VRFrameData object and populates it with the information required to render the current frame.

VRDisplay.getImmediatePose() Deprecated Non-standard

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() Deprecated Non-standard

Returns the layers currently being presented by the VRDisplay.

VRDisplay.getPose() Deprecated Non-standard

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() Deprecated Non-standard

Resets the pose for this VRDisplay, treating its current VRPose.position and VRPose.orientation as the "origin/zero" values.

VRDisplay.cancelAnimationFrame() Deprecated Non-standard

A special implementation of Window.cancelAnimationFrame that allows callbacks registered with VRDisplay.requestAnimationFrame() to be unregistered.

VRDisplay.requestAnimationFrame() Deprecated Non-standard

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() Deprecated Non-standard

Starts the VRDisplay presenting a scene.

VRDisplay.exitPresent() Deprecated Non-standard

Stops the VRDisplay presenting a scene.

VRDisplay.submitFrame() Deprecated Non-standard

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.

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 [1].

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
VRDisplay No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
cancelAnimationFrame No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
capabilities No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
depthFar No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
depthNear No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
displayId No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
displayName No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
exitPresent No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
getEyeParameters No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
getFrameData No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
getImmediatePose No No 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No No
getLayers No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
getPose No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
isConnected No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
isPresenting No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
requestAnimationFrame No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
requestPresent No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
resetPose No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
stageParameters No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.
submitFrame No 15–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No No 55–98 No No
6.0Google Cardboard supported in Samsung Internet 7.0.

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay