castle-web-cli 0.4.231 → 0.4.232

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.
Files changed (55) hide show
  1. package/dist/serverBundle.js +5 -3
  2. package/kits/hub-game/CLAUDE.md +26 -4
  3. package/kits/hub-game/code/client/avatar.js +39 -0
  4. package/kits/hub-game/code/client/chat.js +12 -0
  5. package/kits/hub-game/code/client/chrome.js +194 -4
  6. package/kits/hub-game/code/client/grab.js +31 -7
  7. package/kits/hub-game/code/client/hats.js +26 -0
  8. package/kits/hub-game/code/client/hookLayer.js +30 -3
  9. package/kits/hub-game/code/client/hudClear.js +126 -0
  10. package/kits/hub-game/code/client/state.js +22 -0
  11. package/kits/hub-game/code/client/tiers.js +31 -6
  12. package/kits/hub-game/code/client/together.js +66 -1
  13. package/kits/hub-game/code/client/wear.js +96 -14
  14. package/kits/hub-game/code/server/actors.js +5 -0
  15. package/kits/hub-game/code/server/grab.js +296 -11
  16. package/kits/hub-game/code/server/hub.js +63 -2
  17. package/kits/hub-game/code/server/manifest.js +48 -3
  18. package/kits/hub-game/code/server/party.js +11 -0
  19. package/kits/hub-game/code/server/say.js +8 -2
  20. package/kits/hub-game/code/server/wear.js +116 -11
  21. package/kits/hub-game/code/systems/hub.js +253 -5
  22. package/kits/hub-game/docs/contract.md +204 -8
  23. package/kits/hub-game/package.json +1 -1
  24. package/kits/hub-game/scripts/test-chat.mjs +32 -0
  25. package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
  26. package/kits/hub-game/scripts/test-grab.mjs +857 -3
  27. package/kits/hub-game/scripts/test-hats.mjs +229 -0
  28. package/kits/hub-game/scripts/test-hub-trip.mjs +513 -0
  29. package/kits/hub-game/scripts/test-hud-clear.mjs +676 -0
  30. package/kits/hub-game/scripts/test-manifest.mjs +75 -0
  31. package/kits/hub-game/scripts/test-party.mjs +22 -1
  32. package/kits/hub-game/scripts/test-say.mjs +59 -2
  33. package/kits/hub-game/scripts/test-tiers.mjs +190 -2
  34. package/kits/hub-game/scripts/test-try-on.mjs +940 -0
  35. package/kits/physics-2d/castle.json +1 -1
  36. package/kits/physics-2d/engine/scene.js +35 -0
  37. package/kits/physics-2d/scripts/test-skip-unchanged.mjs +44 -0
  38. package/kits/physics-3d/CLAUDE.md +252 -0
  39. package/kits/physics-3d/behaviors/Player.jsx +363 -2
  40. package/kits/physics-3d/castle.json +2 -2
  41. package/kits/physics-3d/docs/pxmodel-format.md +4 -0
  42. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +32 -0
  43. package/kits/physics-3d/engine3d/optimize.js +49 -0
  44. package/kits/physics-3d/engine3d/orbitinput.js +277 -0
  45. package/kits/physics-3d/engine3d/world3d.js +81 -25
  46. package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
  47. package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
  48. package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
  49. package/kits/physics-3d/scripts/test-camera-orbit.mjs +2105 -0
  50. package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
  51. package/kits/physics-3d/scripts/test-static-actors.mjs +6 -1
  52. package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
  53. package/kits/physics-3d/scripts/test-steady-hover.mjs +633 -0
  54. package/kits/physics-3d/systems/physics3d.js +91 -6
  55. package/package.json +1 -1
