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
@@ -8,10 +8,23 @@ export function water(opts?: WaterOptions): ModuleDef<Water>;
8
8
  /** engine.water */
9
9
  export class Water {
10
10
  /**
11
- * Water material (shared by all water)
12
- * @type {Material}
11
+ * The loaded normal map (null = none): a game material takes it as its own normalMap. Its offset scrolls and the water UVs tile for it whatever material draws
12
+ * @type {Texture | null}
13
+ */
14
+ normalTexture: THREE.Texture | null;
15
+ /**
16
+ * The engine's water shader patches (waves, waterSurface when asked for, fresnel), so a game material keeps the behavior: applyEffects(mat, { patches: engine.water.patches })
17
+ * @type {import('../../render/patches.js').ShaderPatch[]}
13
18
  */
14
- material: THREE.Material;
19
+ patches: import("../../render/patches.js").ShaderPatch[];
20
+ /**
21
+ * Shader values, written directly and live: uWave, uWaveScale, uWaveSpeed, uFresnel, uTime; with depthColor / foam uWaterShallow, uWaterDeep, uWaterCurve,
22
+ * uFoamColor, uFoamStart, uFoamEnd, uFoamOpacity; and what shader({ uniforms }) declared
23
+ * @type {Record<string, { value: any }>}
24
+ */
25
+ uniforms: Record<string, {
26
+ value: any;
27
+ }>;
15
28
  /**
16
29
  * Water body → mesh
17
30
  * @type {Map<WaterBody, THREE.Mesh>}
@@ -22,8 +35,42 @@ export class Water {
22
35
  * @type {THREE.Mesh | null}
23
36
  */
24
37
  sea: THREE.Mesh | null;
38
+ set material(m: THREE.Material);
39
+ /**
40
+ * Water material, shared by all water. Reading gives the plain three.js material in use (a neutral MeshLambertMaterial until you set one); setting swaps it on every
41
+ * water mesh and draws it as given: no engine patch is added, so a material that should keep the waves goes through applyEffects(m, { patches: engine.water.patches })
42
+ * @type {Material}
43
+ */
44
+ get material(): THREE.Material;
45
+ /**
46
+ * Which GLSL the water has. Keys left out keep what an earlier call gave; null takes one back to the built-in. Refreshes engine.water.patches and engine.water.uniforms
47
+ * and patches the engine's own material again (one recompile). A game's material is the game's to patch again. uWave, uWaveScale, uWaveSpeed and uFresnel stay the same objects
48
+ * @example
49
+ * engine.water.shader({ depthColor: { shallow: 0x55ddcc, deep: 0x082040 }, foam: true });
50
+ * engine.water.shader({ uniforms: { uBands: 4 }, surface: `vec4 threedogWaterSurface(vec4 base, float wave, float facing, vec3 worldPos, float time) {
51
+ * return vec4(base.rgb * floor(facing * uBands) / uBands, base.a); }` });
52
+ * @param {WaterShaderOptions} [opts]
53
+ * @returns {void}
54
+ */
55
+ shader(opts?: WaterShaderOptions): void;
56
+ /**
57
+ * Normal map by asset name (null = none): a flat-normal placeholder until the asset loads, then it takes the asset's image source (shared, not copied; goes through asset
58
+ * management, so it can be preloaded and released). Goes on the engine's own material; a game's material takes the returned texture (also engine.water.normalTexture).
59
+ * The tiling and the scroll apply whatever material draws. Keys left out keep their value (defaults scale 0.4, repeat 0.05, speed [0.01, 0.006])
60
+ * @example
61
+ * engine.water.normalMap('water-n', { scale: 0.6, repeat: 0.1, speed: [0.02, 0.01] });
62
+ * @param {string | null} name
63
+ * @param {{ scale?: number, repeat?: number, speed?: [number, number] }} [opts] scale: strength; repeat: tiles per meter; speed: scroll [x, z] per second
64
+ * @returns {Texture | null}
65
+ */
66
+ normalMap(name: string | null, opts?: {
67
+ scale?: number;
68
+ repeat?: number;
69
+ speed?: [number, number];
70
+ }): THREE.Texture | null;
25
71
  }
26
72
  import type { WaterOptions } from '../../../world';
27
73
  import type { ModuleDef } from '../../../core';
28
74
  import * as THREE from 'three';
29
75
  import type { WaterBody } from '../../../world';
76
+ import type { WaterShaderOptions } from '../../../world';
@@ -1,11 +1,11 @@
1
1
  // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/weather/Weather.js (edit the JSDoc in the source, then run npm run map)
