threedog 0.5.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (750) hide show
  1. package/CHANGELOG.md +276 -1
  2. package/README.md +18 -13
  3. package/core/{Animator.js → assets/Animator.js} +28 -18
  4. package/core/{Assets.js → assets/Assets.js} +116 -61
  5. package/core/{Baked.js → assets/Baked.js} +16 -25
  6. package/core/assets/assetEntry.js +237 -0
  7. package/core/{assetHot.js → assets/assetHot.js} +7 -6
  8. package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
  11. package/core/{assetReport.js → assets/assetReport.js} +9 -15
  12. package/core/{namedModel.js → assets/namedModel.js} +24 -16
  13. package/core/{Audio.js → audio/Audio.js} +27 -24
  14. package/core/{audioRules.js → audio/audioRules.js} +8 -5
  15. package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
  16. package/core/{Events.js → base/Events.js} +3 -3
  17. package/core/{I18n.js → base/I18n.js} +10 -10
  18. package/core/{Random.js → base/Random.js} +5 -4
  19. package/core/{easing.js → base/easing.js} +1 -1
  20. package/core/{errorCodes.js → base/errorCodes.js} +154 -139
  21. package/core/{errorHints.js → base/errorHints.js} +9 -10
  22. package/core/{errors.js → base/errors.js} +9 -9
  23. package/core/{events.generated.js → base/events.generated.js} +2 -0
  24. package/core/{math.js → base/math.js} +22 -4
  25. package/core/{params.js → base/params.js} +3 -4
  26. package/core/base/util.js +32 -0
  27. package/core/{validate.js → base/validate.js} +29 -8
  28. package/core/{Engine.js → engine/Engine.js} +112 -105
  29. package/core/{Loading.js → engine/Loading.js} +4 -2
  30. package/core/{copies.js → engine/copies.js} +4 -4
  31. package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
  32. package/core/{lifecycle.js → engine/lifecycle.js} +16 -16
  33. package/core/{loop.js → engine/loop.js} +80 -52
  34. package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
  35. package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
  36. package/core/{modules.js → engine/modules.js} +20 -17
  37. package/core/engine/page.js +125 -0
  38. package/core/{plugins.js → engine/plugins.js} +68 -103
  39. package/core/{services.js → engine/services.js} +47 -40
  40. package/core/{startup.js → engine/startup.js} +35 -35
  41. package/core/{Input.js → input/Input.js} +41 -27
  42. package/core/{inputContext.js → input/inputContext.js} +14 -5
  43. package/core/{inputPad.js → input/inputPad.js} +1 -1
  44. package/core/{inputPointer.js → input/inputPointer.js} +8 -2
  45. package/core/{inputTouch.js → input/inputTouch.js} +1 -1
  46. package/core/{Budget.js → inspect/Budget.js} +23 -22
  47. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
  48. package/core/{Describe.js → inspect/Describe.js} +33 -30
  49. package/core/{Inspect.js → inspect/Inspect.js} +14 -9
  50. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
  51. package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
  52. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  53. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
  54. package/core/inspect/UrlState.js +182 -0
  55. package/core/{catalog.js → inspect/catalog.js} +18 -5
  56. package/core/{checks.js → inspect/checks.js} +7 -5
  57. package/core/{debugView.js → inspect/debugView.js} +8 -8
  58. package/core/inspect/describeRender.js +148 -0
  59. package/core/{describeText.js → inspect/describeText.js} +17 -12
  60. package/core/inspect/geometryWatch.js +38 -0
  61. package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
  62. package/core/inspect/pictureWriters.js +342 -0
  63. package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
  64. package/core/{Ops.js → ops/Ops.js} +16 -11
  65. package/core/{control.js → ops/control.js} +13 -12
  66. package/core/ops/holds.js +139 -0
  67. package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
  68. package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
  69. package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
  70. package/core/{opsRun.js → ops/opsRun.js} +7 -4
  71. package/core/{owned.js → ops/owned.js} +37 -37
  72. package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
  73. package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
  74. package/core/{stacks.js → ops/stacks.js} +18 -20
  75. package/core/{wrap.js → ops/wrap.js} +8 -6
  76. package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
  77. package/core/{Saves.js → saves/Saves.js} +58 -36
  78. package/core/{saveApply.js → saves/saveApply.js} +13 -9
  79. package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
  80. package/core/{saveValues.js → saves/saveValues.js} +20 -3
  81. package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
  82. package/core/{session.js → saves/session.js} +31 -17
  83. package/core/{Rays.js → scene/Rays.js} +27 -24
  84. package/core/{Views.js → scene/Views.js} +15 -6
  85. package/core/{adaptive.js → scene/adaptive.js} +15 -8
  86. package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
  87. package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
  88. package/core/{gameLights.js → scene/gameLights.js} +24 -7
  89. package/core/{grayMap.js → scene/grayMap.js} +8 -2
  90. package/core/{grid.js → scene/grid.js} +4 -4
  91. package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
  92. package/core/{ground.js → scene/ground.js} +9 -9
  93. package/core/{movement.js → scene/movement.js} +3 -3
  94. package/core/scene/pictureSlots.js +33 -0
  95. package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
  96. package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
  97. package/core/scene/stepPoses.js +55 -0
  98. package/core/{targeting.js → scene/targeting.js} +4 -5
  99. package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
  100. package/core/{thingOps.js → scene/thingOps.js} +4 -3
  101. package/core/{things.js → scene/things.js} +19 -6
  102. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  103. package/core/{tier.js → scene/tier.js} +1 -1
  104. package/core/scene/view.js +44 -0
  105. package/core/{Batching.js → stream/Batching.js} +85 -27
  106. package/core/{Stream.js → stream/Stream.js} +62 -33
  107. package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
  108. package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
  109. package/core/{scatter.js → stream/scatter.js} +2 -2
  110. package/core/{streamSources.js → stream/streamSources.js} +12 -7
  111. package/core/{Commits.js → threads/Commits.js} +6 -5
  112. package/core/{Jobs.js → threads/Jobs.js} +12 -10
  113. package/core/{Threads.js → threads/Threads.js} +16 -16
  114. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  115. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  116. package/core/{Clock.js → time/Clock.js} +17 -10
  117. package/core/{dayTime.js → time/dayTime.js} +5 -1
  118. package/core/{skip.js → time/skip.js} +18 -17
  119. package/core/{time.js → time/time.js} +18 -12
  120. package/core/{uiClock.js → time/uiClock.js} +4 -4
  121. package/docs/AI.md +70 -63
  122. package/docs/API.md +30 -29
  123. package/docs/CODEMAP.md +98 -223
  124. package/docs/COMMANDS.md +80 -69
  125. package/docs/CONVENTIONS.md +87 -41
  126. package/docs/MIGRATING-0.7.md +39 -0
  127. package/docs/MIGRATING-0.8.md +169 -0
  128. package/docs/THREE.md +100 -49
  129. package/docs/api/assets.md +17 -16
  130. package/docs/api/audio.md +8 -7
  131. package/docs/api/budget.md +8 -4
  132. package/docs/api/calendar.md +10 -11
  133. package/docs/api/cameraRig.md +29 -29
  134. package/docs/api/characters.md +26 -19
  135. package/docs/api/clock.md +1 -1
  136. package/docs/api/collision.md +14 -11
  137. package/docs/api/content.md +6 -6
  138. package/docs/api/dialogue.md +3 -3
  139. package/docs/api/engine.md +82 -53
  140. package/docs/api/events.md +5 -3
  141. package/docs/api/flow.md +1 -1
  142. package/docs/api/grids.md +9 -2
  143. package/docs/api/ground.md +4 -5
  144. package/docs/api/hud.md +4 -1
  145. package/docs/api/i18n.md +6 -6
  146. package/docs/api/input.md +10 -9
  147. package/docs/api/interactions.md +6 -4
  148. package/docs/api/inventory.md +10 -11
  149. package/docs/api/jobs.md +5 -5
  150. package/docs/api/level.md +7 -8
  151. package/docs/api/lightPool.md +2 -7
  152. package/docs/api/music.md +3 -3
  153. package/docs/api/nav.md +10 -10
  154. package/docs/api/occlusion.md +5 -0
  155. package/docs/api/openWorld.md +1 -1
  156. package/docs/api/particles.md +8 -5
  157. package/docs/api/photo.md +4 -2
  158. package/docs/api/pickups.md +7 -1
  159. package/docs/api/post.md +24 -5
  160. package/docs/api/quests.md +3 -3
  161. package/docs/api/rays.md +5 -7
  162. package/docs/api/rigid.md +27 -18
  163. package/docs/api/saves.md +8 -7
  164. package/docs/api/settings.md +9 -8
  165. package/docs/api/sky.md +17 -14
  166. package/docs/api/stream.md +7 -7
  167. package/docs/api/swarm.md +34 -0
  168. package/docs/api/terrain.md +17 -12
  169. package/docs/api/terrainDraw.md +12 -0
  170. package/docs/api/timeline.md +2 -2
  171. package/docs/api/tools.md +30 -26
  172. package/docs/api/triggers.md +2 -0
  173. package/docs/api/vars.md +1 -1
  174. package/docs/api/vegetation.md +11 -5
  175. package/docs/api/vegetationDraw.md +10 -0
  176. package/docs/api/water.md +7 -3
  177. package/docs/api/weather.md +11 -6
  178. package/docs/api/weatherDraw.md +10 -0
  179. package/docs/api/world.md +6 -6
  180. package/docs/recipes/01-new-game.md +38 -57
  181. package/docs/recipes/02-npc.md +19 -20
  182. package/docs/recipes/03-items-pickups.md +47 -42
  183. package/docs/recipes/04-quests.md +3 -4
  184. package/docs/recipes/05-props-bake.md +72 -66
  185. package/docs/recipes/06-clock-events.md +30 -21
  186. package/docs/recipes/07-flow-scenes-pause.md +21 -17
  187. package/docs/recipes/08-weather-sky.md +117 -75
  188. package/docs/recipes/09-materials-lights-models.md +171 -0
  189. package/docs/recipes/10-blender-level.md +6 -7
  190. package/docs/recipes/11-vehicles.md +33 -25
  191. package/docs/recipes/12-navmesh.md +9 -8
  192. package/docs/recipes/13-animation.md +50 -22
  193. package/docs/recipes/14-custom-module.md +20 -17
  194. package/docs/recipes/15-perf.md +52 -29
  195. package/docs/recipes/16-dev-bridge.md +47 -57
  196. package/docs/recipes/18-world.md +45 -30
  197. package/docs/recipes/19-shooting-picking.md +11 -7
  198. package/docs/recipes/20-content-actions-save.md +36 -37
  199. package/docs/recipes/21-camera.md +41 -8
  200. package/docs/recipes/22-shop-gold.md +0 -4
  201. package/docs/recipes/23-ops.md +11 -11
  202. package/docs/recipes/26-ui-parts.md +56 -22
  203. package/docs/recipes/27-net.md +0 -2
  204. package/docs/recipes/28-terrain.md +126 -30
  205. package/docs/recipes/29-grid.md +16 -7
  206. package/docs/recipes/30-templates.md +62 -21
  207. package/docs/recipes/31-audio.md +9 -9
  208. package/docs/recipes/32-action-game.md +32 -9
  209. package/docs/recipes/33-stream-sources.md +2 -2
  210. package/docs/recipes/34-environment-lighting.md +164 -52
  211. package/docs/recipes/35-picture-from-reference.md +140 -0
  212. package/docs/recipes/36-ground-plants.md +105 -0
  213. package/docs/recipes/40-scene.md +105 -30
  214. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
  215. package/docs/recipes/44-water-weather-hooks.md +196 -0
  216. package/docs/recipes/45-cascaded-shadows.md +145 -25
  217. package/docs/recipes/46-blender-art-route.md +21 -25
  218. package/docs/recipes/49-game-module-contract.md +5 -5
  219. package/docs/recipes/50-own-renderer.md +3 -3
  220. package/docs/recipes/52-around-the-picture.md +137 -0
  221. package/docs/recipes/53-ground-up-close.md +65 -28
  222. package/docs/recipes/55-mods-time-wrap.md +25 -17
  223. package/docs/recipes/56-webgpu-tsl.md +73 -28
  224. package/docs/recipes/57-control.md +47 -1
  225. package/docs/recipes/58-input.md +3 -0
  226. package/docs/recipes/59-depth-post-effects.md +5 -5
  227. package/docs/recipes/60-judge-the-picture.md +47 -27
  228. package/docs/recipes/61-deploy.md +27 -0
  229. package/docs/recipes/62-picture-code.md +276 -0
  230. package/docs/recipes/63-third-person-start.md +90 -0
  231. package/docs/recipes/64-particles.md +35 -0
  232. package/docs/recipes/65-swarm.md +140 -0
  233. package/examples/action/.threedog/content-index.json +1 -1
  234. package/examples/action/GAMEMAP.md +9 -7
  235. package/examples/action/main.js +5 -4
  236. package/examples/action/models.js +12 -14
  237. package/examples/action/picture/index.js +13 -0
  238. package/examples/action/picture/lights.js +35 -0
  239. package/examples/action/picture/materials.js +8 -0
  240. package/examples/action/picture/palette.js +33 -0
  241. package/examples/perf-island/.threedog/content-index.json +1 -0
  242. package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
  243. package/examples/{sheepisland → perf-island}/assets.js +2 -2
  244. package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
  245. package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
  246. package/examples/{sheepisland → perf-island}/main.js +22 -16
  247. package/examples/{sheepisland/style → perf-island}/models.js +13 -24
  248. package/examples/{sheepisland → perf-island}/params.js +1 -1
  249. package/examples/perf-island/picture/index.js +20 -0
  250. package/examples/perf-island/picture/lights.js +34 -0
  251. package/examples/perf-island/picture/materials.js +61 -0
  252. package/examples/perf-island/picture/palette.js +60 -0
  253. package/examples/perf-island/picture/sky.js +20 -0
  254. package/examples/{sheepisland → perf-island}/views.js +1 -1
  255. package/examples/plain-picture/.threedog/content-index.json +1 -0
  256. package/examples/plain-picture/GAMEMAP.md +91 -0
  257. package/examples/plain-picture/main.js +48 -0
  258. package/examples/plain-picture/picture/index.js +21 -0
  259. package/examples/plain-picture/picture/lights.js +54 -0
  260. package/examples/plain-picture/picture/materials.js +24 -0
  261. package/examples/plain-picture/picture/palette.js +16 -0
  262. package/examples/plain-picture/picture/sky.js +37 -0
  263. package/examples/pullable.json +31 -9
  264. package/examples/rc2d/GAMEMAP.md +10 -4
  265. package/examples/rc2d/README.md +11 -6
  266. package/examples/rc2d/main.js +26 -36
  267. package/examples/rc2d/picture/index.js +18 -0
  268. package/examples/rc2d/picture/lights.js +11 -0
  269. package/examples/rc2d/picture/materials.js +18 -0
  270. package/examples/rc2d/picture/palette.js +15 -0
  271. package/examples/rc2d/picture/post.js +11 -0
  272. package/examples/rc2d/rc2d.js +18 -28
  273. package/examples/styletest/.threedog/content-index.json +1 -1
  274. package/examples/styletest/GAMEMAP.md +15 -10
  275. package/examples/styletest/main.js +20 -30
  276. package/examples/styletest/models.js +29 -29
  277. package/examples/styletest/params.js +1 -4
  278. package/examples/styletest/picture/env.js +38 -0
  279. package/examples/styletest/picture/index.js +16 -0
  280. package/examples/styletest/picture/lights.js +9 -0
  281. package/examples/styletest/picture/materials.js +28 -0
  282. package/examples/styletest/picture/palette.js +22 -0
  283. package/examples/techniques/contact-shadows/README.md +22 -23
  284. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  285. package/examples/techniques/contact-shadows/main.js +20 -18
  286. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  287. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  288. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  289. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  290. package/examples/techniques/day-night-grade/README.md +13 -16
  291. package/examples/techniques/day-night-grade/main.js +15 -25
  292. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  293. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  294. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  295. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  296. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  297. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  298. package/examples/techniques/interior-light/README.md +16 -13
  299. package/examples/techniques/interior-light/interiorLight.js +19 -17
  300. package/examples/techniques/interior-light/main.js +31 -68
  301. package/examples/techniques/interior-light/picture/index.js +24 -0
  302. package/examples/techniques/interior-light/picture/lights.js +52 -0
  303. package/examples/techniques/interior-light/picture/materials.js +13 -0
  304. package/examples/techniques/interior-light/picture/palette.js +32 -0
  305. package/examples/techniques/interior-light/picture/sky.js +40 -0
  306. package/examples/techniques/modular-building/README.md +8 -6
  307. package/examples/techniques/modular-building/kit.js +2 -2
  308. package/examples/techniques/modular-building/main.js +9 -17
  309. package/examples/techniques/modular-building/picture/index.js +17 -0
  310. package/examples/techniques/modular-building/picture/lights.js +26 -0
  311. package/examples/techniques/modular-building/picture/materials.js +13 -0
  312. package/examples/techniques/modular-building/picture/palette.js +23 -0
  313. package/examples/techniques/night-lights/README.md +15 -14
  314. package/examples/techniques/night-lights/main.js +20 -43
  315. package/examples/techniques/night-lights/nightLights.js +25 -21
  316. package/examples/techniques/night-lights/picture/index.js +18 -0
  317. package/examples/techniques/night-lights/picture/lights.js +44 -0
  318. package/examples/techniques/night-lights/picture/materials.js +15 -0
  319. package/examples/techniques/night-lights/picture/palette.js +34 -0
  320. package/examples/techniques/night-lights/picture/post.js +9 -0
  321. package/examples/techniques/night-lights/picture/sky.js +36 -0
  322. package/examples/techniques/outlines-and-rim/README.md +2 -2
  323. package/examples/techniques/outlines-and-rim/main.js +15 -38
  324. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  325. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  326. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  327. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  328. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  329. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  330. package/examples/techniques/procedural-animation/README.md +6 -4
  331. package/examples/techniques/procedural-animation/main.js +9 -7
  332. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  333. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  334. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  335. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  336. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  337. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  338. package/examples/techniques/procedural-surface/README.md +2 -0
  339. package/examples/techniques/procedural-surface/main.js +17 -55
  340. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  341. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  342. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  343. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  344. package/examples/techniques/stylized-shading/README.md +13 -14
  345. package/examples/techniques/stylized-shading/main.js +11 -42
  346. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  347. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  348. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  349. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  350. package/examples/techniques/stylized-shading/shading.js +2 -2
  351. package/examples/techniques/sun-and-key-light/README.md +20 -22
  352. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  353. package/examples/techniques/sun-and-key-light/main.js +19 -63
  354. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  355. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  356. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  357. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  358. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  359. package/examples/techniques/three-looks/README.md +21 -0
  360. package/examples/techniques/three-looks/main.js +58 -0
  361. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  362. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  363. package/examples/techniques/three-looks/picture/comic.js +27 -0
  364. package/examples/techniques/three-looks/picture/index.js +14 -0
  365. package/examples/techniques/three-looks/picture/sun.js +23 -0
  366. package/examples/techniques/wet-road/README.md +7 -4
  367. package/examples/techniques/wet-road/main.js +18 -38
  368. package/examples/techniques/wet-road/picture/index.js +17 -0
  369. package/examples/techniques/wet-road/picture/lights.js +57 -0
  370. package/examples/techniques/wet-road/picture/materials.js +16 -0
  371. package/examples/techniques/wet-road/picture/palette.js +24 -0
  372. package/examples/techniques/wet-road/picture/sky.js +46 -0
  373. package/examples/webgpu-tsl/GAMEMAP.md +10 -4
  374. package/examples/webgpu-tsl/README.md +13 -10
  375. package/examples/webgpu-tsl/main.js +30 -7
  376. package/examples/webgpu-tsl/picture/index.js +18 -0
  377. package/examples/webgpu-tsl/picture/lights.js +25 -0
  378. package/examples/webgpu-tsl/picture/materials.js +36 -0
  379. package/examples/webgpu-tsl/picture/palette.js +23 -0
  380. package/examples/webgpu-tsl/picture/post.js +16 -0
  381. package/examples/webgpu-tsl/picture/sky.js +30 -0
  382. package/examples/world/.threedog/content-index.json +1 -1
  383. package/examples/world/GAMEMAP.md +16 -12
  384. package/examples/world/art/humanoid.js +9 -13
  385. package/examples/world/art/index.js +2 -2
  386. package/examples/world/art/models.js +3 -4
  387. package/examples/world/art/shapes.js +2 -2
  388. package/examples/world/assets.js +2 -2
  389. package/examples/world/content/audio.js +1 -1
  390. package/examples/world/content/items.js +1 -1
  391. package/examples/world/content/props.js +1 -1
  392. package/examples/world/content/templates.js +1 -1
  393. package/examples/world/content/vegetation.js +1 -1
  394. package/examples/world/main.js +10 -10
  395. package/examples/world/models.js +17 -7
  396. package/examples/world/picture/index.js +20 -0
  397. package/examples/world/picture/lights.js +41 -0
  398. package/examples/world/picture/materials.js +34 -0
  399. package/examples/world/picture/palette.js +74 -0
  400. package/examples/world/picture/post.js +9 -0
  401. package/examples/world/picture/sky.js +39 -0
  402. package/index.d.ts +14 -22
  403. package/index.js +36 -36
  404. package/llms.txt +19 -21
  405. package/modules/ambience/Ambience.js +12 -9
  406. package/modules/calendar/Calendar.js +20 -20
  407. package/modules/calendar/index.js +14 -13
  408. package/modules/calendar/schedule.js +11 -6
  409. package/modules/calendar/seasons.js +7 -7
  410. package/modules/camera/FirstPersonCamera.js +2 -2
  411. package/modules/camera/FixedCamera.js +14 -15
  412. package/modules/camera/FollowCamera.js +4 -4
  413. package/modules/camera/RtsCamera.js +11 -11
  414. package/modules/camera/common.js +51 -25
  415. package/modules/camera/contract.js +1 -0
  416. package/modules/camera/projection.js +2 -2
  417. package/modules/characters/Character.js +47 -39
  418. package/modules/characters/NPC.js +30 -22
  419. package/modules/characters/assetModel.js +18 -13
  420. package/modules/characters/astar.js +7 -5
  421. package/modules/characters/behaviors.js +4 -5
  422. package/modules/characters/contract.js +2 -2
  423. package/modules/characters/index.js +172 -193
  424. package/modules/characters/moveHelpers.js +14 -3
  425. package/modules/characters/movers/common.js +22 -15
  426. package/modules/characters/movers/manual.js +4 -1
  427. package/modules/characters/movers/rapier.js +7 -6
  428. package/modules/characters/movers/simple.js +3 -3
  429. package/modules/characters/movers/support.js +32 -18
  430. package/modules/characters/npcAvoid.js +4 -4
  431. package/modules/characters/npcSim.js +28 -18
  432. package/modules/characters/npcView.js +6 -5
  433. package/modules/characters/pathAsync.js +12 -10
  434. package/modules/characters/pathWorker.js +1 -1
  435. package/modules/characters/player.js +108 -0
  436. package/modules/characters/playerStrings.js +2 -2
  437. package/modules/characters/proceduralRig.js +19 -5
  438. package/modules/characters/useModel.js +5 -5
  439. package/modules/characters/walkTo.js +11 -17
  440. package/modules/collision/Collision.js +30 -22
  441. package/modules/collision/contract.js +15 -0
  442. package/modules/content/explain.js +1 -2
  443. package/modules/content/fields.js +24 -3
  444. package/modules/content/ids.js +2 -2
  445. package/modules/content/index.js +68 -98
  446. package/modules/content/loader.js +14 -17
  447. package/modules/content/markers.js +25 -0
  448. package/modules/content/models.js +66 -18
  449. package/modules/content/packs.js +3 -3
  450. package/modules/content/parts.js +2 -2
  451. package/modules/content/places.js +35 -0
  452. package/modules/content/props.js +19 -14
  453. package/modules/content/rules.js +34 -22
  454. package/modules/content/stages.js +7 -7
  455. package/modules/content/templates.js +24 -22
  456. package/modules/content/words.js +34 -0
  457. package/modules/debug/DebugPanel.js +10 -43
  458. package/modules/flow/contract.js +1 -1
  459. package/modules/flow/index.js +11 -7
  460. package/modules/gameplay/Container.js +12 -11
  461. package/modules/gameplay/Containers.js +14 -5
  462. package/modules/gameplay/Dialogue.js +13 -11
  463. package/modules/gameplay/Interactions.js +115 -27
  464. package/modules/gameplay/Inventory.js +11 -12
  465. package/modules/gameplay/Quests.js +16 -9
  466. package/modules/gameplay/boxOps.js +1 -1
  467. package/modules/gameplay/dialogueBox.js +1 -1
  468. package/modules/gameplay/dialogueBubbles.js +4 -5
  469. package/modules/gameplay/interactionPrompt.js +1 -1
  470. package/modules/gameplay/interactions.contract.js +1 -1
  471. package/modules/gameplay/inventoryOps.js +2 -3
  472. package/modules/gameplay/pickups.js +81 -44
  473. package/modules/gameplay/questLog.js +2 -2
  474. package/modules/gameplay/questSave.js +3 -3
  475. package/modules/grid/Grid.js +1 -1
  476. package/modules/grid/Layer.js +16 -3
  477. package/modules/grid/index.js +47 -19
  478. package/modules/grid/preview.js +29 -20
  479. package/modules/grid/tiles.js +19 -23
  480. package/modules/hlod/index.js +38 -55
  481. package/modules/hud/index.js +27 -8
  482. package/modules/hud/parts.js +13 -11
  483. package/modules/level/contract.js +16 -0
  484. package/modules/level/heightfield.js +12 -10
  485. package/modules/level/index.js +48 -152
  486. package/modules/level/load.js +79 -0
  487. package/modules/level/meshes.js +65 -0
  488. package/modules/level/nodes.js +6 -7
  489. package/modules/lights/index.js +34 -183
  490. package/modules/lights/slots.js +93 -0
  491. package/modules/lights/sources.js +88 -0
  492. package/modules/music/Music.js +31 -27
  493. package/modules/music/rules.js +1 -1
  494. package/modules/nav/contract.js +14 -0
  495. package/modules/nav/index.js +11 -10
  496. package/modules/net/Client.js +7 -7
  497. package/modules/net/Host.js +7 -7
  498. package/modules/net/Net.js +1 -1
  499. package/modules/net/index.js +5 -4
  500. package/modules/net/sync.js +2 -2
  501. package/modules/net/transports.js +2 -2
  502. package/modules/particles/Particles.js +49 -25
  503. package/modules/particles/effect.js +27 -10
  504. package/modules/particles/shaders.js +2 -1
  505. package/modules/photo/Photo.js +26 -27
  506. package/modules/rigid/RigidBodies.js +66 -43
  507. package/modules/rigid/Vehicles.js +2 -3
  508. package/modules/rigid/ragdoll.js +287 -0
  509. package/modules/rigid/ragdollBones.js +159 -0
  510. package/modules/rigid/sync.js +6 -6
  511. package/modules/settings/Settings.js +114 -45
  512. package/modules/settings/apply.js +10 -10
  513. package/modules/settings/sections.js +16 -14
  514. package/modules/settings/strings.js +1 -1
  515. package/modules/settings/view.js +3 -3
  516. package/modules/sky/Sky.js +125 -103
  517. package/modules/sky/clouds.js +22 -23
  518. package/modules/sky/dome.js +113 -0
  519. package/modules/sky/domeLayers.js +13 -13
  520. package/modules/sky/environment.js +47 -171
  521. package/modules/sky/fog.js +5 -180
  522. package/modules/sky/frame.js +42 -97
  523. package/modules/sky/season.js +9 -3
  524. package/modules/sky/shader.js +49 -44
  525. package/modules/sky/skyModule.js +25 -35
  526. package/modules/sky/tint.js +9 -11
  527. package/modules/swarm/Swarm.js +346 -0
  528. package/modules/swarm/draw.js +68 -0
  529. package/modules/swarm/grid.js +63 -0
  530. package/modules/terrain/ChunkManager.js +97 -62
  531. package/modules/terrain/chunkQueries.js +7 -24
  532. package/modules/terrain/chunkWorker.js +1 -1
  533. package/modules/terrain/draw.js +157 -0
  534. package/modules/terrain/index.js +60 -88
  535. package/modules/terrain/terrainColorMap.js +6 -3
  536. package/modules/terrain/terrainDefaults.js +4 -3
  537. package/modules/terrain/terrainEdit.js +32 -27
  538. package/modules/terrain/terrainGen.js +19 -14
  539. package/modules/terrain/terrainIsland.js +2 -2
  540. package/modules/terrain/terrainMesh.js +7 -6
  541. package/modules/terrain/terrainShape.js +8 -10
  542. package/modules/terrain/terrainShapeMain.js +3 -3
  543. package/modules/timeline/Timeline.js +27 -19
  544. package/modules/timeline/Tween.js +6 -6
  545. package/modules/timeline/shots.js +5 -7
  546. package/modules/triggers/index.js +19 -15
  547. package/modules/vegetation/Vegetation.js +87 -39
  548. package/modules/vegetation/densityMap.js +4 -7
  549. package/modules/vegetation/draw.js +196 -0
  550. package/modules/vegetation/groundChunks.js +11 -31
  551. package/modules/vegetation/index.js +18 -16
  552. package/modules/vegetation/modelGeometry.js +3 -6
  553. package/modules/vegetation/nearFade.js +1 -1
  554. package/modules/water/Water.js +140 -93
  555. package/modules/water/surface.js +56 -56
  556. package/modules/weather/Weather.js +84 -38
  557. package/modules/weather/particles.js +18 -10
  558. package/modules/weather/shaders.js +1 -1
  559. package/modules/weather/weatherDraw.js +145 -0
  560. package/modules/world/World.js +10 -10
  561. package/modules/world/explain.js +1 -1
  562. package/modules/world/index.js +18 -12
  563. package/modules/world/persist.js +73 -25
  564. package/modules/world/pos.js +4 -4
  565. package/modules/world/records.js +28 -8
  566. package/modules/world/sim.js +4 -4
  567. package/modules/world/state.js +12 -5
  568. package/modules/world/thingSource.js +4 -2
  569. package/modules/world/views.js +12 -10
  570. package/package.json +44 -8
  571. package/presets.js +3 -5
  572. package/render/PostFX.js +233 -63
  573. package/render/backend.js +72 -32
  574. package/render/cascades.js +200 -0
  575. package/render/cascades.tsl.js +93 -0
  576. package/render/daylight.js +56 -0
  577. package/render/detail.js +13 -12
  578. package/render/effects.js +60 -42
  579. package/render/fuse.js +3 -3
  580. package/render/fx/cel.tsl.js +42 -0
  581. package/render/fx/cloudShadow.tsl.js +3 -3
  582. package/render/fx/detail.tsl.js +1 -1
  583. package/render/fx/index.js +10 -13
  584. package/render/fx/library.tsl.js +11 -0
  585. package/render/fx/lighting.tsl.js +2 -1
  586. package/render/fx/nodeErrors.tsl.js +2 -2
  587. package/render/fx/objectOrigin.tsl.js +1 -2
  588. package/render/fx/patchNodes.tsl.js +6 -16
  589. package/render/fx/postWebGPU.tsl.js +55 -28
  590. package/render/fx/sky.tsl.js +34 -109
  591. package/render/fx/uniforms.tsl.js +4 -4
  592. package/render/fx/water.tsl.js +1 -1
  593. package/render/fx/wind.tsl.js +1 -1
  594. package/render/fxNumbers.js +3 -0
  595. package/render/layers.js +14 -0
  596. package/render/lighting.js +11 -8
  597. package/render/lightmap.js +142 -0
  598. package/render/lights.js +26 -204
  599. package/render/lit.js +24 -0
  600. package/render/materials.js +47 -162
  601. package/render/mergeCommon.js +22 -0
  602. package/render/modeling.js +2 -2
  603. package/render/neutral.js +23 -0
  604. package/render/occlusion.js +200 -0
  605. package/render/ownFrame.js +5 -5
  606. package/render/patches.js +46 -41
  607. package/render/postWebGL.js +19 -9
  608. package/render/probes.js +182 -128
  609. package/render/recordSweep.js +117 -0
  610. package/render/shaderErrors.js +10 -9
  611. package/render/shadowCache.tsl.js +107 -0
  612. package/render/shadowTypes.js +9 -0
  613. package/render/shadows.js +451 -0
  614. package/render/slots.js +11 -11
  615. package/render/terms.js +63 -113
  616. package/render/uniformDecl.js +2 -2
  617. package/types/core.d.ts +489 -405
  618. package/types/gameplay.d.ts +225 -114
  619. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
  620. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  621. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  622. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
  623. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  624. package/types/generated/core/engine/page.d.ts +24 -0
  625. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
  626. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  627. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
  628. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
  629. package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
  630. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
  631. package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
  632. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  633. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
  634. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  635. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
  636. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  637. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  638. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  639. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  640. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  641. package/types/generated/modules/grid/Layer.d.ts +9 -1
  642. package/types/generated/modules/grid/index.d.ts +32 -8
  643. package/types/generated/modules/music/Music.d.ts +7 -5
  644. package/types/generated/modules/particles/Particles.d.ts +14 -7
  645. package/types/generated/modules/sky/Sky.d.ts +101 -23
  646. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  647. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  648. package/types/generated/modules/timeline/Timeline.d.ts +2 -1
  649. package/types/generated/modules/water/Water.d.ts +51 -3
  650. package/types/generated/modules/weather/Weather.d.ts +44 -10
  651. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  652. package/types/generated/modules/world/World.d.ts +7 -5
  653. package/types/generated/render/PostFX.d.ts +69 -20
  654. package/types/generated/render/lighting.d.ts +29 -0
  655. package/types/generated/render/materials.d.ts +20 -44
  656. package/types/generated/render/occlusion.d.ts +22 -0
  657. package/types/generated/render/patches.d.ts +1 -0
  658. package/types/generated/ui/Focus.d.ts +1 -0
  659. package/types/generated/ui/UI.d.ts +1 -0
  660. package/types/nav.d.ts +11 -11
  661. package/types/physics.d.ts +104 -73
  662. package/types/tsl.d.ts +45 -4
  663. package/types/world.d.ts +372 -86
  664. package/ui/Focus.js +21 -10
  665. package/ui/LoadingScreen.js +2 -2
  666. package/ui/Parts.js +12 -7
  667. package/ui/UI.js +17 -17
  668. package/ui/cursor.js +1 -1
  669. package/ui/defaults.js +3 -2
  670. package/ui/theme.js +36 -28
  671. package/ui/touchPart.js +1 -1
  672. package/core/UrlState.js +0 -110
  673. package/core/assetEntry.js +0 -106
  674. package/core/describeRender.js +0 -71
  675. package/core/holds.js +0 -134
  676. package/core/look/coreParts.js +0 -219
  677. package/core/look/part.js +0 -253
  678. package/core/look/points.js +0 -255
  679. package/core/look/report.js +0 -96
  680. package/core/look/shadowPart.js +0 -63
  681. package/core/look/state.js +0 -45
  682. package/core/look/write.js +0 -70
  683. package/core/page.js +0 -79
  684. package/core/shadowTypes.js +0 -16
  685. package/core/styleParts.js +0 -114
  686. package/core/util.js +0 -17
  687. package/docs/MIGRATING-0.3.md +0 -248
  688. package/docs/MIGRATING-0.4.md +0 -228
  689. package/docs/MIGRATING-0.5.md +0 -68
  690. package/docs/PERF.md +0 -245
  691. package/docs/api/style.md +0 -136
  692. package/docs/api/terrainLook.md +0 -10
  693. package/docs/api/vegetationLook.md +0 -10
  694. package/docs/api/weatherLook.md +0 -10
  695. package/docs/recipes/09-style.md +0 -218
  696. package/docs/recipes/35-style-from-reference.md +0 -153
  697. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  698. package/docs/recipes/37-terrain-look-hooks.md +0 -119
  699. package/docs/recipes/38-environment-look-hooks.md +0 -99
  700. package/docs/recipes/41-thing-registry.md +0 -97
  701. package/docs/recipes/42-terrain-shape.md +0 -64
  702. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  703. package/docs/recipes/47-island-snow-backdrop.md +0 -45
  704. package/docs/recipes/48-make-material.md +0 -75
  705. package/docs/recipes/52-look.md +0 -282
  706. package/docs/recipes/54-three-idioms.md +0 -88
  707. package/examples/action/look.js +0 -5
  708. package/examples/sheepisland/.threedog/content-index.json +0 -1
  709. package/examples/sheepisland/style/index.js +0 -79
  710. package/examples/styletest/look.js +0 -11
  711. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  712. package/examples/webgpu-tsl/tslScene.js +0 -75
  713. package/examples/world/style/index.js +0 -61
  714. package/examples/world/style/plugins/10-bloom.js +0 -5
  715. package/modules/sky/cascades.js +0 -186
  716. package/modules/sky/cascades.tsl.js +0 -82
  717. package/modules/sky/look.js +0 -54
  718. package/modules/sky/lookFog.js +0 -76
  719. package/modules/sky/lookShadow.js +0 -62
  720. package/modules/sky/lookSky.js +0 -169
  721. package/modules/sky/shadow.js +0 -98
  722. package/modules/terrain/look.js +0 -83
  723. package/modules/terrain/lookGround.js +0 -66
  724. package/modules/vegetation/look.js +0 -119
  725. package/modules/vegetation/lookWind.js +0 -98
  726. package/modules/water/look.js +0 -91
  727. package/modules/water/surfaceDefaults.js +0 -3
  728. package/modules/weather/look.js +0 -74
  729. package/modules/weather/weatherLook.js +0 -135
  730. package/render/lookGlow.js +0 -139
  731. package/render/lookSurface.js +0 -224
  732. package/render/postLook.js +0 -164
  733. package/render/surface.js +0 -105
  734. package/types/generated/core/page.d.ts +0 -18
  735. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  736. package/types/style.d.ts +0 -671
  737. /package/core/{Vars.js → base/Vars.js} +0 -0
  738. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  739. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  740. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  741. /package/core/{actor.js → ops/actor.js} +0 -0
  742. /package/core/{opsFail.js → ops/opsFail.js} +0 -0
  743. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  744. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  745. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  746. /package/core/{cells.js → stream/cells.js} +0 -0
  747. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  748. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  749. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  750. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
