@typeonce/ritmo-render 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # @typeonce/ritmo-render
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b58d75b: **Child entities' nodes attach under their parent's node.** `RenderSync.system(Game, { ..., hierarchy: Attached })` takes a `Descriptor.Hierarchy` of the game: a child's node is added under its parent's node instead of the root, so the renderer composes the transforms and `apply` sets the child's local transform. A child moves when its parent changes, is removed, or gains or loses its node, in the same run; parents move before their children. Despawning a parent despawns its children, so their nodes go with it. A parent that only loses its renderable hands its children's nodes back to the root.
8
+
9
+ ```ts
10
+ const { relation: Attached } = Descriptor.Hierarchy(
11
+ "Game/Attached",
12
+ "Game/Attachments"
13
+ );
14
+ const Render = RenderSync.system(Game, {
15
+ name: "Game/Render",
16
+ renderable: Body,
17
+ transform: Position,
18
+ registry: Sprites,
19
+ hierarchy: Attached,
20
+ create,
21
+ apply,
22
+ });
23
+ ```
24
+
25
+ - A `Descriptor.Relation` as `hierarchy` does not compile (`hierarchy must be a Descriptor.Hierarchy relation`), and neither does a relation missing from the schema (`hierarchy must be a relation of the game's schema`).
26
+ - `NodeRegistry` keeps the node tree: `ensure(entity, create, parent?)` creates a node under a parent's node, `reparent(entity, parent)` moves one (and refuses a loop), and `parents` maps each nested node's entity to its parent's. `remove` moves a removed node's children back to the root before detaching it, and `clear` detaches children before their parents.
27
+ - `PixiNodeRegistry.make(container)` adds a node with `(parent ?? container).addChild(node)`. Its nodes must be able to hold children (`addChild` and `removeChild`, as every Pixi display object has); otherwise it does not compile (`each node must be a container`).
28
+ - **Breaking: `RegistryOptions.attach` receives the parent node**, `(node, parent: Node | undefined)`, `undefined` meaning the root, and is also called to move an attached node, so it must take the node out of its current parent. A one-parameter `attach` still compiles but puts every node on the root, so a game passing `hierarchy` sees children unattached. Update a custom registry:
29
+
30
+ ```diff
31
+ NodeRegistry.make<Mesh>({
32
+ - attach: (mesh) => scene.add(mesh),
33
+ - detach: (mesh) => scene.remove(mesh)
34
+ + attach: (mesh, parent) => (parent ?? scene).add(mesh),
35
+ + detach: (mesh) => mesh.removeFromParent()
36
+ })
37
+ ```
38
+
39
+ - **Breaking: a hand-written `NodeRegistry<Node>` object needs `reparent` and `parents`**, and `ensure` takes an optional `parent`. Build registries with `NodeRegistry.make` instead of implementing the interface.
40
+ - **Breaking: `PixiNodeRegistry.make`'s nodes must have `addChild` and `removeChild`.** Pixi display objects already do; a test double adds the two methods.
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [3a195b7]
45
+ - Updated dependencies [d01a735]
46
+ - Updated dependencies [45458dc]
47
+ - Updated dependencies [c75daff]
48
+ - Updated dependencies [b77b17d]
49
+ - Updated dependencies [c20f20b]
50
+ - Updated dependencies [01959dd]
51
+ - Updated dependencies [637fa1f]
52
+ - Updated dependencies [44e9b42]
53
+ - @typeonce/ritmo@0.15.0
54
+
55
+ ## 0.14.0
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [c3719a5]
60
+ - Updated dependencies [70d054e]
61
+ - Updated dependencies [adb4066]
62
+ - Updated dependencies [97e95fb]
63
+ - Updated dependencies [dbfbd9d]
64
+ - Updated dependencies [343660e]
65
+ - Updated dependencies [d24258e]
66
+ - Updated dependencies [cfe332a]
67
+ - Updated dependencies [8aa1e85]
68
+ - @typeonce/ritmo@0.14.0
69
+
3
70
  ## 0.13.0
4
71
 
5
72
  ### Patch Changes
