C Specification
The xrCreateSpatialAnchorEXT function is defined as:
// Provided by XR_EXT_spatial_anchor
XrResult xrCreateSpatialAnchorEXT(
XrSpatialContextEXT spatialContext,
const XrSpatialAnchorCreateInfoEXT* createInfo,
XrSpatialEntityIdEXT* anchorEntityId,
XrSpatialEntityEXT* anchorEntity);
Parameters
The application can create a spatial anchor by using xrCreateSpatialAnchorEXT.
Description
To get updated component data for an anchor, pass the value populated in
anchorEntity into the
XrSpatialUpdateSnapshotCreateInfoEXT::entities when creating a
snapshot.
The application can use anchorEntityId to uniquely identify this
anchor in the XrSpatialComponentDataQueryResultEXT::entityIds
array when using xrQuerySpatialComponentDataEXT.
The runtime must return XR_ERROR_VALIDATION_FAILURE from
xrCreateSpatialAnchorEXT if XR_SPATIAL_CAPABILITY_ANCHOR_EXT was
not configured for spatialContext.
See https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#ext_spatial_anchor_config for how to configure an
XrSpatialContextEXT for the XR_SPATIAL_CAPABILITY_ANCHOR_EXT
capability.
The anchor represented by anchorEntity is only valid for the lifetime
of spatialContext, or until the application calls
xrDestroySpatialEntityEXT on it, whichever comes first.
Other extensions may offer functions to persist this newly created anchor
across multiple XrSession or to share it across process boundaries
with other applications.
A newly created anchor, until destroyed, must be discoverable in its parent
spatial context.
This means that the runtime must include anchorEntityId in the
snapshot created using xrCreateSpatialDiscoverySnapshotAsyncEXT for
spatialContext if the anchor matches the discovery criteria set in
XrSpatialDiscoverySnapshotCreateInfoEXT.
The newly created anchor may also be discoverable in other spatial contexts
configured with XR_SPATIAL_CAPABILITY_ANCHOR_EXT, although with a
different XrSpatialEntityIdEXT since a particular
XrSpatialEntityIdEXT is unique to its XrSpatialContextEXT.
See Also
Document Notes
For more information, see the OpenXR Specification
This page is extracted from the OpenXR Specification. Fixes and changes should be made to the Specification, not directly.
Copyright
Copyright 2014-2025 The Khronos Group Inc.
This work is licensed under a Creative Commons Attribution 4.0 International License.