threedog 0.8.0 → 1.0.1

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 (372) hide show
  1. package/CHANGELOG.md +223 -4
  2. package/README.md +6 -6
  3. package/core/assets/Animator.js +2 -0
  4. package/core/assets/Assets.js +44 -13
  5. package/core/assets/assetEntry.js +87 -22
  6. package/core/assets/assetHot.js +2 -1
  7. package/core/assets/assetReport.js +1 -2
  8. package/core/audio/Audio.js +24 -5
  9. package/core/base/I18n.js +6 -3
  10. package/core/base/Random.js +3 -1
  11. package/core/base/Vars.js +14 -4
  12. package/core/base/errorCodes.js +54 -16
  13. package/core/base/errorHints.js +12 -1
  14. package/core/base/errors.js +6 -4
  15. package/core/base/events.generated.js +10 -0
  16. package/core/base/follows.js +26 -0
  17. package/core/base/math.js +15 -8
  18. package/core/base/params.js +2 -2
  19. package/core/{saves → base}/saveValues.js +24 -6
  20. package/core/base/sections.js +97 -0
  21. package/core/base/spelling.js +32 -0
  22. package/core/base/validate.js +8 -29
  23. package/core/engine/Engine.js +61 -18
  24. package/core/engine/Loading.js +30 -3
  25. package/core/engine/copies.js +1 -1
  26. package/core/engine/headlessLoad.js +30 -13
  27. package/core/engine/lifecycle.js +30 -25
  28. package/core/engine/loop.js +22 -4
  29. package/core/engine/moduleSlots.js +91 -15
  30. package/core/engine/moduleTypes.js +13 -0
  31. package/core/engine/modules.js +248 -62
  32. package/core/engine/page.js +25 -8
  33. package/core/engine/plugins.js +15 -3
  34. package/core/engine/services.js +3 -0
  35. package/core/engine/startup.js +46 -36
  36. package/core/input/Input.js +39 -19
  37. package/core/input/inputKeyboard.js +39 -0
  38. package/core/input/inputPad.js +23 -2
  39. package/core/input/inputPointer.js +3 -1
  40. package/core/input/inputSeat.js +66 -0
  41. package/core/input/inputTouch.js +23 -6
  42. package/core/inspect/DebugOverrides.js +13 -2
  43. package/core/inspect/Describe.js +10 -6
  44. package/core/inspect/Inspect.js +31 -4
  45. package/core/inspect/UrlState.js +14 -10
  46. package/core/inspect/catalog.js +12 -5
  47. package/core/inspect/describeRender.js +3 -2
  48. package/core/inspect/describeText.js +6 -2
  49. package/core/inspect/metadata.generated.js +4140 -0
  50. package/core/inspect/pictureWriters.js +117 -33
  51. package/core/inspect/toolDoor.js +21 -0
  52. package/core/inspect/valueHistory.js +35 -0
  53. package/core/ops/Ops.js +32 -7
  54. package/core/ops/control.js +48 -23
  55. package/core/ops/holds.js +4 -3
  56. package/core/ops/opsAtomic.js +18 -6
  57. package/core/ops/opsCheck.js +7 -5
  58. package/core/ops/opsFail.js +5 -7
  59. package/core/ops/opsRun.js +2 -2
  60. package/core/ops/owned.js +20 -3
  61. package/core/ops/sharedPoint.js +7 -10
  62. package/core/ops/stacks.js +22 -1
  63. package/core/saves/SaveStore.js +52 -26
  64. package/core/saves/Saves.js +122 -27
  65. package/core/saves/saveApply.js +159 -61
  66. package/core/saves/saveFiles.js +30 -25
  67. package/core/saves/saveVersions.js +20 -6
  68. package/core/saves/session.js +76 -33
  69. package/core/saves/stateReplace.js +184 -0
  70. package/core/scene/Rays.js +21 -5
  71. package/core/scene/Views.js +6 -6
  72. package/core/scene/adaptive.js +13 -10
  73. package/core/scene/canvasBox.js +2 -0
  74. package/core/scene/compositeGround.js +72 -0
  75. package/core/scene/floor.js +17 -0
  76. package/core/scene/grid.js +2 -0
  77. package/core/scene/ground.contract.js +14 -0
  78. package/core/scene/ground.js +52 -17
  79. package/core/scene/pixel.js +154 -0
  80. package/core/scene/pixelRatio.js +167 -0
  81. package/core/scene/sceneDelta.js +3 -3
  82. package/core/scene/sceneMethods.js +11 -6
  83. package/core/scene/stepPoses.js +6 -1
  84. package/core/scene/thingExplain.js +1 -1
  85. package/core/scene/thingOps.js +22 -14
  86. package/core/scene/things.js +1 -1
  87. package/core/scene/tier.js +10 -0
  88. package/core/scene/view.js +126 -9
  89. package/core/stream/Batching.js +0 -1
  90. package/core/stream/Stream.js +24 -12
  91. package/core/stream/batchGroups.js +1 -0
  92. package/core/stream/scatter.js +5 -2
  93. package/core/stream/streamSources.js +2 -1
  94. package/core/threads/Commits.js +12 -7
  95. package/core/threads/Jobs.js +15 -5
  96. package/core/threads/Threads.js +5 -2
  97. package/core/time/Clock.js +3 -1
  98. package/core/time/skip.js +10 -4
  99. package/core/time/time.js +16 -10
  100. package/docs/AI.md +89 -72
  101. package/docs/API.md +18 -14
  102. package/docs/CODEMAP.md +68 -40
  103. package/docs/COMMANDS.md +22 -23
  104. package/docs/CONVENTIONS.md +120 -17
  105. package/docs/MIGRATING-0.8.md +2 -0
  106. package/docs/MIGRATING-1.0.md +101 -0
  107. package/docs/THREE.md +65 -12
  108. package/docs/api/cameraRig.md +3 -0
  109. package/docs/api/characters.md +13 -7
  110. package/docs/api/collider3d.md +9 -0
  111. package/docs/api/content.md +16 -15
  112. package/docs/api/dialogue.md +2 -1
  113. package/docs/api/engine.md +18 -16
  114. package/docs/api/events.md +14 -4
  115. package/docs/api/ground.md +2 -2
  116. package/docs/api/i18n.md +1 -1
  117. package/docs/api/input.md +2 -1
  118. package/docs/api/interactions.md +1 -1
  119. package/docs/api/inventory.md +1 -1
  120. package/docs/api/level.md +3 -2
  121. package/docs/api/nav.md +4 -2
  122. package/docs/api/particles.md +8 -5
  123. package/docs/api/pickups.md +1 -1
  124. package/docs/api/post.md +3 -4
  125. package/docs/api/quests.md +4 -2
  126. package/docs/api/rays.md +2 -0
  127. package/docs/api/rigid.md +3 -2
  128. package/docs/api/saves.md +8 -7
  129. package/docs/api/stream.md +4 -5
  130. package/docs/api/terrain.md +3 -4
  131. package/docs/api/terrainDraw.md +1 -1
  132. package/docs/api/timeline.md +2 -2
  133. package/docs/api/tools.md +3 -1
  134. package/docs/api/triggers.md +2 -0
  135. package/docs/api/vegetationDraw.md +1 -1
  136. package/docs/api/water.md +6 -2
  137. package/docs/api/weather.md +19 -4
  138. package/docs/api/weatherDraw.md +1 -1
  139. package/docs/api/world.md +1 -1
  140. package/docs/recipes/01-new-game.md +3 -3
  141. package/docs/recipes/02-npc.md +3 -4
  142. package/docs/recipes/03-items-pickups.md +11 -11
  143. package/docs/recipes/04-quests.md +2 -0
  144. package/docs/recipes/05-props-bake.md +9 -9
  145. package/docs/recipes/06-clock-events.md +6 -6
  146. package/docs/recipes/07-flow-scenes-pause.md +18 -15
  147. package/docs/recipes/08-weather-sky.md +5 -5
  148. package/docs/recipes/09-materials-lights-models.md +3 -3
  149. package/docs/recipes/10-blender-level.md +16 -4
  150. package/docs/recipes/11-vehicles.md +18 -6
  151. package/docs/recipes/12-navmesh.md +52 -8
  152. package/docs/recipes/13-animation.md +34 -8
  153. package/docs/recipes/14-custom-module.md +20 -8
  154. package/docs/recipes/15-perf.md +4 -4
  155. package/docs/recipes/16-dev-bridge.md +9 -8
  156. package/docs/recipes/18-world.md +13 -5
  157. package/docs/recipes/19-shooting-picking.md +3 -2
  158. package/docs/recipes/20-content-actions-save.md +26 -6
  159. package/docs/recipes/21-camera.md +17 -23
  160. package/docs/recipes/22-shop-gold.md +21 -12
  161. package/docs/recipes/23-ops.md +19 -15
  162. package/docs/recipes/26-ui-parts.md +3 -2
  163. package/docs/recipes/27-net.md +3 -3
  164. package/docs/recipes/28-terrain.md +3 -3
  165. package/docs/recipes/29-grid.md +1 -1
  166. package/docs/recipes/30-templates.md +10 -13
  167. package/docs/recipes/31-audio.md +2 -2
  168. package/docs/recipes/32-action-game.md +6 -5
  169. package/docs/recipes/33-stream-sources.md +4 -1
  170. package/docs/recipes/34-environment-lighting.md +7 -8
  171. package/docs/recipes/35-picture-from-reference.md +13 -9
  172. package/docs/recipes/36-ground-plants.md +3 -2
  173. package/docs/recipes/40-scene.md +11 -10
  174. package/docs/recipes/43-shader-patches-surfaces.md +7 -7
  175. package/docs/recipes/44-water-weather-hooks.md +9 -8
  176. package/docs/recipes/45-cascaded-shadows.md +3 -4
  177. package/docs/recipes/46-blender-art-route.md +3 -3
  178. package/docs/recipes/49-game-module-contract.md +2 -1
  179. package/docs/recipes/50-own-renderer.md +1 -0
  180. package/docs/recipes/51-capability-catalog.md +14 -8
  181. package/docs/recipes/52-around-the-picture.md +4 -4
  182. package/docs/recipes/55-mods-time-wrap.md +5 -4
  183. package/docs/recipes/56-webgpu-tsl.md +12 -1
  184. package/docs/recipes/57-control.md +30 -10
  185. package/docs/recipes/58-input.md +13 -0
  186. package/docs/recipes/60-judge-the-picture.md +1 -1
  187. package/docs/recipes/62-picture-code.md +106 -48
  188. package/docs/recipes/63-third-person-start.md +2 -1
  189. package/docs/recipes/64-particles.md +53 -4
  190. package/docs/recipes/65-swarm.md +2 -2
  191. package/docs/recipes/66-common-tasks.md +313 -0
  192. package/examples/action/.threedog/content-index.json +1 -1
  193. package/examples/action/GAMEMAP.md +3 -3
  194. package/examples/perf-island/.threedog/content-index.json +1 -1
  195. package/examples/perf-island/GAMEMAP.md +3 -3
  196. package/examples/perf-island/main.js +2 -2
  197. package/examples/plain-picture/GAMEMAP.md +3 -1
  198. package/examples/rc2d/GAMEMAP.md +1 -1
  199. package/examples/rc2d/rc2d.js +1 -1
  200. package/examples/styletest/.threedog/content-index.json +1 -1
  201. package/examples/styletest/GAMEMAP.md +3 -3
  202. package/examples/webgpu-tsl/GAMEMAP.md +1 -1
  203. package/examples/world/.threedog/content-index.json +1 -1
  204. package/examples/world/GAMEMAP.md +5 -4
  205. package/examples/world/main.js +3 -3
  206. package/index.d.ts +8 -5
  207. package/index.js +22 -1
  208. package/llms.txt +2 -1
  209. package/modules/ambience/Ambience.js +5 -3
  210. package/modules/calendar/index.js +7 -5
  211. package/modules/camera/FirstPersonCamera.js +3 -3
  212. package/modules/camera/FixedCamera.js +34 -20
  213. package/modules/camera/FollowCamera.js +20 -11
  214. package/modules/camera/RtsCamera.js +1 -0
  215. package/modules/camera/common.js +33 -22
  216. package/modules/camera/pixelSnap.js +62 -0
  217. package/modules/characters/Character.js +136 -43
  218. package/modules/characters/NPC.js +60 -28
  219. package/modules/characters/assetModel.js +2 -2
  220. package/modules/characters/astar.js +47 -28
  221. package/modules/characters/character.contract.js +21 -0
  222. package/modules/characters/contract.js +17 -3
  223. package/modules/characters/index.js +94 -34
  224. package/modules/characters/moveHelpers.js +80 -15
  225. package/modules/characters/mover.contract.js +14 -0
  226. package/modules/characters/movers/common.js +6 -4
  227. package/modules/characters/movers/rapier.js +12 -5
  228. package/modules/characters/movers/simple.js +25 -12
  229. package/modules/characters/movers/support.js +18 -7
  230. package/modules/characters/npcAvoid.js +15 -12
  231. package/modules/characters/npcSim.js +75 -25
  232. package/modules/characters/npcView.js +13 -6
  233. package/modules/characters/pathAsync.js +74 -24
  234. package/modules/characters/pathJob.js +38 -21
  235. package/modules/characters/player.js +59 -47
  236. package/modules/characters/seat.js +56 -0
  237. package/modules/characters/vehicle.contract.js +8 -5
  238. package/modules/characters/walkTo.js +31 -18
  239. package/modules/collision/Collision.js +44 -26
  240. package/modules/collision/contract.js +2 -2
  241. package/modules/collision/grid.js +6 -1
  242. package/modules/content/explain.js +1 -1
  243. package/modules/content/fields.js +3 -3
  244. package/modules/content/ids.js +3 -1
  245. package/modules/content/index.js +83 -27
  246. package/modules/content/loader.js +110 -130
  247. package/modules/content/markers.js +1 -1
  248. package/modules/content/models.js +48 -14
  249. package/modules/content/packs.js +2 -1
  250. package/modules/content/places.js +5 -4
  251. package/modules/content/props.js +8 -6
  252. package/modules/content/rules.js +29 -47
  253. package/modules/content/templates.js +66 -35
  254. package/modules/content/words.js +19 -6
  255. package/modules/debug/DebugPanel.js +4 -2
  256. package/modules/flow/contract.js +1 -0
  257. package/modules/flow/index.js +24 -14
  258. package/modules/gameplay/Container.js +5 -2
  259. package/modules/gameplay/Containers.js +9 -1
  260. package/modules/gameplay/Dialogue.js +82 -25
  261. package/modules/gameplay/Interactions.js +61 -32
  262. package/modules/gameplay/Inventory.js +56 -13
  263. package/modules/gameplay/Quests.js +133 -24
  264. package/modules/gameplay/boxOps.js +7 -0
  265. package/modules/gameplay/dialogueBubbles.js +14 -9
  266. package/modules/gameplay/inventoryOps.js +11 -7
  267. package/modules/gameplay/pickups.js +43 -16
  268. package/modules/gameplay/questLog.js +4 -2
  269. package/modules/gameplay/questSave.js +6 -1
  270. package/modules/gameplay/quests.contract.js +1 -1
  271. package/modules/grid/Grid.js +1 -1
  272. package/modules/grid/Layer.js +8 -4
  273. package/modules/grid/index.js +21 -15
  274. package/modules/grid/ops.js +43 -46
  275. package/modules/grid/tiles.js +1 -1
  276. package/modules/hlod/index.js +6 -3
  277. package/modules/hud/index.js +6 -4
  278. package/modules/hud/parts.js +4 -4
  279. package/modules/level/contract.js +2 -2
  280. package/modules/level/heightfield.js +17 -21
  281. package/modules/level/index.js +83 -26
  282. package/modules/level/load.js +165 -48
  283. package/modules/level/nodes.js +34 -16
  284. package/modules/lights/index.js +6 -3
  285. package/modules/lights/sources.js +3 -1
  286. package/modules/music/Music.js +4 -2
  287. package/modules/nav/contract.js +7 -5
  288. package/modules/nav/index.js +174 -44
  289. package/modules/nav/navPath.js +45 -10
  290. package/modules/net/index.js +1 -1
  291. package/modules/particles/Particles.js +85 -22
  292. package/modules/particles/effect.js +80 -28
  293. package/modules/particles/shaders.js +17 -0
  294. package/modules/photo/Photo.js +12 -10
  295. package/modules/rigid/RigidBodies.js +200 -57
  296. package/modules/rigid/Vehicles.js +15 -5
  297. package/modules/rigid/collider3d.contract.js +26 -0
  298. package/modules/rigid/ragdoll.js +55 -44
  299. package/modules/rigid/ragdollBones.js +83 -33
  300. package/modules/rigid/refresh.js +10 -0
  301. package/modules/rigid/sync.js +46 -15
  302. package/modules/settings/Settings.js +84 -37
  303. package/modules/settings/apply.js +15 -8
  304. package/modules/settings/sections.js +7 -4
  305. package/modules/settings/strings.js +2 -2
  306. package/modules/sky/skyModule.js +3 -1
  307. package/modules/swarm/Swarm.js +16 -6
  308. package/modules/terrain/ChunkManager.js +10 -16
  309. package/modules/terrain/index.js +17 -11
  310. package/modules/terrain/terrainEdit.js +13 -2
  311. package/modules/terrain/terrainGen.js +5 -3
  312. package/modules/terrain/terrainShape.js +1 -1
  313. package/modules/timeline/Timeline.js +58 -26
  314. package/modules/timeline/Tween.js +19 -13
  315. package/modules/timeline/shots.js +19 -10
  316. package/modules/triggers/index.js +87 -20
  317. package/modules/vegetation/Vegetation.js +4 -3
  318. package/modules/vegetation/draw.js +16 -0
  319. package/modules/vegetation/groundChunks.js +10 -7
  320. package/modules/vegetation/index.js +30 -7
  321. package/modules/water/Water.js +6 -2
  322. package/modules/weather/Weather.js +16 -15
  323. package/modules/weather/weatherDraw.js +7 -6
  324. package/modules/world/World.js +20 -7
  325. package/modules/world/explain.js +1 -1
  326. package/modules/world/index.js +13 -6
  327. package/modules/world/persist.js +23 -8
  328. package/modules/world/pos.js +4 -4
  329. package/modules/world/records.js +13 -7
  330. package/modules/world/sim.js +74 -23
  331. package/modules/world/simFar.js +2 -2
  332. package/modules/world/state.js +31 -6
  333. package/modules/world/thingSource.js +16 -3
  334. package/modules/world/views.js +19 -8
  335. package/package.json +7 -1
  336. package/render/PostFX.js +47 -29
  337. package/render/backend.js +5 -1
  338. package/render/fx/particles.tsl.js +8 -6
  339. package/render/fx/postWebGPU.tsl.js +3 -3
  340. package/render/layers.js +1 -1
  341. package/render/lightmap.js +23 -3
  342. package/render/occlusion.js +43 -12
  343. package/render/patches.js +2 -2
  344. package/render/postWebGL.js +4 -3
  345. package/render/probes.js +25 -0
  346. package/render/shadows.js +2 -2
  347. package/types/core.d.ts +142 -55
  348. package/types/gameplay.d.ts +92 -40
  349. package/types/generated/core/base/I18n.d.ts +2 -2
  350. package/types/generated/core/input/Input.d.ts +16 -2
  351. package/types/generated/core/input/inputSeat.d.ts +26 -0
  352. package/types/generated/core/inspect/DebugOverrides.d.ts +15 -1
  353. package/types/generated/core/ops/Ops.d.ts +2 -1
  354. package/types/generated/core/ops/control.d.ts +12 -2
  355. package/types/generated/core/saves/Saves.d.ts +26 -6
  356. package/types/generated/core/saves/session.d.ts +1 -1
  357. package/types/generated/core/scene/Views.d.ts +1 -1
  358. package/types/generated/core/stream/Stream.d.ts +6 -4
  359. package/types/generated/modules/grid/Grid.d.ts +1 -0
  360. package/types/generated/modules/particles/Particles.d.ts +4 -3
  361. package/types/generated/modules/timeline/Timeline.d.ts +5 -4
  362. package/types/generated/modules/weather/Weather.d.ts +1 -7
  363. package/types/generated/modules/world/World.d.ts +6 -4
  364. package/types/generated/render/PostFX.d.ts +6 -14
  365. package/types/nav.d.ts +36 -4
  366. package/types/physics.d.ts +55 -7
  367. package/types/pixel.d.ts +75 -0
  368. package/types/world.d.ts +14 -8
  369. package/ui/Parts.js +9 -2
  370. package/ui/theme.js +2 -2
  371. package/core/scene/engineCamera.js +0 -32
  372. package/modules/camera/projection.js +0 -21