@@ -0,0 +1,787 @@
1
+ // `"engine": { "dropEmptyParts": true }` (engine3d/world3d.js, optimize.js
2
+ // `dropEmptyGroups`; CLAUDE.md has the terms), on the real `syncActors` and
3
+ // real models: the kit's own, and the hub town's and hub-game's when this
4
+ // checkout has them.
5
+ //
6
+ // - With the key absent a placed model is the tree `buildModelNode` and
7
+ // `copyModel` make, object for object, under the shared-build key and the
8
+ // node signature it always had.
9
+ // - With it, every drawn object (mesh, outline) has the geometry, material
10
+ // and world matrix it has without it, frame after frame, with walkers
11
+ // walking and parts in motion, with and without `skipUnchangedActors`.
12
+ // - What stays (a `keep` part, a `slot-...`, a part that moves, and what is
13
+ // above them) and what `modelParts` then holds; no rig for a model that
14
+ // draws nothing.
15
+ // - What reads a placed model's parts still reads the same: the walk, motion
16
+ // and glow, multiplayer-3d's head lookup, hub-game's rig lookup and its
17
+ // low-picture levers.
18
+ // - A node or shared build made for a scene that asked is never one for a
19
+ // scene that did not: two scenes in one world one after the other, a door
20
+ // trip with the first parked, the key changed under a playing scene, a
21
+ // scene played from inside another's pass, a model file edited.
22
+ //
23
+ // `DROP_DECKS=<deck dir>,<deck dir>` compares whole generated scenes as well.
24
+ // test-static-actors.mjs runs it (`npm run check`).
25
+ import assert from 'node:assert/strict';
26
+ import fs from 'node:fs';
27
+ import path from 'node:path';
28
+ import { fileURLToPath } from 'node:url';
29
+ import * as THREE from 'three';
30
+ // Its import registers the resolver the kit's modules need under node.
31
+ import { makeWorld } from './test-static-passes.mjs';
32
+
33
+ const { syncActors, disposeWorld } = await import('../engine3d/world3d.js');
34
+ const { copyModel } = await import('../engine3d/optimize.js');
35
+ const { buildModelNode, parseModelCached, animateModelParts } = await import('../engine3d/pxmodel.js');
36
+
37
+ const DT = 1 / 60;
38
+ const KIT = fileURLToPath(new URL('..', import.meta.url));
39
+ const REPO = path.join(KIT, '..', '..');
40
+ let checks = 0;
41
+ const ok = (value, message) => {
42
+ checks += 1;
43
+ assert.ok(value, message);
44
+ };
45
+ const equal = (a, b, message) => {
46
+ checks += 1;
47
+ assert.deepEqual(a, b, message);
48
+ };
49
+
50
+ //
51
+ // Models
52
+ //
53
+
54
+ function readModels(dir, prefix, files) {
55
+ if (!fs.existsSync(dir)) return 0;
56
+ let count = 0;
57
+ for (const name of fs.readdirSync(dir).sort()) {
58
+ const full = path.join(dir, name);
59
+ if (fs.statSync(full).isDirectory()) count += readModels(full, `${prefix}/${name}`, files);
60
+ else if (name.endsWith('.pxmodel')) {
61
+ files[`${prefix}/${name}`] = fs.readFileSync(full, 'utf8');
62
+ count += 1;
63
+ }
64
+ }
65
+ return count;
66
+ }
67
+
68
+ const empty = (id, more = {}) => ({ id, kind: 'model', ...more });
69
+ const box = (id, y, more = {}) => ({ id, kind: 'box', size: [0.3, 0.3, 0.3], position: [0, y, 0], color: '#8899aa', ...more });
70
+ // A walker with empty parts of every standing: reached for by a deck (`keep`,
71
+ // a slot), under one that is, moved, and plain.
72
+ const LOCATORS = 'models/test/locators.pxmodel';
73
+ const locators = {
74
+ format: 'pxmodel',
75
+ name: 'Locators',
76
+ parts: [
77
+ box('torso', 0.8),
78
+ box('legL', 0.4, { position: [0.1, 0.4, 0] }),
79
+ box('legR', 0.4, { position: [-0.1, 0.4, 0] }),
80
+ box('armL', 0.8, { position: [0.3, 0.8, 0], parent: 'torso' }),
81
+ box('head', 1.2, { parent: 'torso' }),
82
+ empty('arm', { parent: 'torso', position: [0.4, 0.2, 0] }),
83
+ empty('muzzle', { parent: 'arm', position: [0, 0, 0.5], keep: true }),
84
+ empty('slot-hand', { parent: 'armL', position: [0, -0.3, 0.1] }),
85
+ empty('gone', { parent: 'torso', position: [0, 0.5, 0] }),
86
+ empty('holder', { position: [1, 0, 0] }),
87
+ empty('deep', { parent: 'holder', position: [0, 1, 0] }),
88
+ ],
89
+ };
90
+ // Parts in motion: one that is drawn and glows, one that draws nothing, one
91
+ // that is only the pivot of another.
92
+ const MOVER = 'models/test/mover.pxmodel';
93
+ const mover = {
94
+ format: 'pxmodel',
95
+ name: 'Mover',
96
+ parts: [
97
+ box('base', 0.2),
98
+ box('flame', 0.6, { emissive: '#ff8800', motion: [{ spin: [0, 90, 0] }, { flicker: 0.3 }] }),
99
+ empty('ghost', { position: [0, 1, 0], motion: { rotate: [0, 20, 0] } }),
100
+ empty('pivot', { position: [0, 0.9, 0], motion: { spin: [0, 0, 40] } }),
101
+ box('sail', 0.3, { parent: 'pivot', repeat: { count: 3, rotate: [0, 0, 120] } }),
102
+ empty('still', { position: [0, 2, 0] }),
103
+ ],
104
+ };
105
+ const NOTHING = 'models/test/nothing.pxmodel';
106
+
107
+ const files = {
108
+ [LOCATORS]: JSON.stringify(locators),
109
+ [MOVER]: JSON.stringify(mover),
110
+ [NOTHING]: JSON.stringify({ format: 'pxmodel', name: 'Nothing', look: false, parts: [] }),
111
+ };
112
+ const kitModels = readModels(path.join(KIT, 'models'), 'imports/castle.physics-3d/models', files);
113
+ const townModels = readModels(path.join(REPO, 'experiments/hub-town/models'), 'models', files);
114
+ const hubModels = readModels(path.join(REPO, 'kits/hub-game/models'), 'imports/castle.hub-game/models', files);
115
+ const PLAYER = 'imports/castle.physics-3d/models/player.pxmodel';
116
+ const everyModel = Object.keys(files).filter((file) => parseModelCached(files[file]));
117
+
118
+ //
119
+ // Worlds
120
+ //
121
+
122
+ const transform = (x, z) => ({ x, y: 0, z, rotationX: 0, rotationY: 0, rotationZ: 0 });
123
+ const actorOf = (id, file, x = 0, z = 0, more = {}) => ({
124
+ id,
125
+ runtime: {},
126
+ components: { Transform: transform(x, z), Shape: { kind: 'box', width: 1, height: 1, depth: 1, color: '#8899aa' }, Model: { file, yOffset: -0.2, scale: 1.5 }, ...more },
127
+ });
128
+
129
+ // What a SceneRuntime is to `syncActors`. `drop` is what its scene file said
130
+ // under `engine.dropEmptyParts`; left out, the runtime has no such field.
131
+ function makeRuntime(actors, { drop, skip = false, scenePath = 'scenes/main.scene', table = files } = {}) {
132
+ const runtime = { skipsUnchangedActors: skip, scenePath, data: { ground: { color: '#445566' } }, files: table, actors, getActors: () => [...actors] };
133
+ if (drop !== undefined) runtime.dropsEmptyParts = drop;
134
+ return runtime;
135
+ }
136
+
137
+ // One of every model in a grid, and walkers.
138
+ function everyActor() {
139
+ const actors = everyModel.map((file, i) => actorOf(`m${i}`, file, (i % 12) * 4, Math.floor(i / 12) * 4));
140
+ for (let i = 0; i < 3; i++) actors.push(actorOf(`walker${i}`, i === 2 ? LOCATORS : PLAYER, -4, i * 3, { Walks: {} }));
141
+ return actors;
142
+ }
143
+
144
+ function frame(world, runtime, i = 0, dt = DT) {
145
+ for (const actor of runtime.actors) {
146
+ if (!actor.components.Walks) continue;
147
+ actor.components.Transform.x += 0.04;
148
+ actor.components.Transform.rotationY = (i * 7) % 360;
149
+ }
150
+ syncActors(world, runtime, {}, dt);
151
+ world.scene.updateMatrixWorld();
152
+ }
153
+
154
+ const countUnder = (object) => {
155
+ let n = 0;
156
+ object.traverse(() => n++);
157
+ return n;
158
+ };
159
+
160
+ // A geometry's or a material's content, as a short string.
161
+ const hashes = new WeakMap();
162
+ function hashOf(attribute) {
163
+ const known = hashes.get(attribute);
164
+ if (known && known.version === attribute.version) return known.hash;
165
+ let hash = 2166136261;
166
+ const array = attribute.array;
167
+ for (let i = 0; i < array.length; i++) hash = Math.imul(hash ^ Math.round(array[i] * 1e5), 16777619);
168
+ hashes.set(attribute, { version: attribute.version, hash });
169
+ return hash;
170
+ }
171
+ function geometryOf(geometry) {
172
+ const names = Object.keys(geometry.attributes).sort();
173
+ const parts = names.map((name) => `${name}:${hashOf(geometry.attributes[name])}`);
174
+ if (geometry.getIndex()) parts.push(`index:${hashOf(geometry.getIndex())}`);
175
+ if (!geometry.boundingSphere) geometry.computeBoundingSphere();
176
+ parts.push(`r:${geometry.boundingSphere.radius}`);
177
+ return parts.join(',');
178
+ }
179
+ const colorOf = (color) => (color?.isColor ? color.getHexString() : '');
180
+ function materialOf(material) {
181
+ const m = material;
182
+ const uniforms = Object.entries(m.uniforms ?? {}).map(([name, u]) => `${name}=${u.value?.isColor ? u.value.getHexString() : u.value}`);
183
+ return [m.type, colorOf(m.color), colorOf(m.emissive), m.emissiveIntensity, m.roughness, m.metalness, m.side, m.vertexColors, m.transparent, m.opacity, m.flatShading, Boolean(m.map), ...uniforms].join('/');
184
+ }
185
+
186
+ // Everything a frame draws: each actor's meshes and outlines in the order
187
+ // three.js walks them, with what each is drawn from and where.
188
+ function drawn(world) {
189
+ const lines = [];
190
+ for (const [id, entry] of world.nodes) {
191
+ entry.node.traverseVisible((object) => {
192
+ if (object.type === 'Group' || object.type === 'Object3D') return;
193
+ const instances = object.isInstancedMesh ? `${object.count}:${hashOf(object.instanceMatrix)}` : '';
194
+ lines.push(
195
+ [
196
+ id,
197
+ object.type,
198
+ Boolean(object.userData.lookOutline),
199
+ geometryOf(object.geometry),
200
+ [object.material].flat().map(materialOf).join('+'),
201
+ object.castShadow,
202
+ object.receiveShadow,
203
+ object.frustumCulled,
204
+ object.renderOrder,
205
+ instances,
206
+ Array.from(object.matrixWorld.elements).join(','),
207
+ ].join('|')
208
+ );
209
+ });
210
+ }
211
+ return lines;
212
+ }
213
+
214
+ function sameDrawn(a, b, what) {
215
+ const A = drawn(a);
216
+ const B = drawn(b);
217
+ checks += 1;
218
+ assert.equal(A.length, B.length, `${what}: as many drawn objects`);
219
+ for (let i = 0; i < A.length; i++) {
220
+ if (A[i] === B[i]) continue;
221
+ const [a, b] = [A[i].split('|'), B[i].split('|')];
222
+ const fields = a.map((field, n) => (field === b[n] ? null : `${field} / ${b[n]}`)).filter(Boolean);
223
+ assert.fail(`${what}: drawn object ${i} (${a[0]}, ${a[1]}) differs\n ${fields.join('\n ').slice(0, 900)}`);
224
+ }
225
+ return A.length;
226
+ }
227
+
228
+ //
229
+ // Key absent
230
+ //
231
+
232
+ // The tree under a node: every object's kind, what marks it, where it stands
233
+ // and what it holds.
234
+ function describe(object) {
235
+ const u = object.userData;
236
+ const p = object.position;
237
+ const q = object.quaternion;
238
+ const s = object.scale;
239
+ return {
240
+ type: object.type,
241
+ marks: [u.partId, u.copyOf, u.partMesh, u.lookOutline, u.merged].map((v) => v ?? null),
242
+ // `+ 0`: the walk's neutral pose writes a rotation of -0.
243
+ at: [p.x, p.y, p.z, q.x, q.y, q.z, q.w, s.x, s.y, s.z].map((v) => v + 0),
244
+ visible: object.visible,
245
+ geometry: object.geometry ? geometryOf(object.geometry) : null,
246
+ children: object.children.map(describe),
247
+ };
248
+ }
249
+
250
+ // The node `ensureActorNode` and `addModelRig` have always made for an actor
251
+ // placing `file`, built here by the same calls.
252
+ function asAlways(file, component) {
253
+ const node = new THREE.Group();
254
+ const rig = copyModel(buildModelNode(parseModelCached(files[file]), {}, files, file, [file], { optimize: true }));
255
+ rig.position.y = component.yOffset ?? 0;
256
+ rig.scale.setScalar(component.scale ?? 1);
257
+ node.add(rig);
258
+ // The walk's neutral pose, which the engine writes on every frame.
259
+ node.userData.modelParts = rig.userData.modelParts;
260
+ animateModelParts({ node }, 0);
261
+ return node;
262
+ }
263
+
264
+ function keyAbsentIsMain() {
265
+ for (const drop of [undefined, false, 'true', 1]) {
266
+ for (const skip of [false, true]) {
267
+ const world = makeWorld();
268
+ const actors = everyModel.map((file, i) => actorOf(`m${i}`, file));
269
+ const runtime = makeRuntime(actors, { drop, skip });
270
+ // A `dt` of 0 holds every model in its neutral pose, as built.
271
+ frame(world, runtime, 0, 0);
272
+ frame(world, runtime, 0, 0);
273
+ for (const actor of actors) {
274
+ const entry = world.nodes.get(actor.id);
275
+ const file = actor.components.Model.file;
276
+ ok(!entry.sig.includes('dropEmptyParts') && !entry.modelKey.includes('dropEmptyParts'), `${file}: the signature and the build key are the old ones`);
277
+ ok(entry.modelKey.startsWith(`${file}|`), 'the build key');
278
+ if (drop === undefined && !skip) equal(describe(entry.node).children, describe(asAlways(file, actor.components.Model)).children, `${file}: the tree it always was`);
279
+ else ok(countUnder(entry.node) === countUnder(asAlways(file, actor.components.Model)), `${file}: every object`);
280
+ }
281
+ ok(!('dropsEmptyParts' in world), 'and nothing about it is kept on the world');
282
+ }
283
+ }
284
+ }
285
+
286
+ //
287
+ // Key present
288
+ //
289
+
290
+ function drawnIsTheSame(actorsOf, what, frames = 90) {
291
+ let objects = null;
292
+ for (const skip of [false, true]) {
293
+ const off = { world: makeWorld(), runtime: makeRuntime(actorsOf(), { skip }) };
294
+ const on = { world: makeWorld(), runtime: makeRuntime(actorsOf(), { skip, drop: true }) };
295
+ let compared = 0;
296
+ for (let i = 0; i < frames; i++) {
297
+ frame(off.world, off.runtime, i);
298
+ frame(on.world, on.runtime, i);
299
+ if (i < 3 || i % 15 === 0 || i === frames - 1) compared = sameDrawn(off.world, on.world, `${what}, frame ${i}${skip ? ', skipping' : ''}`);
300
+ }
301
+ objects = { off: countUnder(off.world.scene), on: countUnder(on.world.scene), drawn: compared };
302
+ ok(objects.on < objects.off, `${what}: fewer objects with the key (${objects.on} of ${objects.off})`);
303
+ let groups = 0;
304
+ on.world.scene.traverse((object) => {
305
+ // Under the key a plain group holds something drawn, or is one that stays.
306
+ if (object.type === 'Group' && object !== on.world.scene && !object.userData.actorId && countMeshes(object) === 0) groups += 1;
307
+ });
308
+ objects.emptyLeft = groups;
309
+ }
310
+ return objects;
311
+ }
312
+
313
+ function countMeshes(object) {
314
+ let n = 0;
315
+ object.traverse((o) => {
316
+ if (o.isMesh) n += 1;
317
+ });
318
+ return n;
319
+ }
320
+
321
+ const partsOf = (world, id) => world.nodes.get(id).node.userData.modelParts;
322
+ const rigUnder = (node) => node.children.find((child) => child.userData.modelParts === node.userData.modelParts);
323
+
324
+ function built(file, drop, { skip = true, frames = 3 } = {}) {
325
+ const world = makeWorld();
326
+ const actors = [actorOf('a', file, 2, 3, { Walks: {} })];
327
+ const runtime = makeRuntime(actors, { drop, skip });
328
+ for (let i = 0; i < frames; i++) frame(world, runtime, i);
329
+ return { world, runtime, actors, node: world.nodes.get('a').node, parts: partsOf(world, 'a') };
330
+ }
331
+
332
+ function whatStays() {
333
+ const off = built(LOCATORS, false);
334
+ const on = built(LOCATORS, true);
335
+ const all = locators.parts.map((part) => part.id);
336
+ equal([...off.parts.keys()].sort(), [...all].sort(), 'without the key every part has its group');
337
+ const kept = ['torso', 'legL', 'legR', 'armL', 'head', 'arm', 'muzzle', 'slot-hand'];
338
+ for (const id of kept) ok(on.parts.has(id), `${id} stays`);
339
+ for (const id of ['gone', 'holder', 'deep']) ok(!on.parts.has(id), `${id}, which draws nothing and no one reaches for, is not in modelParts`);
340
+ equal([...on.parts.keys()].sort(), [...kept].sort(), 'and nothing else is');
341
+ // A kept locator is where it was, and what a deck hangs on it is drawn there.
342
+ for (const id of ['muzzle', 'slot-hand', 'arm']) {
343
+ equal(Array.from(on.parts.get(id).matrixWorld.elements), Array.from(off.parts.get(id).matrixWorld.elements), `${id} stands where it stood`);
344
+ }
345
+ for (const side of [off, on]) {
346
+ side.parts.get('slot-hand').add(new THREE.Mesh(new THREE.BoxGeometry(0.1, 0.4, 0.1), new THREE.MeshStandardMaterial()));
347
+ frame(side.world, side.runtime, 5);
348
+ }
349
+ sameDrawn(off.world, on.world, 'a mesh hung on a slot');
350
+ // The template's own list, which `isStaticModel` reads, is the whole one.
351
+ const template = [...on.world.models.values()][0].template;
352
+ equal([...template.userData.modelParts.keys()].sort(), [...all].sort(), 'the shared build still lists every part');
353
+ }
354
+
355
+ function nothingHasNoRig() {
356
+ const off = built(NOTHING, false);
357
+ const on = built(NOTHING, true);
358
+ equal(off.node.children.length, 1, 'without the key: a rig that holds nothing');
359
+ equal(on.node.children.length, 0, 'with it: no rig');
360
+ ok(on.parts instanceof Map && on.parts.size === 0, 'modelParts is there, and empty');
361
+ ok(on.world.nodes.get('a').modelKey.endsWith('|dropEmptyParts'), 'its build is still held');
362
+ equal(on.world.models.size, 1);
363
+ on.actors.length = 0;
364
+ frame(on.world, on.runtime);
365
+ equal(on.world.models.size, 0, 'and given back when the actor goes');
366
+ equal(on.world.nodes.size, 0);
367
+ // A model with only a kept part is not one that draws nothing.
368
+ const file = 'models/test/only-a-slot.pxmodel';
369
+ files[file] = JSON.stringify({ format: 'pxmodel', name: 'Slot', look: false, parts: [empty('slot-top', { position: [0, 1, 0] })] });
370
+ const slot = built(file, true);
371
+ equal(slot.node.children.length, 1, 'a model that is one slot keeps its rig');
372
+ ok(slot.parts.has('slot-top'));
373
+ delete files[file];
374
+ }
375
+
376
+ //
377
+ // What reads the parts
378
+ //
379
+
380
+ function walkAndMotion() {
381
+ // The walk: the legs swing the same.
382
+ const off = built(PLAYER, false, { frames: 40 });
383
+ const on = built(PLAYER, true, { frames: 40 });
384
+ for (const id of ['legL', 'legR', 'armL', 'armR', 'torso']) {
385
+ ok(on.parts.get(id), `${id} is there to animate`);
386
+ equal(on.parts.get(id).rotation.toArray(), off.parts.get(id).rotation.toArray(), `${id} swings the same`);
387
+ }
388
+ ok(Math.abs(on.parts.get('legL').rotation.x) > 0.01, 'and does swing');
389
+ // motion.js: the same targets, the ones that draw nothing among them, and
390
+ // the same glow.
391
+ const a = built(MOVER, false, { frames: 30 });
392
+ const b = built(MOVER, true, { frames: 30 });
393
+ const targets = (side) => side.world.nodes.get('a').motionState.targets.map((t) => `${t.id}#${t.index}:${t.glow ? 'glow' : ''}`);
394
+ equal(targets(b), targets(a), 'motion finds the same parts');
395
+ ok(targets(b).some((t) => t.startsWith('ghost')) && targets(b).some((t) => t.startsWith('pivot')), 'a moving part that draws nothing stays');
396
+ ok(b.parts.has('ghost') && !b.parts.has('still'), 'and a still one that draws nothing goes');
397
+ sameDrawn(a.world, b.world, 'parts in motion');
398
+ }
399
+
400
+ // multiplayer-3d avatars.js `dressHead` looks a head's mesh up this way, and
401
+ // hub-game idle.js `rigOf` the rig this way; neither exports it.
402
+ const headMesh = (node) => node.userData.modelParts?.get('head')?.children.find((child) => child.userData.partMesh === 'head');
403
+ function rigOf(node) {
404
+ const children = node?.children ?? [];
405
+ const parts = node?.userData?.modelParts;
406
+ return (parts && children.find((c) => c.userData?.modelParts === parts)) ?? (children.length === 1 ? children[0] : null);
407
+ }
408
+
409
+ function kitReaders() {
410
+ const avatars = everyModel.filter((file) => file === PLAYER || file === LOCATORS || file.startsWith('imports/castle.hub-game/models/'));
411
+ for (const file of avatars) {
412
+ const off = built(file, false);
413
+ const on = built(file, true);
414
+ const [a, b] = [headMesh(off.node), headMesh(on.node)];
415
+ equal(Boolean(b), Boolean(a), `${file}: a head mesh is found with the key exactly when it is without`);
416
+ if (a) equal([b.geometry.type, b.geometry.parameters ?? null], [a.geometry.type, a.geometry.parameters ?? null], 'and is the same mesh');
417
+ ok(rigOf(on.node) === rigUnder(on.node) && rigOf(on.node) === on.node.children[0], `${file}: the rig is found`);
418
+ equal(Array.from(rigOf(on.node).matrixWorld.elements), Array.from(rigOf(off.node).matrixWorld.elements), 'where it was');
419
+ }
420
+ equal(rigOf(built(NOTHING, true).node), null, 'a model that draws nothing has no rig to pose');
421
+ }
422
+
423
+ // hub-game tiers.js: the low picture takes far scenery out of the scene by its
424
+ // real bounds, and watches for a node the engine built again.
425
+ async function levers() {
426
+ const file = path.join(REPO, 'kits/hub-game/code/client/tiers.js');
427
+ if (!fs.existsSync(file)) return false;
428
+ const { makeLevers } = await import(file);
429
+ const scenery = everyModel.filter((name) => name !== NOTHING).slice(0, 24);
430
+ const make = (drop) => {
431
+ const table = { ...files };
432
+ const actors = scenery.map((name, i) => actorOf(`s${i}`, name, i * 5, 0, { Solid: {} }));
433
+ actors.push(actorOf('hollow', NOTHING, 200, 0, { Solid: {} }));
434
+ const world = makeWorld();
435
+ const runtime = makeRuntime(actors, { drop, skip: true, table });
436
+ const scene = { scenePath: runtime.scenePath, data: runtime.data, readFromFile: () => ({ actors }), getActor: (id) => actors.find((a) => a.id === id) };
437
+ world.camera.position.set(0, 2, 0);
438
+ frame(world, runtime);
439
+ const lv = makeLevers();
440
+ const hidden = () => [...world.nodes].filter(([, entry]) => entry.node.parent !== world.scene).map(([id]) => id);
441
+ return { world, runtime, scene, lv, hidden, table, actors };
442
+ };
443
+ const off = make(false);
444
+ const on = make(true);
445
+ for (const side of [off, on]) side.lv.apply(side.world, side.scene, 0);
446
+ ok(on.hidden().length > 0 && on.hidden().length < on.actors.length, 'some scenery is far and some near');
447
+ equal(on.hidden(), off.hidden(), 'the same nodes are taken out with the key');
448
+ for (let i = 0; i < 3; i++) frame(on.world, on.runtime, i);
449
+ equal(on.hidden(), off.hidden(), 'and stay out while the engine runs');
450
+ // A hidden actor's model is edited: its node is built again, and taken out again.
451
+ const far = on.hidden()[0];
452
+ const edited = on.actors.find((a) => a.id === far).components.Model.file;
453
+ const before = on.world.nodes.get(far);
454
+ on.table[edited] = `${on.table[edited]} `;
455
+ frame(on.world, on.runtime);
456
+ ok(on.world.nodes.get(far) !== before && on.world.nodes.get(far).node.parent === on.world.scene, 'a rebuilt node is drawn again');
457
+ on.lv.apply(on.world, on.scene, 1);
458
+ equal(on.hidden(), off.hidden(), 'and the levers take it out again');
459
+ ok(on.world.nodes.get(far).modelKey.endsWith('|dropEmptyParts'));
460
+ on.lv.restore(on.world);
461
+ equal(on.hidden(), [], 'restore puts every node back');
462
+ return true;
463
+ }
464
+
465
+ //
466
+ // One world, scenes that ask and scenes that do not
467
+ //
468
+
469
+ const droppedKeys = (world) => [...world.models.keys()].filter((key) => key.endsWith('|dropEmptyParts')).length;
470
+
471
+ // Every ActorNode's record is of the tree it now has.
472
+ function recordsAreCurrent(world, what) {
473
+ for (const [id, entry] of world.nodes) {
474
+ const record = entry.node.computedFrom;
475
+ if (record) equal(record.ids.length, countUnder(entry.node), `${what}: ${id}'s record counts its own tree`);
476
+ }
477
+ }
478
+
479
+ function scenesInOneWorld() {
480
+ // Nothing here walks, and time stands still (a `dt` of 0): a node built
481
+ // again for the other way starts its walk and its motion from the
482
+ // beginning, as any rebuilt node does, where a node kept across the two
483
+ // scenes would carry on.
484
+ const models = [PLAYER, LOCATORS, NOTHING, ...everyModel.filter((f) => f.includes('/town/')).slice(0, 6)];
485
+ const actorsOf = () => models.map((file, i) => actorOf(`a${i}`, file, i * 3, 0));
486
+ const fresh = (drop) => {
487
+ const side = { world: makeWorld(), runtime: makeRuntime(actorsOf(), { drop, skip: true }) };
488
+ for (let i = 0; i < 4; i++) frame(side.world, side.runtime, i, 0);
489
+ return side;
490
+ };
491
+ const full = countUnder(fresh(false).world.scene);
492
+ const less = countUnder(fresh(true).world.scene);
493
+ ok(less < full);
494
+
495
+ for (const resident of [false, true]) {
496
+ const world = makeWorld();
497
+ const keep = resident ? new Set(['scenes/town.scene', 'scenes/game.scene']) : undefined;
498
+ const town = makeRuntime(actorsOf(), { drop: true, skip: true, scenePath: 'scenes/town.scene' });
499
+ const game = makeRuntime(actorsOf(), { skip: true, scenePath: 'scenes/game.scene' });
500
+ town.residentScenes = keep;
501
+ game.residentScenes = keep;
502
+ const what = resident ? 'a door trip, the town resident' : 'one scene after another';
503
+ // The same trips in a world neither of whose scenes asks.
504
+ const plain = makeWorld();
505
+ const twins = new Map([
506
+ [town, makeRuntime(actorsOf(), { skip: true, scenePath: 'scenes/town.scene' })],
507
+ [game, makeRuntime(actorsOf(), { skip: true, scenePath: 'scenes/game.scene' })],
508
+ ]);
509
+ for (const twin of twins.values()) twin.residentScenes = keep;
510
+ const play = (runtime, n = 4) => {
511
+ for (let i = 0; i < n; i++) {
512
+ frame(world, runtime, i, 0);
513
+ frame(plain, twins.get(runtime), i, 0);
514
+ }
515
+ sameDrawn(plain, world, `${what}: drawn as in a world where no scene asks`);
516
+ };
517
+ play(town);
518
+ equal(countUnder(world.scene), less, `${what}: the town, which asks`);
519
+ const townNodes = new Map(world.nodes);
520
+ equal(droppedKeys(world), world.models.size, 'every build is a dropped one');
521
+ play(game);
522
+ equal(countUnder(world.scene), full, `${what}: the game, which does not, has every group`);
523
+ for (const [id, entry] of world.nodes) ok(entry !== townNodes.get(id) && !entry.sig.includes('dropEmptyParts'), `${id} was built for the game`);
524
+ recordsAreCurrent(world, what);
525
+ if (resident) {
526
+ // The town's nodes are parked with their builds; the game's are its own.
527
+ equal(droppedKeys(world) * 2, world.models.size, 'each model is built twice, once each way');
528
+ const templates = new Set([...world.models.values()].map((entry) => entry.template));
529
+ equal(templates.size, world.models.size, 'and no build is shared');
530
+ } else {
531
+ equal(droppedKeys(world), 0, 'the town\'s builds are given back');
532
+ }
533
+ play(town);
534
+ equal(countUnder(world.scene), less, `${what}: and the town again`);
535
+ for (const [id, entry] of world.nodes) {
536
+ ok(entry.sig.endsWith('|dropEmptyParts'));
537
+ if (resident) ok(entry === townNodes.get(id), `${id} is the node that was parked`);
538
+ }
539
+ recordsAreCurrent(world, what);
540
+ play(game);
541
+ equal(countUnder(world.scene), full);
542
+ }
543
+
544
+ // A scene file reloaded with the key changed: the same runtime, the same
545
+ // path, the same actors.
546
+ const side = fresh(false);
547
+ const before = new Map(side.world.nodes);
548
+ side.runtime.dropsEmptyParts = true;
549
+ for (let i = 0; i < 3; i++) frame(side.world, side.runtime, i);
550
+ equal(countUnder(side.world.scene), less, 'the key set under a playing scene: every node is built again without its empty groups');
551
+ for (const [id, entry] of side.world.nodes) ok(entry !== before.get(id));
552
+ equal(droppedKeys(side.world), side.world.models.size);
553
+ recordsAreCurrent(side.world, 'the key set');
554
+ side.runtime.dropsEmptyParts = false;
555
+ for (let i = 0; i < 3; i++) frame(side.world, side.runtime, i);
556
+ equal(countUnder(side.world.scene), full, 'and taken away again');
557
+ equal(droppedKeys(side.world), 0);
558
+ recordsAreCurrent(side.world, 'the key taken away');
559
+ }
560
+
561
+ // A callback the engine calls in the middle of a pass (a ground-height
562
+ // function, while a walker is animated) syncs another scene, one that builds
563
+ // the other way, in the same world. Whether a pass drops is the pass's own:
564
+ // every actor the interrupted pass places after the callback is built that
565
+ // pass's way, on that very frame, in both orders, skipping or not, and
566
+ // whether the inner sync returns or throws.
567
+ function aSceneInsideAPass() {
568
+ const fullParts = locators.parts.length;
569
+ for (const outerDrops of [false, true]) {
570
+ for (const skip of [false, true]) {
571
+ for (const throws of [false, true]) {
572
+ const what = `${outerDrops ? 'a pass that drops' : 'a pass that does not drop'}, entered by one that ${outerDrops ? 'does not' : 'does'}${skip ? ', skipping' : ''}${throws ? ', which throws' : ''}`;
573
+ const world = makeWorld();
574
+ // The walker is placed first; `l`, `n` and `m` come after the callback.
575
+ const actorsOf = () => [actorOf('w', PLAYER, 0, 0, { Walks: {} }), actorOf('l', LOCATORS, 3), actorOf('n', NOTHING, 6), actorOf('m', MOVER, 9)];
576
+ const mode = (drops) => (drops ? { drop: true } : {});
577
+ const outer = makeRuntime(actorsOf(), { ...mode(outerDrops), skip, scenePath: 'scenes/outer.scene' });
578
+ const inner = makeRuntime(actorsOf(), { ...mode(!outerDrops), skip, scenePath: 'scenes/inner.scene' });
579
+ for (let i = 0; i < 4; i++) frame(world, outer, i);
580
+ let called = 0;
581
+ world.scene.userData.groundHeight = () => {
582
+ called += 1;
583
+ if (called === 1) {
584
+ syncActors(world, inner, {}, DT);
585
+ if (throws) throw new Error('from the callback');
586
+ }
587
+ return 0;
588
+ };
589
+ if (throws) assert.throws(() => frame(world, outer, 4), /from the callback/);
590
+ else frame(world, outer, 4);
591
+ ok(called > 0, `${what}: the callback ran`);
592
+ delete world.scene.userData.groundHeight;
593
+ if (throws) {
594
+ // The pass ended where it threw; the next one is the outer scene's again.
595
+ frame(world, outer, 5);
596
+ }
597
+ // This frame, as the outer pass left it.
598
+ for (const id of ['l', 'n', 'm']) {
599
+ const entry = world.nodes.get(id);
600
+ equal(entry.sig.endsWith('|dropEmptyParts'), outerDrops, `${what}: ${id}'s signature is the pass's own`);
601
+ equal((entry.modelKey ?? '').endsWith('|dropEmptyParts'), outerDrops, `${what}: ${id}'s build is the pass's own`);
602
+ }
603
+ equal(partsOf(world, 'l').size === fullParts, !outerDrops, `${what}: the locators have ${outerDrops ? 'lost their empty groups' : 'every group'}`);
604
+ equal(world.nodes.get('n').node.children.length, outerDrops ? 0 : 1, `${what}: the model that draws nothing ${outerDrops ? 'has no rig' : 'has its rig'}`);
605
+ equal(partsOf(world, 'm').has('still'), !outerDrops, `${what}: the mover`);
606
+ // And each scene alone afterwards.
607
+ for (let i = 0; i < 3; i++) frame(world, inner, i);
608
+ equal(partsOf(world, 'l').size === fullParts, outerDrops, `${what}: then the other scene, its own way`);
609
+ equal(droppedKeys(world), outerDrops ? 0 : world.models.size);
610
+ for (let i = 0; i < 3; i++) frame(world, outer, i);
611
+ equal(partsOf(world, 'l').size === fullParts, !outerDrops, `${what}: and the first again`);
612
+ equal(droppedKeys(world), outerDrops ? world.models.size : 0);
613
+ if (skip) recordsAreCurrent(world, what);
614
+ }
615
+ }
616
+ }
617
+ }
618
+
619
+ // Two runtimes of one scene path played turn about in one world, one asking
620
+ // and one not, with nothing between them the engine could notice: what a
621
+ // skipping pass wrote down for the one never vouches for the other's node.
622
+ function turnAbout() {
623
+ for (const skip of [false, true]) {
624
+ const world = makeWorld();
625
+ const actors = [actorOf('l', LOCATORS, 3), actorOf('n', NOTHING, 6)];
626
+ const asks = makeRuntime(actors, { drop: true, skip });
627
+ const plain = makeRuntime(actors, { skip });
628
+ for (let i = 0; i < 6; i++) {
629
+ frame(world, asks, i, 0);
630
+ ok(!partsOf(world, 'l').has('gone') && world.nodes.get('n').node.children.length === 0, 'the one that asks');
631
+ frame(world, plain, i, 0);
632
+ ok(partsOf(world, 'l').has('gone') && world.nodes.get('n').node.children.length === 1, 'the one that does not');
633
+ }
634
+ // A world disposed in between leaves nothing that says which way to build.
635
+ disposeWorld(world);
636
+ ok(!('dropsEmptyParts' in world) && world.models.size === 0, 'a disposed world');
637
+ }
638
+ }
639
+
640
+ // Copies of a part that stays, stay: the walk's parts, a part in motion, a
641
+ // clip's, a kept part and a slot, each empty, repeated and mirrored.
642
+ function copiesStay() {
643
+ const file = 'models/test/copies.pxmodel';
644
+ const copied = (id, more = {}) => empty(id, { position: [0, 1, 0], repeat: { count: 3, offset: [0.2, 0, 0] }, mirror: 'x', ...more });
645
+ const model = {
646
+ format: 'pxmodel',
647
+ name: 'Copies',
648
+ clips: { wave: { duration: 1, tracks: { banner: { rotate: [[0, [0, 0, 0]], [0.5, [0, 0, 30]], [1, [0, 0, 0]]] } } } },
649
+ parts: [box('body', 0.5), copied('torso'), copied('legL'), copied('tail'), copied('spinner', { motion: { spin: [0, 90, 0] } }), copied('banner'), copied('marker', { keep: true }), copied('slot-side'), copied('plain')],
650
+ };
651
+ files[file] = JSON.stringify(model);
652
+ const off = built(file, false);
653
+ const on = built(file, true);
654
+ const copies = (side, id) => {
655
+ let n = 0;
656
+ side.node.traverse((object) => {
657
+ if (object.userData.copyOf === id) n += 1;
658
+ });
659
+ return n;
660
+ };
661
+ // The model's own list of what moves has the gait's, the motion's and the
662
+ // clip's part, and not the walk's: those stay by their names alone.
663
+ const animation = off.world.models.values().next().value.template.userData.animation;
664
+ equal(animation.clips.wave.tracks.banner.rotate.length, 3, 'the clip is read, with its keys');
665
+ for (const id of ['tail', 'spinner', 'banner']) ok(animation.parts.includes(id), `${id} is one of the model's moving parts`);
666
+ for (const id of ['torso', 'legL']) ok(!animation.parts.includes(id), `${id} is not: it stays as one of the walk's`);
667
+ for (const id of ['torso', 'legL', 'tail', 'spinner', 'banner', 'marker', 'slot-side']) {
668
+ ok(copies(off, id) > 0, `${id} has copies`);
669
+ equal(copies(on, id), copies(off, id), `every copy of ${id} stays`);
670
+ ok(on.parts.has(id), `${id} itself stays`);
671
+ }
672
+ ok(copies(off, 'plain') > 0 && copies(on, 'plain') === 0 && !on.parts.has('plain'), 'a part that is none of those goes, with its copies');
673
+ for (let i = 0; i < 20; i++) {
674
+ frame(off.world, off.runtime, i);
675
+ frame(on.world, on.runtime, i);
676
+ }
677
+ const targets = (side) => side.world.nodes.get('a').motionState.targets.map((t) => `${t.id}#${t.index}`);
678
+ equal(targets(on), targets(off), 'motion finds the same parts and copies');
679
+ sameDrawn(off.world, on.world, 'copies');
680
+ delete files[file];
681
+ }
682
+
683
+ // A model file edited while its scene plays.
684
+ function hotReload() {
685
+ for (const skip of [false, true]) {
686
+ const table = { ...files };
687
+ const world = makeWorld();
688
+ const actors = [actorOf('a', LOCATORS), actorOf('b', LOCATORS, 3)];
689
+ const runtime = makeRuntime(actors, { drop: true, skip, table });
690
+ for (let i = 0; i < 3; i++) frame(world, runtime, i);
691
+ const before = world.nodes.get('a');
692
+ const key = before.modelKey;
693
+ const edited = structuredClone(locators);
694
+ edited.parts.push(empty('new-empty'), box('hat', 1.6, { parent: 'head' }), empty('slot-hat', { parent: 'head' }));
695
+ table[LOCATORS] = JSON.stringify(edited);
696
+ for (let i = 0; i < 3; i++) frame(world, runtime, i);
697
+ const after = world.nodes.get('a');
698
+ ok(after !== before && after.modelKey !== key && after.modelKey.endsWith('|dropEmptyParts'), 'an edited model is built again, for the key');
699
+ ok(!world.models.has(key) && world.models.size === 1, 'the old build is given back');
700
+ const parts = after.node.userData.modelParts;
701
+ // `hat` is drawn, in a batch with the other boxes; its own group is empty.
702
+ ok(parts.has('slot-hat') && parts.has('head') && !parts.has('hat') && !parts.has('new-empty') && !parts.has('gone'), 'and its empty groups are gone again');
703
+ const plain = makeWorld();
704
+ const plainRuntime = makeRuntime([actorOf('a', LOCATORS), actorOf('b', LOCATORS, 3)], { skip, table });
705
+ for (let i = 0; i < 3; i++) frame(plain, plainRuntime, i);
706
+ sameDrawn(plain, world, 'the edited model');
707
+ }
708
+ }
709
+
710
+ // `instanceModels`: the copies of a static model drawn together.
711
+ function instanced() {
712
+ const counts = (drop) => {
713
+ const world = makeWorld();
714
+ world.instanceModels = true;
715
+ world.camera.position.set(0, 5, 20);
716
+ world.camera.lookAt(0, 0, 0);
717
+ world.camera.updateMatrixWorld();
718
+ const file = 'imports/castle.physics-3d/models/barrel.pxmodel';
719
+ const actors = [0, 1, 2, 3].map((i) => actorOf(`b${i}`, file, i * 2 - 3));
720
+ actors.push(actorOf('n', NOTHING));
721
+ const runtime = makeRuntime(actors, { drop });
722
+ for (let i = 0; i < 3; i++) frame(world, runtime, i);
723
+ return [...world.instances.values()].flatMap((instances) => instances.parts.map((part) => `${part.mesh?.count}:${part.mesh ? geometryOf(part.mesh.geometry) : ''}`));
724
+ };
725
+ const on = counts(true);
726
+ ok(on.length > 0 && on.every((line) => !line.startsWith('0:') && !line.startsWith('undefined')), 'instances are drawn');
727
+ // Without the key the model that draws nothing has an instance set of no parts.
728
+ equal(on, counts(false), 'the same instanced meshes with the key');
729
+ }
730
+
731
+ // Whole scenes a generator wrote (`DROP_DECKS`), every actor that has a model
732
+ // or a shape, the Player and the NPCs walking.
733
+ function decks() {
734
+ const out = [];
735
+ for (const deck of (process.env.DROP_DECKS ?? '').split(',').filter(Boolean)) {
736
+ const table = { ...files };
737
+ readModels(path.join(deck, 'models'), 'models', table);
738
+ const data = JSON.parse(fs.readFileSync(path.join(deck, 'scenes/main.scene'), 'utf8'));
739
+ const stalls = process.env.DROP_STALLS ? Number(process.env.DROP_STALLS) : Infinity;
740
+ const actorsOf = () =>
741
+ data.actors
742
+ .filter((a) => {
743
+ const stall = /^(?:stall|keeper|stall-crate|stall-goods)-[a-z]+-(\d+)$/.exec(a.id);
744
+ return !(stall && Number(stall[1]) >= stalls);
745
+ })
746
+ .map((a) => {
747
+ let components = structuredClone(a.components);
748
+ if (a.blueprint) components = { ...structuredClone(JSON.parse(fs.readFileSync(path.join(deck, a.blueprint), 'utf8')).actors[0].components), ...components };
749
+ components.Transform = { ...transform(0, 0), ...components.Transform };
750
+ if (components.Player || components.HubNpc) components.Walks = {};
751
+ return { id: a.id, runtime: {}, components };
752
+ });
753
+ const make = (drop) => ({ world: makeWorld(), runtime: makeRuntime(actorsOf(), { drop, skip: data.engine?.skipUnchangedActors === true, table }) });
754
+ const off = make(false);
755
+ const on = make(data.engine?.dropEmptyParts === true || process.env.DROP_FORCE === '1');
756
+ let compared = 0;
757
+ for (let i = 0; i < 120; i++) {
758
+ frame(off.world, off.runtime, i);
759
+ frame(on.world, on.runtime, i);
760
+ if (i < 2 || i % 30 === 0 || i === 119) compared = sameDrawn(off.world, on.world, `${deck}, frame ${i}`);
761
+ }
762
+ out.push(`${path.basename(deck)}: ${off.runtime.actors.length} actors, ${countUnder(off.world.scene)} objects without the key, ${countUnder(on.world.scene)} with (scene asks: ${data.engine?.dropEmptyParts === true}), ${compared} drawn objects equal over 120 frames`);
763
+ }
764
+ return out;
765
+ }
766
+
767
+ export async function run() {
768
+ checks = 0;
769
+ keyAbsentIsMain();
770
+ const every = drawnIsTheSame(everyActor, 'every model');
771
+ whatStays();
772
+ nothingHasNoRig();
773
+ walkAndMotion();
774
+ kitReaders();
775
+ const withLevers = await levers();
776
+ scenesInOneWorld();
777
+ aSceneInsideAPass();
778
+ turnAbout();
779
+ copiesStay();
780
+ hotReload();
781
+ instanced();
782
+ const whole = decks();
783
+ for (const line of whole) console.log(`drop empty parts: ${line}`);
784
+ return `${checks} drop-empty-parts checks on ${everyModel.length} models (${kitModels} of the kit, ${townModels} of the hub town, ${hubModels} of hub-game${withLevers ? ', with hub-game\'s levers' : ''}): ${every.drawn} drawn objects equal with the key, ${every.on} objects for ${every.off}`;
785
+ }
786
+
787
+ if (process.argv[1] === fileURLToPath(import.meta.url)) console.log(await run());