- Qt 6.11
- Qt Quick 3D
- QML Types
- QtQuick3D.Xr (Technology Preview)
- XrSpatialAnchor
- Qt Quick 3D | Commercial or GPLv3

# XrSpatialAnchor QML Type

Tracks a specific location or object in real space. More...

Import Statement: | `import QtQuick3D.Xr`
Since: | Qt 6.8
Inherits: | QtObject
Status: | Technology Preview

- List of all members, including inherited members

## Properties

- Classification : enumeration
- classification : enumeration
- classificationString : string
- extent2D : vector2d
- extent3D : vector3d
- has2DBounds : bool
- has3DBounds : bool
- identifier : string
- offset2D : vector2d
- offset3D : vector3d
- position : vector3d
- rotation : quaternion

## Detailed Description

This type represents a spatial anchor that tracks a specific location or object in real space. It provides information about the anchor's position, rotation, classification, and bounds.

Spatial anchors are accessed through an XrSpatialAnchorListModel.

Note: The system provides Anchor objects. They cannot be created in QML.

See the Qt Quick 3D - XR Spatial Anchors Example for how to use this type.

## Platform notes

### Meta Quest Devices

This API makes use of the Meta Quest Scene and Spatial Anchor APIs. You need to add the following permissions to your app's `AndroidManifest.xml` file:

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

Note: You need to manually set up a Space before running an app, or anchors will not be available.

## Property Documentation

### Classification : enumeration `[read-only]`

The classification of the spatial anchor.

The Classification enum provides a set of predefined category types that describe the purpose or context of a spatial anchor.

Constant | Description
--- | ---
`Classification.Unknown` | The label has not been set or identified.
`Classification.Wall` | The anchor represents a wall.
`Classification.Ceiling` | The anchor represents a ceiling.
`Classification.Floor` | The anchor represents a floor.
`Classification.Table` | The anchor represents a table.
`Classification.Seat` | The anchor represents a seat.
`Classification.Window` | The anchor represents a window.
`Classification.Door` | The anchor represents a door.
`Classification.Other` | The anchor was not identified as any of the above types. See: classificationString

The following table shows the mapping between the classification type in Qt Quick 3D Xr, OpenXR, and VisionOS. If the classification type from the system falls outside of the defined types, then the Type is set to `Other`, and the system type is provided by the classificationString property.

Note: The classification string can also be `Other`.

Type | OpenXR | VisionOS | Description
--- | --- | --- | ---
Unknown | - | - | The label has not been set or identified.
Wall | WALL_FACE | Wall | The anchor represents a wall.
Ceiling | CEILING | Ceiling | The anchor represents a ceiling.
Floor | FLOOR | Floor | The anchor represents a floor.
Table | TABLE | Table | The anchor represents a table.
Seat | COUCH | Seat | The anchor represents a seat.
Window | WINDOW_FRAME | Window | The anchor represents a window.
Door | DOOR_FRAME | Door | The anchor represents a door.
Other | - | - | The anchor represents something else. See: classificationString

### classification : enumeration `[read-only]`

The classification type of the spatial anchor.

This property returns the classification type for this anchor (for example,`Table` or `Floor`) describing the anchor's purpose or context.

Note: The classification type coming from the system might not be in the set of labels defined by the Classification enum, in which case the type will be set to `Other` and the classificationString property will contain the original label.

See also classificationString.

### classificationString : string `[read-only]`

The classification type of the spatial anchor as a string.

This property returns the classification type as a string if one exists. If the classification type is not in the set of types defined by the Classification enums, the label is set to `Other`, and this property can be used to access the type as it was reported by the system.

Note: This string can be empty or change, depending on the system and how the anchor gets classified.

See also classification.

### extent2D : vector2d `[read-only]`

The 2D extent of the spatial anchor.

This property holds the spatial anchor's size in two dimensions (width and height) within the X/Z plane. It is valid when has2DBounds is `true`.

See also has2DBounds and offset2D.

### extent3D : vector3d `[read-only]`

The 3D extent of the spatial anchor.

This property specifies the spatial anchor's volume in three dimensions (width, height, and depth). It is valid when has3DBounds is `true`.

See also offset3D and has3DBounds.

### has2DBounds : bool `[read-only]`

Indicates whether the spatial anchor has 2D bounds.

This property holds `true` if the spatial anchor has 2D bounds, described by offset2D and extent2D, indicating that it represents a flat surface (for example, a floor or wall).

Otherwise, it returns false.

See also offset2D, extent2D, and has3DBounds.

### has3DBounds : bool `[read-only]`

Indicates whether the spatial anchor has 3D bounds.

This property returns `true` if the spatial anchor has 3D bounds, indicating that it represents a volume (for example, a table or a cupboard). The bounds are described by offset3D and extent3D.

Otherwise, it returns `false`.

See also offset3D, extent3D, and has2DBounds.

### identifier : string `[read-only]`

A unique identifier for this spatial anchor.

This property holds a unique identifier associated with the spatial anchor. This is the same identifier referenced by a XrSpatialAnchorListModel.

### offset2D : vector2d `[read-only]`

The 2D offset of the spatial anchor.

This property holds the offset of the anchor's bounds within the X/Z plane. It is valid when has2DBounds is `true`.

See also has2DBounds and extent2D.

### offset3D : vector3d `[read-only]`

The 3D offset of the spatial anchor.

This property provides the 3D offset of the anchor's bounds (in meters) from the anchor's position.

See also offset3D and has3DBounds.

### position : vector3d `[read-only]`

The position of the spatial anchor.

This property returns the 3D position (in meters) of the spatial anchor's origin within the session's coordinate system.

### rotation : quaternion `[read-only]`

The orientation of the spatial anchor.

This property provides the spatial anchor's rotation (as a quaternion).