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/core/plugins.js CHANGED
@@ -1,10 +1,8 @@
1
1
  // engine.plugins: the plugins folder (docs/plans/2026-11-03-slot-map.md section 6). Each file in the game's plugins/ folder is imported at
2
2
  // start and plugged in by WHAT it exports, through the one call a game would have written by hand:
3
3
  // Object3D -> engine.add(obj, { id: <file name> }) (same as scene.add, plus a stable save id)
4
- // three.js Pass (has render()) -> engine.look.post.add(pass, { name: <file name> })
5
- // post effect { name, create | node | fuse } -> engine.look.post.add(effect) (create for WebGL, node for WebGPU: one file runs on both)
6
- // Material -> engine.look.materials.replace(role, mat) role = mat.name, else the file name
7
- // ShaderPatch { slot, glsl|tsl } -> engine.look.materials.add(<file>, spec, { roles })
4
+ // three.js Pass (has render()) -> engine.post.add(pass, { name: <file name> })
5
+ // post effect { name, create | node | fuse } -> engine.post.add(effect) (create for WebGL, node for WebGPU: one file runs on both)
8
6
  // module { name, type, install / init } -> engine.use(mod)
9
7
  // an array of those -> each one, in array order
10
8
  // anything else is a dev error naming the file and the shapes above. A function is never a plugin, on either renderer: a plugin says what it
@@ -15,42 +13,28 @@
15
13
  // Order: by file name (10-fog.js before 20-bloom.js), or plugins/plugins.json { "order": [...], "off": [...] }. Nothing is sorted behind
16
14
  // the game's back: describe().slots lists the order used.
17
15
  // Off: plugins.json "off" (no code change), or engine.plugins.off(name) at run time; on(name) plugs it again.
18
- // A style pack is a bundle of the same plugins (style.plugins, core/styleParts.js stylePlugins): plugged here first, through this same code, named
19
- // '<pack>/<file>', with materials and material patches on the style layer so the game, effects and settings still win; off('<pack>') takes the pack's out
20
- // (its plugins only: the pack's starting values, style.exposure / fog / materials table, are the style itself and stay).
21
- // Owners: every plugin is its own owner ('plugin:<file>', 'style:<pack>/<file>'); the pack only groups them. Why: with one owner per pack, B's
22
- // remove dropped the key A had written too (A said on, the base came back). Two plugins writing one key on one layer is a shared-conflict naming
23
- // both, unless one file says `export const replaces = '<other file>'` (then the other is unplugged while this one is on).
24
- // Reach: a post effect, an object, a module change the picture at once ('live'); a material / material patch changes what makeMaterial makes
25
- // NEXT ('new materials only'), so off / on rebuilds the materials already made (engine.look.materials.rebuild(); { rebuild: false } skips it).
16
+ // Owners: every plugin is its own owner ('plugin:<file>'). Why: with one owner for all, B's remove dropped the key A had written too (A said on,
17
+ // the base came back). Two plugins writing one key on one layer is a shared-conflict naming both, unless one file says `export const replaces = '<other file>'` (then the other is unplugged while this one is on).
18
+ // A Material or a ShaderPatch is no plugin: it says nothing about which mesh it belongs to, so it goes on that mesh or module in plain code.
26
19
  // Places: a post effect keeps the place it first got (its name is reserved in plugin order), so off / on never reorders the chain.
27
- // Why not a second loader for styles: one path means a plugin file works alone in plugins/ or inside any number of style packs, unchanged.
28
20
  import { codedError } from './errorHints.js';
29
- import { stylePlugins } from './styleParts.js';
30
21
  import { MODULE_TYPES } from './moduleTypes.js';
31
22
 
32
23
  const SHAPES = 'an Object3D (goes in the scene), a three.js Pass with render() (post chain), a post effect { name, create: ctx => pass, node: (input, ctx) => node } or { name, fuse } (post chain, both renderers), ' +
33
- 'a Material (look.materials role = material.name or the file name), a ShaderPatch { slot, glsl | tsl, roles? } (look.materials.add), ' +
34
24
  "a module { name, type, install / init } (engine.use), or an array of these. Export it as default (export default new THREE.Mesh(...))";
35
25
 
36
26
  /** Which slot a value plugs into, or null when it is none of the accepted shapes */
