Published on

ARKit (Part 2) — Core Classes Overview

Core Classes Overview

ARAnchor

ARAnchor represents the position and orientation of an object in 3D space. It is commonly referred to as a 3D anchor point for an object — somewhat similar to the Anchor property of CALayer in the UIKit framework.

@interface ARAnchor : NSObject <NSCopying>

/**
 The unique identifier of the anchor.
 */
@property (nonatomic, readonly) NSUUID *identifier;

/**
 The rotation transform matrix of the anchor, defining rotation, position, and scale. This is a 4x4 matrix.
 */
@property (nonatomic, readonly) matrix_float4x4 transform;

/**
 Initializer. Generally does not need to be called directly, as ARKit notifies us of an object's anchor via a delegate callback when a 3D object is added.
 */
- (instancetype)initWithTransform:(matrix_float4x4)transform;

@end

ARCamera

ARCamera is the bridge between the virtual scene and the real world. In ARKit, it is the camera that captures real-world images; in SceneKit, it is the camera in the 3D virtual world. (In typical first-person 3D games, the main character is essentially a 3D camera — what we see on screen is what that camera captures.)

You generally do not need to create a camera manually. When an AR view is initialized, a camera is created by default. This camera corresponds to the position of the device's physical camera, and is also the origin of the 3D world (x=0, y=0, z=0).

/**
 Values describing the camera's tracking state.
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_ENUM(NSInteger, ARTrackingState) {
    /** Not available */
    ARTrackingStateNotAvailable,

    /** Tracking is limited; see ARTrackingStateReason */
    ARTrackingStateLimited,

    /** Normal */
    ARTrackingStateNormal,
} NS_REFINED_FOR_SWIFT;

/**
 Values describing the reason why camera tracking is limited.
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_ENUM(NSInteger, ARTrackingStateReason) {
    /** Tracking is not limited */
    ARTrackingStateReasonNone,

    /** Tracking is limited while initializing */
    ARTrackingStateReasonInitializing,

    /** Tracking is limited due to excessive camera motion */
    ARTrackingStateReasonExcessiveMotion,

    /** Tracking is limited due to insufficient feature points */
    ARTrackingStateReasonInsufficientFeatures,
} NS_REFINED_FOR_SWIFT;

@interface ARCamera : NSObject <NSCopying>

/**
 4x4 matrix representing the camera's position, same as ARAnchor. Defines camera rotation and translation in world coordinates.
 */
@property (nonatomic, readonly) matrix_float4x4 transform;

/**
 Vector of Euler angles describing camera orientation (rotation) along x/y/z axes.

 @discussion The order of elements in the vector matches the rotation axes:
               1. Pitch (x) — device tilt angle (radians)
               2. Yaw   (y) — rotation around the axis perpendicular to the screen (radians)
               3. Roll  (z) — rotation around the device's upward direction (radians)
            ARKit applies these rotations in reverse order:
               1. First roll
               2. Then yaw
               3. Finally pitch
 */
@property (nonatomic, readonly) vector_float3 eulerAngles;

/**
 The camera's tracking state.
 */
@property (nonatomic, readonly) ARTrackingState trackingState NS_REFINED_FOR_SWIFT;

/**
 The reason for the camera's tracking state being limited.
 */
@property (nonatomic, readonly) ARTrackingStateReason trackingStateReason NS_REFINED_FOR_SWIFT;

/**
 The camera's intrinsics matrix.
 @discussion A 3x3 matrix that maps 3D points in the real world to the image captured by the camera:
 fx 0   px
 0  fy  py
 0  0   1
 fx and fy are focal lengths in pixels.
 px and py are the principal point coordinates.
 The origin is at the top-left pixel center.
 */
@property (nonatomic, readonly) matrix_float3x3 intrinsics;

/**
 The image resolution of the camera.
 */
@property (nonatomic, readonly) CGSize imageResolution;

