VREyeParameters

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

VREyeParameters interface of the WebVR API represents all the information required to correctly render a scene for a given eye, including field of view information.

This interface is accessible through the VRDisplay.getEyeParameters() 方法。

The values in this interface should not be used to compute view or projection matrices. In order to ensure the widest possible hardware compatibility use the matrices provided by VRFrameData .

特性

VREyeParameters.offset 只读
Represents the o ffset from the center point between the user's eyes to the center of the eye, measured in meters.
VREyeParameters.fieldOfView 只读
Describes t he current field of view for the eye, which can vary as the user adjusts their interpupillary distance (IPD).
VREyeParameters.renderWidth 只读
Describes the recommended render target width of each eye viewport, in pixels.
VREyeParameters.renderHeight 只读
Describes the recommended render target height of each eye viewport, in pixels.

范例

navigator.getVRDisplays().then(function(displays) {
  // If a display is available, use it to present the scene
  vrDisplay = displays[0];
  console.log('Display found');
  // Starting the presentation when the button is clicked:
  //   It can only be called in response to a user gesture
  btn.addEventListener('click', function() {
    vrDisplay.requestPresent([{ source: canvas }]).then(function() {
      console.log('Presenting to WebVR display');
      // Set the canvas size to the size of the vrDisplay viewport
      var leftEye = vrDisplay.getEyeParameters('left');
      var rightEye = vrDisplay.getEyeParameters('right');
      canvas.width = Math.max(leftEye.renderWidth, rightEye.renderWidth) * 2;
      canvas.height = Math.max(leftEye.renderHeight, rightEye.renderHeight);
      drawVRScene();
    });
  });
});
					

规范

规范 状态 Comment
WebVR 1.1
The definition of 'VREyeParameters' 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
VREyeParameters
弃用
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.
fieldOfView
弃用
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.
maximumFieldOfView
弃用 非标
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
minimumFieldOfView
弃用 非标
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
offset
弃用
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.
recommendedFieldOfView
弃用 非标
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
renderHeight
弃用
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.
renderRect
弃用 非标
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
renderWidth
弃用
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.

图例

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

另请参阅