Files
feuerwerk/src/runtime/Entity.ts
T
adminandClaude Opus 5 193378e6a9 An animation is a timeline of rows over one asset, played on an object rather than worn as a picture (#97)
Part (a) of the animation rework: model, commands, saving, runtime and nodes.

- AnimationAsset holds a root (sprite, text, container or scene) and rows; a row keys one
  property of the root or of an object inside it, keys sit on whole frames.
- The last key decides the length (its frame counts as a frame of its own). The playhead runs
  between frames, so numbers and colors blend every tick even at 10 fps; everything else holds.
- Playback gains `once-reset`, which puts back what was there before the start. A row can be
  relative, adding to where its target stood.
- Play / Pause / Stop animation act on an object; each instance plays on its own, the later
  start wins on a shared property, and a behavior writing the same property still writes last.
- A sprite no longer wears an animation through `texture`. "Create animation from texture"
  builds a sprite plus a texture row keyed frame by frame instead.
- The Animation tab shows a placeholder until the timeline editor (part b) lands.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-16 20:02:25 +02:00

30 lines
1.3 KiB
TypeScript

import type { ENTITY_HANDLE } from '../core/graph/NodeContext';
import type { AnimationPlayer } from '../core/model/animation';
import type { AssetType } from '../core/model/AssetTypes';
import type { PropertyBag } from '../core/model/Properties';
/** A live instance of a scene object; its resolved props are mutable runtime state the world mirrors back. */
export interface Entity {
/** What tells a graph this object is a live entity and not a struct value. */
readonly [ENTITY_HANDLE]: true;
id: string;
/** Scene object this entity was instantiated from (for selection highlighting). */
objectId: string;
assetId: string;
type: AssetType;
name: string;
/** Position local to `parent` (world position for top-level entities). */
x: number;
y: number;
/** Draw order, relative to the parent as well; higher is drawn on top. */
z: number;
/** For behaviors: the resolved variables (mutable state). For others: resolved properties. */
props: PropertyBag;
/** Parent entity (mirrors `SceneObject.parentId`); children move and die with it. */
parent: Entity | null;
/** The animations playing on this object; kept out of `props`, which the world writes back. */
animations?: AnimationPlayer[];
/** How often an `Emit` node has restarted this particle source; out of `props` for the same reason. */
emits?: number;
}