ARSession
The object that manages the major tasks associated with every AR experience, such as motion tracking, camera passthrough, and image analysis.
Declaration
class ARSessionMentioned in
Overview
An ARSession object coordinates the major processes that ARKit performs on your behalf to create an augmented reality experience. These processes include reading data from the device’s motion sensing hardware, controlling the device’s built-in camera, and performing image analysis on captured camera images. The session synthesizes all of these results to establish a correspondence between the real-world space the device inhabits and a virtual space where you model AR content.
Create a Session
Every AR experience requires an ARSession. If you implement a custom renderer, you instantiate the session yourself.
let session = ARSession()
session.delegate = selfIf you use one of the standard renderers (like ARView, ARSCNView, or ARSKView), the renderer creates a session object for you. When you want to interact with your app’s session, you access it on your app’s renderer.
let session = myView.sessionRun a Session
Running a session requires a configuration. Subclasses of ARConfiguration determine how ARKit tracks a device’s position and motion relative to the real world, and thus it determines the kinds of AR experiences you create. For example, ARWorldTrackingConfiguration enables you to augment the user’s view of the world around them though the device’s back camera.