37
27
  function shapeOf(v) {
38
28
  if (v?.isObject3D) return 'scene';
39
- if (v?.isMaterial) return 'material';
29
+ if (v?.isMaterial) return null; // it has name, type and dispose(), so the module test below would take it for a module
40
30
  if (v && typeof v === 'object') {
41
31
  if (typeof v.render === 'function' && 'needsSwap' in v) return 'post'; // three's Pass base class sets needsSwap: a Pass, not a module with render()
42
32
  if (typeof v.name === 'string' && v.type && (v.install || v.init || v.fixed || v.frame || v.dispose)) return 'module';
43
33
  if (typeof v.name === 'string' && (typeof v.create === 'function' || typeof v.node === 'function' || (v.fuse && typeof v.fuse === 'object'))) return 'post';
44
- if (typeof v.glsl === 'string' || typeof v.glsl === 'object' || v.tsl) return 'patch';
45
34
  }
46
35
  return null;
47
36
  }
48
37
 
49
- const NEW = 'new materials only';
50
- /** How far a slot reaches: a material or patch changes what makeMaterial makes next; everything else changes the picture at once */
51
- const slotReach = slot => (slot === 'material' || slot === 'patch' ? NEW : 'live');
52
- /** A plugin's reach: NEW when any of its values is a material / patch */
53
- const reachOf = p => (p.values.some(v => slotReach(shapeOf(v)) === NEW) ? NEW : 'live');
54
38
  /** The post chain name of a plugin's post value: an effect keeps its own name, a bare Pass is named by its file ('<file>/<i>' with several) */
55
39
  const postName = (p, v, i) => (v.isPass || 'needsSwap' in v ? (p.values.length > 1 ? `${p.name}/${i}` : p.name) : v.name);
56
40
 
