安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

mode 特性为 XRPermissionDescriptor dictionary is a string taken from the XRSessionMode enumerated type, specifying which Web XR session mode ( inline , immersive-vr ,或 immersive-ar ) the described permissions will be used for.

句法

xrPermissionDescriptor = {
  mode: xrSessionMode,
  requiredFeatures: reqFeatureList,
  optionalFeatures: optFeatureList
};
xrPermissionDescriptor.mode = xrSessionMode;
xrMode = xrPermissionDescriptor.mode;
					

A DOMString whose value is one of the strings found in the XRSessionMode enumerated type:

immersive-ar

The session's output will be given exclusive access to the immersive device, but the rendered content will be blended with the real-world environment. The session's environmentBlendMode indicates the method to be used to blend the content together.

重要: immersive-ar mode is defined by the WebXR Augmented Reality Module, which is not yet stable and should not be used other than for testing and experimentation.

immersive-vr
Indicates that the rendered session will be displayed using an immersive XR device in VR mode; it is not intended to be overlaid or integrated into the surrounding environment. The environmentBlendMode is expected to be opaque if possible, but might be additive if the hardware requires it.
inline
The output is presented inline within the context of an element in a standard HTML document, rather than occupying the full visual space. Inline sessions can be presented in either mono or stereo mode, and may or may not have viewer tracking available. Inline sessions don't require special hardware and should be avalable on any 用户代理 offering WebXR API support.

用法注意事项

范例

The example below checks to ensure that permission has been granted to allow the user to use WebXR for an immersive virtual reality experience. No specific features are specified during this query; see requiredFeatures and optionalFeatures for more information on specifying features during a WebXR permission check.

let xrPermissionDesc = {
  name: "xr",
  mode: "immersive-vr"
};
if (navigator.permissions) {
  navigator.permissions.query(xrPermissionDesc).then(({state}) => {
    switch(state) {
      case "granted":
        setupXR();
        break;
      case "prompt":
        promptAndSetupXR();
        break;
      默认:
        /* do nothing otherwise */
       break;
  }
  .catch(err) {
    console.log(err);
  }
} else {
  setupXR();
}
					

规范

规范 状态 注释
WebXR 设备 API
The definition of 'XRPermissionDescriptor.mode' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
mode Chrome No Edge No Firefox No IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No

图例

不支持

不支持

另请参阅

元数据

  • 最后修改: