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

草案
此页面不完整。

只读 XRBoundedReferenceSpace property boundsGeometry 是数组化的 DOMPointReadOnly objects which specifies the points making up a polygon inside which the viewer is allowed to move. Each point is treated as a two-dimensional point, and must be located at ground level (that is, its y coordinate must be 0).

This boundary is typically configured by the user, using the software that controls their XR hardware. This may be done by walking the border of the space they wish to use, or by drawing the shape of their room using their XR input device. Theoretically, a more advanced system might use sensors or other detection methods to determine the bounds of a dedicated XR room (notice how we carefully don't call it a holodeck?).

句法

bounds = xrReferenceSpace.boundsGeometry;
					

boundsGeometry property is an array of DOMPointReadOnly objects, each of which defines one vertex in a polygon inside which the viewer is required to remain. Each point must be at floor level, with its y coordinate's value set to 0. Additionally, the value of w is always 1 in every point in the array. Additionally, the points must be listed in clockwise order.

Each entry in boundsGeometry is equal to an entry in the list of native bounds geometry points for the room, premultiplied by the inverse of the origin offset. In other words, the bounds are the physical limitations of the available space, shifted so that the reference space's bounds points are all defined relative to the XRBoundedReferenceSpace 's effective origiin.

用法注意事项

Bounded reference spaces always have their origin located at ground level, where y is 0. As a general rule, with the origin for x and z located in or near the center of the space, and with the orientation set facing in a logical forward direction, as appropriate for the underlying platform or XR hardware.

In order to reduce the risk of the room boundaries being used for fingerprinting purposes, each point in the boundsGeometry array may be rounded or adjusted by some amount. The specification recommends that browsers shift the points to the nearest 5 centimeters (while avoiding going outside the physical limitations of the hardware).

Boundary size

XRBoundedReferenceSpace is not intended to be used for very large bounded areas. Instead, it's meant to be used for one-room spaces with no more than around 15 meters of available movement space in any direction from the native origin. That said, the bounds extend upward indefinitely, since the bounds are defined in only two dimensions.

If you need to create a multi-room space, or a space which is very large or needs to have varying floor levels, you should instead use an unbounded XRReferenceSpace and enforce the bounds on your own, as appropriate.

Boundary shape

The shape defined by boundsGeometry may be as simple as a square or as complex as is needed, potentially including concave and/or convex sections. However, you can't represent spaces with uneven floor levels using XRBoundedReferenceSpace . The ground is always at y = 0.

It's important that your content not be designed to require the user to exit the bounds specified by boundsGeometry . However, if the user's surroundings permit them to move in such a way as to exit the defined bounds, your content must be able to gracefully handle the situation, which is not considered an error condition.

Although some samples render a mesh or other shape to display the bounds to the user, in a real-world application, you shouldn't do this. The browser, however, should provide appropriate warnings to the user about any risks (such as the risk that they might run into a physical wall if they keep moving).

规范

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

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

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

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

元数据

  • 最后修改: