W3cubDocs

/DOM

VRDisplay

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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.

An array of all connected VR Devices can be returned by invoking the Navigator.getVRDisplays() method.

Properties

VRDisplay.capabilities Read only
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, 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, i.e. the nearest viewable boundary of the scene.
VRDisplay.displayId Read only
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
Returns a human-readable name to identify the VRDisplay.
VRDisplay.isConnected Read only
Returns a Boolean indicating whether the VRDisplay is connected to the computer.
VRDisplay.isPresenting Read only
Returns a Boolean indicating whether the VRDisplay is currently having content presented through it.
VRDisplay.stageParameters Read only
Returns a VRStageParameters object containing room-scale parameters, if the VRDisplay is capable of supporting room-scale experiences.

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.getLayers()
Returns the layers currently being presented by the VRDisplay.
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 VRLayer currently being presented and displays it on the VRDisplay.

Deprecated methods

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.

Obsolete methods

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.hardwareUnitId
Returns a DOMString defining the shared ID of the display, and any other devices that are part of that hardware set (e.g. controllers). This is no longer needed, and has been removed from the spec. Displays now use VRDisplay.displayId, and corresponsing controllers will now return the same ID under Gamepad.displayId.

Examples

if(navigator.getVRDisplays) {
  console.log('WebVR 1.1 supported');
  // Then get the displays attached to the computer
  navigator.getVRDisplays().then(function(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

Specification Status Comment
WebVR 1.1
The definition of 'VRDisplay' in that specification.
Draft Initial definition

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support No Yes 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
cancelAnimationFrame No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
capabilities No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
depthFar No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
depthNear No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
displayId No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
displayName No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
exitPresent No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
getEyeParameters No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
getFrameData No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
getLayers No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
getImmediatePose No No 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
getPose No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
hardwareUnitId No No No No ? ?
isConnected No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
isPresenting No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
requestAnimationFrame No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
resetPose No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
requestPresent No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
stageParameters No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
submitFrame No 15 55
55
Windows support was enabled in Firefox 55.
63
macOS support was enabled in Firefox 63.
No ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
cancelAnimationFrame No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
capabilities No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
depthFar No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
depthNear No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
displayId No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
displayName No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
exitPresent No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
getEyeParameters No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
getFrameData No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
getLayers No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
getImmediatePose No No No ? ? ? No
getPose No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
hardwareUnitId No No No ? ? ? No
isConnected No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
isPresenting No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
requestAnimationFrame No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
resetPose No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
requestPresent No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
stageParameters No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0
submitFrame No 56
Disabled
56
Disabled
Only works in an experimental version of Chrome. (Other builds won't return any devices when Navigator.getVRDisplays() is invoked.)
Daydream View supported in Chrome 56.
Google Cardboard supported in Chrome 57.
Disabled From version 56: this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
? ? ? ? 6.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay