This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
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.capabilitiesRead only
- Returns a VRDisplayCapabilitiesobject 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.displayIdRead only
- Returns an identifier for this particular VRDisplay, which is also used as an association point in the Gamepad API (see Gamepad.displayId).
- VRDisplay.displayNameRead only
- Returns a human-readable name to identify the VRDisplay.
- VRDisplay.isConnectedRead only
- Returns a Booleanindicating whether theVRDisplayis connected to the computer.
- VRDisplay.isPresentingRead only
- Returns a Booleanindicating whether theVRDisplayis currently having content presented through it.
- VRDisplay.stageParametersRead only
- Returns a VRStageParametersobject containing room-scale parameters, if theVRDisplayis capable of supporting room-scale experiences.
Methods
- VRDisplay.getEyeParameters()
- Returns the VREyeParametersobject containing the eye parameters for the specified eye.
- VRDisplay.getFrameData()
- Accepts a VRFrameDataobject 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.positionandVRPose.orientationas the "origin/zero" values.
- VRDisplay.cancelAnimationFrame()
- A special implementation of Window.cancelAnimationFramethat allows callbacks registered withVRDisplay.requestAnimationFrame()to be unregistered.
- VRDisplay.requestAnimationFrame()
- A special implementation of Window.requestAnimationFramecontaining a callback function that will be called every time a new frame of theVRDisplaypresentation is rendered.
- VRDisplay.requestPresent()
- Starts the VRDisplaypresenting a scene.
- VRDisplay.exitPresent()
- Stops the VRDisplaypresenting a scene.
- VRDisplay.submitFrame()
- Captures the current state of the VRLayercurrently being presented and displays it on theVRDisplay.
Deprecated methods
- VRDisplay.getPose()
- Returns a VRPoseobject defining the future predicted pose of theVRDisplayas it will be when the current frame is actually presented. This method is deprecated — instead, you should useVRDisplay.getFrameData(), which also provides aVRPoseobject.
Obsolete methods
- VRDisplay.getImmediatePose()
- Returns a VRPoseobject 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 DOMStringdefining 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. | Editor's Draft | Initial definition | 
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) | 
|---|---|---|---|---|---|---|
| Basic support | No support[1] | (Yes) | 55 (55)[2] | No support | No support | No support | 
| Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android | Samsung Internet for GearVR | 
|---|---|---|---|---|---|---|---|---|
| Basic support | No support | No support | 55.0 (55) | No support | No support | No support | (Yes)[3] | (Yes) | 
[1] API Available on all platforms behind a flag, but currently only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays() is invoked).
[2] Currently only Windows support is enabled by default. Mac support is available in Firefox Nightly.
[3] Currently supported only by Google Daydream.
See also
- WebVR API homepage
- MozVr.com — demos, downloads, and other resources from the Mozilla VR team.