import Component from '../core/Component.js'; import Vector2 from '../math/Vector2.js'; /** * Component that holds the position, rotation, and scale of an entity. * Supports hierarchical transformations (parent-child relationships). */ export default class TransformComponent extends Component { private _position; private _rotation; private _scale; /** Local position relative to the parent. */ get position(): Vector2; set position(val: Vector2); /** Local rotation in radians relative to the parent. */ get rotation(): number; set rotation(val: number); /** Local scale relative to the parent. */ get scale(): Vector2; set scale(val: Vector2); /** Reference to the parent transform. */ parent?: TransformComponent; /** List of children transforms. */ children: Set; private _isDirty; private _worldPosition; private _worldRotation; private _worldScale; constructor(); /** * Internal callback for when local vectors are modified. * @private */ private onLocalTransformChange; /** * Sets this transform and all its children as dirty, forcing a recalculation * of world-space properties on the next access. */ setDirty(): void; /** * Adds a child transform to this one. * @param child The child transform to add. */ addChild(child: TransformComponent): void; /** * Removes a child transform from this one. * @param child The child transform to remove. */ removeChild(child: TransformComponent): void; /** * Gets the world-space position. * Note: This returns a clone to prevent accidental cache mutation. * For performance, use getWorldPosition(out). */ get worldPosition(): Vector2; /** * Writes the world-space position into the provided 'out' vector. * Allocation-free alternative to the worldPosition getter. * @param out The vector to write into. * @returns The 'out' vector for chaining. */ getWorldPosition(out: Vector2): Vector2; /** * Calculates the world-space rotation. */ get worldRotation(): number; /** * Calculates the world-space scale. * Note: This returns a clone to prevent accidental cache mutation. * For performance, use getWorldScale(out). */ get worldScale(): Vector2; /** * Writes the world-space scale into the provided 'out' vector. * Allocation-free alternative to the worldScale getter. * @param out The vector to write into. * @returns The 'out' vector for chaining. */ getWorldScale(out: Vector2): Vector2; /** * Recalculates all world-space properties from the root parent down. * @private */ private updateWorldTransform; }