One Logo Pool Ball
RealityKit · IOS API REFERENCE

ARView

class · iOS 13.0+ · SDK 27.1

@MainActor @objc @preconcurrency class ARView

A view that enables you to display an AR experience with RealityKit. Use an ``ARView`` instance to display rendered 3D graphics to the user. You typically add a single view to your app’s storyboard, and then provide an outlet for that view in your code. Alternatively, you can create and add a view to your view hierarchy programmatically at runtime, as you would any other view. A view has a single ``Scene`` instance that you access through the read-only ``ARView/scene`` property. To the view’s ``Scene`` instance you add one or more ``AnchorEntity`` instances that tell the view’s AR ``ARView/session`` how to tether content to something in the real world. To each anchor, you attach a hierarchy of other ``Entity`` instances that make up the content of the scene. ![Block diagram highlighting the AR view as the root object that you interact with when using RealityKit.](ARView-1) Additionally, you can use the view to: - Configure render options, environmental characteristics, and the camera mode. - Handle platform-appropriate user interaction in the form of mouse, keyboard, or gesture input. - Find entities at a given point in the view. - Access statistics and visualizations that help you debug your app. Note that with ``ARView``, a ``ModelEntity`` casts a grounding shadow on a physical surface by default. ``RealityView`` does not have this default behavior.

Members (49)

get · iOS 13.0+

layerClass

TypeScript
static get layerClass(): Promise<string>
Swift declaration
@MainActor @preconcurrency override dynamic class var layerClass: AnyClass { get }

The class used to create the layer for view instances.

method · iOS 13.0+

didMoveToSuperview

TypeScript
didMoveToSuperview(): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func didMoveToSuperview()

Tells the view that its superview changed.

method · iOS 13.0+

gestureRecognizer

TypeScript
gestureRecognizerShouldReceive(gestureRecognizer: _UIKit_UIGestureRecognizer, touch: _UIKit_UITouch): Promise<boolean>
Swift declaration
@MainActor @preconcurrency @objc dynamic func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool
method · iOS 13.0+

gestureRecognizer

TypeScript
gestureRecognizerShouldRecognizeSimultaneouslyWith(gestureRecognizer: _UIKit_UIGestureRecognizer, otherGestureRecognizer: _UIKit_UIGestureRecognizer): Promise<boolean>
Swift declaration
@MainActor @preconcurrency @objc dynamic func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool
method · iOS 13.0+

layoutSubviews

TypeScript
layoutSubviews(): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func layoutSubviews()

Lays out subviews.

method · iOS 13.0+

touchesBegan

