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
@@ -1,65 +1,124 @@
1
+ // describe().picture: what three.js holds right now, read straight off the renderer and the scene. No record, no layers: whoever wrote a value
2
+ // (the game's picture code, a module, a console line), this is the value the frame is drawn with. .writers says which line wrote it (core/pictureWriters.js).
1
3
  // describe().render: renderer, post, lights and probes. Facts read from three.js and the post chain.
2
- // Who set a value lives in one place, describe().look: each `look` here is the path of that record ('look.tone.exposure'), and `writer` is copied
3
- // from that record, not a second answer worked out again (review r2 #11); 'engine' when no look part covers it. `writer` is the one "who set it"
4
- // field name across describe() (look, owned, render), so a tool never has to know which section says `by` and which says `writer`.
5
4
  // This is information only: the engine never warns when a game changes the renderer or lights.
5
+ import { NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, CustomToneMapping, AgXToneMapping, NeutralToneMapping } from 'three';
6
6
  import { SHADOW_TYPES } from './shadowTypes.js';
7
- import { describeLook } from './look/report.js';
8
7
  import { rv } from './math.js';
9
- import { toneName } from './look/coreParts.js';
10
8
  import { defineOwned } from './owned.js';
9
+ import { slotHolders } from './pictureSlots.js';
10
+ import { backendFacts } from '../render/backend.js';
11
11
 
12
12
  const shadowName = v => Object.keys(SHADOW_TYPES).find(k => SHADOW_TYPES[k].three === v) ?? String(v);
13
+ const TONE_NAMES = { [NoToneMapping]: 'none', [LinearToneMapping]: 'linear', [ReinhardToneMapping]: 'reinhard', [CineonToneMapping]: 'cineon',
14
+ [ACESFilmicToneMapping]: 'aces', [CustomToneMapping]: 'custom', [AgXToneMapping]: 'agx', [NeutralToneMapping]: 'neutral' };
15
+ const toneName = v => TONE_NAMES[v] ?? String(v);
16
+ const hex = c => `#${c.getHexString()}`;
17
+ /** What a build without the dev server says for every picture value (core/pictureWriters.js stays out of it) */
18
+ export const NO_WRITERS = 'not tracked: source lines are only known on the dev server (threedog dev or npm run dev); a bundled build has no file:line to give';
19
+
20
+ /** scene.fog as data @param {any} f */
21
+ const fogOf = f => (!f ? null : f.isFogExp2 ? { type: 'FogExp2', color: hex(f.color), density: f.density } : { type: 'Fog', color: hex(f.color), near: f.near, far: f.far });
22
+ /** scene.background as data: a Color by value, a texture by kind @param {any} s */
23
+ function backgroundOf(s) {
24
+ const b = s.background;
25
+ if (!b) return null;
26
+ return b.isColor ? { type: 'Color', color: hex(b) } : { type: b.isCubeTexture ? 'CubeTexture' : 'Texture', name: b.name || null, intensity: s.backgroundIntensity };
27
+ }
28
+ /** Whether three draws with this light: every parent visible and on a layer the camera sees (the test three's renderer makes) */
29
+ function lit(o, cam) {
30
+ if (!o.layers.test(cam.layers)) return false;
31
+ for (let p = o; p; p = p.parent) if (!p.visible) return false;
32
+ return true;
33
+ }
34
+ const lightOf = (l, cam) => ({ type: l.type, name: l.name, color: hex(l.color), ...(l.groundColor ? { groundColor: hex(l.groundColor) } : {}), intensity: l.intensity, castShadow: !!l.castShadow, visible: lit(l, cam) });
35
+
36
+ /**
37
+ * describe().picture: the values the frame is drawn with, read off the three.js objects, so a direct three.js write shows at once and at full precision.
38
+ * @param {any} e
39
+ * @returns {{ toneMapping: string, exposure: number, fog: any, environment: { present: boolean, intensity: number }, background: any, lights: any[], shadows: { enabled: boolean, type: string }, writers: any }}
40
+ */
41
+ export function describePicture(e) {
42
+ const r = e.renderer, s = e.scene, lights = /** @type {any[]} */ ([]);
43
+ s.traverse(o => { if (/** @type {any} */ (o).isLight && !(/** @type {any} */ (o).isLightProbeGrid)) lights.push(lightOf(o, e.camera)); }); // a probe grid has its own rows (probes)
44
+ return { toneMapping: toneName(r.toneMapping), exposure: r.toneMappingExposure, fog: fogOf(s.fog), environment: { present: !!s.environment, intensity: s.environmentIntensity },
45
+ background: backgroundOf(s), lights, shadows: { enabled: r.shadowMap.enabled, type: shadowName(r.shadowMap.type) }, slots: slotHolders(e), writers: e._picture?.list() ?? { tracked: false, note: NO_WRITERS } };
46
+ }
13
47
 
14
48
  /**
15
49
  * Record how the renderer was made.
16
50
  * @param {any} e
17
- * @param {{ owned: boolean }} o owned: false when the game passed its own renderer (then the style's tone mapping / exposure were not applied by the engine)
51
+ * @param {{ owned: boolean }} o owned: false when the game passed its own renderer
18
52
  */
19
53
  export function recordRender(e, { owned }) {
20
- // tone mapping is written once at creation (coreParts.js). Who writes it now is one owned record like every other look value (core/owned.js),
54
+ // who writes tone mapping now is one owned record like every other picture value (core/owned.js),
21
55
  // not a comparison against a remembered creation value here: a direct renderer.toneMapping write yields it ('three (engine yielded)'), quietly (once),
22
56
  // because that write is the documented way to change the curve. A game-supplied renderer (owned false) starts manual: the engine never wrote it
23
57
  e._oTone = defineOwned(e, { id: 'toneMapping', part: 'tone', key: 'toneMapping', read: () => e.renderer.toneMapping, objects: [e.renderer], once: true,
24
- write: v => { e.renderer.toneMapping = v; }, levels: { manual: "engine.look.tone.manual('toneMapping')" } });
58
+ write: v => { e.renderer.toneMapping = v; }, levels: { manual: 'engine.renderer.toneMapping = THREE.AgXToneMapping' } });
25
59
  if (owned) e._oTone.mark(); else e._oTone.manual(true, 'game renderer');
