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.
VRDisplay.capabilities
Read only
VRDisplayCapabilities
object that indicates the various capabilities of the VRDisplay
.VRDisplay.depthFar
VRDisplay.depthNear
VRDisplay.displayId
Read only
Gamepad.displayId
).VRDisplay.displayName
Read only
VRDisplay
.VRDisplay.isConnected
Read only
Boolean
indicating whether the VRDisplay
is connected to the computer.VRDisplay.isPresenting
Read only
Boolean
indicating whether the VRDisplay
is currently having content presented through it.VRDisplay.stageParameters
Read only
VRStageParameters
object containing room-scale parameters, if the VRDisplay
is capable of supporting room-scale experiences.VRDisplay.getEyeParameters()
VREyeParameters
object containing the eye parameters for the specified eye.VRDisplay.getFrameData()
VRFrameData
object and populates it with the information required to render the current frame.VRDisplay.getLayers()
VRDisplay
.VRDisplay.resetPose()
VRDisplay
, treating its current VRPose.position
and VRPose.orientation
as the "origin/zero" values.VRDisplay.cancelAnimationFrame()
Window.cancelAnimationFrame
that allows callbacks registered with VRDisplay.requestAnimationFrame()
to be unregistered.VRDisplay.requestAnimationFrame()
Window.requestAnimationFrame
containing a callback function that will be called every time a new frame of the VRDisplay
presentation is rendered.VRDisplay.requestPresent()
VRDisplay
presenting a scene.VRDisplay.exitPresent()
VRDisplay
presenting a scene.VRDisplay.submitFrame()
VRLayer
currently being presented and displays it on the VRDisplay
.VRDisplay.getPose()
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.getImmediatePose()
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
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
.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.
Specification | Status | Comment |
---|---|---|
WebVR 1.1 The definition of 'VRDisplay' in that specification. | Editor's Draft | Initial definition |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes1 2 | Yes |
553 584 |
No | ? | ? |
cancelAnimationFrame |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
capabilities |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
depthFar |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
depthNear |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
displayId |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
displayName |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
exitPresent |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
getEyeParameters |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
getFrameData |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
getLayers |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
getImmediatePose |
No | No |
553 584 |
No | ? | ? |
getPose |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
hardwareUnitId |
No | No | No | No | ? | ? |
isConnected |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
isPresenting |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
requestAnimationFrame |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
resetPose |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
requestPresent |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
stageParameters |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
submitFrame |
Yes1 2 | Yes |
553 584 |
No | ? | ? |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | No | Yes5 | ? | ? | No | ? | ? |
cancelAnimationFrame |
No | Yes5 | ? | ? | No | ? | ? |
capabilities |
No | Yes5 | ? | ? | No | ? | ? |
depthFar |
No | Yes5 | ? | ? | No | ? | ? |
depthNear |
No | Yes5 | ? | ? | No | ? | ? |
displayId |
No | Yes5 | ? | ? | No | ? | ? |
displayName |
No | Yes5 | ? | ? | No | ? | ? |
exitPresent |
No | Yes5 | ? | ? | No | ? | ? |
getEyeParameters |
No | Yes5 | ? | ? | No | ? | ? |
getFrameData |
No | Yes5 | ? | ? | No | ? | ? |
getLayers |
No | Yes5 | ? | ? | No | ? | ? |
getImmediatePose |
No | No | No | ? | No | ? | ? |
getPose |
No | Yes5 | ? | ? | No | ? | ? |
hardwareUnitId |
No | No | No | ? | No | ? | ? |
isConnected |
No | Yes5 | ? | ? | No | ? | ? |
isPresenting |
No | Yes5 | ? | ? | No | ? | ? |
requestAnimationFrame |
No | Yes5 | ? | ? | No | ? | ? |
resetPose |
No | Yes5 | ? | ? | No | ? | ? |
requestPresent |
No | Yes5 | ? | ? | No | ? | ? |
stageParameters |
No | Yes5 | ? | ? | No | ? | ? |
submitFrame |
No | Yes5 | ? | ? | No | ? | ? |
1. Only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays()
is invoked).
2. This feature is behind the WebVR
preference. To change preferences in Chrome, visit chrome://flags.
3. Windows support was enabled in Firefox 55.
4. macOS support was enabled in Firefox 58.
5. Currently supported only by Google Daydream.
© 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