@@ -75,29 +59,25 @@ export class Plugins {
75
59
  * @returns {this}
76
60
  * @example engine.plugins.add(import.meta.glob('./plugins/*.js', { eager: true }), { off: ['20-bloom'] });
77
61
  */
78
- add(files, { order = [], off = [] } = {}) { return this._add(files, { order, off }); }
79
-
80
- /** @internal the one loader: the game's folder (group null) and each style pack's plugins (group = the pack's name, style layer) */
81
- _add(files, { order = [], off = [], group = null }) {
62
+ add(files, { order = [], off = [] } = {}) {
82
63
  const paths = Object.keys(files).sort((a, b) => baseOf(a) < baseOf(b) ? -1 : baseOf(a) > baseOf(b) ? 1 : 0);
83
64
  const rank = n => { const i = order.indexOf(n); return i < 0 ? order.length : i; };
84
65
  paths.sort((a, b) => rank(baseOf(a)) - rank(baseOf(b))); // stable sort: listed names first, the rest keep file-name order
85
66
  for (const n of [...order, ...off]) if (!paths.some(p => baseOf(p) === n))
86
67
  throw codedError('plugin-shape', `plugins.json names '${n}', but there is no plugins/${n}.js; files: ${paths.map(baseOf).join(', ') || 'none'}`);
87
- const where = group ? `style ${group}: plugins/` : 'plugins/';
88
68
  for (const path of paths) {
89
- const ns = files[path], name = group ? `${group}/${baseOf(path)}` : baseOf(path);
69
+ const ns = files[path], name = baseOf(path);
90
70
  // replaces: a word about the file, never plugged (a string is no plugin shape)
91
71
  const named = ns && 'default' in ns ? [['default', ns.default]] : Object.entries(ns ?? {}).filter(([k]) => k !== 'replaces'), values = named.flatMap(([, v]) => [].concat(v));
92
- if (!values.length) throw codedError('plugin-shape', `${where}${baseOf(path)}.js exports nothing. Fix: export default one of: ${SHAPES}`);
93
- for (const [key, x] of named) for (const v of [].concat(x)) if (!shapeOf(v)) throw codedError('plugin-shape', notAPlugin(`${where}${baseOf(path)}.js`, key, v));
94
- const file = group ? `${where}${baseOf(path)}.js` : path.replace(/^.*?(plugins\/)/, '$1');
95
- const replaces = [].concat(ns?.replaces ?? []).map(r => (group && !String(r).includes('/') ? `${group}/${r}` : String(r)));
96
- this._list.set(name, { name, group, file, values, replaces, replacedBy: null, on: !off.includes(name), plugged: [] });
72
+ if (!values.length) throw codedError('plugin-shape', `plugins/${baseOf(path)}.js exports nothing. Fix: export default one of: ${SHAPES}`);
73
+ for (const [key, x] of named) for (const v of [].concat(x)) if (!shapeOf(v)) throw codedError('plugin-shape', notAPlugin(`plugins/${baseOf(path)}.js`, key, v));
74
+ const file = path.replace(/^.*?(plugins\/)/, '$1');
75
+ const replaces = [].concat(ns?.replaces ?? []).map(String);
76
+ this._list.set(name, { name, file, values, replaces, replacedBy: null, on: !off.includes(name), plugged: [] });
97
77
  }
98
78
  for (const p of this._list.values()) for (const r of p.replaces) if (!this._list.has(r))
99
79
  throw codedError('plugin-shape', `${p.file}: export const replaces = '${r}', but there is no plugin '${r}'; plugins: ${[...this._list.keys()].join(', ')}`);
100
- if (!group) this._added = true;
80
+ this._added = true;
101
81
  if (this._e._started) this._plugAll();
102
82
  return this;
103
83
  }
@@ -109,22 +89,21 @@ export class Plugins {
109
89
  for (const p of all) p.values.forEach((v, i) => { if (shapeOf(v) === 'post') e.post?._place(postName(p, v, i), true); });
110
90
  const todo = all.filter(p => p.on && !p.plugged.length && !p.replacedBy);
111
91
  for (const p of todo) if (p.on && !p.plugged.length && !p.replacedBy) this._plug(p); // re-checked: a plug can unplug a later one it replaces
112
- if (e._started && todo.some(p => reachOf(p) === NEW)) e.look?.materials?.rebuild?.();
113
92
  }
114
93
 
115
94
  /** @internal */
116
95
  _plug(p) {
117
- const e = this._e, owner = (p.group ? 'style:' : 'plugin:') + p.name, layer = p.group ? 'style' : 'game'; // a style's plugins sit under the game
96
+ const e = this._e, owner = 'plugin:' + p.name, layer = 'game';
97
+ let at = null; // the value being plugged, so a clash can name the other plugin
118
98
  for (const r of p.replaces) { const q = this._list.get(r); q.replacedBy = p.name; this._unplug(q); }
119
99
  try {
120
100
  for (const v of p.values) {
101
+ at = v;
121
102
  const slot = shapeOf(v);
122
103
  let remove;
123
104
  if (slot === 'scene') { e.add(v, { id: p.values.length > 1 ? `${p.name}/${p.plugged.length}` : p.name }); remove = () => { v.removeFromParent(); e._things.forget(v); e.rays.forget(v); }; } // not engine.remove: that disposes, and on() puts it back
124
- // an effect keeps its own name (look.post.set({ bloom: false }) reads the same from any source); a bare Pass is named by its file
125
- else if (slot === 'post') { const h = e.look.post.add(v, { owner, layer, ...(v.isPass || 'needsSwap' in v ? { name: postName(p, v, p.plugged.length) } : {}) }); remove = () => h.remove(); }
126
- else if (slot === 'material') { const h = e.look.materials.replace(v.name || baseOf(p.name), v, { owner, layer }); remove = () => h.remove(); }
127
- else if (slot === 'patch') { const { roles, ...spec } = v, h = e.look.materials.add(p.name, spec, { roles, owner, layer }); remove = () => h.remove(); }
105
+ // an effect keeps its own name (engine.post.get('bloom') reads the same from any source); a bare Pass is named by its file
106
+ else if (slot === 'post') { const h = e.post.add(v, v.isPass || 'needsSwap' in v ? { name: postName(p, v, p.plugged.length) } : {}); remove = () => h.remove(); }
128
107
  else { e.use(v); remove = () => { if (e.modules.get(v.name) === v) e._unuse(v.name); }; }
129
108
  p.plugged.push({ slot, value: v, remove });
130
109
  }
@@ -132,7 +111,10 @@ export class Plugins {
132
111
  this._unplug(p); // all or nothing per file: half a plugin is harder to read than none
133
112
  this._giveBack(p);
134
113
  err.message = `${p.file}: ${err.message}`;
135
- if (/shared-conflict/.test(err.message)) err.message += ` Two plugins write the same key: keep one, or say which wins in the file that should: export const replaces = '<the other file>';`;
114
+ // two plugins naming one post effect: the error comes from the post chain, which knows names and not files, so the file of the first is added here
115
+ const first = [...this._list.values()].find(q => q !== p && q.plugged.some(x => x.slot === 'post' && at?.name && x.value.name === at.name));
116
+ if (first) err.message += ` ${first.file} added it first.`;
117
+ if (first || /shared-conflict/.test(err.message)) err.message += ` Two plugins write the same key: keep one, or say which wins in the file that should: export const replaces = '<the other file>';`;
136
118
  throw err;
137
119
  }
138
120
  }
@@ -144,57 +126,47 @@ export class Plugins {
144
126
  }
145
127
 
146
128
  /**
147
- * Switch a plugin off: everything it plugged is taken out again (the object leaves the scene, the pass the chain, the patch its layer,
148
- * the module is unloaded). No code change: plugins.json "off" does the same at start. A style pack's name switches off all of that pack's
149
- * plugins ('ink'), '<pack>/<file>' one of them; the pack's starting values (style fields) stay. A material / patch plugin also rebuilds the
150
- * materials already made (engine.look.materials.rebuild()), unless { rebuild: false }.
151
- * To pause a post effect and keep everything else, look.post.set({ <effect>: false }) is lighter: off unloads.
152
- * @param {string} name file name without .js, or a style pack's name @param {{ rebuild?: boolean }} [o]
153
- * @returns {{ off: string[], reach: string[], rebuilt: number | null, note: string }}
129
+ * Switch a plugin off: everything it plugged is taken out again (the object leaves the scene, the pass the chain,
130
+ * the module is unloaded). No code change: plugins.json "off" does the same at start.
131
+ * To pause a post effect and keep everything else, engine.post.get('<effect>').enabled = false is lighter: off unloads.
132
+ * @param {string} name file name without .js
133
+ * @returns {{ off: string[], note: string }}
154
134
  */
155
- off(name, { rebuild = true } = {}) {
156
- const ps = this._get(name);
157
- for (const p of ps) { p.on = false; this._unplug(p); }
158
- for (const p of ps) this._giveBack(p);
159
- return this._result('off', name, ps, rebuild);
135
+ off(name) {
136
+ const p = this._get(name);
137
+ p.on = false; this._unplug(p);
138
+ this._giveBack(p);
139
+ return this._result('off', p);
160
140
  }
161
141
  /**
162
- * Switch a plugin (or a style pack's plugins) back on (plugged at once after start); a material / patch plugin rebuilds the made materials
163
- * as off does. @param {string} name @param {{ rebuild?: boolean }} [o]
164
- * @returns {{ on: string[], reach: string[], rebuilt: number | null, note: string }}
142
+ * Switch a plugin back on (plugged at once after start). @param {string} name
143
+ * @returns {{ on: string[], note: string }}
165
144
  */
166
- on(name, { rebuild = true } = {}) {
167
- const ps = this._get(name);
168
- for (const p of ps) { p.on = true; if (this._e._started && !p.plugged.length && !p.replacedBy) this._plug(p); }
169
- return this._result('on', name, ps, rebuild);
145
+ on(name) {
146
+ const p = this._get(name);
147
+ p.on = true; if (this._e._started && !p.plugged.length && !p.replacedBy) this._plug(p);
148
+ return this._result('on', p);
170
149
  }
171
150
  /** @internal what off / on did, in words a reader can act on */
172
- _result(verb, name, ps, rebuild) {
173
- const e = this._e, reach = [...new Set(ps.map(reachOf))], notes = [];
174
- let rebuilt = null;
175
- if (reach.includes(NEW) && e._started) {
176
- if (rebuild && e.look?.materials?.rebuild) rebuilt = e.look.materials.rebuild().rebuilt;
177
- else notes.push('materials made before keep the old look until engine.look.materials.rebuild() (new ones follow at once)');
178
- }
179
- const fx = ps.flatMap(p => p.values.map((v, i) => (shapeOf(v) === 'post' ? postName(p, v, i) : null))).filter(Boolean);
180
- if (verb === 'off' && fx.length) notes.push(`plugins.off unloads; to pause an effect in its place use engine.look.post.set({ ${fx.map(n => `${/^[\w$]+$/.test(n) ? n : `'${n}'`}: false`).join(', ')} })`);
181
- if (verb === 'off' && ps.some(p => p.group === name)) notes.push(`style '${name}': its plugins are off; the pack's starting values (exposure, fog, its materials table ...) stay, they are the style itself`);
182
- const replaced = ps.filter(p => p.replacedBy).map(p => `${p.name} stays out while ${p.replacedBy} (replaces it) is on`);
183
- return { [verb]: ps.map(p => p.name), reach, rebuilt, note: [...notes, ...replaced].join('; ') };
151
+ _result(verb, p) {
152
+ const notes = [];
153
+ const fx = p.values.map((v, i) => (shapeOf(v) === 'post' ? postName(p, v, i) : null)).filter(Boolean);
154
+ if (verb === 'off' && fx.length) notes.push(`plugins.off unloads; to pause an effect in its place use ${fx.map(n => `engine.post.get('${n}').enabled = false`).join('; ')}`);
155
+ if (p.replacedBy) notes.push(`${p.name} stays out while ${p.replacedBy} (replaces it) is on`);
156
+ return { [verb]: [p.name], note: notes.join('; ') };
184
157
  }
185
- /** @internal the plugin by name, or every plugin of the style pack by that name */
158
+ /** @internal */
186
159
  _get(name) {
187
- const p = this._list.get(name), pack = p ? [p] : [...this._list.values()].filter(x => x.group === name);
188
- if (!pack.length) throw codedError('plugin-shape', `engine.plugins: no plugin '${name}' (nor a style pack by that name); plugins: ${[...this._list.keys()].join(', ') || 'none (no plugins folder, no style plugins)'}`);
189
- return pack;
160
+ const p = this._list.get(name);
161
+ if (!p) throw codedError('plugin-shape', `engine.plugins: no plugin '${name}'; plugins: ${[...this._list.keys()].join(', ') || 'none (no plugins folder)'}`);
162
+ return p;
190
163
  }
191
164
 
192
165
  /**
193
- * The plugins in plug order (a style's first): { name, file, on, slots, reach, style, replacedBy } (style: the pack's name, null for the game's
194
- * folder; reach per slot: 'live', or 'new materials only' for a material / patch, which off / on rebuilds; replacedBy: the plugin that holds it out)
195
- * @returns {{ name: string, file: string, on: boolean, slots: string[], reach: string[], style: string | null, replacedBy: string | null }[]}
166
+ * The plugins in plug order: { name, file, on, slots, replacedBy } (replacedBy: the plugin that holds it out)
167
+ * @returns {{ name: string, file: string, on: boolean, slots: string[], replacedBy: string | null }[]}
196
168
  */
197
- list() { return [...this._list.values()].map(p => ({ name: p.name, file: p.file, on: p.on, slots: p.values.map(v => shapeOf(v)), reach: [...new Set(p.values.map(v => slotReach(shapeOf(v))))], style: p.group, replacedBy: p.replacedBy })); }
169
+ list() { return [...this._list.values()].map(p => ({ name: p.name, file: p.file, on: p.on, slots: p.values.map(v => shapeOf(v)), replacedBy: p.replacedBy })); }
198
170
  }
199
171
 
200
172
  /**
@@ -203,6 +175,9 @@ export class Plugins {
203
175
  */
204
176
  function notAPlugin(file, key, v) {
205
177
  const what = key === 'default' ? 'the default export' : `the export '${key}'`;
178
+ if (v?.isMaterial) return `${file}: ${what} is a Material, which says nothing about what it goes on. Fix: put it on its mesh in your picture/ code, or on a module (engine.water.material = mat)`;
179
+ if (v && typeof v === 'object' && !v.isObject3D && (v.slot || typeof v.glsl === 'string' || typeof v.glsl === 'object' || v.tsl))
180
+ return `${file}: ${what} is a ShaderPatch, which says nothing about which material it changes. Fix: applyEffects(material, { patches: [patch] }) in your picture/ code`;
206
181
  if (typeof v === 'function') {
207
182
  const fn = v.name && v.name !== 'default' ? v.name : 'make';
208
183
  return `${file}: ${what} is a function (${v.name || 'anonymous'}). A function is never a plugin: it does not say where it plugs in. ` +
@@ -225,15 +200,10 @@ function notAPlugin(file, key, v) {
225
200
  }
226
201
 
227
202
  /**
228
- * Plug the style's plugins (style layer), then what the page's plugins folder gave (the vite preset puts it on globalThis.__threedogPlugins
229
- * before main.js runs) and the files engine.plugins.add received. Called once by start(). @param {any} e
203
+ * Plug what the page's plugins folder gave (the vite preset puts it on globalThis.__threedogPlugins before main.js runs) and the files
204
+ * engine.plugins.add received. Called once by start(). @param {any} e
230
205
  */
231
206
  export function plugAtStart(e) {
232
- // the style's first, so their list order (and describe().slots) reads base look, then the game's additions
233
- const before = [...e.plugins._list.entries()];
234
- e.plugins._list.clear();
235
- for (const { group, files } of stylePlugins(e.style)) e.plugins._add(files, { group });
236
- for (const [k, v] of before) e.plugins._list.set(k, v);
237
207
  const page = typeof globalThis !== 'undefined' ? globalThis.__threedogPlugins : null;
238
208
  if (page && !e.plugins._added) e.plugins.add(page.files, page.config ?? {});
239
209
  e.plugins._plugAll();
@@ -241,18 +211,16 @@ export function plugAtStart(e) {
241
211
 
242
212
  /**
243
213
  * describe().slots: one table of what is plugged in where. Each row: { slot, plugged, file, on, affects }; file is the plugin file, the
244
- * file:line that called scene.add / engine.add (dev), or the call that plugged it ('engine.use', 'look.post.add'). Why one table:
245
- * a reader asking "what did this game add to the engine" had to put describe().scene, render.post, look and modules side by side.
214
+ * file:line that called scene.add / engine.add (dev), or the call that plugged it ('engine.use', 'engine.post.add'). Why one table:
215
+ * a reader asking "what did this game add to the engine" had to put describe().scene, render.post and modules side by side.
246
216
  * @param {any} e
247
217
  */
248
218
  export function describeSlots(e) {
249
219
  const rows = [], fromPlugin = new Set();
250
220
  const passOf = v => e.post?._list.find(h => h._def === v || h._def._pass === v || h._def.node === v);
251
- const affects = (slot, v, name) => {
221
+ const affects = (slot, v) => {
252
222
  if (slot === 'scene') { const t = e._things.byObj.get(v); return t ? [`engine.thing('${t.id}')`, `save tier ${e._things.tier(t)}`] : ['scene']; }
253
223
  if (slot === 'post') { const h = passOf(v); return [h ? `picture: post chain ${h.slot} slot, ${h.name}` : 'picture: post chain']; }
254
- if (slot === 'material') { const r = v.name || baseOf(name); return [`look.materials replace:${r}`, `makeMaterial('${r}')`]; }
255
- if (slot === 'patch') return [`look.materials hook:${name}`, v.roles ? `materials of roles ${v.roles.join(', ')}` : 'every makeMaterial material', `shader slot ${v.slot ?? '?'}`];
256
224
  if (slot === 'light') return ["budget 'lights'", ...(v.castShadow ? ["budget 'shadowLights'", 'idle shadow redraw rule'] : [])];
257
225
  return [`engine.${v.name}`, `type ${v.type}`, ...(v.provides ?? []).map(s => `provides ${s}`)];
258
226
  };
@@ -260,15 +228,15 @@ export function describeSlots(e) {
260
228
  const slot = shapeOf(v);
261
229
  fromPlugin.add(v);
262
230
  const live = p.on && !p.replacedBy;
263
- rows.push({ slot, plugged: (slot === 'module' ? v.name : v.name || v.type) || p.name, file: p.file, on: live, reach: slotReach(slot),
264
- affects: live ? affects(slot, v, p.name) : p.replacedBy ? [`replaced by ${p.replacedBy}`] : p.group ? [`off; style '${p.group}' starting values stay`] : [] });
231
+ rows.push({ slot, plugged: (slot === 'module' ? v.name : v.name || v.type) || p.name, file: p.file, on: live,
232
+ affects: live ? affects(slot, v) : p.replacedBy ? [`replaced by ${p.replacedBy}`] : [] });
265
233
  }
266
234
  for (const o of e.scene.children) { const en = e._things.byObj.get(o); if (en?.owner === 'game' && !fromPlugin.has(o) && !o.isLight)
267
235
  rows.push({ slot: 'scene', plugged: o.name || o.type, file: en.at ?? 'scene.add / engine.add', on: true, affects: affects('scene', o) }); }
268
236
  for (const h of e.post?._list ?? []) if (![h._def, h._def._pass, h._def.node].some(v => v && fromPlugin.has(v)))
269
- rows.push({ slot: 'post', plugged: h.name, file: 'look.post.add', on: h.enabled, affects: [`picture: post chain ${h.slot} slot, ${h.name}`] });
237
+ rows.push({ slot: 'post', plugged: h.name, file: 'engine.post.add', on: h.enabled, affects: [`picture: post chain ${h.slot} slot, ${h.name}`] });
270
238
  for (const m of e.post?._plain ?? []) if (m.output)
271
- rows.push({ slot: 'post', plugged: 'OutputPass (skipped: the engine tone maps; passes after it run in ldr)', file: 'look.post.add', on: true, affects: ['picture: where display color starts'] });
239
+ rows.push({ slot: 'post', plugged: 'OutputPass (skipped: the engine tone maps; passes after it run in ldr)', file: 'engine.post.add', on: true, affects: ['picture: where display color starts'] });
272
240
  for (const m of e.modules.values()) if (!fromPlugin.has(m))
273
241
  rows.push({ slot: 'module', plugged: m.name, file: 'engine.use', on: true, affects: affects('module', m) });
274
242
  for (const l of e._gameLights?.list() ?? [])
@@ -35,6 +35,7 @@ if (!P[KEY]) {
35
35
  Object.defineProperty(P, KEY, { value: true, configurable: true });
36
36
  Object.defineProperty(P, ORIG, { value: { add, remove }, configurable: true });
37
37
  P.add = function (...a) {
38
+ if (!patchOn('scene-add-hook')) return add.apply(this, a); // switched off while another library's wrapper sits on top of ours: pass through
38
39
  const out = add.apply(this, a); // three detaches each child from its old parent first (through remove below), then attaches
39
40
  const t = trackerOf(this);
40
41
  if (t) for (const c of a) if (c?.parent === this) t.pending.add(c);
@@ -44,7 +45,7 @@ if (!P[KEY]) {
44
45
  return out;
45
46
  };
46
47
  P.remove = function (...a) {
47
- const t = trackerOf(this);
48
+ const t = patchOn('scene-add-hook') ? trackerOf(this) : null;
48
49
  if (!t) return remove.apply(this, a);
49
50
  let gone = null, roots = null;
50
51
  for (const c of a) if (c?.parent === this && t.seen.has(c)) (gone ??= []).push(c);
@@ -54,13 +55,20 @@ if (!P[KEY]) {
54
55
  if (roots) for (const c of roots) if (c.parent !== this) for (const f of t.rootLeaves) f(c);
55
56
  return out;
56
57
  };
58
+ P[ORIG].ours = { add: P.add, remove: P.remove }; // to tell at off() whether they are still the outermost
57
59
  }
58
60
  notePatch('scene-add-hook', 'Object3D.prototype.add / remove: wrapped once per page to see what enters and leaves a watched scene at any depth (three\'s childadded fires on the direct parent only)',
59
- () => { const o = P[ORIG]; if (!o || !P[KEY]) return; P.add = o.add; P.remove = o.remove; delete P[KEY]; delete P[ORIG]; },
60
- { lost: 'plain scene.add is no longer adopted like engine.add, and fog, cascades, cloud shadow, night glow and light counts miss objects added later' });
61
+ () => {
62
+ // a wrapper another library put on top of ours stays: taking it off would undo that library too. Ours then only passes calls through (patchOn above).
63
+ const o = P[ORIG]; if (!o?.ours) return;
64
+ if (P.add === o.ours.add) P.add = o.add;
65
+ if (P.remove === o.ours.remove) P.remove = o.remove;
66
+ if (P.add === o.add && P.remove === o.remove) { delete P[KEY]; delete P[ORIG]; }
67
+ },
68
+ { lost: 'plain scene.add is no longer adopted like engine.add, and fog, cascades, night glow and light counts miss objects added later' });
61
69
  notePatch('mesh-material-accessor', 'mesh.material on each object with a material that enters a watched scene: an own get / set on that object (the class accessor still runs) so a material swap is seen',
62
70
  () => {}, // off: objects entering from now on keep a plain material (_walk asks patchOn)
63
- { scope: 'objects in the scene', lost: 'mesh.material = other on objects entering from now on is not seen: the new material misses fog, cascades and cloud shadow until the object re-enters' });
71
+ { scope: 'objects in the scene', lost: 'mesh.material = other on objects entering from now on is not seen: the new material misses fog and cascades until the object re-enters' });
64
72
 
65
73
  /** The accessor (get / set) `material` resolves to on this object or up its prototype chain, or null when it is a plain value */
66
74
  function materialAccessor(o) {
@@ -1,18 +1,11 @@
1
- // Scene and render settings on the engine (split out of Engine.js): add / detach / remove objects, pixel ratio, shadows, fog distance,
2
- // tone mapping and exposure, one-off renders (renderOnce).
1
+ // Scene and render settings on the engine (split out of Engine.js): add / detach / remove objects, pixel ratio, one-off renders (renderOnce).
3
2
  // add registers each root in the thing registry (things.js) so engine.thing / hit.thing can say what it is and what a save keeps. A plain
4
3
  // engine.scene.add(obj) is registered the same way (things.js adopts roots added under the scene), so both ways in give the same answer.
5
4
  import { DEV } from './validate.js';
6
5
  import { codedError } from './errorHints.js';
7
6
  import { thing } from './thingOps.js';
8
- import { TONE, exposureDriver } from './look/coreParts.js';
9
7
  import { freshFrame, renderOnce as drawOnce } from '../render/backend.js';
10
8
 
11
- /** The engine's fog distance when nobody set one (look.fog far's default; also the stream radius without terrain or fog) */
12
- export const FOG_FAR = 600;
13
- /** The fog distance in effect: look.fog far (with every layer: terrain view, style, game, weather), else FOG_FAR @param {any} e */
14
- export const fogFarOf = e => e.look?.fog?.value('far') ?? FOG_FAR;
15
-
16
9
  /** A short stack for "added at main.js:50" (dev): 4 frames are enough (this, add, its caller) and keep the cost low; it is formatted only when read */
17
10
  function captureStack() {
18
11
  const lim = Error.stackTraceLimit; Error.stackTraceLimit = 4;
@@ -97,7 +90,7 @@ export const sceneMethods = {
97
90
  },
98
91
  // an engine.setPixelRatio call is the game's (or settings') request: written even when the game took the ratio, and re-read so it is not an outside write
99
92
  setPixelRatio(p) { this.renderer.setPixelRatio(p); this._oPixelRatio?.mark(); },
100
- /** Raise camera.far to at least far (terrain view range, fog). Goes through ownership: a game that owns camera.far (look.view.manual('far')) keeps its value. @param {number} far */
93
+ /** Raise camera.far to at least far (terrain view range). Goes through ownership: a game that owns camera.far (engine.view.manual('far')) keeps its value. @param {number} far */
101
94
  viewFar(far) {
102
95
  if (this.camera.far >= far) return;
103
96
  if (this._oFar) this._oFar.drive(far); else { this.camera.far = far; this.camera.updateProjectionMatrix(); }
package/core/services.js CHANGED
@@ -48,7 +48,7 @@ export function createServices(engine, { canvas, validate, locale, strings, save
48
48
  engine.session = new Session(engine); // new game / continue / back to title from a clean slate (session.js)
49
49
  // before Input: key bindings are the shared point 'input.keys'.
50
50
  // shared quantities (stacks.js): engine.mod(name, { owner, mul | add | set | clamp, for }) is the one way several systems change one
51
- (engine.stacks ??= new Stacks(engine))._hook(); // one registry, made early by Engine.js (look parts register points); saves and events hook in now
51
+ (engine.stacks ??= new Stacks(engine))._hook(); // one registry, made early by Engine.js (drawing parts register points); saves and events hook in now
52
52
  engine.mod = (name, o) => engine.stacks.mod(name, o);
53
53
  engine.stacks.define('input.gate', { kind: 'any', per: true }); // input.gate(action, owner): one entry per owner and action (Input.js)
54
54
  engine.input = new Input(engine, canvas, { joystick, bindings });
@@ -9,7 +9,7 @@ export const SHADOW_TYPES = {
9
9
  vsm: { three: THREE.VSMShadowMap, cost: 1.6 },
10
10
  };
11
11
 
12
- /** Validate a shadow type name; throws with the allowed values (a wrong name would otherwise silently fall back to the default look). */
12
+ /** Validate a shadow type name; throws with the allowed values (a wrong name would otherwise silently fall back to the default picture). */
13
13
  export function shadowTypeOf(name, where) {
14
14
  if (Object.hasOwn(SHADOW_TYPES, name)) return SHADOW_TYPES[name].three;
15
15
  throw codedError('shadow-type', `${where}: unknown shadow type ${JSON.stringify(name)}. Use one of: ${Object.keys(SHADOW_TYPES).map(k => `'${k}'`).join(', ')}.`);