/**
 The camera's projection matrix.
*/
@property (nonatomic, readonly) matrix_float4x4 projectionMatrix;

/**
 Projects a 3D point in world coordinates into 2D viewport space.

 @param point A 3D point in world coordinate space.
 @param orientation The viewport orientation.
 @param viewportSize The size of the viewport (or image).
 @return A 2D coordinate in viewport coordinate space, with the origin at the top-left.
 */
- (CGPoint)projectPoint:(vector_float3)point orientation:(UIInterfaceOrientation)orientation viewportSize:(CGSize)viewportSize;

/**
 Creates a projection matrix for the camera with the given parameters.

 @discussion The returned projection matrix accounts for viewport size and orientation planes.
 @param orientation Viewport orientation.
 @param viewportSize Viewport size.
 @param zNear Near clipping plane distance.
 @param zFar Far clipping plane distance.
 */
- (matrix_float4x4)projectionMatrixForOrientation:(UIInterfaceOrientation)orientation viewportSize:(CGSize)viewportSize zNear:(CGFloat)zNear zFar:(CGFloat)zFar;

/**
 Creates a view matrix for the camera with the given orientation.

 @discussion The view matrix can be used to transform geometry into camera space for the given orientation.
 @param orientation The interface orientation used to render the camera view.
 */
- (matrix_float4x4)viewMatrixForOrientation:(UIInterfaceOrientation)orientation;

@end

ARError

The class in the ARKit framework that describes errors. Errors can originate from an unsupported device, or from the ARSession disconnecting when the camera stays in the background.

// The error domain, typically indicates which class encountered the issue
FOUNDATION_EXTERN NSString *const ARErrorDomain;

typedef NS_ERROR_ENUM(ARErrorDomain, ARErrorCode) {
    /** The session tracking configuration is not supported; devices with chips below A9 will trigger this */
    ARErrorCodeUnsupportedConfiguration   = 100,

    /** A sensor required to run the session is unavailable */
    ARErrorCodeSensorUnavailable          = 101,

    /** A sensor failed to provide the required input */
    ARErrorCodeSensorFailed               = 102,

    /** The app does not have permission to use the camera; the user can change this in Settings */
    ARErrorCodeCameraUnauthorized         = 103,

    /** Tracking error */
    ARErrorCodeWorldTrackingFailed        = 200,
};

ARFrame

A wrapper class for camera video frames, containing position tracking information, environmental parameters, and the video frame itself.

@interface ARFrame : NSObject <NSCopying>

/**
 Timestamp used to identify the frame.
 */
@property (nonatomic, readonly) NSTimeInterval timestamp;

/**
 Color information captured by the color camera.
 */
@property (nonatomic, readonly) CVPixelBufferRef capturedImage;

/**
 Depth information captured by the depth camera.
 */
@property (nonatomic, strong, readonly, nullable) AVDepthData *capturedDepthData;

/**
 Timestamp for capturedDepthData. In testing at 60fps, approximately 1 out of every 4 frames contains depth data.
 */
@property (nonatomic, readonly) NSTimeInterval capturedDepthDataTimestamp;

/**
 The camera that captured the image.
 */
@property (nonatomic, copy, readonly) ARCamera *camera;

/**
 Returns anchor data currently captured by the camera.
 */
@property (nonatomic, copy, readonly) NSArray<ARAnchor *> *anchors;

/**
 Lighting estimate; may be nil if not configured.
 */
@property (nonatomic, strong, nullable, readonly) ARLightEstimate *lightEstimate;

/**
 Feature points.
 */
@property (nonatomic, strong, nullable, readonly) ARPointCloud *rawFeaturePoints;