TypeScript
touchesBegan(touches: Array<_UIKit_UITouch>, event?: (_UIKit_UIEvent) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

Tells the view that one or more new touches occurred. See <doc://com.apple.documentation/documentation/uikit/uiresponder/1621142-touchesbegan> for more information. - Parameters: - touches: A set of `UITouch` instances that represent the touches whose values changed. These touches all belong to the specified `event`. For touches in a view, this set contains only one touch by default. To receive multiple touches, set the view’s <doc://com.apple.documentation/documentation/uikit/uiview/1622519-ismultipletouchenabled> property to `true`. - event: The event to which the touches belong.

method · iOS 13.0+

touchesCancelled

TypeScript
touchesCancelled(touches: Array<_UIKit_UITouch>, event?: (_UIKit_UIEvent) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?)

Tells the view when a system event (such as a system alert) cancels a touch sequence. See <doc://com.apple.documentation/documentation/uikit/uiresponder/1621116-touchescancelled> for more information. - Parameters: - touches: A set of `UITouch` instances that represent the touches whose values changed. These touches all belong to the specified `event`. For touches in a view, this set contains only one touch by default. To receive multiple touches, set the view’s <doc://com.apple.documentation/documentation/uikit/uiview/1622519-ismultipletouchenabled> property to `true`. - event: The event to which the touches belong.

method · iOS 13.0+

touchesEnded

TypeScript
touchesEnded(touches: Array<_UIKit_UITouch>, event?: (_UIKit_UIEvent) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)

Tells the view when one or more fingers are raised from the view. See ``EntityTranslationGestureRecognizer/touchesEnded(_:with:)`` for more information. - Parameters: - touches: A set of `UITouch` instances that represent the touches whose values changed. These touches all belong to the specified `event`. For touches in a view, this set contains only one touch by default. To receive multiple touches, set the view’s <doc://com.apple.documentation/documentation/uikit/uiview/1622519-ismultipletouchenabled> property to `true`. - event: The event to which the touches belong.

method · iOS 13.0+

touchesMoved

TypeScript
touchesMoved(touches: Array<_UIKit_UITouch>, event?: (_UIKit_UIEvent) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?)

Tells the view when one or more touches associated with an event changed. See <doc://com.apple.documentation/documentation/uikit/uiresponder/1621107-touchesmoved> for more information. - Parameters: - touches: A set of `UITouch` instances that represent the touches whose values changed. These touches all belong to the specified `event`. For touches in a view, this set contains only one touch by default. To receive multiple touches, set the view’s <doc://com.apple.documentation/documentation/uikit/uiview/1622519-ismultipletouchenabled> property to `true`. - event: The event to which the touches belong.

get · iOS 13.0+

contentScaleFactor

TypeScript
get contentScaleFactor(): Promise<number>
Swift declaration
@MainActor @preconcurrency override dynamic var contentScaleFactor: CGFloat { get set }

The scale factor of the content in the view.

set · iOS 13.0+

contentScaleFactor

TypeScript
setContentScaleFactor(value: number): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic var contentScaleFactor: CGFloat { get set }

The scale factor of the content in the view.

get · iOS 13.0+

session

TypeScript
get session(): Promise<_ARKit_ARSession>
Swift declaration
@MainActor @preconcurrency dynamic var session: ARSession { get set }

The AR session that supports the view’s rendering. RealityKit automatically creates a default session that the view manages. If you have an existing or custom session, setting it as the view's session replaces the default session. If you replace the default session, you need to start it by calling <doc://com.apple.documentation/documentation/arkit/arsession/2875735-run>. See ``automaticallyConfigureSession`` for more details. When ``ARView/automaticallyConfigureSession`` is <doc://com.apple.documentation/documentation/swift/true>, the default value is an <doc://com.apple.documentation/documentation/arkit/arworldtrackingconfiguration>.

set · iOS 13.0+

session

TypeScript
setSession(value: _ARKit_ARSession): Promise<void>
Swift declaration
@MainActor @preconcurrency dynamic var session: ARSession { get set }

The AR session that supports the view’s rendering. RealityKit automatically creates a default session that the view manages. If you have an existing or custom session, setting it as the view's session replaces the default session. If you replace the default session, you need to start it by calling <doc://com.apple.documentation/documentation/arkit/arsession/2875735-run>. See ``automaticallyConfigureSession`` for more details. When ``ARView/automaticallyConfigureSession`` is <doc://com.apple.documentation/documentation/swift/true>, the default value is an <doc://com.apple.documentation/documentation/arkit/arworldtrackingconfiguration>.

init · iOS 13.0+

init

TypeScript
static initCoder(decoder: _Foundation_NSCoder): Promise<(ARView) | null>
Swift declaration
@MainActor @preconcurrency required dynamic init?(coder decoder: NSCoder)

Creates an AR view initialized from data in a given decoder. - Parameters: - decoder: The decoder used to initialize the view.

init · iOS 13.0+

init

TypeScript
static initFrame(frameRect: { x: number; y: number; width: number; height: number }): Promise<ARView>
Swift declaration
@MainActor @preconcurrency override required dynamic init(frame frameRect: CGRect)

Creates an AR view with the specified dimensions. - Parameters: - frameRect: The frame rectangle for the view, measured in points.

get · iOS 13.0+

cameraMode

TypeScript
get cameraMode(): Promise<ARView_CameraMode>
Swift declaration
@MainActor @preconcurrency var cameraMode: ARView.CameraMode { get set }

A setting that chooses between the AR session’s camera and a virtual one.

set · iOS 13.0+

cameraMode

TypeScript
setCameraMode(value: ARView_CameraMode): Promise<void>
Swift declaration
@MainActor @preconcurrency var cameraMode: ARView.CameraMode { get set }

A setting that chooses between the AR session’s camera and a virtual one.

get · iOS 13.0+

environment

TypeScript
get environment(): Promise<ARView_Environment>
Swift declaration
@MainActor @preconcurrency var environment: ARView.Environment { get set }

The view’s background, lighting, and acoustic properties.

set · iOS 13.0+

environment

TypeScript
setEnvironment(value: ARView_Environment): Promise<void>
Swift declaration
@MainActor @preconcurrency var environment: ARView.Environment { get set }

The view’s background, lighting, and acoustic properties.

get · iOS 13.0+

debugOptions

TypeScript
get debugOptions(): Promise<ARView_DebugOptions>
Swift declaration
@MainActor @preconcurrency var debugOptions: ARView.DebugOptions { get set }

The current debugging options.

set · iOS 13.0+

debugOptions

TypeScript
setDebugOptions(value: ARView_DebugOptions): Promise<void>
Swift declaration
@MainActor @preconcurrency var debugOptions: ARView.DebugOptions { get set }

The current debugging options.

get · iOS 13.0+

audioListener

TypeScript
get audioListener(): Promise<(_RealityFoundation_Entity) | null>
Swift declaration
@MainActor @preconcurrency var audioListener: Entity? { get set }

The entity that defines the listener position and orientation for spatial audio. Set the ``ARView/audioListener`` to the entity in the scene from whose point of view RealityKit should render spatial audio. By default, the property is set to `nil`, in which case the active camera acts as the audio listener. This is usually what you want, because the camera typically mirrors the user’s point of view.

set · iOS 13.0+

audioListener

TypeScript
setAudioListener(value?: (_RealityFoundation_Entity) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency var audioListener: Entity? { get set }

The entity that defines the listener position and orientation for spatial audio. Set the ``ARView/audioListener`` to the entity in the scene from whose point of view RealityKit should render spatial audio. By default, the property is set to `nil`, in which case the active camera acts as the audio listener. This is usually what you want, because the camera typically mirrors the user’s point of view.

get · iOS 13.0+

physicsOrigin

TypeScript
get physicsOrigin(): Promise<(_RealityFoundation_Entity) | null>
Swift declaration
@MainActor @preconcurrency var physicsOrigin: Entity? { get set }

The entity that defines the origin of the scene's physics simulation. By default, the scene's origin acts as the origin for physics calculations. Set the ``ARView/physicsOrigin`` to choose a particular entity within the scene to act as the origin instead. Here are the steps to do that: 1. Add a new entity to the scene that tracks the ARKit anchor position. 2. Set `physicsOrigin` to the entity to indicate that this entity's transform determines the origin of the physics simulation. 3. Optionally, parent the Jenga blocks to the anchor entity. This way the Jenga blocks update automatically when the anchor position changes. Example: ```swift // Define your anchor entity and add it to the scene. let myAnchor = AnchorEntity(.image(group: "References", name: "GameImage")) scene.addAnchor(myAnchor) // Set myAnchor as the origin of the physics simulation. arView.physicsOrigin = myAnchor // Add the simulated blocks to the anchor. myAnchor.addChild(block0) myAnchor.addChild(block1) // ... ``` Using this setup, RealityKit simulates all forces, velocities, etc. relative to `myAnchor`. Moving the anchor will not affect the simulation. For more information, see <doc:handling-different-sized-objects-in-physics-simulations>.

set · iOS 13.0+

physicsOrigin

TypeScript
setPhysicsOrigin(value?: (_RealityFoundation_Entity) | null): Promise<void>
Swift declaration
@MainActor @preconcurrency var physicsOrigin: Entity? { get set }

The entity that defines the origin of the scene's physics simulation. By default, the scene's origin acts as the origin for physics calculations. Set the ``ARView/physicsOrigin`` to choose a particular entity within the scene to act as the origin instead. Here are the steps to do that: 1. Add a new entity to the scene that tracks the ARKit anchor position. 2. Set `physicsOrigin` to the entity to indicate that this entity's transform determines the origin of the physics simulation. 3. Optionally, parent the Jenga blocks to the anchor entity. This way the Jenga blocks update automatically when the anchor position changes. Example: ```swift // Define your anchor entity and add it to the scene. let myAnchor = AnchorEntity(.image(group: "References", name: "GameImage")) scene.addAnchor(myAnchor) // Set myAnchor as the origin of the physics simulation. arView.physicsOrigin = myAnchor // Add the simulated blocks to the anchor. myAnchor.addChild(block0) myAnchor.addChild(block1) // ... ``` Using this setup, RealityKit simulates all forces, velocities, etc. relative to `myAnchor`. Moving the anchor will not affect the simulation. For more information, see <doc:handling-different-sized-objects-in-physics-simulations>.

get · iOS 13.0+

renderOptions

TypeScript
get renderOptions(): Promise<ARView_RenderOptions>
Swift declaration
@MainActor @preconcurrency var renderOptions: ARView.RenderOptions { get set }

The render options that configure the view’s AR session. RealityKit applies effects like camera grain, motion blur, and depth of field to the render to make the AR experience more immersive. Each effect causes your virtual content to better blend in with live images from the camera in some way. To disable an effect, you add an option from the ``ARView/RenderOptions-swift.struct`` option set to the view’s ``ARView/renderOptions-swift.property`` property: ```swift arView.renderOptions.insert(.disableMotionBlur) // Turn off motion blur. ``` When you create an AR view, the system automatically adds certain render options to disable effects that might be too demanding for the GPU hardware on which your app is running. But you can modify the ``ARView/renderOptions-swift.property`` set at any time to enable or disable any particular effect, depending on the needs of your app. To decide whether to use an effect, consider both its visual impact on your app, and its computational cost. Check the cost by measuring your app’s CPU and GPU utilization with the effect enabled across all the devices your app supports, as described in <doc:improving-the-performance-of-a-realitykit-app>.

set · iOS 13.0+

renderOptions

TypeScript
setRenderOptions(value: ARView_RenderOptions): Promise<void>
Swift declaration
@MainActor @preconcurrency var renderOptions: ARView.RenderOptions { get set }

The render options that configure the view’s AR session. RealityKit applies effects like camera grain, motion blur, and depth of field to the render to make the AR experience more immersive. Each effect causes your virtual content to better blend in with live images from the camera in some way. To disable an effect, you add an option from the ``ARView/RenderOptions-swift.struct`` option set to the view’s ``ARView/renderOptions-swift.property`` property: ```swift arView.renderOptions.insert(.disableMotionBlur) // Turn off motion blur. ``` When you create an AR view, the system automatically adds certain render options to disable effects that might be too demanding for the GPU hardware on which your app is running. But you can modify the ``ARView/renderOptions-swift.property`` set at any time to enable or disable any particular effect, depending on the needs of your app. To decide whether to use an effect, consider both its visual impact on your app, and its computational cost. Check the cost by measuring your app’s CPU and GPU utilization with the effect enabled across all the devices your app supports, as described in <doc:improving-the-performance-of-a-realitykit-app>.

method · iOS 13.0+

trackedRaycast

TypeScript
trackedRaycast(point: { x: number; y: number }, target: _ARKit_ARRaycastQuery_Target, alignment: _ARKit_ARRaycastQuery_TargetAlignment, updateHandler: ((arg0: Array<_ARKit_ARRaycastResult>) => void)): Promise<(_ARKit_ARTrackedRaycast) | null>
Swift declaration
@MainActor @preconcurrency func trackedRaycast(from point: CGPoint, allowing target: ARRaycastQuery.Target, alignment: ARRaycastQuery.TargetAlignment, updateHandler: @escaping ([ARRaycastResult]) -> Void) -> ARTrackedRaycast?

Performs a tracked ray cast, where a ray is cast into the scene from the center of the camera through a point in the view. - Parameters: - point: A point in the view’s local coordinate system. - target: The type of target where the ray should terminate. - alignment: The alignment of the target. - updateHandler: A closure the method calls to update the list of results, sorted from nearest to farthest from the camera. The closure is called on the ``ARView/session`` instance’s delegate queue. - Returns: A tracked ray-cast instance used to update or stop ray casting. The result is `nil` if the ray cast fails or if the AR ``ARView/session`` configuration isn’t <doc://com.apple.documentation/documentation/arkit/arworldtrackingconfiguration> or one of its subclasses.

get · iOS 13.0+

cameraTransform

TypeScript
get cameraTransform(): Promise<_RealityFoundation_Transform>
Swift declaration
@MainActor @preconcurrency var cameraTransform: Transform { get }

The transform of the currently active camera.

method · iOS 13.0+

installGestures

TypeScript
installGestures(gestures: ARView_EntityGestures, entity: Implements<_RealityFoundation_HasCollision> | SDKHandle): Promise<Array<SDKHandle>>
Swift declaration
@discardableResult @MainActor @preconcurrency func installGestures(_ gestures: ARView.EntityGestures = .all, for entity: any HasCollision) -> [any EntityGestureRecognizer]

Installs standard gestures onto the given entity, configured to be recognized simultaneously. - Parameters: - gestures: The gesture types to install. - entity: The entity with which to associate the gesture recognizers. - Returns: The set of gesture recognizers created to handle the requested gestures.

get · iOS 15.0+

renderCallbacks

TypeScript
get renderCallbacks(): Promise<ARView_RenderCallbacks>
Swift declaration
@MainActor @preconcurrency var renderCallbacks: ARView.RenderCallbacks { get set }

A container that holds the view’s render callbacks. Render callbacks are closures RealityKit calls at predefined times. You can use render callbacks to modify the results of RealityKit’s rendering. If you assign a function or closure to any of the contained callback properties, RealityKit calls that function or closure at a predefined time. Setting the ``ARView/RenderCallbacks-swift.postProcess`` property, for example, causes RealityKit to call the assigned function or closure every frame, after RealityKit renders the scene, but before it displays it.

set · iOS 15.0+

renderCallbacks

TypeScript
setRenderCallbacks(value: ARView_RenderCallbacks): Promise<void>
Swift declaration
@MainActor @preconcurrency var renderCallbacks: ARView.RenderCallbacks { get set }

A container that holds the view’s render callbacks. Render callbacks are closures RealityKit calls at predefined times. You can use render callbacks to modify the results of RealityKit’s rendering. If you assign a function or closure to any of the contained callback properties, RealityKit calls that function or closure at a predefined time. Setting the ``ARView/RenderCallbacks-swift.postProcess`` property, for example, causes RealityKit to call the assigned function or closure every frame, after RealityKit renders the scene, but before it displays it.

method · iOS 13.0+

makeRaycastQuery

TypeScript
makeRaycastQuery(point: { x: number; y: number }, target: _ARKit_ARRaycastQuery_Target, alignment: _ARKit_ARRaycastQuery_TargetAlignment): Promise<(_ARKit_ARRaycastQuery) | null>
Swift declaration
@MainActor @preconcurrency func makeRaycastQuery(from point: CGPoint, allowing target: ARRaycastQuery.Target, alignment: ARRaycastQuery.TargetAlignment) -> ARRaycastQuery?

Creates a ray-cast query originating from a point in the view, centered on the camera’s field of view. - Parameters: - point: A point in the view’s coordinate system. - target: The type of target where the ray should terminate. - alignment: The alignment of the target. - Returns: A query result.

get · iOS 13.0+

automaticallyConfigureSession

TypeScript
get automaticallyConfigureSession(): Promise<boolean>
Swift declaration
@MainActor @preconcurrency var automaticallyConfigureSession: Bool { get set }

An indication of whether to use an automatically configured AR session. When enabled, the ``RealityKit/ARView`` automatically runs an ``RealityKit/ARSession`` with a default configuration. RealityKit updates that configuration based on t camera mode and scene anchors. When disabled, you need to provide a configuration object and run the session manually. The default value is <doc://com.apple.documentation/documentation/swift/true>.

set · iOS 13.0+

automaticallyConfigureSession

TypeScript
setAutomaticallyConfigureSession(value: boolean): Promise<void>
Swift declaration
@MainActor @preconcurrency var automaticallyConfigureSession: Bool { get set }

An indication of whether to use an automatically configured AR session. When enabled, the ``RealityKit/ARView`` automatically runs an ``RealityKit/ARSession`` with a default configuration. RealityKit updates that configuration based on t camera mode and scene anchors. When disabled, you need to provide a configuration object and run the session manually. The default value is <doc://com.apple.documentation/documentation/swift/true>.

method · iOS 13.0+

ray

TypeScript
ray(screenPoint: { x: number; y: number }): Promise<({ "origin": SDKHandle; "direction": SDKHandle }) | null>
Swift declaration
@MainActor @preconcurrency func ray(through screenPoint: CGPoint) -> (origin: SIMD3<Float>, direction: SIMD3<Float>)?

Determines the position and direction of a ray through the given point in the 2D space of the view. - Parameters: - screenPoint: A point in the view’s coordinate system. - Returns: A tuple that represents a ray in AR coordinates that goes from the camera origin through the specified point on the screen.

init · iOS 13.0+

init

TypeScript
static initFrameCameraModeAutomaticallyConfigureSession(frameRect: { x: number; y: number; width: number; height: number }, cameraMode: ARView_CameraMode, automaticallyConfigureSession: boolean): Promise<ARView>
Swift declaration
@MainActor @preconcurrency init(frame frameRect: CGRect, cameraMode: ARView.CameraMode, automaticallyConfigureSession: Bool)

Creates an AR view with the specified dimensions, camera mode, and session configuration state. - Parameters: - frameRect: The frame rectangle for the view, measured in points. - cameraMode: An indication of whether to use the device’s camera or a virtual one. - automaticallyConfigureSession: An indication of whether to use an AR session with configuration that’s updated automatically based on camera mode and scene anchors. Set this value to `false` if you want to run the session manually with your own configuration.

init · iOS 13.0+ · Deprecated

init

TypeScript
static initFrameCameraMode(frameRect: { x: number; y: number; width: number; height: number }, cameraMode: ARView_CameraMode): Promise<ARView>
Swift declaration
@MainActor @preconcurrency convenience init(frame frameRect: CGRect, cameraMode: ARView.CameraMode)

Creates an AR view with the specified dimensions and camera mode. - Parameters: - frameRect: The frame rectangle for the view, measured in points. - cameraMode: An indication of whether to use the device’s camera or a virtual one.

get · iOS 13.0+

scene

TypeScript
get scene(): Promise<_RealityFoundation_Scene>
Swift declaration
@MainActor @preconcurrency var scene: Scene { get }

The scene that the view renders and simulates. When you initialize a view, it comes with a single ``Scene`` instance that you access through the view’s ``ARView/scene`` property. Add ``AnchorEntity`` instances to the scene’s ``Scene/anchors`` collection to provide content for the scene.

method · iOS 13.0+

entity

TypeScript
entity(point: { x: number; y: number }): Promise<(_RealityFoundation_Entity) | null>
Swift declaration
@MainActor @preconcurrency func entity(at point: CGPoint) -> Entity?

Finds the entity in the AR scene closest to the specified point. The method ignores entities that lack a ``CollisionComponent``. - Parameters: - point: A point in the view’s coordinate system. - Returns: The entity at `point`, or `nil` if no entity is found.

method · iOS 13.0+

hitTest

TypeScript
hitTestQueryMask(point: { x: number; y: number }, query?: _RealityFoundation_CollisionCastQueryType, mask?: _RealityFoundation_CollisionGroup): Promise<Array<_RealityFoundation_CollisionCastHit>>
Swift declaration
@MainActor @preconcurrency func hitTest(_ point: CGPoint, query: CollisionCastQueryType = .all, mask: CollisionGroup = .all) -> [CollisionCastHit]

Searches for objects corresponding to a point in the view based on a query and a collision mask. The method ignores entities that lack a ``CollisionComponent``. - Parameters: - point: A point in the view’s coordinate system. - query: The query type. - mask: A collision mask that can be used to prevent hits with certain objects. - Returns: An array of hit results.

method · iOS 13.0+

hitTest

TypeScript
hitTestTypes(point: { x: number; y: number }, types: _ARKit_ARHitTestResult_ResultType): Promise<Array<_ARKit_ARHitTestResult>>
Swift declaration
@MainActor @preconcurrency func hitTest(_ point: CGPoint, types: ARHitTestResult.ResultType) -> [ARHitTestResult]

Searches for objects corresponding to a point in the view based on a set of result types. The method ignores entities that lack a ``CollisionComponent``. - Parameters: - point: A point in the view’s coordinate system. - types: The hit test search type to look for. - Returns: An array of hit results.

method · iOS 13.0+

project

TypeScript
project(point: SDKHandle): Promise<({ x: number; y: number }) | null>
Swift declaration
@MainActor @preconcurrency func project(_ point: SIMD3<Float>) -> CGPoint?

Projects a point from the 3D world coordinate system of the scene to the 2D pixel coordinate system of the view. - Parameters: - point: The point in 3D world coordinates. - Returns: A point in the view’s coordinate space.

method · iOS 13.0+

raycast

TypeScript
raycast(point: { x: number; y: number }, target: _ARKit_ARRaycastQuery_Target, alignment: _ARKit_ARRaycastQuery_TargetAlignment): Promise<Array<_ARKit_ARRaycastResult>>
Swift declaration
@MainActor @preconcurrency func raycast(from point: CGPoint, allowing target: ARRaycastQuery.Target, alignment: ARRaycastQuery.TargetAlignment) -> [ARRaycastResult]

Performs a ray cast, where a ray is cast into the scene from the center of the camera through a point in the view, and the results are immediately returned. - Parameters: - point: A point in the view’s local coordinate system. - target: The type of target where the ray should terminate. - alignment: The alignment of the target. - Returns: A list of ray-cast results, sorted from nearest to farthest from the camera. The list is empty if the ray cast fails.

method · iOS 13.0+

entities

TypeScript
entities(point: { x: number; y: number }): Promise<Array<_RealityFoundation_Entity>>
Swift declaration
@MainActor @preconcurrency func entities(at point: CGPoint) -> [Entity]

Finds the collection of entities at the specified point in the scene. The method ignores entities that lack a ``CollisionComponent``. - Parameters: - point: A point in the view’s coordinate system. - Returns: An array of entities at `point`. The array is empty if there are no entities.

method · iOS 13.0+

snapshot

TypeScript
snapshot(saveToHDR: boolean, completion: ((arg0: (_UIKit_UIImage) | null) => void)): Promise<void>
Swift declaration
@MainActor @preconcurrency func snapshot(saveToHDR: Bool, completion: @escaping (ARView.Image?) -> Void)

Takes a screenshot.

method · iOS 13.0+

unproject

TypeScript
unprojectViewport(point: { x: number; y: number }, viewport: { x: number; y: number; width: number; height: number }): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @preconcurrency func unproject(_ point: CGPoint, viewport: CGRect) -> SIMD3<Float>?

Maps a 2D point from the pixel coordinate system of a viewport into a 3D coordinate space. The point lies on this view's near clipping plane. - Parameters: - point: A point in `viewport`. - viewport: A viewport. - Returns: A view-space 3D coordinate.

method · iOS 14.0+

unproject

TypeScript
unprojectOntoPlaneRelativeToCamera(point: { x: number; y: number }, planeTransform: SDKHandle, relativeToCamera: boolean): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @preconcurrency func unproject(_ point: CGPoint, ontoPlane planeTransform: float4x4, relativeToCamera: Bool) -> SIMD3<Float>?

Unproject a 2D point from the view onto a plane in 3D world coordinates. A 2D point in the view’s coordinate space can refer to any point along a line segment in the 3D coordinate space. Unprojecting gets the 3D position of the point along this line segment that intersects the provided plane. - Parameters: - point: A point in the view’s coordinate system. - planeTransform: The transform used to define the coordinate system of the plane. The coordinate system’s positive y-axis is assumed to be the normal of the plane. - relativeToCamera: If the plane transform is relative to camera space or world space. - Returns: 3D position in world coordinates or nil if unprojection is not possible.

method · iOS 13.0+

unproject

TypeScript
unprojectOntoPlane(point: { x: number; y: number }, planeTransform: SDKHandle): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @preconcurrency func unproject(_ point: CGPoint, ontoPlane planeTransform: float4x4) -> SIMD3<Float>?

Maps a 2D point from the view’s coordinate system onto the given plane in 3D space. - Parameters: - point: The point in the view’s coordinate system. - planeTransform: A transform used to define the coordinate system of the plane. The positive y-axis is taken as the normal of the plane. - Returns: The 3D position in world coordinates, or `nil` if the mapping isn’t possible.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityKit types →