dacha
    Preparing search index...

    Class Transform

    Component responsible for handling local and world-space transforms.

    A Transform manages position, rotation, and scale, and computes corresponding transformation matrices. It supports hierarchical parent-child relationships via world matrix composition.

    // Create a transform for an actor
    const transform = new Transform({
    offset: { x: 100, y: 50 },
    rotation: 45,
    scale: { x: 1.5, y: 1.0 }
    });

    // Add to actor
    actor.setComponent(transform);

    // Access world coordinates
    console.log(`Position: ${transform.world.position.x}, ${transform.world.position.y}`);
    console.log(`Rotation (in radians): ${transform.world.rotation}`);
    console.log(`Scale: ${transform.world.scale.x}, ${transform.world.scale.y}`);

    Hierarchy (View Summary)

    Index
    actor?: Actor
    local: LocalTransform

    Local-space transform values (position, rotation, scale). These values are relative to the parent transform.

    localMatrix: Matrix

    Matrix representing the local-space transformation.

    world: WorldTransform

    World-space transform values derived from the local transform and the parent hierarchy.

    worldMatrix: Matrix

    Matrix representing the world-space transformation.

    componentName: string
    • get invertedWorldMatrix(): Matrix

      Inverse of the world transformation matrix. Useful for converting world-space coordinates to local space.

      Returns Matrix

    • Returns the parent Transform component, if one exists.

      Returns Transform | undefined

      The parent Transform or undefined if this transform has no parent.

    • Marks this transform and all descendant transforms as dirty.

      This signals that their matrices must be recalculated before use.

      Returns void

    • Recomputes the local transformation matrix from local position, rotation, and scale.

      Returns void

    • Recomputes the world transformation matrix if the transform is dirty.

      This method ensures parent transforms are updated first and then composes the local matrix with the parent world matrix.

      Returns void