VRDisplay

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

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() 方法。

特性

VRDisplay.capabilities 只读
返回 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 只读
Returns an identifier for this particular VRDisplay, which is also used as an association point in the 手柄 API (见 Gamepad.displayId ).
VRDisplay.displayName 只读
Returns a human-readable name to identify the VRDisplay .
VRDisplay.isConnected 只读
返回 Boolean indicating whether the VRDisplay is connected to the computer.
VRDisplay.isPresenting 只读
返回 Boolean indicating whether the VRDisplay is currently having content presented through it.
VRDisplay.stageParameters 只读
返回 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()
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 .

弃用方法

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 对象。

Obsolete methods

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
    }
  });
}
					

注意 : You can see this complete code at raw-webgl-example .

规范

规范 状态 Comment
WebVR 1.1
The definition of 'VRDisplay' in that specification.
草案 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
VRDisplay
弃用
Chrome No Edge ≤18 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
cancelAnimationFrame
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
capabilities
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
depthFar
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
depthNear
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
displayId
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
displayName
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
exitPresent
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
getEyeParameters
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
getFrameData
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
getImmediatePose
弃用 非标
Chrome No Edge No Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android No Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android No
getLayers
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
getPose
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
hardwareUnitId
弃用 非标
Chrome No Edge No Firefox No IE No Opera ? Safari No WebView Android No Chrome Android No Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android No
isConnected
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
isPresenting
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
requestAnimationFrame
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
requestPresent
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
resetPose
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
stageParameters
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.
submitFrame
弃用
Chrome No Edge 15 — 79 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android 56 — 80
Disabled
不支持 56 — 80
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 until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 55 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
6.0
Google Cardboard supported in Samsung Internet 7.0.

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
用户必须明确启用此特征。

另请参阅