package/types/core.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  // Engine core: the Engine class, events, input, i18n, saves, assets, audio, the ground interface, module definitions.
2
2
  import type { Object3D, Vector3, Vector2, Color, Texture, BufferGeometry, Handle, PositionLike, Vec3Like, ColorLike, Material } from './common';
3
- import type { Style, StyleInput, MaterialSpec } from './style';
4
3
  import type {
5
- Terrain, TerrainLook, Vegetation, VegetationLook, Sky, Calendar, Weather, WeatherLook, Water, WaterBody, WaterBodyOptions, VegetationRemoveEvent, Hlod, LightPool, Budget, BudgetLimits, BudgetReport,
4
+ Terrain, TerrainDraw, Vegetation, VegetationDraw, Sky, Calendar, Weather, WeatherDraw, Water, WaterBody, WaterBodyOptions, VegetationRemoveEvent, Hlod, LightPool, Budget, BudgetLimits, BudgetReport,
6
5
  } from './world';
7
6
  import type { World } from './generated/modules/world/World';
8
7
  import type { Net } from './generated/modules/net/Net';
@@ -10,28 +9,29 @@ import type { PostEffect } from './generated/render/PostFX';
10
9
  import type { Grids } from './generated/modules/grid/index';
11
10
  import type { Collision, RigidBodies, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle, Rideable } from './physics';
