Index · Object → OpenXRExtensionWrapper → OpenXRSpatialEntityExtension

OpenXRSpatialEntityExtension

OpenXR extension that handles spatial entities.

Class Description

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

func add_spatial_entity(spatial_context: RID, entity_id: int, entity: int) -> RID

Registers an entity that was created directly on the OpenXR runtime.

func create_spatial_context(capability_configurations: OpenXRSpatialCapabilityConfigurationBaseHeader[], next: OpenXRStructureBase = null, user_callback: Callable = Callable()) -> OpenXRFutureResult

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.

func discover_spatial_entities(spatial_context: RID, component_types: PackedInt64Array, next: OpenXRStructureBase = null, user_callback: Callable = Callable()) -> OpenXRFutureResult

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.

func discover_spatial_entities_with_component_data(spatial_context: RID, component_data: OpenXRSpatialComponentData[], next: OpenXRStructureBase = null, user_callback: Callable = Callable()) -> OpenXRFutureResult

Convenience method when the caller only has an Array of OpenXRSpatialComponentData and needs to discover spatial entities.

func find_spatial_entity(entity_id: int) -> RID

Returns the RID for the specified spatial entity ID.

func free_spatial_context(spatial_context: RID) -> void

Frees a spatial context previously created when calling create_spatial_context(). If the spatial context creation is still ongoing, the asynchronous process is cancelled.

func free_spatial_entity(entity: RID) -> void

Frees an entity previously created when calling add_spatial_entity() or make_spatial_entity().

func free_spatial_snapshot(spatial_snapshot: RID) -> void

Frees a spatial snapshot previously created when calling discover_spatial_entities(). If the spatial snapshot creation is still ongoing, the asynchronous process is cancelled.

func get_float_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedFloat32Array

Returns a buffer with floats from a buffer that was retrieved when taking a snapshot.

func get_spatial_context_handle(spatial_context: RID) -> int

Returns the OpenXR spatial context handle for this snapshot.

Note: This method is intended to be used from GDExtensions that implement spatial entity capability handlers.

func get_spatial_context_ready(spatial_context: RID) -> bool

Returns true if the spatial context finished its creation and is ready to be used.

func get_spatial_entity_context(entity: RID) -> RID

Returns the spatial context for this entity.

func get_spatial_entity_id(entity: RID) -> int

Returns the internal XrSpatialEntityIdEXT associated with the entity.

func get_spatial_snapshot_context(spatial_snapshot: RID) -> RID

Returns the spatial context related to this spatial snapshot.

func get_spatial_snapshot_handle(spatial_snapshot: RID) -> int

Returns the OpenXR spatial snapshot handle for this snapshot.

Note: This method is intended to be used from GDExtensions that implement spatial entity capability handlers.

func get_string(spatial_snapshot: RID, buffer_id: int) -> String

Returns a string from a buffer that was retrieved when taking a snapshot.

func get_uint8_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedByteArray

Returns a buffer with 8 bit ints from a buffer that was retrieved when taking a snapshot.

func get_uint16_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedInt32Array

Returns a buffer with 16 bit ints from a buffer that was retrieved when taking a snapshot.

func get_uint32_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedInt32Array

Returns a buffer with 32 bit ints from a buffer that was retrieved when taking a snapshot.

func get_vector2_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedVector2Array

Returns a buffer with Vector2 entries from a buffer that was retrieved when taking a snapshot.

func get_vector3_buffer(spatial_snapshot: RID, buffer_id: int) -> PackedVector3Array

Returns a buffer with Vector3 entries from a buffer that was retrieved when taking a snapshot.

func make_spatial_entity(spatial_context: RID, entity_id: int) -> RID

Creates a new entity for this entity_id. The spatial_context should match the context that discovered the entity.

func query_snapshot(spatial_snapshot: RID, component_data: OpenXRSpatialComponentData[], next: OpenXRStructureBase = null) -> bool

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.

func supports_capability(capability: OpenXRSpatialEntityExtension.Capability) -> bool

Returns true if this spatial entity capability is supported by the hardware used.

func supports_component_type(capability: OpenXRSpatialEntityExtension.Capability, component_type: OpenXRSpatialEntityExtension.ComponentType) -> bool

Returns true if this capability supports the component_type.

func update_spatial_entities(spatial_context: RID, entities: RID[], component_types: PackedInt64Array, next: OpenXRStructureBase = null) -> RID

Performs a snapshot for a limited number of entities. This is NOT an asynchronous method and will return the snapshot immediately.

Inherited from OpenXRExtensionWrapper (47)
func _on_event_polled(event: const void*) -> bool
func _on_instance_created(instance: int) -> void
func _on_instance_destroyed() -> void
func _on_post_draw_viewport(viewport: RID) -> void
func _on_pre_draw_viewport(viewport: RID) -> void
func _on_pre_render() -> void
func _on_process() -> void
func _on_register_metadata(interaction_profile_metadata: OpenXRInteractionProfileMetadata) -> void
func _on_session_created(session: int) -> void
func _on_session_destroyed() -> void
func _on_state_exiting() -> void
func _on_state_focused() -> void
func _on_state_idle() -> void
func _on_state_loss_pending() -> void
func _on_state_ready() -> void
func _on_state_stopping() -> void
func _on_state_synchronized() -> void
func _on_state_visible() -> void
func _on_sync_actions() -> void
func _on_viewport_composition_layer_destroyed(layer: const void*) -> void
func _prepare_view_configuration(view_count: int) -> void
func _set_frame_end_info_and_get_next_pointer(next_pointer: void*) -> int
func _set_frame_wait_info_and_get_next_pointer(next_pointer: void*) -> int
func _set_hand_joint_locations_and_get_next_pointer(hand_index: int, next_pointer: void*) -> int
func _set_instance_create_info_and_get_next_pointer(xr_version: int, next_pointer: void*) -> int
func _set_projection_layer_and_get_next_pointer(next_pointer: void*) -> int
func _set_projection_views_and_get_next_pointer(view_index: int, next_pointer: void*) -> int
func _set_reference_space_create_info_and_get_next_pointer(reference_space_type: int, next_pointer: void*) -> int
func _set_session_create_and_get_next_pointer(next_pointer: void*) -> int
func _set_view_configuration_and_get_next_pointer(view: int, next_pointer: void*) -> int
func _set_view_locate_info_and_get_next_pointer(next_pointer: void*) -> int
func _set_viewport_composition_layer_and_get_next_pointer(layer: const void*, property_values: Dictionary, next_pointer: void*) -> int
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)

Enums & Constants

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.

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).