/**
 Performs a hit test to search for 3D models from a 2D screen point. This method is commonly used when the user taps a point on the phone screen to find the corresponding 3D model position. The result is an array because the phone screen is a 2D rectangle, while the camera captures a 3D frustum extending from that plane. A tap on the screen can be thought of as shooting a ray through the frustum — multiple 3D objects may lie along that ray.
 point: A 2D coordinate point on screen (in the image space coordinate system of the captured image, ranging from (0,0) top-left to (1,1) bottom-right).
 ARHitTestResultType: The type of result to search for — point or plane.
 (NSArray<ARHitTestResult *> *): Array of hit test results. See ARHitTestResult for details.
 */
- (NSArray<ARHitTestResult *> *)hitTest:(CGPoint)point types:(ARHitTestResultType)types;

/**
 Returns the display transform for the provided viewport size and orientation.
 Can be used to convert normalized points in the image space of the captured image to normalized points in the view's coordinate space. The transform provides the correct rotation and display of the captured image for the given orientation and size.
 The orientation of the viewport.
 */
- (CGAffineTransform)displayTransformForOrientation:(UIInterfaceOrientation)orientation viewportSize:(CGSize)viewportSize;

@end

ARHitTestResult

The hit test result class, primarily used for interaction between the real world and 3D virtual objects in AR. For example, moving or dragging a 3D virtual object in the camera view can use this class to obtain results captured by ARKit.

/**
 Option set of hit test result types.
 */
typedef NS_OPTIONS(NSUInteger, ARHitTestResultType) {
    /** Result type intersecting the nearest feature point */
    ARHitTestResultTypeFeaturePoint              = (1 << 0),

    /** Result type intersecting an estimated horizontal plane in the current frame */
    ARHitTestResultTypeEstimatedHorizontalPlane  = (1 << 1),

    /** Result type intersecting an existing plane anchor */
    ARHitTestResultTypeExistingPlane             = (1 << 3),

    /** Result type intersecting an existing plane anchor, considering the plane's extent */
    ARHitTestResultTypeExistingPlaneUsingExtent  = (1 << 4),
} NS_SWIFT_NAME(ARHitTestResult.ResultType);

@interface ARHitTestResult : NSObject

/**
 The type of the hit test result.
 */
@property (nonatomic, readonly) ARHitTestResultType type;

/**
 The distance from the camera to the intersection point — the distance between the 3D virtual object and the camera (in meters).
 */
@property (nonatomic, readonly) CGFloat distance;

/**
 The transform matrix defining the rotation, translation, and scale of the intersection relative to the anchor or nearest feature point.
 Local coordinate matrix (world coordinates use the camera as the scene origin, while each 3D object has its own local coordinate system — similar to the difference between frame and bounds).
 */
@property (nonatomic, readonly) matrix_float4x4 localTransform;

/**
 The transform matrix defining the rotation, translation, and scale of the intersection relative to the world — the world coordinate matrix.
 */
@property (nonatomic, readonly) matrix_float4x4 worldTransform;

/**
 The anchor for the hit test intersection. Anchors are only provided for existing plane result types.
 The anchor (a 3D virtual object has a position in the virtual world represented by SCNVector3 in SceneKit), while the anchor represents that object's position in the AR real-world scene, as a 4x4 matrix.
 */
@property (nonatomic, strong, nullable, readonly) ARAnchor *anchor;

@end

ARLightEstimate

ARLightEstimate provides lighting effects to make AR scenes appear more realistic.

@interface ARLightEstimate : NSObject

/**
 The ambient intensity of the lighting.
 In a well-lit environment, this value is close to 1000. It typically ranges from 0 (very dark) to about 2000 (very bright).
 */
@property (nonatomic, readonly) CGFloat ambientIntensity;

/**
 The ambient color temperature of the light.
 This specifies the ambient color temperature of the lighting in Kelvin (6500 corresponds to pure white).
*/
@property (nonatomic, readonly) CGFloat ambientColorTemperature;

@end

ARDirectionalLightEstimate

ARDirectionalLightEstimate is a subclass of ARLightEstimate.

@interface ARDirectionalLightEstimate : ARLightEstimate