12
11
  import type { Nav } from './nav';
13
- import type { Stream } from './generated/core/Stream';
14
- import type { Batching } from './generated/core/Batching';
15
- import type { Rays } from './generated/core/Rays';
16
- import type { Control } from './generated/core/control';
17
- import type { I18n } from './generated/core/I18n';
18
- import type { Audio } from './generated/core/Audio';
19
- import type { Input } from './generated/core/Input';
20
- import type { Saves } from './generated/core/Saves';
21
- import type { Session } from './generated/core/session';
22
- import type { Page } from './generated/core/page';
23
- import type { Events } from './generated/core/Events';
24
- import type { Commits } from './generated/core/Commits';
25
- import type { Threads } from './generated/core/Threads';
26
- import type { Ops } from './generated/core/Ops';
27
- import type { Views } from './generated/core/Views';
28
- import type { DebugOverrides } from './generated/core/DebugOverrides';
29
- import type { Jobs } from './generated/core/Jobs';
30
- import type { Random } from './generated/core/Random';
12
+ import type { Stream } from './generated/core/stream/Stream';
13
+ import type { Batching } from './generated/core/stream/Batching';
14
+ import type { Rays } from './generated/core/scene/Rays';
15
+ import type { Control } from './generated/core/ops/control';
16
+ import type { I18n } from './generated/core/base/I18n';
17
+ import type { Audio } from './generated/core/audio/Audio';
18
+ import type { Input } from './generated/core/input/Input';
19
+ import type { Saves } from './generated/core/saves/Saves';
20
+ import type { Session } from './generated/core/saves/session';
21
+ import type { Page } from './generated/core/engine/page';
22
+ import type { Events } from './generated/core/base/Events';
23
+ import type { Commits } from './generated/core/threads/Commits';
24
+ import type { Threads } from './generated/core/threads/Threads';
25
+ import type { Ops } from './generated/core/ops/Ops';
26
+ import type { Views } from './generated/core/scene/Views';
27
+ import type { DebugOverrides } from './generated/core/inspect/DebugOverrides';
28
+ import type { Jobs } from './generated/core/threads/Jobs';
29
+ import type { Random } from './generated/core/base/Random';
31
30
  import type { PostFX } from './generated/render/PostFX';
31
+ import type { Occlusion } from './generated/render/occlusion';
32
32
  import type {
33
33
  Timeline, Level, LevelLoadedEvent, Triggers, TriggerEvent, TemplateStageEvent,
34
- Particles, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
34
+ Particles, SwarmMaker, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
35
35
  Interactions, Dialogue, Inventory, ItemEvent, ItemUseEvent, PickupEvent, Pickups, PickupsOptions, Quests, Photo, PhotoShot, Ambience, DebugPanel,
36
36
  Clock, Vars, Content, Flow, Hud,
37
37
  } from './gameplay';
