@wildshard/engine 0.1.22 → 0.1.24

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 (179) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/index.html +17 -4
  3. package/lint/engine-sides.json +9 -0
  4. package/lint/sim-players.json +2 -13
  5. package/package.json +36 -3
  6. package/scripts/apfs-clone.mjs +5 -2
  7. package/scripts/app-build/catalogue.ts +39 -8
  8. package/scripts/app-build/serviceWorker.ts +4 -1
  9. package/scripts/app-build/splitOutput.mjs +33 -11
  10. package/scripts/app-build/titlePreloads.mjs +8 -5
  11. package/scripts/bake-road-surfaces.entry.ts +18 -0
  12. package/scripts/bake-road-surfaces.mjs +44 -0
  13. package/scripts/changelog.mjs +2 -1
  14. package/scripts/ci-pack.mjs +3 -3
  15. package/scripts/engine-ci-shard.mjs +11 -0
  16. package/scripts/fight-page-census.mjs +131 -0
  17. package/scripts/goldens/board.py +44 -11
  18. package/scripts/goldens/capture.mjs +18 -6
  19. package/scripts/goldens/native-residency.d.mts +2 -0
  20. package/scripts/goldens/native-residency.mjs +31 -4
  21. package/scripts/grid-road-lag.mjs +209 -0
  22. package/scripts/keep-copy.mjs +172 -0
  23. package/scripts/land.d.mts +4 -1
  24. package/scripts/land.mjs +121 -9
  25. package/scripts/lane-live.mjs +136 -0
  26. package/scripts/leftovers-report.mjs +47 -0
  27. package/scripts/loading-card-proof.mjs +42 -9
  28. package/scripts/loading-flow/benchmax.mjs +59 -7
  29. package/scripts/loading-flow/stalls.d.mts +2 -0
  30. package/scripts/loading-flow/stalls.mjs +13 -0
  31. package/scripts/map-hash.mjs +1 -1
  32. package/scripts/mmo-bots.mjs +5 -3
  33. package/scripts/mmo-grid-proof.mjs +74 -0
  34. package/scripts/mmo-seat-proof.mjs +43 -0
  35. package/scripts/nightly-heads.ts +13 -13
  36. package/scripts/nightly-model.ts +26 -12
  37. package/scripts/nightly-tag.mjs +2 -4
  38. package/scripts/nightly.proof.ts +18 -5
  39. package/scripts/nightly.ts +13 -8
  40. package/scripts/no-astc-boot.mjs +77 -0
  41. package/scripts/page-release/content.mjs +19 -10
  42. package/scripts/page-release/flow.d.mts +3 -2
  43. package/scripts/page-release/flow.mjs +31 -21
  44. package/scripts/page-release/packs.d.mts +5 -0
  45. package/scripts/page-release/packs.mjs +13 -3
  46. package/scripts/page-release/preview.d.mts +2 -0
  47. package/scripts/page-release/preview.mjs +74 -0
  48. package/scripts/page-release.mjs +13 -5
  49. package/scripts/physics-route.json +6 -6
  50. package/scripts/pins-reuse.mjs +1 -0
  51. package/scripts/pins-staging.ts +54 -0
  52. package/scripts/pins.ts +5 -0
  53. package/scripts/ring3.proof.ts +71 -0
  54. package/scripts/ring3.ts +100 -0
  55. package/scripts/road-drive-proof.mjs +269 -0
  56. package/scripts/road-memory-probe.mjs +129 -0
  57. package/scripts/scratch-dir.mjs +33 -14
  58. package/scripts/scratch-sweep.mjs +15 -23
  59. package/scripts/server-release/github.mjs +59 -26
  60. package/scripts/server-release/items.d.mts +7 -0
  61. package/scripts/server-release/items.mjs +28 -0
  62. package/scripts/server-release/publish.mjs +24 -2
  63. package/scripts/server-release/sign.mjs +8 -4
  64. package/scripts/side-parity.mjs +1 -1
  65. package/scripts/test-products.json +1 -0
  66. package/scripts/test_prebuilt_output.py +3 -1
  67. package/scripts/tsconfig.json +2 -0
  68. package/scripts/turn-in-shots.mjs +83 -0
  69. package/scripts/vitest-bench-observe-proof.py +168 -0
  70. package/scripts/vitest-bench.py +122 -77
  71. package/scripts/vitest-ci-files.ts +5 -1
  72. package/scripts/vps/rebuild.sh +3 -1
  73. package/scripts/vps/wildshard-config +106 -1
  74. package/scripts/warm-native-chrome.mjs +9 -3
  75. package/scripts/worker-client-fights.mjs +9 -3
  76. package/scripts/worktree-reap.mjs +36 -140
  77. package/scripts/worktree.mjs +92 -12
  78. package/scripts/zone-gate-proof.mjs +93 -0
  79. package/src/client/engine/audio/audioLog.ts +7 -2
  80. package/src/client/engine/boot/diagnostics.ts +69 -1
  81. package/src/client/engine/boot/sw.ts +3 -1
  82. package/src/client/engine/core/ktx2.ts +33 -10
  83. package/src/client/engine/core/ktx2Zstd.ts +2 -1
  84. package/src/client/engine/models/place.ts +7 -5
  85. package/src/client/engine/pwa/sw.js +83 -10
  86. package/src/client/engine/render/dataLook.ts +14 -7
  87. package/src/client/engine/render/lookLight.ts +64 -20
  88. package/src/client/engine/render/precompile.ts +6 -0
  89. package/src/client/engine/render/tiers.ts +9 -0
  90. package/src/client/engine/ui/Loading.ts +6 -8
  91. package/src/client/engine/ui/lookLightOption.ts +1 -1
  92. package/src/client/engine/ui/playerReload.ts +5 -5
  93. package/src/client/game/audio/cueDirector.ts +2 -1
  94. package/src/client/game/boot/bytes.generated.ts +4 -1
  95. package/src/client/game/boot/versions.generated.ts +8 -5
  96. package/src/client/game/boss/arenaRoom.ts +4 -3
  97. package/src/client/game/boss/roamingProjection.ts +1 -1
  98. package/src/client/game/devScene/hook.ts +1 -1
  99. package/src/client/game/devScene/liveLook.ts +1 -1
  100. package/src/client/game/grid/cellClip.ts +70 -6
  101. package/src/client/game/grid/dataCellKit.ts +9 -1
  102. package/src/client/game/grid/gateCard.css +9 -0
  103. package/src/client/game/grid/gateCard.ts +67 -0
  104. package/src/client/game/grid/live.ts +17 -3
  105. package/src/client/game/grid/liveSession.ts +15 -5
  106. package/src/client/game/grid/neighbourLife.ts +10 -1
  107. package/src/client/game/grid/neighbourPanels.ts +29 -2
  108. package/src/client/game/grid/pageEntry.ts +21 -0
  109. package/src/client/game/grid/products.ts +21 -7
  110. package/src/client/game/grid/regionalWorld.ts +5 -0
  111. package/src/client/game/grid/roadCompressedSurfaces.ts +69 -0
  112. package/src/client/game/grid/roadLook.ts +5 -73
  113. package/src/client/game/grid/roadLookPlatform.ts +11 -6
  114. package/src/client/game/grid/roadSurfaceMaps.ts +80 -0
  115. package/src/client/game/grid/roadTilePool.ts +4 -0
  116. package/src/client/game/grid/session.ts +58 -16
  117. package/src/client/game/grid/softWallLook.ts +6 -1
  118. package/src/client/game/plugin/ui.ts +3 -0
  119. package/src/client/game/population/signals.ts +1 -1
  120. package/src/client/game/quest/chapterDirector.ts +1 -0
  121. package/src/client/game/session/play.ts +3 -0
  122. package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
  123. package/src/client/game/shardfile/clientSource.ts +5 -2
  124. package/src/client/game/shardfile/clientWorker.ts +25 -8
  125. package/src/client/game/shardfile/look.ts +1 -1
  126. package/src/client/game/shardfile/runtimeProduct.ts +9 -5
  127. package/src/client/game/shardfile/slabLibrary.ts +37 -0
  128. package/src/client/game/shardfile/slabRanges.ts +145 -0
  129. package/src/client/game/shardfile/wirePage.ts +5 -2
  130. package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
  131. package/src/client/host/online/shell.ts +2 -2
  132. package/src/client/host/standalone/shell.ts +4 -1
  133. package/src/cook/game/cookWorker.ts +8 -5
  134. package/src/cook/game/tierTextures.ts +5 -3
  135. package/src/server/engine/net/simWorld.ts +3 -4
  136. package/src/server/game/grid/cellHome.ts +58 -0
  137. package/src/server/game/grid/simulation.ts +32 -8
  138. package/src/server/game/plugin/mover.ts +18 -14
  139. package/src/server/game/plugin/simulation.ts +2 -0
  140. package/src/server/game/shardfile/dataRespawn.ts +47 -0
  141. package/src/server/game/shardfile/declaredKitItems.ts +31 -7
  142. package/src/server/host/bake/headlessWorker.ts +3 -3
  143. package/src/server/host/dedicated/cellWorker.ts +4 -2
  144. package/src/server/host/dedicated/main.ts +7 -4
  145. package/src/server/host/dedicated/packReader.ts +15 -2
  146. package/src/server/host/dedicated/playerStore.ts +1 -1
  147. package/src/server/host/headlessRuntime.ts +11 -6
  148. package/src/server/host/standalone/cellWorld.ts +20 -6
  149. package/src/server/host/standalone/gridServer.ts +20 -6
  150. package/src/server/host/standalone/roadWorld.ts +36 -0
  151. package/src/server/host/standalone/serverHost.ts +2 -2
  152. package/src/shared/engine/entities/AnimalSim.ts +10 -0
  153. package/src/shared/engine/physics/gridBorders.ts +15 -1
  154. package/src/shared/engine/physics/transferWalls.ts +9 -4
  155. package/src/shared/engine/sim/snapshot.ts +5 -5
  156. package/src/shared/game/grid/allocator.ts +8 -1
  157. package/src/shared/game/grid/gateCount.ts +27 -0
  158. package/src/shared/game/grid/zoneWalls.ts +64 -0
  159. package/src/shared/game/ledger.ts +13 -4
  160. package/src/shared/game/loot/platformCatalogue.ts +14 -0
  161. package/src/shared/game/quest/ledger.ts +3 -3
  162. package/src/shared/game/shardfile/items.ts +9 -1
  163. package/src/shared/game/strings.ts +2 -0
  164. package/src/shared/host/headlessJourney.ts +3 -3
  165. package/src/shared/host/headlessTape.ts +7 -6
  166. package/src/shared/host/releaseRows.ts +4 -1
  167. package/src/shared/host/standalone/harnessPlace.ts +4 -0
  168. package/src/test/engine/simState.ts +134 -0
  169. package/src/test/game/builtProduct.ts +6 -0
  170. package/src/test/game/headless/admittedProductCache.ts +61 -0
  171. package/src/test/game/headless/checkedReplayPipeline.ts +21 -0
  172. package/src/test/game/headless/nativeBounds.ts +27 -0
  173. package/src/test/game/headless/processUsage.ts +22 -0
  174. package/src/test/game/headless/productSession.ts +39 -0
  175. package/src/test/game/headless/ropeBodies.ts +60 -0
  176. package/src/test/game/headless/worker.ts +34 -0
  177. package/src/test/game/headlessNative.ts +114 -0
  178. package/src/test/game/headlessWorker.ts +43 -0
  179. package/src/test/tsconfig.game.json +3 -0
