A component that defines the scale, rotation, and translation of an entity.


struct Transform


An entity acquires a Transform component, as well as a set of methods for manipulating the transform, by adopting the HasTransform protocol. This is true for all entities, because the Entity base class adopts the protocol.


Creating a Transform


Creates a transform with the values of the identity transform.

init(scale: SIMD3<Float>, rotation: simd_quatf, translation: SIMD3<Float>)

Creates a new transformation using the given values.

init(pitch: Float, yaw: Float, roll: Float)

Creates a new transform from the specified Euler angles.

init(matrix: float4x4)

Creates a new transform represented as a 4x4 matrix.

Setting Transform Properties

var scale: SIMD3<Float>

The scaling factor applied to the entity.

var rotation: simd_quatf

The rotation of the entity specified as a unit quaternion.

var translation: SIMD3<Float>

The position of the entity along the x, y, and z axes.

var matrix: float4x4

The transform represented as a 4x4 matrix.

Getting the Identity Transform

static let identity: Transform

The identity transform.

Comparing Transforms

static func == (Transform, Transform) -> Bool

Indicates whether two transforms are equal.

static func != (Transform, Transform) -> Bool

Indicates whether two transforms are not equal.

func hash(into: inout Hasher)

Hashes the essential components of the transform by feeding them into the given hash function.

var hashValue: Int

The hashed value of the transform.

Registering a Component Type

static func registerComponent()

Registers a new component type.


Conforms To

See Also

Accessing the Component