The main object you use to control an AR experience.
SDK
- iOS 11.0+
Framework
- ARKit
Declaration
class ARSession : NSObject
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 = self
If 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.session
Run 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, ARWorld
enables you to augment the user's view of the world around them though the device's back camera.