package/CHANGELOG.md CHANGED
@@ -2,6 +2,229 @@
2
2
 
3
3
  What changed in each version and how a game upgrades.
4
4
 
5
+ ## 1.0.1 (2026-11-07)
6
+
7
+ - Docs only: the install lines in the package READMEs name 1.0 (0.9 was never on npm).
8
+
9
+ ## 1.0.0 (2026-11-07)
10
+
11
+ - A request awaited inside a save load without its `turn` fails with `save-nested` after `engine.loading.timeoutMs` with no sign of life, and the load fails its normal way. It used to wait for good.
12
+ - `detach` is gone from the engine: write `obj.removeFromParent()`. `engine.remove` stays.
13
+ - A `turn` kept after its load ended no longer lets `content.load` jump the line: it waits behind the load before it, as `level.load` did.
14
+ - `applyState({ save })` and `{ play }` answer in `refused` when the load or the new game failed, so `threedog state` and a scenario stop there. The title stays open. They used to answer ok.
15
+ - An item's `use` that answers `{ ok: false, code }` or throws keeps the item: `inventory.use` is atomic, sends no `item:use`, and hands the failure to the caller. It used to spend the item and answer ok.
16
+ - `engine.i18n.locale` is read-only: `setLocale` is the one way to change the language. Writing it skipped the name lookup and `i18n:change`.
17
+ - A failed `content.load` no longer marks the pack's vegetation table for good: the same pack loaded again registers its plants.
18
+ - A pack that names an op nothing defines, loaded in a running game, leaves nothing behind. Its actions and quests used to stay, and the name then failed every later load.
19
+ - A world save holding a record faster than its time channel (`time.local` above 1) loads. Its debt mark goes below zero, and the load refused that as damage, the rollback of a failed load too.
20
+ - A tween whose write throws ends there and its promise rejects: `await engine.timeline.tween(...)` can now throw, and a `timeline.play` step with it ends `failed` and gives control and input back. It used to never answer. A tween nobody awaits is reported as an unhandled rejection, once.
21
+ - A cutscene writes a character or the camera only while it is the holder in charge. A path on a ragdoll or a seated rider, and a shot under a newer `takeCamera` or a newer run, keep their time and write nothing; back in charge they write where their clock is.
22
+ - The default physics floor follows the ground: a level installed while running takes it away, and a ground source that leaves brings it back. Terrain chunks and trunks leave with their ground source too. `ops.undo` of a failed run answers `nothingToUndo` instead of throwing.
23
+ - A solid prop is in a new `collision` or `collider3d` on the line after `engine.use`. It used to come back on the next frame.
24
+ - A save part's `load(data, turn)` and a module's `afterLoad(engine, turn)` can change level and load packs after an await: `level.load(x, { turn })` and `content.load(x, { turn })` go at once. It used to wait for itself, for ever. Without the turn a call waits in line like any outside request, and dev says so when it stalls (`save-nested`).
25
+ - A part registered during a load runs after it, whole, in its own turn. Its first lines used to run inside the load.
26
+ - A failed pack ends only when the old level and registrations are back, and saves and loads asked meanwhile wait. A restore that fails reaches the caller (`err.notRestored`). It used to reload in the background and swallow the failure.
27
+ - `content.load` returns a Promise for this load, not `engine.content`.
28
+ - One reading route in the docs: taking over a game starts at its status notes, a new feature at `AI.md` or `threedog how`, then the recipe and API page. `AI.md` calls its table a recommendation, and `API.md` no longer tells a game to write `?.` for a module it needs.
29
+ - MCP `check` now lists the first bypass hints with file, line, advice and how to switch them off, the same ones `threedog check` prints, one of each kind first. It used to drop them.
30
+ - In a game that runs, `threedog how` answers the most asked tasks with the lines to add (recipe 66 "In an existing game": where they go, what to skip, the failure to handle, the check; a test runs them). An answer shows an example only if it belongs to the chosen route.
31
+ - `threedog how` with no words opens a category list; `--browse <category>` lists capabilities, `--card <id>` shows one: what it solves, when it does not fit, install, dependencies, time, saves, an example and what verified it. The MCP tool takes `browse` and `card` fields. `--list` is gone.
32
+ - A scenario can say `{ "until": { ... }, "within": seconds }`: reach this state by the deadline, then check the end with `expect`. A win that freezes early passes; an error, a freeze before the state, a stuck load and a missed deadline each name themselves. `step` stays strict.
33
+ - `before` / `after` that contradict the stages through a capability are refused with `module-order`, as they are by module name. They used to warn and drop the line. `water` no longer states `after: ['sky']`: it reads the horizon color, and a frame's lag does not show.
34
+ - Frozen physics queries refresh through one wrapper that gives the step length back even if Rapier throws. Checked on Rapier 0.21: no narrower native route exists, and the refresh leaves velocities, sleep, contacts and a pending kinematic move alone.
35
+ - A swap is finished when queries can trust it: after `engine.use(collision(), { replaces: 'collision' })` the next line reads the level walls, frozen or not. A module that feeds a provider says so with `ctx.feeds(capability, fn)`; a provider that refuses what it is fed fails its `use()` and the old one comes back. A copy rebuilt through `follows` that throws is built again at the next read.
36
+ - An old `engine.haltLoop` or `views.show` handle no longer ends a later hold of the same name.
37
+ - `world.simulate` on a time channel pays the time as it passed. A far or tiered record, `engine.skip` and a saved debt no longer rewrite the past at the speed of the settlement: half a second at 1x and half at 0.5x gives 0.75, not 0.5. Each record's own `time.local` rate counts the same way. Older saves load; what they owe is read at the first speed it meets.
38
+ - A dialogue `do` that throws ends the conversation and answers its `say()`, on a bubble too. It used to leave a line nobody could finish.
39
+ - A cutscene has one ending: `finished`, `skipped`, `dropped` or `failed`. `timeline.play()` resolves with `{ ending, error? }`, `timeline:end` carries the same, and describe counts it; `{ skipped }` is gone. A dropped or failed run runs no more steps, a parallel branch included, and gives the screen back. A new game or `dispose` drops a run: its `do` steps no longer run on what came after.
40
+ - A failed atomic op puts `once` items, interaction counters and content markers back with everything else. Every engine save part now says whether an atomic op covers it, or why not (`notAtomic`, rule R67).
41
+ - A reward that cannot be given is no longer lost in silence. `content.run` answers `{ ok: true }` or a failure listing each word that failed, and `content:failed` fires; `{ give }` reports what did not fit, part of a stack too. A finished quest fires `quest:unpaid`, tells the player (`quests.notify` gets type `'unpaid'`), and owes the items until there is room (saved, shown in `quests.list()`); `onUnpaid` lets the game decide instead.
42
+ - An async `onUse` is judged when it settles: one that fails or throws spends no `once` item and adds no count, and it cannot be used twice while it waits.
43
+ - Physics queries and rays see walls, solids, bodies and moves at once, also while frozen; world boxes stand on a new level at once. `engine.remove` of a model or a parent also removes its body. Public vectors must be finite: NaN and Infinity are refused with `bad-position`.
44
+ - `exit()` takes the first walkable exit a vehicle offers (`exitPosition(seat, n)`; `rigid` cars offer four) and answers `false`, rider seated, when none is. `exit({ force: true })` always gets out. It used to step into the wall and shove the car
45
+ - A seat is one relation owned by `characters`, saved with its seat number. A load keeps who sat where; a car built after the load takes its rider; a game's own vehicle keeps its rider through a load (`characters.addVehicle`); a cutscene over a driver lets go of the pedal; a rider stays on the seat with no holder moving it. `interaction.use`'s `approaching` has `remove()`, like the walk it stands for
46
+ - A walk is a task of the control slot, and one list says what ends it: a load or new game, a level change, a placement, a seat, physics taking the body, the character going. It used to outlive the level, the seat and the placement, and wait for ever under a ragdoll. `character.placeAt` drops an NPC's path as `npc.placeAt` does
47
+ - The view has one write route. The first holder of the camera records the view it took and the last one out lands it, so a slider moved during a shot takes effect at the end and overlapping shots no longer leave a half-way fov. A rig told to move during a hold records it and lands at release. A hold from writing the camera directly ends at a new game. The first-person body hides only while that view shows.
48
+ - Quality presets are shares of what the game set: High lets everything through, and no preset raises anything. MSAA never changes during a run: the settings row applies at the next start, and Low no longer turns the post chain on. `engine.tier` is the one quality value: the device's tier unless the player's preset says otherwise, for particles and everything else that reads it. `settings.set` refuses a key no row owns. Terrain and vegetation offer their own settings rows.
49
+ - Tools: `verify` and `step` share one step result, and less time than asked is a failure in both. `check` names a local file an asset pack names that `public/` lacks. A switched-off module has the state `disabled`; `engine.disabledModules` is gone, `describe().disabledModules` is derived from the state, and the short describe names it.
50
+ - `applyState` takes its module keys from each module's `stateKeys`: core no longer lists them.
51
+ - Loads and state turns, one rule per cause. A level file that fails now fails, whatever the manifest falls back to: no gray level, no `level:loaded`, and `saves.apply` answers false. Every load has one limit, `engine.loading.timeoutMs`, measured as silence, so a file that never answers no longer freezes `start()`, `level.load` or a load, and a load everybody stopped waiting for is aborted. `flow.transition` rejects at the same limit and gives the screen back. `level.load` during a save load waits for it. Autosave waits for the end of a door trip or a cutscene. A failed load puts a code-built level back. A content pack never commits inside a state replacement. A session turn on a disposed engine answers false.
52
+
53
+ - An unloaded level takes its `world.zone` and `level.spawn` with it. `unuse('content')` takes its hud markers off the screen. Path rasters no longer outlive the collision module or the playthrough that made them
54
+ - A collider with no `y` stands on the ground as it is now: after `terrain.edit` the rigid copy of a `collision.addBox` moves with the ground, so a crate no longer falls through a post left at the old height
55
+ - `engine.skip` during a skip rejects with `skip-busy`, as its doc says. It used to resolve, and its end unfroze the game during the first one's fade
56
+ - `assets.release` keeps a model whose geometry was handed out, as `trim` does
57
+ - `saves.register` on a held key throws `save-key-taken`. It used to take the part away from its owner in silence
58
+ - `replaces` sees more than the one module it names. `engine.use(terrain(), { replaces: 'terrain' })` now installs the new `terrainDraw` too, where the old drawing part stayed on a terrain that had gone and the new one was dropped with a warning; weather and vegetation act alike. A hold a rig opened on the camera ends with the rig, so the next rig moves. A live ragdoll gives its character back when rigid leaves. A swap, failed or not, leaves the game on the level it stood on, and a pack's older level no longer takes it back; a newcomer with its own `url` or `scene` still opens there
59
+ - A module that leaves takes what it registered with it. `unuse('characters')` used to hang the world step with a near NPC; `unuse('rigid')` broke `raycast({ targets: 'all' })`; `unuse('level')` left record nodes in the scene and in rays; `unuse('inventory')` left its touch button. `input.touchButton` and `assets.onSwap` now return `{ remove() }`; a button two parties asked for stays until the last one leaves
60
+ - A template's physics prop comes back from a load as it was saved: turned, moving, asleep or in the air. It used to land upright on the ground. A load no longer writes a change for a crate nothing touched, and a crate that was nudged stays nudged in a save (a nudge under 5 cm used to count as settling and was lost). A body keeps the speed it fell asleep with.
61
+ - `engine.unuse('rigid')` or replacing it stands a limp character back up. It used to stay held by the old physics for good.
62
+ - Weather set with `seconds: 0` reads the same after a load.
63
+ - `thing.set` with no height stands a template's physics prop on the ground. It used to go half into the floor and could fall through it.
64
+ - `stream.teleport` belongs to the state it was asked in: a new game or load (`saves.load` too) that goes through during the trip abandons it. It rejects with `stream-removed` and the player stays. It used to land on the new state, below ground at the old door's destination. A `flow.transition` still fading out is dropped the same way, and `engine.skip` is now cancelled by `saves.load` as well.
65
+ - Autosave no longer overwrites a save after `session.quit()` with no title part: `session.playing` stays false until a new playthrough starts.
66
+ - Every load entry acts alike. `saves.apply` ends a walk and rebuilds what `saves.load` does; any save put back closes the title; a rolled-back `saves.load` or `saves.apply` fires `session:failed` with `kind: 'quick'`. A rollback keeps rigid velocities and quest markers.
67
+ - A new game leaves no run state behind: holds taken in play, `world.anchor`, `audio.state` (a new save part, `audio`), a level loaded after a code-built opening scene.
68
+ - A module's function timer follows the module at a new game: gone with it, kept when it was used after `start()`.
69
+ - What joins after `start()` joins the new-game state: a player where it began, a part as its `init` left it, a pack's `startItems`.
70
+ - The title track plays after quit whichever of `flow` and `music` was installed first. `session.load` keeps the vehicle camera and a view saved on a switched rig.
71
+ - `flow.transition` goes on across a load that fails, as `stream.teleport` does. An atomic op's rollback puts a `NaN` back as it was.
72
+ - A second `engine.skip` during one under way rejects, as its doc says; its end used to unfreeze the game during the first one's fade.
73
+ - Dev warns when a second `saves.register` takes a key another part holds. A dev gameplay error stays frozen until reload, a new game included: documented, and guarded by a test.
74
+
75
+ - `stream.teleport` belongs to the state it was asked in: it waits out a running load, and a new game or load (`saves.load` too) that goes through abandons it. It rejects with `stream-removed` and the player stays. It used to land on the new state, below ground at the old door's destination. A load that fails leaves the trip going, and a level change does not touch it. A `flow.transition` running or in line is dropped the same way, without bringing the old track back, and `engine.skip` is now cancelled by `saves.load` as well.
76
+ - `saves.apply` fires `save:loaded`, as `saves.load` does: a walk ends on it, and the HUD quest list and calendar ranges rebuild. Its `slot` argument is what the event carries.
77
+ - A save part named `__proto__` is refused at `saves.register`. Its data used to be lost without a word.
78
+ - `saves.save` refuses data with `NaN` or `Infinity` at any depth, naming the part and the path, and the slot keeps its last good save. It used to answer true and store `null`. A game with a field like `hp: Infinity` saves a finite number or leaves the field out.
79
+ - A longer view distance builds stream entries and world models without the player moving.
80
+ - A delete the store refused lists the slot again.
81
+ - `saves.apply(x); saves.save('s'); saves.apply(y)` stores x on a page with `afterLoad` hooks too.
82
+ - A save part may be named like an Object method (`constructor`, `toString`).
83
+ - A `commits.request` made during a failed `session` load's rollback lands.
84
+ - `views.current` is declared `string | null`, as it is at runtime.
85
+
86
+ - New event `level:unloaded { source }`: a level left, by `unload()` or a switch just before the new one commits. On it the navmesh goes (`nav.ready` false, no path of any size from the old level), hlod lets the level go, grid tiles and A* rasters drop what they read from it. `level.ready` stays true after `unload()` because nothing is loading; `level.root` says whether a level stands, and `level.playable` is false.
87
+ - `walkTo` ends with its playthrough: `session.newGame`, `session.load` and `quit` settle it as `cancelled` and give the control slot back. It used to go on walking in the new game.
88
+ - The level's walls reach a replaced `collision` while the engine is frozen or skipping, not only on the next fixed step.
89
+ - `engine.unuse('cameraRig')` puts back the perspective view and the fov it found.
90
+ - A replaced provider no longer leaves consumers on the old one. After `replaces` on `rigid`, a template's crates get bodies in the new module where play left them (a template reload that changes, adds or removes `body` reaches built copies too), riders leave the old module's car by the normal exit, and rapier movers build anew. NPC agents, `findPathAsync`, weather drawing, interaction entries of props, NPCs, pickups and cars, and a replaced camera rig all follow the provider installed now. Version numbers no longer decide this: they count per module, so compare the object. Game code that keeps a handle does the same (recipes/55).
91
+ - `replaces: 'world'` and `unuse('world')` are refused (`module-replaces`, `module-unuse`) once a module that uses the world is installed or the game has started, and nothing changes: it used to break the game. Install your world before the modules that need it.
92
+ - One way to an orthographic view: a real `THREE.OrthographicCamera` in `engine.camera`. A rig's `projection: 'orthographic'` now does exactly that, and the next perspective view brings the first camera back, so the camera class that acted as both is gone: `engine.camera` is a plain three.js camera, always. `camera.orthoSize` and `camera.isEngineCamera` are gone (`MIGRATING-1.0.md`).
93
+ - Navmesh paths fit the body that asks: a `radius` on `findPath` or `findPathAsync`, and `walkTo` and NPCs with theirs, gets a mesh of that size, built on first ask and rebuilt with the level. Small bodies take gaps a large one cannot; a body too wide for every way gets `noPath` where its `walkTo` used to end `'stuck'` at the gap. One size costs nothing extra. Recipe 12 section 5.
94
+ - `findPathAsync` on A* sees every floor of a level: ground under a bridge or a lower storey is walked as `findPath` walks it. It used to read only the top one, so a steep roof closed the road under it and a slope under a deck did not count.
95
+ - `level({ url })` with a pack that sets `level`: `content.load` before `start()` now ends as it does after `start()`, the pack whole and its level up, and the url file is not fetched. The url load used to overtake the pack and drop all of it, in silence. If the pack's level cannot load, the url is the level.
96
+ - A pack whose `level` is overtaken by a newer `level.load`, save load or unload is no longer lost: only its `level` gives way, and its other sections commit on the level that won, once that load has ended. A newer load that fails leaves the old level, and the pack's other sections still go in. An overtaken `level.load` now resolves when the newer load has ended.
97
+ - Two engines on a page: gamepads follow the keyboard, so only the engine last pressed or focused (the first one until then) reads them, seats included. An engine alone on a page reads a pad as before.
98
+ - The level's `col_` walls and solid props go into whichever `collision` is installed, tilted props into whichever `collider3d`: after a `replaces`, a failed one, or a module that came late or came back. They used to stay behind in the old module, so a character walked through. `module:restored` now fires after every swap, with the fresh modules, once their `init` is done, and content sections load into a newcomer that declares them, as a `content.load` on a running game would. A newcomer with its own format that refuses a pack written for the old holder gets a warning naming the pack, and the game runs on.
99
+ - `level({ url })` with a pack that sets `level`: `content.load` before `start()` now ends as it does after `start()`, the pack whole and its level up, and the url file is not fetched. The url load used to overtake the pack and drop all of it, in silence. If the pack's level cannot load, the url is the level. A pack overtaken by a newer `level.load` still goes, and now warns.
100
+ - Two engines on a page: gamepads follow the keyboard, so only the engine last pressed or focused (the first one until then) reads the pads no seat is bound to. A seat hears the pad it was given on any engine, and the owner leaves that pad alone. An engine alone on a page reads a pad as before.
101
+ - The level's `col_` walls and solid props go into whichever `collision` is installed, tilted props into whichever `collider3d`: after a `replaces`, a failed one, or a module that came late or came back. They used to stay behind in the old module, so a character walked through. `module:restored` now fires after every swap, with the fresh modules, once their `init` is done, and content sections load into a newcomer that declares them, as a `content.load` on a running game would.
102
+ - Recipe 66 has two more whole examples, both run by its test: two areas built in code that a save returns to by their manifest names, and a ladder that goes on after a load mid-climb.
103
+ - Rule R40 no longer calls a `subtitle` option and a canvas lookup on one `createEngine` line a dialogue box.
104
+ - `thing.set`, `world.set` and `world.move` on a live character (the player, an NPC with a model) are its `placeAt`: they used to answer ok and be undone by the next step.
105
+ - A write to a record with `positionFrom: 'view'` moves its model and any rigid body on it, instead of being overwritten at the end of the step; `rot` and `scale` on a template with a `body` build a new body.
106
+ - `rot` and `scale` written to a character's record (`world.set`, `thing.set`) reach the character and survive a rebuild and a load; what it cannot obey is refused by name. `thing.set` no longer drops the x and z of `rotation` and `scale` arrays.
107
+ - Undo of a `thing.set` that ended a ride seats the character again, or answers `ownerRefuses` if the seat is gone or taken; `ops.define` takes `canUndo` for such answers. `placeAt` on a ragdoll carries the whole body there at rest, where the next step used to put it back.
108
+ - `placeAt` on a seated character, and so any write to its record's position, ends the ride and puts it there: the seat used to pull it back on the next step.
109
+ - One entry each: `stream.setRadius`, `weather.setAuto` and `post.setAntialias` are gone; assign `stream.radius`, `weather.auto` and `post.antialias`, which do the same. The command `threedog eval` is gone; `threedog js` is the one name.
110
+ - `threedog test` no longer counts a check labelled `skipped:` as passed: the summary names it and says how many did not run.
111
+ - `engine.skip(null)` fails with `skip-amount` like `engine.skip({})`, not a TypeError. Bad arguments throw at the call, and the docs now say so.
112
+ - The perf island example opens again: its op name was refused by the `noun.verb` rule.
113
+ - `engine.camera = cam` takes a real `THREE.PerspectiveCamera` or `THREE.OrthographicCamera`: rendering, post, picking, shadows, audio, rigs and `pixelSnap` go on with it, and resize keeps its frustum. Other classes are refused with `camera-option`. The type of `engine.camera` is now the union of the two, so TypeScript code reading `.fov` narrows first.
114
+ - Terrain: `terrain.setViewChunks` and `terrain.setDensity` are gone; assign `terrain.viewChunks = n` and `terrain.density = d`, which do the same. Density thins plants without a collider only, so it never changes collision.
115
+ - Declarations: `terrain()` and `vegetation()` are declared as the two modules they return, like `weather()`; nothing changes in a game that passes them to `engine.use`. The class names `Ambience`, `Budget`, `Calendar`, `DebugPanel`, `Grid`, `Grids`, `Layer`, `Music`, `Net`, `Particles`, `PostFX`, `Sky`, `SoundHandle`, `Swarm`, `Timeline`, `Water`, `Weather`, `WeatherDraw` and `World` are types only, as they always were: nothing can import them as values. The `weather.*` names (`weather.auto`, `weather.current`, `weather.defineField`, `weather.label`, `weather.lightningBrightness`, `weather.name`, `weather.overcastColor`, `weather.particles`, `weather.set`, `weather.setAuto`, `weather.types`) are unchanged, now counted as a module's.
116
+ - `compositeGround` with `rigid`: terrain inside a level's region was solid but not on the ground. The hills stood as invisible collision inside the level, so a dropped box stopped in mid-air over a lake. The terrain's physics triangles now stop at the regions where another part answers.
117
+ - `mover: 'rapier'`: a swimmer moved to a place with no water, or whose water was removed, froze the game with a NaN position. It falls and lands now.
118
+ - A content pack with a `level` file now commits as a whole once the file is here: `{ place: 'npc_home' }` reads the new level's marker, and a later pack of the same load, or a later `content.load`, waits for it. If the file fails, nothing of the pack commits. Code right after `content.load` cannot read such a pack's sections yet; wait for `start()` or `level:loaded`. A pack refused by a section leaves the level as it was, a load in flight included. A section may declare `cancel(prepared, c)` to let go of what its `prepare` holds.
119
+ - A save that names the current level now drops a `level.load` still downloading. Before, the file landed on top of the loaded save.
120
+ - `engine.unuse('level')` and `{ replaces: 'ground' }` take the level with the module: its scene, `col_` walls and what `level.track` holds. Before, they stayed behind.
121
+ - Object contracts (`mover`, `vehicle`, `ground`, `collider3d`) list their members under `api` like every other contract; a replacement's own `contract.js` with `methods` should rename it.
122
+ - A content section's `fields` key is gone: nothing read it for a section. A game kind's and a template's `fields` are unchanged.
123
+ - A template with a `body` and a per-axis `scale` builds: the array went into its resting height and the model failed to appear. A place turned on a reload now turns a record with an `[x, y, z]` rot too, and the editor's turn handle keeps the three numbers.
124
+ - `compositeGround`: `terrain:void` fires for rigid bodies and ragdolls again when one part is a level. The void height comes from the parts that have one.
125
+ - `compositeGround` region: `(x, z) => boolean` or `{ volume }`, the shape water and trigger zones take. `{ circle }` and `{ rect }` are gone: write them as a function.
126
+ - `slope` and `groundType` with a `refY` pick the layer on a level, as `surface` always did, so walkability and footsteps under a bridge read the ground under the bridge.
127
+ - `quests.list()`: a step counts as done once the quest left it. A step `next` jumped over stays not done, and a step a loop came back to is current and not done.
128
+ - A* (`findPath` without `nav`): a goal on a floor the walker can't reach is `noPath`, and `walkTo` ends with that status. It used to be `ok` with a path that ended under the goal.
129
+ - `compositeGround({ parts })` could not be installed: its only option was refused as unknown. It works now; recipe 10 section 6 shows it.
130
+ - Water goes by height: a character, `describe().player.inWater` and buoyant rigid bodies now pass their own height to `waterAt`. Before, a character walking under a lake was lifted through the ceiling to swim. A game's `addWaterBody({ query })` now gets `y` from these too.
131
+ - `docs/MIGRATING-1.0.md`: every change an existing game can hit since 0.9.0, as what you will see and what to do. A `preventDefault` on `character:fall` and a `thing.explain()` now answer with the fix instead of a bare TypeError.
132
+
133
+ - Local players on one screen: `engine.input.seat({ pad, keys })` is one player's own keys and gamepad, read like `engine.input`; `createPlayer({ id, input })` adds a player with that seat and its own world record (no `id`: the one player, as before); `characters.moveInput` takes an optional seat (no argument: as before); `removePlayer(id)`; `engine.player` stays the first player. Interactions, footstep sounds and NPCs giving way still follow `engine.player` only. Recipe 58.
134
+ - Data checks that ran only in development now hold in release: a NaN or short position (`world.add`, `move`, `set`) is refused and writes nothing; an op with a missing required arg or an `id` with no record fails with `badArgs` before `run`; `world.set` cannot change a record's id or kind; two NPCs with one name and no id, a `once` interaction with no stable id, and a template state value outside its fields all throw. A game that passes its development run is unaffected.
135
+ - Contracts state position authority: the characters, mover and vehicle contracts have a `position` entry naming who may write a character's position, and `@threedog/tools/contract` checks any contract that has one. Nothing changes at run time.
136
+ - A `picture` or `ui` module disabled after an error now gives back what it borrowed with `ctx.borrow`, as unloading does: a value someone else set meanwhile stands. Before, its fog or tone mapping stayed on the screen with nothing maintaining it.
137
+ - Skip: a module says how `engine.skip` advances it with `skipKind`: `exact`, `approx`, `step` or `none`. Every engine module declares it (rule R57), `engine.catalog` shows it and reports a module with a `fixed` or `skip` hook that has none, and an unknown word stops `engine.use`. The `skip` hook and `noSkip` stay.
138
+ - Metadata: `threedog map` now writes one generated file of module, content section, contract and placement field facts (`threedog/metadata`). `catalog`, `how` (engine modules and options by name, with no page running), the editor, rules R38 and R50 and the content loader read it instead of keeping their own lists. A content section can declare `live: true`; field specs take `label` and `rare`. A pack with a `level` section and no `level()` module now gets the named error instead of being dropped. The code map, rule R51 and the content file list now read it too: a content section states what it holds in its own `desc`, and `describe().content.sections` also names `actions`, `places`, `audio`, `views`, `renames` and `rules`. Rule R6 now also fails when an option or contract name in it is missing from the types; a contract name a game should not call is marked `@internal` at its source.
139
+ - Asset tool chain: `npm audit` flagged `glob`/`minimatch` under `@gltf-transform/cli` (moderate, build time only). This repo overrides them to the fixed `glob` 14; a game that installs `@gltf-transform/cli` for `threedog assets optimize` adds the same `overrides` entry (recipe 46). `threedog assets optimize` itself is unchanged.
140
+ - Capabilities and readiness: `before` / `after` can name a capability (`after: ['ground']` follows whichever module provides it, also across a `replaces`); `engine.explain({ module })` and `{ capability }` say whether one can be called now. `engine.has(name)` now also answers for a capability a module provides. Development and test builds compare a bound provider's API with the capability's contract, on module changes only: a gap is one `module-contract` warning and a line in `engine.catalog(name).problems`, and the module still runs.
141
+ - `engine.explain` is the one way to ask why: `{ thing: id }` replaces `engine.thing(id).explain()` (`detail` holds the same object), `{ module }` and `{ capability }` are new, and `threedog explain thing <id> --full` replaces `threedog thing <id>` (MCP: `explain` with `about: "thing"`). The CLI word for a value is `threedog explain value fog.far`.
142
+ - Dev server: who writes a value now covers the values the engine writes on its own and shared points, not only picture values; `engine.debug.watch(name, object, key)` adds any value the game names (does nothing in release). `engine.explain({ value })` replaces `explain({ picture })` and also gives the value's short history; two writers taking turns across frames are reported too, in a one-line `[picture-conflict]` hint whose fix moved to `explain`; a yield warning and `describe().owned` name the line that took the value. Only watched values are seen, so no conflict seen is not proof of none.
143
+ - Water asked at a height: characters, rigid bodies, `describe().player.inWater` and spawn search now pass their height to `waterAt`, so a game's `addWaterBody({ query })` or `{ volume }` that depends on `y` (a pool upstairs, a waterfall) works for them. Before, they asked with no height and saw no water.
144
+ - `collider3d.sweep`: a ball that starts touching a solid and moves out of it is clear, so a flying mover can take off from the ground it stands on.
145
+ - `walkTo`: a vertical leg of a path (a path source for a flyer) is progress and goes straight; before, it drifted sideways and ended `stuck`.
146
+ - `mover: 'rapier'` NPC: while another mover has it, its capsule leaves the world and comes back at the character. Before, it stayed at the take-off spot as an invisible wall and blocked the new mover's own sweeps. A mover may give an optional `leave()` for this (`mover.contract.js`).
147
+ - Types: `player.move` and `player.mover` now show the `y` a control step passes (the code already took it); nothing to change in a game.
148
+ - A failed `replaces` leaves the game as it was: the old modules come back in their old places, also when one requires another, and content sections load into them again, so definitions and progress are back. Game code that defined things by hand does so again on the new event `module:restored` `{ modules }`.
149
+ - `session.newGame` / `quit` could be refused for good after a late `replaces` by a part of a lower version: the new-game state now takes the new part's data when the part cannot read what is there.
150
+ - A failed load also rolls back a part whose `save()` gave nothing just before it: it goes to its new-game state. Without one, a soft error names the part.
151
+ - A load taken over by a newer one on the next line can no longer roll back over it, and a taken-over `saves.load` no longer emits `save:loaded`.
152
+ - A content section may say `once: true`: its commit gives state, not definitions (`startItems`), so it is not replayed.
153
+ - `engine.use(x(), { replaces: 'slot' })` with a module named `x` already installed that does not hold the slot is now `[module-replaces]`. Before, the newcomer was ignored and the slot's holder unloaded for nothing.
154
+ - `engine.setPixelSize(null)` leaves a ratio the game took with `renderer.setPixelRatio`; before, it was overwritten.
155
+ - `ctx.borrow`: a module's handles now end newest first when it leaves, so two borrows of one property give back the original value (before: the first borrow's value stayed).
156
+ - Control: two owners taking one character on one layer now throw `[control-conflict]` in release builds too (was: warn once, the later owner won), and the first keeps the character.
157
+ - Shared values: two owners `set` one point on one layer, or a second provider of an exclusive slot, now throw `[shared-conflict]` / `[shared-taken]` in release builds too (was: warn once, the later write won). Development and release behave the same and the earlier value stays.
158
+ - Placement: a prop's `rot` and `scale` also take `[x, y, z]` (numbers act as before), `ground: false` keeps the written `y` instead of snapping to the ground, and `collide` on a model turned about x or z is held by `engine.collider3d` (a named error without one). `triggers.add({ volume: { contains(p), bounds? } })` takes the same plain volume as water.
159
+ - Ground: `slope`, `groundType` and `waterAt` (and a provider's `ground.slope` / `ground.type`) take `refY` like `surface` (existing calls unchanged); `core/scene/ground.contract.js` states what a ground provider gives; `compositeGround({ parts: [{ of, region, priority }] })` holds the ground slot over `terrain({ part: true })` / `level({ part: true })` so both can run; `engine.addWaterBody({ query(x, z, y), bounds, mesh })` or `{ volume, level }` is water you draw yourself; `describe().spatial` shows the ground holder and water.
160
+ - `engine.collider3d`, a new slot with a contract (`modules/rigid/collider3d.contract.js`): `addSolid`, `overlap`, `sweep` on all three axes. `rigid` is the first holder. Nothing changes for a game that does not call it. A module of yours that `provides: ['collider3d']` now needs `{ replaces: 'collider3d' }` next to `rigid`.
161
+ - Ragdolls take any body: the rule `ragdoll.graph` is `'humanoid'` (default, unchanged), a graph `{ part: { bone, parent, limits, mass } }` for four legs or a tail, or `false` (then `rigid.ragdoll` returns null). Recipe 11. A hit without `position` lands on the root part, hips on a human. `rigid.ragdoll({ mass })` is now the exact total (a human came out 1% over).
162
+ - Falling is one rule, `fall`, covering characters and rigid bodies; the default is unchanged (`'rescue'`). `engine.mod('fall', { owner, id?, set: false })` leaves it to the game, and a function `(facts, engine) => 'rescue' | false` decides per fall (`facts.kind`: `'character'` or `'body'`). It is asked once per fall.
163
+ - Migration: `preventDefault` on `character:fall` is gone (calling it now throws `not a function`). Replace `events.on('character:fall', e => e.preventDefault())` with `engine.mod('fall', { owner: 'game', id: 'player', set: false })`, or a function for a decision per fall. `character:fall` still fires first, with `{ character, safe }`.
164
+ - `rigid({ fallbackFloor: false })` removes the flat plane at y = 0 that a ground without collision of its own got; default unchanged.
165
+ - Assets: a model copy now holds its asset's data: `release`, `trim` and a replaced build wait for the last copy, and `describe().assets` lists `leases` and `waiting`. Nothing to do in a game.
166
+ - New games and starter pictures: `picture/index.js` is now a `type: 'picture'` module. Write `engine.use(createPicture()); const { picture } = engine;` and switch looks at run time with `engine.use(next(), { replaces: 'picture' })`; meshes holding old materials must take the new ones. A hand-written `createPicture(engine)` keeps working; a newly pulled starter picture needs the new line.
167
+ - Modules: `ctx.borrow(obj, values)` writes properties on an object the module does not own and restores them when it goes, unless something else wrote them meanwhile. Replace a hand-written save and restore with it; nothing else changes.
168
+ - Vegetation: at low quality, plants with `collider` are drawn thinned again, as many as before they were placed in full. Plants not drawn still block. Nothing to do in a game.
169
+ - `characters.path` rule: `engine.mod('characters.path', { owner, id?, set: ({ from, to, o }, engine) => points | null | 'walk' })` is where `findPath`, `findPathAsync`, `walkTo` and NPCs get paths (default `'walk'`, `false` for none), for flight or anything off the ground; `findPath(a, b, { id })` picks a character's entry.
170
+ - `character.mover` rule: `engine.mod('character.mover', { owner, id, set })` swaps how a character moves until the handle goes, and `mover` (`player.mover` too) takes `(character, engine) => ({ name, move(x, z, run, dt, y) })` (`mover.contract.js`, `engine.characters.kit`, recipe 57). `control.take` steps and `handle.move(x, z, run, dt, y)` gain `y`, default 0. A mover name that does not exist now throws `character-option` instead of warning and walking with `'simple'`: fix the name.
171
+ - XYZ: paths from `findPath` / `findPathAsync` / `engine.nav` are `{ x, y, z }`; schedule stops keep a `y` you give (`{ x, z }` still means the ground) and it picks the floor, also for where the NPC starts; `walkTo` and NPC stops arrive only at the height asked for. A height near no walkable surface at that spot (a stop written `[x, 0, z]` on ground at 8) goes to the nearest surface and warns once `[nav-height]`, so nothing needs rewriting; a height near a surface picks that floor. `collision.addBox({ y })` stops only a body overlapping `y .. y + height`, so a wall upstairs leaves the floor below free (`y` omitted: as before). `collision.walkable` with a `y` and `walkableAt(x, z, radius, y)` read boxes the same way, and so does A*, on the walker's floor; a wall on a level file's upper floor no longer blocks A* paths below it. A navmesh path that only gets under a goal cut off upstairs is now `noPath`, not a path ending a floor below. NPCs on different floors no longer push each other, or yield to a player on another floor.
172
+ - World stays the same at any quality or position: scattered plants with `collider` are placed identically at every `density` (only collider-free species thin); terrain edit, height and shape keys no longer alias far from the origin; `engine.nav` / `findPathAsync` / NPC crowd goals go to the floor the height you pass picks (the ground answers only when none is given); rigid bodies under a moved or rotated parent register at the world pose and write back through the parent (a parent scaled differently per axis throws `rigid-misuse`); standing at the exact centre of a circle or box collider is pushed out towards +x; buoyancy no longer clears forces the game adds to the same body.
173
+ - Containers: `add`, `remove`, `setData`, `transfer` and `trade` throw `[container]` for a quantity that is not a whole number >= 1 (before, `remove("apple", -2)` added stock). `{ op }` and `{ can }` content words run as the actor given to `content.run` / `content.test`, like `give` / `take`. A swarm `capacity` must be a whole number, and a damaged swarm save part is refused whole instead of half-loaded. Weather fields that are not finite numbers, terrain paint types that are not strings and grid layer payloads that are not objects are no longer loaded from a save.
174
+ - `threedog new-game name --pixel` (and `init --pixel`): a sprite-character starting point (`pixelSize`, `pixelSprite`, a `pixelSnap` camera, input, interactions, dialogue, autosave and start screen), gray placeholders; not together with `--open-world`. Recipe 13 gains 3d (which modules need an engine character, run on a sprite) and its `c.facing < 0` mirror test is replaced: `facing` is an angle, not a left/right sign.
175
+ - Release and recovery: a trigger zone's `remove()` inside its own `onExit` no longer deletes a neighbouring zone, and a second `remove()` does nothing. A water normal map swapped for another frees the old texture. A throwing particle depth pass puts the scene back. Unloading the light pool puts back the glow of the stand-ins it borrowed. Unloading `timeline` ends running cutscenes (camera and actors go back) and `flow` stops a transition that has not swapped the scene yet. Modules get `ctx.signal`, which aborts when their install ends, for async work started in `install`.
176
+ - Branching quests: a step can have `next` (a step id, `e => id`, or `false` to finish), and `quests.state(id).visited` lists the steps passed. Save version 3 adds `visited`; older saves load as before.
177
+ - `dialogue({ bubbleChoice: 'ask' })`: a bubble line with choices stays up and waits for `dialogue.choose { index, run }` (run is in `dialogue.bubbles()`); the default still warns and ends the script.
178
+ - `triggers.add({ occupancy: 'each' })`: an enter, stay and exit per actor instead of one for the whole zone (default `'zone'`).
179
+ - Modules own their content sections: a module field `content: { section: { fields, references, validate, prepare, commit, effects } }` decides a section's format, so replacing a module replaces its format. A replacement quests, dialogue or inventory module must declare its own section to read content data. A pack is checked and prepared whole before anything commits. Data for a module that is not installed is a `module-needs` error naming it.
180
+ - `level.load` builds the new level first: on failure the old level stays, `level:failed` fires instead of `level:loaded`, and the Promise rejects, so a save that names a broken level rolls back. Catch the rejection if you called it without `await`. New events `level:loading` and `level:playable`, new field `level.playable`; `level:loaded` means the state is committed.
181
+ - `saves.save` during a load waits for it to end; `saves.collect` during a load throws `save-busy`.
182
+
183
+ - `threedog check`: the bypass hints (rule R40) now show without `--verbose` (the first 5; `--rule R40` lists all) and the last line counts them ("check passed, 3 bypasses"). R40 also catches `new Promise(r => setTimeout(r, ms))` (use `engine.clock.after`), every `localStorage.setItem` that is not an obvious preference, raw `keydown` / `keyup` listeners, `AudioContext` / `new Audio`, hand-made dialogue boxes, interact-distance checks and box-overlap collision. The game template's CLAUDE.md starts with "name the engine system before writing a new system file".
184
+ - Pixel games: `threedog/pixel` adds `pixelGrid`, `pixelSprite` and `spriteFrame`, and `followCamera` and `fixedCamera` take `pixelSnap: { pixelsPerMeter, bounds }`. Camera and sprites round on one grid along the screen's axes, so a turned view moves by whole art pixels, also along a level's edge. Recipe 62 section 4b.
185
+ - With `pixelSize`, the pointer's `ndcX` / `ndcY` ran across the padding at the right and bottom as well, up to k real pixels off; they now run across the picture.
186
+
187
+ - Replacing the game state is now one transaction. `saves.apply`, `saves.load` and `session.newGame` / `load` / `quit` take turns in the order asked, so two overlapping loads end as one whole save instead of a mix of both, and a load that fails rolls back to the whole state before it. Idle, a save with only synchronous parts still applies before `apply` returns. What a game may notice:
188
+ - A second `apply` / `load` asked while one runs now waits for it (async parts or a running `afterLoad`). Do not await one inside a part's `load()` or an `afterLoad`: it cannot start until they return, so it would wait forever (dev warns, `save-nested`). Start it from a `save:loaded` or `session:start` listener.
189
+ - `ops.run`, `ops.can` and `ops.undo` now answer `'loading'` and change nothing for the whole replacement: also during a synchronous part's `load()`, a `world:load` listener, a running `afterLoad` and a rollback (before, only while an async part loaded). An `afterLoad` or `load()` that ran an op to rebuild should write directly, inside `engine.ops.allow(...)`. A game's own `engine.freeze` (a menu) keeps allowing ops.
190
+ - During a failed load in dev, ops answer `'loading'` until the rollback ended, then `'halted'` (before, `'halted'` at once).
191
+ - `session.load` of a missing or unreadable slot asked during a replacement now answers after its turn, not at once.
192
+ - The load's freeze owners `threedog:load` and `threedog:load-parts` are one owner, `threedog:state-replace`. Code that looked for those names reads the new `engine.saves.replacing`.
193
+ - A module's registrations now leave with it. `ctx.ops.define`, `ctx.saves.register`, `ctx.ui.define`, `ctx.stream.addReadyCheck`, `ctx.budget.metric`, `ctx.things.addSource` / `explainWith` and `ctx.ground.provide` / `addColliders` take the same arguments as the engine calls; `engine.unuse`, a `use()` batch that throws and a failed `init` all remove them, so `use(inventory())`, `unuse('inventory')`, `use(inventory())` works. Your own modules keep working unchanged; move their registrations to `ctx` to get this. `engine.catalog(name).resources` lists what a module owns.
194
+ - A save part that leaves keeps its data: it rides in later saves and goes back to a part registered under that key. So `engine.use(mine(), { replaces })` where `mine` registers the same part key now receives the old module's data through `load`; give `mine` its own key if it uses another format. `saves.register` and `ui.define` now return a handle (they returned nothing, so no code changes).
195
+ - A module whose `init` failed loses its ops, save parts and UI parts with its other handles. Calling one of its ops now answers that the op is unknown.
196
+ - `ground` is one exclusive capability, held by `terrain` and `level`. Installing both now fails at `use()` with `shared-taken` instead of the later `setGround` winning: keep one, or swap with `engine.use(terrain(), { replaces: 'ground' })`. `level` no longer sorts after `terrain`. A module of your own giving the ground declares `provides: ['ground']` and calls `ctx.ground.provide(...)` instead of `engine.setGround`. When a provider leaves, the flat ground comes back. `engine.setGround` from game code still works over a module's ground, with a dev warning.
197
+ - `use`, `unuse`, `replaces` and `engine.plugins.on` / `off` now go through one check: the module list after the change is worked out and every module in it must still find what it `requires`, before anything is touched. A `replaces` that drops a capability another module needs now throws `module-replaces` instead of leaving that module broken: add the capability to `provides` of the module that takes over. `engine.plugins.off` throws `module-unuse` and stays on when a module outside the plugin needs it; a plugin owning both provider and consumer goes off as a set.
198
+ - `requires` now means the provider works. Until a required provider runs (still initializing, failed, or blocked), a module is `'blocked'`: its `init` waits and its hooks do not run, and `engine.catalog(name).blockedBy` and `describe().moduleStates` say why. If a provider fails, a `critical` module requiring it stops `start()` with `module-critical`, and others stay blocked; modules that do not depend on it go on. A later `engine.use(mine(), { replaces })` of the failed provider starts them. A module that can live without the provider lists it in `optional`. Inits of one late `use()` batch now run provider first instead of side by side.
199
+ - A second provider of an exclusive slot is now refused in every build, before anything is touched. A release build used to warn and let the later one win.
200
+
201
+ - `threedog check` and the runtime error for a guessed pause (`engine.time.pause()`, `engine.pause()`, `engine.time.stop()`, `resume`) now point to `engine.freeze(owner)`.
202
+ - A game in `games/` of a clone no longer breaks `npm install` after an engine upgrade. `threedog new-game` now writes `"*"` for `threedog` and `@threedog/*` (the workspace copies), and `threedog doctor` reports a game whose range does not accept the current engine, or that has its own copy of the engine in `node_modules`; `threedog doctor --fix` rewrites the ranges. `threedog init` outside a clone keeps `^version`.
203
+ - Test tools: a spec file that cannot be imported (for example its top level touches `document` or `window`) is now named with the file that threw, the cause and the fix; the other spec files still run and the round ends failed, instead of one bare "document is not defined" stopping everything. New warning rule R56: a test item that fails on a measured time (`ms < 100`) without `serial: true`.
204
+ - `createEngine({ pixelSize: k })` and `engine.setPixelSize(k)`: one art pixel is k real screen pixels, every one the same width at any display scale, on WebGL and WebGPU, through page zoom and moves to another display. Replaces working out `devicePixelRatio / k` by hand (recipe 62 section 4b). Every engine write of the pixel ratio now goes through one place, so settings that clash are an error naming which to keep (`pixel-conflict`).
205
+
206
+ ## 0.9.0 (2026-11-06)
207
+
208
+ A game on 0.8.0 upgrades with no code changes, apart from the three points below: a particle list of three or more stops now uses every stop, `engine.start()` after `dispose()` rejects, and a save damaged in the listed ways is refused. Run `threedog doctor --fix` to move the `threedog` and `@threedog/*` pins in `package.json` (a `^0.8.0` range does not reach 0.9, so a game in `games/` of a clone would get a second engine from npm).
209
+
210
+ - Picture check, checked against what seven games really show. `shadow-jag` now moves the shadow map's pixel grid by half a pixel and reads what follows it, in place of counting corners, which stayed the same with a map four times finer. `shadow-stripes` needs at least two bands, and glowing lines through a shadow no longer split it. Moving film grain is no longer read as shadow.
211
+ - `nav({ crowd: true })` NPCs walk to a link's end before crossing, as other walkers do: they started about 1 m short, so a climb cut through the deck. One whose goal lay just past the landing no longer stops short of it.
212
+ - Docs from a real trial: recipe 12 gives where a hatch's ends really sit, in place of the unchecked 0.4 m, a `linkPose` for a hatch, and says a link has no queue; recipe 02 says crowd NPCs walk through the player; recipe 57's ladder read an action that does not exist (`moveBack`), so it could not go down; recipe 64 shows a flipbook on both routes.
213
+ - Tools: a headless browser is closed after 2 idle minutes (was 10), and every tool that opens one first stops what a dead browser left behind, such as a stuck page whose tool was killed.
214
+ - `engine.start()` always answers after `dispose()`: it rejects at once with `engine-disposed`. It used to stay pending for good when `dispose()` ran while it waited on a model, the preload or a module's `init`, and a `start()` after the `dispose()` of a running engine answered as if the engine were alive.
215
+ - `whenReady` of the built-in stream sources, and any `stream.source` or `stream.teleport` asked for after `dispose()`, reject with `stream-removed` instead of waiting for a frame. Waits in game code (`assets.model`, `jobs.add`, `nextFixed`) stay pending after `dispose()`, as before.
216
+ - A damaged save is refused in more cases: a `containers`, `inventory`, `quests`, `terrain` or `grids` part of the wrong shape, and a world `step` that is not a whole number. Each is `save-bad-record` at load (load false, game rolled back) instead of a code error, a game frozen one step later, or a bag emptied without a word. Found by the long fuzz runs.
217
+ - New games' `CLAUDE.md` and recipes 16 and 32 ask for a scenario for every end state (lose, die and respawn, retry, reload mid-run) and a read of `threedog verify`'s "ops never run" list.
218
+ - Recipe 56 lists what draws wrong on WebGPU without a thrown error (`Points` size, `LineLoop`, `linewidth`, `customDepthMaterial`, `MeshDepthMaterial`, `toneMapped`, `dithering`, `texture(map, uv)` and `map.repeat`).
219
+ - The docs no longer say the navigation library can be swapped: a module in the `nav` slot is Recast underneath (CONVENTIONS.md "What can be replaced"). Recipe 12 gives Recast's real download size.
220
+ - `nav({ links: [{ id, from, to, oneWay, radius }] })` (experimental): NPCs path across jumps and ladders. These are Recast off-mesh connections: a path point that starts one has `link: { id, from, to }`, tiles rebuilt by obstacles keep them, and `findPathAsync` sees the same ones. A link that attaches nowhere warns `nav-link` at the build.
221
+ - NPCs, `character.walkTo` and `nav({ crowd: true })` NPCs cross links in a straight line at walking speed unless the game says otherwise: `link:enter` and `link:exit` tell it when (`crossing.seconds` sets how long), `engine.characters.linkPose` bends the line. No default animation. An NPC saved mid-link goes on from the same spot after a load. Recipe 12, section 6.
222
+ - `characters.findPath`, `characters.findPathAsync` and `nav.findPath` now type their points as `NavPathPoint`: `{ x, z }` plus `link` on a point that starts a link. A game without links gets the same points as before and changes nothing; code that walks a path by hand past a link should stop at that point, or use `character.walkTo`.
223
+ - Particles: `size`, `color` and `opacity` take more than two stops, evenly spaced `[a, b, c]` or timed `[[0, a], [0.2, b], [1, c]]`, so a fade-in is possible. The two-point form reads as before; a list of three or more used to drop the rest and now uses them. A bad list throws `[module-params]` at `define`, `emit`, `attach` or `particles()`.
224
+ - Particles: the geometry attribute `aLife` holds each particle's life fraction (0 birth, 1 death) for a game's own material.
225
+ - Particles: `ratePerMeter` (effect option, option of `particles.attach`, live on the handle) emits per meter the emitter moves, spread along the path of the step, on top of `rate`. Default 0.
226
+ - Particles: `soft` fades a particle where it meets what writes depth, default 0, off. On WebGLRenderer it costs a depth-only draw of the scene per render while a soft effect is on screen; on WebGPURenderer's WebGL2 backend it works only with post and antialias on, and warns otherwise.
227
+
5
228
  ## 0.8.0 (2026-11-06)
6
229
 
7
230
  npm never had 0.7.1: coming from 0.7.0, read this section and the 0.7.1 section below it, and follow `docs/MIGRATING-0.8.md`, which goes from 0.7.0 straight to 0.8.0.
@@ -23,10 +246,6 @@ npm never had 0.7.1: coming from 0.7.0, read this section and the 0.7.1 section
23
246
  - `phase` on the engine has one more value, `'starting'`, while modules run their `init`; `'loading'` now starts after them.
24
247
  - `uiFocus` is marked experimental: its shape may still change. `engine.input.push` is the stable route.
25
248
 
26
- ## 0.8.0 (2026-11-05)
27
-
28
- npm never had 0.7.1: coming from 0.7.0, read this section and the 0.7.1 section below it, and follow `docs/MIGRATING-0.8.md`, which goes from 0.7.0 straight to 0.8.0.
29
-
30
249
  - 249 public names are now `@experimental`, so 1.0 does not freeze them: the ones no game, recipe, example or template uses, and the coordination features no test game has used (`engine.stacks`, `engine.wrap`, `engine.mod`, `time.channel`). None is removed; `docs/api-surface.txt` lists each one. They sit in: `adaptive`, `assets`, `audio`, `batching`, `budget`, `calendar`, `characters`, `checkOptions`, `collision`, `control`, `decoders`, `dialogue`, `error`, `firstPersonCamera`, `fixedCamera`, `flow`, `followCamera`, `ground`, `i18n`, `inRange`, `input`, `interactions`, `inventory`, `jobs`, `level`, `materialPatches`, `mod`, `music`, `nav`, `ops`, `page`, `particles`, `photo`, `pickups`, `player`, `post`, `quests`, `random`, `rays`, `rigid`, `rtsCamera`, `runState`, `saves`, `session`, `settings`, `sky`, `stacks`, `startup`, `stateApplied`, `stateRefused`, `stream`, `terrain`, `terrainMaterial`, `time`, `timeline`, `toggleOnKey`, `ui`, `uniforms`, `urlState`, `validate`, `vars`, `vegetation`, `water`, `weather`, `world`, `wrap`.
31
250
  - NPCs and `character.walkTo` follow a path by one rule: an NPC skips points it has passed and no longer stands still for a step at each point, so it runs a few centimetres ahead of where it was mid-walk.
32
251
  - `inventory.slotsUsed` is gone: read `inventory.of().slotsUsed`.
package/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  A web 3D game engine on three.js 0.187: **core** (rendering, main loop, input, audio, saving, UI) -> **modules** (terrain, sky and weather, physics, characters, dialogue, inventory, quests... installed on demand); all art is the game's own (`picture/` folder, `assets.js`).
4
4
 
5
5
  ## Install
6
- This README describes threedog 0.8.0 (older releases do not match it; upgrade steps are in `docs/MIGRATING-0.8.md`). To work on the engine itself, clone the [repository](https://github.com/penstic123-code/Threedog.js-Game-Engine), run `npm install`, then `npm run new-game -- my-game`. A game in its own folder:
6
+ This README describes threedog 1.0 (older releases do not match it; from 0.x read `docs/MIGRATING-1.0.md`, from 0.8.0 `CHANGELOG.md`, from 0.7.0 first `docs/MIGRATING-0.8.md`). To work on the engine itself, clone the [repository](https://github.com/penstic123-code/Threedog.js-Game-Engine), run `npm install`, then `npm run new-game -- my-game`. A game in its own folder:
7
7
  ```sh
8
- npm install threedog@0.8 three@~0.187.0
9
- npm install @threedog/terrain-noise@0.8 # optional: the noise terrain generator terrainPreset() (without one the ground is flat)
10
- npm install -D vite @threedog/tools@0.8 # optional: the vite preset and the threedog command line
8
+ npm install threedog@1 three@~0.187.0
9
+ npm install @threedog/terrain-noise@1 # optional: the noise terrain generator terrainPreset() (without one the ground is flat)
10
+ npm install -D vite @threedog/tools@1 # optional: the vite preset and the threedog command line
11
11
  ```
12
12
  Then let it set up the folder: `npx threedog init` (flags: `--open-world` for generated ground, sky, follow camera and a player; the default is a blank scene with a camera and a gray starter picture in `picture/`) writes index.html, main.js, vite.config.js, content/, CLAUDE.md and `.mcp.json` (Claude Code then starts the threedog MCP server by itself), never overwriting a file you have. Finish with `npm install` (for what the new files need) and `npm run dev`.
13
13
  `three` is a peer dependency: your game and the engine share one copy. Types for three come with the engine (`@types/three`, same version), so `// @ts-check` JS and TypeScript both see real three.js types.
@@ -31,11 +31,11 @@ The picture is the game's own: plain three.js in its `picture/` folder (what `th
31
31
  - The engine ships no art (visuals only; the noise terrain generator `terrainPreset()` is `@threedog/terrain-noise`); without picture code everything is a neutral gray placeholder.
32
32
  - `threedog/tsl`: the WebGPU route; import it before `createEngine({ renderer: 'webgpu' })`. Also TSL helpers for materials and lighting.
33
33
  - `threedog/layers`: `RESERVED_LAYERS`, the three.js layers the engine keeps (a game's own are 1 to 25).
34
+ - `threedog/pixel`: `pixelGrid`, `pixelSprite`, `spriteFrame` (art pixel math on an orthographic camera, and an upright sprite; recipe 62 section 4b).
34
35
  - `threedog/grid`: `sampleGrid`, `gridFromPixels`, `decodePng` (2D fields; no three.js, works in workers and tests).
35
36
  - `threedog/worker`: `serve(handler)`, the worker side of `engine.threads` lanes.
36
- - `threedog/error-hints`: the developer error hint table (used by `@threedog/tools`).
37
37
 
38
- Nothing else is a public path; files under `core/`, `modules/` etc. may move between versions.
38
+ Nothing else is a public path: `threedog/error-hints`, `threedog/metadata` and `threedog/spelling` are there for `@threedog/tools`, not for game code; files under `core/`, `modules/` etc. may move between versions.
39
39
 
40
40
  ## Changes to three.js
41
41
  The engine changes three.js in a few places, because three.js has no per-object hook for what it needs. `describe().threePatches` lists every one at run time, `threePatches.off(id)` turns off the ones that can be turned off, and `docs/THREE.md` is the full list, with what each does to your code.
@@ -279,3 +279,5 @@ export class Animator {
279
279
  /** Call when no longer needed to stop per-frame updates. */
280
280
  dispose() { this._hook?.remove(); this.mixer.stopAllAction(); }
281
281
  }
282
+
283
+ export const handRolled = [{ kind: 'animation', seen: 'an AnimationMixer of its own', use: 'engine.assets.animate(model, { states }): states, crossfades, sync with game time and pause (recipe 13)', quiet: /\bassets\.animate\b/, code: /\bnew\s+(?:THREE\.)?AnimationMixer\s*\(|\bmixer\.update\s*\(/i }];
@@ -2,7 +2,7 @@
2
2
  // 1. Asset manifest: register every model, texture and sound under a name; code uses names only, so swapping a file means editing the manifest.
3
3
  // 2. Preload: load everything marked preload once at startup; the loading screen shows progress.
4
4
  // 3. Cache and reuse: one file downloads once; models return independent copies (geometry and materials shared), so you can place many.
5
- // 4. Release: models count usage per copy; release(name) frees only when the last copy is removed, trim() frees every model with no copy in use (see their docs
5
+ // 4. Release: one count of leases, and a model copy is one (assetEntry.js takeLease); release(name) frees only when the last lease ends, trim() frees every model with no copy in use (see their docs
6
6
  // below).
7
7
  // 5. Compression: Draco / Meshopt models and .ktx2 textures load as-is; the decoder downloads on first use (npm run assets -- optimize produces compressed files in public/optimized/).
8
8
  // 6. Made in code: a model / texture / sound may be a function in the manifest instead of a file, used by name exactly like a file (content, model(),
@@ -32,7 +32,7 @@ import { clone as skeletonClone } from 'three/addons/utils/SkeletonUtils.js';
32
32
  import { warnMissing, warnOnce, fmt, DEV } from '../base/validate.js';
33
33
  import { codedError, coded } from '../base/errorHints.js';
34
34
  import { Animator } from './Animator.js';
35
- import { fetchEntry, freeEntry, retireEntry, dropCopy, disposeEntries, preloadEntries, shadowDefaults, longSound } from './assetEntry.js';
35
+ import { waitLoad, freeEntry, retireEntry, takeLease, disposeEntries, preloadEntries, shadowDefaults, longSound } from './assetEntry.js';
36
36
  import { registerManifest, paramValues } from './assetManifest.js';
37
37
  import { setParams } from './assetHot.js';
38
38
  import { wrapLod } from './assetLod.js';
@@ -43,6 +43,7 @@ import { memory } from '../../render/backend.js';
43
43
  const STRINGS = {
44
44
  textureFailed: "{where}: texture '{name}' did not load ({msg}); {instead}. Register it (engine.assets.manifest({ textures: { name: 'file.png' } })) or check its URL",
45
45
  notLoaded: 'assets.modelNow(\'{name}\') is null: nothing has loaded that model yet (a code-built model is built, or read from the bake cache, on its first load too). Use `engine.assets.modelNow(\'{name}\') ?? await engine.assets.model(\'{name}\')`, or mark it preload: true in the manifest and await engine.assets.preload()',
46
+ noLease: 'assets.lease(\'{name}\'): nothing is registered or loaded under that name, so there is no data to hold. Fix: register it in an asset pack, or load it first with assets.model / assets.texture',
46
47
  noFont: 'assets.font(\'{name}\'): no font named {name}{known}. Register the file in an asset pack: engine.assets.manifest({ fonts: { {name}: \'/fonts/{name}.woff2\' } })',
47
48
  sameName: 'model \'{name}\': the same name was used with two different generator functions, so the cache would mix them (keyed by name + params). Use a different name per model; if the result depends on outer variables, put them in params',
48
49
  };
@@ -124,7 +125,7 @@ export class Assets {
124
125
  */
125
126
  setParams(name, values) { return setParams(this.engine, name, values); }
126
127
  /** @internal a module rebuilds its own copies after a hot swap (vegetation): fn({ names, geometry, material }) -> { name: copies } */
127
- onSwap(fn) { (this._swapHooks ||= []).push(fn); }
128
+ onSwap(fn) { (this._swapHooks ||= new Set()).add(fn); return { remove: () => this._swapHooks.delete(fn) }; }
128
129
 
129
130
  _resolve(nameOrUrl, type) {
130
131
  let e = this.entries.get(nameOrUrl);
@@ -143,8 +144,17 @@ export class Assets {
143
144
  * @internal Run use(value, load) on an entry's live data, in the same tick it is checked. Why the loop: code resumed by an await runs after other
144
145
  * continuations, and one of them may have released the entry since the load finished; handing out that value is a freed model
145
146
  */
146
- async _with(e, use) {
147
- for (;;) { const v = await fetchEntry(this, e); if (v === e.load?.value) return use(v, e.load); }
147
+ async _with(e, use, wait) {
148
+ for (;;) {
149
+ const v = await waitLoad(this, e, wait);
150
+ if (wait?.whole && e.fellBack) throw e.fellBack;
151
+ if (v === e.load?.value) return use(v, e.load);
152
+ }
153
+ }
154
+ /** @internal A model copy for a caller that cannot stand on a stand-in and may stop waiting: a failed file rejects whatever the manifest falls back to, and an aborted signal leaves the load (assetEntry.js) */
155
+ wholeModel(nameOrUrl, signal) {
156
+ const e = this._resolve(nameOrUrl, 'model');
157
+ return this._with(e, () => this._copy(e), { whole: true, signal });
148
158
  }
149
159
  /** @internal The entry moves on from its current load (assetEntry.js) */
150
160
  _retire(e) { retireEntry(this, e); }
@@ -203,13 +213,33 @@ export class Assets {
203
213
  if (DEV && e?.type === 'model' && !e.promise) warnOnce(coded('asset-not-loaded', fmt(STRINGS.notLoaded, { name: nameOrUrl })));
204
214
  return null;
205
215
  }
216
+ /**
217
+ * @internal For modules that hand out what they load, as content does for its models. Hold an asset's data until the handle's remove(): release and trim wait for the last lease, and so does a build replaced by a hot swap or a palette write. For a texture, sound or
218
+ * shared material a game keeps past its own scene. Model copies hold one each already, so nobody has to lease what they took from model(). A lease says "do not free this",
219
+ * it frees nothing by itself: the data stays cached until release or trim. Counts are in describe().assets.
220
+ * @example const lease = ctx.track(await engine.assets.lease('rock')); // in a module: ends with it
221
+ * @param {string} name a registered name, or a path already loaded
222
+ * @returns {Promise<{ name: string, remove(): void }>}
223
+ */
224
+ async lease(name) {
225
+ const e = this.entries.get(name);
226
+ if (!e) throw codedError('unknown-name', fmt(STRINGS.noLease, { name }));
227
+ return this._with(e, () => this._lease(e, name));
228
+ }
229
+ /** @internal the one place a lease is taken, and where describe().assets starts to report (only a game that holds something pays for the line) */
230
+ _lease(e, name) {
231
+ if (!this._reported) { this._reported = true; this.engine.describe?.add?.('assets', () => this._holders()); }
232
+ return takeLease(this, e, name);
233
+ }
234
+ /** @internal describe().assets: leases per name (a model copy is one) and the names whose release waits for them; both empty again means every lease came back */
235
+ _holders() {
236
+ const held = [...this.entries].filter(([, e]) => e.users > 0);
237
+ return { leases: Object.fromEntries(held.map(([k, e]) => [k, e.users])), waiting: held.filter(([, e]) => e.releasePending).map(([k]) => k) };
238
+ }
206
239
  /** @internal one copy of a loaded model, counted on the load that owns its data, which for a name that fell back belongs to the other entry */
207
240
  _copy(e, { castShadow, receiveShadow, static: isStatic = false } = {}) {
208
- const load = e.load, owner = load.owner, gltf = load.value, root = skeletonClone(gltf.scene);
209
- load.users++; e.users = (e.users || 0) + 1;
210
- if (owner !== e) owner.users = (owner.users || 0) + 1;
211
- e.releasePending = owner.releasePending = false;
212
- this._instances.set(root, { e, load });
241
+ const load = e.load, gltf = load.value, root = skeletonClone(gltf.scene);
242
+ this._instances.set(root, { e, load, lease: this._lease(e) });
213
243
  // the call, then the manifest entry; else a generator's own flags; else cast + receive (shadowDefaults, the same rule content props use)
214
244
  shadowDefaults(root, { castShadow: castShadow ?? e.opts.castShadow, receiveShadow: receiveShadow ?? e.opts.receiveShadow });
215
245
  root.animations = gltf.animations; // three's own place: .clone() keeps it as clips, where userData goes through JSON and the clips would come back broken
@@ -290,6 +320,7 @@ export class Assets {
290
320
  * A model with copies still in the scene is not released yet; it is freed when the last copy is engine.remove'd (copies in use are never broken).
291
321
  * A load still running ends here and its result is thrown away; code awaiting that load is a use, so it gets a fresh load, never the freed data.
292
322
  * A name that fell back has no data of its own: release the name it fell back to (describe().assets says what still holds it).
323
+ * A model whose geometry was handed out (assets.geometry, a generator's prototype) stays: nothing can know who still draws it, as with trim.
293
324
  */
294
325
  release(name) {
295
326
  for (const [k, v] of this.entries) if (v.variantOf === name) {
@@ -297,12 +328,12 @@ export class Assets {
297
328
  this.release(k);
298
329
  if (!waited) this.entries.delete(k);
299
330
  }
300
- const e = this.entries.get(name); if (e) freeEntry(this, e);
331
+ const e = this.entries.get(name); if (e && !e.load?.pinned) freeEntry(this, e);
301
332
  }
302
333
  /** Release every model with no copy in use and every long decoded sound (music, long loops; short effects stay), unless marked preload (call after a level change; level calls it). A prop or template keeps one copy for good, so its model stays. A sound still playing plays on. Returns the names released */
303
334
  trim() {
304
335
  const freed = [];
305
- for (const [k, e] of this.entries) if (e.type === 'model' ? e.value && !e.users && !e.load.pinned && !e.opts.preload : longSound(e)) { freeEntry(this, e); freed.push(k); }
336
+ for (const [k, e] of this.entries) if (e.type === 'model' ? e.value && !e.users && !e.load.pinned && !e.opts.preload : longSound(e) && !e.users) { freeEntry(this, e); freed.push(k); }
306
337
  return freed;
307
338
  }
308
339
  /**
@@ -316,7 +347,7 @@ export class Assets {
316
347
  const anim = this._animators.get(o); if (anim) { this._animators.delete(o); anim.dispose(); }
317
348
  const copy = this._instances.get(o); if (!copy) return;
318
349
  this._instances.delete(o);
319
- dropCopy(this, copy);
350
+ copy.lease.remove();
320
351
  });
321
352
  }
322
353
  /**