/**
 Second-order spherical harmonic coefficients representing light intensity.

 The data is an array of 27 32-bit float values containing three non-interleaved datasets corresponding to red, green, and blue coefficient groups.
 */
@property (nonatomic, copy, readonly) NSData *sphericalHarmonicsCoefficients;

/**
 The primary direction of the light.
 */
@property (nonatomic, readonly) vector_float3 primaryLightDirection;

/**
 The intensity of light in the primary direction.
 */
@property (nonatomic, readonly) CGFloat primaryLightIntensity;

@end

ARPlaneAnchor

ARPlaneAnchor is a subclass of ARAnchor and can be understood as a planar anchor. ARKit can automatically detect planes and will add an anchor to the scene by default. To visualize a detected plane in the real world, you need to use an SCNNode to render the anchor. An anchor is just a position.

@interface ARPlaneAnchor : ARAnchor

/**
 The type of plane. Currently only one type is available: horizontal (ARPlaneAnchorAlignmentHorizontal).
 */
@property (nonatomic, readonly) ARPlaneAnchorAlignment alignment;

/**
 A 3-axis vector representing the center point of the plane (x/y/z).
 */
@property (nonatomic, readonly) vector_float3 center;

/**
 A 3-axis vector representing the size of the plane (width and height) (x/y/z).
 */
@property (nonatomic, readonly) vector_float3 extent;

@end

ARPointCloud

ARPointCloud is a point cloud renderer, primarily used for rendering scenes.

@interface ARPointCloud : NSObject

/**
 The number of points.
 */
@property (nonatomic, readonly) NSUInteger count NS_REFINED_FOR_SWIFT;

/**
 A collection of positions for each point (a pointer to a struct array).
 */
@property (nonatomic, readonly) const vector_float3 *points NS_REFINED_FOR_SWIFT;

/**
 The 3D point identifiers in the point cloud.
 */
@property (nonatomic, readonly) const uint64_t *identifiers NS_REFINED_FOR_SWIFT;

@end

ARSCNView

A supplementary view whose main function is to render 3D content from SceneKit onto the real-time camera image to create an AR experience. ARSCNView inherits from SCNView in the SceneKit framework, and SCNView inherits from UIView in UIKit. This class primarily does the following:

  • Takes the real-time feed from the device camera and renders it as the background of the 3D scene.

  • ARKit's 3D coordinate system can be matched to SceneKit's 3D coordinate system. Objects rendered in this view are automatically matched to ARKit's world coordinates.

  • Automatically moves the virtual SceneKit camera to match the 3D coordinates tracked by ARKit in the real world, so we don't need to write code to associate movement events with SceneKit's 3D graphics.

Since ARKit automatically aligns SceneKit space with the real world, placing a virtual object at a real-world position only requires setting an appropriate SceneKit coordinate. We don't need to use the ARAnchor class to track the coordinates of objects we add to the scene, but we do need to implement ARSCNViewDelegate methods to add SceneKit content on any anchor that ARKit automatically detects.

Note: the ability to render 3D objects is provided by the parent class SCNView, while capturing the 3D real-world scene and performing the corresponding coordinate conversion is implemented by ARSCNView (i.e., ARKit).

@interface ARSCNView : SCNView

/**
 Delegate
 */
@property (nonatomic, weak, nullable) id<ARSCNViewDelegate> delegate;

/**
 ARSession
 */
@property (nonatomic, strong) ARSession *session;

/**
 Specifies the SCNScene
 */
@property(nonatomic, strong) SCNScene *scene;

/**
 Whether to automatically adapt lighting; defaults to YES.
 */
@property(nonatomic) BOOL automaticallyUpdatesLighting;

/**
 Returns the anchor corresponding to a given node. A node is a 3D virtual object with coordinates in the virtual scene, while ARAnchor is ARKit's real-world coordinates.
 */
- (nullable ARAnchor *)anchorForNode:(SCNNode *)node;

/**
 Returns the node corresponding to a given anchor.
 */
- (nullable SCNNode *)nodeForAnchor:(ARAnchor *)anchor;

/**
 Performs a hit test to search for 3D models from a 2D screen point. This method is commonly used when the user taps a point on the phone screen to find the position of the 3D model at that point. The result is an array because the phone screen is a 2D rectangle, while the camera captures a 3D frustum. A tap on the screen corresponds to shooting a ray along the edge of that frustum — multiple 3D objects may lie along it.
 @param point A 2D coordinate point on screen.
 @param types The type of hit test results.
 @return An array of all hit-test results. See ARHitTestResult for details. Results are sorted from nearest to farthest.
 */
- (NSArray<ARHitTestResult *> *)hitTest:(CGPoint)point types:(ARHitTestResultType)types;

@end

#pragma mark - ARSCNViewDelegate

/**
 The delegate internally implements SCNSceneRendererDelegate (SceneKit delegate) and ARSessionObserver (ARSession KVO-based observation).
 */
@protocol ARSCNViewDelegate <SCNSceneRendererDelegate, ARSessionObserver>
@optional

/**
 Provides a custom node for the given anchor. If not implemented, a node is created automatically. If nil is returned, the anchor is ignored.

 @param renderer The renderer that renders the scene.
 @param anchor The added anchor.
 @return The node corresponding to the anchor.
 */
- (nullable SCNNode *)renderer:(id <SCNSceneRenderer>)renderer nodeForAnchor:(ARAnchor *)anchor;

/**
 Called when a node is added. This delegate method allows us to know the anchor in the AR scene (real-world coordinates) when we add a virtual object.

 @param renderer The renderer that renders the scene.
 @param node The node corresponding to the anchor.
 @param anchor The added anchor.
 */
- (void)renderer:(id <SCNSceneRenderer>)renderer didAddNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor;

/**
 Called when a node is about to be updated from the given anchor.

 @param renderer The renderer that renders the scene.
 @param node The node about to be updated.
 @param anchor The updated anchor.
 */
- (void)renderer:(id <SCNSceneRenderer>)renderer willUpdateNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor;

/**
 Called when a node has been updated from the given anchor.

 @param renderer The renderer that renders the scene.
 @param node The updated node.
 @param anchor The updated anchor.
 */
- (void)renderer:(id <SCNSceneRenderer>)renderer didUpdateNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor;

/**
 Called when the given anchor has been removed from the scene graph.

 @param renderer The renderer that renders the scene.
 @param node The removed node.
 @param anchor The removed anchor.
 */
- (void)renderer:(id <SCNSceneRenderer>)renderer didRemoveNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor;

@end

/**
 Debug options extension for ARSCNView.
 */
struct ARSCNDebugOptions {} API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos);

/** Show the world origin in the scene */
FOUNDATION_EXTERN const SCNDebugOptions ARSCNDebugOptionShowWorldOrigin NS_SWIFT_NAME(ARSCNDebugOptions.showWorldOrigin);

/** Show 3D feature points detected in the world */
FOUNDATION_EXTERN const SCNDebugOptions ARSCNDebugOptionShowFeaturePoints NS_SWIFT_NAME(ARSCNDebugOptions.showFeaturePoints);

ARSession

ARSession is a bridge between the underlying layer and the AR view. In fact, all delegate methods in ARSCNView are provided by ARSession. Every AR scene built with ARKit requires an ARSession object. It is responsible for controlling the camera, collecting all sensor data from the device (including reading data from the device's motion sensors, controlling the device camera, and analyzing images captured by the camera) to establish the connection between the user's real-world location and the AR content space. The ARSCNView instance already contains an ARSession instance — you just need to configure it at startup (using ARSessionConfiguration or its subclass ARWorldTrackingSessionConfiguration).

ARSession provides two main ways to retrieve camera position data: one is by implementing the ARSession delegate method didUpdateFrame, and the other is by accessing the ARSession property currentFrame.

/**
 Options for running the ARSession. Options change the way the ARSession runs. If not set, tracking will continue from the last known position for all anchors.
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_OPTIONS(NSUInteger, ARSessionRunOptions) {
    /** ARSession resets tracking */
    ARSessionRunOptionResetTracking           = (1 << 0),

    /** ARSession will remove all existing anchors */
    ARSessionRunOptionRemoveExistingAnchors   = (1 << 1)
} NS_SWIFT_NAME(ARSession.RunOptions);

