One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

HasTransform

protocol · iOS 13.0+ · SDK 27.1

@MainActor @preconcurrency protocol HasTransform : Entity

An interface that enables manipulating the scale, rotation, and translation of an entity. All entities automatically adopt this protocol because the ``Entity`` base class does. This adoption gives all entities a ``Transform`` component, and a collection of methods for manipulating the component, that you use to position the entity in space.

Members (32)

method · iOS 13.0+

setTransformMatrix

Swift declaration
@MainActor @preconcurrency func setTransformMatrix(_ transform: float4x4, relativeTo referenceEntity: Entity?)

Sets the transform of the entity relative to the given reference entity using a 4x4 matrix representation. The ``Transform`` component can’t represent all transforms that a general 4x4 matrix can represent. Setting a ``HasTransform/transform`` using a 4x4 matrix is therefore a lossy event that might result in certain transformations, like shear, being dropped. - Parameters: - transform: A 4x4 transform matrix, given relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 13.0+

orientation

Swift declaration
@MainActor @preconcurrency func orientation(relativeTo referenceEntity: Entity?) -> simd_quatf

Gets the orientation of an entity relative to the given entity. - Parameters: - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The orientation of the entity relative to `referenceEntity`.

get · iOS 13.0+

orientation

Swift declaration
@MainActor @preconcurrency var orientation: simd_quatf { get set }