26
- // style vs engine only says which default the creation write used (the pack named a curve, or the baseline AgX)
27
- e._renderBase = { owned, toneBy: e.style?.toneMapping != null ? 'style' : 'engine' };
60
+ e._renderBase = { owned };
61
+ }
62
+
63
+ /**
64
+ * What the engine itself still puts on the picture right now, each with how to stop it: a value the game never wrote must be findable (plan 2026-11-04,
65
+ * section 2). What moves every frame is describe().owned; this is what stands with no game code asking.
66
+ * @param {any} e @returns {{ what: string, value: string, off: string }[]}
67
+ */
68
+ function engineDefaults(e) {
69
+ const r = e.renderer, s = e.scene, bg = s.background, rows = [];
70
+ if (bg && bg === e.baseBackground) rows.push({ what: 'scene.background', value: `#${bg.getHexString()}`, off: 'scene.background = your color or texture' });
71
+ for (const [name, l] of Object.entries(e.lights ?? {})) if (l.parent) rows.push({ what: `lights.${name}`, value: `${l.type} ${rv(l.intensity)}`, off: 'createEngine({ lights: false })' });
72
+ if (r.shadowMap.enabled) rows.push({ what: 'renderer.shadowMap', value: shadowName(r.shadowMap.type), off: 'renderer.shadowMap.enabled = false' });
73
+ // render/postWebGL.js direct(): only once the game has picked a tone curve, so a Color background agrees with the effect chain's OutputPass
74
+ if (r.toneMapping !== NoToneMapping && (bg?.isColor || bg == null) && !e.post?.active) rows.push({ what: 'background tone', value: 'drawn as a 1x1 tone-mapped texture during the render; scene.background itself is not changed', off: 'renderer.toneMapping = THREE.NoToneMapping' });
75
+ return rows;
28
76
  }
29
77
 
78
+ /** One row of backgroundOf / fogOf on a line: 'none', 'Color #aabbcc', 'Fog #aabbcc 10..80', 'FogExp2 #aabbcc 0.02' */
79
+ const sceneWord = x => (!x ? 'none' : [x.type, x.color, x.near != null ? `${rv(x.near)}..${rv(x.far)}` : x.density].filter(v => v != null).join(' '));
80
+
30
81
  /** The render section: structured data plus one compact text block (`text`) @param {any} e */
