XrSpatialAnchor QML Type

跟踪真实空间中的特定位置或物体。更多

Import Statement: import QtQuick3D.Xr
Since: Qt 6.8
Inherits:

QtObject

Status: Technical Preview

属性

详细说明

该类型表示空间锚,可跟踪现实空间中的特定位置或物体。它提供有关锚点位置、旋转、分类和边界的信息。

空间锚点可通过XrSpatialAnchorListModel 访问。

注: 系统提供锚对象。它们不能在 QML 中创建。

有关如何使用该类型,请参阅Qt Quick 3D - XR 空间锚示例

平台说明

Meta Quest 设备

此 API 使用 Meta Quest 场景和空间锚点 API。您需要在应用程序的AndroidManifest.xml 文件中添加以下权限:

<uses-permission android:name="com.oculus.permission.USE_ANCHOR_API"/>
<uses-permission android:name="com.oculus.permission.USE_SCENE"/>

注意: 在运行应用程序之前,您需要手动设置空间,否则锚点将不可用。

属性文档

Classification : enumeration [read-only]

空间锚点的分类。

分类枚举提供了一组预定义的类别类型,用于描述空间锚点的用途或上下文。

常量说明
Classification.Unknown标签尚未设置或识别。
Classification.Wall锚点代表墙壁。
Classification.Ceiling锚点代表天花板。
Classification.Floor锚点代表地板。
Classification.Table锚点代表桌子。
Classification.Seat锚点代表座位。
Classification.Window锚点代表窗户
Classification.Door锚栓代表门
Classification.Other锚没有被识别为上述任何类型。请参阅:classificationString

下表显示了Qt Quick 3D Xr、OpenXR 和 VisionOS 中分类类型之间的映射。如果来自系统的分类类型不属于定义的类型,那么类型将设置为Other ,系统类型由classificationString 属性提供。

注: 分类字符串也可以是Other

类型OpenXRVisionOS描述
未知--标签尚未设置或识别。
墙面墙面墙面锚点代表一面墙。
天花板天花板天花板锚点代表天花板。
地板地板地板锚点代表地板。
桌子表格桌子锚点代表一张桌子。
座椅沙发座椅锚点代表座位。
窗户窗框窗户锚点代表窗户。
门框锚点代表一扇门。
其他--锚点代表其他东西。参见:classificationString

classification : enumeration [read-only]

空间锚点的分类类型。

该属性返回该锚点的classification type (如TableFloor ),描述了锚点的目的或上下文。

注意: 来自系统的分类类型可能不在Classification 枚举定义的标签集中,在这种情况下,类型将被设置为Other ,而classificationString 属性将包含原始标签。

另请参阅 classificationString


classificationString : string [read-only]

空间锚点的分类类型(字符串)。

如果存在分类类型,该属性将以字符串形式返回分类类型。如果分类类型不在Classification 枚举定义的类型集中,则标签将设为Other ,该属性可用于访问系统报告的类型。

注: 该字符串可以为空,也可以更改,具体取决于系统和锚点的分类方式。

另请参阅 classification


extent2D : vector2d [read-only]

空间锚点的二维范围。

该属性表示空间锚在 X/Z 平面内的二维尺寸(宽度和高度)。它在has2DBoundstrue 时有效。

另请参阅 has2DBoundsoffset2D


extent3D : vector3d [read-only]

空间锚点的三维范围。

该属性指定空间锚点在三维空间(宽度、高度和深度)中的体积。当has3DBoundstrue 时有效。

另请参阅 offset3Dhas3DBounds


has2DBounds : bool [read-only]

表示空间锚点是否有二维边界。

如果空间锚点有二维边界(由offset2Dextent2D 描述),则该属性为true ,表示空间锚点代表一个平面(例如地板或墙)。

否则,返回 false。

另请参阅 offset2D,extent2D, 和has3DBounds


has3DBounds : bool [read-only]

表示空间锚点是否有三维边界。

如果空间锚点有三维边界,则此属性返回true ,表示空间锚点代表一个体积(如桌子或柜子)。边界由offset3Dextent3D 描述。

否则,返回false

另请参阅 offset3D,extent3D, 和has2DBounds


identifier : string [read-only]

该空间锚点的唯一标识符。

该属性包含与空间锚相关联的唯一标识符。这与XrSpatialAnchorListModel 引用的标识符相同。


offset2D : vector2d [read-only]

空间锚的二维偏移量。

该属性包含锚点边界在 X/Z 平面内的偏移量。它在has2DBoundstrue 时有效。

另请参阅 has2DBoundsextent2D


offset3D : vector3d [read-only]

空间锚点的三维偏移。

该属性提供了锚点边界与锚点position 的三维偏移量(以米为单位)。

另请参阅 offset3D 和has3DBounds


position : vector3d [read-only]

空间锚点的位置。

该属性返回空间锚点在会话坐标系中原点的三维位置(以米为单位)。


rotation : quaternion [read-only]

空间锚点的方向。

该属性提供空间锚的旋转(四元数)。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.