OpenXRSpatialEntityExtension
Inherits: OpenXRExtensionWrapper < Object
Description
Section titled “Description”OpenXR extension that handles spatial entities.
OpenXR extension that handles spatial entities and, when enabled, allows querying those spatial entities. This extension will also automatically manage XRTracker objects for static entities.
Methods
Section titled “Methods”Signals
Section titled “Signals”spatial_discovery_recommended
spatial_discovery_recommended(spatial_context: RID)
Emitted when OpenXR recommends running a discovery query because entities managed by this spatial context have (likely) changed.
Enumerations
Section titled “Enumerations”Capability
enum Capability
CAPABILITY_PLANE_TRACKING = 1000741000
Plane tracking capability.
CAPABILITY_MARKER_TRACKING_QR_CODE = 1000743000
QR code based marker tracking capability.
CAPABILITY_MARKER_TRACKING_MICRO_QR_CODE = 1000743001
Micro QR code based marker tracking capability.
CAPABILITY_MARKER_TRACKING_ARUCO_MARKER = 1000743002
ArUco marker based marker tracking capability.
CAPABILITY_MARKER_TRACKING_APRIL_TAG = 1000743003
April tag based marker tracking capability.
CAPABILITY_ANCHOR = 1000762000
Anchor capability.
ComponentType
enum ComponentType
COMPONENT_TYPE_BOUNDED_2D = 1
Component that provides the 2D bounds for a spatial entity. The corresponding list structure is XrSpatialComponentBounded2DListEXT; the corresponding data structure is XrSpatialBounded2DDataEXT.
COMPONENT_TYPE_BOUNDED_3D = 2
Component that provides the 3D bounds for a spatial entity. The corresponding list structure is XrSpatialComponentBounded3DListEXT; the corresponding data structure is XrBoxf.
COMPONENT_TYPE_PARENT = 3
Component that provides the XrSpatialEntityIdEXT of the parent for a spatial entity. The corresponding list structure is XrSpatialComponentParentListEXT; the corresponding data structure is XrSpatialEntityIdEXT.
COMPONENT_TYPE_MESH_3D = 4
Component that provides a 3D mesh for a spatial entity. The corresponding list structure is XrSpatialComponentMesh3DListEXT; the corresponding data structure is XrSpatialMeshDataEXT.
COMPONENT_TYPE_PLANE_ALIGNMENT = 1000741000
Component that provides the plane alignment enum for a spatial entity. The corresponding list structure is XrSpatialComponentPlaneAlignmentListEXT; the corresponding data structure is XrSpatialPlaneAlignmentEXT (Added by the XR_EXT_spatial_plane_tracking extension).
COMPONENT_TYPE_MESH_2D = 1000741001
Component that provides a 2D mesh for a spatial entity. The corresponding list structure is XrSpatialComponentMesh2DListEXT; the corresponding data structure is XrSpatialMeshDataEXT (Added by the XR_EXT_spatial_plane_tracking extension).
COMPONENT_TYPE_POLYGON_2D = 1000741002
Component that provides a 2D boundary polygon for a spatial entity. The corresponding list structure is XrSpatialComponentPolygon2DListEXT; the corresponding data structure is XrSpatialPolygon2DDataEXT (Added by the XR_EXT_spatial_plane_tracking extension).
COMPONENT_TYPE_PLANE_SEMANTIC_LABEL = 1000741003
Component that provides a semantic label for a plane. The corresponding list structure is XrSpatialComponentPlaneSemanticLabelListEXT; the corresponding data structure is XrSpatialPlaneSemanticLabelEXT (Added by the XR_EXT_spatial_plane_tracking extension).
COMPONENT_TYPE_MARKER = 1000743000
A component describing the marker type, ID and location. The corresponding list structure is XrSpatialComponentMarkerListEXT; the corresponding data structure is XrSpatialMarkerDataEXT (Added by the XR_EXT_spatial_marker_tracking extension).
COMPONENT_TYPE_ANCHOR = 1000762000
Component that provides the location for an anchor. The corresponding list structure is XrSpatialComponentAnchorListEXT; the corresponding data structure is XrPosef (Added by the XR_EXT_spatial_anchor extension).
COMPONENT_TYPE_PERSISTENCE = 1000763000
Component that provides the persisted UUID for a spatial entity. The corresponding list structure is XrSpatialComponentPersistenceListEXT; the corresponding data structure is [code]XrSpatialPersistenceDataEXT (Added by the XR_EXT_spatial_persistence extension).
TrackingState
enum TrackingState
TRACKING_UNSUPPORTED_CAPABILITY = -3
A capability supplied when creating the spatial context for tracking is unsupported.
TRACKING_NO_PERMISSION = -2
A permission required by the tracking logic is missing.
TRACKING_SETUP_FAILED = -1
Setup of the tracking logic failed, consult the logs for more details.
TRACKING_NOT_ACTIVE = 0
Tracking is currently not active.
TRACKING_SETTING_UP = 1
Tracking is being set up.
TRACKING_ENABLED = 2
Tracking is enabled and running.
Method descriptions
Section titled “Method descriptions”add_spatial_entity
RID add_spatial_entity(spatial_context: RID, entity_id: int, entity: int)
Registers an entity that was created directly on the OpenXR runtime.
create_spatial_context
OpenXRFutureResult create_spatial_context(capability_configurations: Array[OpenXRSpatialCapabilityConfigurationBaseHeader], next: OpenXRStructureBase = null, user_callback: Callable = Callable(), failed_callback: Callable = Callable())
Creates a new spatial context that handles entities for the provided capability configurations. capability_configurations is an array of OpenXRSpatialCapabilityConfigurationBaseHeader with the needed capability configuration data.
next is an optional parameter that can contain additional information for creating our spatial context.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the creation process.
On success user_callback will be called if specified. The result data for this function is the RID for our spatial context - the argument will be the OpenXR result code (as an integer).
On failure failed_callback will be called if specified. The OpenXR result code will be supplied as an integer - the arguments will be the OpenXR result code (as an integer) and a boolean indicating whether requesting the result failed, or the execution failed.
discover_spatial_entities
OpenXRFutureResult discover_spatial_entities(spatial_context: RID, component_types: PackedInt64Array, next: OpenXRStructureBase = null, user_callback: Callable = Callable())
Starts a new discovery query, this will gather all objects tracked by the spatial_context that have at least one of the component types specified in component_types.
next is an optional parameter that can contain additional information for executing the discovery query.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the discovery process. On success user_callback will be called if specified. The result data for this function is the RID for our snapshot.
discover_spatial_entities_with_component_data
OpenXRFutureResult discover_spatial_entities_with_component_data(spatial_context: RID, component_data: Array[OpenXRSpatialComponentData], next: OpenXRStructureBase = null, user_callback: Callable = Callable())
Convenience method when the caller only has an Array of OpenXRSpatialComponentData and needs to discover spatial entities.
find_spatial_entity
RID find_spatial_entity(entity_id: int)
Returns the RID for the specified spatial entity ID.
free_spatial_context
void free_spatial_context(spatial_context: RID)
Frees a spatial context previously created when calling create_spatial_context(). If the spatial context creation is still ongoing, the asynchronous process is cancelled.
free_spatial_entity
void free_spatial_entity(entity: RID)
Frees an entity previously created when calling add_spatial_entity() or make_spatial_entity().
free_spatial_snapshot
void free_spatial_snapshot(spatial_snapshot: RID)
Frees a spatial snapshot previously created when calling discover_spatial_entities(). If the spatial snapshot creation is still ongoing, the asynchronous process is cancelled.
get_float_buffer
PackedFloat32Array get_float_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with floats from a buffer that was retrieved when taking a snapshot.
get_spatial_context_handle
int get_spatial_context_handle(spatial_context: RID) const
Returns the OpenXR spatial context handle for this snapshot.
Note: This method is intended to be used from NativeExtensions that implement spatial entity capability handlers.
get_spatial_context_ready
bool get_spatial_context_ready(spatial_context: RID) const
Returns true if the spatial context finished its creation and is ready to be used.
get_spatial_entity_context
RID get_spatial_entity_context(entity: RID) const
Returns the spatial context for this entity.
get_spatial_entity_id
int get_spatial_entity_id(entity: RID) const
Returns the internal XrSpatialEntityIdEXT associated with the entity.
get_spatial_snapshot_context
RID get_spatial_snapshot_context(spatial_snapshot: RID) const
Returns the spatial context related to this spatial snapshot.
get_spatial_snapshot_handle
int get_spatial_snapshot_handle(spatial_snapshot: RID) const
Returns the OpenXR spatial snapshot handle for this snapshot.
Note: This method is intended to be used from NativeExtensions that implement spatial entity capability handlers.
get_string
String get_string(spatial_snapshot: RID, buffer_id: int) const
Returns a string from a buffer that was retrieved when taking a snapshot.
get_uint8_buffer
PackedByteArray get_uint8_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with 8 bit ints from a buffer that was retrieved when taking a snapshot.
get_uint16_buffer
PackedInt32Array get_uint16_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with 16 bit ints from a buffer that was retrieved when taking a snapshot.
get_uint32_buffer
PackedInt32Array get_uint32_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with 32 bit ints from a buffer that was retrieved when taking a snapshot.
get_vector2_buffer
PackedVector2Array get_vector2_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with Vector2 entries from a buffer that was retrieved when taking a snapshot.
get_vector3_buffer
PackedVector3Array get_vector3_buffer(spatial_snapshot: RID, buffer_id: int) const
Returns a buffer with Vector3 entries from a buffer that was retrieved when taking a snapshot.
make_spatial_entity
RID make_spatial_entity(spatial_context: RID, entity_id: int)
Creates a new entity for this entity_id. The spatial_context should match the context that discovered the entity.
query_snapshot
bool query_snapshot(spatial_snapshot: RID, component_data: Array[OpenXRSpatialComponentData], next: OpenXRStructureBase = null)
Queries the snapshot data. This will find all entities in the snapshot that contain all requested components in component_data. The objects held within component_data will then be populated with the queried data. component_data must always have an object of OpenXRSpatialQueryResultData as the first entry.
next is an optional parameter that can contain additional information passed when setting our query conditions.
supports_capability
bool supports_capability(capability: Capability)
Returns true if this spatial entity capability is supported by the hardware used.
supports_component_type
bool supports_component_type(capability: Capability, component_type: ComponentType)
Returns true if this capability supports the component_type.
update_spatial_entities
RID update_spatial_entities(spatial_context: RID, entities: Array[RID], component_types: PackedInt64Array, next: OpenXRStructureBase = null)
Performs a snapshot for a limited number of entities. This is NOT an asynchronous method and will return the snapshot immediately.
