Taos API Reference
    Preparing search index...

    Class Transform

    Local TRS plus a cached world transform for a GameObject.

    Holds the owning object's local-space position / rotation / scale and lazily derives the world-space matrix (and its inverse) from the parent chain.

    Invalidation is compare-on-read, not write-interception: position, rotation, and scale stay plain mutable Vec3/Quaternion instances that callers mutate however they like (pos.set(...), pos.y += dt, whole-vector assignment). Nothing marks a dirty flag on write. Instead, Transform.worldMatrix detects change on read:

    • Local change — the 10 current TRS scalars are compared against the values last baked into localMatrix; a mismatch rebuilds it.
    • Ancestor change — each transform bumps a _worldVersion counter whenever it recomputes its world matrix; a child folds in the parent's matrix only when the parent's version differs from the one it last saw.

    Reading worldMatrix therefore walks to the root doing cheap scalar/integer comparisons, but only performs matrix math on transforms that actually moved. Reading the raw position/rotation/scale does no work at all.

    Index

    Constructors

    Properties

    gameObject: GameObject

    The GameObject this transform belongs to. Provides the parent chain.

    Accessors

    • get worldMatrix(): Mat4

      World-space matrix. Recomputed only when this transform's local TRS changed or any ancestor's world matrix changed since the last read.

      Returns Mat4

    • get worldScale(): Vec3

      World-space scale — the per-axis magnitude of the worldMatrix basis columns, recovered from the full parent chain. A negative (mirrored) determinant folds its sign into the X component, matching the convention used when re-composing via Mat4.setTrs.

      Heavier than worldPosition, but memoized: the decomposition runs only when the world matrix changed. Returns a Vec3 owned by this transform; copy it (or use getWorldScale) before mutating.

      Returns Vec3

    • get worldRotation(): Quaternion

      World-space rotation — the quaternion of worldMatrix with scale removed, recovered from the full parent chain. For a sheared world matrix the result is the closest pure rotation.

      Heaviest of the three, but memoized: the decomposition runs only when the world matrix changed. Returns a Quaternion owned by this transform; copy it (or use getWorldRotation) before mutating.

      Returns Quaternion

    Methods