2
2
  /**
3
- * Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its look (engine.weatherLook, type 'look'; needs sky)
3
+ * Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture'; needs sky)
4
4
  * @param {WeatherOptions} [opts]
5
- * @returns {[ModuleDef<Weather>, ModuleDef<import('./weatherLook.js').WeatherLook>]}
5
+ * @returns {[ModuleDef<Weather>, ModuleDef<import('./weatherDraw.js').WeatherDraw>]}
6
6
  * @example engine.use(sky(), weather({ types: presets.weather.temperate.types, start: 'clear' }))
7
7
  */
8
- export function weather(opts?: WeatherOptions): [ModuleDef<Weather>, ModuleDef<import("./weatherLook.js").WeatherLook>];
8
+ export function weather(opts?: WeatherOptions): [ModuleDef<Weather>, ModuleDef<import("./weatherDraw.js").WeatherDraw>];
9
9
  /** engine.weather */
10
10
  export class Weather {
11
11
  /**
@@ -29,6 +29,33 @@ export class Weather {
29
29
  lightningFirst: number;
30
30
  /** [min, max] seconds between bolts while a type with lightning > 0.5 holds @type {number[]} */
31
31
  lightningInterval: number[];
32
+ /** Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount. Write it at any time @type {(flash: number, engine: any) => number} */
33
+ lightning: (flash: number, engine: any) => number;
34
+ /** Multiplies the sky flash of every strike; write it at any time @type {number} */
35
+ lightningBrightness: number;
36
+ /** Color the sky turns as a weather type raises grey: a THREE.Color, overcastColor.set(0x667788) changes it live @type {THREE.Color} */
37
+ overcastColor: THREE.Color;
38
+ /**
39
+ * The particle systems drawn now, by field: rain and snow when the table has them, plus what define() added. Each has material (the plain three.js
40
+ * material: read it, or set your own, drawn as given; null gives the engine's back), uniforms ({ value } objects the engine writes each frame, a
41
+ * ShaderMaterial of yours shares them; uColor, uLen, uPx, uMaxPx, uSwayAmp are yours to write), spec (opacity, speed, slant, density are read each
42
+ * frame, plain writes), object (the three.js object). Empty when a game replaced the weather drawing
43
+ * @example engine.weather.particles.rain.spec.speed = 30;
44
+ * @example engine.weather.particles.rain.uniforms.uColor.value.set(0xa8b8d0);
45
+ * @type {Record<string, WeatherParticleSystem>}
46
+ */
47
+ get particles(): Record<string, WeatherParticleSystem>;
48
+ /**
49
+ * Draw a field of the weather table with particles: your own (ash, petals, sparks) or rain / snow in place of the built-in ones. The amount each
50
+ * frame is weather.current[field], so they fade with the weather. spec takes the keys of weather({ rain }), or
51
+ * { create(engine, { area, count }) => { object, update?(amount, { camera, time, wind }) } } for a system of your own; null gives rain / snow back
52
+ * to weather({ rain, snow }) and removes any other field. Defining a field again replaces it. A field no type has throws with the table's fields
53
+ * @example engine.weather.define('ash', { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 });
54
+ * @param {string} field
55
+ * @param {WeatherParticles | null} spec
56
+ * @returns {WeatherParticleSystem | null}
57
+ */
58
+ define(field: string, spec: WeatherParticles | null): WeatherParticleSystem | null;
32
59
  /**
33
60
  * Automatic weather on/off
34
61
  * @param {boolean} on
@@ -58,4 +85,7 @@ export class Weather {
58
85
  import type { WeatherOptions } from '../../../world';
59
86
  import type { ModuleDef } from '../../../core';
60
87
  import type { WeatherPreset } from '../../../world';
88
+ import * as THREE from 'three';
89
+ import type { WeatherParticleSystem } from '../../../world';
90
+ import type { WeatherParticles } from '../../../world';
61
91
  import type { WeatherName } from '../../../world';
@@ -0,0 +1,11 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/weather/weatherDraw.js (edit the JSDoc in the source, then run npm run map)
2
+
3
+ /** engine.weatherDraw: particles and picture effects of the current weather */
4
+ export class WeatherDraw {
5
+ /** Sky flash now, 1 at a strike (the weather:lightning event) fading to 0 @type {number} */
6
+ flash: number;
7
+ /** Default particle count per system (halved on low-tier devices) @type {number} */
8
+ particles: number;
9
+ /** Particle systems drawn now: field -> { field, object, material, uniforms, spec } (rain / snow when the table has them, plus fields engine.weather.define adds) @type {Map<string, any>} */
10
+ systems: Map<string, any>;
11
+ }
@@ -151,14 +151,14 @@ export class World {
151
151
  * focus, teleport destination) and torn down when far from all of them (radius × 1.25); tearing down never touches the record. Callbacks:
152
152
  * build(rec) → three.js object (may be async). world adds it to the scene and places it at rec.position; if it throws / fails / returns a non-object:
153
153
  * reported once, does not block ready, retried when you leave and come back.
154
- * update(rec, obj, dt): called every frame for records that have a model (change the look from the data, e.g. an opened chest swaps texture).
154
+ * update(rec, obj, dt): called every frame for records that have a model (change the picture from the data, e.g. an opened chest swaps texture).
155
155
  * dispose(rec, obj): called on teardown (record first, model second); if omitted, engine.remove(obj).
156
156
  * show(rec) → false: this record has no model right now (picked up, waiting to respawn); re-evaluated when world.set changes records of this kind.
157
157
  * radius: meters, or a function (for distances that change, like terrain view distance); defaults to world.radius. Registering the same kind again: old
158
158
  * models are torn down with the old dispose and rebuilt with the new one.
159
159
  * positionFrom: 'record' (default, the model follows the record every frame) or 'view' (the model moves itself, e.g. driven by a character mover; model
160
160
  * position is copied back to the record at the end of each fixed step).
161
- * @example engine.world.present('chest', { build: rec => new THREE.Mesh(boxGeo, makeMaterial('prop')), dispose: (rec, obj) => engine.remove(obj), show: rec
161
+ * @example engine.world.present('chest', { build: rec => new THREE.Mesh(boxGeo, new THREE.MeshStandardMaterial()), dispose: (rec, obj) => engine.remove(obj), show: rec
162
162
  * => !rec.looted })
163
163
  * @param {string} kind
164
164
  * @param {{ build: (rec: WorldRecord) => any, update?: (rec: WorldRecord, obj: any, dt: number) => void, dispose?: (rec: WorldRecord, obj: any) => void,
@@ -14,8 +14,8 @@ export class PostFX {
14
14
  /**
15
15
  * The three.js EffectComposer the chain runs in, for reading (pass list, sizes, its targets), or null while no post work has run yet (built
16
16
  * the first time an effect or MSAA is on; it is not built here, so asking never costs a half-float target). Read-only by rule, not by lock:
17
- * the engine owns it, rebuilds composer.passes whenever the chain changes and disposes it with the engine. To add a pass use look.post.add,
18
- * to own the whole chain look.post.replace (recipe 52). Why public: a game reading the chain had to dig into an internal field (review 2026-11-03)
17
+ * the engine owns it, rebuilds composer.passes whenever the chain changes and disposes it with the engine. To add a pass use post.add,
18
+ * to own the whole chain post.own() (recipe 52). Why public: a game reading the chain had to dig into an internal field (review 2026-11-03)
19
19
  * @returns {any}
20
20
  */
21
21
  object(): any;
@@ -36,14 +36,40 @@ export class PostFX {
36
36
  writeBuffer: any;
37
37
  } | null;
38
38
  /**
39
- * Read-only record of an added effect (name, slot, order, enabled, params), or undefined. Change one with engine.look.post.set({ 'bloom.strength': 0.6 })
39
+ * The one way to add a post effect. x is a three.js Pass (WebGL), a TSL node function (input, ctx) => node (WebGPU), or an effect
40
+ * { name, create | node | fuse, slot, order, params, needsDepth, needsBuffers, backend, skipOnLowTier, facts } (both renderers when it gives create and node, or a fuse). A wrong shape throws with nothing added.
41
+ * needsDepth, needsBuffers ('normal' | 'diffuse' | 'velocity', WebGPU), backend ('webgpu': not on the WebGL2 backend), skipOnLowTier (held when engine.tier is 'low') and facts (shown by describe().render.post) are explained on PostEffect.
42
+ * A Pass that draws engine.scene takes the 'scene' slot, FXAA / SMAA / TAA 'final', any other 'hdr' after the effects already there, or 'ldr' once an
43
+ * OutputPass was added. A RenderPass of engine.scene and an OutputPass are the engine's own stages: skipped and said once (an OutputPass still marks where display color starts).
44
+ * @example const glow = engine.post.add(new UnrealBloomPass(size, 0.6, 0.4, 0.85), { name: 'glow' }); glow.enabled = false;
45
+ * @example engine.post.add({ name: 'dim', fuse: { glsl: 'color.rgb *= 0.9;' }, slot: 'ldr' });
46
+ * @param {any} x @param {{ name?: string, slot?: PostSlot | (string & {}), order?: number }} [o]
47
+ * @returns {PostHandle}
48
+ */
49
+ add(x: any, o?: {
50
+ name?: string;
51
+ slot?: PostSlot | (string & {});
52
+ order?: number;
53
+ }): PostHandle;
54
+ /**
55
+ * An added effect's handle (as add() returns it), or undefined.
56
+ * @example engine.post.get('bloom').set({ strength: 0.6 });
40
57
  * @param {string} name
41
58
  * @returns {PostHandle | undefined}
42
59
  * @experimental
43
60
  */
44
61
  get(name: string): PostHandle | undefined;
45
62
  /**
46
- * Turn MSAA on or off. It is a render setting, not a look part. With no effect on, the start value is the canvas's own MSAA (free: no
63
+ * Hand the built chain to the game: the engine stops rebuilding it, so the composer's passes (post.object().passes) or the WebGPU pipeline's
64
+ * outputNode are the game's to edit. own(false) gives it back and rebuilds from the list. describe().owned shows who has it.
65
+ * @example engine.post.own(); engine.post.object().passes.reverse();
66
+ * @param {boolean} [on]
67
+ * @returns {void}
68
+ * @experimental
69
+ */
70
+ own(on?: boolean): void;
71
+ /**
72
+ * Turn MSAA on or off. It is a render setting, not a drawing part. With no effect on, the start value is the canvas's own MSAA (free: no
47
73
  * post chain); the other value, and any effect, draws through the chain, whose render targets carry the MSAA.
48
74
  * @example engine.post.setAntialias(false);
49
75
  * @param {boolean} on
@@ -105,9 +131,10 @@ export type PostFuse = {
105
131
  reads?: boolean;
106
132
  };
107
133
  /**
108
- * WebGPU only. scenePass: the scene's pass() node (.getTextureNode('depth'), getViewZNode() ...); tsl: three/tsl; display: three's display nodes
109
- * (bloom, ao from three/addons/tsl/display) plus pass (an extra scene render) and texture (the color so far as a texture to sample at other uvs),
110
- * handed in so effect packages never import three/webgpu themselves and so the nodes they make are disposed with the chain;
134
+ * WebGPU only. scenePass: the scene's pass() node (.getTextureNode('depth'), getViewZNode() ...; .getTextureNode('normal' | 'diffuse' | 'velocity')
135
+ * when an effect that is on says so in needsBuffers); tsl: three/tsl; display: three's display nodes (bloom, ao from three/addons/tsl/display) plus
136
+ * pass (an extra scene render), texture (the color so far as a texture to sample at other uvs) and own (a node the effect made itself, disposed with the chain),
137
+ * handed in so the main entry of an effect package never imports three/webgpu (its /tsl subpath may, a WebGL game never loads that) and so the nodes they make are disposed with the chain;
111
138
  * p: live uniform nodes of the number / color params (as in PostFuse tsl), so set() of those never rebuilds the pipeline; a param read from
112
139
  * ctx.params while node() runs is a constant in the graph, so set() of it rebuilds the chain (as WebGL rebuilds an effect without update()).
113
140
  */
@@ -132,11 +159,17 @@ export type PostNodeContext = {
132
159
  * slot: a PostSlot; typed as any string too because a slot in a plain JS object (an effect returned from a function) is a string to
133
160
  * TypeScript, and the chain throws on an unknown slot naming the valid ones.
134
161
  * order: position inside the slot, low first; ties keep the order the names were first added in (a name keeps that place when it is
135
- * switched off and on, or a plugin is unplugged and plugged again: look.post.set({ name: false }) pauses it in place). costly: off by default on low-tier devices.
162
+ * switched off and on, or a plugin is unplugged and plugged again: handle.enabled = false pauses it in place).
136
163
  * needsDepth: the scene's depth texture is kept for it (readBuffer.depthTexture). Only the buffer the scene render wrote holds
137
164
  * scene depth, so a depth reader must run before any pass that swaps buffers (needsSwap, e.g. a ShaderPass, a scene-slot
138
165
  * RenderPixelatedPass, or the tone-mapping output); the chain throws when it would not. A pass that writes the scene depth into its own output (gl_FragDepth, then set pass.keepsDepth = true; dof does) does not count as a swap. update: apply new params in place;
139
166
  * without it set() rebuilds the implementation.
167
+ * needsBuffers (WebGPU): extra outputs of the one scene render, merged across every effect that is on, so two effects never overwrite each other's setMRT:
168
+ * 'normal' (view space, raw), 'diffuse' (surface color), 'velocity' (a temporal resolve follows, so the scene pass runs without MSAA).
169
+ * backend: 'webgpu' = needs three's WebGPU backend itself (storage textures; WebGPURenderer on its WebGL2 backend cannot run it, so it is held there).
170
+ * skipOnLowTier: the effect's own statement that engine.tier 'low' is too weak for it. The rule: an effect declares this itself and the engine only follows the declaration; no list of
171
+ * expensive effects lives in the engine, and an effect that does not declare it runs on every tier. A held effect costs nothing, describe().render.post says why in `held`, the console says it once; the game's enabled stays as written.
172
+ * facts: read by describe().render.post (a voxel size, what the effect still misses).
140
173
  */
141
174
  export type PostEffect = {
142
175
  name: string;
@@ -146,17 +179,27 @@ export type PostEffect = {
146
179
  slot?: PostSlot | (string & {});
147
180
  order?: number;
148
181
  enabled?: boolean;
149
- costly?: boolean;
150
182
  needsDepth?: boolean;
183
+ needsBuffers?: ("normal" | "diffuse" | "velocity")[];
184
+ backend?: "webgpu";
185
+ skipOnLowTier?: boolean;
186
+ facts?: () => Record<string, any> | null;
151
187
  params?: Record<string, any>;
152
188
  update?: (impl: any, params: Record<string, any>) => void;
153
189
  };
190
+ /**
191
+ * What add() and get() return. enabled reads what runs now; writing it is the game's choice on the shared point post.<name>.enabled, so a settings
192
+ * restriction above it still holds it off. set: params by name, unknown names throw. remove: takes it out of the chain (a game's own Pass is not disposed).
193
+ * A RenderPass or OutputPass handed to add() gives { name: null, ... }: the engine's own stages stand in for them, so only remove() does anything.
194
+ */
154
195
  export type PostHandle = {
155
196
  readonly name: string;
156
197
  readonly slot: PostSlot;
157
198
  readonly order: number;
158
- readonly enabled: boolean;
199
+ enabled: boolean;
159
200
  readonly params: Record<string, any>;
201
+ set(params: Record<string, any>): void;
202
+ remove(): void;
160
203
  };
161
204
  import type { Engine } from '../../core';
162
205
  import * as THREE from 'three';
@@ -0,0 +1,29 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/render/lighting.js (edit the JSDoc in the source, then run npm run map)
2
+
3
+ /**
4
+ * The gradientMap of a toon material from `ramp` (grays or colors, dark to light) and `soften` (0 = hard bands, 1 = bands melt into each other).
5
+ * A gray number n is the light's strength in that band. three's toon reads only the red channel of this texture on both renderers; color entries
6
+ * tint the band under `celLighting` of threedog/tsl (WebGPU route).
7
+ * @example new THREE.MeshToonMaterial({ color: 0x8aa0b0, gradientMap: rampTexture([0.35, 0.7, 1], 0.2) });
8
+ * @param {(number | import('../../common').ColorLike)[]} ramp
9
+ * @param {number} [soften]
10
+ * @returns {THREE.DataTexture}
11
+ */
12
+ export function rampTexture(ramp: (number | import("../../common").ColorLike)[], soften?: number): THREE.DataTexture;
13
+ export type LightingOptions = {
14
+ wrap?: number;
15
+ shadowTint?: {
16
+ color: import("../../common").ColorLike;
17
+ strength?: number;
18
+ soft?: number;
19
+ };
20
+ rim?: {
21
+ color: import("../../common").ColorLike;
22
+ strength?: number;
23
+ power?: number;
24
+ shadowSide?: number;
25
+ };
26
+ glsl?: string;
27
+ uniforms?: Record<string, any>;
28
+ };
29
+ import * as THREE from 'three';
@@ -1,34 +1,11 @@
1
1
  // Generated by npm run map, do not edit by hand. Source: packages/engine/render/materials.js (edit the JSDoc in the source, then run npm run map)
2
2
 
3
- /**
4
- * Create a material by role: makeMaterial('furniture', { color: 0x8a5a36 }); the look comes from look.materials for that role, whose style layer is the
5
- * style's materials table and whose game layer is look.materials.set / replace (unlisted roles use the 'default' role).
6
- * Roles the engine uses: default terrain vegetation character water pickup prop (MATERIAL_PURPOSES); a game may pick new names (e.g. 'building'),
7
- * and a name close to an existing role ('props', 'charcter') warns in dev.
8
- * A style entry has one of three forms; params are then applied to the result (keys the material lacks are skipped):
9
- * @example
10
- * materials: {
11
- * default: { type: 'toon', steps: 3 }, // spec: type lambert | phong | standard | physical | toon | basic, plus properties
12
- * water: new THREE.MeshMatcapMaterial({ matcap: tex }), // instance: cloned on every call
13
- * prop: (params, purpose, engine) => new THREE.ShaderMaterial({ ... }), // function: returns any three.js Material
14
- * }
15
- * A pack Material instance is cloned with its shader patches (applyEffects) kept.
16
- * Whose style decides: engine.makeMaterial(purpose, params) (this engine's) or the third argument; without either the first live engine's
17
- * (fine for a one-engine game; engine code and styles always pass the engine, and two engines on the page warn in dev).
18
- * @param {string} [purpose]
19
- * @param {import('../../style').MaterialSpec} [params] spec keys (type, steps, ramp, soften, repeat, wrap, detail, lighting) as in style.materials, plus any material property
20
- * @param {{ style: any }} [engine]
21
- * @returns {Material}
22
- */
23
- export function makeMaterial(purpose?: string, params?: import("../../style").MaterialSpec, engine?: {
24
- style: any;
25
- }): THREE.Material;
26
- /** @param {{ glsl?: string, uniforms?: Record<string, any>, tsl?: (ctx: any) => any }} sway */
3
+ /** @param {{ glsl?: string, uniforms?: Record<string, any>, tsl?: (ctx: any) => any }} sway @param {boolean} [gpu] the engine draws with WebGPURenderer; left out: unknown */
27
4
  export function windCustom({ glsl, uniforms, tsl }: {
28
5
  glsl?: string;
29
6
  uniforms?: Record<string, any>;
30
7
  tsl?: (ctx: any) => any;
31
- }): {
8
+ }, gpu?: boolean): {
32
9
  uniforms: Record<string, {
33
10
  value: any;
34
11
  }>;
@@ -37,23 +14,25 @@ export function windCustom({ glsl, uniforms, tsl }: {
37
14
  tsl: (ctx: any) => any;
38
15
  };
39
16
  /**
40
- * Add effects to any material (built-in, from a style, or third-party); returns the same material. The one entry for shader effects:
17
+ * Add effects to any material (the engine's or your own); returns the same material. The one entry for shader effects:
41
18
  * wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is
42
- * style.clouds.shadow), season ('foliage' | 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in
43
- * render/patches.js), detail (grain / paper / strokes / a texture over the surface, see MaterialDetail in types/style.d.ts; a texture given by
44
- * asset name loads from `engine`, default the first live engine). The 'world' patch (varying vThreedogWorld, world position) comes with clouds, and is added for any of your
19
+ * engine.uniforms.uCloudShadow), season ('foliage' | 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in
20
+ * render/patches.js), detail (grain / paper / strokes / a texture over the surface, see DetailOptions in render/detail.js; a texture given by
21
+ * asset name loads from `engine`, default the first live engine), lighting (light shaping: { wrap, shadowTint, rim }, or your own { glsl, uniforms };
22
+ * see LightingOptions in render/lighting.js; materials with the same options share one program). The 'world' patch (varying vThreedogWorld, world position) comes with clouds, and is added for any of your
45
23
  * patches that lists it in needs.patches or reads vThreedogWorld (a one-time dev note asks for the needs line).
46
24
  * Built-in effects the material cannot take (MeshBasicMaterial has no lighting chunk for clouds) are skipped with a one-time warning;
47
- * your own patches throw when their anchor is missing. Calling again with the same effect replaces it.
25
+ * detail, lighting and your own patches throw when their anchor is missing. Calling again with the same effect replaces it.
48
26
  * @example
49
27
  * applyEffects(new THREE.MeshToonMaterial({ color: 0x5a8a3a }), { wind: 0.03, season: 'foliage' });
28
+ * applyEffects(new THREE.MeshLambertMaterial({ color: 0xb0a080 }), { lighting: { wrap: 0.4, rim: { color: 0xffe0b0, strength: 0.3 } } });
50
29
  * applyEffects(mat, { clouds: false, patches: [{ name: 'snap', cacheKey: 64, uniforms: { uGrid: { value: 64 } },
51
30
  * slot: 'clipPosition', pars: 'uniform float uGrid;', glsl: 'gl_Position.xy = floor(gl_Position.xy / gl_Position.w * uGrid) / uGrid * gl_Position.w;' }] });
52
31
  * @param {Material} material
53
- * @param {{ wind?: number | { amplitude: number, glsl?: string, uniforms?: Record<string, any>, tsl?: (ctx: any) => any }, clouds?: boolean, season?: 'foliage' | 'ground', detail?: import('../../../render/detail').DetailOptions, engine?: { assets: any }, patches?: import('./patches.js').ShaderPatch[] }} [opts]
32
+ * @param {{ wind?: number | { amplitude: number, glsl?: string, uniforms?: Record<string, any>, tsl?: (ctx: any) => any }, clouds?: boolean, season?: 'foliage' | 'ground', detail?: import('../../../render/detail').DetailOptions, lighting?: import('./lighting.js').LightingOptions, engine?: { assets: any }, patches?: import('./patches.js').ShaderPatch[] }} [opts]
54
33
  * @returns {Material}
55
34
  */
56
- export function applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: {
35
+ export function applyEffects(material: THREE.Material, { wind, clouds, season, detail, lighting, engine, patches }?: {
57
36
  wind?: number | {
58
37
  amplitude: number;
59
38
  glsl?: string;
@@ -63,25 +42,26 @@ export function applyEffects(material: THREE.Material, { wind, clouds, season, d
63
42
  clouds?: boolean;
64
43
  season?: "foliage" | "ground";
65
44
  detail?: import("../../../render/detail").DetailOptions;
45
+ lighting?: import("./lighting.js").LightingOptions;
66
46
  engine?: {
67
47
  assets: any;
68
48
  };
69
49
  patches?: import("./patches.js").ShaderPatch[];
70
50
  }): THREE.Material;
71
51
  /**
72
- * Terrain material: base (default the style's 'terrain' role with vertex colors) + cloud shadows + season tint + optional detail texture
73
- * (style.terrain.detail). Pass the engine so its style and assets are used. effects: false returns your base as is (no engine patch at
74
- * all, the vegetation.define({ effects: false }) word): look.ground.replace(myMaterial, { effects: false }).
52
+ * Terrain material: base (default neutral with vertex colors) + cloud shadows + season tint + optional detail layer (detail: see DetailOptions; defaults scale 0.25,
53
+ * strength 0.35, top-down world projection, multiply). Pass the engine so its assets load a detail texture by name. effects: false returns your base as is
54
+ * (no engine patch at all, the vegetation.define({ effects: false }) word).
75
55
  * @param {Material | null} [base]
76
- * @param {{ style: any, assets: any }} [engine]
77
- * @param {{ effects?: boolean }} [o]
56
+ * @param {{ assets: any }} [engine]
57
+ * @param {{ effects?: boolean, detail?: import('../../../render/detail').DetailOptions | null }} [o]
78
58
  * @returns {Material}
79
59
  */
80
60
  export function terrainMaterial(base?: THREE.Material | null, engine?: {
81
- style: any;
82
61
  assets: any;
83
- }, { effects }?: {
62
+ }, { effects, detail }?: {
84
63
  effects?: boolean;
64
+ detail?: import("../../../render/detail").DetailOptions | null;
85
65
  }): THREE.Material;
86
66
  /**
87
67
  * Merge several geometries into one vertex-colored geometry (a tree = trunk + canopy in one draw call): [[geometry, color], ...].
@@ -97,10 +77,5 @@ export function terrainMaterial(base?: THREE.Material | null, engine?: {
97
77
  export function mergeColored(parts: [THREE.BufferGeometry, ColorLike][], { flat }?: {
98
78
  flat?: boolean;
99
79
  }): THREE.BufferGeometry;
100
- /**
101
- * Material roles the engine itself uses
102
- * @type {string[]}
103
- */
104
- export const MATERIAL_PURPOSES: string[];
105
80
  import * as THREE from 'three';
106
81
  import type { ColorLike } from '../../common';
@@ -0,0 +1,13 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/render/occlusion.js (edit the JSDoc in the source, then run npm run map)
2
+ export class Occlusion {
3
+ set enabled(v: boolean);
4
+ /** Occlusion culling of hlod cells and batched groups; describe().render.occlusion says what it saved @returns {boolean} */
5
+ get enabled(): boolean;
6
+ /** What it does now: { watched, hidden, trianglesSkipped } (items, items hidden this frame, triangles not drawn this frame) */
7
+ get stats(): {
8
+ watched: number;
9
+ hidden: number;
10
+ trianglesSkipped: number;
11
+ };
12
+ }
13
+ import * as THREE from 'three';
@@ -19,7 +19,7 @@ export interface CollisionOptions {
19
19
  cameraMin?: number;
20
20
  /** Height above the water surface (meters) at which it counts as walkable, default 0.2 */
21
21
  walkableWaterMargin?: number;
22
- /** What camera occlusion checks: 'colliders' (default) | 'meshes' registered static meshes (engine.rays) | 'both' */
22
+ /** What camera occlusion checks: 'both' (default) | 'colliders' | 'meshes' = static meshes registered with engine.rays.addStatic(mesh, { occluder: true }) */
23
23
  cameraOcclusion?: 'colliders' | 'meshes' | 'both';
24
24
  }
25
25
  /** Circle collider: center x/z, radius r, height h (meters), occ false when added with occluder: false */
@@ -73,7 +73,7 @@ export interface Collision {
73
73
  addBox(position: PositionLike, opts?: BoxColliderOptions): Handle;
74
74
  /** Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y, occluder (as in addBox). A gap between segments is a gate. Returns a handle { remove() } */
75
75
  addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?: number; height?: number; y?: number; occluder?: boolean }): Handle;
76
- /** Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds { minX, maxX, minZ, maxZ } (world metres, the field's x / z extent) skips fn outside it; give it to keep findPathAsync's ground sampling cheap. Returns a handle { remove() } */
76
+ /** Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure (no side effects, same answer for the same (x, z)); reading engine.ground in it is fine. findPathAsync caches the answers, so after the ground or your own state changes, remove() and add the field again. bounds { minX, maxX, minZ, maxZ } (world metres, the field's x / z extent) skips fn outside it; give it to keep findPathAsync's ground sampling cheap. Returns a handle { remove() } */
77
77
  addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds?: { minX: number; maxX: number; minZ: number; maxZ: number } }): Handle;
78
78
  /** Is a character of this radius touching addBlocked ground at (x, z) */
79
79
  blockedAt(x: number, z: number, radius?: number): boolean;
@@ -335,7 +335,7 @@ export interface AnimatorInfo {
335
335
  }
336
336
  /** Animation state machine parameters */
337
337
  export interface AnimatorOptions {
338
- /** Default transition seconds, default 0.25 (style.character.animation.fade) */
338
+ /** Default transition seconds, default 0.25 (characters({ animation: { fade } }) for every character) */
339
339
  fade?: number;
340
340
  /** States: name → state */
341
341
  states?: Record<string, AnimatorState>;
@@ -347,6 +347,8 @@ export interface AnimatorOptions {
347
347
  /** Skeletal animation state machine (returned by engine.assets.animate(model, config)) */
348
348
  export declare class Animator {
349
349
  constructor(engine: Engine, root: Object3D, opts?: AnimatorOptions);
350
+ /** The animated object */
351
+ root: Object3D;
350
352
  /** three.js AnimationMixer */
351
353
  mixer: any;
352
354
  /** clip name → three.js AnimationAction */
package/types/tsl.d.ts CHANGED
@@ -68,6 +68,14 @@ export function shadowTint(ambient: Node, tint: Node, strength: Node | number, s
68
68
  * (viewDir from the surface to the eye, e.g. normalView and positionViewDirection); shadowSide 1 = only on the side facing away from the sun.
69
69
  */
70
70
  export function rim(normal: Node, viewDir: Node, color: Node, strength: Node | number, power: Node | number, shadowSide: Node | number, nl: Node): Node;
71
+ /**
72
+ * The lighting model for cel bands with colored ramps: assign it to a MeshToonNodeMaterial, whose gradientMap holds the ramp (rampTexture). A shadowed pixel reads the
73
+ * dark end of the ramp, so a cast shadow takes the same flat band and color as the side turned away. Without a gradientMap: two levels, as three's toon.
74
+ * @example
75
+ * const mat = new MeshToonNodeMaterial({ color: 0xe08050, gradientMap: rampTexture([0x4a5a9a, 0xc0c8e0, 0xffffff]) });
76
+ * mat.setupLightingModel = celLighting;
77
+ */
78
+ export function celLighting(): import('three/webgpu').LightingModel;
71
79
  /**
72
80
  * GLSL float threedogWaterWave(vec3 p, float t): the built-in wave sum (height before waveHeight). p = world position * waveScale, t = time * waveSpeed.
73
81
  * @example