// @forgeax/engine-runtime - authored local transform and derived world output. import { defineComponent } from '@forgeax/engine-ecs'; const IDENTITY_MAT4 = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); /** Scene-owned derived world transform. Only TransformPropagation writes it. */ export const GlobalTransform = defineComponent( 'GlobalTransform', { world: { type: 'array', default: IDENTITY_MAT4 }, }, { transient: true }, ); /** * Authored local position, rotation and scale columns. * * The ECS `requires` declaration is the generic structural invariant: callers * add `Transform`, while `GlobalTransform` is materialized once at spawn/add. */ export const Transform = defineComponent( 'Transform', { pos: { type: 'array', default: new Float32Array([0, 0, 0]) }, // Component order [x, y, z, w] is shared with glTF. quat: { type: 'array', default: new Float32Array([0, 0, 0, 1]) }, scale: { type: 'array', default: new Float32Array([1, 1, 1]) }, }, { requires: [GlobalTransform] }, );