:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/../../GodotApplePlugins/doc_classes/ARSession.xml. .. _class_ARSession: ARSession ========= **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Manages an AR session with world tracking, plane detection, and anchor management. .. rst-class:: classref-introduction-group Description ----------- The main entry point for ARKit functionality. Supports world tracking, plane detection, scene reconstruction, hand tracking, image tracking, and more depending on platform. \ **Platform availability:**\ - **iOS:** Full support for all features including raycasting, world map persistence, collaboration, body/face/geo tracking, and camera image capture. - **visionOS:** World tracking, plane detection, scene reconstruction, hand tracking, and image tracking via async providers. Raycasting, world maps, collaboration, body tracking, and camera images are not available (use RealityKit for spatial queries on visionOS). - **macOS 26.0+:** Remote-session bridge only. Connects to a remote iOS/visionOS device and relays camera pose via DeviceAnchor. Anchor CRUD, raycasting, world maps, collaboration, and all other features are not available through the remote API. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-------------------------------------------------------------------------+--------------------------------------------------------------+--------------------------------------------+ | :ref:`Array` | :ref:`anchors` | ``[]`` | +-------------------------------------------------------------------------+--------------------------------------------------------------+--------------------------------------------+ | :ref:`ARWorldTrackingConfiguration` | :ref:`configuration` | ``null`` | +-------------------------------------------------------------------------+--------------------------------------------------------------+--------------------------------------------+ | :ref:`ARFrame` | :ref:`current_frame` | ``null`` | +-------------------------------------------------------------------------+--------------------------------------------------------------+--------------------------------------------+ | :ref:`String` | :ref:`identifier` | ``"C3DA7EF3-0621-46A4-BFFA-30B88A331CCD"`` | +-------------------------------------------------------------------------+--------------------------------------------------------------+--------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_anchor`\ (\ anchor\: :ref:`ARAnchor`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`capture_high_resolution_frame`\ (\ callback\: :ref:`Callable`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`get_current_world_map`\ (\ callback\: :ref:`Callable`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_supported`\ (\ ) |static| | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`pause`\ (\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`raycast`\ (\ query\: :ref:`ARRaycastQuery`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_all_anchors`\ (\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_anchor`\ (\ anchor\: :ref:`ARAnchor`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`run`\ (\ configuration\: :ref:`ARWorldTrackingConfiguration`, options\: :ref:`int`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`run_body_tracking`\ (\ configuration\: :ref:`ARBodyTrackingConfiguration`, options\: :ref:`int`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`run_geo_tracking`\ (\ configuration\: :ref:`ARGeoTrackingConfiguration`, options\: :ref:`int`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`run_with_world_map`\ (\ configuration\: :ref:`ARWorldTrackingConfiguration`, worldMap\: :ref:`ARWorldMap`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_world_origin`\ (\ relativeTransform\: :ref:`Transform3D`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`ARTrackedRaycast` | :ref:`tracked_raycast`\ (\ query\: :ref:`ARRaycastQuery`, callback\: :ref:`Callable`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`update_with_collaboration_data`\ (\ data\: :ref:`ARCollaborationData`\ ) | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_ARSession_signal_anchors_added: .. rst-class:: classref-signal **anchors_added**\ (\ anchors\: :ref:`Array`\ ) :ref:`🔗` Emitted when new anchors are added to the session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_anchors_removed: .. rst-class:: classref-signal **anchors_removed**\ (\ anchors\: :ref:`Array`\ ) :ref:`🔗` Emitted when anchors are removed from the session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_anchors_updated: .. rst-class:: classref-signal **anchors_updated**\ (\ anchors\: :ref:`Array`\ ) :ref:`🔗` Emitted when existing anchors receive updated pose or geometry data. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_camera_tracking_changed: .. rst-class:: classref-signal **camera_tracking_changed**\ (\ camera\: :ref:`ARCamera`\ ) :ref:`🔗` Emitted when the camera tracking state changes. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_collaboration_data_received: .. rst-class:: classref-signal **collaboration_data_received**\ (\ collaborationData\: :ref:`ARCollaborationData`\ ) :ref:`🔗` Emitted when collaboration data is produced for multi-peer AR. **iOS 13+ only.** Requires ``isCollaborationEnabled`` on the configuration. Never emitted on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_frame_updated: .. rst-class:: classref-signal **frame_updated**\ (\ frame\: :ref:`ARFrame`\ ) :ref:`🔗` Emitted whenever the session produces a new frame. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_hand_anchor_updated: .. rst-class:: classref-signal **hand_anchor_updated**\ (\ hand\: :ref:`ARHandAnchor`\ ) :ref:`🔗` Emitted when a hand anchor is added or updated. **visionOS only.** Never emitted on iOS or macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_interruption_ended: .. rst-class:: classref-signal **interruption_ended**\ (\ ) :ref:`🔗` Emitted after the session interruption has ended and tracking can resume. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_mesh_anchor_added: .. rst-class:: classref-signal **mesh_anchor_added**\ (\ mesh\: :ref:`ARMeshAnchor`\ ) :ref:`🔗` Emitted when scene reconstruction produces a new mesh anchor. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_mesh_anchor_removed: .. rst-class:: classref-signal **mesh_anchor_removed**\ (\ mesh\: :ref:`ARMeshAnchor`\ ) :ref:`🔗` Emitted when a reconstructed mesh anchor is removed. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_mesh_anchor_updated: .. rst-class:: classref-signal **mesh_anchor_updated**\ (\ mesh\: :ref:`ARMeshAnchor`\ ) :ref:`🔗` Emitted when a reconstructed mesh anchor changes geometry or pose. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_session_failed: .. rst-class:: classref-signal **session_failed**\ (\ message\: :ref:`String`\ ) :ref:`🔗` Emitted when the session fails and provides a human-readable error message. .. rst-class:: classref-item-separator ---- .. _class_ARSession_signal_session_interrupted: .. rst-class:: classref-signal **session_interrupted**\ (\ ) :ref:`🔗` Emitted when the session is interrupted by the system. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_ARSession_RunOption: .. rst-class:: classref-enumeration enum **RunOption**: :ref:`🔗` .. _class_ARSession_constant_RESET_TRACKING: .. rst-class:: classref-enumeration-constant :ref:`RunOption` **RESET_TRACKING** = ``1`` Reset session tracking when the configuration is run. .. _class_ARSession_constant_REMOVE_EXISTING_ANCHORS: .. rst-class:: classref-enumeration-constant :ref:`RunOption` **REMOVE_EXISTING_ANCHORS** = ``2`` Remove existing anchors when the configuration is run. .. _class_ARSession_constant_STOP_TRACKED_RAYCASTS: .. rst-class:: classref-enumeration-constant :ref:`RunOption` **STOP_TRACKED_RAYCASTS** = ``4`` Stop existing tracked raycasts when the configuration is run. .. _class_ARSession_constant_RESET_SCENE_RECONSTRUCTION: .. rst-class:: classref-enumeration-constant :ref:`RunOption` **RESET_SCENE_RECONSTRUCTION** = ``8`` Reset accumulated scene-reconstruction data when the configuration is run. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_ARSession_property_anchors: .. rst-class:: classref-property :ref:`Array` **anchors** = ``[]`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`Array` **get_anchors**\ (\ ) The anchors currently known to the session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_property_configuration: .. rst-class:: classref-property :ref:`ARWorldTrackingConfiguration` **configuration** = ``null`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`ARWorldTrackingConfiguration` **get_configuration**\ (\ ) The last world-tracking configuration used with :ref:`run()` or :ref:`run_with_world_map()`, if any. .. rst-class:: classref-item-separator ---- .. _class_ARSession_property_current_frame: .. rst-class:: classref-property :ref:`ARFrame` **current_frame** = ``null`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`ARFrame` **get_current_frame**\ (\ ) The most recent frame produced by the session, if available. .. rst-class:: classref-item-separator ---- .. _class_ARSession_property_identifier: .. rst-class:: classref-property :ref:`String` **identifier** = ``"C3DA7EF3-0621-46A4-BFFA-30B88A331CCD"`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`String` **get_identifier**\ (\ ) A unique identifier for this session instance. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_ARSession_method_add_anchor: .. rst-class:: classref-method |void| **add_anchor**\ (\ anchor\: :ref:`ARAnchor`\ ) :ref:`🔗` Adds a custom anchor to the running session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_capture_high_resolution_frame: .. rst-class:: classref-method |void| **capture_high_resolution_frame**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Captures a high-resolution camera frame asynchronously. **iOS 16+ only.** Reports unavailability on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_get_current_world_map: .. rst-class:: classref-method |void| **get_current_world_map**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Asynchronously captures the current world map for session persistence. The callback receives an :ref:`ARWorldMap` and an optional error string. **iOS only.** Reports unavailability on visionOS/macOS (visionOS persists anchors automatically via WorldTrackingProvider). .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_is_supported: .. rst-class:: classref-method :ref:`bool` **is_supported**\ (\ ) |static| :ref:`🔗` Returns ``true`` when ARKit session support is available on the current platform and device. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_pause: .. rst-class:: classref-method |void| **pause**\ (\ ) :ref:`🔗` Pauses the session and stops delivering new frame updates until it is run again. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_raycast: .. rst-class:: classref-method :ref:`Array` **raycast**\ (\ query\: :ref:`ARRaycastQuery`\ ) :ref:`🔗` Performs a raycast against detected surfaces. Returns an array of :ref:`ARRaycastResult`. **iOS only.** Returns empty on visionOS/macOS. On visionOS, use RealityKit scene queries instead. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_remove_all_anchors: .. rst-class:: classref-method |void| **remove_all_anchors**\ (\ ) :ref:`🔗` Removes every current anchor from the session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_remove_anchor: .. rst-class:: classref-method |void| **remove_anchor**\ (\ anchor\: :ref:`ARAnchor`\ ) :ref:`🔗` Removes the given anchor from the session. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_run: .. rst-class:: classref-method |void| **run**\ (\ configuration\: :ref:`ARWorldTrackingConfiguration`, options\: :ref:`int`\ ) :ref:`🔗` Starts or reconfigures the session using ``configuration``. ``options`` is a bitmask of :ref:`RunOption` flags. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_run_body_tracking: .. rst-class:: classref-method |void| **run_body_tracking**\ (\ configuration\: :ref:`ARBodyTrackingConfiguration`, options\: :ref:`int`\ ) :ref:`🔗` Starts the session with body tracking configuration. **iOS only.** Reports unavailability on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_run_geo_tracking: .. rst-class:: classref-method |void| **run_geo_tracking**\ (\ configuration\: :ref:`ARGeoTrackingConfiguration`, options\: :ref:`int`\ ) :ref:`🔗` Starts the session with geo tracking for GPS-anchored AR. **iOS 14+ only.** Reports unavailability on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_run_with_world_map: .. rst-class:: classref-method |void| **run_with_world_map**\ (\ configuration\: :ref:`ARWorldTrackingConfiguration`, worldMap\: :ref:`ARWorldMap`\ ) :ref:`🔗` Starts the session with a previously saved world map for relocalization. **iOS only.** Reports unavailability on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_set_world_origin: .. rst-class:: classref-method |void| **set_world_origin**\ (\ relativeTransform\: :ref:`Transform3D`\ ) :ref:`🔗` Resets the session's world origin relative to ``relativeTransform``. Use this to realign virtual content without recreating anchors. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_tracked_raycast: .. rst-class:: classref-method :ref:`ARTrackedRaycast` **tracked_raycast**\ (\ query\: :ref:`ARRaycastQuery`, callback\: :ref:`Callable`\ ) :ref:`🔗` Creates a continuously-tracked raycast that invokes the callback as results update. **iOS only.** Returns null on visionOS/macOS. .. rst-class:: classref-item-separator ---- .. _class_ARSession_method_update_with_collaboration_data: .. rst-class:: classref-method |void| **update_with_collaboration_data**\ (\ data\: :ref:`ARCollaborationData`\ ) :ref:`🔗` Feeds collaboration data received from a peer into the session for multi-user AR. **iOS 13+ only.** No-op on visionOS/macOS. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`