@wildshard/engine 0.1.18 → 0.1.20

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 (334) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +18 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +19 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +33 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +83 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +284 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +126 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/land.mjs +2 -1
  56. package/scripts/live-prepush.py +3 -5
  57. package/scripts/loading-flow/benchmax.mjs +37 -12
  58. package/scripts/loading-flow/deskbench.mjs +276 -0
  59. package/scripts/loading-flow/stalls.d.mts +17 -3
  60. package/scripts/loading-flow/stalls.mjs +82 -3
  61. package/scripts/look-loop/test_look_loop.py +1 -38
  62. package/scripts/memory-proof.mjs +61 -6
  63. package/scripts/mmo-bots.mjs +8 -2
  64. package/scripts/net-lag-proof.mjs +219 -0
  65. package/scripts/night-market-kit-budget.mjs +2 -2
  66. package/scripts/nightly-model.ts +9 -6
  67. package/scripts/offline-proof-rules.d.mts +2 -2
  68. package/scripts/offline-proof-rules.mjs +15 -4
  69. package/scripts/offline-proof.mjs +80 -13
  70. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  71. package/scripts/page-release/content.d.mts +9 -1
  72. package/scripts/page-release/content.mjs +131 -17
  73. package/scripts/page-release/flow.mjs +36 -10
  74. package/scripts/page-release/stamp-content.mjs +24 -0
  75. package/scripts/page-release.mjs +28 -6
  76. package/scripts/page-size.mjs +2 -1
  77. package/scripts/parity/boot-smoke.mjs +13 -2
  78. package/scripts/pin-format.ts +5 -2
  79. package/scripts/pin-packs.ts +1 -1
  80. package/scripts/pins-reuse.d.mts +1 -0
  81. package/scripts/pins-reuse.mjs +22 -0
  82. package/scripts/pins.ts +4 -4
  83. package/scripts/precommit-checks.mjs +1 -7
  84. package/scripts/precommit-jobs.mjs +0 -1
  85. package/scripts/precommit-source.py +1 -9
  86. package/scripts/program-discovery.mjs +1 -1
  87. package/scripts/ring-cook.mjs +2 -1
  88. package/scripts/ring-step.ts +1 -1
  89. package/scripts/scratch-dir.mjs +95 -0
  90. package/scripts/scratch-sweep.mjs +182 -0
  91. package/scripts/script-scenario-metrics.mjs +1 -1
  92. package/scripts/shard-output-content.d.mts +1 -1
  93. package/scripts/shard-output-content.mjs +2 -2
  94. package/scripts/shard-outputs.mjs +1 -1
  95. package/scripts/shard-public.mjs +1 -1
  96. package/scripts/shard-wire-meter.mjs +24 -9
  97. package/scripts/side-parity.mjs +4 -2
  98. package/scripts/standalone-smoke.mjs +8 -3
  99. package/scripts/tier-textures.mjs +22 -4
  100. package/scripts/tile-bake-report.mjs +1 -1
  101. package/scripts/tile-bakes.mjs +1 -1
  102. package/scripts/title-assets.generated.json +2 -0
  103. package/scripts/tsconfig.json +2 -14
  104. package/scripts/vendor/basisu/LICENSE +201 -0
  105. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  106. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  107. package/scripts/vitest-push-guards.config.ts +1 -1
  108. package/scripts/vps/harden-apply.sh +4 -1
  109. package/scripts/vps/harden-prometheus.sh +179 -0
  110. package/scripts/vps/harden.sh +16 -0
  111. package/scripts/vps/rebuild.sh +18 -0
  112. package/scripts/vps/wildshard-config +6 -2
  113. package/scripts/worker-client-play.mjs +6 -2
  114. package/scripts/worktree-reap.mjs +59 -13
  115. package/scripts/worktree.mjs +19 -5
  116. package/src/.oxlintrc.json +3 -182
  117. package/src/client/app/entry.ts +10 -2
  118. package/src/client/engine/anim/rigParser.ts +2 -2
  119. package/src/client/engine/boot/bootCache.ts +2 -2
  120. package/src/client/engine/boot/bootTrace.ts +12 -4
  121. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  122. package/src/client/engine/boot/clearDownloads.ts +5 -2
  123. package/src/client/engine/boot/contentRead.ts +11 -0
  124. package/src/client/engine/boot/gpuFiles.ts +4 -2
  125. package/src/client/engine/boot/lastEnd.ts +99 -12
  126. package/src/client/engine/boot/texturePack.ts +2 -2
  127. package/src/client/engine/core/Game.ts +63 -19
  128. package/src/client/engine/core/gpuOnly.ts +10 -0
  129. package/src/client/engine/core/renderBudget.ts +134 -0
  130. package/src/client/engine/net/netPlayer.ts +19 -2
  131. package/src/client/engine/net/otherPlayers.ts +55 -8
  132. package/src/client/engine/net/predictor.ts +33 -9
  133. package/src/client/engine/net/redial.ts +68 -10
  134. package/src/client/engine/pwa/cacheNames.ts +58 -1
  135. package/src/client/engine/pwa/sw.js +41 -11
  136. package/src/client/engine/render/dataLook.ts +219 -44
  137. package/src/client/engine/render/families/detail.ts +89 -0
  138. package/src/client/engine/render/families/pbr.ts +9 -1
  139. package/src/client/engine/render/families/registry.ts +11 -2
  140. package/src/client/engine/render/families/sceneSurface.ts +116 -0
  141. package/src/client/engine/render/look.ts +12 -0
  142. package/src/client/engine/render/lookLight.ts +103 -11
  143. package/src/client/engine/render/lookRender.ts +105 -0
  144. package/src/client/engine/render/precompile.ts +4 -2
  145. package/src/client/engine/render/tiers.ts +4 -1
  146. package/src/client/engine/saves/indexed.ts +2 -2
  147. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  148. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  149. package/src/client/engine/ui/debugOptions.ts +1 -1
  150. package/src/client/engine/ui/lookLightOption.ts +10 -6
  151. package/src/client/engine/ui/namePrompt.ts +7 -0
  152. package/src/client/engine/world/declaredProps.ts +5 -1
  153. package/src/client/engine/world/skyRig.ts +4 -1
  154. package/src/client/engine/world/terrainTileView.ts +64 -23
  155. package/src/client/game/boot/audio.generated.ts +114 -114
  156. package/src/client/game/boot/bytes.generated.ts +118 -220
  157. package/src/client/game/boot/placedSpawn.ts +35 -0
  158. package/src/client/game/boot/spawnDownload.ts +25 -6
  159. package/src/client/game/boot/versions.generated.ts +7 -5
  160. package/src/client/game/devScene/hook.ts +428 -0
  161. package/src/client/game/devScene/liveLook.ts +21 -0
  162. package/src/client/game/grid/cellLoading.ts +12 -2
  163. package/src/client/game/grid/live.ts +152 -19
  164. package/src/client/game/grid/liveSession.ts +53 -3
  165. package/src/client/game/grid/mapAtlas.ts +18 -4
  166. package/src/client/game/grid/minimapBlend.ts +15 -5
  167. package/src/client/game/grid/oneWayIn.ts +5 -1
  168. package/src/client/game/grid/pageEntry.ts +12 -1
  169. package/src/client/game/grid/placedCells.ts +114 -12
  170. package/src/client/game/grid/placedContent.ts +85 -0
  171. package/src/client/game/grid/prefetch.ts +9 -1
  172. package/src/client/game/grid/productInputs.ts +23 -10
  173. package/src/client/game/grid/productLeases.ts +4 -1
  174. package/src/client/game/grid/products.ts +8 -4
  175. package/src/client/game/grid/roadLook.ts +24 -15
  176. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  177. package/src/client/game/grid/roadResources.ts +24 -0
  178. package/src/client/game/grid/roadSign.worker.ts +4 -3
  179. package/src/client/game/grid/roadSignPaint.ts +16 -5
  180. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  181. package/src/client/game/grid/roadSignScale.ts +8 -0
  182. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  183. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  184. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  185. package/src/client/game/grid/roadTileWriter.ts +2 -1
  186. package/src/client/game/grid/screenReports.ts +39 -0
  187. package/src/client/game/grid/session.ts +32 -7
  188. package/src/client/game/grid/softWallLook.ts +25 -8
  189. package/src/client/game/mainMenu.ts +6 -2
  190. package/src/client/game/plugin/context.ts +2 -1
  191. package/src/client/game/plugin/followedMovers.ts +7 -1
  192. package/src/client/game/quest/figures.ts +2 -0
  193. package/src/client/game/session/finish.ts +9 -0
  194. package/src/client/game/shardfile/assetCache.ts +4 -4
  195. package/src/client/game/shardfile/client.ts +28 -8
  196. package/src/client/game/shardfile/clientAssets.ts +9 -5
  197. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  198. package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
  199. package/src/client/game/shardfile/clientViews.ts +36 -8
  200. package/src/client/game/shardfile/clientWater.ts +51 -9
  201. package/src/client/game/shardfile/clientWorker.ts +19 -7
  202. package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
  203. package/src/client/game/shardfile/groundMerge.ts +57 -5
  204. package/src/client/game/shardfile/hybrid.ts +2 -0
  205. package/src/client/game/shardfile/look.ts +8 -3
  206. package/src/client/game/shardfile/product.ts +34 -7
  207. package/src/client/game/shardfile/productChecks.ts +2 -2
  208. package/src/client/game/shardfile/productCost.ts +2 -2
  209. package/src/client/game/shardfile/readAsset.ts +2 -2
  210. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  211. package/src/client/game/shardfile/seatGrace.ts +9 -0
  212. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  213. package/src/client/game/shardfile/slabLibrary.ts +115 -49
  214. package/src/client/game/shardfile/tileContent.ts +1 -1
  215. package/src/client/game/shardfile/tileDriver.ts +38 -11
  216. package/src/client/game/shardfile/wirePage.ts +7 -3
  217. package/src/client/game/shardfile/worldScenes.ts +17 -10
  218. package/src/client/game/systems/npc/figureRows.ts +9 -0
  219. package/src/client/host/online/doctor.ts +22 -7
  220. package/src/client/host/online/doctorView.ts +2 -0
  221. package/src/client/host/online/linkScreens.ts +109 -5
  222. package/src/client/host/online/shell.ts +13 -4
  223. package/src/client/host/standalone/shell.ts +40 -0
  224. package/src/cook/game/astc6Encode.ts +55 -0
  225. package/src/cook/game/astc6Wasm.ts +176 -0
  226. package/src/cook/game/cookJob.ts +30 -6
  227. package/src/cook/game/cookWorker.ts +38 -11
  228. package/src/cook/game/entryTotals.ts +51 -24
  229. package/src/cook/game/shardCook.ts +35 -7
  230. package/src/cook/game/spawnParts.ts +33 -8
  231. package/src/cook/game/tierTextures.ts +87 -14
  232. package/src/server/engine/ai/bossContenders.ts +27 -3
  233. package/src/server/engine/ai/phases.ts +1 -1
  234. package/src/server/engine/entities/creatureRefill.ts +9 -2
  235. package/src/server/engine/net/ledgerBook.ts +2 -0
  236. package/src/server/engine/net/room.ts +15 -0
  237. package/src/server/engine/sim/respawn.ts +8 -0
  238. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  239. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  240. package/src/server/game/boss/native.ts +2 -1
  241. package/src/server/game/boss/nativeWake.ts +9 -5
  242. package/src/server/game/boss/openArenaNative.ts +2 -2
  243. package/src/server/game/boss/openArenaRoom.ts +3 -1
  244. package/src/server/game/grid/room.ts +44 -3
  245. package/src/server/game/grid/simulation.ts +23 -0
  246. package/src/server/game/population/mixedRoster.ts +11 -3
  247. package/src/server/game/population/nativeBake.ts +8 -3
  248. package/src/server/game/population/nativeReturns.ts +6 -3
  249. package/src/server/game/population/roster.ts +5 -3
  250. package/src/server/game/quest/eliteDrops.ts +18 -3
  251. package/src/server/game/quest/nativeChapter.ts +1 -1
  252. package/src/server/game/quest/nativeComposition.ts +5 -1
  253. package/src/server/game/riding/nativeTaming.ts +22 -7
  254. package/src/server/game/riding/wildRefill.ts +3 -2
  255. package/src/server/game/shardfile/bossRow.ts +4 -2
  256. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  257. package/src/server/host/bake/headlessWorker.ts +1 -1
  258. package/src/server/host/dedicated/cellHost.ts +112 -18
  259. package/src/server/host/dedicated/cellProtocol.ts +18 -1
  260. package/src/server/host/dedicated/cellWorker.ts +8 -5
  261. package/src/server/host/dedicated/dedicatedRoom.ts +38 -11
  262. package/src/server/host/dedicated/gridCells.ts +15 -6
  263. package/src/server/host/dedicated/loopLag.ts +21 -0
  264. package/src/server/host/dedicated/main.ts +13 -5
  265. package/src/server/host/dedicated/packReader.ts +3 -3
  266. package/src/server/host/dedicated/placementFile.ts +3 -2
  267. package/src/server/host/dedicated/roadRoom.ts +34 -4
  268. package/src/server/host/dedicated/serverMetrics.ts +135 -0
  269. package/src/server/host/dedicated/socketPump.ts +21 -4
  270. package/src/server/host/dedicated/workerTable.ts +32 -14
  271. package/src/server/host/dedicated/world.ts +65 -7
  272. package/src/server/host/headless.ts +1 -1
  273. package/src/server/host/headlessRuntime.ts +1 -1
  274. package/src/server/host/standalone/roadWorld.ts +15 -3
  275. package/src/server/host/standalone/serverHost.ts +57 -8
  276. package/src/server/host/standalone/serverProduct.ts +48 -16
  277. package/src/server/host/standalone/serverRuntime.ts +1 -1
  278. package/src/shared/engine/ai/BossBrain.ts +8 -0
  279. package/src/shared/engine/core/framePacing.ts +12 -1
  280. package/src/shared/engine/physics/terrainTiles.ts +20 -4
  281. package/src/shared/game/boss/wake.ts +6 -0
  282. package/src/shared/game/devColliders.ts +107 -0
  283. package/src/shared/game/devGameplay.ts +41 -0
  284. package/src/shared/game/eliteSystem.ts +8 -0
  285. package/src/shared/game/grid/allocator.ts +3 -0
  286. package/src/shared/game/grid/placementRows.ts +5 -2
  287. package/src/shared/game/plugin/bossRecord.ts +3 -2
  288. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  289. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  290. package/src/shared/game/shardfile/packReads.ts +28 -3
  291. package/src/shared/game/shardfile/serverPack.ts +9 -0
  292. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  293. package/src/shared/host/formatJsonSchema.ts +2 -2
  294. package/src/tsconfig.json +1 -27
  295. package/lint/host-reviews.json +0 -14
  296. package/lint/listed-view-code.json +0 -13
  297. package/lint/platform-pending-users.json +0 -2520
  298. package/lint/platform-pending-users.md +0 -18
  299. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  300. package/scripts/check-closed-components.d.mts +0 -7
  301. package/scripts/check-closed-components.mjs +0 -87
  302. package/scripts/g571-hosts.d.mts +0 -3
  303. package/scripts/g571-hosts.mjs +0 -54
  304. package/scripts/host-ruler/register-migrate.mjs +0 -242
  305. package/scripts/listed-view-code.d.mts +0 -7
  306. package/scripts/listed-view-code.mjs +0 -93
  307. package/scripts/look-loop/fit-lut.py +0 -142
  308. package/scripts/look-loop/palette-delta.py +0 -183
  309. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  310. package/scripts/look-loop/regions/far-reach.json +0 -225
  311. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  312. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  313. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  314. package/scripts/platform-chargebacks.d.mts +0 -9
  315. package/scripts/platform-chargebacks.mjs +0 -135
  316. package/scripts/shard-component-spans.d.mts +0 -15
  317. package/scripts/shard-component-spans.mjs +0 -18
  318. package/scripts/shard-components.d.mts +0 -16
  319. package/scripts/shard-components.mjs +0 -363
  320. package/scripts/shard-platform-hosts.d.mts +0 -2
  321. package/scripts/shard-platform-hosts.mjs +0 -93
  322. package/scripts/shard-platform-sections.d.mts +0 -2
  323. package/scripts/shard-platform-sections.mjs +0 -9
  324. package/scripts/shard-platform.d.mts +0 -76
  325. package/scripts/shard-platform.mjs +0 -1072
  326. package/src/.oxfmtrc.json +0 -48
  327. package/src/scripts/ask-new.sh +0 -29
  328. package/src/scripts/asks.mjs +0 -142
  329. package/src/scripts/herdr-prompt.sh +0 -34
  330. package/src/scripts/herdr-question-open.sh +0 -67
  331. package/src/scripts/md-wrap.mjs +0 -229
  332. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  333. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  334. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -17,7 +17,7 @@ export async function prepareCheckedProduct(source: Shardfile): Promise<boolean>
