An anchor that tethers entities to a scene.
Control how RealityKit places virtual objects into your scene with anchor entities.
`AnchorEntity` conforms to the ``HasAnchoring`` protocol,
which gives it an ``AnchoringComponent`` instance.
RealityKit places anchors based on the anchoring component's
``AnchoringComponent/target-swift.property`` property. For example, you can
configure an anchor entity to rest on a horizontal surface that RealityKit detects in an AR
scene like a table or floor, and RealityKit automatically places that anchor
after it detects an appropriate horizontal plane in the real world.
The example below creates an anchor to a horizontal surface:
```swift
AnchorEntity(.plane(.horizontal,
classification: .any,
minimumBounds: SIMD2<Float>(0.2, 0.2)
))
```
See <doc:selecting-an-anchor-for-a-reality-composer-scene> for more
information about the different types of anchors available when using Reality Composer Pro.

Add anchor entities directly to your scene's ``Scene/anchors`` collection,
or anywhere else in the scene hierarchy by adding them to the
``Entity/children`` collection of another entity in your scene. Because
`AnchorEntity` is a subclass of ``Entity``, you can make an anchor entity
a subentity of any other entity. RealityKit might move anchor entities as the
scene updates, so the location and rotation of the anchor entity can change
relative to its container entity, even if your code never modifies its
``Entity/transform`` property.
Some anchor entities might not show up in your scene at all if RealityKit
fails to detect an appropriate place for them. For example, an anchor entity
with an `image` target doesn't show up in the scene until RealityKit detects
the specified image in the real world.

You can have multiple anchors in a RealityKit scene. For example, one anchor
can place a toy car on a horizontal surface, like a table, and another
can tie an informative text bubble to an image in the same scene.
- Note: By default, physics bodies and colliders affect only entities that share
the same anchor.
An entity and its descendants can participate in the physics simulation at the
root of your scene by setting its
``AnchoringComponent/physicsSimulation-swift.property`` to
``AnchoringComponent/PhysicsSimulation-swift.enum/none``.
Creates an anchor entity that targets a plane with the given
characteristics.
- Parameters:
- alignment: The alignment of the plane to target, like
``AnchoringComponent/Target-swift.enum/Alignment/horizontal`` or
``AnchoringComponent/Target-swift.enum/Alignment/vertical``.
- classification: The classification of the target plane to look for,
like ``AnchoringComponent/Target-swift.enum/Classification/floor`` or
``AnchoringComponent/Target-swift.enum/Classification/ceiling``.
- minimumBounds: The minimum size of the target plane.
Creates an anchor entity with a target fixed at the given position in
the scene.
- Parameters:
- transform: The transform with which to initialize the world target.
Creates an anchor entity with a target fixed at the given position in
the scene.
- Parameters:
- position: The position with which to initialize the world target.