The rotation of the entity relative to its parent. This value is the entity’s rotation relative to its parent. To get the world-space orientation of the entity, use ``HasTransform/orientation(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/rotation`` value on the ``HasTransform/transform``.

set · iOS 13.0+

orientation

Swift declaration
@MainActor @preconcurrency var orientation: simd_quatf { get set }

The rotation of the entity relative to its parent. This value is the entity’s rotation relative to its parent. To get the world-space orientation of the entity, use ``HasTransform/orientation(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/rotation`` value on the ``HasTransform/transform``.

method · iOS 13.0+

setPosition

Swift declaration
@MainActor @preconcurrency func setPosition(_ position: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Sets the position of the entity relative to the given reference entity. - Parameters: - position: A new position, relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 13.0+

visualBounds

Swift declaration
@MainActor @preconcurrency func visualBounds(recursive: Bool = true, relativeTo referenceEntity: Entity?, excludeInactive: Bool = false) -> BoundingBox

Computes a bounding box for the entity in the specified space, optionally including child entities. The method has complexity `O(n)`, where `n` is the number of entities in the hierarchy. - Parameters: - recursive: A Boolean that you set to `true` to incorporate the bounds of all descendants. - referenceEntity: An entity that defines a frame of reference. Set to `nil` to indicate world space. - excludeInactive: A Boolean that you set to `true` to exclude inactive entities. - Returns: The bounding box.

method · iOS 13.0+

setOrientation

Swift declaration
@MainActor @preconcurrency func setOrientation(_ orientation: simd_quatf, relativeTo referenceEntity: Entity?)

Sets the orientation of the entity relative to the given reference entity. - Parameters: - orientation: A new orientation, relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 13.0+

transformMatrix

Swift declaration
@MainActor @preconcurrency func transformMatrix(relativeTo referenceEntity: Entity?) -> float4x4

Gets the 4 x 4 transform matrix of an entity relative to the given entity. - Parameters: - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The transform of the entity relative to `referenceEntity`.

method · iOS 18.0+

look

Swift declaration
@MainActor @preconcurrency func look(at target: SIMD3<Float>, from position: SIMD3<Float>, upVector: SIMD3<Float> = SIMD3<Float>(0, 1, 0), relativeTo referenceEntity: Entity?, forward: Entity.ForwardDirection = .negativeZ)

Positions and orients the entity such that it looks at certain target from a give position. - Parameters: - target: The target position to look at. - position: The new position of the entity. - upVector: The *up* direction of the entity. - referenceEntity: The reference entity which defines the frame of reference. Can be `nil`, which is equivalent to "world space". - forward: Use default forward (.negativeZ). Can be set to .positiveZ for non-camera entities This function moves the entity to the specified `position`. It rotates the entity such that the forward direction is pointing towards `target`. It further makes sure that entity's *up* direction aligns with the specified `upVector`. - Note: This method can be used for non-camera entities.

method · iOS 13.0+

look

Swift declaration
@MainActor @preconcurrency func look(at target: SIMD3<Float>, from position: SIMD3<Float>, upVector: SIMD3<Float> = SIMD3<Float>(0, 1, 0), relativeTo referenceEntity: Entity?)

Positions and orients the entity to look at a target from a given position. You can use this method on any entity, but it’s particularly useful for orienting cameras and lights to aim at a particular point in space. - Parameters: - target: The target position to look at. - position: The new position of the entity. - upVector: The up direction of the entity after moving. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 13.0+

move

Swift declaration
@discardableResult @MainActor @preconcurrency func move(to target: Transform, relativeTo referenceEntity: Entity?, duration: TimeInterval, timingFunction: AnimationTimingFunction = .default) -> AnimationPlaybackController

Moves an entity over a period of time to a new location given by a transform. Animating the scale of an entity to 0 will cause a subsequent inverse of the entity's transform to return NaN values. Developers may consider animating the scale of an entity to a small non-zero value. When the move completes, the entity can then be hidden or removed if applicable to the use case. - Parameters: - target: A ``Transform`` instance that indicates the new location. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - duration: The time in seconds over which the move should occur. - timingFunction: A timing function that controls the progress of the animation. - Returns: An ``AnimationPlaybackController`` instance that you use to control the animation playback.

method · iOS 13.0+

move

Swift declaration
@discardableResult @MainActor @preconcurrency func move(to target: float4x4, relativeTo referenceEntity: Entity?, duration: TimeInterval, timingFunction: AnimationTimingFunction = .default) -> AnimationPlaybackController

Moves an entity over a period of time to a new location given by a 4x4 matrix. - Parameters: - target: A 4x4 matrix that indicates the new location. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - duration: The time in seconds over which the move should occur. - timingFunction: A timing function that controls the progress of the animation. - Returns: An ``AnimationPlaybackController`` instance that you use to control the animation playback.

method · iOS 13.0+

move

Swift declaration
@MainActor @preconcurrency func move(to transform: Transform, relativeTo referenceEntity: Entity?)

Moves an entity instantly to a new location given by a transform. - Parameters: - transform: A ``Transform`` instance that indicates the new location. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 13.0+

move

Swift declaration
@MainActor @preconcurrency func move(to transform: float4x4, relativeTo referenceEntity: Entity?)

Moves an entity instantly to a new location given by a 4x4 matrix. - Parameters: - transform: A 4x4 matrix that indicates the new location. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

method · iOS 18.0+

align

Swift declaration
@discardableResult @MainActor @preconcurrency func align(_ originPin: GeometricPin, to targetPin: GeometricPin) -> float4x4?

Moves and rotates the entity by a transformation from the origin pin to the target pin. - Parameter originPin: The `GeometricPin` to align. It should be one of the pins on the entity. - Parameter targetPin: The `GeometricPin` to align to. - Returns: Transformation matrix that has been applied to the `Entity`, in the frame or reference of the parent of the `Entity`. If either pin doesn't exist, returns `nil`.

method · iOS 13.0+

scale

Swift declaration
@MainActor @preconcurrency func scale(relativeTo referenceEntity: Entity?) -> SIMD3<Float>

Gets the scale of an entity relative to the given entity. - Parameters: - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

get · iOS 13.0+

scale

Swift declaration
@MainActor @preconcurrency var scale: SIMD3<Float> { get set }

The scale of the entity relative to its parent. This value is the entity’s scale relative to its parent. To get the actual scale of the entity in the scene, use ``HasTransform/scale(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/scale`` value on the ``HasTransform/transform``.

set · iOS 13.0+

scale

Swift declaration
@MainActor @preconcurrency var scale: SIMD3<Float> { get set }

The scale of the entity relative to its parent. This value is the entity’s scale relative to its parent. To get the actual scale of the entity in the scene, use ``HasTransform/scale(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/scale`` value on the ``HasTransform/transform``.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(normal: SIMD3<Float>, to referenceEntity: Entity?) -> SIMD3<Float>

Converts a normal vector from the local space of the entity on which you called this method to the local space of a reference entity. - Parameters: - normal: A vector perpendicular to a surface at a point, given in the local space of the entity. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The normal vector specified relative to `referenceEntity`.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(normal: SIMD3<Float>, from referenceEntity: Entity?) -> SIMD3<Float>

Converts a normal vector from the local space of a reference entity to the local space of the entity on which you called this method. - Parameters: - normal: A vector perpendicular to a surface at a point, specified relative to specified relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The normal vector given in the local space of the entity.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(position: SIMD3<Float>, to referenceEntity: Entity?) -> SIMD3<Float>

Converts a position from the local space of the entity on which you called this method to the local space of a reference entity. - Parameters: - position: The position given in the local space of the entity. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The position specified relative to `referenceEntity`.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(position: SIMD3<Float>, from referenceEntity: Entity?) -> SIMD3<Float>

Converts a position from the local space of a reference entity to the local space of the entity on which you called this method. - Parameters: - position: The position specified relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The position given in the local space of the entity.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(direction: SIMD3<Float>, to referenceEntity: Entity?) -> SIMD3<Float>

Converts a direction vector from the local space of the entity on which you called this method to the local space of a reference entity. - Parameters: - direction: The direction vector given in the local space of the entity. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The direction vector specified relative to `referenceEntity`.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(direction: SIMD3<Float>, from referenceEntity: Entity?) -> SIMD3<Float>

Converts a direction vector from the local space of a reference entity to the local space of the entity on which you called this method. - Parameters: - direction: The direction vector specified relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The direction vector given in the local space of the entity.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(transform: Transform, to referenceEntity: Entity?) -> Transform

Converts the scale, rotation, and position of a transform from the local space of the entity on which you called this method to the local space of a reference entity. - Parameters: - transform: The transform given in the local space of the entity. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The transform specified relative to `referenceEntity`.

method · iOS 13.0+

convert

Swift declaration
@MainActor @preconcurrency func convert(transform: Transform, from referenceEntity: Entity?) -> Transform

Converts the scale, rotation, and position of a transform from the local space of a reference entity to the local space of the entity on which you called this method. - Parameters: - transform: The transform specified relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The transform given in the local space of the entity.

method · iOS 13.0+

position

Swift declaration
@MainActor @preconcurrency func position(relativeTo referenceEntity: Entity?) -> SIMD3<Float>

Gets the position of an entity relative to the given entity. - Parameters: - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space. - Returns: The position of the entity relative to `referenceEntity`.

get · iOS 13.0+

position

Swift declaration
@MainActor @preconcurrency var position: SIMD3<Float> { get set }

The position of the entity relative to its parent. This value is the entity’s position relative to its parent. To get the world-space position of the entity in the scene, use ``HasTransform/position(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/translation`` value on the ``HasTransform/transform``.

set · iOS 13.0+

position

Swift declaration
@MainActor @preconcurrency var position: SIMD3<Float> { get set }

The position of the entity relative to its parent. This value is the entity’s position relative to its parent. To get the world-space position of the entity in the scene, use ``HasTransform/position(relativeTo:)``, passing `nil` as the reference entity. This is the same as the ``Transform/translation`` value on the ``HasTransform/transform``.

method · iOS 13.0+

setScale

Swift declaration
@MainActor @preconcurrency func setScale(_ scale: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Sets the scale factor of the entity relative to the given reference entity. - Parameters: - scale: A new scale factor, relative to `referenceEntity`. - referenceEntity: The entity that defines a frame of reference. Set this to `nil` to indicate world space.

get · iOS 13.0+

transform

Swift declaration
@MainActor @preconcurrency var transform: Transform { get set }

The transform of an entity relative to its parent. For an ``AnchorEntity`` instance, the transform is relative to the AR anchor.

set · iOS 13.0+

transform

Swift declaration
@MainActor @preconcurrency var transform: Transform { get set }

The transform of an entity relative to its parent. For an ``AnchorEntity`` instance, the transform is relative to the AR anchor.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →