ARSession

Inherits: RefCounted < Object

Manages an AR session with world tracking, plane detection, and anchor management.

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.

Properties

Array

anchors

[]

ARWorldTrackingConfiguration

configuration

null

ARFrame

current_frame

null

String

identifier

"C3DA7EF3-0621-46A4-BFFA-30B88A331CCD"

Methods

void

add_anchor(anchor: ARAnchor)

void

capture_high_resolution_frame(callback: Callable)

void

get_current_world_map(callback: Callable)

bool

is_supported() static

void

pause()

Array

raycast(query: ARRaycastQuery)

void

remove_all_anchors()

void

remove_anchor(anchor: ARAnchor)

void

run(configuration: ARWorldTrackingConfiguration, options: int)

void

run_body_tracking(configuration: ARBodyTrackingConfiguration, options: int)

void

run_geo_tracking(configuration: ARGeoTrackingConfiguration, options: int)

void

run_with_world_map(configuration: ARWorldTrackingConfiguration, worldMap: ARWorldMap)

void

set_world_origin(relativeTransform: Transform3D)

ARTrackedRaycast

tracked_raycast(query: ARRaycastQuery, callback: Callable)

void

update_with_collaboration_data(data: ARCollaborationData)


Signals

anchors_added(anchors: Array) 🔗

Emitted when new anchors are added to the session.


anchors_removed(anchors: Array) 🔗

Emitted when anchors are removed from the session.


anchors_updated(anchors: Array) 🔗

Emitted when existing anchors receive updated pose or geometry data.


camera_tracking_changed(camera: ARCamera) 🔗

Emitted when the camera tracking state changes.


collaboration_data_received(collaborationData: ARCollaborationData) 🔗

Emitted when collaboration data is produced for multi-peer AR. iOS 13+ only. Requires isCollaborationEnabled on the configuration. Never emitted on visionOS/macOS.


frame_updated(frame: ARFrame) 🔗

Emitted whenever the session produces a new frame.


hand_anchor_updated(hand: ARHandAnchor) 🔗

Emitted when a hand anchor is added or updated. visionOS only. Never emitted on iOS or macOS.


interruption_ended() 🔗

Emitted after the session interruption has ended and tracking can resume.


mesh_anchor_added(mesh: ARMeshAnchor) 🔗

Emitted when scene reconstruction produces a new mesh anchor.


mesh_anchor_removed(mesh: ARMeshAnchor) 🔗

Emitted when a reconstructed mesh anchor is removed.


mesh_anchor_updated(mesh: ARMeshAnchor) 🔗

Emitted when a reconstructed mesh anchor changes geometry or pose.


session_failed(message: String) 🔗

Emitted when the session fails and provides a human-readable error message.


session_interrupted() 🔗

Emitted when the session is interrupted by the system.


Enumerations

enum RunOption: 🔗

RunOption RESET_TRACKING = 1

Reset session tracking when the configuration is run.

RunOption REMOVE_EXISTING_ANCHORS = 2

Remove existing anchors when the configuration is run.

RunOption STOP_TRACKED_RAYCASTS = 4

Stop existing tracked raycasts when the configuration is run.

RunOption RESET_SCENE_RECONSTRUCTION = 8

Reset accumulated scene-reconstruction data when the configuration is run.


Property Descriptions

Array anchors = [] 🔗

  • Array get_anchors()

The anchors currently known to the session.


ARWorldTrackingConfiguration configuration = null 🔗

The last world-tracking configuration used with run() or run_with_world_map(), if any.


ARFrame current_frame = null 🔗

The most recent frame produced by the session, if available.


String identifier = "C3DA7EF3-0621-46A4-BFFA-30B88A331CCD" 🔗

  • String get_identifier()

A unique identifier for this session instance.


Method Descriptions

void add_anchor(anchor: ARAnchor) 🔗

Adds a custom anchor to the running session.


void capture_high_resolution_frame(callback: Callable) 🔗

Captures a high-resolution camera frame asynchronously. iOS 16+ only. Reports unavailability on visionOS/macOS.


void get_current_world_map(callback: Callable) 🔗

Asynchronously captures the current world map for session persistence. The callback receives an ARWorldMap and an optional error string. iOS only. Reports unavailability on visionOS/macOS (visionOS persists anchors automatically via WorldTrackingProvider).


bool is_supported() static 🔗

Returns true when ARKit session support is available on the current platform and device.


void pause() 🔗

Pauses the session and stops delivering new frame updates until it is run again.


Array raycast(query: ARRaycastQuery) 🔗

Performs a raycast against detected surfaces. Returns an array of ARRaycastResult. iOS only. Returns empty on visionOS/macOS. On visionOS, use RealityKit scene queries instead.


void remove_all_anchors() 🔗

Removes every current anchor from the session.


void remove_anchor(anchor: ARAnchor) 🔗

Removes the given anchor from the session.


void run(configuration: ARWorldTrackingConfiguration, options: int) 🔗

Starts or reconfigures the session using configuration. options is a bitmask of RunOption flags.


void run_body_tracking(configuration: ARBodyTrackingConfiguration, options: int) 🔗

Starts the session with body tracking configuration. iOS only. Reports unavailability on visionOS/macOS.


void run_geo_tracking(configuration: ARGeoTrackingConfiguration, options: int) 🔗

Starts the session with geo tracking for GPS-anchored AR. iOS 14+ only. Reports unavailability on visionOS/macOS.


void run_with_world_map(configuration: ARWorldTrackingConfiguration, worldMap: ARWorldMap) 🔗

Starts the session with a previously saved world map for relocalization. iOS only. Reports unavailability on visionOS/macOS.


void set_world_origin(relativeTransform: Transform3D) 🔗

Resets the session’s world origin relative to relativeTransform. Use this to realign virtual content without recreating anchors.


ARTrackedRaycast tracked_raycast(query: ARRaycastQuery, callback: Callable) 🔗

Creates a continuously-tracked raycast that invokes the callback as results update. iOS only. Returns null on visionOS/macOS.


void update_with_collaboration_data(data: ARCollaborationData) 🔗

Feeds collaboration data received from a peer into the session for multi-user AR. iOS 13+ only. No-op on visionOS/macOS.