@@ -13,14 +13,15 @@ import { leaveAfterPaint } from '../boot/leaveAfterPaint';
13
13
  *
14
14
  * RL3: the tap's own turn turns the control into a loading button and puts the full-page RELOADING cover up
15
15
  * (src/client/engine/ui/reloadCover.ts), before the save, the worker or anything else is awaited. The cover stays until
16
- * the page unloads. RL2: on the title it loads a fresh `/`, anywhere else the page reloads where it is.
16
+ * the page unloads. The page reloads where it is, its path, query and hash kept (Jake, 2026-11-15: "Tap to reload does not
17
+ * respect the URL ... I was on /slug/blender-template"; this replaces RL2's fresh `/` on the title).
17
18
  * QC3: a waiting worker is activated first (SKIP_WAITING, then its `activated` state) so the next document is the new
18
19
  * build's. RL5: that hand-over gets RELOAD_FALLBACK_MS from the tap; past it the page reloads hard and the cover says so.
19
20
  * Nothing to adopt (no worker, or it retired) is a plain reload. Every path ends in a navigation, one painted frame after
20
21
  * the cover (leaveAfterPaint).
21
22
  */
22
23
 
23
- /** The title (or its menus) is up: the reload lands on a fresh `/` rather than where the page is. */
24
+ /** The title (or its menus) is up: only what the next boot records differs; the reload keeps the URL either way. */
24
25
  export function titleShowing(): boolean {
25
26
  return document.querySelector('#hud.intro .ws-menu:not(.hide), #hud.intro .ws-main:not(.hide)') !== null;
26
27
  }
@@ -38,8 +39,7 @@ export function reloadForPlayer(control: HTMLElement | null, { newer = false, wh
38
39
  gone = true;
39
40
  leaveAfterPaint(() => {
40
41
  leftByPlayer(); markReload(reason);
41
- if (title) location.replace('/');
42
- else location.reload();
42
+ location.reload();
43
43
  });
44
44
  };
45
45
  if (sw === undefined) { leaveSaved(plain); return; }
@@ -49,7 +49,7 @@ export function reloadForPlayer(control: HTMLElement | null, { newer = false, wh
49
49
  // the hand-over ran out of time (not merely "nothing to adopt"): say so, in amber, on the way out
50
50
  const hard = (): void => { if (diagnosticNow() - tapped >= RELOAD_FALLBACK_MS - 50) reloadingLine(engineString('s_reloading_slow'), 'slow'); plain(); };
51
51
  if (left <= 0) { hard(); return; }
52
- void sw.adopt(title ? '/' : undefined, reason, left)
52
+ void sw.adopt(undefined, reason, left)
53
53
  .then(sent => { if (sent) gone = true; else hard(); return undefined; }, hard);
54
54
  });
55
55
  }
@@ -4,6 +4,7 @@ import { parse } from 'valibot';
4
4
  import type { Game } from '@wildshard/engine/core/Game';
5
5
  import type { Scope } from '@wildshard/engine/app/scope';
6
6
  import type { CombatCues } from '@wildshard/engine/combat/cues';
7
+ import { audioLog } from '@wildshard/engine/audio/audioLog';
7
8
  import { Impacts } from '@wildshard/engine/fx/Impacts';
8
9
  import { effectField, type EffectField } from '@wildshard/engine/fx/effectField';
9
10
  import { ParticlePool, pointScale } from '@wildshard/engine/fx/ParticlePool';
@@ -151,7 +152,7 @@ export class CueDirector {
151
152
  }
152
153
  if (row.sound !== undefined) {
153
154
  if (this.sounds === undefined) throw new Error('Cue sound owner is absent');
154
- this.sounds.cue(row.sound as `cue.${string}`, row.soundPhase === undefined ? {} : { phase: row.soundPhase });
155
+ audioLog('cue', row.id, this.sounds.cue(row.sound as `cue.${string}`, row.soundPhase === undefined ? {} : { phase: row.soundPhase }), row.sound);
155
156
  }
156
157
  }