17
17
  if (!isBuildValidatedOutput(source)) throw new Error('Shardfile needs server validation before client admission');
18
18
  return false;
19
19
  }
20
- const checked = await import('@wildshard/format/product');
20
+ const checked = await import('@wildshard/format/shardfileAssets');
21
21
  await checked.prepareAssetDecoders();
22
22
  checked.preflightAssetGraph(source);
23
23
  return true;
@@ -33,7 +33,7 @@ export async function checkedProductCosts(source: Shardfile, memory: MemoryAdmis
33
33
  export async function validateCheckedProductAssets(source: Shardfile, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
34
34
  memory: MemoryAdmission | undefined, textures: TextureTranscodeSupport | undefined, sections: ReadonlyMap<string, unknown> | undefined, decodersReady: boolean): Promise<void> {
35
35
  if (!(import.meta.env?.SSR ?? true)) throw new Error('Shardfile needs server validation before client admission');
36
- if (!decodersReady) await (await import('@wildshard/format/product')).prepareAssetDecoders();
36
+ if (!decodersReady) await (await import('@wildshard/format/shardfileAssets')).prepareAssetDecoders();
37
37
  const { validateShardfileAssets } = await import('@wildshard/format/assetAdmission');
38
38
  const { scriptAdmissionRows } = await import('@wildshard/format/scriptContract');
39
39
  validateShardfileAssets(source, assets, hash, memory, textures, scriptAdmissionRows(sections));
@@ -14,7 +14,7 @@ import { preflightShardfile, preflightShardfileSteps } from '@wildshard/format/p
14
14
  import { jsonDataHeapBytes } from '@wildshard/format/json';
15
15
  import { outputDescriptor, isBuildValidatedOutput } from '../../../shared/game/shardfile/outputDescriptor';
16
16
  import { otherTierSplatFiles } from '../../../shared/game/shardfile/wholeInputs';
17
- import {builtProductPostCost} from '@wildshard/format/validationReceipt';
17
+ import {builtShardfilePostCost} from '@wildshard/format/validationReceipt';
18
18
  import {postStackCost,type PostStackCost} from '@wildshard/format/postStack';
19
19
  import { isPlatformDataSection } from '@wildshard/format/outputFields';
20
20
  import { parseWorldScenes } from '@wildshard/format/worldScenes';
@@ -306,7 +306,7 @@ export function jsonResidentBytes(input: unknown): number {
306
306
  export function productPostCost(source:Shardfile,bytes:(hash:string)=>Uint8Array|undefined):PostStackCost{
307
307
  const descriptor=outputDescriptor(source);
308
308
  if(descriptor?.built===true){
309
- const cost=builtProductPostCost(descriptor.index.build.sourceHash);
309
+ const cost=builtShardfilePostCost(descriptor.index.build.sourceHash);
310
310
  if(cost===undefined)throw new Error('Build must publish post cost');
311
311
  return cost;
312
312
  }
@@ -1,5 +1,5 @@
1
1
  import { readContent, type ContentReadOptions } from '@wildshard/engine/boot/contentRead';
2
- import { ASSET_CACHE_NAME } from '@wildshard/engine/pwa/cacheNames';
2
+ import { assetCacheName } from '@wildshard/engine/pwa/cacheNames';
3
3
  import { SHARDFILE_ADMISSION_LIMITS as limits } from '@wildshard/format/admissionLimits';
4
4
 
5
5
  interface AssetStorePort { open: (name: string) => Promise<Pick<Cache, 'put'>> }
@@ -36,7 +36,7 @@ export async function readAsset(url: string, bytes: number | undefined, options:
36
36
  } });
37
37
  options.signal?.throwIfAborted();
38
38
  if (copy !== undefined && publication !== undefined) {
39
- try { await (await publication.open(ASSET_CACHE_NAME)).put(url, copy); }
39
+ try { await (await publication.open(assetCacheName())).put(url, copy); }
40
40
  catch { /* Disk denial never rejects complete online bytes. */ }
41
41
  }
42
42
  return result;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * A pool's declared surface (meta TEMPLATES-CLEANROOM M4.1/M4.6, `@wildshard/format/pool-surface`): how its water draws.
3
+ *
4
+ * - `reflect: 'planar'` on the desktop tier: a mirror of the scene (three's `Reflector`, one extra scene draw per frame
5
+ * while the pool is in view, at `resolution` texels, 512 absent), its UVs rippled in world space, a Fresnel blend of the
6
+ * reflection over the deep `tint` (face-on `fresnel[0]`, rising by the power `fresnel[1]` toward grazing).
7
+ * - `reflect: 'sky'`, and `planar` on the phone tier: the engine's default water surface (`defaultWaterMaterial`), opaque
8
+ * in `tint` with the surface's Fresnel and ripple: the look's sky and sun reflected, no second scene draw.
9
+ *
10
+ * The cleanroom pond this ports (mossgate-cleanroom `src/main.js`) is a 1024² reflector, tint `#3a3458`, Fresnel 0.35 +
11
+ * 0.65·(1 − v·y)³; the milky pond it replaces was the default surface's 0.7 alpha over a fog-coloured sky.
12
+ */
13
+ import { CircleGeometry, Color, Shape, ShapeGeometry, Vector2, type BufferGeometry, type Mesh, type ShaderMaterial } from 'three';
14
+ import { Reflector } from 'three/examples/jsm/objects/Reflector.js';
15
+ import type { PoolSurface } from '@wildshard/format/pool-surface';
16
+
17
+ /** the mirror's texels on a side when the surface names none */
18
+ export const DEFAULT_MIRROR_TEXELS = 512;
19
+ /** how far the mirror's clip plane sits under the water (metres): keeps the bank's foot out of its own reflection */
20
+ const CLIP_BIAS = 0.003;
21
+
22
+ /** A pool's outline in its own x / y plane (z negated, so a −90° turn about x lays it on the ground as declared). */
23
+ export function poolPlane(shape: { readonly kind: 'circle'; readonly x: number; readonly z: number; readonly radius: number } | { readonly kind: 'polygon'; readonly points: readonly (readonly [number, number])[] }): BufferGeometry {
24
+ if (shape.kind === 'circle') return new CircleGeometry(shape.radius, 32).translate(shape.x, -shape.z, 0);
25
+ return new ShapeGeometry(new Shape(shape.points.map(([x, z]) => new Vector2(x, -z))), 12);
26
+ }
27
+
28
+ const VERTEX = /* glsl */`
29
+ uniform mat4 textureMatrix;
30
+ varying vec4 vMirror; varying vec3 vWorld;
31
+ void main() {
32
+ vMirror = textureMatrix * vec4(position, 1.0);
33
+ vWorld = (modelMatrix * vec4(position, 1.0)).xyz;
34
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
35
+ }`;
36
+ // linear out (the composer tone-maps): the rippled mirror over the tint, by Fresnel
37
+ const FRAGMENT = /* glsl */`
38
+ uniform sampler2D tDiffuse; uniform vec3 color; uniform float uTime; uniform vec3 uTint; uniform vec2 uFresnel; uniform vec3 uRipple;
39
+ varying vec4 vMirror; varying vec3 vWorld;
40
+ void main() {
41
+ vec2 w = vWorld.xz * uRipple.x, t = vec2(uTime * uRipple.z);
42
+ vec2 d = vec2(sin(w.x * 1.03 + t.x * 1.3) + sin(w.y * 0.77 - t.x * 0.9), cos(w.y * 1.23 + t.x * 1.1) + sin(w.x * 0.57 + w.y * 0.7 + t.x)) * uRipple.y;
43
+ vec4 uv = vMirror; uv.xy += d * uv.w;
44
+ vec3 mirror = texture2DProj(tDiffuse, uv).rgb * color;
45
+ vec3 v = normalize(cameraPosition - vWorld);
46
+ float fresnel = uFresnel.x + (1.0 - uFresnel.x) * pow(1.0 - max(v.y, 0.0), uFresnel.y);
47
+ gl_FragColor = vec4(mix(uTint, mirror, fresnel), 1.0);
48
+ }`;
49
+
50
+ /** A planar-reflecting pool: a `Reflector` laid on the ground at `level`; `tick(dt)` runs its ripples on the game clock. */
51
+ export function mirrorPool(shape: Parameters<typeof poolPlane>[0], level: number, surface: PoolSurface): { mesh: Mesh; tick: (dt: number) => void; dispose: () => void } {
52
+ const texels = surface.resolution ?? DEFAULT_MIRROR_TEXELS;
53
+ const mirror = new Reflector(poolPlane(shape), {
54
+ textureWidth: texels, textureHeight: texels, clipBias: CLIP_BIAS, multisample: 0,
55
+ // a faint cool cast on the mirror, as the cleanroom's (0.82, 0.76, 0.84)
56
+ color: new Color(0.82, 0.78, 0.86),
57
+ shader: {
58
+ name: 'engine.water.mirror',
59
+ uniforms: { color: { value: null }, tDiffuse: { value: null }, textureMatrix: { value: null }, uTime: { value: 0 },
60
+ uTint: { value: new Color().setRGB(surface.tint[0], surface.tint[1], surface.tint[2]) },
61
+ uFresnel: { value: new Vector2(surface.fresnel[0], surface.fresnel[1]) },
62
+ uRipple: { value: [surface.ripple.scale, surface.ripple.amplitude, surface.ripple.speed] } },
63
+ vertexShader: VERTEX, fragmentShader: FRAGMENT,
64
+ },
65
+ });
66
+ mirror.rotation.x = -Math.PI / 2;
67
+ mirror.position.y = level;
68
+ mirror.updateMatrixWorld();
69
+ const material = mirror.material as ShaderMaterial, time = material.uniforms['uTime'];
70
+ let clock = 0;
71
+ const tick = (dt: number): void => { clock += dt; if (time !== undefined) time.value = clock; };
72
+ return { mesh: mirror, tick, dispose: () => { mirror.dispose(); mirror.geometry.dispose(); } };
73
+ }
@@ -0,0 +1,9 @@
1
+ /** OFFLINE OF9 (J298, Jake 2026-11-12: "Load into the world. And then have a really hard time moving around"): how long a world
2
+ * build's load waits for its seat before it opens the world without one. A seat in time keeps QA row 29's reveal at the saved place;
3
+ * a page that knows it is offline doesn't wait at all. */
4
+ export const SEAT_GRACE_MS = 1500;
5
+ /** OF9: whether the seat comes within `graceMs` (the page's link known down: no wait). A pure race, so a test pins it. */
6
+ export function seatedInTime(booted: Promise<unknown>, graceMs: number, online: boolean, wait: (ms: number) => Promise<void>): Promise<boolean> {
7
+ if (!online) return Promise.resolve(false);
8
+ return Promise.race([booted.then(() => true, () => true), wait(graceMs).then(() => false)]);
9
+ }
@@ -14,7 +14,7 @@ import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js
14
14
  import { bindRig, prepareRigLoader, type ClipName, type RigInstance } from '@wildshard/engine/anim/rig';
15
15
  import { AnimMachine } from '@wildshard/engine/anim/machine';
16
16
  import type { Scope } from '@wildshard/engine/app/scope';
17
- import type { AssetCost } from '@wildshard/format/product';
17
+ import type { AssetCost } from '@wildshard/format/shardfileAssets';
18
18
  import { parseGlbData, prepareGlbCost } from '@wildshard/format/glbCost';
19
19
  import { skinLayerDecoded } from '@wildshard/format/skinLayers';
20
20
  import { parseSkinBindings, type SkinRow, type SkinBinding } from '@wildshard/format/skinData';
@@ -2,6 +2,7 @@ import { Box3, BufferGeometry, InstancedBufferAttribute, InstancedMesh, Mesh, Sp
2
2
  import * as v from 'valibot';
3
3
  import { prepareRigLoader } from '@wildshard/engine/anim/rig';
4
4
  import type { Scope } from '@wildshard/engine/app/scope';
5
+ import { pageScope } from '@wildshard/engine/app/resources';
5
6
  import { ownSceneResource } from '@wildshard/engine/app/sceneOwnership';
6
7
  import { workSlice } from '@wildshard/engine/core/workSlice';
7
8
  import { nativeWholeGeometry } from '@wildshard/engine/models/nativeGeometry';
@@ -11,6 +12,7 @@ import type { ShardProduct } from '../../../shared/game/shardfile/shardProduct';
11
12
  import { runtimeProduct } from './runtimeProduct';
12
13
  import { SharedTileBuilds, type TileContent } from './tileContent';
13
14
  import type { ControlRefinement } from './controlRefinement';
15
+ import { tilesSettling } from './tileDriver';
14
16
 
15
17
  type WholeLibrary = Extract<WorldScenesSection['libraries'][number], { kind: 'whole' }>;
16
18
  type SlabTile = WorldSceneSlabLibrary['tiles'][number];
@@ -21,6 +23,12 @@ const EMPTY: ReadonlySet<number> = new Set();
21
23
  function slabMesh(node: Object3D): node is Mesh { return node instanceof Mesh; }
22
24
  function materialList(mesh: Mesh): Material[] { return Array.isArray(mesh.material) ? mesh.material : [mesh.material]; }
23
25
 
26
+ /** NB3: the longest a loader publication waits for one more bank read before it publishes what it holds */
27
+ const GATHER_MS = 250;
28
+
29
+ /** One slab part waiting to publish: its instanced chunk, the anchor it joins, and the holder scope that retires it. */
30
+ export interface SlabPart { readonly part: InstancedMesh; readonly anchor: Mesh; readonly scope: Scope }
31
+
24
32
  /** a tile's chunks in file order, then each file's chunk order (as its build returns their geometries) */
25
33
  const chunksOf = (entry: SlabTile): readonly WorldSceneSlabChunk[] => entry.files.flatMap(file => file.chunks);
26
34
 
@@ -76,17 +84,25 @@ export class SlabLibrary {
76
84
  private readonly entries = new Map<number, SlabTile>();
77
85
  private readonly keys = new Map<string, WorldSceneSlabKey>();
78
86
  private serial = 0;
79
- private publication: Promise<void> = Promise.resolve();
87
+ /** the parts waiting for the one publication cursor, and whether it is running (`publish`) */
88
+ private readonly waiting: { readonly parts: readonly SlabPart[]; readonly mount: () => Promise<void>; readonly done: () => void; readonly fail: (error: unknown) => void }[] = [];
89
+ private publishing = false;
90
+ private readonly bounds: ReadonlyMap<number, ShardProduct['shardfile']['tiles'][number]['bounds']>;
91
+ private readonly product: ShardProduct;
92
+ /** bank reads running now, and the publication waiting for one to finish (NB3: the loader's gather) */
93
+ private reads = 0;
94
+ private readonly readDone: (() => void)[] = [];
80
95
  constructor(owner: Scope, product: ShardProduct, private readonly whole: WholeLibrary, private readonly row: WorldSceneSlabLibrary,
81
96
  private readonly queue: ControlRefinement, private readonly cover: (tile: number) => Promise<void>,
82
- private readonly prepare?: (part: InstancedMesh, owner: Scope, anchor: Mesh) => Promise<void>) {
97
+ private readonly prepare?: (parts: readonly SlabPart[]) => Promise<void>) {
83
98
  if (row.of !== whole.id) throw new Error('Slab library covers another library');
84
99
  for (const key of row.keys) {
85
100
  if (key.castFrom !== undefined) throw new Error('Slab key casting from a band has no run-time draw');
86
101
  for (const source of key.sources) { if (this.keys.has(source)) throw new Error('Slab source belongs to two keys'); this.keys.set(source, key); }
87
102
  }
88
103
  for (const model of whole.models) if (!this.keys.has(model.id)) throw new Error(`Slab library omits refine model ${model.id}`);
89
- const bounds = new Map(product.shardfile.tiles.filter(tile => tile.lod === 0).map(tile => [tile.z * 8 + tile.x, tile.drawBounds ?? tile.bounds] as const));
104
+ const bounds = this.bounds = new Map(product.shardfile.tiles.filter(tile => tile.lod === 0).map(tile => [tile.z * 8 + tile.x, tile.drawBounds ?? tile.bounds] as const));
105
+ this.product = product;
90
106
  const declared = new Set(product.shardfile.files.filter(file => file.kind === 'glb').map(file => file.hash));
91
107
  for (const entry of row.tiles) {
92
108
  for (const tile of entry.covers ?? [entry.tile]) if (!bounds.has(tile)) throw new Error(`Slabs require a declared fine tile: ${String(tile)}`);
@@ -94,38 +110,87 @@ export class SlabLibrary {
94
110
  this.entries.set(entry.tile, entry);
95
111
  }
96
112
  this.builds = new SharedTileBuilds(owner, async (tile, scope) => {
97
- const entry = this.entries.get(tile); if (entry === undefined) throw new Error('Missing slab tile');
98
- const chunks: BufferGeometry[] = [];
99
- let box = bounds.get(tile);
100
- if (entry.covers !== undefined) {
101
- const min: [number, number, number] = [Infinity, Infinity, Infinity], max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
102
- for (const logical of entry.covers) {
103
- const covered = bounds.get(logical); if (covered === undefined) throw new Error('Missing slab logical bounds');
104
- for (const axis of [0, 1, 2] as const) { min[axis] = Math.min(min[axis], covered.min[axis]); max[axis] = Math.max(max[axis], covered.max[axis]); }
105
- }
106
- box = { min, max };
113
+ this.reads++;
114
+ try { return await this.read(tile, scope); }
115
+ finally { this.reads--; for (const wake of this.readDone.splice(0)) wake(); }
116
+ });
117
+ }
118
+ /** One storage bank's chunk geometries: read and decoded in the refinement queue, its covered tiles first covered. */
119
+ private async read(tile: number, scope: Scope): Promise<BufferGeometry[]> {
120
+ const { row, queue, bounds, product } = this;
121
+ const entry = this.entries.get(tile); if (entry === undefined) throw new Error('Missing slab tile');
122
+ const chunks: BufferGeometry[] = [];
123
+ let box = bounds.get(tile);
124
+ if (entry.covers !== undefined) {
125
+ const min: [number, number, number] = [Infinity, Infinity, Infinity], max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
126
+ for (const logical of entry.covers) {
127
+ const covered = bounds.get(logical); if (covered === undefined) throw new Error('Missing slab logical bounds');
128
+ for (const axis of [0, 1, 2] as const) { min[axis] = Math.min(min[axis], covered.min[axis]); max[axis] = Math.max(max[axis], covered.max[axis]); }
107
129
  }
108
- // A shared bank is visible wherever any of its actual logical coverage
109
- // is visible. Its storage address alone cannot fence its publication.
110
- const at = { x: entry.covers === undefined || box === undefined ? -250 + (tile % 8 + 0.5) * 62.5 : (box.min[0] + box.max[0]) / 2,
111
- y: box === undefined ? 0 : (box.min[1] + box.max[1]) / 2,
112
- z: entry.covers === undefined || box === undefined ? -250 + (Math.floor(tile / 8) + 0.5) * 62.5 : (box.min[2] + box.max[2]) / 2,
113
- ...(box === undefined ? {} : { bounds: box }) };
114
- await queue.add(`${row.id}:${String(tile)}:${String(this.serial++)}`, at, async () => {
130
+ box = { min, max };
131
+ }
132
+ // A shared bank is visible wherever any of its actual logical coverage
133
+ // is visible. Its storage address alone cannot fence its publication.
134
+ const at = { x: entry.covers === undefined || box === undefined ? -250 + (tile % 8 + 0.5) * 62.5 : (box.min[0] + box.max[0]) / 2,
135
+ y: box === undefined ? 0 : (box.min[1] + box.max[1]) / 2,
136
+ z: entry.covers === undefined || box === undefined ? -250 + (Math.floor(tile / 8) + 0.5) * 62.5 : (box.min[2] + box.max[2]) / 2,
137
+ ...(box === undefined ? {} : { bounds: box }) };
138
+ await queue.add(`${row.id}:${String(tile)}:${String(this.serial++)}`, at, async () => {
139
+ if (scope.disposed || scope.disposing) return;
140
+ for (const logical of entry.covers ?? [tile]) await this.cover(logical);
141
+ for (const file of entry.files) {
115
142
  if (scope.disposed || scope.disposing) return;
116
- for (const logical of entry.covers ?? [tile]) await this.cover(logical);
117
- for (const file of entry.files) {
118
- if (scope.disposed || scope.disposing) return;
119
- let read: readonly BufferGeometry[];
120
- try { read = await readSlabChunks(scope, product, tile, file); }
121
- catch (error) { if (scope.disposed || scope.disposing) return; throw error; }
122
- for (const geometry of read) ownSceneResource(geometry, scope);
123
- chunks.push(...read);
124
- }
125
- });
126
- if (!scope.disposed && !scope.disposing && chunks.length !== chunksOf(entry).length) throw new Error('Slab tile chunk count differs from its row');
127
- return chunks;
143
+ let read: readonly BufferGeometry[];
144
+ try { read = await readSlabChunks(scope, product, tile, file); }
145
+ catch (error) { if (scope.disposed || scope.disposing) return; throw error; }
146
+ for (const geometry of read) ownSceneResource(geometry, scope);
147
+ chunks.push(...read);
148
+ }
128
149
  });
150
+ if (!scope.disposed && !scope.disposing && chunks.length !== chunksOf(entry).length) throw new Error('Slab tile chunk count differs from its row');
151
+ return chunks;
152
+ }
153
+ /**
154
+ * The library's one publication cursor: `parts` are prepared (the native warm and its completed-draw fence) before they
155
+ * mount (`mount`, inside the cursor), never while another publication's preparation runs. In play a publication is one queued part list (one part);
156
+ * NINE-DRAGON-BENCHMAX NB3: under the loader's settle a publication takes every list waiting when it starts, so one warm
157
+ * covers what was ~50 serialized ones on Nine's spawn view (~75 ms each on a cold phone). A failed preparation fails
158
+ * every list it covered; a retired holder's part is left out of the next publication.
159
+ */
160
+ private publish(parts: readonly SlabPart[], mount: () => Promise<void>): Promise<void> {
161
+ return new Promise<void>((resolve, reject) => { this.waiting.push({ parts, mount, done: resolve, fail: reject }); void this.drain(); });
162
+ }
163
+ private async drain(): Promise<void> {
164
+ if (this.publishing) return;
165
+ this.publishing = true;
166
+ try {
167
+ while (this.waiting.length > 0) {
168
+ // under the loader a publication first gathers: while banks are still reading it waits for them (each wait capped
169
+ // at GATHER_MS, so a read that never runs can't hold it), and then takes every part they produced at once
170
+ for (let gathered = true; gathered && tilesSettling() && this.reads > 0;) {
171
+ gathered = await new Promise<boolean>(resolve => {
172
+ let settled = false;
173
+ const settle = (read: boolean): void => { if (!settled) { settled = true; resolve(read); } };
174
+ pageScope.timeout(GATHER_MS, () => { settle(false); });
175
+ this.readDone.push(() => { settle(true); });
176
+ });
177
+ }
178
+ const lists = tilesSettling() ? this.waiting.splice(0) : this.waiting.splice(0, 1);
179
+ const parts = lists.flatMap(list => list.parts).filter(({ scope }) => !scope.disposed && !scope.disposing);
180
+ try { if (this.prepare !== undefined && parts.length > 0) await this.prepare(parts); }
181
+ catch (error) {
182
+ // a holder retired during a shared preparation fails only its own list; the live lists publish again
183
+ const retired = (list: (typeof lists)[number]): boolean => list.parts.some(({ scope }) => scope.disposed || scope.disposing);
184
+ const live = lists.filter(list => !retired(list));
185
+ if (live.length < lists.length && live.length > 0) { for (const list of lists) if (retired(list)) list.fail(error); this.waiting.unshift(...live); }
186
+ else for (const list of lists) list.fail(error);
187
+ continue;
188
+ }
189
+ for (const list of lists) {
190
+ try { await list.mount(); list.done(); } catch (error) { list.fail(error); }
191
+ }
192
+ }
193
+ } finally { this.publishing = false; }
129
194
  }
130
195
  /** an anchor's frozen stand-in until its key's first chunk: no channels (the anchor stays hidden) */
131
196
  geometry(id: string): BufferGeometry | null { return this.whole.models.some(model => model.id === id) ? new BufferGeometry() : null; }
@@ -159,7 +224,7 @@ export class SlabLibrary {
159
224
  const drawn: InstancedMesh[] = [];
160
225
  if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return drawn;
161
226
  scope.onDispose(() => { for (const part of drawn) { part.removeFromParent(); part.dispose(); } drawn.length = 0; });
162
- const slice = workSlice(undefined, scope);
227
+ const slice = workSlice(undefined, scope), parts: SlabPart[] = [];
163
228
  for (const [index, chunk] of chunksOf(entry).entries()) {
164
229
  if (chunk.key !== key.id) continue;
165
230
  if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return drawn;
@@ -171,23 +236,24 @@ export class SlabLibrary {
171
236
  part.name = `${mesh.name}:slab:${String(tile)}:${String(index)}`; part.matrixAutoUpdate = false;
172
237
  part.castShadow = key.castShadow; part.receiveShadow = key.receiveShadow; part.renderOrder = key.renderOrder;
173
238
  part.layers.mask = key.layers; part.frustumCulled = key.frustumCulled;
174
- // All keys share one publication cursor. A CPU-budget yield alone can
175
- // mount several still-culled chunks before a turn first uploads them.
176
- // Preparation lends the actual native geometry to the existing warmer;
177
- // it must finish its completed-draw fence before another key enters.
178
- drawn.push(part);
179
- const prior = this.publication;
180
- let release = (): void => undefined;
181
- this.publication = new Promise<void>(resolve => { release = resolve; });
182
- await prior;
183
- try {
184
- if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return drawn;
185
- if (this.prepare !== undefined) await this.prepare(part, scope, mesh);
186
- if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return drawn;
239
+ drawn.push(part); parts.push({ part, anchor: mesh, scope });
240
+ }
241
+ // All keys share one publication cursor. A CPU-budget yield alone can
242
+ // mount several still-culled chunks before a turn first uploads them.
243
+ // Preparation lends the actual native geometry to the existing warmer;
244
+ // it must finish its completed-draw fence before another key enters.
245
+ // In play one part a publication (and a frame); under the loader's card a
246
+ // publication takes every part waiting then (NB3, `publish`).
247
+ for (let at = 0; at < parts.length;) {
248
+ const batch = tilesSettling() ? parts.slice(at) : parts.slice(at, at + 1);
249
+ at += batch.length;
250
+ if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return drawn;
251
+ await this.publish(batch, async () => {
252
+ if (lifetime.disposed || lifetime.disposing || scope.disposed || scope.disposing) return;
187
253
  if (!laid) lay();
188
- mesh.add(part);
189
- await slice.yield();
190
- } finally { release(); }
254
+ for (const { part } of batch) mesh.add(part);
255
+ await (tilesSettling() ? slice.check() : slice.yield());
256
+ });
191
257
  }
192
258
  return drawn;
193
259
  });
@@ -331,7 +331,7 @@ export function clientRingPorts(instances: ReadonlyMap<string, ClientRingInstanc
331
331
  const tiles = await prepareClientTile(source, assets, key, scope, {
332
332
  terrain: async (bytes, owner) => {
333
333
  const data = await ports.decoder.decode(bytes); if (owner.disposed || owner.disposing) throw new Error('shardfile rings: tile dropped while decoding');
334
- return views.terrain(data, group, owner, false);
334
+ return views.terrain(data, group, owner, false, instance.root);
335
335
  },
336
336
  props: (props, address, bytes, owner, additional) => views.props(props, address, bytes, group, owner, additional, instance.root),
337
337
  });
@@ -24,7 +24,7 @@ import { macrotask } from '@wildshard/engine/boot/plan';
24
24
  import { loadingUnits } from '@wildshard/engine/boot/waits';
25
25
  import { diagnosticNow } from '@wildshard/engine/core/clock';
26
26
  import { bootTask, bootWork } from '@wildshard/engine/boot/timing';
27
- import { FENCE_LANES, SPAWN_VIEW_M, spawnViewUsesCamera } from './controlRefinement';
27
+ import { SPAWN_VIEW_M, spawnViewUsesCamera } from './controlRefinement';
28
28
  import { streamingDistance, streamingOrder, type StreamingBounds, type StreamingPoint, type StreamingView } from './streamingView';
29
29
 
30
30
  /** MF5: the live drivers, and whether the loader is settling them (no world frames under the card since FC2). */
@@ -52,6 +52,8 @@ export async function settleTileDrivers(frame?: () => void, stallMs = 20000): Pr
52
52
  await bootTask('app:spawn-view-tiles', async () => { for (const driver of Array.from(liveDrivers)) await driver.settle(stallMs); });
53
53
  } finally { loaderMode = false; }
54
54
  }
55
+ /** Whether the loader is settling the live drivers now (no frame is presented under its card). */
56
+ export function tilesSettling(): boolean { return loaderMode; }
55
57
  /** DL21: while the loader settles, the render tiles inside its fence across the live drivers and how many are complete (the
56
58
  * spawn view's card counts them); null outside the settle. */
57
59
  export function settlingTiles(): { readonly done: number; readonly total: number; readonly stages: number; readonly stagesTotal: number } | null {
@@ -81,8 +83,8 @@ export class TileDriver {
81
83
  private readonly retried = new Set<string>();
82
84
  private centre: CellTile | null = null;
83
85
  private renderRing: ReadonlySet<number> = new Set();
84
- /** the attaches `step` started, while they run (the loader's settle waits on them): one in play, FENCE_LANES under the
85
- * loader */
86
+ /** the attaches `step` started, while they run (the loader's settle waits on them): one in play, every fence tile under
87
+ * the loader */
86
88
  private readonly inflight = new Set<Promise<void>>();
87
89
  private plan: TileRingPlan | null = null;
88
90
  private coarseScope: Scope | null = null;
@@ -189,7 +191,7 @@ export class TileDriver {
189
191
  }
190
192
 
191
193
  /** Once a frame with the player's cell-local position: retire the tiles outside the rings, then start the nearest wanted
192
- * tile not yet attached (colliders first), one at a time in play; under the loader up to FENCE_LANES at once (DL21: the
194
+ * tile not yet attached (colliders first), one at a time in play; under the loader all at once (DL21, NB3: the
193
195
  * fence's slab reads and decodes then overlap, where one tile at a time held its queue at one job). Render owners retire one tile beyond the attach ring;
194
196
  * collider owners retain the exact 3 x 3 physical ring (D2 B). */
195
197
  step(x: number, z: number): void {
@@ -201,7 +203,10 @@ export class TileDriver {
201
203
  if (plan.retained[layer].has(key)) continue;
202
204
  this.attached[layer].delete(key); tile.scope.dispose();
203
205
  }
204
- const lanes = loaderMode ? FENCE_LANES : 1;
206
+ // NB3: under the loader every fence tile starts at once. A tile's attach mostly awaits shared work (its slab banks'
207
+ // reads and their one publication chain, the refinement queue's FENCE_LANES jobs), so a lane cap left the spawn's
208
+ // slab tiles queued behind the collider ring's builds (Nine: render began ~450 ms in at x4)
209
+ const lanes = loaderMode ? Number.POSITIVE_INFINITY : 1;
205
210
  if (this.inflight.size >= lanes) return;
206
211
  const now = diagnosticNow(), cone = loaderMode || this.view === null ? null : this.view(), streamView = spawnViewUsesCamera() ? this.streamingView?.() ?? null : null;
207
212
  for (const key of this.wantedAt.keys()) if (!wanted.render.has(key)) this.wantedAt.delete(key);
@@ -326,17 +331,39 @@ export class TileDriver {
326
331
  // content (the card names the step's wait; this says which content holds it)
327
332
  const timed = loaderMode, started = timed ? diagnosticNow() : 0, contents: Record<string, number> = {};
328
333
  try {
329
- for (const content of this.contents) {
330
- if (tile.done.has(content)) continue;
331
- if (!content.tiles().has(key)) { tile.done.add(content); continue; }
332
- if (layer === 'render' && content.ready?.() === false) continue;
334
+ /** under the loader, one content's stage of this tile (timed); false when the tile retired meanwhile */
335
+ const stage = async (content: TileContent): Promise<boolean> => {
336
+ if (tile.done.has(content)) return true;
337
+ if (!content.tiles().has(key)) { tile.done.add(content); return true; }
338
+ if (layer === 'render' && content.ready?.() === false) return true;
333
339
  // Cached stages may resolve in microtasks; share the live frame's
334
340
  // budget before admitting another stage, including background tiles.
335
- if (frameBudgetSpent(WORK_SLICE_MS)) await (loaderMode ? task() : this.pause()); // MF5: no frames under the card
336
- if (tile.scope.disposed || tile.scope.disposing) return null;
341
+ if (frameBudgetSpent(WORK_SLICE_MS)) await task(); // MF5: no frames under the card
342
+ if (tile.scope.disposed || tile.scope.disposing) return false;
337
343
  const at = timed ? diagnosticNow() : 0;
338
344
  await (layer === 'render' ? content.attach(key, tile.scope) : content.attachColliders?.(key, tile.scope));
339
345
  if (timed) contents[content.id] = Math.round(diagnosticNow() - at);
346
+ if (tile.scope.disposed || tile.scope.disposing) return false;
347
+ tile.done.add(content);
348
+ return true;
349
+ };
350
+ // NINE-DRAGON-BENCHMAX NB3: under the loader a tile's contents attach together, so the slab keys' publications queue
351
+ // at once and publish as one warm (slabLibrary.ts `publish`); one after another, each waited on its own (~50 serialized
352
+ // warms on Nine's spawn view, ~75 ms each on a cold phone). In play they stay in order, one at a time.
353
+ // allSettled: a failed content rethrows only once its siblings have finished, so the settle's retry never starts a
354
+ // second attach of this key while the first is still running on the scope the catch disposes
355
+ if (loaderMode) {
356
+ const settled = await Promise.allSettled(this.contents.map(stage)), failed = settled.find(row => row.status === 'rejected');
357
+ if (failed !== undefined) throw failed.reason;
358
+ if (!settled.every(row => row.status === 'fulfilled' && row.value)) return null;
359
+ }
360
+ else for (const content of this.contents) {
361
+ if (tile.done.has(content)) continue;
362
+ if (!content.tiles().has(key)) { tile.done.add(content); continue; }
363
+ if (layer === 'render' && content.ready?.() === false) continue;
364
+ if (frameBudgetSpent(WORK_SLICE_MS)) await this.pause();
365
+ if (tile.scope.disposed || tile.scope.disposing) return null;
366
+ await (layer === 'render' ? content.attach(key, tile.scope) : content.attachColliders?.(key, tile.scope));
340
367
  if (tile.scope.disposed || tile.scope.disposing) return null;
341
368
  tile.done.add(content);
342
369
  }
@@ -82,6 +82,8 @@ export class WirePage {
82
82
  private readonly quests = new Map<string, QuestProgress>();
83
83
  private readonly heard = new Set<string>();
84
84
  private readonly feeds = new Map<string, QuestViewFeed>();
85
+ /** each feed's declaration, as text: a changed one makes a new feed */
86
+ private readonly feedWords = new Map<string, string>();
85
87
  private readonly waiting = new Set<Live>();
86
88
  private readonly books = new Set<Flags>();
87
89
  /** The rows a sky reads: none, until the wire is up. */
@@ -140,7 +142,7 @@ export class WirePage {
140
142
  for (const use of this.waiting) use(client);
141
143
  this.waiting.clear();
142
144
  }
143
- unbind(): void { this.client = null; this.press = () => undefined; this.act = () => undefined; this.dayRow = undefined; this.stop = () => undefined; this.encounterRows = null; this.heads = () => false; this.seeded = null; this.purchases.clear(); this.books.clear(); this.feeds.clear(); this.movers.clear(); }
145
+ unbind(): void { this.client = null; this.press = () => undefined; this.act = () => undefined; this.dayRow = undefined; this.stop = () => undefined; this.encounterRows = null; this.heads = () => false; this.seeded = null; this.purchases.clear(); this.books.clear(); this.feeds.clear(); this.feedWords.clear(); this.movers.clear(); }
144
146
  /** A setting's weather or a dev's jump: the server's sky takes it. Only a mode outlives its world. */
145
147
  climate(word: ClimateWord): void {
146
148
  if (word.op !== 'force') this.skyWords.set(word.op, word);
@@ -215,8 +217,10 @@ export class WirePage {
215
217
  }
216
218
  /** A quest view for `def`, over this player's rows. */
217
219
  quest(def: QuestDef): QuestView {
218
- const feed = this.feeds.get(def.id) ?? new QuestViewFeed([def], { quests: this.quests, phased: this.heard });
219
- this.feeds.set(def.id, feed);
220
+ // SHARD-SOURCE AP19 (DEVSERVER): a quest whose declaration changed (`wildshard watch`'s soft restart) gets a feed of its new steps
221
+ const words = typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ ? JSON.stringify(def) : '', held = this.feeds.get(def.id);
222
+ const feed = held !== undefined && this.feedWords.get(def.id) === words ? held : new QuestViewFeed([def], { quests: this.quests, phased: this.heard });
223
+ this.feeds.set(def.id, feed); this.feedWords.set(def.id, words);
220
224
  return feed.quest(def.id);
221
225
  }
222
226
  /** The server's payouts: the page's own go, so a kill pays once. */
@@ -420,18 +420,25 @@ async function buildPrepared(ctx: ShardContext, section: WorldScenesSection, res
420
420
  // reconstructing a union during play.
421
421
  const slabs = section.libraries.find(entry => entry.kind === 'slabs' && entry.of === row.id);
422
422
  if (slabs?.kind !== 'slabs') throw new Error(`Fine refinement requires baked slabs: ${row.id}`);
423
- const whole = new SlabLibrary(owner, product, row, slabs, refinementQueue(), coarse.ensure, async (part, scope, anchor) => {
423
+ const whole = new SlabLibrary(owner, product, row, slabs, refinementQueue(), coarse.ensure, async parts => {
424
424
  const game = ctx.game.runtime?.world?.game;
425
425
  if (game === undefined || game === null) return;
426
- const live = (): boolean => !owner.disposed && !owner.disposing && !scope.disposed && !scope.disposing;
427
- // The native warmer draws connected hidden roots. Borrow the
428
- // key's actual world frame, without exposing a partial anchor.
429
- anchor.updateWorldMatrix(true, false);
430
- const stage = new Group(); stage.visible = false; stage.matrixAutoUpdate = false; stage.matrix.copy(game.rootScene.matrixWorld).invert().multiply(anchor.matrixWorld);
431
- stage.add(part); game.rootScene.add(stage);
432
- const forget = scope.capture('disposers', () => { stage.removeFromParent(); });
433
- try { await game.warmSceneRoots([stage], live, undefined, { drawGeometry: true }); }
434
- finally { forget(); part.removeFromParent(); stage.removeFromParent(); }
426
+ const live = (): boolean => !owner.disposed && !owner.disposing && parts.every(({ scope }) => !scope.disposed && !scope.disposing);
427
+ // The native warmer draws connected hidden roots. Borrow each
428
+ // key's actual world frame, without exposing a partial anchor;
429
+ // one hidden root holds the publication's every part (NB3).
430
+ const root = new Group(); root.visible = false; root.matrixAutoUpdate = false;
431
+ root.matrix.copy(game.rootScene.matrixWorld).invert();
432
+ const staged = parts.map(({ part, anchor, scope }) => {
433
+ anchor.updateWorldMatrix(true, false);
434
+ const stage = new Group(); stage.matrixAutoUpdate = false; stage.matrix.copy(anchor.matrixWorld);
435
+ stage.add(part); root.add(stage);
436
+ const forget = scope.capture('disposers', () => { stage.removeFromParent(); });
437
+ return { part, stage, forget };
438
+ });
439
+ game.rootScene.add(root);
440
+ try { await game.warmSceneRoots([root], live, undefined, { drawGeometry: true }); }
441
+ finally { for (const { part, stage, forget } of staged) { forget(); part.removeFromParent(); stage.removeFromParent(); } root.removeFromParent(); }
435
442
  });
436
443
  refining.set(row.id, whole);
437
444
  libraries.set(row.id, { geometry: id => whole.geometry(id) }); return;
@@ -14,6 +14,7 @@ import { standingFigure, type FigureSkinState } from './standingFigure';
14
14
  import { skinEnvelope } from '../../grid/skinEnvelope';
15
15
 
16
16
  const skins = new FigureSkins();
17
+ const rootAt = new THREE.Vector3();
17
18
  const entered = new WeakMap<Scope, Map<string, Set<FigureRows>>>();
18
19
  function sourceId(ref: ScenePointRef): string {
19
20
  if (!('part' in ref)) throw new Error('Figure object requires a scene part');
@@ -139,6 +140,14 @@ export class FigureRows {
139
140
  private refreshPoint(): void {
140
141
  this.group.updateWorldMatrix(true, false);
141
142
  this.talkPoint.set(0, this.row.talkHeight, 0).applyMatrix4(this.group.matrixWorld);
143
+ // A figure on a borrowed root is placed after it is built (a kit figure's group goes to its feet once made): its body
144
+ // stands where the root is now, so a registry piece that follows the root holds it at the feet, not at the origin
145
+ // (SERVER-PARITY SS10b, Driftwood's Wendell). A standing person keeps its own collider (`update`).
146
+ if (this.person === undefined) {
147
+ const at = rootAt.setFromMatrixPosition(this.group.matrixWorld), box = this.row.collider;
148
+ this.collider.x = at.x; this.collider.z = at.z;
149
+ this.collider.yTop = at.y + (box?.kind === 'box' ? box.top : 0); this.collider.yBottom = at.y - (box?.kind === 'box' ? box.bottom : 0);
150
+ }
142
151
  }
143
152
  /** Refresh a borrowed pivot figure's world prompt without advancing its law. */
144
153
  syncAnchors(): void { if (this.live) this.refreshPoint(); }