threedog 0.5.0 → 0.7.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 (511) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +21 -13
  3. package/core/Assets.js +23 -12
  4. package/core/Audio.js +1 -1
  5. package/core/Baked.js +14 -23
  6. package/core/Budget.js +2 -2
  7. package/core/DebugOverrides.js +33 -18
  8. package/core/Describe.js +10 -11
  9. package/core/Engine.js +50 -46
  10. package/core/I18n.js +2 -2
  11. package/core/Input.js +11 -5
  12. package/core/Inspect.js +6 -3
  13. package/core/InspectMaterials.js +2 -3
  14. package/core/InspectPerf.js +11 -4
  15. package/core/MaterialInfo.js +7 -5
  16. package/core/Rays.js +7 -2
  17. package/core/Stream.js +2 -3
  18. package/core/UrlState.js +49 -9
  19. package/core/Views.js +1 -0
  20. package/core/adaptive.js +2 -2
  21. package/core/assetEntry.js +5 -2
  22. package/core/assetLoad.js +13 -15
  23. package/core/assetManifest.js +6 -3
  24. package/core/assetReport.js +4 -4
  25. package/core/batchGroups.js +9 -1
  26. package/core/catalog.js +16 -3
  27. package/core/chunkStream.js +1 -1
  28. package/core/copies.js +1 -1
  29. package/core/debugView.js +4 -4
  30. package/core/describeRender.js +104 -28
  31. package/core/describeText.js +6 -6
  32. package/core/errorCodes.js +72 -45
  33. package/core/errorHints.js +4 -1
  34. package/core/errors.js +4 -4
  35. package/core/events.generated.js +1 -0
  36. package/core/gameLights.js +9 -2
  37. package/core/lifecycle.js +2 -4
  38. package/core/lightWatch.js +5 -3
  39. package/core/loop.js +18 -11
  40. package/core/math.js +7 -0
  41. package/core/moduleSlots.js +32 -7
  42. package/core/moduleTypes.js +20 -7
  43. package/core/modules.js +7 -7
  44. package/core/namedModel.js +8 -4
  45. package/core/owned.js +33 -30
  46. package/core/page.js +43 -10
  47. package/core/pictureSlots.js +33 -0
  48. package/core/pictureWriters.js +343 -0
  49. package/core/plugins.js +64 -96
  50. package/core/sceneDelta.js +12 -4
  51. package/core/sceneMethods.js +2 -9
  52. package/core/services.js +1 -1
  53. package/core/shadowTypes.js +1 -1
  54. package/core/shadows.js +405 -0
  55. package/core/sharedPoint.js +5 -19
  56. package/core/stackFrames.js +16 -5
  57. package/core/stacks.js +6 -6
  58. package/core/startup.js +9 -11
  59. package/core/thingExplain.js +1 -1
  60. package/core/things.js +1 -1
  61. package/core/tier.js +1 -1
  62. package/core/util.js +1 -1
  63. package/core/validate.js +1 -1
  64. package/core/view.js +43 -0
  65. package/docs/AI.md +62 -58
  66. package/docs/API.md +15 -15
  67. package/docs/CODEMAP.md +36 -54
  68. package/docs/COMMANDS.md +28 -25
  69. package/docs/CONVENTIONS.md +36 -30
  70. package/docs/MIGRATING-0.4.md +93 -1
  71. package/docs/MIGRATING-0.6.md +126 -0
  72. package/docs/MIGRATING-0.7.md +39 -0
  73. package/docs/THREE.md +24 -22
  74. package/docs/api/assets.md +5 -3
  75. package/docs/api/audio.md +2 -2
  76. package/docs/api/budget.md +4 -0
  77. package/docs/api/characters.md +3 -1
  78. package/docs/api/collision.md +2 -2
  79. package/docs/api/engine.md +47 -20
  80. package/docs/api/events.md +2 -1
  81. package/docs/api/grids.md +8 -1
  82. package/docs/api/ground.md +1 -1
  83. package/docs/api/hud.md +3 -0
  84. package/docs/api/input.md +3 -2
  85. package/docs/api/interactions.md +3 -1
  86. package/docs/api/inventory.md +1 -2
  87. package/docs/api/level.md +0 -1
  88. package/docs/api/lightPool.md +1 -1
  89. package/docs/api/occlusion.md +5 -0
  90. package/docs/api/particles.md +6 -3
  91. package/docs/api/pickups.md +6 -0
  92. package/docs/api/post.md +5 -3
  93. package/docs/api/sky.md +12 -10
  94. package/docs/api/terrain.md +12 -6
  95. package/docs/api/terrainDraw.md +12 -0
  96. package/docs/api/tools.md +8 -7
  97. package/docs/api/triggers.md +2 -0
  98. package/docs/api/vegetation.md +7 -2
  99. package/docs/api/vegetationDraw.md +10 -0
  100. package/docs/api/water.md +6 -2
  101. package/docs/api/weather.md +5 -0
  102. package/docs/api/weatherDraw.md +10 -0
  103. package/docs/api/world.md +1 -1
  104. package/docs/recipes/01-new-game.md +19 -23
  105. package/docs/recipes/03-items-pickups.md +25 -4
  106. package/docs/recipes/05-props-bake.md +53 -37
  107. package/docs/recipes/06-clock-events.md +3 -3
  108. package/docs/recipes/07-flow-scenes-pause.md +12 -3
  109. package/docs/recipes/08-weather-sky.md +45 -57
  110. package/docs/recipes/09-materials-lights-models.md +185 -0
  111. package/docs/recipes/10-blender-level.md +2 -2
  112. package/docs/recipes/11-vehicles.md +3 -3
  113. package/docs/recipes/13-animation.md +13 -7
  114. package/docs/recipes/14-custom-module.md +7 -5
  115. package/docs/recipes/15-perf.md +3 -3
  116. package/docs/recipes/16-dev-bridge.md +22 -12
  117. package/docs/recipes/18-world.md +10 -8
  118. package/docs/recipes/19-shooting-picking.md +7 -5
  119. package/docs/recipes/20-content-actions-save.md +6 -2
  120. package/docs/recipes/21-camera.md +8 -3
  121. package/docs/recipes/23-ops.md +1 -1
  122. package/docs/recipes/26-ui-parts.md +35 -11
  123. package/docs/recipes/28-terrain.md +12 -12
  124. package/docs/recipes/29-grid.md +14 -5
  125. package/docs/recipes/30-templates.md +8 -3
  126. package/docs/recipes/31-audio.md +4 -4
  127. package/docs/recipes/32-action-game.md +18 -4
  128. package/docs/recipes/34-environment-lighting.md +102 -38
  129. package/docs/recipes/35-picture-from-reference.md +147 -0
  130. package/docs/recipes/36-sky-ground-plants.md +158 -0
  131. package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
  132. package/docs/recipes/38-environment-hooks.md +67 -0
  133. package/docs/recipes/40-scene.md +106 -27
  134. package/docs/recipes/42-terrain-shape.md +1 -1
  135. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
  136. package/docs/recipes/44-water-weather-hooks.md +191 -0
  137. package/docs/recipes/45-cascaded-shadows.md +121 -23
  138. package/docs/recipes/46-blender-art-route.md +17 -20
  139. package/docs/recipes/47-island-snow-backdrop.md +10 -12
  140. package/docs/recipes/49-game-module-contract.md +1 -1
  141. package/docs/recipes/50-own-renderer.md +3 -3
  142. package/docs/recipes/52-around-the-picture.md +181 -0
  143. package/docs/recipes/53-ground-up-close.md +12 -12
  144. package/docs/recipes/54-three-idioms.md +18 -18
  145. package/docs/recipes/55-mods-time-wrap.md +17 -5
  146. package/docs/recipes/56-webgpu-tsl.md +66 -23
  147. package/docs/recipes/57-control.md +39 -0
  148. package/docs/recipes/58-input.md +3 -0
  149. package/docs/recipes/59-depth-post-effects.md +5 -5
  150. package/docs/recipes/60-judge-the-picture.md +39 -24
  151. package/docs/recipes/61-deploy.md +27 -0
  152. package/docs/recipes/62-picture-code.md +244 -0
  153. package/docs/recipes/63-third-person-start.md +77 -0
  154. package/docs/recipes/64-particles.md +35 -0
  155. package/examples/action/.threedog/content-index.json +1 -1
  156. package/examples/action/GAMEMAP.md +7 -5
  157. package/examples/action/main.js +5 -4
  158. package/examples/action/models.js +12 -14
  159. package/examples/action/picture/index.js +13 -0
  160. package/examples/action/picture/lights.js +35 -0
  161. package/examples/action/picture/materials.js +8 -0
  162. package/examples/action/picture/palette.js +33 -0
  163. package/examples/plain-picture/.threedog/content-index.json +1 -0
  164. package/examples/plain-picture/FINDINGS.md +53 -0
  165. package/examples/plain-picture/GAMEMAP.md +90 -0
  166. package/examples/plain-picture/main.js +48 -0
  167. package/examples/plain-picture/picture/index.js +21 -0
  168. package/examples/plain-picture/picture/lights.js +54 -0
  169. package/examples/plain-picture/picture/materials.js +24 -0
  170. package/examples/plain-picture/picture/palette.js +16 -0
  171. package/examples/plain-picture/picture/sky.js +37 -0
  172. package/examples/pullable.json +31 -9
  173. package/examples/rc2d/GAMEMAP.md +8 -3
  174. package/examples/rc2d/README.md +11 -6
  175. package/examples/rc2d/main.js +25 -33
  176. package/examples/rc2d/picture/index.js +18 -0
  177. package/examples/rc2d/picture/lights.js +11 -0
  178. package/examples/rc2d/picture/materials.js +18 -0
  179. package/examples/rc2d/picture/palette.js +15 -0
  180. package/examples/rc2d/picture/post.js +11 -0
  181. package/examples/rc2d/rc2d.js +18 -28
  182. package/examples/sheepisland/.threedog/content-index.json +1 -1
  183. package/examples/sheepisland/GAMEMAP.md +13 -10
  184. package/examples/sheepisland/assets.js +2 -2
  185. package/examples/sheepisland/content/templates.js +1 -1
  186. package/examples/sheepisland/content/vegetation.js +3 -1
  187. package/examples/sheepisland/main.js +15 -9
  188. package/examples/sheepisland/{style/models.js → models.js} +13 -24
  189. package/examples/sheepisland/picture/index.js +20 -0
  190. package/examples/sheepisland/picture/lights.js +34 -0
  191. package/examples/sheepisland/picture/materials.js +61 -0
  192. package/examples/sheepisland/picture/palette.js +60 -0
  193. package/examples/sheepisland/picture/sky.js +20 -0
  194. package/examples/sheepisland/views.js +1 -1
  195. package/examples/styletest/.threedog/content-index.json +1 -1
  196. package/examples/styletest/GAMEMAP.md +15 -11
  197. package/examples/styletest/main.js +20 -30
  198. package/examples/styletest/models.js +29 -29
  199. package/examples/styletest/params.js +1 -4
  200. package/examples/styletest/picture/env.js +38 -0
  201. package/examples/styletest/picture/index.js +16 -0
  202. package/examples/styletest/picture/lights.js +9 -0
  203. package/examples/styletest/picture/materials.js +28 -0
  204. package/examples/styletest/picture/palette.js +22 -0
  205. package/examples/techniques/contact-shadows/README.md +22 -23
  206. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  207. package/examples/techniques/contact-shadows/main.js +20 -18
  208. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  209. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  210. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  211. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  212. package/examples/techniques/day-night-grade/README.md +13 -16
  213. package/examples/techniques/day-night-grade/main.js +15 -25
  214. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  215. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  216. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  217. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  218. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  219. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  220. package/examples/techniques/interior-light/README.md +16 -13
  221. package/examples/techniques/interior-light/interiorLight.js +19 -17
  222. package/examples/techniques/interior-light/main.js +30 -67
  223. package/examples/techniques/interior-light/picture/index.js +24 -0
  224. package/examples/techniques/interior-light/picture/lights.js +52 -0
  225. package/examples/techniques/interior-light/picture/materials.js +13 -0
  226. package/examples/techniques/interior-light/picture/palette.js +32 -0
  227. package/examples/techniques/interior-light/picture/sky.js +40 -0
  228. package/examples/techniques/modular-building/README.md +4 -3
  229. package/examples/techniques/modular-building/kit.js +2 -2
  230. package/examples/techniques/modular-building/main.js +9 -17
  231. package/examples/techniques/modular-building/picture/index.js +17 -0
  232. package/examples/techniques/modular-building/picture/lights.js +26 -0
  233. package/examples/techniques/modular-building/picture/materials.js +13 -0
  234. package/examples/techniques/modular-building/picture/palette.js +23 -0
  235. package/examples/techniques/night-lights/README.md +15 -14
  236. package/examples/techniques/night-lights/main.js +20 -43
  237. package/examples/techniques/night-lights/nightLights.js +25 -21
  238. package/examples/techniques/night-lights/picture/index.js +18 -0
  239. package/examples/techniques/night-lights/picture/lights.js +44 -0
  240. package/examples/techniques/night-lights/picture/materials.js +15 -0
  241. package/examples/techniques/night-lights/picture/palette.js +34 -0
  242. package/examples/techniques/night-lights/picture/post.js +9 -0
  243. package/examples/techniques/night-lights/picture/sky.js +36 -0
  244. package/examples/techniques/outlines-and-rim/README.md +2 -2
  245. package/examples/techniques/outlines-and-rim/main.js +15 -38
  246. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  247. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  248. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  249. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  250. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  251. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  252. package/examples/techniques/procedural-animation/README.md +5 -3
  253. package/examples/techniques/procedural-animation/main.js +9 -7
  254. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  255. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  256. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  257. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  258. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  259. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  260. package/examples/techniques/procedural-surface/README.md +2 -0
  261. package/examples/techniques/procedural-surface/main.js +17 -55
  262. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  263. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  264. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  265. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  266. package/examples/techniques/stylized-shading/README.md +13 -14
  267. package/examples/techniques/stylized-shading/main.js +11 -42
  268. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  269. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  270. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  271. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  272. package/examples/techniques/stylized-shading/shading.js +2 -2
  273. package/examples/techniques/sun-and-key-light/README.md +20 -22
  274. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  275. package/examples/techniques/sun-and-key-light/main.js +19 -63
  276. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  277. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  278. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  279. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  280. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  281. package/examples/techniques/three-looks/README.md +21 -0
  282. package/examples/techniques/three-looks/main.js +58 -0
  283. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  284. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  285. package/examples/techniques/three-looks/picture/comic.js +27 -0
  286. package/examples/techniques/three-looks/picture/index.js +14 -0
  287. package/examples/techniques/three-looks/picture/sun.js +23 -0
  288. package/examples/techniques/wet-road/README.md +7 -4
  289. package/examples/techniques/wet-road/main.js +18 -38
  290. package/examples/techniques/wet-road/picture/index.js +17 -0
  291. package/examples/techniques/wet-road/picture/lights.js +57 -0
  292. package/examples/techniques/wet-road/picture/materials.js +16 -0
  293. package/examples/techniques/wet-road/picture/palette.js +24 -0
  294. package/examples/techniques/wet-road/picture/sky.js +46 -0
  295. package/examples/webgpu-tsl/GAMEMAP.md +9 -4
  296. package/examples/webgpu-tsl/README.md +13 -10
  297. package/examples/webgpu-tsl/main.js +30 -7
  298. package/examples/webgpu-tsl/picture/index.js +18 -0
  299. package/examples/webgpu-tsl/picture/lights.js +25 -0
  300. package/examples/webgpu-tsl/picture/materials.js +36 -0
  301. package/examples/webgpu-tsl/picture/palette.js +23 -0
  302. package/examples/webgpu-tsl/picture/post.js +16 -0
  303. package/examples/webgpu-tsl/picture/sky.js +30 -0
  304. package/examples/world/.threedog/content-index.json +1 -1
  305. package/examples/world/GAMEMAP.md +15 -12
  306. package/examples/world/art/humanoid.js +9 -13
  307. package/examples/world/art/index.js +2 -2
  308. package/examples/world/art/models.js +3 -4
  309. package/examples/world/art/shapes.js +2 -2
  310. package/examples/world/assets.js +2 -2
  311. package/examples/world/content/audio.js +1 -1
  312. package/examples/world/content/items.js +1 -1
  313. package/examples/world/content/props.js +1 -1
  314. package/examples/world/content/templates.js +1 -1
  315. package/examples/world/content/vegetation.js +1 -1
  316. package/examples/world/main.js +10 -10
  317. package/examples/world/models.js +17 -7
  318. package/examples/world/picture/index.js +20 -0
  319. package/examples/world/picture/lights.js +41 -0
  320. package/examples/world/picture/materials.js +34 -0
  321. package/examples/world/picture/palette.js +74 -0
  322. package/examples/world/picture/post.js +9 -0
  323. package/examples/world/picture/sky.js +39 -0
  324. package/index.d.ts +7 -16
  325. package/index.js +7 -7
  326. package/llms.txt +15 -13
  327. package/modules/ambience/Ambience.js +1 -1
  328. package/modules/calendar/Calendar.js +1 -1
  329. package/modules/calendar/index.js +1 -0
  330. package/modules/camera/FirstPersonCamera.js +1 -1
  331. package/modules/camera/FixedCamera.js +2 -2
  332. package/modules/camera/RtsCamera.js +1 -1
  333. package/modules/camera/common.js +7 -5
  334. package/modules/characters/Character.js +15 -10
  335. package/modules/characters/NPC.js +5 -5
  336. package/modules/characters/assetModel.js +5 -4
  337. package/modules/characters/index.js +28 -3
  338. package/modules/characters/movers/common.js +6 -1
  339. package/modules/characters/movers/manual.js +3 -0
  340. package/modules/characters/movers/support.js +25 -11
  341. package/modules/characters/npcSim.js +5 -1
  342. package/modules/characters/proceduralRig.js +18 -4
  343. package/modules/characters/useModel.js +2 -2
  344. package/modules/collision/Collision.js +4 -2
  345. package/modules/content/index.js +8 -0
  346. package/modules/content/models.js +56 -11
  347. package/modules/content/props.js +5 -3
  348. package/modules/content/rules.js +12 -4
  349. package/modules/content/templates.js +5 -3
  350. package/modules/gameplay/Interactions.js +91 -16
  351. package/modules/gameplay/Inventory.js +3 -3
  352. package/modules/gameplay/dialogueBox.js +1 -1
  353. package/modules/gameplay/dialogueBubbles.js +1 -1
  354. package/modules/gameplay/interactionPrompt.js +1 -1
  355. package/modules/gameplay/interactions.contract.js +1 -1
  356. package/modules/gameplay/inventoryOps.js +2 -2
  357. package/modules/gameplay/pickups.js +62 -24
  358. package/modules/gameplay/questLog.js +2 -2
  359. package/modules/grid/Layer.js +13 -0
  360. package/modules/grid/index.js +40 -11
  361. package/modules/grid/preview.js +24 -15
  362. package/modules/grid/tiles.js +15 -19
  363. package/modules/hlod/index.js +3 -2
  364. package/modules/hud/index.js +13 -0
  365. package/modules/hud/parts.js +9 -7
  366. package/modules/level/index.js +5 -4
  367. package/modules/lights/index.js +12 -8
  368. package/modules/music/Music.js +1 -1
  369. package/modules/particles/Particles.js +41 -20
  370. package/modules/particles/effect.js +21 -6
  371. package/modules/photo/Photo.js +11 -10
  372. package/modules/settings/Settings.js +7 -7
  373. package/modules/settings/apply.js +5 -5
  374. package/modules/settings/sections.js +2 -2
  375. package/modules/settings/strings.js +1 -1
  376. package/modules/sky/Sky.js +104 -89
  377. package/modules/sky/clouds.js +16 -17
  378. package/modules/sky/dome.js +100 -0
  379. package/modules/sky/domeLayers.js +5 -5
  380. package/modules/sky/environment.js +45 -169
  381. package/modules/sky/fog.js +5 -180
  382. package/modules/sky/frame.js +26 -90
  383. package/modules/sky/season.js +3 -3
  384. package/modules/sky/shader.js +35 -29
  385. package/modules/sky/skyModule.js +25 -22
  386. package/modules/sky/tint.js +9 -11
  387. package/modules/terrain/ChunkManager.js +29 -12
  388. package/modules/terrain/draw.js +154 -0
  389. package/modules/terrain/index.js +44 -66
  390. package/modules/terrain/terrainDefaults.js +2 -2
  391. package/modules/terrain/terrainEdit.js +1 -1
  392. package/modules/terrain/terrainGen.js +2 -2
  393. package/modules/triggers/index.js +10 -6
  394. package/modules/vegetation/Vegetation.js +58 -17
  395. package/modules/vegetation/draw.js +191 -0
  396. package/modules/vegetation/groundChunks.js +1 -1
  397. package/modules/vegetation/index.js +10 -10
  398. package/modules/water/Water.js +135 -88
  399. package/modules/water/surface.js +53 -53
  400. package/modules/weather/Weather.js +52 -17
  401. package/modules/weather/particles.js +13 -5
  402. package/modules/weather/shaders.js +1 -1
  403. package/modules/weather/weatherDraw.js +141 -0
  404. package/modules/world/World.js +2 -2
  405. package/modules/world/views.js +1 -1
  406. package/package.json +3 -2
  407. package/presets.js +2 -2
  408. package/render/PostFX.js +199 -41
  409. package/render/backend.js +52 -6
  410. package/render/cascades.js +195 -0
  411. package/render/cascades.tsl.js +96 -0
  412. package/render/daylight.js +39 -0
  413. package/render/detail.js +5 -5
  414. package/render/effects.js +41 -26
  415. package/render/fx/cel.tsl.js +42 -0
  416. package/render/fx/index.js +7 -5
  417. package/render/fx/patchNodes.tsl.js +1 -1
  418. package/render/fx/postWebGPU.tsl.js +30 -7
  419. package/render/fx/sky.tsl.js +19 -92
  420. package/render/fx/water.tsl.js +1 -1
  421. package/render/layers.js +14 -0
  422. package/render/lighting.js +6 -5
  423. package/render/lightmap.js +142 -0
  424. package/render/lights.js +23 -201
  425. package/render/materials.js +44 -160
  426. package/render/neutral.js +23 -0
  427. package/render/occlusion.js +184 -0
  428. package/render/ownFrame.js +1 -1
  429. package/render/patches.js +34 -29
  430. package/render/postWebGL.js +11 -3
  431. package/render/probes.js +179 -122
  432. package/render/slots.js +4 -4
  433. package/render/terms.js +53 -101
  434. package/render/uniformDecl.js +1 -1
  435. package/types/core.d.ts +333 -296
  436. package/types/gameplay.d.ts +65 -26
  437. package/types/generated/core/Audio.d.ts +1 -1
  438. package/types/generated/core/DebugOverrides.d.ts +14 -6
  439. package/types/generated/core/Input.d.ts +9 -2
  440. package/types/generated/core/page.d.ts +9 -2
  441. package/types/generated/modules/grid/Layer.d.ts +8 -0
  442. package/types/generated/modules/grid/index.d.ts +29 -5
  443. package/types/generated/modules/particles/Particles.d.ts +13 -6
  444. package/types/generated/modules/sky/Sky.d.ts +85 -18
  445. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  446. package/types/generated/modules/water/Water.d.ts +50 -3
  447. package/types/generated/modules/weather/Weather.d.ts +33 -3
  448. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  449. package/types/generated/modules/world/World.d.ts +2 -2
  450. package/types/generated/render/PostFX.d.ts +53 -10
  451. package/types/generated/render/lighting.d.ts +29 -0
  452. package/types/generated/render/materials.d.ts +19 -44
  453. package/types/generated/render/occlusion.d.ts +13 -0
  454. package/types/physics.d.ts +5 -3
  455. package/types/tsl.d.ts +8 -0
  456. package/types/world.d.ts +376 -57
  457. package/ui/Focus.js +12 -2
  458. package/ui/LoadingScreen.js +2 -2
  459. package/ui/Parts.js +8 -4
  460. package/ui/UI.js +10 -10
  461. package/ui/cursor.js +1 -1
  462. package/ui/theme.js +33 -27
  463. package/ui/touchPart.js +1 -1
  464. package/core/look/coreParts.js +0 -219
  465. package/core/look/part.js +0 -253
  466. package/core/look/points.js +0 -255
  467. package/core/look/report.js +0 -96
  468. package/core/look/shadowPart.js +0 -63
  469. package/core/look/state.js +0 -45
  470. package/core/look/write.js +0 -70
  471. package/core/styleParts.js +0 -114
  472. package/docs/api/style.md +0 -136
  473. package/docs/api/terrainLook.md +0 -10
  474. package/docs/api/vegetationLook.md +0 -10
  475. package/docs/api/weatherLook.md +0 -10
  476. package/docs/recipes/09-style.md +0 -218
  477. package/docs/recipes/35-style-from-reference.md +0 -153
  478. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  479. package/docs/recipes/38-environment-look-hooks.md +0 -99
  480. package/docs/recipes/41-thing-registry.md +0 -97
  481. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  482. package/docs/recipes/48-make-material.md +0 -75
  483. package/docs/recipes/52-look.md +0 -282
  484. package/examples/action/look.js +0 -5
  485. package/examples/sheepisland/style/index.js +0 -79
  486. package/examples/styletest/look.js +0 -11
  487. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  488. package/examples/webgpu-tsl/tslScene.js +0 -75
  489. package/examples/world/style/index.js +0 -61
  490. package/examples/world/style/plugins/10-bloom.js +0 -5
  491. package/modules/sky/cascades.js +0 -186
  492. package/modules/sky/cascades.tsl.js +0 -82
  493. package/modules/sky/look.js +0 -54
  494. package/modules/sky/lookFog.js +0 -76
  495. package/modules/sky/lookShadow.js +0 -62
  496. package/modules/sky/lookSky.js +0 -169
  497. package/modules/sky/shadow.js +0 -98
  498. package/modules/terrain/look.js +0 -83
  499. package/modules/terrain/lookGround.js +0 -66
  500. package/modules/vegetation/look.js +0 -119
  501. package/modules/vegetation/lookWind.js +0 -98
  502. package/modules/water/look.js +0 -91
  503. package/modules/water/surfaceDefaults.js +0 -3
  504. package/modules/weather/look.js +0 -74
  505. package/modules/weather/weatherLook.js +0 -135
  506. package/render/lookGlow.js +0 -139
  507. package/render/lookSurface.js +0 -224
  508. package/render/postLook.js +0 -164
  509. package/render/surface.js +0 -105
  510. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  511. package/types/style.d.ts +0 -671
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';
@@ -29,6 +28,7 @@ import type { DebugOverrides } from './generated/core/DebugOverrides';
29
28
  import type { Jobs } from './generated/core/Jobs';
