安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
XRPermissionDescriptor
dictionary's
requiredFeatures
property should be set prior to calling
navigator.permissions.query()
to a list of WebXR features which must be supported for the app to work.
This ensures that permissions are checked as applicable to ensure that those features are available upon request.
xrPermissionDescriptor = {
mode: xrSessionMode,
requiredFeatures: reqFeatureList,
optionalFeatures: optFeatureList
};
xrPermissionDescriptor.requiredFeatures = reqFeatureList;
reqFeatureList = xrPermissionDescriptor.requiredFeatures;
An array of strings indicating the WebXR features which must be available for use by the app or site. The permissions check will be performed in such a manner as to verify that all features in the list are available for use with the user's permission.
Currently, all features are members of the
XRReferenceSpaceType
enumerated type, indicating the reference space types that your app would like permission to use, but can operate without. Future editions of WebXR may add more recognized features.
The permitted values are:
The types of reference space are listed in the table below, with brief information about their use cases and which interface is used to implement them.
| XRReferenceSpaceType | 描述 | 接口 |
|---|---|---|
bounded-floor
|
类似于
local
type, except the user is not expected to move outside a predetermined boundary, given by the
boundsGeometry
in the returned object.
|
XRBoundedReferenceSpace
|
local
|
A tracking space whose native origin is located near the viewer's position at the time the session was created. The exact position depends on the underlying platform and implementation. The user isn't expected to move much if at all beyond their starting position, and tracking is optimized for this use case.
For devices with six degrees of freedom (6DoF) tracking, the
|
XRReferenceSpace
|
local-floor
|
类似于
local
type, except the starting position is placed in a safe location for the viewer to stand, where the value of the y axis is 0 at floor level. If that floor level isn't known, the
用户代理
will estimate the floor level. If the estimated floor level is non-zero, the browser is expected to round it such a way as to avoid fingerprinting (likely to the nearest centimeter).
|
XRReferenceSpace
|
unbounded
|
A tracking space which allows the user total freedom of movement, possibly over extremely long distances from their origin point. The viewer isn't tracked at all; tracking is optimized for stability around the user's current position, so the native origin may drift as needed to accommodate that need. |
XRReferenceSpace
|
viewer
|
A tracking space whose native origin tracks the viewer's position and orientation. This is used for environments in which the user can physically move around, and is supported by all instances of
XRSession
, both immersive and inline, though it's most useful for inline sessions. It's particularly useful when determining the distance between the viewer and an input, or when working with offset spaces. Otherwise, typically, one of the other reference space types will be used more often.
|
XRReferenceSpace
|
In this example, permissions are checked to ensure that the user has granted permission for the site or app to use immersive augmented reality mode with the
local-floor
reference space (presumably since the user is unlikely to start to fly).
let xrPermissionDesc = {
name: "xr",
mode: "immersive-ar",
requiredFeatures: [ "local-floor" ]
};
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.requiredFeatures' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
requiredFeatures
|
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 |
不支持
XRPermissionStatus
navigator.permissions
and
WorkerNavigator.permissions
权限
XRPermissionDescriptor
mode
optionalFeatures
requiredFeatures
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceArray
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer