Class

ARSCNView

A view that enables you to display an AR experience with SceneKit.

Declaration

class ARSCNView : SCNView

Overview

The ARSCNView class provides the easiest way to create augmented reality experiences that blend virtual 3D content with a device camera view of the real world. When you run the view's provided ARSession object:

  • The view automatically renders the live video feed from the device camera as the scene background.

  • The world coordinate system of the view's SceneKit scene directly responds to the AR world coordinate system established by the session configuration.

  • The view automatically moves its SceneKit camera to match the real-world movement of the device.

Because ARKit automatically matches SceneKit space to the real world, placing a virtual object such that it appears to maintain a real-world position only requires setting that object's SceneKit position appropriately. (See Providing 3D Virtual Content with SceneKit.)

You don't necessarily need to use the ARAnchor class to track positions of objects you add to the scene, but by implementing ARSCNViewDelegate methods, you can add SceneKit content to any anchors that are automatically detected by ARKit.

Topics

Essentials

Providing 3D Virtual Content with SceneKit

Use SceneKit to add realistic three-dimensional objects to your AR experience.

var session: ARSession

The AR session that manages motion tracking and camera image processing for the view's contents.

var scene: SCNScene

The SceneKit scene to be displayed in the view.

Responding to AR Updates

var delegate: ARSCNViewDelegate?

An object you provide to mediate synchronization of the view's AR scene information with SceneKit content.

protocol ARSCNViewDelegate

Methods you can implement to mediate the automatic synchronization of SceneKit content with an AR session.

Finding Real-World Surfaces

func hitTest(CGPoint, types: ARHitTestResult.ResultType) -> [ARHitTestResult]

Searches for real-world objects or AR anchors in the captured camera image corresponding to a point in the SceneKit view.

func raycastQuery(from: CGPoint, allowing: ARRaycastQuery.Target, alignment: ARRaycastQuery.TargetAlignment) -> ARRaycastQuery?

Creates a raycast query that originates from a point on the view, aligned with the center of the camera's field of view.

Beta

Mapping Content to Real-World Positions

func anchor(for: SCNNode) -> ARAnchor?

Returns the AR anchor associated with the specified SceneKit node, if any.

func node(for: ARAnchor) -> SCNNode?

Returns the SceneKit node associated with the specified AR anchor, if any.

func unprojectPoint(CGPoint, ontoPlane: simd_float4x4) -> simd_float3?

Returns the projection of a point from 2D view onto a plane in the 3D world space detected by ARKit.

Managing Lighting

var automaticallyUpdatesLighting: Bool

A Boolean value that specifies whether ARKit creates and updates SceneKit lights in the view's scene.

Debugging AR Display

typealias ARSCNDebugOptions

Options for drawing overlay content to aid debugging of AR tracking in a SceneKit view.

Managing Rendering Effects

var rendersMotionBlur: Bool

Determines whether the view renders motion blur.

Beta
var rendersCameraGrain: Bool

A flag that determines whether SceneKit applies image noise characteristics to your app's virtual content.

Beta

See Also

Display

class ARView

A view that enables you to display an AR experience with RealityKit.

Beta
class ARSKView

A view that enables you to display an AR experience with SpriteKit.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software