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
_skew: Vector3
identity: Immutable<Transform>

Accessors

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

    Returns Vector3

  • get down(): Vector3
  • Gets the negative Y (down) axis of the object.

    Returns Vector3

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

    Returns Vector3

  • get inverseMatrix(): Matrix4
  • Builds the inverse transform matrix.

    Returns Matrix4

  • get isUsingSkew(): boolean
  • Returns true if the transform has a non-zero skew.

    Returns boolean

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

    Returns Vector3

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

    Returns Matrix4

  • get matrix3(): Matrix3
  • Builds the 3x3 upper left transform matrix from rotation, scale and skew.

    Returns Matrix3

  • set matrix3(value): void
  • Parameters

    Returns void

  • get position(): Vector3
  • Returns Vector3

  • set position(value): void
  • Parameters

    Returns void

  • get right(): Vector3
  • Gets the negative 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

  • get skew(): Vector3
  • Skew factors in QDU convention: XY, XZ, YZ (vecU from QDUDecomposition). kZero means no skew.

    Returns Vector3

  • set skew(value): void
  • Parameters

    Returns void

  • get up(): Vector3
  • Gets the positive Y (up) axis of the object.

    Returns Vector3

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

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

    Parameters

    Returns Transform

  • 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 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 Transform

  • Rotate the object around an arbitrary axis.

    Parameters

    Returns Transform

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

    Parameters

    Returns Transform

  • 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

  • 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 Transform

  • Rotate the object around an arbitrary axis.

    Parameters

    Returns Transform

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

    Parameters

    Returns Transform

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

    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 by comparing position, rotation and scale.

    Parameters

    Returns boolean