31
82
  export function describeRender(e) {
32
83
  const r = e.renderer, b = e._renderBase;
33
84
  if (!b) return undefined;
34
- const look = describeLook(e) ?? {};
35
- // { look, writer }: the record to read in describe().look and its writer; 'engine' (no look record) when no part covers it
36
- const who = (part, key) => { const row = look[part]?.[key]; return row ? { look: `look.${part}.${key}`, writer: row.writer } : { look: null, writer: 'engine' }; };
37
- e._oTone.check(); // a direct write since the last look turns the record to 'yielded' (quiet: no warning)
38
85
  // a post effect in the 'tone' slot replaces the tone-mapping stage (render/PostFX.js): then it, not renderer.toneMapping, makes the picture
39
86
  const toneFx = e.post?._list?.find(h => h.slot === 'tone' && h.enabled);
40
- const tone = toneFx ? { value: `post effect '${toneFx.name}' (tone slot)`, ...who('post', `${toneFx.name}.enabled`) }
41
- : { value: toneName(r.toneMapping), writer: e._oTone.on ? b.toneBy : 'game' };
42
- const exposure = { value: rv(r.toneMappingExposure), ...who('tone', 'exposure') }; // keyframes / a function: the value used this frame
43
- const shadows = { enabled: r.shadowMap.enabled, type: shadowName(r.shadowMap.type), ...who('shadow', 'type') };
44
- const post = (e.post?._list || []).map(h => ({ name: h.name, on: h.enabled, params: { ...h.params }, ...who('post', `${h.name}.enabled`),
45
- ...(e.post._offWhy?.[h.name] && !h.enabled ? { why: e.post._offWhy[h.name] } : {}) }));
87
+ // who decides an effect's switch: the point's writer, 'default' while nobody wrote it
88
+ const postWho = n => { const point = `post.${n}.enabled`; return { point, writer: e.stacks.get(point).row().writer }; };
89
+ const tone = toneFx ? { value: `post effect '${toneFx.name}' (tone slot)`, ...postWho(toneFx.name) }
90
+ : { value: toneName(r.toneMapping), writer: e._oTone.on ? 'three default' : 'game' };
91
+ const exposure = { value: rv(r.toneMappingExposure) };
92
+ const shadows = { enabled: r.shadowMap.enabled, type: shadowName(r.shadowMap.type) };
93
+ const post = (e.post?._list || []).map(h => { const held = e.post._held(h), facts = h._def.facts?.();
94
+ return { name: h.name, on: h.enabled, params: { ...h.params }, ...postWho(h.name), ...(held ? { held } : {}), ...(facts ? { facts } : {}) }; });
46
95
  const lights = Object.entries(e.lights || {}).filter(([, l]) => l.parent)
47
- .map(([name, l]) => ({ name, type: l.type, intensity: rv(l.intensity), source: 'engine-default', ...who('lights', `${name}.intensity`) }));
96
+ .map(([name, l]) => ({ name, type: l.type, intensity: rv(l.intensity), source: 'engine-default' }));
48
97
  // the game's own point / spot lights (core/gameLights.js): adopted like a lightPool light, listed with the line that added them
49
98
  for (const l of e._gameLights?.list() ?? []) lights.push({ name: l.name || l.type, type: l.type, intensity: rv(l.intensity), castShadow: l.castShadow,
50
99
  source: 'game', writer: 'game', at: e._things?.entryOf(l)?.[0]?.at ?? null, ...(e._gameLights.idled(l) ? { shadowIdled: true } : {}) });
100
+ const defaults = engineDefaults(e);
101
+ const by = x => (x.writer ? ` (${x.writer})` : '');
102
+ const antialias = e.post?._antialiasNow() ?? { samples: 0, replacedBy: null };
51
103
  const kv = x => Object.entries(x).map(([k, v]) => `${k}=${typeof v === 'number' ? rv(v) : v}`).join(' ');
52
104
  const srgb = r.outputColorSpace === 'srgb' ? '' : ' (WRONG: colors are encoded for srgb; color textures must be srgb, data maps linear, see assets.report)';
53
105
  let text = [
54
- `renderer: ${tone.value} (${tone.writer}) exposure ${exposure.value} (${exposure.writer}) shadows ${shadows.enabled ? shadows.type : 'off'} (${shadows.writer})${b.owned ? '' : ' [game-supplied renderer]'} output ${r.outputColorSpace}${srgb}`,
55
- `post: ${post.map(x => `${x.name}${x.on ? '' : x.why ? ' off (low-tier default)' : ' off'}${Object.keys(x.params).length ? `{${kv(x.params)}}` : ''} (${x.writer})`).join(', ') || 'none'}${e.post?.antialias ? ' + MSAA' : ''}`,
56
- `lights: ${lights.map(l => `${l.name} ${l.type} ${l.intensity} (${l.writer}${l.at ? ' ' + l.at : ''})`).join(', ')}`,
106
+ `renderer: ${tone.value}${by(tone)} exposure ${exposure.value}${by(exposure)} shadows ${shadows.enabled ? shadows.type : 'off'}${by(shadows)}${b.owned ? '' : ' [game-supplied renderer]'} output ${r.outputColorSpace}${srgb}`,
107
+ `post: ${post.map(x => `${x.name}${x.held ? ` held off: ${x.held}` : x.on ? '' : ' off'}${Object.keys(x.params).length ? `{${kv(x.params)}}` : ''} (${x.writer})`).join(', ') || 'none'}${antialias.samples ? ` + MSAA x${antialias.samples}` : antialias.replacedBy ? ` + ${antialias.replacedBy} in place of MSAA` : ''}`,
108
+ `lights: ${lights.map(l => `${l.name} ${l.type} ${l.intensity}${l.writer ? ` (${l.writer}${l.at ? ' ' + l.at : ''})` : ''}`).join(', ')}`,
109
+ `scene: background ${sceneWord(backgroundOf(e.scene))} fog ${sceneWord(fogOf(e.scene.fog))} environment ${e.scene.environment ? rv(e.scene.environmentIntensity) : 'none'}`,
110
+ `engine defaults on the picture: ${defaults.map(d => d.what).join(', ') || 'none'}`,
57
111
  ].join('\n');
58
- // probe sets (render/probes.js): how many, how dense, who made them and who writes the scene probe now
112
+ // probe sets (render/probes.js): how many, how dense, who made them, what they miss and what doubles them
59
113
  const probes = [...(e._probeSets ?? [])].map(s => s.info());
60
- if (probes.length) text += `\nprobes: ${probes.map(p => `${p.count} (${p.counts.join('x')}, step ${p.step.join('/')}) from ${p.source} by ${p.owner}, follow ${p.follow}${p.writer ? ` (${p.writer})` : ''}`).join('; ')}`;
114
+ if (probes.length) text += `
115
+ probes: ${probes.map(p => `${p.count} (${p.counts.join('x')}, step ${p.step.join('/')}) from ${p.source} by ${p.owner}`).join('; ')}`
116
+ + (probes[0].outside.count ? `
117
+ outside the probe grid (no probe light): ${probes[0].outside.count} lit object(s), ${probes[0].outside.names.join(', ')}` : '')
118
+ + (probes[0].doubled.length ? `
119
+ counted twice with the probes: ${probes[0].doubled.join(', ')}` : '');
61
120
  const dv0 = e.debug?.viewState?.(), dv = dv0 && dv0.mode !== 'off' ? dv0 : null;
62
- if (dv) text = `DEBUG VIEW "${dv.mode}" (by ${dv.owner}) is ON: ${dv.what}. This is NOT the real look; the debug view 'off' restores it.
121
+ if (dv) text = `DEBUG VIEW "${dv.mode}" (by ${dv.owner}) is ON: ${dv.what}. This is NOT the real picture; the debug view 'off' restores it.
63
122
  ` + text;
64
123
  // render scale: the canvas resolution against the display. auto: the adaptive resolution lowered it at some point (it raises it back when frames are fast)
65
124
  const dpr = (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1, cur = r.getPixelRatio(), ad = e.adaptive;
@@ -67,5 +126,22 @@ export function describeRender(e) {
67
126
  adaptive: !!ad?.on, floor: ad?.min ?? null, max: ad?.max ?? null };
68
127
  text += `
69
128
  render scale: ${scale.current} of device pixel ratio ${dpr}${scale.upscaled ? ' (picture is upscaled, softer than the screen)' : ''}${scale.autoLowered ? ` (auto-lowered by adaptive resolution, floor ${scale.floor}; adaptiveResolution: false turns it off)` : ''}`;
70
- return { debugView: dv, scale, toneMapping: tone, exposure, shadows, post, lights, probes, text };
129
+ // the lightmap (render/lightmap.js): what is baked, and what no longer matches the bake
130
+ const lightmap = e._lightmap?.info() ?? null;
131
+ if (lightmap) text += `\nlightmap: ${lightmap.meshes} mesh(es), ${lightmap.size} map from ${lightmap.file}`
132
+ + ['skipped', 'missing', 'moved', 'doubled', 'shared'].map(k => (lightmap[k].length ? `, ${k}: ${lightmap[k].slice(0, 3).map(x => x.name ?? x).join(', ')}` : '')).join('');
133
+ // occlusion culling (render/occlusion.js): what it skipped this frame, so a game can see whether it pays
134
+ const occlusion = e.occlusion?.enabled ? e.occlusion.stats : null;
135
+ if (occlusion) text += `\nocclusion: ${occlusion.hidden} of ${occlusion.watched} big things hidden, ${occlusion.trianglesSkipped} triangles skipped`;
136
+ return { debugView: dv, scale, toneMapping: tone, exposure, shadows, post, antialias, lights, defaults, probes, lightmap, occlusion, text };
137
+ }
138
+
139
+ /**
140
+ * Which renderer was asked for and which backend draws; reason = why not WebGPU (core/startup.js _startRenderer); the rest is what that backend can run.
141
+ * All null before start(): the facts need the started backend.
142
+ * @param {any} e
143
+ */
144
+ export function describeBackend(e) {
145
+ if (e._backend) return { ...e._backend, ...backendFacts(e.renderer) };
146
+ return { requested: e._backendWant.requested, backend: null, reason: null, gpu: null, tsl: null, glsl: null, compute: null };
71
147
  }
@@ -9,7 +9,7 @@ const STRINGS = {
9
9
  head: '[Game state] running {s} s{flags}',
10
10
  actions: 'Can do (engine.ops): {list}',
11
11
  error: '[Error, gameplay frozen] {where}: {message}', errorAt: ' ({at})',
12
- errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled look / ui modules (they threw): {list}',
12
+ errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}',
13
13
  paused: ', paused', headless: ', headless', notReady: ', still loading',
14
14
  waiting: 'Loading: {waiting} ({pending} pending, {done}/{total} done)', loadFailed: 'Load failed{blocked}: {list}', blocked: ' (start blocked)',
15
15
  loadWarn: 'Loaded with missing references: {list}',
@@ -44,7 +44,7 @@ const STRINGS = {
44
44
  noPath: 'describe() has no "{path}"; top-level keys: {keys}',
45
45
  none: 'none',
46
46
  state: { idle: 'standing', walk: 'walking', run: 'running', jump: 'jumping', fall: 'falling', swim: 'swimming' },
47
- kind: { npc: 'NPC', pickup: 'pickup', interactable: 'interactable', trigger: 'trigger' },
47
+ kind: { npc: 'NPC', pickup: 'pickup', interactable: 'interactable', noKey: 'no key bound, the player cannot use it', trigger: 'trigger' },
48
48
  dir: { N: 'north', NE: 'northeast', E: 'east', SE: 'southeast', S: 'south', SW: 'southwest', W: 'west', NW: 'northwest' },
49
49
  rel: { front: 'ahead', 'front-right': 'ahead right', right: 'right', 'back-right': 'behind right', back: 'behind', 'back-left': 'behind left', left: 'left',
50
50
  'front-left': 'ahead left' },
@@ -62,7 +62,7 @@ const n1 = v => (typeof v === 'number' ? r1(v) : v);
62
62
  const SHOWN = new Set(['nearbyRadius', 'ready', 'error', 'disabledModules', 'loading', 'time', 'player', 'camera', 'nearby', 'actions', 'ui', 'cutscene',
63
63
  'modules', 'perf', 'weather', 'render', 'threePatches']); // threePatches: page-wide, the same every call; describe() JSON carries it, the text stays short
64
64
  // engine bookkeeping in describe(): one count each in the summary, the content one describeText({ path }) away
65
- const TABLES = new Set(['holds', 'input', 'control', 'shared', 'wraps', 'slots', 'scene', 'owned', 'look', 'renderer']);
65
+ const TABLES = new Set(['holds', 'input', 'control', 'shared', 'wraps', 'slots', 'scene', 'owned', 'picture', 'renderer']);
66
66
  const argText = a => Object.entries(a || {}).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(',') : v}`).join(' ');