30
29
  import type { Random } from './generated/core/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
34
  Particles, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
@@ -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
  */
@@ -190,6 +190,8 @@ export interface EventMap extends GameEvents {
190
190
  'music:stinger': [{ name: string }];
191
191
  /** Scenario parameters were applied (URL parameters or engine.applyState) */
192
192
  'state:applied': [StateParams];
193
+ /** A scenario (at, pos) moved the player: a camera or view that eases jumps there */
194
+ 'state:placed': [{ x: number; z: number }];
193
195
  /** A one-shot action of the animation state machine finished */
194
196
  'anim:end': [{ root: Object3D; state: string }];
195
197
  /** A record was added to world */
@@ -214,7 +216,7 @@ export interface EventMap extends GameEvents {
214
216
  'net:result': [{ seq: number; name: string; ok: boolean; code: string | null; value?: any; tick: number }];
215
217
  /** A gameplay error in development / testing; gameplay is frozen (error severity levels, see engine.error) */
216
218
  'engine:error': [EngineError];
217
- /** A look or ui module errored and was disabled (the game continues) */
219
+ /** A picture or ui module errored and was disabled (the game continues) */
218
220
  'module:disabled': [{ name: string; message: string }];
219
221
  /** A character boarded a vehicle */
220
222
  'vehicle:enter': [{ character: Character; vehicle: Rideable }];
@@ -261,33 +263,78 @@ export interface EngineUniforms {
261
263
  uTime: { value: number };
262
264
  /** Wind strength multiplier (weather) */
263
265
  uWind: { value: number };
264
- /** Sway frequency multiplier (style.wind.frequency) */
266
+ /** Sway frequency multiplier */
265
267
  uWindFreq: { value: number };
268
+ /** Sway amplitude multiplier: every wind patch's amplitude is scaled by it */
269
+ uWindAmp: { value: number };
266
270
  /** Cloud cover 0-1 (weather) */
267
271
  uCloud: { value: number };
268
- /** Darkest cloud shadow 0-1 (style.clouds.shadow; 0 = none) */
272
+ /** Rain amount 0-1 (weather state, every frame): a signal for the game's own wet surfaces */
273
+ uRain: { value: number };
274
+ /** Snow amount 0-1 (weather state, every frame) */
275
+ uSnow: { value: number };
276
+ /** Weather's light multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its own lights by it */
277
+ uWeatherLight: { value: number };
278
+ /** Weather's fog multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its fog distance by it */
279
+ uWeatherFog: { value: number };
280
+ /** 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 */
281
+ uViewDistance: { value: number };
282
+ /** Darkest cloud shadow 0-1 (0 = none) */
269
283
  uCloudShadow: { value: number };
270
- /** Cloud size: smaller = bigger clouds (style.clouds.scale) */
284
+ /** Cloud size: smaller = bigger clouds */
271
285
  uCloudScale: { value: number };
272
- /** Cloud drift per second (style.clouds.speed) */
286
+ /** Cloud drift per second */
273
287
  uCloudSpeed: { value: Vector2 };
274
288
  /** Unit vector toward the sun (sky, every frame); share the object in your own sky: mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir */
275
289
  uSunDir: { value: Vector3 };
290
+ /** Sun color now, from the sky's keyframes (white with no sky): what a game's own sun takes. Linear, like every THREE.Color */
291
+ uSunColor: { value: Color };
276
292
  /** 0 at night .. 1 at noon (sky, the sun it draws) */
277
293
  uDaylight: { value: number };
294
+ /** 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 */
295
+ uNight: { value: number };
278
296
  /** Time of day 0-1 the sky draws (calendar time, or the sky's fixed time) */
279
297
  uTimeOfDay: { value: number };
280
- /** Zenith color the sky draws this frame (keyframes, look.sky top, weather tint, lightning); linear, like every THREE.Color */
298
+ /** Zenith color the sky draws this frame (keyframes, engine.sky.top, weather tint, lightning); linear, like every THREE.Color */
281
299
  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 */
300
+ /** Horizon color the sky draws this frame (or the backdrop color). Read it for a shader that should meet the sky */
283
301
  uSkyHorizon: { value: Color };
302
+ /** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below */
303
+ uSunSize: { value: number };
304
+ uSunGlow: { value: number };
305
+ /** Sun disk brightness (sky({ sunBrightness })) */
306
+ uSunPower: { value: number };
307
+ /** Moon disk sharpness (larger = smaller) */
308
+ uMoonSize: { value: number };
309
+ /** Moon disk brightness (sky({ moonBrightness })) */
310
+ uMoonPower: { value: number };
311
+ uMoonColor: { value: Color };
312
+ /** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) */
313
+ uStars: { value: number };
314
+ /** Star grid resolution: larger = smaller, more numerous stars */
315
+ uStarScale: { value: number };
316
+ /** Horizon-to-zenith gradient exponent (sky({ gradientCurve })) */
317
+ uCurve: { value: number };
318
+ /** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's uCloud */
319
+ uCloudCover: { value: number };
320
+ /** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } })); uCloudScale is the cloud shadows' */
321
+ uSkyCloudScale: { value: number };
322
+ /** Dome cloud drift [x, z] per second; uCloudSpeed is the cloud shadows' */
323
+ uSkyCloudSpeed: { value: Vector2 };
324
+ uCloudOpacity: { value: number };
325
+ /** Dome cloud edge softness */
326
+ uCloudSoft: { value: number };
327
+ /** Lit side of the dome's clouds */
328
+ uCloudColor: { value: Color };
329
+ /** Shaded side of the dome's clouds */
330
+ uCloudShade: { value: Color };
284
331
  /** Season tint of foliage (sky, by the calendar's season) */
285
332
  uFoliageTint: { value: Color };
286
333
  /** Season tint of the ground (sky, by the calendar's season) */
287
334
  uGroundTint: { value: Color };
288
335
  uFoliageMix: { value: number };
289
336
  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 */
337
+ /** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in */
291
338
  uCover: { value: Vector2 };
292
339
  }
293
340
 
@@ -427,7 +474,7 @@ export interface AssetManifest {
427
474
  * like a file: audio.sfx(name), audio.sounds rules (src / variants), music and ambience. Example: sounds: { step: '/sfx/step.ogg', ding: dingSynth }
428
475
  */
429
476
  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 */
477
+ /** Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). ui.fonts lists the names the UI uses */
431
478
  fonts?: Record<string, string | FontAssetEntry>;
432
479
  }
433
480
  /** One font of an asset pack: the file plus the FontFace descriptors (family defaults to the asset name) */
@@ -436,9 +483,9 @@ export interface FontAssetEntry {
436
483
  /** CSS font-family it registers (default: the asset name); several entries may share one family with different weight / style */
437
484
  family?: string;
438
485
  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) */
486
+ /** start() stops if it fails (otherwise text falls back to the next family of ui.theme.font) */
440
487
  critical?: boolean;
441
- /** Load at start() even if style.ui.fonts does not name it */
488
+ /** Load at start() even if ui.fonts does not name it */
442
489
  preload?: boolean;
443
490
  }
444
491
 
@@ -460,7 +507,7 @@ export interface Assets {
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>;
@@ -502,6 +549,12 @@ export interface Assets {
502
549
  forget(obj: Object3D): void;
503
550
  /** Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20 */
504
551
  cacheMinMs: number;
552
+ /**
553
+ * 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
554
+ * 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.
555
+ * @example engine.assets.palette = { leaf: 0xd98a3a, bark: 0x6b4a30 };
556
+ */
557
+ palette: Record<string, any>;
505
558
  /** Geometry and materials shared by model copies (engine.remove does not release them, use release) */
506
559
  shared: WeakSet<object>;
507
560
  /** Current GPU memory usage (number of geometries and textures) */
@@ -531,7 +584,7 @@ export interface Assets {
531
584
  export interface AssetReport {
532
585
  name: string | null; url: string | null; fromFile: boolean;
533
586
  counts: Record<string, number>;
534
- materials: { name: string; type: string; maps: Record<string, any>; flatShading: boolean; vertexColors: boolean; madeByStyle: boolean }[];
587
+ materials: { name: string; type: string; maps: Record<string, any>; flatShading: boolean; vertexColors: boolean; madeByEngine: boolean }[];
535
588
  textures: any[]; clips: { name: string; seconds: number }[]; colliders: any[]; templates: any[];
536
589
  issues: { severity: 'warn' | 'info'; code: string; msg: string }[];
537
590
  }
@@ -663,7 +716,7 @@ export interface ContentAudio {
663
716
  music?: { tracks?: Record<string, import('./gameplay').MusicTrack>; rules?: import('./gameplay').MusicRule[] };
664
717
  footsteps?: Record<string, string>;
665
718
  }
666
- /** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). Not part of a style */
719
+ /** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). */
667
720
  export interface AudioConfig {
668
721
  /** Sound name -> play rule: an asset sound name / path, variants, or SoundDef */
669
722
  sounds?: Record<string, SoundSource>;
@@ -744,8 +797,60 @@ export interface UITitleItem {
744
797
  label: string | ((engine: Engine) => string);
745
798
  run(engine: Engine): any;
746
799
  }
800
+ /** Replaces a window's inner HTML (createEngine({ ui: { templates } }), engine.ui.templates) */
801
+ export type UITemplate = (data: any, tools: { esc: (s: any) => string; t: (key: string, params?: Record<string, any>) => string; icon?: (def: any) => string }) => string;
802
+ /** The CSS values of every default UI part: each key becomes the variable --threedog-<key> on engine.uiRoot */
803
+ export interface UITheme {
804
+ /** Background color */
805
+ bg?: string;
806
+ /** Text color */
807
+ fg?: string;
808
+ /** Secondary text color */
809
+ muted?: string;
810
+ /** Accent color */
811
+ accent?: string;
812
+ /** Color for good news such as "done" */
813
+ good?: string;
814
+ /** Divider color */
815
+ line?: string;
816
+ /** Font (CSS font-family) */
817
+ font?: string;
818
+ /** Corner radius of windows and the dialogue box (CSS, e.g. '12px') */
819
+ radius?: string;
820
+ /** Corner radius of small things: buttons, prompts, toasts, bubbles, HUD counters (CSS, default '8px') */
821
+ radiusSmall?: string;
822
+ /** Loading screen background */
823
+ loadingBg?: string;
824
+ /** Window shadow (CSS) */
825
+ shadow?: string;
826
+ /** Shadow of small things: speech bubbles, objective marker labels (CSS) */
827
+ shadowSmall?: string;
828
+ /** Fade color for scene transitions (CSS), default '#000' */
829
+ fadeBg?: string;
830
+ /** Background / text / accent of objective markers, counters and progress bars (CSS); default: follow bg, fg and accent */
831
+ hudBg?: string;
832
+ hudFg?: string;
833
+ hudAccent?: string;
834
+ /** Other CSS variables (become --threedog-name) */
835
+ [cssVar: string]: string | number | undefined;
836
+ }
837
+ /** createEngine({ ui }): the look of the default parts (theme, css, fonts, templates); every other key is a part name */
838
+ export interface UIOptions {
839
+ /** CSS values of every default part */
840
+ theme?: UITheme;
841
+ /** Extra CSS, placed after every default (overrides .threedog-* classes) */
842
+ css?: string;
843
+ /** Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in theme.font: '"pixel", system-ui' */
844
+ fonts?: string[];
845
+ /** Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar… */
846
+ templates?: Record<string, UITemplate>;
847
+ /** Part name → false (off), true (default), options, or your own part */
848
+ [part: string]: UIPartValue | UITheme | string | string[] | Record<string, UITemplate> | undefined;
849
+ }
747
850
  /** 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
851
  export interface UIParts {
852
+ /** Window content by name: a function here replaces that window's default HTML, read each time it draws */
853
+ templates: Record<string, UITemplate>;
749
854
  /** Declare a part and its default (engine and modules; games use set) */
750
855
  define(name: string, factory: UIPartFactory, def?: UIPartDef): void;
751
856
  /**
@@ -778,6 +883,9 @@ export interface UIParts {
778
883
  // Ground interface
779
884
  // ======================================================================
780
885
 
886
+ /** Conventional names for the picture values only one writer may hold (core/pictureSlots.js), taken with provides like any other slot */
887
+ export type PictureSlot = 'sky' | 'fog' | 'tone' | 'environment' | 'background' | 'sun';
888
+
781
889
  /** Ground: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0) */
782
890
  export interface Ground {
783
891
  /**
@@ -802,7 +910,7 @@ export interface Ground {
802
910
  forEachCollider?(x: number, z: number, range: number, fn: (cx: number, cz: number, r: number) => void): void;
803
911
  /** Optional: chunk edge length (meters) */
804
912
  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) */
913
+ /** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) */
806
914
  viewRange?(): number;
807
915
  /** Optional: collision data of a chunk (used by the physics module) */
808
916
  chunkCollision?(cx: number, cz: number): any;
@@ -847,7 +955,7 @@ export interface ModuleCtx {
847
955
  }
848
956
 
849
957
  /** What a module may own (ModuleDef.type; core/moduleTypes.js) */
850
- export type ModuleType = 'world' | 'look' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
958
+ export type ModuleType = 'world' | 'picture' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
851
959
 
852
960
  /**
853
961
  * A module (the argument of engine.use). The name is the property name on the engine once installed.
@@ -857,7 +965,7 @@ export interface ModuleDef<Api = any> {
857
965
  /** Module name; after install, access the object returned by install through engine[name] */
858
966
  name: string;
859
967
  /**
860
- * What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'look' what is seen and heard (changes no
968
+ * What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'picture' what is seen and heard (changes no
861
969
  * 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
970
  * | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Breaking a rule throws in dev with the fix.
863
971
  */
@@ -872,8 +980,9 @@ export interface ModuleDef<Api = any> {
872
980
  /**
873
981
  * Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep
874
982
  * working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
983
+ * Picture values only one writer may hold have conventional names (PictureSlot, PICTURE_SLOTS; recipes/62-picture-code.md "Picture parts").
875
984
  */
876
- provides?: string[];
985
+ provides?: (PictureSlot | (string & {}))[];
877
986
  /**
878
987
  * Optional dependencies (modules the code uses as e.xxx?. or guards with if (e.xxx); rule R16 requires listing them all).
879
988
  * 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 +1003,7 @@ export interface ModuleDef<Api = any> {
894
1003
  after?: string[];
895
1004
  /**
896
1005
  * 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
1006
+ * 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
1007
  * start() goes on. Only start() reads it; a critical module installed after start() is reported like any other
899
1008
  * @example engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })
900
1009
  */
@@ -933,8 +1042,8 @@ export interface ModuleDef<Api = any> {
933
1042
  counts?(e: Engine): number | Record<string, number>;
934
1043
  /** Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) } */
935
1044
  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>;
1045
+ /** 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 */
1046
+ applyState?(e: Engine, params: StateParams): void | PositionLike | Promise<void>;
938
1047
  /**
939
1048
  * Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers,
940
1049
  * Audio nodes you connected yourself.
@@ -961,10 +1070,7 @@ export interface EngineOptions {
961
1070
  * working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
962
1071
  * Every fallback prints one '[threedog] WebGPU unavailable (...)' line and shows in describe().renderer */
963
1072
  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) */
1073
+ /** 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
1074
  antialias?: boolean;
969
1075
  /** 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
1076
  pixelRatio?: number;
@@ -973,10 +1079,12 @@ export interface EngineOptions {
973
1079
  /** Target frame rate for automatic resolution lowering, default 55 */
974
1080
  targetFps?: number;
975
1081
  /**
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.
1082
+ * 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
1083
+ * default parts (theme, css, fonts, templates).
977
1084
  * @example createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })
1085
+ * @example createEngine({ canvas, ui: { theme: { bg: '#1c140e', accent: '#e8a13a' }, css: '.threedog-prompt{font-size:16px}' } })
978
1086
  */
979
- ui?: Record<string, UIPartValue>;
1087
+ ui?: UIOptions;
980
1088
  /** Volume of each channel, 0–1 */
981
1089
  audio?: AudioConfig;
982
1090
  /** Camera field of view (degrees), default 55 */
@@ -1029,7 +1137,7 @@ export interface EngineOptions {
1029
1137
  threads?: 'auto' | number | false;
1030
1138
  /** Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page) */
1031
1139
  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 */
1140
+ /** 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
1141
  lights?: boolean;
1034
1142
  /** 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 } */
1035
1143
  batching?: false | BatchingOptions;
@@ -1104,7 +1212,7 @@ export interface ThingExplanation {
1104
1212
  /** at: 'content/props.js:14' (null in release builds and for code without a file) */
1105
1213
  definition: { at: string | null; template: string | null; templateAt: string | null; level?: string; node?: string; spawned?: boolean; [k: string]: any };
1106
1214
  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 })[];
1215
+ materials: ({ role: string | null; name: string | null; from: 'engine' | 'game'; type: string; color: string | null; mesh: string | null } | { more: number })[];
1108
1216
  state: { position?: number[]; visible?: boolean; scale?: number[]; [k: string]: any };
1109
1217
  rules: { height?: number; blocksMovement?: any; pickable?: boolean; interact?: any; [k: string]: any };
1110
1218
  ops: { op: string; desc: string | null; args: any }[];
@@ -1146,7 +1254,7 @@ export interface HitThing {
1146
1254
  phase?: 'setup' | 'play';
1147
1255
  op?: string | null;
1148
1256
  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 */
1257
+ /** how much a save keeps (recipe 40): record = world save; code = thing.set / thing.remove overrides; session = nothing; engine = its module's business */
1150
1258
  saved?: 'record' | 'code' | 'session' | 'engine';
1151
1259
  /** what a save keeps / loses, in words */
1152
1260
  keeps?: string[];
@@ -1274,6 +1382,8 @@ export interface StateParams {
1274
1382
  weather?: string;
1275
1383
  /** Player position: 'x,z' or a position (sets the focus when there is no player) */
1276
1384
  pos?: string | PositionLike;
1385
+ /** 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 */
1386
+ at?: string;
1277
1387
  /** Which save slot to load */
1278
1388
  save?: string;
1279
1389
  /** How many seconds to advance (real seconds: fixed-step seconds, no scale) */
@@ -1284,6 +1394,8 @@ export interface StateParams {
1284
1394
  view?: string;
1285
1395
  /** 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
1396
  play?: string | boolean;
1397
+ /** 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 */
1398
+ fresh?: string | boolean;
1287
1399
  }
1288
1400
 
1289
1401
  /** A claim on something only its owner releases (pause, freeze, takeCamera, views) */
@@ -1302,225 +1414,121 @@ export interface CameraOverride {
1302
1414
  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 }
1303
1415
 
1304
1416
  // ======================================================================
1305
- // Look parts engine.look.<part> (recipes/52-look.md)
1417
+ // Shadows: engine.shadows (recipes/45-cascaded-shadows.md)
1306
1418
  // ======================================================================
1307
1419
 
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> {
1312
- /**
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);
1315
- */
1316
- include<M extends import('three').Material>(material: M): M;
1317
- }
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 {
1320
- /**
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 });
1326
- */
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 };
1420
+ /** engine.shadows.cascades options (recipes/45) */
1421
+ export interface ShadowCascadeOptions {
1422
+ /** Shadow maps along the view, 1-4 (default 3; 1 = the plain single map) */
1423
+ count?: number;
1424
+ /** Meters from the camera they cover (default 120) */
1425
+ maxFar?: number;
1426
+ /** Where the borders fall (default 'practical') */
1427
+ split?: 'practical' | 'uniform' | 'logarithmic' | ((count: number, near: number, far: number, out: number[]) => void);
1428
+ /** Cross-fade at the borders (default true) */
1429
+ fade?: boolean;
1430
+ /** Meters behind each cascade box toward the light still caught as casters (default 100) */
1431
+ lightMargin?: number;
1432
+ /** On engine.tier 'low': { count } (default 1, one map) */
1433
+ low?: { count: number };
1329
1434
  }
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>>> {
1332
- /**
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'] });
1336
- */
1337
- add(name: string, patch: import('./generated/render/patches').ShaderPatch | Record<string, any>, opts?: { roles?: string[]; owner?: string }): LookHandle;
1338
- /**
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 });
1345
- */
1346
- glow(match: string | import('three').Material | ((material: import('three').Material) => boolean), opts: { night: number; day?: number; dusk?: number; owner?: string }): LookHandle;
1347
- /**
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
1353
- */
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;
1435
+ /** What engine.shadows.cascades returns */
1436
+ export interface ShadowCascades {
1437
+ /** The game's light it was given */
1438
+ readonly light: import('three').DirectionalLight;
1439
+ /** three's CSM object (the shadow node on WebGPURenderer); null while there is one map */
1440
+ readonly csm: any;
1441
+ /** Change options (a rebuild recompiles lit materials: a settings screen, not per frame) */
1442
+ set(options: ShadowCascadeOptions): void;
1443
+ /** Back to one plain shadow map: the light's position, target and shadow box as the game left them */
1444
+ remove(): void;
1374
1445
  }
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;
1446
+ /** engine.shadows.box options */
1447
+ export interface ShadowBoxOptions {
1448
+ /** What the box centers on: 'focus' (engine.focus, default) | 'camera' | an Object3D | () => Vector3 | false (it stays on the light's target) */
1449
+ follow?: 'focus' | 'camera' | import('three').Object3D | (() => import('three').Vector3) | false;
1450
+ /** Half size of the box in meters; left out: the light's own shadow camera stays as it is */
1451
+ extent?: number;
1452
+ /** Center snap grid in meters (default 0.5), or 'texel': one shadow pixel */
1453
+ snap?: number | 'texel';
1454
+ /** Meters the center is shifted in front of the view, default 0 */
1455
+ ahead?: number;
1409
1456
  }
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 */
1457
+ /** What engine.shadows.box returns */
1458
+ export interface ShadowBox {
1459
+ set(options: ShadowBoxOptions): void;
1460
+ /** Stop following: the light's position, target and shadow camera come back */
1443
1461
  remove(): void;
1444
1462
  }
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 };
1463
+ /** What engine.shadows.budget returns */
1464
+ export interface ShadowBudget {
1465
+ set(options: { every?: number }): void;
1466
+ /** Redraw this light's map on the next frame */
1467
+ redraw(): void;
1468
+ /** light.shadow.autoUpdate as it was */
1469
+ remove(): void;
1462
1470
  }
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);
1471
+ /** A game's own term: a patch, in place of the engine's on every material that carries it */
1472
+ export interface TermSpec {
1473
+ /** Slot code for WebGLRenderer */
1474
+ glsl?: string;
1475
+ /** (ctx) => node for WebGPURenderer */
1476
+ tsl?: any;
1477
+ uniforms?: Record<string, any>;
1478
+ /** Extra declarations for the glsl */
1479
+ pars?: string;
1480
+ /** Default 'lighting' for the cloud shadow, 'color' for the season tint */
1481
+ slot?: string;
1467
1482
  }
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;
1483
+ /** engine.terms */
1484
+ export interface Terms {
1485
+ /**
1486
+ * 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
1487
+ * all. uCloud*, uTime and threedogCloudShadow(worldPos) stay in scope. remove() gives the engine's back.
1488
+ * @example const mine = engine.terms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= 0.5;', tsl: c => ({ directDiffuse: c.directDiffuse.mul(0.5) }) }); mine.remove();
1489
+ */
1490
+ cloudShadow(spec: TermSpec | false): { remove(): void };
1491
+ /**
1492
+ * 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
1493
+ * takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix, uCover and threedogSeason(color, kind) stay in scope. remove() gives the engine's back.
1494
+ * @example const mine = engine.terms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uCover.y);', tsl: c => c.color })); mine.remove();
1495
+ */
1496
+ season(spec: TermSpec | ((kind: 'foliage' | 'ground') => TermSpec) | false): { remove(): void };
1475
1497
  }
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;
1498
+ /** engine.view */
1499
+ export interface View {
1500
+ /**
1501
+ * 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
1502
+ * 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.
1503
+ * @example const mine = engine.view.manual('far'); engine.camera.far = 5000; mine.remove();
1504
+ */
1505
+ manual(key: 'far' | 'fov' | 'pixelRatio' | 'camera', on?: boolean): { remove(): void };
1484
1506
  }
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>);
1507
+ /** engine.shadows */
1508
+ export interface Shadows {
1509
+ /**
1510
+ * Master switch: renderer.shadowMap.enabled, never a light's castShadow; materials recompile once. A cutscene holds it with
1511
+ * engine.mod('shadows.enabled', { owner, layer: 'system', set: false }); the settings menu restricts it.
1512
+ */
1513
+ enabled: boolean;
1514
+ /** Cascaded shadows for a DirectionalLight (in engine.scene, castShadow on): sharp near the camera, wide far away; color, intensity and shadow values stay yours */
1515
+ cascades(light: import('three').DirectionalLight, options?: ShadowCascadeOptions): ShadowCascades;
1516
+ /** Keep a DirectionalLight's one shadow map around something that moves; the light keeps its direction */
1517
+ box(light: import('three').DirectionalLight, options?: ShadowBoxOptions): ShadowBox;
1518
+ /** Redraw one light's shadow map every N frames; other lights are not touched */
1519
+ budget(light: import('three').Light, options?: { every?: number }): ShadowBudget;
1520
+ /** 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) */
1521
+ mapSize(light: import('three').Light, width: number, height?: number): void;
1522
+ /**
1523
+ * Let cascaded shadows patch a lit ShaderMaterial of yours (lights: true, built from THREE.ShaderLib); built-in lit materials need nothing. Returns it.
1524
+ * @example engine.shadows.include(myShaderMaterial);
1525
+ */
1526
+ include<M extends import('three').Material>(material: M): M;
1527
+ /** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off */
1528
+ readonly csm: any;
1520
1529
  }
1521
-
1522
1530
  /**
1523
- * The engine. Created by createEngine({ canvas, style }); engine.use(module...) installs modules, engine.start() starts it.
1531
+ * The engine. Created by createEngine({ canvas }); engine.use(module...) installs modules, engine.start() starts it.
1524
1532
  * Installed modules hang on the engine (engine.terrain, engine.sky...); modules not installed are undefined, check with engine.xxx?.method().
1525
1533
  */
1526
1534
  export declare class Engine {
@@ -1529,8 +1537,6 @@ export declare class Engine {
1529
1537
  // ---------- Core objects ----------
1530
1538
  /** three.js (a game can also import { THREE } from 'threedog' directly) */
1531
1539
  THREE: typeof import('three');
1532
- /** Style */
1533
- style: Style;
1534
1540
  /** three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer) */
1535
1541
  renderer: EngineRenderer;
1536
1542
  /** 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,8 +1544,7 @@ export declare class Engine {
1538
1544
  /** three.js scene */
1539
1545
  scene: import('three').Scene;
1540
1546
  /**
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`
1547
+ * Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
1543
1548
  */
1544
1549
  lights: { sun: import('three').DirectionalLight; hemi: import('three').HemisphereLight };
1545
1550
  /** 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) */
@@ -1600,7 +1605,7 @@ export declare class Engine {
1600
1605
  * message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
1601
1606
  */
1602
1607
  readonly error: EngineError | null;
1603
- /** Names of look / ui modules disabled after an error (a module's type decides: look and ui fail soft) */
1608
+ /** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) */
1604
1609
  readonly disabledModules: Set<string>;
1605
1610
  /**
1606
1611
  * The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on
@@ -1633,8 +1638,8 @@ export declare class Engine {
1633
1638
  readonly loading: Loading;
1634
1639
  /** Post-processing: named effects in slots (add / get / enable / list) */
1635
1640
  post: PostFX;
1636
- /** Every look in one place: engine.look.<part>.set / patch / replace (recipes/52-look.md) */
1637
- look: Look;
1641
+ /** 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) */
1642
+ occlusion: Occlusion;
1638
1643
  /** UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md) */
1639
1644
  ui: UIParts;
1640
1645
  /** Automatic resolution state */
@@ -1658,7 +1663,7 @@ export declare class Engine {
1658
1663
  clock: Clock;
1659
1664
  /**
1660
1665
  * 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
1666
+ * @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
1667
  * @example engine.mod('time.player', { owner: 'haste', mul: 1.2, for: 5 }) // haste on the player
1663
1668
  * @example engine.mod('freeze', { owner: 'pause-menu' }) // pause menu (same as engine.freeze('pause-menu'))
1664
1669
  */
@@ -1678,7 +1683,7 @@ export declare class Engine {
1678
1683
  * @example engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })
1679
1684
  */
1680
1685
  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?) */
1686
+ /** Time channels: read seconds with time.now('real' | 'ambient' | 'calendar' | a channel such as 'world'), speeds with scale(ch, id?) */
1682
1687
  time: import('./gameplay').Time;
1683
1688
  /** Story flags and counters (autosaved) */
1684
1689
  vars: Vars;
@@ -1689,15 +1694,14 @@ export declare class Engine {
1689
1694
  /** Plug a folder's modules yourself (the vite preset does it): import.meta.glob('./plugins/*.js', { eager: true }) */
1690
1695
  add(files: Record<string, any>, o?: { order?: string[]; off?: string[] }): any;
1691
1696
  /**
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.
1697
+ * Unload: take everything a plugin plugged out again (file name without .js).
1698
+ * 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
1699
  */
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 }[];
1700
+ off(name: string): { off: string[]; note: string };
1701
+ /** Plug a switched-off plugin again (same place in the post chain) */
1702
+ on(name: string): { on: string[]; note: string };
1703
+ /** In plug order. replacedBy: the plugin that holds it out (export const replaces) */
1704
+ list(): { name: string; file: string; on: boolean; slots: string[]; replacedBy: string | null }[];
1701
1705
  };
1702
1706
  /** Ray registry (what engine.raycast hits) */
1703
1707
  rays: Rays;
@@ -1743,20 +1747,20 @@ export declare class Engine {
1743
1747
  // ---------- Modules (undefined when not installed) ----------
1744
1748
  /** Procedural terrain, data part (terrain() module: chunks, heights, edits, collision) */
1745
1749
  terrain?: Terrain;
1746
- /** Draws the terrain chunks (terrain()'s look module, slot 'terrain-look'; undefined when a game replaced it) */
1747
- terrainLook?: TerrainLook;
1750
+ /** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) */
1751
+ terrainDraw?: TerrainDraw;
1748
1752
  /** Vegetation (vegetation() module; grows on terrain or on any ground provider) */
1749
1753
  vegetation?: Vegetation;
1750
- /** Draws the plants (vegetation()'s look module, slot 'vegetation-look'; undefined when a game replaced it) */
1751
- vegetationLook?: VegetationLook;
1754
+ /** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) */
1755
+ vegetationDraw?: VegetationDraw;
1752
1756
  /** Sky dome, sun / moon light and fog drawn from the calendar's time (sky() module) */
1753
1757
  sky?: Sky;
1754
1758
  /** Time of day, day, seasons and clock-time timers (calendar() module); NPC schedules, content clock conditions and audio time rules read it */
1755
1759
  calendar?: Calendar;
1756
1760
  /** Weather state (weather() module): the table, current values, set / setAuto, save, events */
1757
1761
  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;
1762
+ /** Weather drawing (installed by weather(), needs sky): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky */
1763
+ weatherDraw?: WeatherDraw;
1760
1764
  /** Water surface (water() module) */
1761
1765
  water?: Water;
1762
1766
  /** 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 */
@@ -1821,6 +1825,12 @@ export declare class Engine {
1821
1825
  nav?: Nav;
1822
1826
  /** HLOD, merged distant geometry (hlod() module) @experimental */
1823
1827
  hlod?: Hlod;
1828
+ /** Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there */
1829
+ shadows: Shadows;
1830
+ /** The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there */
1831
+ view: View;
1832
+ /** Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there */
1833
+ terms: Terms;
1824
1834
  /** Light pool: many light sources, a fixed number of real lights (lightPool() module) */
1825
1835
  lightPool?: LightPool;
1826
1836
  /** Content loading (content() module) */
@@ -1837,11 +1847,15 @@ export declare class Engine {
1837
1847
  * @example engine.use(myInventory(), { replaces: 'inventory' })
1838
1848
  */
1839
1849
  use(...mods: (ModuleInput | { replaces: string | string[] })[]): this;
1850
+ /**
1851
+ * 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
1852
+ * leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }).
1853
+ * @example engine.unuse('rain');
1854
+ */
1855
+ unuse(name: string): void;
1840
1856
  /** Whether a module is installed */
1841
1857
  has(name: string): boolean;
1842
1858
 
1843
- /** Material by role from this engine's style: engine.makeMaterial('prop', { color: 0x8a5a36 }) */
1844
- makeMaterial(purpose?: string, params?: MaterialSpec): Material;
1845
1859
 
1846
1860
  // ---------- Ground ----------
1847
1861
  /** Set the ground (called by the terrain and level modules); missing parts fall back to flat ground */
@@ -1931,28 +1945,35 @@ export declare class Engine {
1931
1945
 
1932
1946
  // ---------- Light probes (render/probes.js) ----------
1933
1947
  /**
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.
1948
+ * 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
1949
+ * 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
1950
+ * scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so).
1951
+ * 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;
1952
+ * ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once:
1953
+ * bake at start-up, not mid-play.
1940
1954
  * @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
1955
+ * saveFile('probes.json', JSON.stringify(probes.toJSON()));
1942
1956
  */
1943
1957
  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>;
1958
+ include?: (o: Object3D) => boolean; owner?: string }): Promise<ProbeSet>;
1945
1959
  /**
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.
1960
+ * 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
1961
  * @example const probes = engine.loadProbes(await (await fetch('probes.json')).json());
1948
1962
  */
1949
- loadProbes(json: ProbeData, opts?: { follow?: ProbeFollow; owner?: string }): ProbeSet;
1963
+ loadProbes(json: ProbeData, opts?: { owner?: string }): ProbeSet;
1964
+ /**
1965
+ * 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
1966
+ * 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
1967
+ * 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.
1968
+ * A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what
1969
+ * was skipped, moved or doubled.
1970
+ * @example const light = await engine.loadLightmap('light/level.lightmap');
1971
+ */
1972
+ loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }): Promise<Lightmap>;
1950
1973
 
1951
1974
  // ---------- Settings ----------
1952
1975
  /** Render resolution */
1953
1976
  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
1977
 
1957
1978
  // ---------- Rays, scenarios ----------
1958
1979
  /** Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit) */
@@ -2031,7 +2052,7 @@ export declare class Engine {
2031
2052
  checkSave(opts?: { ignore?: string[] }): Promise<{ ok: boolean; diffs: { path: string; a: any; b: any }[] }>;
2032
2053
  /**
2033
2054
  * 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
2055
+ * "nearby" (meters, default 30). describe('picture') or describe({ only: ['picture', 'shared'] }) returns just those top-level sections (the whole object
2035
2056
  * is tens of KB on a big world); an unknown name comes back in unknownSections next to the list of sections.
2036
2057
  * 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
2058
  * returned handle's remove() cancels it.
@@ -2045,7 +2066,7 @@ export declare class Engine {
2045
2066
  };
2046
2067
  /**
2047
2068
  * 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.
2069
+ * 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
2070
  * { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data).
2050
2071
  * @example engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })
2051
2072
  */
@@ -2201,7 +2222,7 @@ export interface GameState {
2201
2222
  ready: boolean;
2202
2223
  /** Gameplay error in development / testing (gameplay is frozen), null when there is none */
2203
2224
  error: EngineError | null;
2204
- /** look / ui modules disabled after an error */
2225
+ /** picture / ui modules disabled after an error */
2205
2226
  disabledModules: string[];
2206
2227
  /** Modules that are initializing or failed ({ name: state }); absent when every module with an init is running (engine.moduleStates has all) */
2207
2228
  moduleStates?: Record<string, string>;
@@ -2252,14 +2273,15 @@ export interface GameState {
2252
2273
  /** Installed modules in install order: name, type, and the capabilities it provides / requires when it has any */
2253
2274
  modules: { name: string; type: ModuleType; provides?: string[]; requires?: string[] }[];
2254
2275
  /** 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[] }[];
2276
+ slots: { slot: 'scene' | 'post' | 'module' | 'light'; plugged: string; file: string; on: boolean; affects: string[] }[];
2256
2277
  /**
2257
2278
  * 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
2279
  * conflicts (two systems managing one object), orphans (saved ids no object has); atCapped when dev stopped taking stacks
2259
2280
  */
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 };
2281
+ 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 }[] };
2282
+ /** 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
2283
+ * (ShaderMaterial, onBeforeCompile) draw, and how renderer.compute() runs ('transform-feedback': no storage textures, atomics or workgroup memory). Null before start() */
2284
+ 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
2285
  /** Performance (fps/cpuMs are null while paused) */
2264
2286
  perf: {
2265
2287
  fps: number | null; cpuMs: number | null; drawCalls: number; triangles: number; pixelRatio: number;
@@ -2278,11 +2300,11 @@ export interface GameState {
2278
2300
  * Weather state: name (label is the display name), rain, snow, fog intensity 0–1, progress is the transition progress 0–1
2279
2301
  */
2280
2302
  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 };
2303
+ /** Weather drawing: rainVisible / snowVisible whether raindrops / snowflakes are drawn right now (object names weather-rain / weather-snow), flash 0–1 */
2304
+ weatherDraw?: { rainVisible: boolean; snowVisible: boolean; flash: number };
2283
2305
  /**
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
2306
+ * Every value the engine writes on its own (shadow box center, background, camera.far, pixel ratio, camera ...) and who writes it now (writer): 'engine',
2307
+ * 'manual:<who>' (engine.view.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
2308
  */
2287
2309
  owned?: Record<string, { part: string; key: string; writer: string; manual?: string }>;
2288
2310
  /** Content added by other modules */
@@ -2312,20 +2334,35 @@ export interface SkipOptions {
2312
2334
  save?: string | boolean;
2313
2335
  }
2314
2336
 
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[] }
2337
+ /** A loaded lightmap (engine.loadLightmap); describe().render.lightmap is its report */
2338
+ export interface Lightmap extends Handle {
2339
+ /** the map: a plain half-float DataTexture on uv1, set as material.lightMap */
2340
+ texture: import('three').DataTexture;
2341
+ /** file side length in pixels */
2342
+ size: number;
2343
+ /** meshes the bake left out, with why (instanced, skinned) */
2344
+ skipped: { name: string; why: string }[];
2345
+ /** baked meshes not found in the scene, or changed since the bake */
2346
+ missing: string[];
2347
+ /** takes the map off the meshes and frees it; the unwrapped geometry stays */
2348
+ remove(): void;
2349
+ }
2350
+ /** A probe file: what ProbeSet.toJSON() returns and engine.loadProbes reads (half: count x 27 half floats, base64; x fastest, then y, then z) */
2351
+ export interface ProbeData { format: 'threedog-probes'; version: 2; origin: [number, number, number]; step: [number, number, number]; counts: [number, number, number]; half: string }
2319
2352
  /** A baked or loaded grid of SH light probes (engine.bakeProbes / loadProbes); describe().render.probes lists the live ones */
2320
2353
  export interface ProbeSet extends Handle {
2321
2354
  /** number of probes */
2322
2355
  count: number;
2323
- /** probes per axis [x, y, z] (y is 1 in height mode) */
2356
+ /** probes per axis [x, y, z] (at least 2 each) */
2324
2357
  counts: [number, number, number];
2325
- /** the actual distance between neighbours per axis (<= spacing, so the grid ends on the bounds) */
2358
+ /** the actual distance between neighbours per axis (<= spacing, so the probes end on the bounds) */
2326
2359
  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;
2360
+ /** three's probe grid, a plain light in the scene: priority, visible and (WebGPU only: three's WebGL shader ignores it) intensity are yours */
2361
+ grid: import('three').Light & { isLightProbeGrid: true; priority: number; texture: import('three').Data3DTexture | null };
2362
+ /** the world box the grid lights: the probes plus half a step on every side */
2363
+ box: import('three').Box3;
2364
+ /** the probes' SH, 27 numbers each (half precision values) */
2365
+ sh: Float32Array;
2329
2366
  /** bake time in ms (null for a loaded set) */
2330
2367
  bakeMs: number | null;
2331
2368
  /** 'bake' | 'file' */
@@ -2336,6 +2373,6 @@ export interface ProbeSet extends Handle {
2336
2373
  point(i: number, out?: Vector3): Vector3;
2337
2374
  /** plain data for a file: engine.loadProbes(json) makes the same set */
2338
2375
  toJSON(): ProbeData;
2339
- /** takes the scene probe out and stops updating it; sample / toJSON still work */
2376
+ /** takes the grid out of the scene and frees its texture; sample / toJSON still work */
2340
2377
  remove(): void;
2341
2378
  }