A container that holds the collection of entities that an AR view renders.
You don’t create a ``Scene`` instance directly. Instead, you get the one and
only scene associated with a view from the ``ARView/scene`` property of an
``ARView`` instance.

To add content to the view’s scene, you first create and add one or more
``AnchorEntity`` instances to the scene’s ``RealityKit/Scene/anchors`` collection.
Anchors tell RealityKit how to pin virtual content to real world objects,
like flat surfaces or images. You then add a hierarchy of other ``RealityKit/Entity``
instances to each anchor to indicate the geometry and behaviors that
RealityKit should render at a given anchor point.
Performs a convex shape cast against all the geometry in the scene.
- Parameters:
- convexShape: The convex shape to cast.
- fromPosition: The starting position of `convexShape` relative to
`referenceEntity`.
- fromOrientation: The starting orientation of `convexShape` relative to
`referenceEntity`.
- toPosition: The ending position of `convexShape` relative to
`referenceEntity`.
- toOrientation: The ending orientation of `convexShape` relative to
`referenceEntity`.
- query: The query type.
- mask: A collision mask that you can use to prevent collisions with
certain objects.
- referenceEntity: An entity that defines the frame of reference. The
method returns results relative to this entity. Set to `nil` to use the
world space origin `(0, 0, 0)`.
- Returns: An array of collision cast hit results. Each hit indicates
where the convex shape, starting at a given point and traveling in a
given direction, collides with entities in the scene. To retrieve the
hit entity from a returned ``CollisionCastHit``, use the
``CollisionCastHit/entity`` property.
For objects that intersect the convex shape at its starting position and
orientation, the returned collision cast hit result’s
``CollisionCastHit/position`` is `(0, 0, 0)` and the
``CollisionCastHit/normal`` points in the opposite direction of the
sweep.
Returns `Entity` with the given `Entity.ID` in the `Scene`.
- Parameters:
- id: `Entity.ID` obtained from `Entity.id`
- Returns: `Entity` with the given `Entity.ID`, or `nil` if no such `Entity` is found in the `Scene`.
- Note: This method uses efficient mapping from `Entity.ID` to `Entity`, not linear traversal of all Entities in the `Scene`.
Searches the scene’s anchor entity hierarchies for an entity with the
given name.
The ``Scene/findEntity(named:)`` method conducts a depth-first,
recursive search over all of the scene’s entities for one whose
``Entity/name`` property matches the given name. The method returns the
first match. Entity names need not be unique.
- Parameters:
- name: The name of the entity for which to search.
- Returns: The first entity found with the given name, or `nil` if none
is found.
get · iOS 27.0+
commandQueue
TypeScript
get commandQueue(): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @preconcurrency var commandQueue: (any MTLCommandQueue)? { get }
If this scene uses a MTLCommandQueue for rendering, returns it.
You use this command queue for GPU workloads that need consistent
ordering relative to RealityKit's scene rendering.
Returns all entities of the scene which pass the query.
When in ``System/update(context:)-69f86``, call ``SceneUpdateContext/entities(matching:updatingSystemWhen:)``
instead of `performQuery`.
This allows the ``System`` to sleep on some platforms
when there is no matching component,
reducing unnecessary work.
method · iOS 13.0+
removeAnchor
TypeScript
removeAnchor(anchor: SDKHandle): Promise<void>
Swift declaration
@MainActor @preconcurrency func removeAnchor(_ anchor: any HasAnchoring)
Removes the specified anchor from the scene.
- Parameters:
- anchor: The anchor to remove.
get · iOS 13.0+
synchronizationService
TypeScript
get synchronizationService(): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @preconcurrency var synchronizationService: (any SynchronizationService)? { get set }
Performs a ray cast against all the geometry in the scene for a
ray between two end points.
The method ignores entities that lack a ``CollisionComponent``.
The ``CollisionCastHit/normal`` property on returned result objects
contains the surface normal at the point of intersection with the
entity’s collision shape.
The following are some details to keep in mind.
* The ray needs to fully intersect a primitive for a hit to be detected. In particular, it is not enough for the ray to precisely tangent or end at the primitive's surface. This becomes especially important when ray casting against primitives that are far away from the ray origin.
* Due to numerical imprecision, it may be necessary to use a slightly longer ray length than your desired maximum distance in order to ensure that a full intersection occurs with your target primitive. Moreover, the length of the ray needs to be a positive finite number that is smaller than ``greatestFiniteMagnitude``.
- Parameters:
- startPosition: The start position of the ray relative to
`referenceEntity`.
- endPosition: The end position of the ray relative to
`referenceEntity`.
- query: A query type.
- mask: A collision mask that you can use to prevent collisions with
certain objects.
- referenceEntity: An entity that defines the frame of reference. The
method returns results relative to this entity. Set to `nil` to use the
world space origin `(0, 0, 0)`.
- Returns: An array of collision cast hit results. Each hit indicates
where the ray, starting at `startPosition` and ending at `endPosition`,
hit a particular entity in the scene.
Performs a ray cast against all the geometry in the scene for a
ray of a given origin, direction, and length.
The method ignores entities that lack a ``CollisionComponent``.
The ``CollisionCastHit/normal`` property on returned result objects
contains the surface normal at the point of intersection with the
entity’s collision shape.
The following are some details to keep in mind.
* The ray needs to fully intersect a primitive for a hit to be detected. In particular, it is not enough for the ray to precisely tangent or end at the primitive's surface. This becomes especially important when ray casting against primitives that are far away from the ray origin.
* Due to numerical imprecision, it may be necessary to use a slightly longer ray length than your desired maximum distance in order to ensure that a full intersection occurs with your target primitive. Moreover, the length of the ray needs to be a positive finite number that is smaller than ``greatestFiniteMagnitude``.
- Parameters:
- origin: The origin of the ray relative to `referenceEntity`.
- direction: The direction of the ray relative to `referenceEntity`.
- length: The length of the ray relative to `referenceEntity`.
- query: A query type.
- mask: A collision mask that you can use to prevent collisions with
certain objects.
- referenceEntity: An entity that defines the frame of reference. The
method returns results relative to this entity. Set to `nil` to use the
world space origin `(0, 0, 0)`.
- Returns: An array of collision cast hit results. Each hit indicates
where the ray, starting at a given point and traveling in a given
direction, hit a particular entity in the scene.
get · iOS 18.0+
timebase
TypeScript
get timebase(): Promise<_CoreMedia_CMTimebase>
Swift declaration
@MainActor @preconcurrency var timebase: CMTimebase { get }
The default timebase for the scene, useful for driving custom
times managed by the user which are derived from the scene time.
method · iOS 13.0+
addAnchor
TypeScript
addAnchor(anchor: SDKHandle): Promise<void>
Swift declaration
@MainActor @preconcurrency func addAnchor(_ anchor: any HasAnchoring)
Adds an anchor to the scene’s list of anchors.
- Parameters:
- anchor: The anchor to add.
Performs a ray cast against all the geometry in the scene for a ray
between two end points.
The method ignores entities that lack a ``ModelComponent`` with a valid
mesh.
- Parameters:
- startPosition: The start position of the ray relative to the scene.
- endPosition: The end position of the ray relative to the scene.
- Returns: A `PixelCastHit`. The hit indicates where the ray, starting
at `startPosition` and ending at `endPosition`, hit a particular entity
in the scene.
Performs a ray cast against all the geometry in the scene for a ray of
a given origin, direction, and length.
The method ignores entities that lack a ``ModelComponent`` with a valid
mesh.
- Parameters:
- origin: The origin of the ray relative to the scene.
- direction: The direction of the ray relative to the scene.
- length: The length of the ray relative to the scene.
- Returns: A `PixelCastHit`. The hit indicates where the ray, starting
at a given point and traveling in a given direction, hit a particular
entity in the scene.
Skipped declarations
4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.