67
67
 
68
68
  /** One module's data in a line: scalars as k=v, arrays as k[n], objects as k{n keys} (nested data is one describeText({ path }) away) */
@@ -103,7 +103,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
103
103
  if (d.disabledModules?.length) L.push(fmt(STRINGS.disabled, { list: d.disabledModules.join(', ') }));
104
104
  if (t.clock) L.push(fmt(STRINGS.time, { clock: t.clock, day: t.day, season: t.season ? ', ' + tr('season', t.season) : '', dayNight: t.isDay ? STRINGS.day
105
105
  : STRINGS.night }));
106
- const w = d.weather, wl = d.weatherLook ?? {}; // weather state, and what of it is drawn (the look half)
106
+ const w = d.weather, wl = d.weatherDraw ?? {}; // weather state, and what of it is drawn (the drawing half)
107
107
  if (w) L.push(fmt(STRINGS.weather, { name: w.name, rain: n1(w.rain), snow: n1(w.snow), fog: n1(w.fog),
108
108
  changing: w.progress < 1 ? fmt(STRINGS.changing, { pct: Math.round(w.progress * 100) }) : '',
109
109
  shown: wl.rainVisible || wl.snowVisible ? fmt(STRINGS.weatherShown,
@@ -143,7 +143,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
143
143
  return L.join('\n');
144
144
  }
145
145
  // Summary order: the game's own describe.add sections first (what its author asked to see), then module lines, then the engine's bookkeeping
146
- // tables folded into one count line. Why: those tables (shared values, slots, owned properties, look parts...) took ~10 of the 30 lines and pushed
146
+ // tables folded into one count line. Why: those tables (shared values, slots, owned properties...) took ~10 of the 30 lines and pushed
147
147
  // the game's own sections past the cut. A table with something wrong in it (scene conflicts / orphans / unsaved) keeps its own line.
148
148
  const rest = Object.keys(d).filter(k => !SHOWN.has(k)), tables = [], mods = [];
149
149
  for (const k of rest.filter(k => game.includes(k))) L.push(fmt(STRINGS.extra, { name: k, json: summary(d[k]) }));
@@ -151,7 +151,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
151
151
  for (const k of rest.filter(k => TABLES.has(k))) {
152
152
  const v = d[k];
153
153
  if (k === 'scene' && v && ['conflicts', 'orphans', 'unsaved'].some(x => v[x]?.length)) L.push(fmt(STRINGS.extra, { name: k, json: summary(v) }));
154
- else if (v != null) tables.push(k === 'renderer' ? `renderer ${v.backend ?? v.requested}` : `${k} ${typeof v === 'object' ? Object.keys(v).length : v}`);
154
+ else if (v != null) tables.push(k === 'renderer' ? `renderer ${v.backend ?? v.requested}${v.reason ? ` (asked ${v.requested}: ${v.reason})` : ''}` : `${k} ${typeof v === 'object' ? Object.keys(v).length : v}`);
155
155
  }
156
156
  // the cut falls on the module lines only: the standard lines, the game's sections and the tables line always stay; the cut ones are named
157
157
  const tail = tables.length ? [fmt(STRINGS.tables, { list: tables.join(', ') })] : [], room = Math.max(0, maxLines - 1 - L.length - tail.length);
@@ -1,7 +1,7 @@
1
1
  // Stable error codes: errors the engine raises by name end their message with "[code]" and carry err.code / err.fix / err.docs (codedError in errorHints.js).
2
2
  // Plain data with no imports (node tools load it through threedog/error-hints). A code never changes meaning once shipped: tools and tests match on it.
3
3
 
4
- // Naming rule for a NEW code: `<area>-<problem>` in lowercase with hyphens (save-version, look-verb, unknown-name): the area first so the codes sort
4
+ // Naming rule for a NEW code: `<area>-<problem>` in lowercase with hyphens (save-version, unknown-name): the area first so the codes sort
5
5
  // and grep by subsystem. Codes already published keep their names even where they do not follow it (renaming would break the tools and tests that match them).
6
6
 
7
7
  /**
@@ -161,6 +161,10 @@ export const ERROR_CODES = {
161
161
  docs: ['recipes/58-input.md', 'api/input.md'],
162
162
  fix: "An action a module needs is read but no key is bound, so it never fires. Modules bind no keys: bind it with " +
163
163
  "engine.input.bind('action', ['KeyX']), createEngine({ bindings }) or a presets.bindings.* map." },
164
+ 'interaction-no-key': {
165
+ docs: ['recipes/63-third-person-start.md', 'recipes/58-input.md', 'api/interactions.md'],
166
+ fix: 'Interactions were added but their action has no key, so a player can never use them. Bind it in createEngine({ bindings }) or with ' +
167
+ 'engine.input.bind; any key works, and bind it to [] if the game really reaches them another way (a click on the prompt).' },
164
168
  'asset-cache': {
165
169
  docs: ['recipes/05-props-bake.md', 'api/assets.md'],
166
170
  fix: 'The dev model cache could not be used, so code-generated models are built from code. Run the game through its vite ' +
@@ -219,53 +223,50 @@ export const ERROR_CODES = {
219
223
  'open-world-camera': {
220
224
  docs: ['recipes/21-camera.md', 'api/openWorld.md'],
221
225
  fix: "openWorld() installs no camera on its own: pass camera: 'follow' | 'firstPerson' | 'rts' | 'fixed' | a camera module | false." },
222
- 'look-param': {
223
- docs: ['recipes/52-look.md'],
224
- fix: 'A look part was given a key it does not have, a value of the wrong type, or a spec without a default. engine.catalog("look.<part>").params lists every key, its default, why and how to turn it off.' },
225
- 'look-fn': {
226
- docs: ['recipes/52-look.md'],
227
- fix: 'A look value given as a function ({ time, weather, season, day, state, sky }) => number threw or returned something that is not a finite number. Guard what may not exist yet (state.boss?.dist ?? 100); until it returns a number the key keeps its last good value.' },
228
- 'look-verb': {
229
- docs: ['recipes/52-look.md'],
230
- fix: 'This look part does not support that verb (set / patch / replace), or the hook name is unknown. engine.catalog("look.<part>").verbs lists what it supports; the message names the verb to use instead.' },
226
+ 'lightpool-dusk': {
227
+ docs: ['api/lightPool.md', 'recipes/09-materials-lights-models.md'],
228
+ fix: 'A lightPool source has a wrong dusk value, or follows daylight while nothing tells day from night: install sky() or calendar(), or register the daylight measure.' },
229
+ 'engine-terms': {
230
+ docs: ['recipes/52-around-the-picture.md'],
231
+ fix: 'engine.terms was given a spec it cannot draw: a term is { glsl, tsl, uniforms?, pars?, slot? } with the form this renderer needs, or false for none.' },
231
232
  'engine-two-copies': {
232
233
  docs: ['THREE.md'],
233
234
  fix: "vite.config.js: resolve: { dedupe: ['threedog', 'three'] }. Two copies of threedog are loaded (the message names both paths); " +
234
235
  'each hooks THREE.Mesh.prototype for shadows, so keep one: `npm ls threedog`, and packs / tools list threedog as a peerDependency.' },
235
236
  'debug-override': {
236
- docs: ['recipes/41-thing-registry.md'],
237
+ docs: ['recipes/40-scene.md'],
237
238
  fix: "engine.debug.override(owner, target, patch): owner names who sets it (engine.debug.clear(owner) removes all of them), target is a thing id or Object3D, " +
238
- "patch is { visible?, material?: 'flat' | 'wire', apply? }. Overrides change only what the screen shows and are never saved." },
239
+ "patch is { visible?, material?: 'flat' | 'wire', apply? }; a three.js value: override(owner, object, key, value). Overrides change only what the screen shows and are never saved." },
239
240
  'plugin-shape': {
240
241
  docs: ['THREE.md', 'recipes/40-scene.md'],
241
242
  fix: 'A file in the plugins folder is plugged by what it exports: an Object3D, a three.js Pass, a post effect { name, create | node | fuse }, ' +
242
243
  'a Material, a ShaderPatch { slot, glsl }, a module { name, type, install }, or an array of these (default export, else every named export). ' +
243
244
  'A function is never a plugin (on either renderer): export what a factory returns (export default makeIt({ ... })), a node pass as { name, node }; threedog lib pull writes that line for library code. plugins.json names only files that exist.' },
244
245
  'thing-id': {
245
- docs: ['recipes/41-thing-registry.md'],
246
+ docs: ['recipes/40-scene.md'],
246
247
  fix: "Ids given to engine.add(obj, { id }) are non-empty strings without '#', unique across engine.add objects and world records. " +
247
248
  'engine.thing(id) takes such an id, a world record id, an object name or an Object3D; the message suggests the closest id.' },
248
249
  'thing-owned': {
249
- docs: ['recipes/41-thing-registry.md', 'recipes/18-world.md'],
250
+ docs: ['recipes/40-scene.md', 'recipes/18-world.md'],
250
251
  fix: "Two systems manage one object: a world model is placed by world every frame. Change the record (ops.run('thing.set', { id, " +
251
252
  "position }), world.set / world.move) instead of the model, and never engine.add a model world built." },
252
253
  'thing-unsaved': {
253
- docs: ['recipes/41-thing-registry.md'],
254
+ docs: ['recipes/40-scene.md'],
254
255
  fix: 'An object you expect to keep cannot be saved: it has no stable id or was added during play. Give it an id at setup ' +
255
256
  "(engine.add(obj, { id })), or make it a template and create it inside an op with engine.content.spawn(name, at)." },
256
257
  'thing-orphan': {
257
- docs: ['recipes/41-thing-registry.md'],
258
+ docs: ['recipes/40-scene.md'],
258
259
  fix: "The 'scene' save part names an id no engine.add object has: the code that added it changed its id or no longer runs. " +
259
260
  'The data is kept in the save; restore the id, or ignore it if the object was deleted on purpose.' },
260
261
  'engine-misuse': {
261
262
  docs: ['api/engine.md'],
262
263
  fix: 'An engine call got an argument it cannot use; the message names the call and the accepted forms.' },
263
264
  'many-lights': {
264
- docs: ['recipes/09-style.md', 'api/lightPool.md'],
265
+ docs: ['recipes/09-materials-lights-models.md', 'api/lightPool.md'],
265
266
  fix: 'More than 8 real-time lights are in the scene. Use engine.use(lightPool({ point: 8 })) and register torches / lamps with ' +
266
267
  'engine.lightPool.add(...) so a fixed small set of real lights follows the nearest sources.' },
267
268
  'light-recompile': {
268
- docs: ['recipes/09-style.md', 'api/lightPool.md'],
269
+ docs: ['recipes/09-materials-lights-models.md', 'api/lightPool.md'],
269
270
  fix: 'The number of lights changed during play, so three.js compiled new shader programs (a long frame). Keep the light ' +
270
271
  'count fixed: engine.use(lightPool({ point: 8 })) before engine.start() and register torches / lamps with ' +
271
272
  'engine.lightPool.add(...), or create your own lights before start and fade them with intensity instead of adding, ' +
@@ -291,11 +292,22 @@ export const ERROR_CODES = {
291
292
  'probes-option': {
292
293
  docs: ['recipes/34-environment-lighting.md', 'api/engine.md'],
293
294
  fix: 'engine.bakeProbes / loadProbes got a wrong option: bounds must be a Box3 or { min, max }, spacing a positive number of meters ' +
294
- '(raise it when the grid has too many probes), follow focus, camera, an Object3D, a function or false.' },
295
+ '(raise it when the grid has too many probes). On a device that cannot render to float textures, bake elsewhere and ship the file.' },
296
+ 'probes-check': {
297
+ docs: ['recipes/34-environment-lighting.md'],
298
+ fix: 'A probe grid is live and something around it will look wrong: lit objects reach outside it (widen bounds or light them another way) ' +
299
+ 'or other light adds to what the bake saw (lower it where the probes take over). The details are in describe().render.probes.' },
295
300
  'probes-data': {
296
301
  docs: ['recipes/34-environment-lighting.md', 'api/engine.md'],
297
302
  fix: 'engine.loadProbes(json) was given data that is not a probe file (or a damaged one), so nothing was added. Pass what ' +
298
303
  'handle.toJSON() returned, or bake again with engine.bakeProbes.' },
304
+ 'lightmap-data': {
305
+ docs: ['recipes/34-environment-lighting.md', 'api/engine.md'],
306
+ fix: 'engine.loadLightmap(file) was given something that is not a file from `threedog bake light`, or a damaged one, so nothing was changed. Bake it again.' },
307
+ 'lightmap-check': {
308
+ docs: ['recipes/34-environment-lighting.md'],
309
+ fix: 'A lightmap is on and something around it will look wrong: a baked mesh moved or is missing, a baked material is shared with an unbaked mesh, ' +
310
+ 'or ambient light adds to what the bake saw. The details are in describe().render.lightmap.' },
299
311
  'grid-data': {
300
312
  docs: ['recipes/29-grid.md', 'api/grids.md'],
301
313
  fix: 'sampleGrid / gridFromImage / decodePng got data it cannot read: wrong width * height, an unknown interp or channel, or a PNG ' +
@@ -307,14 +319,14 @@ export const ERROR_CODES = {
307
319
  'input-owner': {
308
320
  docs: ['api/input.md'],
309
321
  fix: 'input.push(name, { owner }) needs a non-empty owner string (who pushed the context), so pop / describe can tell owners apart.' },
310
- 'style-value': {
311
- docs: ['recipes/09-style.md', 'recipes/52-look.md'],
312
- fix: 'A style value is the wrong shape (toneMapping, exposure, a style part), or is world state put in a style. Use the form in the ' +
313
- 'message; world state (map size, rules) goes in the game, not in the look.' },
314
322
  'owned-misuse': {
315
- docs: ['recipes/52-look.md', 'recipes/54-three-idioms.md'],
316
- fix: 'defineOwned / look.<part>.manual(key) was called wrongly: a module definition misses id / part / read / levels.manual, or ' +
323
+ docs: ['recipes/52-around-the-picture.md', 'recipes/54-three-idioms.md'],
324
+ fix: 'defineOwned / engine.view.manual(key) was called wrongly: a module definition misses id / part / read / levels.manual, or ' +
317
325
  'manual() named a key the part does not write. Use a key listed in the message.' },
326
+ 'shadow-cascades': {
327
+ docs: ['recipes/45-cascaded-shadows.md'],
328
+ fix: 'engine.shadows (cascades, box, budget, include, enabled) was called wrongly: the message names what to change. ' +
329
+ 'An engine draws one set of cascades, and a light takes a box or cascades, not both.' },
318
330
  'shadow-type': {
319
331
  docs: ['recipes/45-cascaded-shadows.md'],
320
332
  fix: 'Unknown shadow type: use one of the names listed in the message.' },
@@ -386,9 +398,9 @@ export const ERROR_CODES = {
386
398
  fix: 'A calendar option, season name or scenario season is wrong (day length not > 0, a season list entry without name / days, a season the ' +
387
399
  'calendar does not have). Day, time, seasons and hours per day are calendar({...}) options; sky({ time }) is only the fixed time drawn without a calendar.' },
388
400
  'sky-option': {
389
- docs: ['recipes/08-weather-sky.md', 'recipes/36-sky-ground-plant-looks.md', 'api/sky.md'],
401
+ docs: ['recipes/08-weather-sky.md', 'recipes/36-sky-ground-plants.md', 'api/sky.md'],
390
402
  fix: 'A sky / fog / clouds / shadow option has a wrong value or is not an option (day length, days and seasons are calendar() options). Own GLSL goes through ' +
391
- 'engine.look.<part>.patch(slot, glsl), not a style key. The message lists the accepted values.' },
403
+ 'engine.sky.clouds() and engine.sky.layer(), not an option key. The message lists the accepted values.' },
392
404
  'terrain-chunk-failed': {
393
405
  docs: ['recipes/28-terrain.md', 'api/terrain.md'],
394
406
  fix: 'A terrain chunk failed on every try and stays empty (no ground, no collision there). Usually the height / groundType / placement rule ' +
@@ -398,32 +410,32 @@ export const ERROR_CODES = {
398
410
  fix: 'A terrain option or terrain edit is wrong (shape mask missing, a brush number not a number, an unknown paint). Use the form ' +
399
411
  'in the message.' },
400
412
  'vegetation-option': {
401
- docs: ['api/vegetation.md', 'recipes/36-sky-ground-plant-looks.md'],
413
+ docs: ['api/vegetation.md', 'recipes/36-sky-ground-plants.md'],
402
414
  fix: 'A vegetation option is wrong: positions entries, densityMap form, fade range or a model with several materials. Fix the ' +
403
415
  'entry the message points at.' },
404
416
  'water-option': {
405
- docs: ['api/water.md', 'recipes/44-water-weather-look-hooks.md'],
406
- fix: 'A water option is wrong; own GLSL goes through look.water.patch(slot, glsl) and must define the function the message names.' },
417
+ docs: ['api/water.md', 'recipes/44-water-weather-hooks.md'],
418
+ fix: 'A water option is wrong; own GLSL goes through engine.water.shader({ wave, surface }) and must define the function the message names.' },
407
419
  'weather-option': {
408
- docs: ['api/weather.md', 'recipes/44-water-weather-look-hooks.md'],
420
+ docs: ['api/weather.md', 'recipes/44-water-weather-hooks.md'],
409
421
  fix: 'A weather type, field, pool or particle definition is wrong. The message lists the defined types and the accepted forms.' },
410
422
  'world-option': {
411
423
  docs: ['recipes/18-world.md', 'api/world.md'],
412
424
  fix: 'A world option is wrong (an anchor shape, a simulate channel that is not a time channel). Use the form in the message.' },
413
425
  'material-option': {
414
- docs: ['recipes/48-make-material.md', 'recipes/43-shader-patches-surface-looks.md'],
426
+ docs: ['recipes/09-materials-lights-models.md', 'recipes/43-shader-patches-surfaces.md'],
415
427
  fix: 'A material / surface / detail / lighting spec is wrong: an unknown type, texture slot or setting, or GLSL that does not define ' +
416
428
  'the function the slot expects. The message names the key and the accepted values.' },
417
429
  'post-effect': {
418
- docs: ['api/post.md', 'recipes/52-look.md'],
419
- fix: 'A post effect is malformed or clashes: look.post.add takes a three.js Pass, a node function (WebGPU) or { name, create | node | fuse }, ' +
420
- 'with a unique name and a known slot. Change an existing effect with look.post.set; add one with look.post.add (the one way).' },
430
+ docs: ['api/post.md', 'recipes/52-around-the-picture.md'],
431
+ fix: 'A post effect is malformed or clashes: engine.post.add takes a three.js Pass, a node function (WebGPU) or { name, create | node | fuse }, ' +
432
+ 'with a unique name and a known slot. Change an existing effect with its handle (engine.post.get(name).set(params), .enabled); add one with engine.post.add (the one way).' },
421
433
  'own-frame': {
422
- docs: ['THREE.md', 'recipes/52-look.md'],
434
+ docs: ['THREE.md', 'recipes/52-around-the-picture.md'],
423
435
  fix: 'The game draws the canvas itself (its own composer.render() / renderer.render outside engine.onRender), so the engine yielded ' +
424
- 'the frame. Intended: nothing to do. To get the engine frame back delete your render call; to add a pass to it use engine.look.post.add(pass).' },
436
+ 'the frame. Intended: nothing to do. To get the engine frame back delete your render call; to add a pass to it use engine.post.add(pass).' },
425
437
  'shader-patch': {
426
- docs: ['recipes/43-shader-patches-surface-looks.md'],
438
+ docs: ['recipes/43-shader-patches-surfaces.md'],
427
439
  fix: 'A shader patch is malformed: glsl goes with a slot name (a string per slot), raw anchors use vertex / fragment, and the ' +
428
440
  'material must provide what the patch needs. The message lists the slot names.' },
429
441
  'renderer-backend': {
@@ -474,10 +486,10 @@ export const ERROR_CODES = {
474
486
  fix: 'before / after constraints of two or more modules point at each other. Remove one of them or give a module a different stage.' },
475
487
  'module-type': {
476
488
  docs: ['recipes/14-custom-module.md'],
477
- fix: "Every module says what it may own: add type: 'rules' (game logic; the usual one for a game module), or 'world' | 'look' | 'actor' | 'ui' | 'net' | 'tool' (core/moduleTypes.js)." },
489
+ fix: "Every module says what it may own: add type: 'rules' (game logic; the usual one for a game module), or 'world' | 'picture' | 'actor' | 'ui' | 'net' | 'tool' (core/moduleTypes.js)." },
478
490
  'module-type-rule': {
479
491
  docs: ['recipes/14-custom-module.md'],
480
- fix: 'A module did something its type does not own (a look module defining an op or writing world records, a ui module binding keys or registering a save part). Move that part into a module of the right type, or change the type, as the message says.' },
492
+ fix: 'A module did something its type does not own (a picture module defining an op or writing world records, a ui module binding keys or registering a save part). Move that part into a module of the right type, or change the type, as the message says.' },
481
493
  'module-stage': {
482
494
  docs: ['recipes/14-custom-module.md'],
483
495
  fix: 'Modules sort by stage (+ before / after), not by number. Use one of the listed stage names.' },
@@ -513,8 +525,8 @@ export const ERROR_CODES = {
513
525
  'message shows.' },
514
526
  'interaction-option': {
515
527
  docs: ['api/interactions.md', 'recipes/03-items-pickups.md'],
516
- fix: 'interactions.add(): hold is seconds the key stays down (a number >= 0) and radius is meters > 0 (Infinity = from ' +
517
- 'anywhere). Fix the option the message names.' },
528
+ fix: 'interactions.add(): hold is seconds the key stays down (a number >= 0), radius is meters > 0 (Infinity = from ' +
529
+ 'anywhere), and a once item needs its own stable id or mesh.name. Fix the option the message names.' },
518
530
  'hud-option': {
519
531
  docs: ['api/hud.md', 'recipes/26-ui-parts.md'],
520
532
  fix: 'A hud element option is wrong: anchor is one of the listed corners / edges, a counter value is a number or text. Fix ' +
@@ -550,6 +562,9 @@ export const ERROR_CODES = {
550
562
  'bad-position': {
551
563
  docs: ['CONVENTIONS.md', 'api/world.md'],
552
564
  fix: 'A position was NaN or the wrong shape: a Vector3 used like an array (v[0]), a missing field, or a division by zero upstream. Use [x, y, z], { x, z } or the Vector3 itself.' },
565
+ 'state-at': {
566
+ docs: ['recipes/07-flow-scenes-pause.md'],
567
+ fix: 'at names a place of content.load({ places }) or a level marker: install content(), or use pos=x,z.' },
553
568
  'content-place': {
554
569
  docs: ['recipes/20-content-actions-save.md', 'api/content.md'],
555
570
  fix: 'content.load references a place that has no coordinates, or needs world() for props / pickups. Give the place in content.load({ places }) or add the marker to the level.' },
@@ -569,8 +584,20 @@ export const ERROR_CODES = {
569
584
  docs: ['api/events.md'],
570
585
  fix: 'The event name is probably a typo of an engine event (the engine emits no event you did not subscribe to under this name).' },
571
586
  'owned-prop': {
572
- docs: ['recipes/52-look.md', 'recipes/54-three-idioms.md'],
587
+ docs: ['recipes/52-around-the-picture.md', 'recipes/54-three-idioms.md'],
573
588
  fix: 'The engine wrote this value on its own (sky, camera, fog distance ...); your direct write took it over, so the engine no longer changes it. Intended: say so with the manual() call in the message. Not intended: give it back with manual(key, false) and adjust it with set(...).' },
589
+ 'picture-held': {
590
+ docs: ['recipes/62-picture-code.md'],
591
+ fix: 'A picture value is held by a part (provides) and other code wrote it, so one of the two never reaches the screen. Delete the stray write; or swap the holder with engine.use(mine(), { replaces: slot }); or, when both need a say, make it a shared value the holder reads (recipes/62-picture-code.md "Picture parts").' },
592
+ 'picture-leftover': {
593
+ docs: ['recipes/62-picture-code.md'],
594
+ fix: "A picture part was removed and what it added stayed. In its install, hand each thing to ctx.track({ remove() { ... } }) (or undo it in dispose), so it goes with the part (recipes/62-picture-code.md \"Picture parts\")." },
595
+ 'module-unuse': {
596
+ docs: ['recipes/14-custom-module.md'],
597
+ fix: "engine.unuse(name): the module must be installed, and no other module may still require it or a slot only it provides. Unload the dependent first, or swap the provider with engine.use(mine(), { replaces: 'slot' })." },
598
+ 'picture-conflict': {
599
+ docs: ['recipes/62-picture-code.md'],
600
+ fix: 'Two places change this picture value inside one frame, so the earlier write never shows. Pick the one that owns the value and delete the other, or turn the second into a signal the owner reads (recipes/62-picture-code.md "Wiring picture/ parts"). Both lines are in the message.' },
574
601
  'camera-kind': {
575
602
  docs: ['recipes/21-camera.md', 'api/cameraRig.md'],
576
603
  fix: 'setCamera() got an unknown camera kind. Use one of the listed kinds; for a camera of your own, take it with engine.takeCamera(owner) and place engine.camera yourself (recipes/21-camera.md).' },
@@ -611,7 +638,7 @@ export const ERROR_CODES = {
611
638
  docs: ['api/engine.md'],
612
639
  fix: 'engine.dispose() takes nothing or { keepContext: true }.' },
613
640
  'tsl-misuse': {
614
- docs: ['recipes/43-shader-patches-surface-looks.md'],
641
+ docs: ['recipes/43-shader-patches-surfaces.md'],
615
642
  fix: 'A threedog/tsl function cannot work here (the message says why): draw it with the engine renderer, on a Mesh or InstancedMesh.' },
616
643
  'webgpu-needs-tsl': {
617
644
  docs: ['recipes/56-webgpu-tsl.md'],
@@ -620,5 +647,5 @@ export const ERROR_CODES = {
620
647
  'create(engine) returning your own node-material object). The message names the part.' },
621
648
  'module-disabled': {
622
649
  docs: ['recipes/14-custom-module.md'],
623
- fix: 'A look or ui module (particles, sky, music, a panel...) threw and was switched off; the game keeps running without it. The error printed with it is the real cause.' },
650
+ fix: 'A picture or ui module (particles, sky, music, a panel...) threw and was switched off; the game keeps running without it. The error printed with it is the real cause.' },
624
651
  };
@@ -21,7 +21,10 @@ import { ERROR_CODES } from './errorCodes.js';
21
21
  export const ERROR_HINTS = [
22
22
  // Only messages the engine does not write itself: JavaScript, the browser and three.js. An engine error carries its own code, fix and
23
23
  // pages (codedError / coded with an ERROR_CODES entry), so a pattern for it here would be a second copy that drifts from the message.
24
- { id: 'frozen-definition', match: /Cannot (assign to read only property|add property .*not extensible|delete property)/,
24
+ // Frozen definitions are plain objects and arrays (freezeDef skips class instances), so the object named in the message must be one of those: a three.js
25
+ // object's read-only `position` / `rotation` (#<Mesh>, or a minified class name) is another cause and gets no hint.
26
+ { id: 'frozen-definition',
27
+ match: /Cannot (assign to read only property '[^']*' of object '(#<Object>|\[object Array\])'|add property [^,]*, object is not extensible|delete property '[^']*' of (#<Object>|\[object Array\]))/,
25
28
  cause: 'Definitions (content templates, items, entity types) are shared by every instance and frozen. Keep per-instance ' +
26
29
  'state on the world record (engine.world.set(id, { opened: true })) or in its container; define another template for a different kind of thing.',
27
30
  docs: ['recipes/30-templates.md', 'recipes/18-world.md'] },
package/core/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Error tiers.
2
2
  // What to do when a module hook, onFixed / onFrame / clock callback or event listener throws (the main loop and the event bus both come here).
3
- // look and ui modules (the module's type says it: particles, sky, music, a HUD, a menu...): disable the module (its hooks are no longer called),
3
+ // picture and ui modules (the module's type says it: particles, sky, music, a HUD, a menu...): disable the module (its hooks are no longer called),
4
4
  // log once to the console, emit module:disabled; the game carries on -- a missing picture, sound or panel does not change game state.
5
5
  // Gameplay (all other modules, the game's own callbacks and event listeners): in dev and tests (DEV) fail hard -- freeze gameplay (freeze('error')),
6
6
  // engine.error records where and why, emits engine:error, and describe() / describeText() show it on the first line;
@@ -13,8 +13,8 @@ import { errorInfo, hintText } from './errorHints.js';
13
13
  const STRINGS = { once: '[engine] {key} threw (later errors at the same place are not reported again)', disabled: '[engine] {type} module {name} threw and was disabled (the game continues) [module-disabled]', halted: '[engine] {key} threw and gameplay is frozen (in dev / tests a gameplay error fails hard; see engine.error for details) [gameplay-frozen]', listener: 'listener of event {name}',
14
14
  rejected: '[engine] a promise rejected and nothing caught it (e.g. audio.play() of a missing file, an async callback that threw); reported once, the game continues. Add .catch or await it in try. ' };
15
15
 
16
- /** look / ui modules only show the game, so an error in one switches it off instead of freezing gameplay (the type is the one source; no extra flag) */
17
- export const failsSoft = m => m?.type === 'look' || m?.type === 'ui';
16
+ /** picture / ui modules only show the game, so an error in one switches it off instead of freezing gameplay (the type is the one source; no extra flag) */
17
+ export const failsSoft = m => m?.type === 'picture' || m?.type === 'ui';
18
18
 
19
19
  /** Handle an error. key: where it happened (for display); module: the module definition that threw (none means a game callback / event listener, counted as gameplay); soft: report only once */
20
20
  export function reportError(engine, err, key, { module = null, soft = false } = {}) {
@@ -53,7 +53,7 @@ export function watchRejections(engine) {
53
53
  /** An event listener threw (called by the event bus): counted as gameplay */
54
54
  export function reportListenerError(engine, name, err) { reportError(engine, err, STRINGS.listener.replace('{name}', name)); }
55
55
 
56
- /** Disable a look / ui module: remove its fixed / frame / afterRender hooks */
56
+ /** Disable a picture / ui module: remove its fixed / frame / afterRender hooks */
57
57
  function disableModule(engine, m, err) {
58
58
  if (engine.disabledModules.has(m.name)) return;
59
59
  engine.disabledModules.add(m.name);
@@ -61,6 +61,7 @@ export const ENGINE_EVENTS = [
61
61
  'music:change',
62
62
  'music:stinger',
63
63
  'state:applied',
64
+ 'state:placed',
64
65
  'anim:end',
65
66
  'world:add',
66
67
  'world:change',
@@ -1,19 +1,21 @@
1
1
  // Plain three.js lights are adopted (docs/plans/2026-11-03-slot-map.md, lights row): a `new THREE.PointLight` / `SpotLight` the game puts anywhere
2
2
  // in the scene gets what a lightPool light gets, without the game naming it to the engine:
3
3
  // · counted: engine.budget categories `lights` (visible point + spot lights, pooled ones included: every one costs every lit pixel) and
4
- // `shadowLights` (those casting, 0 while renderer.shadowMap.enabled is off); describe().render.lights lists the game's lights with the file:line that added them
4
+ // `shadowLights` (those casting, 0 while renderer.shadowMap.enabled is off); `shadowMaps` (every map the renderer draws, sun and cascades included, a point
5
+ // light six) and `shadowMapSize` (the largest side) carry no default limit: the game picks them, usually from engine.tier; describe().render.lights lists the game's lights with the file:line that added them
5
6
  // · the idle-shadow rule: a shadow-casting light at intensity 0 stops redrawing its shadow map (a point light is six shadow passes a frame
6
7
  // for a light that lights nothing) and redraws once it is lit again. This is the one setting of a game light the engine writes, so it is
7
8
  // kept to what it took: only a light whose shadow.autoUpdate was on is idled; only a light the engine idled gets autoUpdate back; a
8
9
  // game that writes autoUpdate itself while the light is idled (its own redraw plan) gets the light handed back and never idled again;
9
10
  // light.userData.idleShadow = false opts one light out; describe().render.lights says shadowIdled: true while the engine holds one.
10
11
  // Listed in threePatches as 'light-idle-shadow' (off() stops it for every light).
11
- // What stays the game's: color, intensity, distance, castShadow (turning shadows off is the renderer's switch, core/look/shadowPart.js), the shadow map size and bias. The engine never writes them (P1).
12
+ // What stays the game's: color, intensity, distance, castShadow (turning shadows off is the renderer's switch, core/shadows.js), the shadow map size and bias. The engine never writes them (P1).
12
13
  // lightPool stays the optional helper for "many lamps, few real lights": that trade-off is a game decision the engine cannot guess.
13
14
  // Cost: a scene visitor (no walk per frame); per frame one loop over the shadow-casting game lights, usually zero to three.
14
15
  import { sceneVisitor } from './sceneDelta.js';
15
16
  import { moduleOwnerOf } from './things.js';
16
17
  import { notePatch, patchOn } from './threePatches.js';
18
+ import { shadowMaps } from '../render/backend.js';
17
19
 
18
20
  const MANY = 8; // same line as the dev warning in lightWatch.js: above it every lit material slows down first on mobile GPUs
19
21
 
@@ -38,9 +40,14 @@ export function watchGameLights(e) {
38
40
  const shown = l => { for (let p = l; p; p = p.parent) if (!p.visible) return false; return true; };
39
41
  e.budget.metric('lights', () => count(l => shown(l) && l.intensity > 0), { limit: MANY });
40
42
  e.budget.metric('shadowLights', () => e.renderer.shadowMap.enabled ? count(l => shown(l) && l.castShadow && l.intensity > 0) : 0);
43
+ const maps = () => shadowMaps(e.renderer, e.scene);
44
+ e.budget.metric('shadowMaps', () => maps().reduce((n, m) => n + m.faces, 0));
45
+ e.budget.metric('shadowMapSize', () => maps().reduce((n, m) => Math.max(n, m.shadow.mapSize.x, m.shadow.mapSize.y), 0));
41
46
  e._gameLights = {
42
47
  /** The game's own point / spot lights (not a module's, not a pool's) */
43
48
  list() { view.sync(); return [...game]; },
49
+ /** Every point / spot light in the scene, modules' and pools' too; a live set, for reading */
50
+ all() { view.sync(); return all; },
44
51
  /** Before each render (loop.js): the idle-shadow rule */
45
52
  frame() {
46
53
  view.sync();