Owning object; its parent drives world derivation.
Optionalposition: Vec3Local position; adopted by reference (default origin).
Optionalrotation: QuaternionLocal rotation; adopted by reference (default identity).
Optionalscale: Vec3Local scale; adopted by reference (default one).
Local-space rotation. Mutate freely; changes are detected on the next world read.
Local-space TRS matrix, rebuilt only when a TRS component changed.
World-space matrix. Recomputed only when this transform's local TRS changed or any ancestor's world matrix changed since the last read.
Inverse of worldMatrix, recomputed lazily only when the world matrix changes. Returns a matrix owned by this transform — copy it before mutating.
World-space position — the translation column of worldMatrix.
Cheap (a direct read, no decomposition). Returns a Vec3 owned by this transform; copy it (or use getWorldPosition) before mutating or holding it across frames.
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.
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.
Allocation-free worldPosition: writes the world position into out
(allocating a fresh Vec3 only when omitted) and returns it.
Optionalout: Vec3Allocation-free worldScale: writes the world scale into out
(allocating a fresh Vec3 only when omitted) and returns it.
Optionalout: Vec3Allocation-free worldRotation: writes the world rotation into out
(allocating a fresh Quaternion only when omitted) and returns it.
Optionalout: Quaternion
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, andscalestay 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:Reading
worldMatrixtherefore walks to the root doing cheap scalar/integer comparisons, but only performs matrix math on transforms that actually moved. Reading the rawposition/rotation/scaledoes no work at all.