157
158
  }
@@ -51,7 +51,7 @@ export const PUBLIC_BYTES = {
51
51
  "/assets/baked/ink-cel-valley/far.json": 949,
52
52
  "/assets/baked/ink-cel-valley/near.glb": 907100,
53
53
  "/assets/baked/ink-cel-valley/near.json": 461,
54
- "/assets/baked/nalati-grasslands/far-impostor.png": 40666,
54
+ "/assets/baked/nalati-grasslands/far-impostor.png": 40285,
55
55
  "/assets/baked/nalati-grasslands/far.glb": 239660,
56
56
  "/assets/baked/nalati-grasslands/far.json": 957,
57
57
  "/assets/baked/nalati-grasslands/near.glb": 3863736,
@@ -440,6 +440,9 @@ export const PUBLIC_BYTES = {
440
440
  "/assets/gpu/tex/wood_trunk_wall/arm_1k.phone-b7f1d0ec.ktx2": 43664,
441
441
  "/assets/gpu/tex/wood_trunk_wall/diffuse-3e7ff479.ktx2": 4796570,
442
442
  "/assets/gpu/tex/wood_trunk_wall/nor_gl-e1b1ecf7.ktx2": 5098654,
443
+ "/assets/grid-road/road-asphalt-phone.ktx2": 211919,
444
+ "/assets/grid-road/road-junction-phone.ktx2": 385931,
445
+ "/assets/grid-road/road-surfaces.json": 1401,
443
446
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.gain.png": 50440,
444
447
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.hdr": 5451493,
445
448
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.sky.jpg": 350530,
@@ -27,11 +27,11 @@ export const ASSET_VERSIONS: Readonly<Record<string, string>> = {
27
27
  "/assets/baked/ink-cel-valley/far.json": 'b9e66797',
28
28
  "/assets/baked/ink-cel-valley/near.glb": '43ca8313',
29
29
  "/assets/baked/ink-cel-valley/near.json": '6ced2af8',
30
- "/assets/baked/nalati-grasslands/far-impostor.png": '287b5d00',
31
- "/assets/baked/nalati-grasslands/far.glb": '6eb862e9',
32
- "/assets/baked/nalati-grasslands/far.json": 'b4ca5b6e',
33
- "/assets/baked/nalati-grasslands/near.glb": '77836045',
34
- "/assets/baked/nalati-grasslands/near.json": '9351f72d',
30
+ "/assets/baked/nalati-grasslands/far-impostor.png": '6aaf713e',
31
+ "/assets/baked/nalati-grasslands/far.glb": '55ace39b',
32
+ "/assets/baked/nalati-grasslands/far.json": '1cfe0d1c',
33
+ "/assets/baked/nalati-grasslands/near.glb": '2587e107',
34
+ "/assets/baked/nalati-grasslands/near.json": '25180ae9',
35
35
  "/assets/baked/nine-dragon-stack/far-impostor.png": '408be760',
36
36
  "/assets/baked/nine-dragon-stack/far.glb": '55623550',
37
37
  "/assets/baked/nine-dragon-stack/far.json": '0f4bcd2f',
@@ -147,6 +147,9 @@ export const ASSET_VERSIONS: Readonly<Record<string, string>> = {
147
147
  "/assets/far-reach/tex/mill-stone.webp": '5b09fa4f',
148
148
  "/assets/far-reach/tex/rock.webp": 'ed684c0d',
149
149
  "/assets/far-reach/tex/stormeye.webp": 'a8f28043',
150
+ "/assets/grid-road/road-asphalt-phone.ktx2": '1f9a805a',
151
+ "/assets/grid-road/road-junction-phone.ktx2": 'a94834d6',
152
+ "/assets/grid-road/road-surfaces.json": 'b291e0c8',
150
153
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.gain.png": '04afee5b',
151
154
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.hdr": '5244534e',
152
155
  "/assets/hdri/kloofendal_48d_partly_cloudy_puresky_2k.sky.jpg": 'dad57443',
@@ -87,9 +87,10 @@ export function pageArenaRoomFight(ctx: ShardContext, dungeon: BossArenaRoom, in
87
87
  const { animals } = play, owner = bindRuntimeBoss(ctx, ctx.product.shardfile, rows.body, undefined, { identity: rows.identity }), binding = views(rows.presentation);
88
88
  // The server's fight runs, and its looks reach this room as it told them. A room nobody has entered has nothing built to draw on.
89
89
  wirePage.whenLive(ctx.scope, client => client.onView(({ name, args }) => {
90
- if (!dungeon.built) return;
90
+ if (!dungeon.built) { if (binding[name] !== undefined) wirePage.unbuilt(name); return; }
91
91
  if (name === 'boss.glow') dungeon.actor = animals.animals.find(actor => actor.rowDriven && actor.kind === owner.row.kind) ?? null; // the server's body is the row's
92
- binding[name]?.(...args);
92
+ const draw = binding[name];
93
+ if (draw !== undefined) { draw(...args); wirePage.drew(name); }
93
94
  }));
94
95
  return rowFightScript({ rewardPoint: () => new Vector3().fromArray(rows.reward), respawnPoint: () => ({ pos: new Vector3().fromArray(rows.respawn), yaw: rows.yaw }) });
95
96
  }
@@ -204,7 +205,7 @@ export class ArenaRoomEncounter {
204
205
  if(encounter.boss.rewardTaken)kit.upgradeBow('bow-reward',play.weapons);
205
206
  }else{
206
207
  if(this.prompt===null||this.projection===null)throw new Error('Missing open arena projection');runtime.interactables.push(this.prompt);
207
- {const word=arenaTieWord(this.data.definition.id),lines=this.data.tieLines,heard=this.projection;wirePage.whenLive(ctx.scope,client=>client.onView(({name,args})=>{const line=name===word?lines[args[0]??-1]:undefined;if(line!==undefined)play.hud.toast(line);if(name.startsWith('open-arena.')){heard.hear(name,args);wirePage.drew(name);}}));}
208
+ {const word=arenaTieWord(this.data.definition.id),lines=this.data.tieLines,heard=this.projection;wirePage.whenLive(ctx.scope,client=>client.onView(({name,args})=>{const line=name===word?lines[args[0]??-1]:undefined;if(line!==undefined){play.hud.toast(line);wirePage.drew(name);}if(name.startsWith('open-arena.')){heard.hear(name,args);wirePage.drew(name);}}));}
208
209
  if(encounter.boss.rewardTaken){if(blade===null)throw new Error('Missing open arena power');kit.upgradeBlade('blade-reward',play.weapons,blade);}
209
210
  page.boundary(ctx.scope,this.projection.boundary);page.lendOpenView(this.projection,ctx.scope);
210
211
  }
@@ -101,7 +101,7 @@ function followRoamingFight(context: ShardContext, { rows, ring, hazard, cues, l
101
101
  hazardFrom.set(fromX, fromY, fromZ); hazard(index, { x, y, z, fallT }, t, beat);
102
102
  },
103
103
  };
104
- wirePage.whenLive(context.scope, client => client.onView(({ name, args }) => { actions[name]?.(args); }));
104
+ wirePage.whenLive(context.scope, client => client.onView(({ name, args }) => { const act = actions[name]; if (act !== undefined) { act(args); wirePage.drew(name); } }));
105
105
  context.system({ id: 'roaming.followed', phase: 'update', run: (dt, t) => {
106
106
  room(dt, t);
107
107
  for (const [slot, row] of lanes.entries()) {
@@ -241,7 +241,7 @@ export function createDevHook(ports: DevHookPorts): DevHook & { readonly root: T
241
241
  group.add(lamps);
242
242
  owned.push({ dispose: () => { for (const light of lamps.children) if (light instanceof THREE.Light) light.dispose(); } });
243
243
  const { update } = lamps;
244
- if (update !== null) { let time = 0; partScope.onDispose(ports.watchFrames(dt => { time += dt; update(time); })); }
244
+ if (update !== null) { let time = 0; partScope.onDispose(ports.watchFrames(dt => { time += dt; update(time, ports.player?.()?.position); })); }
245
245
  }
246
246
  // the client's own water surfaces, under this part's scope
247
247
  installClientWater(part.water, { root: group, scope: partScope, frame: run => { partScope.onDispose(ports.watchFrames(run)); } });
@@ -16,6 +16,6 @@ export function shardfileLiveLook(look: Shardfile['look'], light: boolean = look
16
16
  return { day: look.day ?? DATA_LOOK_DAY, dayOverride: look.dayOverride, keys: look.keys, lut: look.grade.lut === null ? null : shardfileFileUrl(look.grade.lut),
17
17
  neutral: look.grade.tone === 'neutral', aces: look.grade.tone === 'aces', exposure: look.grade.exposure, vignette: look.grade.vignette ?? null, bloomRadius: resolved.bloom.radius,
18
18
  bloom: resolved.bloom,
19
- light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, bounce: resolved.bounce, environment: resolved.environment,
19
+ light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, lampsLit: resolved.lampsLit, bounce: resolved.bounce, environment: resolved.environment,
20
20
  shadow: resolved.shadow, motes: resolved.motes } };
21
21
  }
@@ -100,6 +100,60 @@ function copySpheres(sphere: Sphere, m: ArrayLike<number>, count: number, target
100
100
  return target;
101
101
  }
102
102
 
103
+ /** ZE2: an instanced or batched draw's XZ bounds for the cell test, exact only where it matters. Each copy's bounding sphere,
104
+ * moved by its instance matrix and the draw's world matrix, settles a copy well inside the cell; only a copy whose sphere
105
+ * crosses takes its exact box (its geometry's box through both matrices). The union is inside exactly when every copy's exact
106
+ * box is, as three's whole walk (`computeBoundingBox`, eight corners of every copy) would say, without the walk: a forest
107
+ * re-choosing its copies as the feet came back in from the road re-walked thousands (46 to 75 ms of Pine's edge frame). */
108
+ interface CopyScratch { readonly box: Box3; readonly copy: Matrix4; readonly composed: Matrix4; readonly sphere: Sphere; readonly local: Box3 }
109
+ function worldScale(world: Matrix4): number {
110
+ const w = world.elements;
111
+ return Math.sqrt(Math.max(w[0] * w[0] + w[1] * w[1] + w[2] * w[2], w[4] * w[4] + w[5] * w[5] + w[6] * w[6], w[8] * w[8] + w[9] * w[9] + w[10] * w[10]));
112
+ }
113
+ /** One copy (its matrix at `o` in `m`) into `target`: its sphere's XZ box when inside, else its exact box. */
114
+ function addCopy(local: Box3, sphere: Sphere, m: ArrayLike<number>, o: number, world: Matrix4, scale: number, inside: (bounds: Box3) => boolean,
115
+ target: Box3, scratch: CopyScratch): void {
116
+ const w = world.elements, cx = sphere.center.x, cy = sphere.center.y, cz = sphere.center.z;
117
+ const a0 = m[o] ?? 0, a1 = m[o + 1] ?? 0, a2 = m[o + 2] ?? 0, a4 = m[o + 4] ?? 0, a5 = m[o + 5] ?? 0, a6 = m[o + 6] ?? 0;
118
+ const a8 = m[o + 8] ?? 0, a9 = m[o + 9] ?? 0, a10 = m[o + 10] ?? 0;
119
+ const k = sphere.radius * scale * Math.sqrt(Math.max(a0 * a0 + a1 * a1 + a2 * a2, a4 * a4 + a5 * a5 + a6 * a6, a8 * a8 + a9 * a9 + a10 * a10));
120
+ const x = a0 * cx + a4 * cy + a8 * cz + (m[o + 12] ?? 0), y = a1 * cx + a5 * cy + a9 * cz + (m[o + 13] ?? 0), z = a2 * cx + a6 * cy + a10 * cz + (m[o + 14] ?? 0);
121
+ const wx = w[0] * x + w[4] * y + w[8] * z + w[12], wz = w[2] * x + w[6] * y + w[10] * z + w[14], box = scratch.box;
122
+ box.min.set(wx - k, 0, wz - k); box.max.set(wx + k, 0, wz + k);
123
+ if (!inside(box)) projectBounds(local, scratch.composed.multiplyMatrices(world, scratch.copy.fromArray(m, o)), box);
124
+ target.union(box);
125
+ }
126
+ function copyBounds(local: Box3, sphere: Sphere, m: ArrayLike<number>, count: number, world: Matrix4, inside: (bounds: Box3) => boolean,
127
+ target: Box3, scratch: CopyScratch): Box3 {
128
+ target.makeEmpty();
129
+ if (sphere.radius < 0 || local.isEmpty()) return target;
130
+ const scale = worldScale(world);
131
+ for (let i = 0; i < count; i++) addCopy(local, sphere, m, i * 16, world, scale, inside, target, scratch);
132
+ return target;
133
+ }
134
+ /** A batched draw's copies the same way (three's `BatchedMesh.computeBoundingBox` walks every active one); null when its
135
+ * instance table is not the shape this reads, for the whole walk to decide. */
136
+ function batchedBounds(node: BatchedMesh, inside: (bounds: Box3) => boolean, target: Box3, scratch: CopyScratch): Box3 | null {
137
+ const info: unknown = Reflect.get(node, '_instanceInfo'), texture: unknown = Reflect.get(node, '_matricesTexture');
138
+ const data: unknown = typeof texture === 'object' && texture !== null ? Reflect.get(Reflect.get(texture, 'image') ?? {}, 'data') : undefined;
139
+ if (!Array.isArray(info) || !(data instanceof Float32Array)) return null;
140
+ target.makeEmpty();
141
+ const world = node.matrixWorld, scale = worldScale(world), shapes = new Map<number, { sphere: Sphere; local: Box3 } | null>();
142
+ for (let i = 0; i < info.length; i++) {
143
+ const row: unknown = info[i];
144
+ if (typeof row !== 'object' || row === null || Reflect.get(row, 'active') === false) continue;
145
+ const id: unknown = Reflect.get(row, 'geometryIndex');
146
+ if (typeof id !== 'number') return null;
147
+ let shape = shapes.get(id);
148
+ if (shape === undefined) {
149
+ const sphere = node.getBoundingSphereAt(id, new Sphere()), local = node.getBoundingBoxAt(id, new Box3());
150
+ shape = sphere === null || local === null || local.isEmpty() ? null : { sphere, local }; shapes.set(id, shape);
151
+ }
152
+ if (shape !== null) addCopy(shape.local, shape.sphere, data, i * 16, world, scale, inside, target, scratch);
153
+ }
154
+ return target;
155
+ }
156
+
103
157
  /** Exact affine XZ projection of an AABB. Height contributes through rotated
104
158
  * axes but has no clipping plane. Unusual projective object matrices keep the
105
159
  * general eight-corner path. */
@@ -130,6 +184,7 @@ const _joint = new Vector3();
130
184
  /** Clip edge-crossing draws at the exact inclusive cell edge. No road-band or dome exemption. */
131
185
  export function cellClip(root: Object3D, half: number, scope: Scope, options: CellClipOptions = {}): CellClip {
132
186
  const cell = { value: new Vector4(-half, -half, half, half) }, origin = new Vector3(), box = new Box3(), camera = { value: new Matrix4() }, submittedWorld = new Matrix4(), alternate = new Box3();
187
+ const copies: CopyScratch = { box: new Box3(), copy: new Matrix4(), composed: new Matrix4(), sphere: new Sphere(), local: new Box3() };
133
188
  root.updateWorldMatrix(true, false); origin.setFromMatrixPosition(root.matrixWorld);
134
189
  if (!Number.isFinite(origin.x) || !Number.isFinite(origin.z)) throw new Error('Cell origin is not finite');
135
190
  cell.value.set(origin.x - half, origin.z - half, origin.x + half, origin.z + half);
@@ -281,13 +336,22 @@ export function cellClip(root: Object3D, half: number, scope: Scope, options: Ce
281
336
  if (!(node instanceof InstancedMesh) || !(sphere instanceof Sphere)
282
337
  || !within(projectBounds(copySpheres(sphere, node.instanceMatrix.array, node.count, alternate), node.matrixWorld, box))) {
283
338
  const walked = node instanceof InstancedMesh ? instanceWalks.get(node) : undefined;
284
- if (node.boundingBox === null || !(node instanceof InstancedMesh) || walked === undefined || walked.geometry !== node.geometry
285
- || walked.version !== node.instanceMatrix.version || walked.count !== node.count) {
286
- node.computeBoundingBox();
287
- if (node instanceof InstancedMesh) instanceWalks.set(node, { geometry: node.geometry, version: node.instanceMatrix.version, count: node.count });
339
+ const affine = node.matrixWorld.elements[3] === 0 && node.matrixWorld.elements[7] === 0 && node.matrixWorld.elements[11] === 0 && node.matrixWorld.elements[15] === 1;
340
+ if (shape instanceof BufferGeometry && shape.boundingBox === null) shape.computeBoundingBox();
341
+ const local: unknown = shape instanceof BufferGeometry ? shape.boundingBox : null;
342
+ if (node instanceof InstancedMesh && sphere instanceof Sphere && local instanceof Box3 && affine) {
343
+ copyBounds(local, sphere, node.instanceMatrix.array, node.count, node.matrixWorld, within, box, copies);
344
+ } else if (node instanceof BatchedMesh && affine && batchedBounds(node, within, box, copies) !== null) {
345
+ // decided copy by copy (batchedBounds), as an instanced draw is
346
+ } else {
347
+ if (node.boundingBox === null || !(node instanceof InstancedMesh) || walked === undefined || walked.geometry !== node.geometry
348
+ || walked.version !== node.instanceMatrix.version || walked.count !== node.count) {
349
+ node.computeBoundingBox();
350
+ if (node instanceof InstancedMesh) instanceWalks.set(node, { geometry: node.geometry, version: node.instanceMatrix.version, count: node.count });
351
+ }
352
+ if (node.boundingBox === null) throw new Error('Cell draw has no instance bounds');
353
+ projectBounds(node.boundingBox, node.matrixWorld, box);
288
354
  }
289
- if (node.boundingBox === null) throw new Error('Cell draw has no instance bounds');
290
- projectBounds(node.boundingBox, node.matrixWorld, box);
291
355
  }
292
356
  } else {
293
357
  if (node.geometry.boundingBox === null) for (const _step of geometryBoundsSteps(node.geometry, 'box')) { /* exact admission scan */ }
@@ -17,7 +17,7 @@ import { EquipmentService } from '@wildshard/engine/combat/EquipmentService';
17
17
  import type { Weapon } from '@wildshard/engine/combat/Weapon';
18
18
  import { playerModes } from '@wildshard/engine/player/modes';
19
19
  import type { Shardfile } from '@wildshard/format/shardSchema';
20
- import { installDeclaredItems, leverLines } from '../../../shared/game/shardfile/items';
20
+ import { installDeclaredItems, leverLines, rackMeleeRows, takenLine } from '../../../shared/game/shardfile/items';
21
21
  import { declaredItemIcon, declaredKitItemFamilies, declaredLever } from '../plugin/weaponFamily';
22
22
  import { itemScene } from '../shardfile/clientItems';
23
23
  import { loadItemModels } from '../shardfile/itemModels';
@@ -76,6 +76,10 @@ export async function enterDataCellKit(source: Shardfile, assets: ReadonlyMap<st
76
76
  kit.enabled = enabled; kit.visible = visible; kit.stowed = false;
77
77
  // TE-ENG2: a lever follows the server's owned lines; taken, it unlocks and comes to hand
78
78
  const levers = weapons.flatMap(weapon => { const lever = declaredLever(weapon); return lever === null ? [] : [lever]; });
79
+ // TEMPLATE-E2E TC-E4: a melee weapon on a rack follows its owned taken line the same way
80
+ // the server's set exactly (never the loadout primary). A kit with no primary whose first weapon is racked still draws it
81
+ // in hand (a kit cannot lock its first); the server refuses its blows until it is taken
82
+ const onRacks = rackMeleeRows(source), racked = new Set(weapons.filter(weapon => onRacks.has(weapon.id)));
79
83
  app.addContentSystem({ id: 'grid.data-cell-kit', phase: 'update', run: (dt, t) => {
80
84
  for (const lever of levers) {
81
85
  if (wirePage.client !== null && here()) {
@@ -84,6 +88,10 @@ export async function enterDataCellKit(source: Shardfile, assets: ReadonlyMap<st
84
88
  }
85
89
  if (lever.taken && !kit.has(lever.id)) { kit.unlock(lever.id); kit.select(lever.id); }
86
90
  }
91
+ if (wirePage.client !== null && here()) for (const weapon of racked) {
92
+ if (wirePage.line(takenLine(weapon.id)) <= 0) continue;
93
+ racked.delete(weapon); if (!kit.has(weapon.id)) { kit.unlock(weapon.id); kit.select(weapon.id); }
94
+ }
87
95
  kit.update(dt, t);
88
96
  } }, entry);
89
97
  entry.onDispose(() => { kit.enabled = false; kit.visible = false; kit.adsHeld = false; kit.altHeld = false; });
@@ -0,0 +1,9 @@
1
+ /* ZE8: the gate card, in Shard Select's card language (glass, cyan line, mono), standing on the gate's face */
2
+ .ws-gate-card { position: fixed; left: 0; top: 0; z-index: calc(var(--ws-layer-hud) + 30); pointer-events: none; width: 220px; padding: 14px 16px 16px; text-align: center; transform-origin: 50% 100%;
3
+ background: var(--ws-glass-deep, rgba(9, 22, 36, 0.88)); border: 1px solid var(--ws-cyan-line, rgba(143, 227, 255, 0.4)); color: var(--ws-text, #e8f6ff);
4
+ font-family: var(--ws-mono, ui-monospace, monospace); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.45);
5
+ -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2); }
6
+ .ws-gate-card[hidden] { display: none; }
7
+ .ws-gate-card .ws-gate-name { font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
8
+ .ws-gate-card .ws-gate-line { margin-top: 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }
9
+ .ws-gate-card .ws-gate-count { margin-top: 8px; font-size: 44px; line-height: 1; color: var(--ws-cyan, #38e6ff); }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ZONE-ENTRY ZE8 (J352): the gate card. Feet in a walled cell's buffer show it on that buffer's gate: the shard's name, "Preparing
3
+ * to enter" and the count (`GateCount`). It is a crisp DOM card in Shard Select's card style, pinned each frame to the gate's face
4
+ * through the camera and scaled with distance, so it reads as standing in the world (board pick A), never G578's blurry canvas
5
+ * panel. A cell the device can't enter shows its reason in place of the count (ZE14). No button: standing there is the yes.
6
+ */
7
+ import { Vector3, type Camera } from 'three';
8
+ import type { Scope } from '@wildshard/engine/app/scope';
9
+ import { CHUNK_HALF } from '@wildshard/engine/core/config';
10
+ import { GAME_STRINGS } from '../../../shared/game/strings';
11
+ import { BUFFER_DEPTH } from '../../../shared/game/grid/zoneWalls';
12
+ import './gateCard.css';
13
+
14
+ /** The card's height on the gate (metres above the road) and the distance it is drawn at its full size. */
15
+ const LIFT = 2.6, FULL_AT = 9;
16
+
17
+ export interface GateCardView {
18
+ /** the gate's cell centre in the render frame, and the feet there: the gate faced is the side nearest the feet */
19
+ readonly centre: { readonly x: number; readonly z: number };
20
+ readonly feet: { readonly x: number; readonly z: number };
21
+ readonly name: string;
22
+ readonly count: number;
23
+ /** why the cell can't be entered from here, shown in place of the count */
24
+ readonly reason?: string | null;
25
+ }
26
+
27
+ export class GateCard {
28
+ readonly root: HTMLElement;
29
+ private readonly name: HTMLElement;
30
+ private readonly count: HTMLElement;
31
+ private readonly at = new Vector3();
32
+ private shown: string | null = null;
33
+
34
+ constructor(scope: Scope, parent: HTMLElement = document.body) {
35
+ const root = this.root = document.createElement('div');
36
+ root.className = 'ws-gate-card'; root.hidden = true; root.setAttribute('role', 'status');
37
+ this.name = document.createElement('div'); this.name.className = 'ws-gate-name';
38
+ const line = document.createElement('div'); line.className = 'ws-gate-line'; line.textContent = GAME_STRINGS.grid.gatePreparing;
39
+ this.count = document.createElement('div'); this.count.className = 'ws-gate-count';
40
+ root.append(this.name, line, this.count); parent.append(root);
41
+ scope.onDispose(() => { root.remove(); });
42
+ }
43
+
44
+ /** Pin the card to its gate, or hide it with `null`. */
45
+ show(view: GateCardView | null, camera: Camera | undefined, width: number, height: number): void {
46
+ if (view === null || camera === undefined) { this.hide(); return; }
47
+ const dx = view.feet.x - view.centre.x, dz = view.feet.z - view.centre.z, alongX = Math.abs(dx) >= Math.abs(dz);
48
+ const face = CHUNK_HALF - BUFFER_DEPTH - 0.3;
49
+ this.at.set(view.centre.x + (alongX ? Math.sign(dx) * face : 0), LIFT, view.centre.z + (alongX ? 0 : Math.sign(dz) * face));
50
+ const distance = Math.max(0.5, this.at.distanceTo(camera.position));
51
+ this.at.project(camera);
52
+ if (this.at.z > 1 || Math.abs(this.at.x) > 1.4 || Math.abs(this.at.y) > 1.4) { this.hide(); return; }
53
+ const key = `${view.name}|${String(view.count)}|${view.reason ?? ''}`;
54
+ if (key !== this.shown) {
55
+ this.shown = key; this.name.textContent = view.name;
56
+ this.count.textContent = view.reason ?? String(Math.max(1, view.count));
57
+ }
58
+ const scale = Math.min(1.2, Math.max(0.45, FULL_AT / distance));
59
+ const x = (this.at.x * 0.5 + 0.5) * width, y = (-this.at.y * 0.5 + 0.5) * height;
60
+ this.root.style.transform = `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) translate(-50%, -100%) scale(${scale.toFixed(3)})`;
61
+ this.root.hidden = false;
62
+ }
63
+
64
+ hide(): void { if (this.root.hidden !== true) this.root.hidden = true; this.shown = null; }
65
+ /** the card's text while shown (proofs read it) */
66
+ get text(): string | null { return this.root.hidden === true ? null : `${this.name.textContent ?? ''} ${this.count.textContent ?? ''}`; }
67
+ }
@@ -72,6 +72,10 @@ export interface LiveGridPorts {
72
72
  /** Keep only the last departed isolated world on the road. Its original
73
73
  * full claim stays unneeded/evictable; no new world may overlap it. */
74
74
  lastCell?: { readonly windowMs: number; readonly playingBytes: number;
75
+ /** ZE3 / ZE21 (J352): the owned home, once departed onto the road, has no time expiry: it stays resident, and needed (never
76
+ * a pressure eviction), while the traveller is within this many metres of it (the page passes Infinity: the whole road),
77
+ * and is retired before any other cell's allocation. Absent: every cell expires. */
78
+ readonly keepHome?: number;
75
79
  readonly schedule: (expire: () => void, delayMs: number) => () => void };
76
80
  /** G580 T2: told once before a resident's retirement or unload disposes its world, so its compiled programs can be kept
77
81
  * for the next world; never refuses a retirement. Absent keeps nothing. */
@@ -142,7 +146,9 @@ export class LiveGridHost {
142
146
  private readonly highway: LiveGridHighway;
143
147
  private sequence: Promise<void> = Promise.resolve();
144
148
  private active: string | null;
145
- private lastCell: { readonly instance: string; readonly until: number; cancel: () => void } | null = null;
149
+ /** `pinned`: the owned home kept on the road (ZE21): needed while kept, so allocator pressure (a neighbour's tiles or
150
+ * products) is refused rather than evicting it. */
151
+ private lastCell: { readonly instance: string; readonly until: number; readonly pinned: boolean; cancel: () => void } | null = null;
146
152
  private disposed = false;
147
153
  /** Each checkpoint of an instance takes a generation; a staged one still waiting is superseded by any later one. */
148
154
  private highwayDisposed = false;
@@ -388,8 +394,13 @@ export class LiveGridHost {
388
394
  } catch { return false; }
389
395
  }
390
396
  this.forgetLastCell();
391
- const last = { instance, until: diagnosticNow() + policy.windowMs, cancel: (): void => undefined };
397
+ const kept = policy.keepHome !== undefined && instance === this.ports.home.instance && this.distance(this.assembly.cell(instance)) <= policy.keepHome;
398
+ const last = { instance, until: kept ? Number.POSITIVE_INFINITY : diagnosticNow() + policy.windowMs, pinned: kept, cancel: (): void => undefined };
392
399
  this.lastCell = last;
400
+ if (kept) {
401
+ resident.lease.update({ needed: true, distance: this.distance(this.assembly.cell(instance)) });
402
+ return true;
403
+ }
393
404
  try {
394
405
  last.cancel = policy.schedule(() => {
395
406
  if (this.lastCell !== last) return;
@@ -406,11 +417,14 @@ export class LiveGridHost {
406
417
  * A different actual entry retires the departure before any new allocation. */
407
418
  private retireInactiveRegions(destination?: string): boolean {
408
419
  const last = this.lastCell;
420
+ const keep = this.ports.lastCell?.keepHome;
409
421
  if (last !== null && (diagnosticNow() >= last.until || !this.retainedFits(last.instance)
422
+ || keep !== undefined && last.instance === this.ports.home.instance && this.distance(this.assembly.cell(last.instance)) > keep
410
423
  || this.active !== null || destination !== undefined && destination !== last.instance)) this.forgetLastCell();
411
424
  let released = true;
412
425
  for (const [instance, resident] of this.residents) {
413
- const needed = instance === this.active || instance === destination || instance === this.ahead || this.requests.has(instance) || resident.reservations > 0;
426
+ const needed = instance === this.active || instance === destination || instance === this.ahead || this.requests.has(instance) || resident.reservations > 0
427
+ || this.lastCell?.instance === instance && this.lastCell.pinned;
414
428
  resident.lease.update({ distance: this.distance(this.assembly.cell(instance)), needed: needed || resident.disposalFailed === true });
415
429
  if (needed || this.lastCell?.instance === instance) continue;
416
430
  if (resident.disposalFailed === true || resident.evicting || this.coldUnloadRefused.has(instance)) { released = false; continue; }
@@ -50,7 +50,7 @@ import type { ResidencyAllocator } from '../../../shared/game/grid/allocator';
50
50
  import type { HomeResidencyClaim } from './pageResidency';
51
51
  import { LiveGridHost, type LiveGridAdmission, type LiveGridFrame, type LiveGridRegion, type LiveGridState } from './live';
52
52
  import { installGridCrossing, type GridCheckpointResult, type GridCrossingSession, type GridCrossingState } from '../../../shared/game/grid/crossing';
53
- import { GridWallet, stowGridMount } from '../../../shared/game/grid/wallet';
53
+ import { GridWallet, stowGridMount, type GridLoadout } from '../../../shared/game/grid/wallet';
54
54
  import type { LedgerCatalogueItem } from '../../../shared/game/ledger';
55
55
  import { installGridHoverSpeed } from '../../../shared/game/grid/rules';
56
56
  import { installGridTravellerCombat } from '../../../shared/game/grid/travellerCombat';
@@ -194,6 +194,11 @@ const HIGHWAY_QUERIES: PlayerFrameQueries = { heightAt: () => 0, waterSurfaceAt:
194
194
  export interface LiveGridSpawn { readonly x: number; readonly y: number | undefined; readonly z: number; readonly yaw: number }
195
195
 
196
196
  /** The platform travel envelope at the deck's 30 m/s; a shardfile's critical bundle is its declared compressed sim. */
197
+ /** ZE21 (Jake, 2026-11-15 ~16:50 Cancún: "Having the home cell in memory when your 10m away 100m or 300m away shouldnt
198
+ * matter, 1000m away shouldnt matter"): the owned home stays resident for the whole road. Measured on the laptop (desktop,
199
+ * 2992x1434@2), the home is ~216 MB of real GPU and RAM; the envelope was filled by neighbours' tile products and the cost
200
+ * model's fixed shares, which now yield to it (`keepHome`). */
201
+ const HOME_KEEP_METRES = Number.POSITIVE_INFINITY;
197
202
  const LINK: ReadinessLink = { speed: 30, linkBitsPerSecond: 5_000_000, requestLatencySeconds: 0.25, maxStallSeconds: 10 };
198
203
 
199
204
  /** G598: a preparation that fails (or a road approach abandoned for another crossing, T7) frees its half-built region as a
@@ -297,7 +302,7 @@ export class LiveGridSession {
297
302
  const highwayBytes = (ports.initialStripBytes ?? ports.strips.reduce((sum, strip) => sum + strip.mesh.positions.byteLength + strip.mesh.indices.byteLength, 0))
298
303
  + assembly.cells.length * TRANSFER_WALL_BYTES;
299
304
  try { this.live = new LiveGridHost(assembly, {
300
- lastCell: { windowMs: 30_000, playingBytes: ports.allocator.envelope(), schedule: (expire, ms) => {
305
+ lastCell: { windowMs: 30_000, playingBytes: ports.allocator.envelope(), keepHome: HOME_KEEP_METRES, schedule: (expire, ms) => {
301
306
  const timer = scope.child('grid.last-cell-expiry');
302
307
  timer.timeout(ms, () => { timer.dispose(); scope.run(expire); });
303
308
  return () => { timer.dispose(); };
@@ -407,12 +412,17 @@ export class LiveGridSession {
407
412
  }, target: (feet) => this.wire === null ? this.live.target(feet) : this.wireTarget() },
408
413
  this.ports.assembly, (instance) => {
409
414
  const runtime = this.runtimeRegions.get(instance), flush = (): boolean => true;
410
- if (runtime === undefined) return { checkpoint: flush, stow: () => { stowGridMount(this.page.traveller); }, interior: () => undefined };
411
- if (this.wire !== null) return { ...runtime.loadout, checkpoint: flush };
415
+ if (runtime === undefined) return { checkpoint: flush, stow: () => { this.keepPrograms('home-edge:cell'); stowGridMount(this.page.traveller); }, interior: () => { this.keepPrograms('home-edge:road'); } };
416
+ // ZE2: the home edge swaps the lights, shadows and kit drawn, so three moves every material to another program key
417
+ // and releases the old one; walking back linked it again on the edge frame (Pine 133 to 650 ms, every lap). Each side's
418
+ // programs are pinned as the feet leave it, so the way back finds them compiled.
419
+ const edge = (loadout: GridLoadout): GridLoadout => ({ ...loadout, stow: () => { this.keepPrograms('home-edge:cell'); loadout.stow(); },
420
+ interior: () => { this.keepPrograms('home-edge:road'); loadout.interior(); } });
421
+ if (this.wire !== null) return edge({ ...runtime.loadout, checkpoint: flush });
412
422
  // rt3-crossing2: a committed runtime the traveller never entered never ran its hooks and never played: it saves as
413
423
  // the stored resident. Its own checkpoint refuses until its hooks restore, so turning back on the strip after the
414
424
  // commit held the crossing in save-failed for good.
415
- return this.startedRuntimes.has(instance) ? runtime.loadout : { ...runtime.loadout, checkpoint: flush };
425
+ return edge(this.startedRuntimes.has(instance) ? runtime.loadout : { ...runtime.loadout, checkpoint: flush });
416
426
  }, this.ports.scope, (from, to) => {
417
427
  if (to !== null || from === null) return;
418
428
  const leaveStart = diagnosticNow();
@@ -93,6 +93,10 @@ export class NeighbourLife {
93
93
  const { mesh, bones } = skinMesh(skin), driver = new SkinDriver(skin, bones);
94
94
  const view: CreatureView = { id, mesh, driver, spawn: { at: spawn.at, yaw: spawn.yaw, scale: spawn.scale }, bodyY: species.dims.bodyY * spawn.scale, t: (spawn.seed % 97) / 13, phase: 0 };
95
95
  mesh.position.set(spawn.at[0], spawn.at[1], spawn.at[2]); mesh.rotation.set(0, spawn.yaw, 0, 'YXZ'); mesh.scale.setScalar(spawn.scale);
96
+ // ZE3a: hidden from birth unless its cell is the active one: an admission that resolves between the late phase (which
97
+ // hides a frozen cell's creatures) and the draw drew them once, and that draw linked their programs on the frame (a
98
+ // neighbour's barrow warden, 114 ms, on the laptop's whole-road drive past an open plot, 2026-11-15)
99
+ mesh.visible = this.ports.active(cell.instance);
96
100
  root.add(mesh); creatures.set(id, view);
97
101
  }
98
102
  const instance = cell.instance;
@@ -130,7 +134,11 @@ export class NeighbourLife {
130
134
  const object: Object3D | null = view?.mesh ?? null;
131
135
  return { entity, object, anchor, emitters };
132
136
  });
133
- return { scripts, views: new ClientScriptViews(scripts.lane, targets, { root, scope: this.ports.scope }) };
137
+ const views = new ClientScriptViews(scripts.lane, targets, { root, scope: this.ports.scope });
138
+ // ZE3a: its particles too, hidden from birth unless its cell is active (ink-cel-valley's pool linked its program for 65 ms
139
+ // on the road, 2026-11-15)
140
+ views.show(this.ports.active(instance));
141
+ return { scripts, views };
134
142
  } catch (error) { scripts.dispose(); throw error; }
135
143
  }
136
144
 
@@ -150,6 +158,7 @@ export class NeighbourLife {
150
158
  life.lane?.views.restore();
151
159
  const region = this.ports.simulation(life.cell.instance), live = this.ports.active(life.cell.instance);
152
160
  // G663: a frozen cell draws none of its creatures and composes no lane
161
+ life.lane?.views.show(live);
153
162
  if (!live) { for (const view of life.creatures.values()) view.mesh.visible = false; continue; }
154
163
  for (const view of life.creatures.values()) {
155
164
  const sim = region?.host.entities.get(view.id);
@@ -8,11 +8,13 @@
8
8
  *
9
9
  * Presentation only: nothing here writes a simulation, a field or a collider.
10
10
  */
11
- import type { Group, Object3D } from 'three';
11
+ import { Euler, Matrix4, Quaternion, Vector3, type Group, type Object3D } from 'three';
12
+ import type { MoverPose } from '@wildshard/engine/physics/mover';
12
13
  import type { ClientTileViews } from '../shardfile/clientViews';
13
14
  import type { Shardfile } from '@wildshard/format/shardSchema';
14
15
  import type { GridCell } from '../../../shared/game/grid/assembly';
15
16
  import type { ProbeAreaTarget } from '@wildshard/engine/debug/probe';
17
+ import { wirePage } from '../shardfile/wirePage';
16
18
 
17
19
  /** What the panels read of a cell the live host has admitted: the solids of its world, and a field's row where this page has one. */
18
20
  export interface PanelRegion { readonly colliders: ReadonlyMap<string, { readonly active: () => boolean; readonly setActive: (active: boolean) => void }>; readonly field: (name: string) => number | undefined }
@@ -38,6 +40,23 @@ export function targetMatched(row: TargetRow, fallback: number, region: PanelReg
38
40
  return ((field === undefined ? undefined : region?.field(field.name)) ?? fallback) === row.equals;
39
41
  }
40
42
 
43
+ /** TEMPLATE-E2E TC-E5b: pose a mover's panel. The panel was baked where the mover rests (its `at` and `euler`), so each
44
+ * pose sets the panel to (pose) x (rest)^-1 x (its baked transform): it turns about the mover's own origin, as the server's
45
+ * body does. Presentation only: the mover's collider is the server's. */
46
+ export function moverPanelPose(panel: Object3D, rest: { readonly at: { x: number; y: number; z: number }; readonly euler: { x: number; y: number; z: number } }): (pose: MoverPose) => void {
47
+ const one = new Vector3(1, 1, 1), euler = new Euler(0, 0, 0, 'YXZ'), q = new Quaternion(), at = new Vector3();
48
+ panel.updateMatrix();
49
+ const baked = panel.matrix.clone(), restInverse = new Matrix4().compose(new Vector3(rest.at.x, rest.at.y, rest.at.z),
50
+ q.setFromEuler(euler.set(rest.euler.x, rest.euler.y, rest.euler.z, 'YXZ')).clone(), one).invert();
51
+ const now = new Matrix4();
52
+ return (pose) => {
53
+ now.compose(at.set(pose.position.x, pose.position.y, pose.position.z), q.setFromEuler(euler.set(pose.euler.x, pose.euler.y, pose.euler.z, 'YXZ')), one)
54
+ .multiply(restInverse).multiply(baked);
55
+ now.decompose(panel.position, panel.quaternion, panel.scale); panel.updateMatrix(); // a frame-floored root walks no matrices
56
+ panel.visible = pose.enabled;
57
+ };
58
+ }
59
+
41
60
  /** The page's neighbour panels: one set per shardfile neighbour whose targets show or hide a panel; disposed with the scope. */
42
61
  export class NeighbourPanels {
43
62
  private readonly ports: NeighbourPanelPorts;
@@ -47,7 +66,7 @@ export class NeighbourPanels {
47
66
  /** Draw one neighbour's declared panels in its cell root (the session's shared per-slug load supplies views and bytes). */
48
67
  async admit(cell: GridCell, root: Group, source: Shardfile, assets: ReadonlyMap<string, Uint8Array>, views: ClientTileViews): Promise<void> {
49
68
  const props = source.props;
50
- if (props === null || props.panels.length === 0 || source.targets.panels.length === 0 || this.cells.has(cell.instance)) return;
69
+ if (props === null || props.panels.length === 0 || source.targets.panels.length === 0 && source.movers.length === 0 || this.cells.has(cell.instance)) return;
51
70
  const panels = await views.panels(props, assets, root, this.ports.scope);
52
71
  if (this.ports.scope.disposed) return;
53
72
  // a panel's programs compile in the page's warm-up, off the drive's frames: hidden until then, then shown by sync
@@ -63,6 +82,14 @@ export class NeighbourPanels {
63
82
  });
64
83
  const cellPanels: CellPanels = { instance: cell.instance, source, bindings };
65
84
  this.cells.set(cell.instance, cellPanels);
85
+ // TEMPLATE-E2E TC-E5b: a mover's look is the props panel with its id; the wire's pose for it moves that panel
86
+ for (const row of source.movers) {
87
+ const panel = panels.get(row.id); if (panel === undefined) continue;
88
+ const view = { pose: moverPanelPose(panel, row) };
89
+ panel.visible = row.enabled; // drawn at rest until the wire poses it (review SHOULD)
90
+ wirePage.movers.set(row.id, view);
91
+ this.ports.scope.onDispose(() => { if (wirePage.movers.get(row.id) === view) wirePage.movers.delete(row.id); });
92
+ }
66
93
  this.sync(cellPanels);
67
94
  }
68
95
 
@@ -140,6 +140,27 @@ export function enterGrid(): void {
140
140
 
141
141
 
142
142
 
143
+ /** ZONE-ENTRY ZE10 (J352, Jake 2026-11-15: "you pop up the full loading screen, the same loading screen that you get in shard select
144
+ * [...] you've evicted the previous zone from memory, you've loaded a new zone into memory"): a gate's count reached 0. The page
145
+ * enters that cell as Shard select enters it: the full loading screen at once, then a fresh page whose home is the target (so its
146
+ * walls move), with a goto asking the world (or the in-page server, J311) to seat it there. The plan's marked-reload form: one world
147
+ * in memory by construction, the old home released with its document. */
148
+ export function enterZone(instance: string): void {
149
+ if (navigating !== null && !navigating.disposed) return;
150
+ const cell = new GridAssembly(gridMode(DEVSERVER)).cells.find(row => row.instance === instance), target = cell === undefined ? undefined : findTitleManifest(cell.slug);
151
+ if (cell === undefined || target === undefined) return; // a cell this build can't open stays behind its gate
152
+ const shown = gridDestination({ slug: target.slug }, target);
153
+ document.documentElement.style.setProperty('--ws-load-portrait', shown.art === '' ? 'none' : `url("${shown.art}")`);
154
+ startEntryDownload(target.slug, 'grid');
155
+ startGridStripDownload(gridMode(DEVSERVER), cell.instance, 'metadata');
156
+ navigating = beginNavigationShell(shown.name, pageScope, () => {
157
+ if (!gridRecovery(saves).clearLoop()) throw new Error('Grid recovery guard could not be cleared');
158
+ clearGridRecovery();
159
+ pageGridIntents().set({ instance: cell.instance, slug: target.slug, goto: true });
160
+ travel({ to: target.slug, mode: 'enter', shown });
161
+ }, null);
162
+ }
163
+
143
164
  /** The grid page's address: its path, and only the harness flags skipintro, mute and nolock, none of which selects a level, and `skipintro` dropped here sent a
144
165
  * `?chunk=<slug>&skipintro` link on a world build back under the title (OFFLINE OF18: every Open Plot in the offline proof). */
145
166
  export function gridPageUrl(href: string): URL {