Class Transform

The Transform contains information about 3D object's position, rotation and scale. The class follows the 'copy-on-write' pattern, which means that every operation returns a copy of the transform with updated values. It also implies that the values of the transform cannot be directly modified.

The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

Constructors

Properties

_position: Vector3
_rotation: Quaternion
_scale: Vector3
identity: Transform

Accessors

  • get forward(): Vector3
  • Determines the Z (forward) axis of the object.

    Returns Vector3

  • get inverseMatrix(): Matrix4
  • Builds the inverse transform matrix from current translation, rotation and scale properties.

    Returns Matrix4

  • get matrix(): Matrix4
  • Builds the transform matrix from current translation, rotation and scale properties.

    Returns Matrix4

  • get position(): Vector3
  • Returns Vector3

  • set position(value): void
  • Parameters

    Returns void

  • get right(): Vector3
  • Gets the X (right) axis of the object.

    Returns Vector3

  • get rotation(): Quaternion
  • Returns Quaternion

  • set rotation(value): void
  • Parameters

    Returns void

  • get scale(): Vector3
  • Returns Vector3

  • set scale(value): void
  • Parameters

    Returns void

Methods

  • Copies all properties defined by the prototype of Transform from other to this instance.

    Parameters

    Returns Transform

  • Clones this instance and returns a new Transform with identical values.

    Returns Transform

  • Makes the current transform relative to the provided transform and returns the result. In other words, converts from a world coordinate system to one local to the provided transform.

    Parameters

    • parent: Immutable<Transform>

      Transform relative to which to make the current transform local.

    Returns Transform

  • Makes the current transform absolute. In other words, converts from a local coordinate system relative to the provided transform, to a world coordinate system.

    Parameters

    • parent: Immutable<Transform>

      Transform relative to which to make the current transform in world space.

    Returns Transform

  • Moves the object's position by the vector offset provided along world axes.

    Parameters

    Returns Transform

  • Moves the object's position by the vector offset provided along it's own axes (relative to orientation).

    Parameters

    Returns Transform

  • Rotate the object around an arbitrary axis.

    Parameters

    Returns void

  • Rotate the object around an arbitrary axis using a Quaternion.

    Parameters

    Returns void

  • Determines if both transforms are equal.

    Parameters

    Returns boolean

  • Makes the current transform relative to the provided transform and returns the result. In other words, converts from a world coordinate system to one local to the provided transform.

    Parameters

    • parent: Immutable<Transform>

      Transform relative to which to make the current transform local.

    Returns Transform

  • Makes the current transform absolute and returns the result. In other words, converts from a local coordinate system relative to the provided transform, to a world coordinate system.

    Parameters

    • parent: Immutable<Transform>

      Transform relative to which to make the current transform in world space.

    Returns Transform

  • Assigns the value as new forward (look at) vector.

    Parameters

    Returns void

  • Orients the object so it is looking at the provided location (world space) while using the Y axis as the up axis.

    Parameters

    Returns void

  • Orients the object so it is looking at the provided location (world space) where up is used for determining the location of the object's Y axis.

    Parameters

    Returns void

  • Converts the provided world position to a space relative to the provided parent, and sets it as the current transform's position.

    Parameters

    Returns void

  • Converts the provided world rotation to a space relative to the provided parent, and sets it as the current transform's rotation.

    Parameters

    Returns void

  • Converts the provided world scale to a space relative to the provided parent, and sets it as the current transform's scale.

    Parameters

    Returns void

  • Returns a string representation of an object.

    Returns string

  • Determines if both transforms are equal.

    Parameters

    Returns boolean