Transform

The Transform component defines an entity’s position, scale, and rotation in the game world.
It supports hierarchical relationships, allowing a transform to be parented to another, so child transforms inherit and combine with their parent’s transformations.

This component provides both local and world-space values and allows selectively ignoring parent transformations for position, scale, and rotation.

Properties

PropertyTypeDescription
positionVector2Position relative to the simulated world’s origin, or relative to the parent if one exists.
scaleVector2Scale factors along the X and Y axes.
rotationnumberRotation expressed in radians.
ignoreParentPositionbooleanIf true, ignores the parent’s position.
ignoreParentScalebooleanIf true, ignores the parent’s scale.
ignoreParentRotationbooleanIf true, ignores the parent’s rotation.
localPosition (read-only)Vector2Actual world position (same as position if there’s no parent).
localScale (read-only)Vector2Actual world scale (same as scale if there’s no parent).
localRotation (read-only)numberActual world rotation (same as rotation if there’s no parent).

Example

const transform = new Transform({
    position: new Vector2(100, 100),
    scale: new Vector2(2, 2),
    rotation: Math.PI / 4,
});

Notes

  • Hierarchical transforms allow powerful parent-child relationships for grouping entities.
  • The ignoreParent* properties provide flexibility to override inherited transformations.