package/README.md CHANGED
@@ -26,13 +26,42 @@ const Render = RenderSync.system(Game, {
26
26
  const runtime = Game.Runtime.make({
27
27
  services: Game.Runtime.services(
28
28
  Game.Runtime.service(Meshes, NodeRegistry.make<Mesh>({
29
- attach: (mesh) => scene.add(mesh),
30
- detach: (mesh) => scene.remove(mesh)
29
+ attach: (mesh, parent) => (parent ?? scene).add(mesh),
30
+ detach: (mesh) => mesh.removeFromParent()
31
31
  }))
32
32
  )
33
33
  }).value
34
34
  ```
35
35
 
36
+ `attach` receives the node to add and the node to add it under (`undefined` for the root). It is also called to move an attached node to another parent, so it must take the node out of the parent it is in, as Three.js's `add` and Pixi's `addChild` do. Declare both parameters: a one-parameter `attach` still compiles but puts every node on the root.
37
+
38
+ ## Hierarchies
39
+
40
+ A part that moves with its entity (a turret on a tank, a name over a head) is a child entity in a `Descriptor.Hierarchy`. Pass the hierarchy to `RenderSync.system` and each child's node is attached under its parent's node, so the renderer composes the transforms:
41
+
42
+ ```ts
43
+ const { relation: Attached } = Descriptor.Hierarchy("Game/Attached", "Game/Attachments")
44
+
45
+ const Render = RenderSync.system(Game, {
46
+ name: "Game/Render",
47
+ renderable: Renderable,
48
+ transform: Position, // a child's Position is relative to its parent
49
+ registry: Meshes,
50
+ hierarchy: Attached,
51
+ create: ({ renderable }) => new Mesh(geometry, materials[renderable.material]),
52
+ apply: (mesh, { transform }) => mesh.position.set(transform.x, 0, transform.y)
53
+ })
54
+ ```
55
+
56
+ - `apply` receives the child's own components: its transform is local to the parent's node. Ritmo does no world-transform math.
57
+ - A child whose parent has no node in the registry sits at the root, and moves under the parent's node when the parent gets one. Only the direct parent counts.
58
+ - A child's node moves when its parent changes (`commands.relate`) or is removed (`commands.unrelate`), in the same run.
59
+ - Despawning a parent despawns its children, so their nodes are destroyed with it. A parent that only loses its renderable hands its children's nodes back to the root.
60
+ - A plain `Descriptor.Relation` does not compile as `hierarchy`.
61
+ - Each run checks every renderable entity that has a parent, so the cost grows with the number of children. A game without `hierarchy` pays nothing.
62
+
63
+ The registry keeps the tree: `ensure(entity, create, parent)` creates a node under a parent's node, `reparent(entity, parent)` moves one, and `parents` maps each nested node's entity to its parent's. Removing a parent's node first moves the nodes under it back to the root, so an entity's node is destroyed only when that entity's is removed.
64
+
36
65
  For Pixi, [`@typeonce/ritmo-pixi`](https://github.com/typeonce-dev/ritmo/blob/main/packages/pixi/README.md) provides `PixiNodeRegistry.make(container)`, an implementation of the same registry contract. The host provides it with `Game.Runtime.service`; render systems keep depending on the generic service descriptor.
37
66
 
38
67
  Released together with [`@typeonce/ritmo`](https://github.com/typeonce-dev/ritmo/blob/main/packages/core/README.md), always with the same version.
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Hosts mirror ECS entities into renderer objects (sprites, containers,
5
5
  * meshes, DOM elements). The registry owns the bookkeeping every game
6
- * repeats: one node per entity, attaching new nodes to the scene, detaching
7
- * and destroying them when the entity loses its renderable or is despawned,
8
- * and teardown. It does not import or assume any renderer: what attaching and
9
- * detaching mean is passed to `make`.
6
+ * repeats: one node per entity, attaching new nodes to the scene (or under
7
+ * another entity's node), detaching and destroying them when the entity
8
+ * loses its renderable or is despawned, and teardown. It does not import or
9
+ * assume any renderer: what attaching and detaching mean is passed to `make`.
10
10
  *
11
11
  * Nodes are keyed by the entity's numeric value, so an `EntityId`, a query
12
12
  * match's `entity.id`, or a stored `Handle` all address the same node.
@@ -17,13 +17,14 @@
17
17
  * @example
18
18
  * ```ts
19
19
  * const meshes = NodeRegistry.make<Mesh>({
20
- * attach: (mesh) => scene.add(mesh),
20
+ * attach: (mesh, parent) => (parent ?? scene).add(mesh),
21
21
  * detach: (mesh) => {
22
- * scene.remove(mesh)
22
+ * mesh.removeFromParent()
23
23
  * mesh.geometry.dispose()
24
24
  * }
25
25
  * })
26
26
  * meshes.ensure(match.entity.id, () => new Mesh(geometry, material))
27
+ * meshes.ensure(turretId, () => new Mesh(turretGeometry, material), match.entity.id)
27
28
  * meshes.remove(despawnedId)
28
29
  * meshes.clear()
29
30
  * ```
@@ -38,6 +39,12 @@ export type EntityKey = number;
38
39
  * as `PixiNodeRegistry.make`). Provide it as a runtime service and hand that
39
40
  * service to `RenderSync.system`, which fills and empties it; host code reads
40
41
  * it with `get`.
42
+ *
43
+ * A node sits at the root of the scene or under another entity's node (its
44
+ * parent): `RenderSync.system`'s `hierarchy` option keeps that in step with
45
+ * a `Descriptor.Hierarchy`. Removing a parent's node first moves the nodes
46
+ * attached under it back to the root, so an entity's node is only ever
47
+ * destroyed by removing that entity.
41
48
  */
42
49
  export interface NodeRegistry<Node> {
43
50
  /** Number of live nodes. */
@@ -45,15 +52,31 @@ export interface NodeRegistry<Node> {
45
52
  /** The entity's node, or `undefined` when it has none. Use `ensure` to create one. */
46
53
  get(entity: EntityKey): Node | undefined;
47
54
  /**
48
- * Returns the entity's node, creating and attaching it first when missing.
55
+ * Returns the entity's node, creating and attaching it first when missing:
56
+ * under `parent`'s node when `parent` is given and has one, else at the
57
+ * root. An existing node is returned where it is; use `reparent` to move it.
58
+ */
59
+ ensure(entity: EntityKey, create: () => Node, parent?: EntityKey): Node;
60
+ /**
61
+ * Moves the entity's existing node under `parent`'s node, or to the root
62
+ * when `parent` is `undefined` or has no node. Does nothing when the node
63
+ * is already there. Returns `false`, moving nothing, when the entity has
64
+ * no node or `parent`'s node is the entity's own or attached under it (a
65
+ * loop); `true` otherwise.
66
+ */
67
+ reparent(entity: EntityKey, parent: EntityKey | undefined): boolean;
68
+ /**
69
+ * Each node attached under another entity's node: the entity's key to its
70
+ * parent's key. Nodes at the root are absent.
49
71
  */
50
- ensure(entity: EntityKey, create: () => Node): Node;
72
+ readonly parents: ReadonlyMap<EntityKey, EntityKey>;
51
73
  /**
52
- * Detaches and destroys the entity's node. Returns whether one existed.
74
+ * Detaches and destroys the entity's node, after moving the nodes attached
75
+ * under it to the root. Returns whether one existed.
53
76
  */
54
77
  remove(entity: EntityKey): boolean;
55
78
  /**
56
- * Detaches and destroys every node.
79
+ * Detaches and destroys every node, children before their parents.
57
80
  */
58
81
  clear(): void;
59
82
  /** The live nodes with their entity keys. */
@@ -61,16 +84,27 @@ export interface NodeRegistry<Node> {
61
84
  }
62
85
  /** What attaching and detaching a node mean for one renderer; see `make`. */
63
86
  export interface RegistryOptions<Node> {
64
- /** Adds a newly created node to the scene. */
65
- readonly attach: (node: Node) => void;
66
- /** Removes a node from the scene and releases it. */
87
+ /**
88
+ * Adds a node to the scene: under `parent` (another entity's node), or at
89
+ * the root when `parent` is `undefined`. Called for new nodes and to move
90
+ * an attached node to a new parent, so it must also take a node out of the
91
+ * parent it is in: Pixi's `addChild` and Three.js's `add` do.
92
+ *
93
+ * Declare both parameters. A one-parameter `attach` still compiles but
94
+ * ignores `parent`, so every node lands on the root.
95
+ */
96
+ readonly attach: (node: Node, parent: Node | undefined) => void;
97
+ /**
98
+ * Removes a node from the scene, from the root or the parent node it is
99
+ * attached under, and releases it.
100
+ */
67
101
  readonly detach: (node: Node) => void;
68
102
  }
69
103
  /**
70
104
  * Creates a registry with explicit attach/detach behavior: `attach` adds a
71
- * newly created node to the scene, `detach` removes and releases it. Renderer
72
- * packages build on this (for example `PixiNodeRegistry.make` in
73
- * `@typeonce/ritmo-pixi`).
105
+ * node under its parent node or at the root, `detach` removes and releases
106
+ * it. Renderer packages build on this (for example `PixiNodeRegistry.make`
107
+ * in `@typeonce/ritmo-pixi`).
74
108
  */
75
109
  export declare const make: <Node>(options: RegistryOptions<Node>) => NodeRegistry<Node>;
76
110
  //# sourceMappingURL=NodeRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NodeRegistry.d.ts","sourceRoot":"","sources":["../src/NodeRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI;IAChC,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sFAAsF;IACtF,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IACnD;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,GAA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;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;IACb,6CAA6C;IAC7C,OAAO,IAAI,gBAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;CACrD;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe,CAAC,IAAI;IACnC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAC/D;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,IAAI,WAAW,eAAe,CAAC,IAAI,CAAC,KAAG,YAAY,CAAC,IAAI,CA2G5E,CAAA"}
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Hosts mirror ECS entities into renderer objects (sprites, containers,
5
5
  * meshes, DOM elements). The registry owns the bookkeeping every game
6
- * repeats: one node per entity, attaching new nodes to the scene, detaching
7
- * and destroying them when the entity loses its renderable or is despawned,
8
- * and teardown. It does not import or assume any renderer: what attaching and
9
- * detaching mean is passed to `make`.
6
+ * repeats: one node per entity, attaching new nodes to the scene (or under
7
+ * another entity's node), detaching and destroying them when the entity
8
+ * loses its renderable or is despawned, and teardown. It does not import or
9
+ * assume any renderer: what attaching and detaching mean is passed to `make`.
10
10
  *
11
11
  * Nodes are keyed by the entity's numeric value, so an `EntityId`, a query
12
12
  * match's `entity.id`, or a stored `Handle` all address the same node.
@@ -17,56 +17,137 @@
17
17
  * @example
18
18
  * ```ts
19
19
  * const meshes = NodeRegistry.make<Mesh>({
20
- * attach: (mesh) => scene.add(mesh),
20
+ * attach: (mesh, parent) => (parent ?? scene).add(mesh),
21
21
  * detach: (mesh) => {
22
- * scene.remove(mesh)
22
+ * mesh.removeFromParent()
23
23
  * mesh.geometry.dispose()
24
24
  * }
25
25
  * })
26
26
  * meshes.ensure(match.entity.id, () => new Mesh(geometry, material))
27
+ * meshes.ensure(turretId, () => new Mesh(turretGeometry, material), match.entity.id)
27
28
  * meshes.remove(despawnedId)
28
29
  * meshes.clear()
29
30
  * ```
30
31
  */
31
32
  /**
32
33
  * Creates a registry with explicit attach/detach behavior: `attach` adds a
33
- * newly created node to the scene, `detach` removes and releases it. Renderer
34
- * packages build on this (for example `PixiNodeRegistry.make` in
35
- * `@typeonce/ritmo-pixi`).
34
+ * node under its parent node or at the root, `detach` removes and releases
35
+ * it. Renderer packages build on this (for example `PixiNodeRegistry.make`
36
+ * in `@typeonce/ritmo-pixi`).
36
37
  */
37
38
  export const make = (options) => {
38
39
  const nodes = new Map();
40
+ // The tree: each nested node's parent, and each parent's nested children.
41
+ const parents = new Map();
42
+ const children = new Map();
43
+ const link = (entity, parent) => {
44
+ parents.set(entity, parent);
45
+ const siblings = children.get(parent);
46
+ if (siblings === undefined)
47
+ children.set(parent, new Set([entity]));
48
+ else
49
+ siblings.add(entity);
50
+ };
51
+ const unlink = (entity) => {
52
+ const parent = parents.get(entity);
53
+ if (parent === undefined)
54
+ return;
55
+ parents.delete(entity);
56
+ const siblings = children.get(parent);
57
+ siblings?.delete(entity);
58
+ if (siblings?.size === 0)
59
+ children.delete(parent);
60
+ };
61
+ // Whether `entity`'s node is `ancestor`'s node or attached somewhere under it.
62
+ const nestedUnder = (entity, ancestor) => {
63
+ for (let current = entity; current !== undefined; current = parents.get(current)) {
64
+ if (current === ancestor)
65
+ return true;
66
+ }
67
+ return false;
68
+ };
69
+ // Moves every node nested under `entity`'s node to the root.
70
+ const release = (entity) => {
71
+ const nested = children.get(entity);
72
+ if (nested === undefined)
73
+ return;
74
+ children.delete(entity);
75
+ for (const child of nested) {
76
+ parents.delete(child);
77
+ const node = nodes.get(child);
78
+ if (node !== undefined)
79
+ options.attach(node, undefined);
80
+ }
81
+ };
82
+ // Detaches a node after the nodes nested under it, depth first.
83
+ const detachTree = (entity) => {
84
+ const nested = children.get(entity);
85
+ if (nested !== undefined)
86
+ for (const child of nested)
87
+ detachTree(child);
88
+ const node = nodes.get(entity);
89
+ if (node !== undefined)
90
+ options.detach(node);
91
+ };
39
92
  return {
40
93
  get size() {
41
94
  return nodes.size;
42
95
  },
96
+ parents,
43
97
  get(entity) {
44
98
  return nodes.get(entity);
45
99
  },
46
- ensure(entity, create) {
100
+ ensure(entity, create, parent) {
47
101
  const existing = nodes.get(entity);
48
102
  if (existing !== undefined) {
49
103
  return existing;
50
104
  }
51
105
  const node = create();
106
+ const parentNode = parent === undefined ? undefined : nodes.get(parent);
52
107
  nodes.set(entity, node);
53
- options.attach(node);
108
+ if (parent !== undefined && parentNode !== undefined)
109
+ link(entity, parent);
110
+ options.attach(node, parentNode);
54
111
  return node;
55
112
  },
113
+ reparent(entity, parent) {
114
+ const node = nodes.get(entity);
115
+ if (node === undefined) {
116
+ return false;
117
+ }
118
+ const parentNode = parent === undefined ? undefined : nodes.get(parent);
119
+ const next = parentNode === undefined ? undefined : parent;
120
+ if (parents.get(entity) === next) {
121
+ return true;
122
+ }
123
+ if (next !== undefined && nestedUnder(next, entity)) {
124
+ return false;
125
+ }
126
+ unlink(entity);
127
+ if (next !== undefined)
128
+ link(entity, next);
129
+ options.attach(node, parentNode);
130
+ return true;
131
+ },
56
132
  remove(entity) {
57
133
  const node = nodes.get(entity);
58
134
  if (node === undefined) {
59
135
  return false;
60
136
  }
137
+ release(entity);
138
+ unlink(entity);
61
139
  nodes.delete(entity);
62
140
  options.detach(node);
63
141
  return true;
64
142
  },
65
143
  clear() {
66
- for (const node of nodes.values()) {
67
- options.detach(node);
144
+ for (const entity of nodes.keys()) {
145
+ if (!parents.has(entity))
146
+ detachTree(entity);
68
147
  }
69
148
  nodes.clear();
149
+ parents.clear();
150
+ children.clear();
70
151
  },
71
152
  entries() {
72
153
  return nodes.entries();
@@ -1 +1 @@
1
- {"version":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AA"}
@@ -26,6 +26,12 @@
26
26
  * services declared in `services`. Those resources and services become
27
27
  * runtime requirements like the registry itself.
28
28
  *
29
+ * With `hierarchy` (a `Descriptor.Hierarchy` of the game), a child's node is
30
+ * attached under its parent's node instead of the root, and moved whenever
31
+ * its parent changes, so the renderer composes the transforms: `apply` sets
32
+ * the child's own (local) transform, relative to the parent's node, and no
33
+ * world-transform math happens in the system.
34
+ *
29
35
  * Its spec is erased, so it does not count as a writer for
30
36
  * `Game.System.thisTick(...)` order checks.
31
37
  *
@@ -52,12 +58,20 @@
52
58
  import type { Descriptor } from "@typeonce/ritmo/Descriptor";
53
59
  import type { Condition, ConditionNeedsFromConditions } from "@typeonce/ritmo/Machine";
54
60
  import type * as Entity from "@typeonce/ritmo/Entity";
61
+ import type { Relation } from "@typeonce/ritmo/Relation";
55
62
  import type { OptionalReadAccess, OptionalReadCell, ReadAccess, ReadCell, ReadonlyValue } from "@typeonce/ritmo/Query";
56
63
  import type { Schema } from "@typeonce/ritmo/Schema";
57
64
  import type { NodeRegistry } from "./NodeRegistry.ts";
58
65
  type RegistryService = Descriptor<"service", string, NodeRegistry<any>>;
59
66
  type ServiceDescriptor = Descriptor<"service", string, any>;
60
67
  type ResourceDescriptor = Descriptor<"resource", string, any>;
68
+ /**
69
+ * The `hierarchy` option: a `Descriptor.Hierarchy` relation of the game's
70
+ * schema, or a message naming the fix for anything else.
71
+ */
72
+ export type HierarchyOption<S extends Schema.Any, H> = [
73
+ H
74
+ ] extends [undefined] ? H : [H] extends [Schema.RelationDescriptor<S>] ? [H] extends [Relation.Hierarchy] ? H : "hierarchy must be a Descriptor.Hierarchy relation: a Descriptor.Relation does not make a parent's node hold its children" : "hierarchy must be a relation of the game's schema: add it to Schema.fragment({ relations })";
61
75
  /**
62
76
  * The node type held by a registry service.
63
77
  */
@@ -89,7 +103,7 @@ export interface NodeContext<S extends Schema.Any, Root, Renderable extends Sche
89
103
  readonly services: ServiceValues<Services>;
90
104
  }
91
105
  /** The options of `system`. */
92
- export interface Options<S extends Schema.Any, Root, Renderable extends Schema.ComponentDescriptor<S>, Transform extends Schema.ComponentDescriptor<S> | undefined, Registry extends RegistryService, Select extends Selection<S>, Services extends Readonly<Record<string, ServiceDescriptor>>, Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {}, When extends ReadonlyArray<Condition> = readonly []> {
106
+ export interface Options<S extends Schema.Any, Root, Renderable extends Schema.ComponentDescriptor<S>, Transform extends Schema.ComponentDescriptor<S> | undefined, Registry extends RegistryService, Select extends Selection<S>, Services extends Readonly<Record<string, ServiceDescriptor>>, Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {}, When extends ReadonlyArray<Condition> = readonly [], Hierarchy extends Relation.Any | undefined = undefined> {
93
107
  /** The system name. */
94
108
  readonly name: string;
95
109
  /** The component whose presence means "this entity has a node". */
@@ -122,6 +136,21 @@ export interface Options<S extends Schema.Any, Root, Renderable extends Schema.C
122
136
  * seen when the system runs again.
123
137
  */
124
138
  readonly when?: When;
139
+ /**
140
+ * A `Descriptor.Hierarchy` of the game whose tree the nodes follow: a
141
+ * child's node is attached under its parent's node (`attach(node, parent)`)
142
+ * when the parent has a node in this registry, and at the root otherwise,
143
+ * and is moved when the parent changes, is removed, or gains or loses its
144
+ * node. Only the direct parent counts: a child of a parent without a node
145
+ * sits at the root, not under a grandparent. `apply` then receives the
146
+ * child's own components, which the renderer composes with its parent's
147
+ * node: a child's transform is local to its parent. Despawning a parent
148
+ * despawns its children (hierarchies despawn together), so their nodes go
149
+ * with it; a parent that only loses its node hands its children's nodes
150
+ * back to the root. Each run checks every renderable entity that has a
151
+ * parent, so the cost grows with the number of children, not of changes.
152
+ */
153
+ readonly hierarchy?: HierarchyOption<S, Hierarchy>;
125
154
  /** Builds the node for a new renderable entity. */
126
155
  readonly create: (context: NodeContext<S, Root, Renderable, Transform, Select, Services, Resources>) => NodeOf<Registry>;
127
156
  /**
@@ -140,7 +169,7 @@ export type RenderSystem<S extends Schema.Any, Root, Needs extends ServiceDescri
140
169
  * applies, and destroys that component's nodes. To place nodes between fixed
141
170
  * steps every frame, add `interpolate` on the same registry after it.
142
171
  */
143
- export declare const system: <S extends Schema.Any, Root, const Renderable extends Schema.ComponentDescriptor<S>, const Registry extends RegistryService, const Select extends Selection<S> = {}, const Services extends Readonly<Record<string, ServiceDescriptor>> = {}, const Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {}, const When extends ReadonlyArray<Condition<Root>> = readonly [], const Transform extends Schema.ComponentDescriptor<S> | undefined = undefined>(Game: Schema.Game<S, Root>, options: Options<S, Root, Renderable, Transform, Registry, Select, Services, Resources, When>) => RenderSystem<S, Root, Registry | Services[keyof Services] | Resources[keyof Resources] | ConditionNeedsFromConditions<When>>;
172
+ export declare const system: <S extends Schema.Any, Root, const Renderable extends Schema.ComponentDescriptor<S>, const Registry extends RegistryService, const Select extends Selection<S> = {}, const Services extends Readonly<Record<string, ServiceDescriptor>> = {}, const Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {}, const When extends ReadonlyArray<Condition<Root>> = readonly [], const Transform extends Schema.ComponentDescriptor<S> | undefined = undefined, const Hierarchy extends Relation.Any | undefined = undefined>(Game: Schema.Game<S, Root>, options: Options<S, Root, Renderable, Transform, Registry, Select, Services, Resources, When, Hierarchy>) => RenderSystem<S, Root, Registry | Services[keyof Services] | Resources[keyof Resources] | ConditionNeedsFromConditions<When>>;
144
173
  /** A 2D position, the value `interpolate` blends when no `blend` is given. */
145
174
  export interface Planar {
146
175
  readonly x: number;
@@ -1 +1 @@
1
- {"version":3,"file":"RenderSync.d.ts","sourceRoot":"","sources":["../src/RenderSync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B,EAAE,MAAM,yBAA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,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAA;CAC7G;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,WAAW,GACtB,CAAC,SAAS,MAAM,CAAC,GAAG,EACpB,IAAI,EACJ,KAAK,CAAC,QAAQ,SAAS,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,EACpD,KAAK,CAAC,OAAO,SAAS,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,EACnD,KAAK,CAAC,QAAQ,SAAS,eAAe,EACtC,KAAK,CAAC,KAAK,SAAS,iBAAiB,EACrC,KAAK,CAAC,IAAI,SAAS,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EAAE,EAC/D,MAAM,GAAG,OAAO,QAEV,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,WACjB,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,KACrF,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAkC7E,CAAA"}
@@ -10,10 +10,12 @@ export const system = (Game, options) => {
10
10
  const Query = Game.Query;
11
11
  const anyOf = Game.Query.anyOf;
12
12
  const transform = options.transform;
13
+ const hierarchy = options.hierarchy;
13
14
  const selection = {
14
15
  ...options.select,
15
16
  __renderable: Game.Query.read(options.renderable),
16
- ...(transform === undefined ? {} : { __transform: Game.Query.read(transform) })
17
+ ...(transform === undefined ? {} : { __transform: Game.Query.read(transform) }),
18
+ ...(hierarchy === undefined ? {} : { __parent: Game.Query.optionalRelation(hierarchy) })
17
19
  };
18
20
  const services = { __registry: Game.System.service(options.registry) };
19
21
  for (const [key, descriptor] of Object.entries(options.services ?? {})) {
@@ -60,13 +62,18 @@ export const system = (Game, options) => {
60
62
  selection: { __renderable: Game.Query.read(options.renderable) },
61
63
  with: required.filter((descriptor) => descriptor !== options.renderable)
62
64
  });
65
+ // Every renderable entity with a parent: checked each run against where
66
+ // its node is attached. There is no per-reader filter for relation edges.
67
+ if (hierarchy !== undefined) {
68
+ queries["parented"] = Query({ selection: { __parent: Game.Query.readRelation(hierarchy) }, with: [options.renderable] });
69
+ }
63
70
  return System(options.name, {
64
71
  queries,
65
72
  removed: removedReads,
66
73
  resources,
67
74
  services,
68
75
  when: options.when ?? []
69
- }, ({ queries, removed, resources, services }) => {
76
+ }, ({ queries, removed, resources, services, lookup }) => {
70
77
  const registry = services.__registry;
71
78
  // Destroy first: an entity that lost a required component has no node,
72
79
  // and one that lost it and got it back since the last run gets a fresh one.
@@ -92,10 +99,58 @@ export const system = (Game, options) => {
92
99
  }
93
100
  for (const { entity, data } of queries["sync"].each()) {
94
101
  const context = contextOf(entity, data, services, resources);
95
- options.apply(registry.ensure(entity.id, () => options.create(context)), context);
102
+ // A child met before its parent's node exists starts at the root; the
103
+ // pass below moves it under the parent in this same run.
104
+ const parent = hierarchy === undefined || !data["__parent"].present ? undefined : data["__parent"].get();
105
+ options.apply(registry.ensure(entity.id, () => options.create(context), parent), context);
96
106
  }
107
+ if (hierarchy !== undefined)
108
+ reattach(registry, queries["parented"], lookup, hierarchy);
97
109
  });
98
110
  };
111
+ // Moves every node whose parent changed since it was attached: the entity
112
+ // gained, lost, or changed its parent, or the parent gained or lost its node.
113
+ // There is no per-reader filter for relation edges, so every parented entity
114
+ // is checked each run. Leaving parents go first, then the rest in depth
115
+ // order (parents before children), so a node never moves under a node that
116
+ // is still inside it and each move happens once.
117
+ const reattach = (registry, parented, lookup, hierarchy) => {
118
+ let moves;
119
+ // Nested nodes whose entity still has a parent; any other nested node lost it.
120
+ let stillParented = 0;
121
+ for (const { entity, data } of parented.each()) {
122
+ const attached = registry.parents.get(entity.id);
123
+ if (attached !== undefined)
124
+ stillParented++;
125
+ const parent = data.__parent.get();
126
+ if (attached === parent)
127
+ continue;
128
+ const wanted = registry.get(parent) === undefined ? undefined : parent;
129
+ if (attached === wanted || registry.get(entity.id) === undefined)
130
+ continue;
131
+ (moves ??= []).push({ entity: entity.id, parent: wanted, depth: 0 });
132
+ }
133
+ if (stillParented < registry.parents.size) {
134
+ const toRoot = [];
135
+ for (const [entity] of registry.parents) {
136
+ if (!lookup.parent(entity, hierarchy).ok)
137
+ toRoot.push(entity);
138
+ }
139
+ for (const entity of toRoot)
140
+ registry.reparent(entity, undefined);
141
+ }
142
+ if (moves === undefined)
143
+ return;
144
+ if (moves.length > 1) {
145
+ for (const move of moves) {
146
+ const ancestors = lookup.ancestors(move.entity, hierarchy);
147
+ move.depth = ancestors.ok ? ancestors.value.length : 0;
148
+ }
149
+ moves.sort((a, b) => a.depth - b.depth);
150
+ }
151
+ for (const move of moves)
152
+ registry.reparent(move.entity, move.parent);
153
+ };
99
154
  /**
100
155
  * Builds the system that draws moving entities between fixed steps.
101
156
  *
@@ -1 +1 @@
1
- {"version":3,"file":"RenderSync.js","sourceRoot":"","sources":["../src/RenderSync.ts"],"names":[],"mappings":"AA+KA;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAWpB,IAA0B,EAC1B,OAA6F,EACiC,EAAE;IAGhI,wEAAwE;IACxE,0EAA0E;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAyF,CAAA;IAC7G,MAAM,KAAK,GAAG,IAAI,CAAC,KAA4C,CAAA;IAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAiE,CAAA;IAC1F,MAAM,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B,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;QACxH,CAAC;IACH,CAAC,CAAiF,CAAA;AACpF,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeonce/ritmo-render",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Renderer-agnostic entity-to-node mirroring for Ritmo",
5
5
  "author": "Sandro Maglione",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "provenance": true
47
47
  },
48
48
  "dependencies": {
49
- "@typeonce/ritmo": "^0.13.0"
49
+ "@typeonce/ritmo": "^0.15.0"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=20"
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Hosts mirror ECS entities into renderer objects (sprites, containers,
5
5
  * meshes, DOM elements). The registry owns the bookkeeping every game
6
- * repeats: one node per entity, attaching new nodes to the scene, detaching
7
- * and destroying them when the entity loses its renderable or is despawned,
8
- * and teardown. It does not import or assume any renderer: what attaching and
9
- * detaching mean is passed to `make`.
6
+ * repeats: one node per entity, attaching new nodes to the scene (or under
7
+ * another entity's node), detaching and destroying them when the entity
8
+ * loses its renderable or is despawned, and teardown. It does not import or
9
+ * assume any renderer: what attaching and detaching mean is passed to `make`.
10
10
  *
11
11
  * Nodes are keyed by the entity's numeric value, so an `EntityId`, a query
12
12
  * match's `entity.id`, or a stored `Handle` all address the same node.
@@ -17,13 +17,14 @@
17
17
  * @example
18
18
  * ```ts
19
19
  * const meshes = NodeRegistry.make<Mesh>({
20
- * attach: (mesh) => scene.add(mesh),
20
+ * attach: (mesh, parent) => (parent ?? scene).add(mesh),
21
21
  * detach: (mesh) => {
22
- * scene.remove(mesh)
22
+ * mesh.removeFromParent()
23
23
  * mesh.geometry.dispose()
24
24
  * }
25
25
  * })
26
26
  * meshes.ensure(match.entity.id, () => new Mesh(geometry, material))
27
+ * meshes.ensure(turretId, () => new Mesh(turretGeometry, material), match.entity.id)
27
28
  * meshes.remove(despawnedId)
28
29
  * meshes.clear()
29
30
  * ```
@@ -40,6 +41,12 @@ export type EntityKey = number
40
41
  * as `PixiNodeRegistry.make`). Provide it as a runtime service and hand that
41
42
  * service to `RenderSync.system`, which fills and empties it; host code reads
42
43
  * it with `get`.
44
+ *
45
+ * A node sits at the root of the scene or under another entity's node (its
46
+ * parent): `RenderSync.system`'s `hierarchy` option keeps that in step with
47
+ * a `Descriptor.Hierarchy`. Removing a parent's node first moves the nodes
48
+ * attached under it back to the root, so an entity's node is only ever
49
+ * destroyed by removing that entity.
43
50
  */
44
51
  export interface NodeRegistry<Node> {
45
52
  /** Number of live nodes. */
@@ -47,15 +54,31 @@ export interface NodeRegistry<Node> {
47
54
  /** The entity's node, or `undefined` when it has none. Use `ensure` to create one. */
48
55
  get(entity: EntityKey): Node | undefined
49
56
  /**
50
- * Returns the entity's node, creating and attaching it first when missing.
57
+ * Returns the entity's node, creating and attaching it first when missing:
58
+ * under `parent`'s node when `parent` is given and has one, else at the
59
+ * root. An existing node is returned where it is; use `reparent` to move it.
60
+ */
61
+ ensure(entity: EntityKey, create: () => Node, parent?: EntityKey): Node
62
+ /**
63
+ * Moves the entity's existing node under `parent`'s node, or to the root
64
+ * when `parent` is `undefined` or has no node. Does nothing when the node
65
+ * is already there. Returns `false`, moving nothing, when the entity has
66
+ * no node or `parent`'s node is the entity's own or attached under it (a
67
+ * loop); `true` otherwise.
51
68
  */
52
- ensure(entity: EntityKey, create: () => Node): Node
69
+ reparent(entity: EntityKey, parent: EntityKey | undefined): boolean
53
70
  /**
54
- * Detaches and destroys the entity's node. Returns whether one existed.
71
+ * Each node attached under another entity's node: the entity's key to its
72
+ * parent's key. Nodes at the root are absent.
73
+ */
74
+ readonly parents: ReadonlyMap<EntityKey, EntityKey>
75
+ /**
76
+ * Detaches and destroys the entity's node, after moving the nodes attached
77
+ * under it to the root. Returns whether one existed.
55
78
  */
56
79
  remove(entity: EntityKey): boolean
57
80
  /**
58
- * Detaches and destroys every node.
81
+ * Detaches and destroys every node, children before their parents.
59
82
  */
60
83
  clear(): void
61
84
  /** The live nodes with their entity keys. */
@@ -64,51 +87,131 @@ export interface NodeRegistry<Node> {
64
87
 
65
88
  /** What attaching and detaching a node mean for one renderer; see `make`. */
66
89
  export interface RegistryOptions<Node> {
67
- /** Adds a newly created node to the scene. */
68
- readonly attach: (node: Node) => void
69
- /** Removes a node from the scene and releases it. */
90
+ /**
91
+ * Adds a node to the scene: under `parent` (another entity's node), or at
92
+ * the root when `parent` is `undefined`. Called for new nodes and to move
93
+ * an attached node to a new parent, so it must also take a node out of the
94
+ * parent it is in: Pixi's `addChild` and Three.js's `add` do.
95
+ *
96
+ * Declare both parameters. A one-parameter `attach` still compiles but
97
+ * ignores `parent`, so every node lands on the root.
98
+ */
99
+ readonly attach: (node: Node, parent: Node | undefined) => void
100
+ /**
101
+ * Removes a node from the scene, from the root or the parent node it is
102
+ * attached under, and releases it.
103
+ */
70
104
  readonly detach: (node: Node) => void
71
105
  }
72
106
 
73
107
  /**
74
108
  * Creates a registry with explicit attach/detach behavior: `attach` adds a
75
- * newly created node to the scene, `detach` removes and releases it. Renderer
76
- * packages build on this (for example `PixiNodeRegistry.make` in
77
- * `@typeonce/ritmo-pixi`).
109
+ * node under its parent node or at the root, `detach` removes and releases
110
+ * it. Renderer packages build on this (for example `PixiNodeRegistry.make`
111
+ * in `@typeonce/ritmo-pixi`).
78
112
  */
79
113
  export const make = <Node>(options: RegistryOptions<Node>): NodeRegistry<Node> => {
80
114
  const nodes = new Map<number, Node>()
115
+ // The tree: each nested node's parent, and each parent's nested children.
116
+ const parents = new Map<number, number>()
117
+ const children = new Map<number, Set<number>>()
118
+
119
+ const link = (entity: number, parent: number): void => {
120
+ parents.set(entity, parent)
121
+ const siblings = children.get(parent)
122
+ if (siblings === undefined) children.set(parent, new Set([entity]))
123
+ else siblings.add(entity)
124
+ }
125
+ const unlink = (entity: number): void => {
126
+ const parent = parents.get(entity)
127
+ if (parent === undefined) return
128
+ parents.delete(entity)
129
+ const siblings = children.get(parent)
130
+ siblings?.delete(entity)
131
+ if (siblings?.size === 0) children.delete(parent)
132
+ }
133
+ // Whether `entity`'s node is `ancestor`'s node or attached somewhere under it.
134
+ const nestedUnder = (entity: number, ancestor: number): boolean => {
135
+ for (let current: number | undefined = entity; current !== undefined; current = parents.get(current)) {
136
+ if (current === ancestor) return true
137
+ }
138
+ return false
139
+ }
140
+ // Moves every node nested under `entity`'s node to the root.
141
+ const release = (entity: number): void => {
142
+ const nested = children.get(entity)
143
+ if (nested === undefined) return
144
+ children.delete(entity)
145
+ for (const child of nested) {
146
+ parents.delete(child)
147
+ const node = nodes.get(child)
148
+ if (node !== undefined) options.attach(node, undefined)
149
+ }
150
+ }
151
+ // Detaches a node after the nodes nested under it, depth first.
152
+ const detachTree = (entity: number): void => {
153
+ const nested = children.get(entity)
154
+ if (nested !== undefined) for (const child of nested) detachTree(child)
155
+ const node = nodes.get(entity)
156
+ if (node !== undefined) options.detach(node)
157
+ }
158
+
81
159
  return {
82
160
  get size() {
83
161
  return nodes.size
84
162
  },
163
+ parents,
85
164
  get(entity) {
86
165
  return nodes.get(entity)
87
166
  },
88
- ensure(entity, create) {
167
+ ensure(entity, create, parent) {
89
168
  const existing = nodes.get(entity)
90
169
  if (existing !== undefined) {
91
170
  return existing
92
171
  }
93
172
  const node = create()
173
+ const parentNode = parent === undefined ? undefined : nodes.get(parent)
94
174
  nodes.set(entity, node)
95
- options.attach(node)
175
+ if (parent !== undefined && parentNode !== undefined) link(entity, parent)
176
+ options.attach(node, parentNode)
96
177
  return node
97
178
  },
179
+ reparent(entity, parent) {
180
+ const node = nodes.get(entity)
181
+ if (node === undefined) {
182
+ return false
183
+ }
184
+ const parentNode = parent === undefined ? undefined : nodes.get(parent)
185
+ const next = parentNode === undefined ? undefined : parent
186
+ if (parents.get(entity) === next) {
187
+ return true
188
+ }
189
+ if (next !== undefined && nestedUnder(next, entity)) {
190
+ return false
191
+ }
192
+ unlink(entity)
193
+ if (next !== undefined) link(entity, next)
194
+ options.attach(node, parentNode)
195
+ return true
196
+ },
98
197
  remove(entity) {
99
198
  const node = nodes.get(entity)
100
199
  if (node === undefined) {
101
200
  return false
102
201
  }
202
+ release(entity)
203
+ unlink(entity)
103
204
  nodes.delete(entity)
104
205
  options.detach(node)
105
206
  return true
106
207
  },
107
208
  clear() {
108
- for (const node of nodes.values()) {
109
- options.detach(node)
209
+ for (const entity of nodes.keys()) {
210
+ if (!parents.has(entity)) detachTree(entity)
110
211
  }
111
212
  nodes.clear()
213
+ parents.clear()
214
+ children.clear()
112
215
  },
113
216
  entries() {
114
217
  return nodes.entries()
package/src/RenderSync.ts CHANGED
@@ -26,6 +26,12 @@
26
26
  * services declared in `services`. Those resources and services become
27
27
  * runtime requirements like the registry itself.
28
28
  *
29
+ * With `hierarchy` (a `Descriptor.Hierarchy` of the game), a child's node is
30
+ * attached under its parent's node instead of the root, and moved whenever
31
+ * its parent changes, so the renderer composes the transforms: `apply` sets
32
+ * the child's own (local) transform, relative to the parent's node, and no
33
+ * world-transform math happens in the system.
34
+ *
29
35
  * Its spec is erased, so it does not count as a writer for
30
36
  * `Game.System.thisTick(...)` order checks.
31
37
  *
@@ -52,6 +58,7 @@
52
58
  import type { Descriptor } from "@typeonce/ritmo/Descriptor"
53
59
  import type { Condition, ConditionNeedsFromConditions } from "@typeonce/ritmo/Machine"
54
60
  import type * as Entity from "@typeonce/ritmo/Entity"
61
+ import type { Relation } from "@typeonce/ritmo/Relation"
55
62
  import type { OptionalReadAccess, OptionalReadCell, ReadAccess, ReadCell, ReadonlyValue } from "@typeonce/ritmo/Query"
56
63
  import type { Schema } from "@typeonce/ritmo/Schema"
57
64
  import type { NodeRegistry } from "./NodeRegistry.ts"
@@ -60,6 +67,18 @@ type RegistryService = Descriptor<"service", string, NodeRegistry<any>>
60
67
  type ServiceDescriptor = Descriptor<"service", string, any>
61
68
  type ResourceDescriptor = Descriptor<"resource", string, any>
62
69
 
70
+ /**
71
+ * The `hierarchy` option: a `Descriptor.Hierarchy` relation of the game's
72
+ * schema, or a message naming the fix for anything else.
73
+ */
74
+ export type HierarchyOption<S extends Schema.Any, H> =
75
+ [H] extends [undefined] ? H
76
+ : [H] extends [Schema.RelationDescriptor<S>]
77
+ ? [H] extends [Relation.Hierarchy]
78
+ ? H
79
+ : "hierarchy must be a Descriptor.Hierarchy relation: a Descriptor.Relation does not make a parent's node hold its children"
80
+ : "hierarchy must be a relation of the game's schema: add it to Schema.fragment({ relations })"
81
+
63
82
  /**
64
83
  * The node type held by a registry service.
65
84
  */
@@ -123,7 +142,8 @@ export interface Options<
123
142
  Select extends Selection<S>,
124
143
  Services extends Readonly<Record<string, ServiceDescriptor>>,
125
144
  Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {},
126
- When extends ReadonlyArray<Condition> = readonly []
145
+ When extends ReadonlyArray<Condition> = readonly [],
146
+ Hierarchy extends Relation.Any | undefined = undefined
127
147
  > {
128
148
  /** The system name. */
129
149
  readonly name: string
@@ -157,6 +177,21 @@ export interface Options<
157
177
  * seen when the system runs again.
158
178
  */
159
179
  readonly when?: When
180
+ /**
181
+ * A `Descriptor.Hierarchy` of the game whose tree the nodes follow: a
182
+ * child's node is attached under its parent's node (`attach(node, parent)`)
183
+ * when the parent has a node in this registry, and at the root otherwise,
184
+ * and is moved when the parent changes, is removed, or gains or loses its
185
+ * node. Only the direct parent counts: a child of a parent without a node
186
+ * sits at the root, not under a grandparent. `apply` then receives the
187
+ * child's own components, which the renderer composes with its parent's
188
+ * node: a child's transform is local to its parent. Despawning a parent
189
+ * despawns its children (hierarchies despawn together), so their nodes go
190
+ * with it; a parent that only loses its node hands its children's nodes
191
+ * back to the root. Each run checks every renderable entity that has a
192
+ * parent, so the cost grows with the number of children, not of changes.
193
+ */
194
+ readonly hierarchy?: HierarchyOption<S, Hierarchy>
160
195
  /** Builds the node for a new renderable entity. */
161
196
  readonly create: (context: NodeContext<S, Root, Renderable, Transform, Select, Services, Resources>) => NodeOf<Registry>
162
197
  /**
@@ -187,10 +222,11 @@ export const system = <
187
222
  const Services extends Readonly<Record<string, ServiceDescriptor>> = {},
188
223
  const Resources extends Readonly<Record<string, Schema.ResourceDescriptor<S>>> = {},
189
224
  const When extends ReadonlyArray<Condition<Root>> = readonly [],
190
- const Transform extends Schema.ComponentDescriptor<S> | undefined = undefined
225
+ const Transform extends Schema.ComponentDescriptor<S> | undefined = undefined,
226
+ const Hierarchy extends Relation.Any | undefined = undefined
191
227
  >(
192
228
  Game: Schema.Game<S, Root>,
193
- options: Options<S, Root, Renderable, Transform, Registry, Select, Services, Resources, When>
229
+ options: Options<S, Root, Renderable, Transform, Registry, Select, Services, Resources, When, Hierarchy>
194
230
  ): RenderSystem<S, Root, Registry | Services[keyof Services] | Resources[keyof Resources] | ConditionNeedsFromConditions<When>> => {
195
231
  type Node = NodeOf<Registry>
196
232
  type Context = NodeContext<S, Root, Renderable, Transform, Select, Services, Resources>
@@ -200,10 +236,12 @@ export const system = <
200
236
  const Query = Game.Query as unknown as (spec: object) => object
201
237
  const anyOf = Game.Query.anyOf as unknown as (...filters: ReadonlyArray<object>) => object
202
238
  const transform = options.transform as Schema.ComponentDescriptor<S> | undefined
239
+ const hierarchy = options.hierarchy as Schema.RelationDescriptor<S> | undefined
203
240
  const selection = {
204
241
  ...options.select,
205
242
  __renderable: Game.Query.read(options.renderable),
206
- ...(transform === undefined ? {} : { __transform: Game.Query.read(transform) })
243
+ ...(transform === undefined ? {} : { __transform: Game.Query.read(transform) }),
244
+ ...(hierarchy === undefined ? {} : { __parent: Game.Query.optionalRelation(hierarchy) })
207
245
  }
208
246
  const services: Record<string, unknown> = { __registry: Game.System.service(options.registry) }
209
247
  for (const [key, descriptor] of Object.entries(options.services ?? {})) {
@@ -258,6 +296,11 @@ export const system = <
258
296
  selection: { __renderable: Game.Query.read(options.renderable) },
259
297
  with: required.filter((descriptor) => descriptor !== options.renderable)
260
298
  })
299
+ // Every renderable entity with a parent: checked each run against where
300
+ // its node is attached. There is no per-reader filter for relation edges.
301
+ if (hierarchy !== undefined) {
302
+ queries["parented"] = Query({ selection: { __parent: Game.Query.readRelation(hierarchy) }, with: [options.renderable] })
303
+ }
261
304
 
262
305
  return System(options.name, {
263
306
  queries,
@@ -265,7 +308,7 @@ export const system = <
265
308
  resources,
266
309
  services,
267
310
  when: options.when ?? []
268
- }, ({ queries, removed, resources, services }) => {
311
+ }, ({ queries, removed, resources, services, lookup }) => {
269
312
  const registry = services.__registry as NodeRegistry<Node>
270
313
  // Destroy first: an entity that lost a required component has no node,
271
314
  // and one that lost it and got it back since the last run gets a fresh one.
@@ -288,11 +331,68 @@ export const system = <
288
331
 
289
332
  for (const { entity, data } of queries["sync"].each()) {
290
333
  const context = contextOf(entity, data, services, resources)
291
- options.apply(registry.ensure(entity.id, () => options.create(context)), context)
334
+ // A child met before its parent's node exists starts at the root; the
335
+ // pass below moves it under the parent in this same run.
336
+ const parent: number | undefined = hierarchy === undefined || !data["__parent"].present ? undefined : data["__parent"].get()
337
+ options.apply(registry.ensure(entity.id, () => options.create(context), parent), context)
292
338
  }
339
+
340
+ if (hierarchy !== undefined) reattach(registry as NodeRegistry<unknown>, queries["parented"], lookup, hierarchy)
293
341
  }) as RenderSystem<S, Root, Registry | Services[keyof Services] | Resources[keyof Resources] | ConditionNeedsFromConditions<When>>
294
342
  }
295
343
 
344
+ // The lookups `reattach` uses, with the generic ids erased.
345
+ interface HierarchyLookup {
346
+ parent(entity: number, relation: unknown): { readonly ok: boolean }
347
+ ancestors(entity: number, relation: unknown): { readonly ok: true; readonly value: ReadonlyArray<number> } | { readonly ok: false }
348
+ }
349
+
350
+ interface ParentedQuery {
351
+ each(): Iterable<{ readonly entity: { readonly id: number }; readonly data: { readonly __parent: { get(): number } } }>
352
+ }
353
+
354
+ // Moves every node whose parent changed since it was attached: the entity
355
+ // gained, lost, or changed its parent, or the parent gained or lost its node.
356
+ // There is no per-reader filter for relation edges, so every parented entity
357
+ // is checked each run. Leaving parents go first, then the rest in depth
358
+ // order (parents before children), so a node never moves under a node that
359
+ // is still inside it and each move happens once.
360
+ const reattach = (
361
+ registry: NodeRegistry<unknown>,
362
+ parented: ParentedQuery,
363
+ lookup: HierarchyLookup,
364
+ hierarchy: unknown
365
+ ): void => {
366
+ let moves: Array<{ readonly entity: number; readonly parent: number | undefined; depth: number }> | undefined
367
+ // Nested nodes whose entity still has a parent; any other nested node lost it.
368
+ let stillParented = 0
369
+ for (const { entity, data } of parented.each()) {
370
+ const attached = registry.parents.get(entity.id)
371
+ if (attached !== undefined) stillParented++
372
+ const parent = data.__parent.get()
373
+ if (attached === parent) continue
374
+ const wanted = registry.get(parent) === undefined ? undefined : parent
375
+ if (attached === wanted || registry.get(entity.id) === undefined) continue
376
+ ;(moves ??= []).push({ entity: entity.id, parent: wanted, depth: 0 })
377
+ }
378
+ if (stillParented < registry.parents.size) {
379
+ const toRoot: Array<number> = []
380
+ for (const [entity] of registry.parents) {
381
+ if (!lookup.parent(entity, hierarchy).ok) toRoot.push(entity)
382
+ }
383
+ for (const entity of toRoot) registry.reparent(entity, undefined)
384
+ }
385
+ if (moves === undefined) return
386
+ if (moves.length > 1) {
387
+ for (const move of moves) {
388
+ const ancestors = lookup.ancestors(move.entity, hierarchy)
389
+ move.depth = ancestors.ok ? ancestors.value.length : 0
390
+ }
391
+ moves.sort((a, b) => a.depth - b.depth)
392
+ }
393
+ for (const move of moves) registry.reparent(move.entity, move.parent)
394
+ }
395
+
296
396
  /** A 2D position, the value `interpolate` blends when no `blend` is given. */
297
397
  export interface Planar {
298
398
  readonly x: number