@@ -49,7 +49,7 @@ declare global {
49
49
  */
50
50
  interface GameEvents {}
51
51
  /**
52
- * Vite's import.meta.glob, the documented way a style lists its plugins folder (style.plugins: import.meta.glob('./plugins/*.js', { eager: true }))
52
+ * Vite's import.meta.glob, the documented way a game lists its plugins folder (import.meta.glob('./plugins/*.js', { eager: true }))
53
53
  * and engine.plugins.add takes one. Declared here because a game's tsconfig has no vite/client types ("types": []), so the documented line
54
54
  * failed the type check of a fresh game; with vite/client too, the two declarations merge as overloads.
55
55
  */
@@ -96,7 +96,7 @@ export interface EventMap extends GameEvents {
96
96
  'season:change': [season: string];
97
97
  /** A mod with `for` ran out (engine.mod(target, { owner, for })): target is the quantity's name, id the record for per-record ones */
98
98
  'mod:end': [{ target: string; owner: string; id: string | null }];
99
- /** engine.skip jumped game time forward (seconds = game seconds skipped); timers and world catch-up already ran */
99
+ /** engine.skip jumped game time forward (seconds = calendar seconds skipped); timers and world catch-up already ran */
100
100
  'time:skip': [{ seconds: number }];
101
101
  /** Lightning strike (weather module) */
102
102
  'weather:lightning': [];
@@ -112,6 +112,8 @@ export interface EventMap extends GameEvents {
112
112
  'character:fall': [{ character: Character; safe: Vector3 | null; preventDefault(): void }];
113
113
  /** A character's model named by asset finished loading and replaced the placeholder body (same root; anim is now set) */
114
114
  'character:model': [{ character: Character; model: Object3D }];
115
+ /** A foot of a walking character came down; character.groundType() is what it stepped on */
116
+ 'character:step': [{ character: Character }];
115
117
  /** A character landed; impact is the landing speed (m/s), the larger the harder the fall */
116
118
  'character:land': [{ character: Character; impact: number }];
117
119
  /**
@@ -187,9 +189,11 @@ export interface EventMap extends GameEvents {
187
189
  /** Background music changed track (null means silence) */
188
190
  'music:change': [MusicChangeEvent];
189
191
  /** A stinger was played */
190
- 'music:stinger': [{ name: string }];
192
+ 'music:stinger': [{ name: string; played: boolean }];
191
193
  /** Scenario parameters were applied (URL parameters or engine.applyState) */
192
194
  'state:applied': [StateParams];
195
+ /** A scenario (at, pos) moved the player: a camera or view that eases jumps there */
196
+ 'state:placed': [{ x: number; z: number }];
193
197
  /** A one-shot action of the animation state machine finished */
194
198
  'anim:end': [{ root: Object3D; state: string }];
195
199
  /** A record was added to world */
@@ -214,7 +218,7 @@ export interface EventMap extends GameEvents {
214
218
  'net:result': [{ seq: number; name: string; ok: boolean; code: string | null; value?: any; tick: number }];
215
219
  /** A gameplay error in development / testing; gameplay is frozen (error severity levels, see engine.error) */
216
220
  'engine:error': [EngineError];
217
- /** A look or ui module errored and was disabled (the game continues) */
221
+ /** A picture or ui module errored and was disabled (the game continues) */
218
222
  'module:disabled': [{ name: string; message: string }];
219
223
  /** A character boarded a vehicle */
220
224
  'vehicle:enter': [{ character: Character; vehicle: Rideable }];
@@ -261,34 +265,79 @@ export interface EngineUniforms {
261
265
  uTime: { value: number };
262
266
  /** Wind strength multiplier (weather) */
263
267
  uWind: { value: number };
264
- /** Sway frequency multiplier (style.wind.frequency) */
268
+ /** Sway frequency multiplier */
265
269
  uWindFreq: { value: number };
266
- /** Cloud cover 0-1 (weather) */
267
- uCloud: { value: number };
268
- /** Darkest cloud shadow 0-1 (style.clouds.shadow; 0 = none) */
270
+ /** Sway amplitude multiplier: every wind patch's amplitude is scaled by it */
271
+ uWindAmp: { value: number };
272
+ /** Cloud cover 0-1 (weather) @experimental */
273
+ uWeatherCloud: { value: number };
274
+ /** Rain amount 0-1 (weather state, every frame): a signal for the game's own wet surfaces */
275
+ uRain: { value: number };
276
+ /** Snow amount 0-1 (weather state, every frame) @experimental */
277
+ uSnow: { value: number };
278
+ /** Weather's light multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its own lights by it */
279
+ uWeatherLight: { value: number };
280
+ /** Weather's fog multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its fog distance by it */
281
+ uWeatherFog: { value: number };
282
+ /** How far the world is meant to be seen, meters (default 600; terrain({ viewFog: true }) writes it): a fog's far, the stream radius without terrain */
283
+ uViewDistance: { value: number };
284
+ /** Darkest cloud shadow 0-1 (0 = none) */
269
285
  uCloudShadow: { value: number };
270
- /** Cloud size: smaller = bigger clouds (style.clouds.scale) */
271
- uCloudScale: { value: number };
272
- /** Cloud drift per second (style.clouds.speed) */
273
- uCloudSpeed: { value: Vector2 };
286
+ /** Cloud size: smaller = bigger clouds @experimental */
287
+ uCloudShadowScale: { value: number };
288
+ /** Cloud drift per second @experimental */
289
+ uCloudShadowSpeed: { value: Vector2 };
274
290
  /** Unit vector toward the sun (sky, every frame); share the object in your own sky: mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir */
275
291
  uSunDir: { value: Vector3 };
292
+ /** Sun color now, from the sky's keyframes (white with no sky): what a game's own sun takes. Linear, like every THREE.Color */
293
+ uSunColor: { value: Color };
276
294
  /** 0 at night .. 1 at noon (sky, the sun it draws) */
277
295
  uDaylight: { value: number };
296
+ /** 0 by day, 1 at night: the curve lightPool sources with `dusk` fade on. For emissive windows and signs: mat.emissiveIntensity = 2 * engine.uniforms.uNight.value */
297
+ uNight: { value: number };
278
298
  /** Time of day 0-1 the sky draws (calendar time, or the sky's fixed time) */
279
299
  uTimeOfDay: { value: number };
280
- /** Zenith color the sky draws this frame (keyframes, look.sky top, weather tint, lightning); linear, like every THREE.Color */
300
+ /** Zenith color the sky draws this frame (keyframes, engine.sky.top, weather tint, lightning); linear, like every THREE.Color */
281
301
  uSkyTop: { value: Color };
282
- /** Horizon color the sky draws this frame (or the backdrop color); the default fog color ('horizon') is this same color. Read it for a shader that should meet the sky */
302
+ /** Horizon color the sky draws this frame (or the backdrop color). Read it for a shader that should meet the sky */
283
303
  uSkyHorizon: { value: Color };
284
- /** Season tint of foliage (sky, by the calendar's season) */
304
+ /** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below @experimental */
305
+ uSunSize: { value: number };
306
+ /** @experimental */ uSunGlow: { value: number };
307
+ /** Sun disk brightness (sky({ sunBrightness })) */
308
+ uSunBrightness: { value: number };
309
+ /** Moon disk sharpness (larger = smaller) @experimental */
310
+ uMoonSize: { value: number };
311
+ /** Moon disk brightness (sky({ moonBrightness })) @experimental */
312
+ uMoonBrightness: { value: number };
313
+ /** @experimental */ uMoonColor: { value: Color };
314
+ /** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) @experimental */
315
+ uStars: { value: number };
316
+ /** Star grid resolution: larger = smaller, more numerous stars @experimental */
317
+ uStarScale: { value: number };
318
+ /** Horizon-to-zenith gradient exponent (engine.uniforms.uSkyCurve) @experimental */
319
+ uSkyCurve: { value: number };
320
+ /** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's uWeatherCloud */
321
+ uCloudCover: { value: number };
322
+ /** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } })); uCloudShadowScale is the cloud shadows' */
323
+ uSkyCloudScale: { value: number };
324
+ /** Dome cloud drift [x, z] per second; uCloudShadowSpeed is the cloud shadows' */
325
+ uSkyCloudSpeed: { value: Vector2 };
326
+ /** @experimental */ uCloudOpacity: { value: number };
327
+ /** Dome cloud edge softness @experimental */
328
+ uCloudSoft: { value: number };
329
+ /** Lit side of the dome's clouds */
330
+ uCloudColor: { value: Color };
331
+ /** Shaded side of the dome's clouds */
332
+ uCloudShade: { value: Color };
333
+ /** Season tint of foliage (sky, by the calendar's season) @experimental */
285
334
  uFoliageTint: { value: Color };
286
- /** Season tint of the ground (sky, by the calendar's season) */
335
+ /** Season tint of the ground (sky, by the calendar's season) @experimental */
287
336
  uGroundTint: { value: Color };
288
- uFoliageMix: { value: number };
289
- uGroundMix: { value: number };
290
- /** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'look.ground.cover' point); the tints above already hold it blended in */
291
- uCover: { value: Vector2 };
337
+ /** @experimental */ uFoliageMix: { value: number };
338
+ /** @experimental */ uGroundMix: { value: number };
339
+ /** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in @experimental */
340
+ uGroundCover: { value: Vector2 };
292
341
  }
293
342
 
294
343
  /** Mouse / touch pointer. ndcX/ndcY are screen coordinates in -1..1 */
@@ -344,9 +393,6 @@ export interface SaveProvider {
344
393
  /** Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }.
345
394
  * The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part */
346
395
  migrate?: Record<number, (data: any, save: { parts: Record<string, any>, versions: Record<string, number> }) => any>;
347
- /** This part's data used to be saved under another part's name: { oldPart: data => newData } (newData in this version's shape). An old save without
348
- * this part but with oldPart loads it here; oldPart is then dropped unless a registered part still owns that name */
349
- movedFrom?: Record<string, (data: any) => any>;
350
396
  }
351
397
 
352
398
 
@@ -366,7 +412,7 @@ export type AssetEntry = string | ModelBuilder | {
366
412
  /** Model: generator function (instead of url) */
367
413
  build?: ModelBuilder;
368
414
  /**
369
- * Model: a params schema (core/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
415
+ * Model: a params schema (core/base/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
370
416
  * object (defaults < dev panel values < a call's own ['name', { ... }]) and the dev panel shows the fields
371
417
  */
372
418
  params?: Record<string, string | { type: string; default?: any; min?: number; max?: number; values?: any[]; desc?: string; optional?: boolean }>;
@@ -427,7 +473,7 @@ export interface AssetManifest {
427
473
  * like a file: audio.sfx(name), audio.sounds rules (src / variants), music and ambience. Example: sounds: { step: '/sfx/step.ogg', ding: dingSynth }
428
474
  */
429
475
  sounds?: Record<string, AssetEntry | SynthFn | { build: SynthFn; params?: Record<string, any> }>;
430
- /** Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). style.ui.fonts lists the names the UI uses */
476
+ /** Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). ui.fonts lists the names the UI uses */
431
477
  fonts?: Record<string, string | FontAssetEntry>;
432
478
  }
433
479
  /** One font of an asset pack: the file plus the FontFace descriptors (family defaults to the asset name) */
@@ -436,9 +482,9 @@ export interface FontAssetEntry {
436
482
  /** CSS font-family it registers (default: the asset name); several entries may share one family with different weight / style */
437
483
  family?: string;
438
484
  weight?: number | string; style?: string; stretch?: string; unicodeRange?: string; display?: string; featureSettings?: string; variationSettings?: string;
439
- /** start() stops if it fails (otherwise text falls back to the next family of style.ui.font) */
485
+ /** start() stops if it fails (otherwise text falls back to the next family of ui.theme.font) */
440
486
  critical?: boolean;
441
- /** Load at start() even if style.ui.fonts does not name it */
487
+ /** Load at start() even if ui.fonts does not name it */
442
488
  preload?: boolean;
443
489
  }
444
490
 
@@ -448,19 +494,20 @@ export interface Assets {
448
494
  * it in engine.loading, base resolves its relative paths
449
495
  */
450
496
  manifest(m: AssetManifest | AssetManifest[]): this;
451
- /** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) */
497
+ /** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) @experimental */
452
498
  builder(name: string): ((...args: any[]) => any) | null;
453
- /** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null */
499
+ /** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null @experimental */
454
500
  paramsOf(name: string): { schema: Record<string, any>; values: Record<string, any>; tuned: Record<string, any> } | null;
455
501
  /** Dev tuning: build a generator with these params (replacing its defaults) and swap every live copy in place; the dev panel's models folder calls it */
456
502
  setParams(name: string, values: Record<string, any>): Promise<{ why: string; names: string[]; copies: Record<string, number>; ms: number; partsChanged?: string[] }>;
457
503
  /**
458
504
  * Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now
459
505
  * showing their fallback
506
+ * @experimental
460
507
  */
461
508
  preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }): Promise<{ loaded: number; failed: string[]; ok: boolean }>;
462
509
  /**
463
- * A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. style.ui.fonts calls
510
+ * A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. ui.fonts calls
464
511
  * it at start()
465
512
  */
466
513
  font(name: string): Promise<FontFace | null>;
@@ -469,10 +516,19 @@ export interface Assets {
469
516
  * acceleration)
470
517
  */
471
518
  model(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<Object3D>;
519
+ /**
520
+ * A model copy as a plain THREE.LOD: the full model near, the levels of `threedog assets optimize --lod` far away. Default distances follow the model's size;
521
+ * distances (rising meters) replace them, hysteresis is the share of a distance that stops flicker at the line (default 0.1). Rays, collision and saves keep
522
+ * using the full model. A LOD object is never batched. Without levels it warns in dev and draws in full.
523
+ * @example const tower = await engine.assets.lod('tower', { distances: [40, 120] }); engine.add(tower); tower.levels[1].object;
524
+ * @experimental
525
+ */
526
+ lod(nameOrUrl: string, opts?: { distances?: number[]; hysteresis?: number; castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<import('three').LOD>;
472
527
  /**
473
528
  * A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs.
474
529
  * Code-built models (a build function in the manifest) count too: they are null until one await model(name) or an entry with preload: true ran (dev warns [asset-not-loaded])
475
530
  * @example const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');
531
+ * @experimental
476
532
  */
477
533
  modelNow(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Object3D | null;
478
534
  /** Get the geometry of the first mesh in a model */
@@ -481,27 +537,34 @@ export interface Assets {
481
537
  gridFromImage(nameOrUrl: string, opts?: { channel?: 'r' | 'g' | 'b' | 'a' | number; range?: [number, number]; bits?: 8 | 16 }): Promise<{ data: Float32Array; width: number; height: number; bits: number }>;
482
538
  /** Get a texture (.ktx2 compressed textures also work) */
483
539
  texture(nameOrUrl: string, opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] }): Promise<Texture>;
484
- /** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one load-failed dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options */
540
+ /** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one asset-load dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options */
485
541
  useTexture(nameOrUrl: string, use: (texture: Texture) => void, o?: { where?: string; instead?: string; opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] } }): Promise<boolean>;
486
542
  /**
487
- * Release a resource and return GPU memory. Not released while copies of the model are still in the scene; it is released when the last copy is
488
- * removed with engine.remove
543
+ * Release a resource and return its memory. Not released while copies of the model are still in the scene; it is released when the last copy is
544
+ * removed with engine.remove. A sound (name or path) plays on where it is playing and loads again on next use. A load still running ends and its result is thrown away; code awaiting it gets a fresh load, never freed data. A name that
545
+ * fell back holds no data of its own: release the name it fell back to
489
546
  */
490
547
  release(name: string): void;
491
548
  /**
492
- * Release every model that has no copy in use (called automatically after level changes). Models whose shared geometry was taken by geometry() and
493
- * code-generated models are not released automatically. Returns the released names
549
+ * Release every model that has no copy in use and every long decoded sound (music, long loops; short effects stay; a sound still playing plays on), unless
550
+ * marked preload (called automatically after level changes). Models whose shared geometry was taken by geometry() and code-generated models are not released
551
+ * automatically. Returns the released names
494
552
  */
495
553
  trim(): string[];
496
- /** How many copies of this model are in use now (taken with model() and not yet removed with engine.remove) */
497
- users(name: string): number;
498
554
  /**
499
555
  * Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies
500
556
  * under it
557
+ * @experimental
501
558
  */
502
559
  forget(obj: Object3D): void;
503
560
  /** Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20 */
504
561
  cacheMinMs: number;
562
+ /**
563
+ * Named colors for what is made in code: a generator written with `function` reads this.palette. Plain data, read, write or replace it freely: it is part
564
+ * of the cache key, so a model or texture asked for after a write is built from the new colors. Copies already placed keep theirs.
565
+ * @example engine.assets.palette = { leaf: 0xd98a3a, bark: 0x6b4a30 };
566
+ */
567
+ palette: Record<string, any>;
505
568
  /** Geometry and materials shared by model copies (engine.remove does not release them, use release) */
506
569
  shared: WeakSet<object>;
507
570
  /** Current GPU memory usage (number of geometries and textures) */
@@ -513,25 +576,24 @@ export interface Assets {
513
576
  animate(root: Object3D, config?: AnimatorOptions): Animator;
514
577
  /** The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping) */
515
578
  mapping(root: Object3D): AnimatorOptions | null;
516
- /** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) */
579
+ /** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) @experimental */
517
580
  gltf: any;
518
581
  /**
519
582
  * three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite
520
583
  * packs it automatically)
584
+ * @experimental
521
585
  */
522
586
  draco: any;
523
- /** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) */
587
+ /** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) @experimental */
524
588
  ktx2: any;
525
589
  /** Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost */
526
590
  report(nameOrRoot: string | Object3D): AssetReport;
527
- /** assets.report as text for the console / describe */
528
- reportText(nameOrRoot: string | Object3D): string;
529
591
  }
530
592
  /** engine.assets.report(): see recipes/46-blender-art-route.md */
531
593
  export interface AssetReport {
532
594
  name: string | null; url: string | null; fromFile: boolean;
533
595
  counts: Record<string, number>;
534
- materials: { name: string; type: string; maps: Record<string, any>; flatShading: boolean; vertexColors: boolean; madeByStyle: boolean }[];
596
+ materials: { name: string; type: string; maps: Record<string, any>; flatShading: boolean; vertexColors: boolean; madeByEngine: boolean }[];
535
597
  textures: any[]; clips: { name: string; seconds: number }[]; colliders: any[]; templates: any[];
536
598
  issues: { severity: 'warn' | 'info'; code: string; msg: string }[];
537
599
  }
@@ -596,7 +658,7 @@ export interface Loading {
596
658
  /** Built-in bus names; a game adds its own with createEngine({ audio: { levels: { voice: 1 } } }) or audio.addBus */
597
659
  export type AudioBus = 'master' | 'music' | 'sfx' | 'ambience' | 'ui' | (string & {});
598
660
  /** A playing sound (returned by audio.sfx / audio.play): stop(fade), fade(to, seconds), setPosition(at) */
599
- import type { SoundHandle } from './generated/core/audioVoice';
661
+ import type { SoundHandle } from './generated/core/audio/audioVoice';
600
662
  export type { SoundHandle };
601
663
  /**
602
664
  * One sounds rule in full form: how a sound plays, never what it is made of (that is the asset manifest's: a file or a synth function).
@@ -663,7 +725,7 @@ export interface ContentAudio {
663
725
  music?: { tracks?: Record<string, import('./gameplay').MusicTrack>; rules?: import('./gameplay').MusicRule[] };
664
726
  footsteps?: Record<string, string>;
665
727
  }
666
- /** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). Not part of a style */
728
+ /** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). */
667
729
  export interface AudioConfig {
668
730
  /** Sound name -> play rule: an asset sound name / path, variants, or SoundDef */
669
731
  sounds?: Record<string, SoundSource>;
@@ -744,8 +806,60 @@ export interface UITitleItem {
744
806
  label: string | ((engine: Engine) => string);
745
807
  run(engine: Engine): any;
746
808
  }
809
+ /** Replaces a window's inner HTML (createEngine({ ui: { templates } }), engine.ui.templates) */
810
+ export type UITemplate = (data: any, tools: { esc: (s: any) => string; t: (key: string, params?: Record<string, any>) => string; icon?: (def: any) => string }) => string;
811
+ /** The CSS values of every default UI part: each key becomes the variable --threedog-<key> on engine.uiRoot */
812
+ export interface UITheme {
813
+ /** Background color */
814
+ bg?: string;
815
+ /** Text color */
816
+ fg?: string;
817
+ /** Secondary text color */
818
+ muted?: string;
819
+ /** Accent color */
820
+ accent?: string;
821
+ /** Color for good news such as "done" */
822
+ good?: string;
823
+ /** Divider color */
824
+ line?: string;
825
+ /** Font (CSS font-family) */
826
+ font?: string;
827
+ /** Corner radius of windows and the dialogue box (CSS, e.g. '12px') */
828
+ radius?: string;
829
+ /** Corner radius of small things: buttons, prompts, toasts, bubbles, HUD counters (CSS, default '8px') */
830
+ radiusSmall?: string;
831
+ /** Loading screen background */
832
+ loadingBg?: string;
833
+ /** Window shadow (CSS) */
834
+ shadow?: string;
835
+ /** Shadow of small things: speech bubbles, objective marker labels (CSS) */
836
+ shadowSmall?: string;
837
+ /** Fade color for scene transitions (CSS), default '#000' */
838
+ fadeBg?: string;
839
+ /** Background / text / accent of objective markers, counters and progress bars (CSS); default: follow bg, fg and accent */
840
+ hudBg?: string;
841
+ hudFg?: string;
842
+ hudAccent?: string;
843
+ /** Other CSS variables (become --threedog-name) */
844
+ [cssVar: string]: string | number | undefined;
845
+ }
846
+ /** createEngine({ ui }): the look of the default parts (theme, css, fonts, templates); every other key is a part name */
847
+ export interface UIOptions {
848
+ /** CSS values of every default part */
849
+ theme?: UITheme;
850
+ /** Extra CSS, placed after every default (overrides .threedog-* classes) */
851
+ css?: string;
852
+ /** Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in theme.font: '"pixel", system-ui' */
853
+ fonts?: string[];
854
+ /** Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar… */
855
+ templates?: Record<string, UITemplate>;
856
+ /** Part name → false (off), true (default), options, or your own part */
857
+ [part: string]: UIPartValue | UITheme | string | string[] | Record<string, UITemplate> | undefined;
858
+ }
747
859
  /** engine.ui: every piece of screen UI is a named part a game can replace or turn off (see recipes/26-ui-parts.md) */
748
860
  export interface UIParts {
861
+ /** Window content by name: a function here replaces that window's default HTML, read each time it draws */
862
+ templates: Record<string, UITemplate>;
749
863
  /** Declare a part and its default (engine and modules; games use set) */
750
864
  define(name: string, factory: UIPartFactory, def?: UIPartDef): void;
751
865
  /**
@@ -756,14 +870,14 @@ export interface UIParts {
756
870
  set(name: string, value: UIPartValue): void;
757
871
  /** The live single part (null when off) */
758
872
  get(name: string): UIPart | null;
759
- /** A new part for one item of a multi part (null when off) */
873
+ /** A new part for one item of a multi part (null when off) @experimental */
760
874
  create(name: string): UIPart | null;
761
875
  /** Open a full-screen part (title): shows it, takes Esc, locks input, freezes gameplay, emits ui:open; false when off */
762
876
  open(name: string, data?: object): boolean;
763
877
  /** Close a full-screen part, emits ui:close */
764
878
  close(name: string): void;
765
- isOpen(name: string): boolean;
766
- /** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle */
879
+ /** @experimental */ isOpen(name: string): boolean;
880
+ /** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle @experimental */
767
881
  titleItem(id: string, item: { label: string | ((engine: Engine) => string); run(engine: Engine): any }): { remove(): void };
768
882
  /** name -> 'default' | 'custom' | 'off' */
769
883
  describe(): Record<string, string>;
@@ -778,6 +892,9 @@ export interface UIParts {
778
892
  // Ground interface
779
893
  // ======================================================================
780
894
 
895
+ /** Conventional names for the picture values only one writer may hold (core/scene/pictureSlots.js), taken with provides like any other slot */
896
+ export type PictureSlot = 'sky' | 'fog' | 'tone' | 'environment' | 'background' | 'sun';
897
+
781
898
  /** Ground: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0) */
782
899
  export interface Ground {
783
900
  /**
@@ -802,16 +919,14 @@ export interface Ground {
802
919
  forEachCollider?(x: number, z: number, range: number, fn: (cx: number, cz: number, r: number) => void): void;
803
920
  /** Optional: chunk edge length (meters) */
804
921
  chunkSize?: number;
805
- /** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else the fog distance, look.fog far) */
922
+ /** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) @experimental */
806
923
  viewRange?(): number;
807
- /** Optional: collision data of a chunk (used by the physics module) */
924
+ /** Optional: collision data of a chunk (used by the physics module) @experimental */
808
925
  chunkCollision?(cx: number, cz: number): any;
809
- /** Optional: static triangle mesh (the level module provides it for physics) */
926
+ /** Optional: static triangle mesh (the level module provides it for physics) @experimental */
810
927
  staticTrimeshes?(): { positions: Float32Array; indices: Uint32Array }[];
811
- /** Optional: version number of the static mesh; rebuild when it changes */
928
+ /** Optional: version number of the static mesh; rebuild when it changes @experimental */
812
929
  staticVersion?(): number;
813
- /** Optional: triangle mesh for building the navmesh (walkable surfaces + obstacle volumes), used by the nav module */
814
- navGeometry?(): { positions: Float32Array; indices: Uint32Array };
815
930
  }
816
931
 
817
932
  // ======================================================================
@@ -846,8 +961,8 @@ export interface ModuleCtx {
846
961
  whileCompiling(fn: () => void): void;
847
962
  }
848
963
 
849
- /** What a module may own (ModuleDef.type; core/moduleTypes.js) */
850
- export type ModuleType = 'world' | 'look' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
964
+ /** What a module may own (ModuleDef.type; core/engine/moduleTypes.js) */
965
+ export type ModuleType = 'world' | 'picture' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
851
966
 
852
967
  /**
853
968
  * A module (the argument of engine.use). The name is the property name on the engine once installed.
@@ -857,11 +972,11 @@ export interface ModuleDef<Api = any> {
857
972
  /** Module name; after install, access the object returned by install through engine[name] */
858
973
  name: string;
859
974
  /**
860
- * What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'look' what is seen and heard (changes no
975
+ * What the module owns (default 'rules'; core/engine/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'picture' what is seen and heard (changes no
861
976
  * game state: no ops, no world record writes) | 'actor' characters | 'rules' game logic | 'ui' panels and menus (binds no keys, no game save part)
862
- * | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Breaking a rule throws in dev with the fix.
977
+ * | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Going against one warns once in dev with the fix; the call still goes through.
863
978
  */
864
- type: ModuleType;
979
+ type?: ModuleType;
865
980
  /** Display name (used by the loading screen) */
866
981
  label?: string;
867
982
  /**
@@ -872,8 +987,9 @@ export interface ModuleDef<Api = any> {
872
987
  /**
873
988
  * Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep
874
989
  * working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
990
+ * Picture values only one writer may hold have conventional names (PictureSlot, PICTURE_SLOTS; recipes/62-picture-code.md "Picture parts").
875
991
  */
876
- provides?: string[];
992
+ provides?: (PictureSlot | (string & {}))[];
877
993
  /**
878
994
  * Optional dependencies (modules the code uses as e.xxx?. or guards with if (e.xxx); rule R16 requires listing them all).
879
995
  * An array only registers them; written as { moduleName: 'what is lost when missing' }, start() prints a one-time development hint when one is
@@ -894,7 +1010,7 @@ export interface ModuleDef<Api = any> {
894
1010
  after?: string[];
895
1011
  /**
896
1012
  * The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of
897
- * starting a broken game. Without it a failed init is reported by severity (type look / ui: disabled and the game carries on; other types: error tiers) and
1013
+ * starting a broken game. Without it a failed init is reported by severity (type picture / ui: disabled and the game carries on; other types: error tiers) and
898
1014
  * start() goes on. Only start() reads it; a critical module installed after start() is reported like any other
899
1015
  * @example engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })
900
1016
  */
@@ -923,6 +1039,12 @@ export interface ModuleDef<Api = any> {
923
1039
  * Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
924
1040
  */
925
1041
  skip?(dt: number, e: Engine, done: boolean): void;
1042
+ /** Why a module with a fixed hook has no skip hook: engine.catalog shows it instead of a warning */
1043
+ noSkip?: string;
1044
+ /** The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it */
1045
+ params?: any;
1046
+ /** Where its docs live, shown by engine.catalog */
1047
+ docs?: string;
926
1048
  /**
927
1049
  * Optional: add state to engine.describe(). The (JSON-able) return value goes into the result keyed by the module name; nothing is added if it
928
1050
  * returns nothing.
@@ -933,8 +1055,10 @@ export interface ModuleDef<Api = any> {
933
1055
  counts?(e: Engine): number | Record<string, number>;
934
1056
  /** Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) } */
935
1057
  explain?: Record<string, (e: Engine, value: any, query: Record<string, any>) => { ok: boolean; text: string; [k: string]: any }>;
936
- /** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season) */
937
- applyState?(e: Engine, params: StateParams): void | Promise<void>;
1058
+ /** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position; return { refused: { key: reason } } for a value it cannot apply */
1059
+ applyState?(e: Engine, params: StateParams): void | PositionLike | { refused: Record<string, string> } | Promise<void>;
1060
+ /** Optional: the applyState keys this module handles; a key no module handles is reported in applyState's refused list. Leave out to count for every key */
1061
+ stateKeys?: string[];
938
1062
  /**
939
1063
  * Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers,
940
1064
  * Audio nodes you connected yourself.
@@ -961,10 +1085,7 @@ export interface EngineOptions {
961
1085
  * working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
962
1086
  * Every fallback prints one '[threedog] WebGPU unavailable (...)' line and shows in describe().renderer */
963
1087
  fallback?: 'webgl2' | 'webgl' | 'error';
964
- /** Style (looks only: materials, sky, lighting, post, UI look), the game's own style (import style from './style/index.js'), or a list of parts
965
- * deep-merged left to right: [basePack, { sky: { sunSize: 600 } }]. Without one: neutral gray placeholders */
966
- style?: StyleInput;
967
- /** MSAA anti-aliasing (kept with post effects on), default style.antialias, else on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on) */
1088
+ /** MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on) */
968
1089
  antialias?: boolean;
969
1090
  /** Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it */
970
1091
  pixelRatio?: number;
@@ -973,10 +1094,12 @@ export interface EngineOptions {
973
1094
  /** Target frame rate for automatic resolution lowering, default 55 */
974
1095
  targetFps?: number;
975
1096
  /**
976
- * UI parts: replace or turn off any piece of screen UI (loading, toast, title, hud.marker, hud.counter, hud.bar). Default title screen is off.
1097
+ * All screen UI: replace or turn off any part (loading, toast, title, hud.marker, hud.counter, hud.bar; the default title screen is off), and the look of the
1098
+ * default parts (theme, css, fonts, templates).
977
1099
  * @example createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })
1100
+ * @example createEngine({ canvas, ui: { theme: { bg: '#1c140e', accent: '#e8a13a' }, css: '.threedog-prompt{font-size:16px}' } })
978
1101
  */
979
- ui?: Record<string, UIPartValue>;
1102
+ ui?: UIOptions;
980
1103
  /** Volume of each channel, 0–1 */
981
1104
  audio?: AudioConfig;
982
1105
  /** Camera field of view (degrees), default 55 */
@@ -1004,16 +1127,18 @@ export interface EngineOptions {
1004
1127
  /**
1005
1128
  * Check parameter names at runtime and warn on misspelled names (the console prints "did you mean xxx"), default true; a release build can write false
1006
1129
  * to turn it off
1130
+ * @experimental
1007
1131
  */
1008
1132
  validate?: boolean;
1009
1133
  /**
1010
1134
  * Directory of Draco/KTX2 decoders (a URL containing draco/ and basis/), for when they live on a CDN. Normally not needed: the decoders bundled with
1011
1135
  * three are packed by vite automatically
1136
+ * @experimental
1012
1137
  */
1013
1138
  decoders?: string;
1014
1139
  /** Performance budget limits, e.g. { drawCalls: 250, fps: 55 }; only the given categories are checked; off by default */
1015
1140
  budget?: BudgetLimits;
1016
- /** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development */
1141
+ /** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development @experimental */
1017
1142
  urlState?: boolean;
1018
1143
  /** Seed for engine.random; default 1 in headless mode (reproducible), the current time for live runs (different every game) */
1019
1144
  seed?: number;
@@ -1029,9 +1154,9 @@ export interface EngineOptions {
1029
1154
  threads?: 'auto' | number | false;
1030
1155
  /** Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page) */
1031
1156
  pauseOnBlur?: boolean;
1032
- /** false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. Default true */
1157
+ /** false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. No light of the engine's reaches the picture. Default true */
1033
1158
  lights?: boolean;
1034
- /** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: engine.stream.cellSize } */
1159
+ /** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: 4 * engine.stream.cellSize } */
1035
1160
  batching?: false | BatchingOptions;
1036
1161
  }
1037
1162
 
@@ -1104,7 +1229,7 @@ export interface ThingExplanation {
1104
1229
  /** at: 'content/props.js:14' (null in release builds and for code without a file) */
1105
1230
  definition: { at: string | null; template: string | null; templateAt: string | null; level?: string; node?: string; spawned?: boolean; [k: string]: any };
1106
1231
  model: string | null;
1107
- materials: ({ role: string | null; name: string | null; from: string | null; keys: string[]; type: string; color: string | null; mesh: string | null } | { more: number })[];
1232
+ materials: ({ role: string | null; name: string | null; from: 'engine' | 'game'; type: string; color: string | null; mesh: string | null } | { more: number })[];
1108
1233
  state: { position?: number[]; visible?: boolean; scale?: number[]; [k: string]: any };
1109
1234
  rules: { height?: number; blocksMovement?: any; pickable?: boolean; interact?: any; [k: string]: any };
1110
1235
  ops: { op: string; desc: string | null; args: any }[];
@@ -1146,7 +1271,7 @@ export interface HitThing {
1146
1271
  phase?: 'setup' | 'play';
1147
1272
  op?: string | null;
1148
1273
  tick?: number;
1149
- /** how much a save keeps (recipe 41): record = world save; code = thing.set / thing.remove overrides; session = nothing; engine = its module's business */
1274
+ /** how much a save keeps (recipe 40): record = world save; code = thing.set / thing.remove overrides; session = nothing; engine = its module's business */
1150
1275
  saved?: 'record' | 'code' | 'session' | 'engine';
1151
1276
  /** what a save keeps / loses, in words */
1152
1277
  keeps?: string[];
@@ -1201,7 +1326,7 @@ export interface StreamEntryOptions {
1201
1326
  radius?: number;
1202
1327
  /** Generate the object (called when entering range, run spread over frames through engine.jobs) */
1203
1328
  build: () => Object3D | Promise<Object3D>;
1204
- /** Unload (called when leaving range), default engine.remove (full removal); write your own when the object is reused (e.g. engine.detach) */
1329
+ /** Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. engine.detach) */
1205
1330
  dispose?: (obj: Object3D) => void;
1206
1331
  /** Do not unload even when out of range */
1207
1332
  keep?: boolean;
@@ -1253,9 +1378,12 @@ export interface StreamHandle { def: StreamEntryOptions; object: Object3D | null
1253
1378
  * world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
1254
1379
  */
1255
1380
  export interface StartupReport {
1256
- totalMs: number; startMs: number; preloadMs: number; streamMs: number | null; compileMs: number; modules: Record<string, { init?: number; ready?: number }>;
1257
- firstFrameMs: number | null;
1258
- phases: { script: number; construct: number; setup: number; init: number; preload: number; world: number; compile: number; draw: number | null };
1381
+ /** @experimental */ totalMs: number;
1382
+ /** @experimental */ startMs: number;
1383
+ /** @experimental */ preloadMs: number;
1384
+ /** @experimental */ streamMs: number | null; compileMs: number; modules: Record<string, { init?: number; ready?: number }>;
1385
+ /** @experimental */ firstFrameMs: number | null;
1386
+ /** @experimental */ phases: { script: number; construct: number; setup: number; init: number; preload: number; world: number; compile: number; draw: number | null };
1259
1387
  }
1260
1388
 
1261
1389
  // ======================================================================
@@ -1274,6 +1402,8 @@ export interface StateParams {
1274
1402
  weather?: string;
1275
1403
  /** Player position: 'x,z' or a position (sets the focus when there is no player) */
1276
1404
  pos?: string | PositionLike;
1405
+ /** Start at a named place (content places, level markers): past the title like play, then the player stands there with the game's camera on it */
1406
+ at?: string;
1277
1407
  /** Which save slot to load */
1278
1408
  save?: string;
1279
1409
  /** How many seconds to advance (real seconds: fixed-step seconds, no scale) */
@@ -1284,12 +1414,15 @@ export interface StateParams {
1284
1414
  view?: string;
1285
1415
  /** Present (?play, any value): leave the title screen the way its Start does (engine.session.newGame(), the title part closes; flow leaves its start state) before wait; nothing when no title is up */
1286
1416
  play?: string | boolean;
1417
+ /** Delete every save of this page first (no Continue on the title); on a running page also end the run and go back to the title. ?fresh in the URL */
1418
+ fresh?: string | boolean;
1287
1419
  }
1288
1420
 
1289
1421
  /** A claim on something only its owner releases (pause, freeze, takeCamera, views) */
1290
1422
  export interface OwnerHandle { owner: string; remove(): void }
1291
- /** engine.runState: state in one word, owners = every pause / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
1292
- export interface RunState { state: 'loading' | 'title-frozen' | 'test-paused' | 'paused' | 'running'; owners: string[]; blockedBy: string[] }
1423
+ /** engine.runState: state in one word, owners = every halt / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
1424
+ export interface RunState { state: 'loading' | 'title-frozen' | 'halted' | 'frozen' | 'running'; owners: string[];
1425
+ /** @experimental */ blockedBy: string[] }
1293
1426
  /** Camera takeover: when non-null no camera module moves the camera (for cutscenes); see engine.takeCamera */
1294
1427
  export interface CameraOverride {
1295
1428
  /** Who took over (any name) */
@@ -1299,238 +1432,151 @@ export interface CameraOverride {
1299
1432
  [key: string]: any;
1300
1433
  }
1301
1434
  /** State of automatic resolution */
1302
- export interface AdaptiveState { paused: boolean; on: boolean; target: number; min: number; max: number; /** true once the render scale was lowered below max (a dev warning was logged) */ lowered?: boolean; [key: string]: any }
1435
+ export interface AdaptiveState { on: boolean; target: number; min: number; max: number; /** The ratio this device or game starts at: the base of the settings presets */ base: number;
1436
+ /** true once the render scale was lowered below max (a dev warning was logged) @experimental */ lowered?: boolean; [key: string]: any }
1303
1437
 
1304
1438
  // ======================================================================
1305
- // Look parts engine.look.<part> (recipes/52-look.md)
1439
+ // Shadows: engine.shadows (recipes/45-cascaded-shadows.md)
1306
1440
  // ======================================================================
1307
1441
 
1308
- /** Returned by set / patch / replace: remove() takes that owner's layer back off */
1309
- export interface LookHandle { remove(): void }
1310
- /** engine.look.shadow */
1311
- export interface LookShadowPart extends LookPart<LookShadow> {
1442
+ /** engine.shadows.cascades options (recipes/45) */
1443
+ export interface ShadowCascadeOptions {
1444
+ /** Shadow maps along the view, 1-4 (default 3; 1 = the plain single map) */
1445
+ count?: number;
1446
+ /** Meters from the camera they cover (default 120) */
1447
+ maxFar?: number;
1448
+ /** Where the borders fall (default 'practical') */
1449
+ split?: 'practical' | 'uniform' | 'logarithmic' | ((count: number, near: number, far: number, out: number[]) => void);
1450
+ /** Cross-fade at the borders (default true) */
1451
+ fade?: boolean;
1452
+ /** Meters behind each cascade box toward the light still caught as casters (default 100) */
1453
+ lightMargin?: number;
1454
+ /** On engine.tier 'low': { count } (default 1, one map) */
1455
+ low?: { count: number };
1456
+ }
1457
+ /** What engine.shadows.cascades returns */
1458
+ export interface ShadowCascades {
1459
+ /** The game's light it was given */
1460
+ readonly light: import('three').DirectionalLight;
1461
+ /** three's CSM object (the shadow node on WebGPURenderer); null while there is one map @experimental */
1462
+ readonly csm: any;
1463
+ /** Change options (a rebuild recompiles lit materials: a settings screen, not per frame) */
1464
+ set(options: ShadowCascadeOptions): void;
1465
+ /** Back to one plain shadow map: the light's position, target and shadow box as the game left them */
1466
+ remove(): void;
1467
+ }
1468
+ /** engine.shadows.box options */
1469
+ export interface ShadowBoxOptions {
1470
+ /** What the box centers on: 'focus' (engine.focus, default) | 'camera' | an Object3D | () => Vector3 | false (it stays on the light's target) */
1471
+ follow?: 'focus' | 'camera' | import('three').Object3D | (() => import('three').Vector3) | false;
1472
+ /** Half size of the box in meters; left out: the light's own shadow camera stays as it is */
1473
+ extent?: number;
1474
+ /** Center snap grid in meters (default 0.5), or 'texel': one shadow pixel */
1475
+ snap?: number | 'texel';
1476
+ /** Meters the center is shifted in front of the view, default 0 */
1477
+ ahead?: number;
1478
+ }
1479
+ /** What engine.shadows.box returns */
1480
+ export interface ShadowBox {
1481
+ set(options: ShadowBoxOptions): void;
1482
+ /** Stop following: the light's position, target and shadow camera come back */
1483
+ remove(): void;
1484
+ }
1485
+ /** What engine.shadows.budget returns */
1486
+ export interface ShadowBudget {
1487
+ set(options: { every?: number }): void;
1488
+ /** Redraw this light's map on the next frame */
1489
+ redraw(): void;
1490
+ /** light.shadow.autoUpdate as it was */
1491
+ remove(): void;
1492
+ }
1493
+ /** A game's own term: a patch, in place of the engine's on every material that carries it */
1494
+ export interface TermSpec {
1495
+ /** Slot code for WebGLRenderer */
1496
+ glsl?: string;
1497
+ /** (ctx) => node for WebGPURenderer */
1498
+ tsl?: any;
1499
+ uniforms?: Record<string, any>;
1500
+ /** Extra declarations for the glsl */
1501
+ pars?: string;
1502
+ /** Default 'lighting' for the cloud shadow, 'color' for the season tint */
1503
+ slot?: string;
1504
+ }
1505
+ /** engine.shaderTerms */
1506
+ export interface Terms {
1312
1507
  /**
1313
- * Let cascaded shadows patch a lit ShaderMaterial of yours (lights: true, built from THREE.ShaderLib); built-in lit materials need nothing. Returns it.
1314
- * @example engine.look.shadow.include(myShaderMaterial);
1508
+ * Your own cloud shadow in place of the engine's on engine materials and on what you passed to applyEffects, built before the call too; false takes it off them
1509
+ * all. uWeatherCloud, uCloudShadow*, uTime and threedogCloudShadow(worldPos) stay in scope. remove() gives the engine's back.
1510
+ * @example const mine = engine.shaderTerms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= 0.5;', tsl: c => ({ directDiffuse: c.directDiffuse.mul(0.5) }) }); mine.remove();
1315
1511
  */
1316
- include<M extends import('three').Material>(material: M): M;
1512
+ cloudShadow(spec: TermSpec | false): { remove(): void };
1513
+ /**
1514
+ * Your own season and snow tint in place of the engine's on engine materials and on what you passed to applyEffects with a season, built before the call too; false
1515
+ * takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix, uGroundCover and threedogSeason(color, kind) stay in scope. remove() gives the engine's back.
1516
+ * @example const mine = engine.shaderTerms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uGroundCover.y);', tsl: c => c.color })); mine.remove();
1517
+ */
1518
+ season(spec: TermSpec | ((kind: 'foliage' | 'ground') => TermSpec) | false): { remove(): void };
1317
1519
  }
1318
- /** engine.look.post: a LookPart whose add() is the one way to put a post effect in the chain (game code, the plugins folder and style plugins all use it) */
1319
- export interface LookPost extends LookPart {
1520
+ /** engine.autoView */
1521
+ export interface View {
1320
1522
  /**
1321
- * Add one post effect: a plain three.js Pass (WebGL; placed by kind: a pass that renders engine.scene itself replaces the scene render,
1322
- * FXAA / SMAA / TAA run last, any other after the style's effects in 'hdr'), a node function (input, ctx) => node (WebGPU), or an effect
1323
- * { name, create, node, fuse, slot, order, params } (both renderers). opts: name (its look.post key: set({ [name]: false })), slot, order
1324
- * (position in the chain), owner. Slot, order and depth-order errors throw and add nothing. remove() takes it out (a Pass of yours is not disposed)
1325
- * @example engine.look.post.add(new UnrealBloomPass(size, 0.6, 0.4, 0.85), { name: 'glow' }); engine.look.post.set({ glow: false });
1523
+ * Stop the engine changing a camera or drawing-buffer value: it is yours until you hand it back (a direct write takes it too; this says so on purpose, with no
1524
+ * warning). 'camera' hands the pose back after a direct write (take it with engine.takeCamera(owner)). Pass false to hand back; remove() does the same.
1525
+ * @example const mine = engine.autoView.manual('far'); engine.camera.far = 5000; mine.remove();
1326
1526
  */
1327
- add(x: PostEffect | { render(...args: any[]): any } | ((input: any, ctx: any) => any),
1328
- opts?: { name?: string; slot?: import('./generated/render/PostFX').PostSlot; order?: number; owner?: string }): { name: string | null; remove(): void };
1527
+ manual(key: 'far' | 'fov' | 'pixelRatio' | 'camera', on?: boolean): { remove(): void };
1329
1528
  }
1330
- /** engine.look.materials: a LookPart whose add() puts a shader patch on some roles, with glow() for emissive that follows daylight */
1331
- export interface LookMaterials extends LookPart<Record<string, Record<string, any>>> {
1529
+ /** engine.shadows.cache options: an Object3D (its whole subtree), a list of them, or a test on each mesh (recipes/45) */
1530
+ export interface ShadowCacheOptions { static: import('three').Object3D | import('three').Object3D[] | ((mesh: import('three').Object3D) => boolean); }
1531
+ /** What engine.shadows.cache returns */
1532
+ export interface ShadowCache {
1533
+ /** Say again what is static; the kept map redraws */
1534
+ set(options: ShadowCacheOptions): void;
1535
+ /** Draw the static casters again on the next shadow frame: after one moved, hid or left */
1536
+ redraw(): void;
1537
+ /** The light's plain shadow again */
1538
+ remove(): void;
1539
+ }
1540
+ /** engine.shadows */
1541
+ export interface Shadows {
1332
1542
  /**
1333
- * Add a named ShaderPatch to the materials made for roles (none = all) from now on; the handle's remove() takes it out. (Was materials.patch:
1334
- * patch only swaps a named hook, and materials have none.)
1335
- * @example const h = engine.look.materials.add('tint', { slot: 'color', glsl: 'diffuseColor.rgb *= 0.9;' }, { roles: ['wool'] });
1543
+ * Master switch: renderer.shadowMap.enabled, never a light's castShadow; materials recompile once. A cutscene holds it with
1544
+ * engine.mod('shadows.enabled', { owner, layer: 'system', set: false }); the settings menu restricts it.
1336
1545
  */
1337
- add(name: string, patch: import('./generated/render/patches').ShaderPatch | Record<string, any>, opts?: { roles?: string[]; owner?: string }): LookHandle;
1546
+ enabled: boolean;
1547
+ /** Cascaded shadows for a DirectionalLight (in engine.scene, castShadow on): sharp near the camera, wide far away; color, intensity and shadow values stay yours */
1548
+ cascades(light: import('three').DirectionalLight, options?: ShadowCascadeOptions): ShadowCascades;
1549
+ /** Keep a DirectionalLight's one shadow map around something that moves; the light keeps its direction */
1550
+ box(light: import('three').DirectionalLight, options?: ShadowBoxOptions): ShadowBox;
1551
+ /** Redraw one light's shadow map every N frames; other lights are not touched */
1552
+ budget(light: import('three').Light, options?: { every?: number }): ShadowBudget;
1338
1553
  /**
1339
- * Materials matching `match` (a material role or material.name such as 'window', one Material, or (material) => boolean) get emissiveIntensity
1340
- * `night` at night and `day` by day, faded in as daylight (calendar, else sky) drops below `dusk` (default 0.3, a starting value: raise it
1341
- * for signs that come on early, lower it for things that only glow in full dark; 0 = on only while daylight is 0). Finds models built later (templates, streamed
1342
- * cells) after each scene change; the emissive color stays the game's. remove() gives each material its own emissiveIntensity back.
1343
- * describe().look.materials lists each rule and how many materials it found
1344
- * @example engine.look.materials.glow('window', { night: 2 });
1554
+ * Keep the shadows of what does not move: static casters are drawn once, each shadow frame copies them and draws only the rest. One plain map on WebGPURenderer;
1555
+ * elsewhere the light draws everything, with a warning. A static object that moves, hides or leaves needs redraw(); a moving light redraws everything. recipes/45
1556
+ * @example const kept = engine.shadows.cache(sun, { static: mesh => mesh !== cars.mesh }); kept.redraw(); kept.remove();
1557
+ * @experimental
1345
1558
  */
1346
- glow(match: string | import('three').Material | ((material: import('three').Material) => boolean), opts: { night: number; day?: number; dusk?: number; owner?: string }): LookHandle;
1559
+ cache(light: import('three').DirectionalLight, options: ShadowCacheOptions): ShadowCache;
1560
+ /** Change a light's shadow resolution at any time, with cascades every cascade's map (light.shadow.mapSize alone does nothing once a map exists) */
1561
+ mapSize(light: import('three').Light, width: number, height?: number): void;
1347
1562
  /**
1348
- * Make every material makeMaterial made that is on a mesh in the scene again from the current layers (type, replace, patches, spec) and put
1349
- * the new one in its place: the one way a patch / replace / type change reaches materials made before it. Keeps the call's own params, live
1350
- * keys set by hand and patches added after makeMaterial (wind, cloud shadow); the old material is disposed. engine.plugins.off / on of a
1351
- * material or patch plugin calls it. kept: made materials the scene does not hold (left as they are).
1352
- * @example engine.look.materials.rebuild(); // after look.materials.add / replace, for the materials already out
1563
+ * Let cascaded shadows patch a lit ShaderMaterial of yours (lights: true, built from THREE.ShaderLib); built-in lit materials need nothing. Returns it.
1564
+ * @example engine.shadows.include(myShaderMaterial);
1353
1565
  */
1354
- rebuild(): { rebuilt: number; kept: number; ms: number };
1355
- }
1356
- /** owner: who writes the layer (non-empty name, default 'game'); roles: only materials.add, the material roles that get the patch */
1357
- export interface LookOptions {
1358
- owner?: string; roles?: string[];
1359
- /** look.ground.replace(myMaterial, { effects: false }): your material as is, no cloud shadow / season / detail patch */
1360
- effects?: boolean;
1361
- }
1362
- /** patch(hook, spec): a spec instead of plain GLSL ({ glsl, tsl, uniforms }); sky 'layer:<name>': glsl, blend, order, uniforms */
1363
- export interface LookPatchSpec {
1364
- glsl?: string | Record<string, any>;
1365
- /** post: 'hdr' | 'ldr' */
1366
- slot?: string;
1367
- /** post and sky layers: draw order, smaller first */
1368
- order?: number;
1369
- uniforms?: Record<string, any>;
1370
- /** post: live values of the generated effect */
1371
- values?: Record<string, any>;
1372
- /** sky layer: 'mix' | 'add' */
1373
- blend?: string;
1374
- }
1375
-
1376
- /**
1377
- * One look part. Layers, upper wins: engine default < style < game (per owner, last write wins) < engine.debug.override.
1378
- * Every part has the same verbs (docs/plans/2026-11-03-look-api.md); a part offers the ones that make sense for it, the others throw naming
1379
- * the call to use: set (values), patch (swap a named hook), add (one more named thing), replace (the one three.js thing it draws),
1380
- * manual (the engine stops writing), value (the one read). A whole module (behaviour, saves) is engine.use(mine(), { replaces: '<slot>' }).
1381
- */
1382
- export interface LookPart<P = Record<string, any>> {
1383
- /** 'look.<part>': the id engine.catalog() and debug.override use */
1384
- readonly id: string;
1385
- /** Shallow-merge into the owner's layer, only the keys given; null drops a key so the layer below shows again. Keys that recompile shaders warn once in dev */
1386
- set(params: { [K in keyof P]?: P[K] | null } & Record<string, any>, opts?: LookOptions): LookHandle;
1387
- /** Swap one named hook the part declares (names: engine.catalog('look.<part>').hooks); the same name again overrides; patch(hook, null) restores the default */
1388
- patch(hook: string, code: string | LookPatchSpec | null, opts?: LookOptions): LookHandle;
1389
- /** Put one more named thing in next to the engine's (look.post.add, look.materials.add); the handle's remove() takes it out. Other parts throw */
1390
- add(...args: any[]): LookHandle;
1391
- /** Swap the one three.js thing the part draws (texture, sky object, Material, effect list ...: see the catalog); replace(null) gives it back. materials.replace takes the role first */
1392
- replace(thing: any, opts?: LookOptions): LookHandle;
1393
- replace(role: string, thing: any, opts?: LookOptions): LookHandle;
1394
- /**
1395
- * Take values the engine writes on its own (every frame or on a timer: the sky's sun, the fog, camera.far ...) for the game: the engine stops
1396
- * writing them and the three.js object is yours. manual(keys, false) or the handle's remove() gives them back. Keys match by dotted prefix
1397
- * ('sun' takes sun.intensity and sun.color); none = every one of the part; a key that matches nothing throws with the part's keys.
1398
- * A direct write without manual() takes the value too (the engine yields and warns once). Which values: describe().owned, recipes/52 "Who writes it".
1399
- * @example engine.look.lights.manual('sun'); engine.lights.sun.intensity = 3;
1400
- */
1401
- manual(keys?: string | string[] | boolean, on?: boolean): LookHandle;
1402
- /** The value in effect for a key (after every layer): the one read. Who set it and how: engine.describe().look.<part> */
1403
- value(key: string): any;
1404
- /** The three.js object(s) behind the part (renderer, lights, scene.fog ...); changing it directly works but describe tags it 'three'.
1405
- * look.materials: a function, object('wool') = the last Material made for that role, object() = all of them */
1406
- readonly object: any;
1407
- /** For module code that defines or drives a part (defineLookPart, recipes/52-look.md "Your own part"); a game never needs it */
1408
- readonly author: LookPartAuthor;
1409
- }
1410
- /** part.author: raw writes, extending keys, drivers and the per-frame tick, for module code. Kept off LookPart so a game's autocomplete shows only the game verbs */
1411
- export interface LookPartAuthor {
1412
- /** Each verb's call shape, e.g. { set: 'set(params, { owner })', replace: 'replace(role, ...)' } (also in engine.catalog('look.<part>')) */
1413
- readonly signatures: Record<string, string>;
1414
- /** Write raw keys (params, 'hook:<name>', '@replace') for an owner, no normalize; null drops a key */
1415
- write(owner: string, values: Record<string, any>, opts?: { layer?: 'style' | 'game' | 'debug' }): LookHandle;
1416
- /** What one owner holds for a key, or undefined */
1417
- ownerValue(owner: string, key: string, opts?: { layer?: 'game' | 'debug' }): any;
1418
- /** Add declared keys to a started part (same fields as defineLookPart params) */
1419
- extend(params: Record<string, any>): void;
1420
- /** Remove every key starting with prefix, with every layer's value for them */
1421
- retract(prefix: string): void;
1422
- /** Is key a declared param */
1423
- has(key: string): boolean;
1424
- /** [key, value] pairs in effect whose key starts with prefix */
1425
- resolved(prefix?: string): Array<[string, any]>;
1426
- /** Resolved params as a plain object */
1427
- values(): Record<string, any>;
1428
- /** The value from the highest game / debug layer for the key (undefined when only style or default gives it) */
1429
- top(key: string): any;
1430
- /** Replace the style layer */
1431
- restyle(values: Record<string, any>): void;
1432
- /** Declare keys a style-driven system writes every frame (by = the driver's module name); drive(keys, null) hands them back */
1433
- drive(keys: string[], by: string | null): void;
1434
- /** Who drives key every frame, or null */
1435
- driven(key: string): string | null;
1436
- /** The driver's value for a driven key this frame */
1437
- feed(key: string, value: any): void;
1438
- /** @internal Once per frame (the sky's frame calls it): function values on number keys are evaluated */
1439
- tick(ctx: any): void;
1440
- /** Run fn with the recompute held, so several writes apply once */
1441
- batch<T>(fn: () => T): T;
1442
- /** Unregister the part (its module went away); remove, not dispose: it owns no GPU resource */
1443
- remove(): void;
1444
- }
1445
-
1446
- /** Exposure only: the tone curve is plain three.js (engine.renderer.toneMapping), written by the engine once at creation (style.toneMapping, else AgX) */
1447
- export interface LookTone { exposure: number | Array<[number, number]> | ((t: number) => number) }
1448
- export interface LookLightSide { color?: ColorLike; intensity?: number; /** hemi only */ ground?: ColorLike }
1449
- /** env: the neutral generated room environment (scene.environment) the no-style baseline uses; 0 = none */
1450
- export interface LookLights { sun: LookLightSide | 'manual' | false; hemi: LookLightSide | 'manual' | false; env: { intensity?: number; share?: number } }
1451
- /** The map itself is the replace slot: look.env.replace('sky' | Texture | null) */
1452
- export interface LookEnv { intensity: number; rotation: number; interval: number }
1453
- export interface LookFog { kind: string; color: ColorLike | 'horizon'; density: number; near: number; far: number; height: number; falloff: number; enabled: boolean }
1454
- /** Color keys also take ({ time, weather, season, day, state, sky }) => color, evaluated every frame (engine.look.state feeds state) */
1455
- export type LookColorFn = ColorLike | ((ctx: import('./style').LookContext) => ColorLike) | null;
1456
- /** The style.sky look keys (types/style.d.ts StyleSky has what each one does) plus the per-frame color overrides top / horizon */
1457
- export interface LookSky {
1458
- clouds: Record<string, any>; backdrop: LookColorFn; top: LookColorFn; horizon: LookColorFn;
1459
- keyframes: import('./style').SkyKeyframe[]; sunSize: number; sunGlow: number; sunBrightness: number; moonSize: number; moonColor: ColorLike;
1460
- moonBrightness: number; starDensity: number; starScale: number; gradientCurve: number; groundTint: ColorLike; orbitTilt: number; orbitSway: number;
1461
- dim: { tint?: boolean; stars?: boolean };
1462
- }
1463
- export interface LookShadow {
1464
- type: 'basic' | 'pcf' | 'vsm'; radius: number; blurSamples: number; bias: number; normalBias: number; mapSize: number; updateEvery: number;
1465
- snap: number | 'texel'; ahead: number; cascades: number; maxFar: number; fade: boolean; lightMargin: number; enabled: boolean;
1466
- split: 'practical' | 'uniform' | 'logarithmic' | ((count: number, near: number, far: number, out: number[]) => void);
1467
- }
1468
- export interface LookCloudShadow { shadow: number; scale: number; speed: [number, number] }
1469
- export interface LookWind { frequency: number; amplitude: number }
1470
- export interface LookGround {
1471
- colors: Record<string, ColorLike>; biomeColors: Record<string, string | string[]>; steep: Array<{ maxNormalY: number; colors: any }>;
1472
- variation: any; detail: any; shading: string;
1473
- /** Texture shading only: lighting normals 'smooth' (null = smooth) | 'flat' */
1474
- normals: 'smooth' | 'flat' | null;
1475
- }
1476
- export interface LookSurface { lighting: Record<string, any>; detail: Record<string, any>; ramp: number[]; soften: number }
1477
- export interface LookWater {
1478
- color: ColorLike; opacity: number; depthColor: { shallow?: ColorLike; deep?: ColorLike }; foam: Record<string, any>;
1479
- waveHeight: number; waveScale: number; waveSpeed: number; fresnel: number;
1480
- /** Normal map asset name or path (null = none; a change rebuilds the material once) */
1481
- normalMap: string | null; normalScale: number; normalRepeat: number;
1482
- /** Normal map scroll [x, z] per second */
1483
- normalSpeed: [number, number]; shininess: number; specular: ColorLike;
1484
- }
1485
-
1486
- /** engine.look: the parts by name. A part exists only when the module that provides it is installed (fog / sky / shadow / env: sky(); ground: terrain(); wind: vegetation(); water; weather) */
1487
- export interface Look {
1488
- tone: LookPart<LookTone>;
1489
- lights: LookPart<LookLights>;
1490
- /**
1491
- * The camera and canvas values the engine writes on its own: camera.far, camera.fov, the pixel ratio. No params, shader or replace slot:
1492
- * manual('far' | 'fov' | 'pixelRatio') takes one for the game (to place the camera itself use engine.takeCamera(owner))
1493
- * @example engine.look.view.manual('far'); engine.camera.far = 3000; engine.camera.updateProjectionMatrix();
1494
- */
1495
- view: LookPart<{}>;
1496
- cloudShadow: LookPart<LookCloudShadow>;
1497
- env: LookPart<LookEnv>;
1498
- fog: LookPart<LookFog>;
1499
- sky: LookPart<LookSky>;
1500
- /** set({ enabled, type }) always (the engine's own: shadows on, 'pcf'); a sky adds cascades, follow, extent ...; include(myLitShaderMaterial) opts a ShaderMaterial of yours into cascaded shadows */
1501
- shadow: LookShadowPart;
1502
- /** Roles are the keys: set({ wool: { roughness: 0.4 } }), add(name, shaderPatch, { roles }), replace('wool', Material | fn), glow('window', { night: 2 }) */
1503
- materials: LookMaterials;
1504
- surface: LookPart<LookSurface>;
1505
- ground: LookPart<LookGround>;
1506
- wind: LookPart<LookWind>;
1507
- water: LookPart<LookWater>;
1508
- /** Keys 'rain.speed', 'snow.size', 'lightning.brightness', overcastColor ...; patch('rain.fragment', wholeShaderText) */
1509
- weather: LookPart;
1510
- /** Per effect: set({ bloom: { strength: 0.6 }, vignette: false }); add(pass | node fn | effect, { name, owner }); replace([effects]) */
1511
- post: LookPost;
1512
- /**
1513
- * The game's half of the frame context every function-valued look key reads ({ time, weather, season, day, state, sky }): merge fields
1514
- * (null drops one) and get the state back; state() only reads it
1515
- * @example engine.look.fog.set({ color: ({ state }) => state.boss ? '#400' : 'horizon' }); engine.look.state({ boss: true });
1516
- */
1517
- state(patch?: Record<string, any> | null): Record<string, any>;
1518
- /** Parts made with defineLookPart */
1519
- [custom: string]: LookPart | ((patch?: Record<string, any> | null) => Record<string, any>);
1566
+ include<M extends import('three').Material>(material: M): M;
1567
+ /** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off @experimental */
1568
+ readonly csm: any;
1520
1569
  }
1521
-
1522
1570
  /**
1523
- * The engine. Created by createEngine({ canvas, style }); engine.use(module...) installs modules, engine.start() starts it.
1571
+ * The engine. Created by createEngine({ canvas }); engine.use(module...) installs modules, engine.start() starts it.
1524
1572
  * Installed modules hang on the engine (engine.terrain, engine.sky...); modules not installed are undefined, check with engine.xxx?.method().
1525
1573
  */
1526
1574
  export declare class Engine {
1527
1575
  constructor(opts: EngineOptions);
1528
1576
 
1529
1577
  // ---------- Core objects ----------
1530
- /** three.js (a game can also import { THREE } from 'threedog' directly) */
1531
- THREE: typeof import('three');
1532
- /** Style */
1533
- style: Style;
1578
+ /** False when createEngine({ validate: false }) turned the development checks off for this engine */
1579
+ validate: boolean;
1534
1580
  /** three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer) */
1535
1581
  renderer: EngineRenderer;
1536
1582
  /** Device tier: 'low' (phones, integrated graphics) | 'high'. A headless page takes it from ?threedog-tier=low|high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier) */
@@ -1538,11 +1584,10 @@ export declare class Engine {
1538
1584
  /** three.js scene */
1539
1585
  scene: import('three').Scene;
1540
1586
  /**
1541
- * Default lights (neutral without sky; the sky module drives these same two). Hide or retune them for your own lighting: `engine.lights.sun.visible =
1542
- * false`
1587
+ * Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
1543
1588
  */
1544
1589
  lights: { sun: import('three').DirectionalLight; hemi: import('three').HemisphereLight };
1545
- /** three.js PerspectiveCamera (class EngineCamera, core/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
1590
+ /** three.js PerspectiveCamera (class EngineCamera, core/scene/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
1546
1591
  camera: import('three').PerspectiveCamera;
1547
1592
  /**
1548
1593
  * Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the
@@ -1572,20 +1617,21 @@ export declare class Engine {
1572
1617
  */
1573
1618
  actorPosition(id?: string): { x: number; y: number; z: number } | null;
1574
1619
  /**
1575
- * Where the engine is in its life: 'constructed' (start() not called) -> 'loading' (start() running: frame hooks only, no fixed step, so no game
1620
+ * Where the engine is in its life: 'constructed' (start() not called) -> 'starting' (modules init) -> 'loading' (assets and the world; in both frame hooks only, no fixed step, so no game
1576
1621
  * time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved)
1577
1622
  * -> 'disposed'. engine.step() during loading runs frame hooks only
1578
1623
  */
1579
- readonly phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed';
1624
+ readonly phase: 'constructed' | 'starting' | 'loading' | 'ready' | 'running' | 'disposed';
1580
1625
  /** phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property) */
1581
1626
  readonly ready: boolean;
1582
1627
  /** phase is 'disposed' */
1583
1628
  readonly disposed: boolean;
1584
- /** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" */
1629
+ /** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" @experimental */
1585
1630
  readonly moduleOrder: string[];
1586
1631
  /**
1587
1632
  * Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'.
1588
1633
  * A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
1634
+ * @experimental
1589
1635
  */
1590
1636
  readonly moduleStates: Record<string, 'registered' | 'initializing' | 'running' | 'failed' | 'disposed'>;
1591
1637
  /**
@@ -1600,7 +1646,7 @@ export declare class Engine {
1600
1646
  * message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
1601
1647
  */
1602
1648
  readonly error: EngineError | null;
1603
- /** Names of look / ui modules disabled after an error (a module's type decides: look and ui fail soft) */
1649
+ /** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) @experimental */
1604
1650
  readonly disabledModules: Set<string>;
1605
1651
  /**
1606
1652
  * The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on
@@ -1633,40 +1679,34 @@ export declare class Engine {
1633
1679
  readonly loading: Loading;
1634
1680
  /** Post-processing: named effects in slots (add / get / enable / list) */
1635
1681
  post: PostFX;
1636
- /** Every look in one place: engine.look.<part>.set / patch / replace (recipes/52-look.md) */
1637
- look: Look;
1682
+ /** Occlusion culling of the engine's big things (hlod cells, batched groups) on both renderers. Off by default; it pays only when heavy things hide behind others (recipe 34) */
1683
+ occlusion: Occlusion;
1638
1684
  /** UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md) */
1639
1685
  ui: UIParts;
1640
1686
  /** Automatic resolution state */
1641
1687
  adaptive: AdaptiveState;
1642
- /**
1643
- * Main-thread CPU milliseconds of the last real-time frame: input, fixed steps, frame hooks, render submission and afterRender hooks
1644
- * (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
1645
- */
1646
- cpuMs: number;
1647
- /** cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks */
1648
- cpuPhases: { fixed: number; frame: number; render: number; afterRender: number };
1688
+ /** How far the drawn frame is from the last fixed step to the next, 0-1 (real loop); 1 after step(). Holds still while frozen. For drawing fixed-step state smoothly */
1689
+ stepBlend: number;
1649
1690
  /** The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only */
1650
- cameraOverride: CameraOverride | null;
1691
+ readonly cameraOverride: CameraOverride | null;
1651
1692
  /** Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one */
1652
1693
  takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>): OwnerHandle;
1653
1694
  /** Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is */
1654
1695
  readonly runState: RunState;
1655
- /** Draco/KTX2 decoder directory */
1656
- decoders: string;
1657
1696
  /** Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar) */
1658
1697
  clock: Clock;
1659
1698
  /**
1660
1699
  * The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value.
1661
- * @example engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on the enemies channel
1700
+ * @example engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made
1662
1701
  * @example engine.mod('time.player', { owner: 'haste', mul: 1.2, for: 5 }) // haste on the player
1663
1702
  * @example engine.mod('freeze', { owner: 'pause-menu' }) // pause menu (same as engine.freeze('pause-menu'))
1703
+ * @experimental
1664
1704
  */
1665
1705
  mod(name: string, opts: import('./gameplay').ModOptions): import('./gameplay').ModHandle;
1666
- /** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) */
1706
+ /** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) @experimental */
1667
1707
  stacks: import('./gameplay').Stacks;
1668
1708
  /**
1669
- * Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the
1709
+ * Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < physics < net; a higher one pauses the
1670
1710
  * lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57
1671
1711
  * @example const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();
1672
1712
  */
@@ -1676,34 +1716,34 @@ export declare class Engine {
1676
1716
  * for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in
1677
1717
  * describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api.
1678
1718
  * @example engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })
1719
+ * @experimental
1679
1720
  */
1680
1721
  wrap<T extends object>(target: T, method: string, fn: (next: (...args: any[]) => any, ...args: any[]) => any, opts?: { owner?: string }): Handle;
1681
- /** Time channels: real seconds, channel seconds (world, player, your own), read speeds with scale(ch, id?) */
1722
+ /** Time channels: read seconds with time.now('real' | 'ambient' | 'calendar' | a channel such as 'world'), speeds with scale(ch, id?) */
1682
1723
  time: import('./gameplay').Time;
1683
1724
  /** Story flags and counters (autosaved) */
1684
1725
  vars: Vars;
1685
1726
  /** Performance budget (off by default) */
1686
1727
  budget: Budget;
1687
- /** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them */
1728
+ /** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/engine/plugins.js); describe().slots lists them */
1688
1729
  plugins: {
1689
1730
  /** Plug a folder's modules yourself (the vite preset does it): import.meta.glob('./plugins/*.js', { eager: true }) */
1690
1731
  add(files: Record<string, any>, o?: { order?: string[]; off?: string[] }): any;
1691
1732
  /**
1692
- * Unload: take everything a plugin plugged out again (file name without .js; a style pack's name: all its plugins, its starting values stay).
1693
- * A material / patch plugin also rebuilds the made materials (look.materials.rebuild) unless { rebuild: false }. To pause a post effect in
1694
- * its place, look.post.set({ name: false }) is lighter. The result names what was switched, the reach and what stays.
1733
+ * Unload: take everything a plugin plugged out again (file name without .js).
1734
+ * To pause a post effect in its place, engine.post.get(name).enabled = false is lighter. The result names what was switched and what stays.
1695
1735
  */
1696
- off(name: string, o?: { rebuild?: boolean }): { off: string[]; reach: ('live' | 'new materials only')[]; rebuilt: number | null; note: string };
1697
- /** Plug a switched-off plugin again (same place in the post chain; material / patch plugins rebuild the made materials) */
1698
- on(name: string, o?: { rebuild?: boolean }): { on: string[]; reach: ('live' | 'new materials only')[]; rebuilt: number | null; note: string };
1699
- /** In plug order. reach per slot: 'live', or 'new materials only' (a material / patch); replacedBy: the plugin that holds it out (export const replaces) */
1700
- list(): { name: string; file: string; on: boolean; slots: string[]; reach: ('live' | 'new materials only')[]; style: string | null; replacedBy: string | null }[];
1736
+ off(name: string): { off: string[]; note: string };
1737
+ /** Plug a switched-off plugin again (same place in the post chain) */
1738
+ on(name: string): { on: string[]; note: string };
1739
+ /** In plug order. replacedBy: the plugin that holds it out (export const replaces) */
1740
+ list(): { name: string; file: string; on: boolean; slots: string[]; replacedBy: string | null }[];
1701
1741
  };
1702
1742
  /** Ray registry (what engine.raycast hits) */
1703
1743
  rays: Rays;
1704
1744
  /** Frame-spread job scheduler */
1705
1745
  jobs: Jobs;
1706
- /** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits */
1746
+ /** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits @experimental */
1707
1747
  commits: Commits;
1708
1748
  /**
1709
1749
  * Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays.
@@ -1714,11 +1754,6 @@ export declare class Engine {
1714
1754
  ops: Ops;
1715
1755
  /** Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md) */
1716
1756
  views: Views;
1717
- /**
1718
- * Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation
1719
- * log use it). Seconds are views of it: engine.time.now('real' | 'ambient' | 'calendar' | channel)
1720
- */
1721
- readonly tick: number;
1722
1757
  /** Seeded random numbers, an object (not a function): engine.random.next() in [0, 1), .range(a, b), .int(a, b), .pick(list), .chance(p). Use it for gameplay randomness: reproducible and saved with the game */
1723
1758
  random: Random;
1724
1759
  /**
@@ -1743,20 +1778,20 @@ export declare class Engine {
1743
1778
  // ---------- Modules (undefined when not installed) ----------
1744
1779
  /** Procedural terrain, data part (terrain() module: chunks, heights, edits, collision) */
1745
1780
  terrain?: Terrain;
1746
- /** Draws the terrain chunks (terrain()'s look module, slot 'terrain-look'; undefined when a game replaced it) */
1747
- terrainLook?: TerrainLook;
1781
+ /** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) @experimental */
1782
+ terrainDraw?: TerrainDraw;
1748
1783
  /** Vegetation (vegetation() module; grows on terrain or on any ground provider) */
1749
1784
  vegetation?: Vegetation;
1750
- /** Draws the plants (vegetation()'s look module, slot 'vegetation-look'; undefined when a game replaced it) */
1751
- vegetationLook?: VegetationLook;
1752
- /** Sky dome, sun / moon light and fog drawn from the calendar's time (sky() module) */
1785
+ /** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) @experimental */
1786
+ vegetationDraw?: VegetationDraw;
1787
+ /** Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog (sky() module) */
1753
1788
  sky?: Sky;
1754
1789
  /** Time of day, day, seasons and clock-time timers (calendar() module); NPC schedules, content clock conditions and audio time rules read it */
1755
1790
  calendar?: Calendar;
1756
1791
  /** Weather state (weather() module): the table, current values, set / setAuto, save, events */
1757
1792
  weather?: Weather;
1758
- /** Weather look (installed by weather(), needs sky): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky */
1759
- weatherLook?: WeatherLook;
1793
+ /** Weather drawing (installed by weather(); sky is optional): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky @experimental */
1794
+ weatherDraw?: WeatherDraw;
1760
1795
  /** Water surface (water() module) */
1761
1796
  water?: Water;
1762
1797
  /** World data (world() module): things that must be saved, survive level changes and keep changing while far away; the model is built only when nearby */
@@ -1789,6 +1824,8 @@ export declare class Engine {
1789
1824
  triggers?: Triggers;
1790
1825
  /** Particles (particles() module) */
1791
1826
  particles?: Particles;
1827
+ /** Makes a swarm of same-kind gameplay objects (swarm() module): engine.swarm({ name, capacity, geometry, material, fields }) @experimental */
1828
+ swarm?: SwarmMaker;
1792
1829
  /** Settings menu (settings() module) */
1793
1830
  settings?: Settings;
1794
1831
  /** Background music (music() module) */
@@ -1821,6 +1858,12 @@ export declare class Engine {
1821
1858
  nav?: Nav;
1822
1859
  /** HLOD, merged distant geometry (hlod() module) @experimental */
1823
1860
  hlod?: Hlod;
1861
+ /** Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there */
1862
+ shadows: Shadows;
1863
+ /** The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there */
1864
+ autoView: View;
1865
+ /** Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there */
1866
+ shaderTerms: Terms;
1824
1867
  /** Light pool: many light sources, a fixed number of real lights (lightPool() module) */
1825
1868
  lightPool?: LightPool;
1826
1869
  /** Content loading (content() module) */
@@ -1837,11 +1880,15 @@ export declare class Engine {
1837
1880
  * @example engine.use(myInventory(), { replaces: 'inventory' })
1838
1881
  */
1839
1882
  use(...mods: (ModuleInput | { replaces: string | string[] })[]): this;
1883
+ /**
1884
+ * Unload one installed module: its tracked handles, its slots and ctx.mod entries, its dispose. What it added some other way stays (dev reports a picture module's
1885
+ * leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }).
1886
+ * @example engine.unuse('rain');
1887
+ */
1888
+ unuse(name: string): void;
1840
1889
  /** Whether a module is installed */
1841
1890
  has(name: string): boolean;
1842
1891
 
1843
- /** Material by role from this engine's style: engine.makeMaterial('prop', { color: 0x8a5a36 }) */
1844
- makeMaterial(purpose?: string, params?: MaterialSpec): Material;
1845
1892
 
1846
1893
  // ---------- Ground ----------
1847
1894
  /** Set the ground (called by the terrain and level modules); missing parts fall back to flat ground */
@@ -1876,7 +1923,10 @@ export declare class Engine {
1876
1923
  addWaterBody(opts: WaterBodyOptions): Handle & { body: WaterBody };
1877
1924
 
1878
1925
  // ---------- Common ----------
1879
- /** Get UI text (i18n) */
1926
+ /**
1927
+ * Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself
1928
+ * @example engine.t('shop.buy', { name: 'Fish' });
1929
+ */
1880
1930
  t(key: string, params?: Record<string, any>): string;
1881
1931
  /**
1882
1932
  * Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set /
@@ -1931,71 +1981,87 @@ export declare class Engine {
1931
1981
 
1932
1982
  // ---------- Light probes (render/probes.js) ----------
1933
1983
  /**
1934
- * Bake a grid of light probes from the scene as it is now: a cube render at every grid point, turned into spherical harmonics (three's
1935
- * LightProbeGenerator), then one scene `LightProbe` that follows a point (`follow`, default the camera focus) and takes the light
1936
- * interpolated there every frame. The probe light adds to whatever ambient light the scene has (hemi, environment): lower those yourself
1937
- * where the probes take over. A load-time cost, not per frame: 6 renders + a GPU read back per probe, awaited one probe at a time so the page
1938
- * keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start.
1939
- * Render targets and cube cameras are disposed before it resolves. Adding the probe changes the light setup: bake at start-up, not mid-play.
1984
+ * Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and
1985
+ * every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the
1986
+ * scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so).
1987
+ * Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing;
1988
+ * ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once:
1989
+ * bake at start-up, not mid-play.
1940
1990
  * @example const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving });
1941
- * probes.sample(npc.position, npcProbe); // your own probe for one object
1991
+ * saveFile('probes.json', JSON.stringify(probes.toJSON()));
1992
+ * @experimental
1942
1993
  */
1943
1994
  bakeProbes(opts: { bounds: import('three').Box3 | { min: PositionLike; max: PositionLike }; spacing: number; resolution?: number;
1944
- include?: (o: Object3D) => boolean; height?: number; follow?: ProbeFollow; owner?: string }): Promise<ProbeSet>;
1995
+ include?: (o: Object3D) => boolean; owner?: string }): Promise<ProbeSet>;
1945
1996
  /**
1946
- * A probe set from a file made by `handle.toJSON()` (no baking). A wrong shape is refused with code `probes-data` and nothing is added.
1997
+ * A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added.
1947
1998
  * @example const probes = engine.loadProbes(await (await fetch('probes.json')).json());
1999
+ * @experimental
2000
+ */
2001
+ loadProbes(json: ProbeData, opts?: { owner?: string }): ProbeSet;
2002
+ /**
2003
+ * Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with
2004
+ * its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be
2005
+ * played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice.
2006
+ * A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what
2007
+ * was skipped, moved or doubled.
2008
+ * @example const light = await engine.loadLightmap('light/level.lightmap');
2009
+ * @experimental
1948
2010
  */
1949
- loadProbes(json: ProbeData, opts?: { follow?: ProbeFollow; owner?: string }): ProbeSet;
2011
+ loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }): Promise<Lightmap>;
1950
2012
 
1951
2013
  // ---------- Settings ----------
1952
- /** Render resolution */
2014
+ /** Render resolution, and the top adaptive resolution climbs back to */
1953
2015
  setPixelRatio(p: number): void;
1954
- /** Exposure per frame from style.exposure / look.tone keyframes or function, null for a plain number; the sky module calls it with engine.sky @readonly */
1955
- exposureDriver: ((sky: any) => number) | null;
1956
2016
 
1957
2017
  // ---------- Rays, scenarios ----------
1958
2018
  /** Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit) */
1959
2019
  raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions): RayHit | null;
1960
- /** Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY) */
2020
+ /**
2021
+ * Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch
2022
+ * write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
2023
+ */
1961
2024
  pick(ndcX: number, ndcY: number, opts?: RaycastOptions): RayHit | null;
1962
2025
  /** Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done */
1963
- applyState(params: StateParams): Promise<void>;
2026
+ applyState(params: StateParams): Promise<{ ok: boolean, refused: { key: string, value: unknown, reason: string }[] }>;
1964
2027
  /** Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name */
1965
2028
  defineState(name: string, params: StateParams, opts?: { owner?: string }): { owner?: string; remove(): void };
1966
2029
  /**
1967
2030
  * Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it:
1968
2031
  * page.waitForFunction(() => window.engine?.stateApplied)
2032
+ * @experimental
1969
2033
  */
1970
2034
  readonly stateApplied: boolean;
2035
+ /** What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied @experimental */
2036
+ readonly stateRefused: { key: string, value: any, reason: string }[];
1971
2037
 
1972
2038
  // ---------- Start, pause, state ----------
1973
2039
  /** Start: initialize modules, preload assets, wait for the world to be ready */
1974
2040
  start(): Promise<this>;
1975
2041
  /** Whether in headless mode (createEngine({ headless: true })) */
1976
2042
  headless: boolean;
1977
- /** Whether paused (headless mode is paused by default, only step() advances) */
1978
- paused: boolean;
2043
+ /** Whether the real-time loop is stopped: only step() advances the game (headless mode starts this way) */
2044
+ halted: boolean;
1979
2045
  /** Smoothed frame rate */
1980
2046
  fps: number;
1981
- /** Ids of the open windows */
1982
- openWindows: Set<string>;
1983
2047
  /**
1984
2048
  * Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu
1985
2049
  * pause
1986
2050
  */
1987
- pause(owner?: string | { owner?: string; kind?: 'test' }, opts?: { kind?: 'test' }): OwnerHandle; // end it with the handle's remove()
2051
+ haltLoop(owner?: string | { owner?: string }): OwnerHandle; // end it with the handle's remove()
1988
2052
  /** Run fn at the start of the next fixed step (via commits); a Promise of fn's value */
1989
2053
  nextFixed<T>(fn: () => T): Promise<T>;
1990
2054
  /**
1991
2055
  * Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame
1992
2056
  * hooks and rendering continue and the UI works.
1993
2057
  * So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's
1994
- * name, default 'game'. uniforms.uTime (wind, water, clouds) keeps moving while frozen; { ambient: true } stops it too
2058
+ * name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { ambient: true } stops them too (a still)
1995
2059
  */
1996
2060
  freeze(owner?: string | { owner?: string; kind?: 'title'; ambient?: boolean }, opts?: { kind?: 'title'; ambient?: boolean }): OwnerHandle;
1997
2061
  /** Is anyone freezing gameplay? */
1998
2062
  readonly frozen: boolean;
2063
+ /** True while a freeze asked for a full still (freeze(owner, { ambient: true })): frame code that moves things reads this, as animation and particles do */
2064
+ readonly still: boolean;
1999
2065
  /**
2000
2066
  * Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render),
2001
2067
  * negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and
@@ -2031,7 +2097,7 @@ export declare class Engine {
2031
2097
  checkSave(opts?: { ignore?: string[] }): Promise<{ ok: boolean; diffs: { path: string; a: any; b: any }[] }>;
2032
2098
  /**
2033
2099
  * Call engine.describe(opts?: { radius?: number }) to get the current game state (a plain object, JSON.stringify-able); radius is how far counts as
2034
- * "nearby" (meters, default 30). describe('look') or describe({ only: ['look', 'shared'] }) returns just those top-level sections (the whole object
2100
+ * "nearby" (meters, default 30). describe('picture') or describe({ only: ['picture', 'shared'] }) returns just those top-level sections (the whole object
2035
2101
  * is tens of KB on a big world); an unknown name comes back in unknownSections next to the list of sections.
2036
2102
  * engine.describe.add(name, fn) registers the game's own state in one line: the return value of fn(engine, ctx) goes into describe().<name>, and the
2037
2103
  * returned handle's remove() cancels it.
@@ -2045,7 +2111,7 @@ export declare class Engine {
2045
2111
  };
2046
2112
  /**
2047
2113
  * The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, the game's describe.add sections,
2048
- * one line per module with its key counts, the engine tables such as shared / slots / look as one count line), ending with how to expand.
2114
+ * one line per module with its key counts, the engine tables such as shared / slots / owned as one count line), ending with how to expand.
2049
2115
  * { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data).
2050
2116
  * @example engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })
2051
2117
  */
@@ -2091,7 +2157,7 @@ export declare class Engine {
2091
2157
  * Budgets are the game's engine.budget limits, else a reference (desktop 60 fps; not enforced). Plain three.js: renderer.info.
2092
2158
  * @example engine.inspect.perf().text
2093
2159
  */
2094
- perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number; compileMs: number; ok: boolean; text: string;
2160
+ perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number | null; compileMs: number; ok: boolean; text: string;
2095
2161
  budgets: { name: string; value: number; budget: number; from: 'engine.budget' | 'reference'; ok: boolean; next?: string }[];
2096
2162
  compiles: { at: number; programs: number; ms: number }[]; [k: string]: any };
2097
2163
  };
@@ -2133,7 +2199,7 @@ export declare class Engine {
2133
2199
  export interface EngineError {
2134
2200
  /** Where it happened, e.g. "fixed hook of module quests" or "load() of save part 'inventory'" */
2135
2201
  where: string;
2136
- /** The error message (English) */
2202
+ /** The error message (English) @experimental */
2137
2203
  message: string;
2138
2204
  /** Stable code (e.g. 'save-load-threw', 'world-plain'); null for an unknown error */
2139
2205
  code: string | null;
@@ -2173,6 +2239,8 @@ export interface EngineCounts {
2173
2239
  rigid?: number;
2174
2240
  /** Only with particles() installed: alive is the number of live particles, emitters the number of attached emitters */
2175
2241
  particles?: { alive: number; emitters: number };
2242
+ /** Only with swarm() installed: alive is the live objects of all swarms, swarms how many exist */
2243
+ swarm?: { alive: number; swarms: number };
2176
2244
  /** Only with sky() installed: timers is the number of at / between / daily / onSeason timers */
2177
2245
  calendar?: { timers: number };
2178
2246
  /** Any other module's counts(e) hook result, under the module name */
@@ -2201,7 +2269,7 @@ export interface GameState {
2201
2269
  ready: boolean;
2202
2270
  /** Gameplay error in development / testing (gameplay is frozen), null when there is none */
2203
2271
  error: EngineError | null;
2204
- /** look / ui modules disabled after an error */
2272
+ /** picture / ui modules disabled after an error */
2205
2273
  disabledModules: string[];
2206
2274
  /** Modules that are initializing or failed ({ name: state }); absent when every module with an init is running (engine.moduleStates has all) */
2207
2275
  moduleStates?: Record<string, string>;
@@ -2209,14 +2277,14 @@ export interface GameState {
2209
2277
  loading: LoadingView;
2210
2278
  /** tick / real / ambient / calendar are the time views (engine.time); with the calendar module there are also clock, day, season, isDay, timeOfDay */
2211
2279
  time: {
2212
- tick: number; real: number; ambient: number; calendar: number; paused: boolean; frozen: boolean; headless: boolean; clock?: string; day?: number; season?: string; isDay?: boolean;
2280
+ tick: number; real: number; ambient: number; calendar: number; halted: boolean; frozen: boolean; headless: boolean; clock?: string; day?: number; season?: string; isDay?: boolean;
2213
2281
  [key: string]: any;
2214
2282
  };
2215
2283
  /**
2216
- * Everyone who holds the engine still (empty parts left out): pause / freeze / camera / debugView [{ owner, at? }], input [{ context, owner, pass }]
2284
+ * Everyone who holds the engine still (empty parts left out): halt / freeze / camera / debugView [{ owner, at? }], input [{ context, owner, pass }]
2217
2285
  * (input.push), gates { action: owners } (input.gate). Every other shared value is in `shared`
2218
2286
  */
2219
- holds: { pause?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
2287
+ holds: { halt?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
2220
2288
  gates?: Record<string, string[]>; };
2221
2289
  /**
2222
2290
  * Every shared value and exclusive slot with entries, one row each ('move.speed[player]' for one record): the value, who decides it, how it
@@ -2251,20 +2319,21 @@ export interface GameState {
2251
2319
  cutscene: { count: number; skippable: boolean; [key: string]: any } | null;
2252
2320
  /** Installed modules in install order: name, type, and the capabilities it provides / requires when it has any */
2253
2321
  modules: { name: string; type: ModuleType; provides?: string[]; requires?: string[] }[];
2254
- /** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/plugins.js) */
2255
- slots: { slot: 'scene' | 'post' | 'material' | 'patch' | 'module' | 'light'; plugged: string; file: string; on: boolean; reach?: 'live' | 'new materials only'; affects: string[] }[];
2322
+ /** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/engine/plugins.js) */
2323
+ slots: { slot: 'scene' | 'post' | 'module' | 'light'; plugged: string; file: string; on: boolean; affects: string[] }[];
2256
2324
  /**
2257
2325
  * engine.add / world things by save tier (counts only) and what will not survive a load: unsaved ('obj#3 (main.js:88, made during play by op x)'),
2258
2326
  * conflicts (two systems managing one object), orphans (saved ids no object has); atCapped when dev stopped taking stacks
2259
2327
  */
2260
- scene: { game: number; code: number; session: number; world: number; engine: number; unsaved: string[]; conflicts: string[]; orphans: string[]; atCapped?: boolean };
2261
- /** Renderer asked for ('webgl' default, 'webgpu') and the backend drawing ('webgl' | 'webgpu' | 'webgl2'; null before start()); reason: why not WebGPU, or null */
2262
- renderer: { requested: 'webgl' | 'webgpu'; backend: 'webgl' | 'webgpu' | 'webgl2' | null; reason: string | null };
2328
+ scene: { game: number; code: number; session: number; world: number; engine: number; unsaved: string[]; conflicts: string[]; orphans: string[]; atCapped?: boolean; overrides?: { owner: string; target: string; [field: string]: any }[] };
2329
+ /** Which renderer was asked for, which backend draws and why not WebGPU; then what that backend can run: the GPU's name, whether TSL node materials and GLSL
2330
+ * (ShaderMaterial, onBeforeCompile) draw, and how renderer.compute() runs ('transform-feedback': no storage textures, atomics or workgroup memory). Null before start() */
2331
+ renderer: { requested: 'webgl' | 'webgpu'; backend: 'webgl' | 'webgpu' | 'webgl2' | null; reason: string | null; gpu: string | null; tsl: boolean | null; glsl: boolean | null; compute: 'compute-shaders' | 'transform-feedback' | null };
2263
2332
  /** Performance (fps/cpuMs are null while paused) */
2264
2333
  perf: {
2265
2334
  fps: number | null; cpuMs: number | null; drawCalls: number; triangles: number; pixelRatio: number;
2266
2335
  chunks?: { loaded: number; visible: number; queued: number }; budget?: BudgetReport | null; startup?: StartupReport | null;
2267
- /** cpuMs by phase (null while paused), see Engine.cpuPhases */
2336
+ /** cpuMs by phase (null while paused), see engine.inspect.perf() */
2268
2337
  cpu?: { fixed: number; frame: number; render: number; afterRender: number } | null;
2269
2338
  /** Cost of applying background results by stage: transit, build, collider, upload, stream (see engine.budget.cost; upload and transit are approximations) */
2270
2339
  apply?: Record<string, { n: number; totalMs: number; maxMs: number; frameMs: number; bytes: number }>;
@@ -2278,11 +2347,11 @@ export interface GameState {
2278
2347
  * Weather state: name (label is the display name), rain, snow, fog intensity 0–1, progress is the transition progress 0–1
2279
2348
  */
2280
2349
  weather?: any;
2281
- /** Weather look: rainVisible / snowVisible whether raindrops / snowflakes are drawn right now (object names weather-rain / weather-snow), flash 0–1 */
2282
- weatherLook?: { rainVisible: boolean; snowVisible: boolean; flash: number };
2350
+ /** Weather drawing: rainVisible / snowVisible whether raindrops / snowflakes are drawn right now (object names weather-rain / weather-snow), flash 0–1 */
2351
+ weatherDraw?: { rainVisible: boolean; snowVisible: boolean; flash: number };
2283
2352
  /**
2284
- * Every value the engine writes on its own (sun, fog, exposure, camera.far, pixel ratio, camera ...) and who writes it now (writer): 'engine',
2285
- * 'manual:<who>' (look.<part>.manual / sky({ sun: 'manual' })) or 'three (engine yielded)' (the game wrote it directly). manual = the takeover call
2353
+ * Every value the engine writes on its own (shadow box center, background, camera.far, pixel ratio, camera ...) and who writes it now (writer): 'engine',
2354
+ * 'manual:<who>' (engine.autoView.manual(key), or the entry that hands the value to the game) or 'three (engine yielded)' (the game wrote it directly). manual = the takeover call
2286
2355
  */
2287
2356
  owned?: Record<string, { part: string; key: string; writer: string; manual?: string }>;
2288
2357
  /** Content added by other modules */
@@ -2304,7 +2373,7 @@ export interface DescribeContext {
2304
2373
  export interface SkipOptions {
2305
2374
  /** Until the calendar clock next reads this time ('HH:MM' or 0-1; needs calendar). The current time itself means a full day */
2306
2375
  to?: string | number;
2307
- /** Game seconds to skip (> 0) */
2376
+ /** Calendar seconds to skip (> 0) */
2308
2377
  seconds?: number;
2309
2378
  /** Fade out / in seconds (default 0: no fade, the jump happens before skip returns) */
2310
2379
  fade?: number;
@@ -2312,20 +2381,35 @@ export interface SkipOptions {
2312
2381
  save?: string | boolean;
2313
2382
  }
2314
2383
 
2315
- /** Where a probe set's scene LightProbe samples the grid each frame; false: no scene probe (read the grid with sample()) */
2316
- export type ProbeFollow = 'focus' | 'camera' | Object3D | (() => PositionLike) | false;
2317
- /** A probe file: what ProbeSet.toJSON() returns and engine.loadProbes reads (sh: count x 27 numbers, x fastest, then y, then z) */
2318
- export interface ProbeData { format: 'threedog-probes'; version: 1; origin: [number, number, number]; step: [number, number, number]; counts: [number, number, number]; height: number | null; sh: number[] }
2384
+ /** A loaded lightmap (engine.loadLightmap); describe().render.lightmap is its report */
2385
+ export interface Lightmap extends Handle {
2386
+ /** the map: a plain half-float DataTexture on uv1, set as material.lightMap */
2387
+ texture: import('three').DataTexture;
2388
+ /** file side length in pixels */
2389
+ size: number;
2390
+ /** meshes the bake left out, with why (instanced, skinned) */
2391
+ skipped: { name: string; why: string }[];
2392
+ /** baked meshes not found in the scene, or changed since the bake */
2393
+ missing: string[];
2394
+ /** takes the map off the meshes and frees it; the unwrapped geometry stays */
2395
+ remove(): void;
2396
+ }
2397
+ /** A probe file: what ProbeSet.toJSON() returns and engine.loadProbes reads (half: count x 27 half floats, base64; x fastest, then y, then z) */
2398
+ export interface ProbeData { format: 'threedog-probes'; version: 2; origin: [number, number, number]; step: [number, number, number]; counts: [number, number, number]; half: string }
2319
2399
  /** A baked or loaded grid of SH light probes (engine.bakeProbes / loadProbes); describe().render.probes lists the live ones */
2320
2400
  export interface ProbeSet extends Handle {
2321
2401
  /** number of probes */
2322
2402
  count: number;
2323
- /** probes per axis [x, y, z] (y is 1 in height mode) */
2403
+ /** probes per axis [x, y, z] (at least 2 each) */
2324
2404
  counts: [number, number, number];
2325
- /** the actual distance between neighbours per axis (<= spacing, so the grid ends on the bounds) */
2405
+ /** the actual distance between neighbours per axis (<= spacing, so the probes end on the bounds) */
2326
2406
  step: [number, number, number];
2327
- /** the scene LightProbe the engine writes the sh of every frame (null with follow: false); its intensity is yours. Writing its sh yourself takes it over (look.lights.manual('probes')) */
2328
- probe: import('three').LightProbe | null;
2407
+ /** three's probe grid, a plain light in the scene: priority, visible and (WebGPU only: three's WebGL shader ignores it) intensity are yours */
2408
+ grid: import('three').Light & { isLightProbeGrid: true; priority: number; texture: import('three').Data3DTexture | null };
2409
+ /** the world box the grid lights: the probes plus half a step on every side */
2410
+ box: import('three').Box3;
2411
+ /** the probes' SH, 27 numbers each (half precision values) */
2412
+ sh: Float32Array;
2329
2413
  /** bake time in ms (null for a loaded set) */
2330
2414
  bakeMs: number | null;
2331
2415
  /** 'bake' | 'file' */
@@ -2336,6 +2420,6 @@ export interface ProbeSet extends Handle {
2336
2420
  point(i: number, out?: Vector3): Vector3;
2337
2421
  /** plain data for a file: engine.loadProbes(json) makes the same set */
2338
2422
  toJSON(): ProbeData;
2339
- /** takes the scene probe out and stops updating it; sample / toJSON still work */
2423
+ /** takes the grid out of the scene and frees its texture; sample / toJSON still work */
2340
2424
  remove(): void;
2341
2425
  }