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 theVRDisplay
. 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 theVRDisplay
is connected to the computer. VRDisplay.isPresenting
Read only- Returns a
Boolean
indicating whether theVRDisplay
is currently having content presented through it. VRDisplay.stageParameters
Read only- Returns a
VRStageParameters
object containing room-scale parameters, if theVRDisplay
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 currentVRPose.position
andVRPose.orientation
as the "origin/zero" values. VRDisplay.cancelAnimationFrame()
- A special implementation of
Window.cancelAnimationFrame
that allows callbacks registered withVRDisplay.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 theVRDisplay
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 theVRDisplay
.
Deprecated methods
VRDisplay.getPose()
- Returns a
VRPose
object defining the future predicted pose of theVRDisplay
as it will be when the current frame is actually presented. This method is deprecated โ instead, you should useVRDisplay.getFrameData()
, which also provides aVRPose
object.
Obsolete methods
VRDisplay.getImmediatePose()
- Returns a
VRPose
object defining the current pose of theVRDisplay
, 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 useVRDisplay.displayId
, and corresponsing controllers will now return the same ID underGamepad.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 compatibility
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
VRDisplay | Chrome No support No | Edge Full support Yes | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
cancelAnimationFrame | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
capabilities | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
depthFar | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
depthNear | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
displayId | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
displayName | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
exitPresent | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
getEyeParameters | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
getFrameData | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
getImmediatePose | Chrome No support No | Edge No support No | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android No support No | Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android No support No |
getLayers | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
getPose | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
hardwareUnitId | Chrome No support No | Edge No support No | Firefox No support No | IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android No support No | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android No support No |
isConnected | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
isPresenting | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
requestAnimationFrame | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
requestPresent | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
resetPose | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
stageParameters | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
submitFrame | Chrome No support No | Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari ? | WebView Android No support No | Chrome Android
Full support
56
| Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
Legend
- Full support ย
- Full support
- No support ย
- No support
- Compatibility unknown ย
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
See also
- WebVR API homepage
- MozVr.com โ demos, downloads, and other resources from the Mozilla VR team.