@interface ARSession : NSObject

/**
 The delegate object that receives ARSession updates.
 */
@property (nonatomic, weak) id <ARSessionDelegate> delegate;

/**
 The dispatch queue for delegate callbacks.
 @discussion If not set, callbacks will occur on the main thread.
 */
@property (nonatomic, strong, nullable) dispatch_queue_t delegateQueue;

/**
 The camera's current position (computed by the ARSession's tracking configuration).
 */
@property (nonatomic, copy, nullable, readonly) ARFrame *currentFrame;

/**
 The ARSession configuration.
 */
@property (nonatomic, copy, nullable, readonly) ARConfiguration *configuration;

/**
 Runs with the given configuration.
 @discussion If already running, it will update the configuration and continue running.
 @param configuration The run configuration.
 */
- (void)runWithConfiguration:(ARConfiguration *)configuration NS_SWIFT_UNAVAILABLE("Use run(_:options:) instead");

/**
 Runs with the given configuration and options.
 @discussion If already running, it will update the configuration and continue running. Options can be used to change the default behavior when switching configurations.
 @param configuration The run configuration.
 @param options The run options.
 */
- (void)runWithConfiguration:(ARConfiguration *)configuration options:(ARSessionRunOptions)options NS_SWIFT_NAME(run(_:options:));

/**
 Pauses the session.
 @discussion After pausing, no updates will be received unless run is called again.
 */
- (void)pause;

/**
 Adds an anchor.
 @discussion The anchor will be added at the next frame update.
 @param anchor The anchor to add.
 */
- (void)addAnchor:(ARAnchor *)anchor NS_SWIFT_NAME(add(anchor:));

/**
 Removes an anchor.
 @discussion The anchor will be removed at the next frame update.
 @param anchor The anchor to remove.
 */
- (void)removeAnchor:(ARAnchor *)anchor NS_SWIFT_NAME(remove(anchor:));

@end

/**
 The session delegate is divided into two parts: observer (KVO) and delegate (traditional delegation).
 */
#pragma mark - ARSessionObserver

/**
 Observer (KVO)
 */
@protocol ARSessionObserver <NSObject>

@optional

/**
 Called when the session fails.

 @discussion The session pauses when it fails.
 @param session The failed session.
 @param error The error; see ARError.h for details.
 */
- (void)session:(ARSession *)session didFailWithError:(NSError *)error;

/**
 Called when the camera's tracking state changes.

 @param session The running session.
 @param camera The camera whose tracking state changed.
 */
- (void)session:(ARSession *)session cameraDidChangeTrackingState:(ARCamera *)camera;

/**
 Called when the session is interrupted.

 @discussion When the session cannot receive data from sensors, it disconnects and stops tracking. This happens when the app is sent to the background or when multiple foreground apps are active (see AVCaptureSessionInterruptionReason). Frames will not update again until the session resumes.
 @param session The interrupted session.
 */
- (void)sessionWasInterrupted:(ARSession *)session;

/**
 Called when the session interruption ends.

 @discussion When the interruption ends, the session can resume from the last known state. If the device has moved, anchors may be misaligned. To avoid this, the app should consider resetting tracking (see ARSessionRunOptions).
 @param session The interrupted session.
 */
- (void)sessionInterruptionEnded:(ARSession *)session;

/**
 Called when the session outputs a new audio sample buffer.

 @param session The running session.
 @param audioSampleBuffer The captured audio sample buffer.
 */
- (void)session:(ARSession *)session didOutputAudioSampleBuffer:(CMSampleBufferRef)audioSampleBuffer;

@end

#pragma mark - ARSessionDelegate


API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
@protocol ARSessionDelegate <ARSessionObserver>

@optional

/**
 Updates the camera state (spatial position, image frames, etc.).

 @param session The running session.
 @param frame The updated frame.
 */
- (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame;

/**
 Called when new anchors are added to the session.

 @param session The running session.
 @param anchors The anchors to add.
 */
- (void)session:(ARSession *)session didAddAnchors:(NSArray<ARAnchor*>*)anchors;

/**
 Called when anchors are updated.

 @param session The running session.
 @param anchors The anchors to update.
 */
- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor*>*)anchors;

/**
 Called when anchors are removed.

 @param session The running session.
 @param anchors The removed anchors.
 */
- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor*>*)anchors;

@end

ARConfiguration

In recent ARKit updates, ARSessionConfiguration has been renamed to ARConfiguration. The subclass ARWorldTrackingSessionConfiguration has also been renamed to ARWorldTrackingConfiguration.

ARWorldTrackingConfiguration

This class tracks device movement across 6 degrees of freedom (6DOF) — 3 rotation axes (roll: rotation around the axis perpendicular to the screen; yaw: rotation around the device's upward axis; pitch: the device's forward tilt angle) and 3 translation axes (movement along x, y, z). This allows us to walk around virtual objects and even move them. If this is not needed and the user will not change position during the AR experience, ARConfiguration can be used to initialize the ARSession instead.

/**
 Enum describing the tracking alignment — how ARKit constructs the scene coordinate system relative to real device motion.
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_ENUM(NSInteger, ARWorldAlignment) {
    /** The y-axis matches the direction of gravity as detected by the device's motion sensor hardware; the vector (0, -1, 0) points downward. */
    ARWorldAlignmentGravity,

    /** The y-axis matches the direction of gravity as detected by the device's motion sensor hardware; the vector (0, -1, 0) points downward.
        The x-axis and z-axis match the longitude and latitude directions measured by location services. Vector (0, 0, -1) points true north; vector (-1, 0, 0) points west.
     */
    ARWorldAlignmentGravityAndHeading,

    /** The scene coordinate system is locked to match the camera's orientation. */
    ARWorldAlignmentCamera
} NS_SWIFT_NAME(ARConfiguration.WorldAlignment);


/**
 Plane detection types.
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_OPTIONS(NSUInteger, ARPlaneDetection) {
    /** No plane detection */
    ARPlaneDetectionNone        = 0,

    /** Horizontal plane detection */
    ARPlaneDetectionHorizontal  = (1 << 0),
} NS_SWIFT_NAME(ARWorldTrackingConfiguration.PlaneDetection);

API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
@interface ARConfiguration : NSObject <NSCopying>

/**
 Whether the current device is supported.
 */
@property(class, nonatomic, readonly) BOOL isSupported;

/**
 Determines how the coordinate system is aligned to the world. Defaults to ARWorldAlignmentGravity.
 */
@property (nonatomic, readwrite) ARWorldAlignment worldAlignment;

/**
 Whether lighting estimation is needed. Defaults to YES.
 */
@property (nonatomic, readwrite, getter=isLightEstimationEnabled) BOOL lightEstimationEnabled;

/**
 Determines whether audio data should be captured and provided. Disabled by default.
 */
@property (nonatomic, readwrite) BOOL providesAudioData;

@end

@interface ARWorldTrackingConfiguration : ARConfiguration

/**
 The types of planes to detect in the scene.
 @discussion When set, new planes will continue to be detected and updated over time. Detected planes are added to the session as ARPlaneAnchor objects. When two planes merge, the later-added plane is removed. Defaults to ARPlaneDetectionNone.
 */
@property (nonatomic, readwrite) ARPlaneDetection planeDetection;

@end

References:

ARKit

ARKit from Beginner to Expert