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
@@ -215,7 +215,7 @@ plugins all call it, so each effect has a name, an owner and on / off with `look
215
215
 
216
216
  Every `engine.look.<part>` has the same verbs: `set` (values), `patch(hook, code)` (swap one named hook; nothing else), `add` (one more named
217
217
  thing: `look.post.add`, `look.materials.add`), `replace(thing)` (the one three.js thing the part draws), `manual(keys)`, and one read, `value(key)`.
218
- A whole module is still `engine.use(mine(), { replaces: '<slot>' })`. Plan: `docs/plans/2026-11-03-look-api.md`.
218
+ A whole module is still `engine.use(mine(), { replaces: '<slot>' })`.
219
219
 
220
220
  | Before | Now |
221
221
  |---|---|
@@ -225,4 +225,96 @@ A whole module is still `engine.use(mine(), { replaces: '<slot>' })`. Plan: `doc
225
225
  | `look.<part>.clear(owner)` (typed, never there) | drop the handle `set()` returned: `h.remove()` |
226
226
  | writer `manual:look.fog.replace` in `describe().owned` | `three (engine yielded)` |
227
227
 
228
+ - *silent*: `collide: 'circle'` on a prop or template measures the model's base, not its widest extent, so trees and lamps block much less (a pine: 1.51 m -> 0.30 m). A row of such props that worked as a fence may now let the player through: write `collide: { circle: <radius> }` on it, or use `engine.collision.addSegment`.
229
+ - *loud*: a `collide` other than `false`, `'box'`, `'circle'` or `{ circle, occluder? }` throws at load (`collide: true` used to mean a box: write `'box'`).
228
230
  - *silent*: `engine.catalog(...).verbs` lists a part's own named verbs too (`post`: `add`, `materials`: `add`, `glow`, `shadow`: `include`).
231
+
232
+ ## Style tools become picture tools
233
+
234
+ - `threedog style check` → gone with style packs: a look is plain three.js in `look/`, and `npm run check` type-checks it.
235
+ - `threedog style palette | compare` → `threedog picture palette | compare`; bridge commands `style-palette`, `style-compare` → `picture-palette`, `picture-compare`; MCP tools `style_palette`, `style_compare` → `picture_palette`, `picture_compare`. Options and output are unchanged.
236
+ - `npm run check` no longer runs R34 (a game's `style/` folder).
237
+ ## Module looks: options and materials
238
+
239
+ - `material spec { lighting: { rim, wrap, shadowTint } }` → a plain patch in the `lighting` slot through `applyEffects` (recipe 43); toon `ramp` → three.js `gradientMap` (recipe 09 §1).
240
+ - `createEngine({ style: { ui: { bg, accent, css, fonts, templates } } })` → `createEngine({ ui: { theme: { bg, accent }, css, fonts, templates } })`.
241
+ - *silent*: `style.ui.promptHeight` → `interactions({ promptHeight })`; `ui.theme.promptHeight` `[ui-misuse]`.
242
+ - `ui: { bg: '#123' }` (a color beside the part names) `[ui-misuse]` → `ui: { theme: { bg: '#123' } }`.
243
+ - *silent*: `style.pickup: { color, size, lift }` → `pickups({ color, size, lift })`; the `pickup` material role → `engine.pickups.material`.
244
+ - *silent*: `style.character.animation` → `characters({ animation })`; the capsule's `character` material role → `engine.characters.material`.
245
+ - *silent*: `style.triggers: { debugColor, debugOpacity }` → `triggers({ debugColor, debugOpacity })`.
246
+ - *silent*: `style.palette` → `engine.assets.palette` (plain object; `this.palette` in generators and the cache key read it). A baked file no longer stands in for a generator while a palette is set, unless it is `source: 'file'`.
247
+ - *silent*: a cached or baked model's material comes back as recorded, not rebuilt from the current material role; a toon `gradientMap` now counts as lost in the GLB (`{ build, cache: false }`). `assets.report()` `madeByStyle` → `madeByEngine`; `materialInfo` `from` is `'engine' | 'game'` and `keys` is gone.
248
+ - *silent*: `style.grid: { ok, bad, previewOpacity, previewHeight, tiles, tileLift }` → `grids({ ... })`, same keys; the `decal` role → `pv.material`, `layer.material`.
249
+ ## The ground's look is plain three.js on the module
250
+
251
+ - `style.terrain.colors | biomeColors | steep | variation | detail`, the look keys of `style.terrain.config` → `terrain({ colors, biomeColors, steep, variation, detail, shading, colorResolution, normals, normalFn })`.
252
+ - `look.ground.set({ colors | biomeColors | steep | variation | shading | normals | detail })` → `engine.terrain.recolor({ ... })`; each value is given whole, `null` takes it out.
253
+ - `look.ground.replace(m)`, `style.terrain.material` → `engine.terrain.material = m`, drawn as given; `applyEffects(m, { patches: engine.terrain.patches })` keeps cloud shadow, season and detail.
254
+ - `look.ground.replace(m, { effects: false })` → `engine.terrain.material = m`, or `terrain({ material: m, effects: false })`.
255
+ - `engine.terrainLook.setMaterial(m)` → `engine.terrain.material = m`.
256
+ - *silent*: `style.terrain` is no longer read, and the default ground is the plain neutral material whatever `style.materials` says.
257
+
258
+ ## The water's look is plain three.js on the module
259
+
260
+ - `look.water.set({ color | opacity })`, `style.water.color | opacity`, `style.materials.water` → `engine.water.material.color.set(...)`, `engine.water.material.opacity = ...`.
261
+ - `look.water.set({ waveHeight | waveScale | waveSpeed | fresnel })`, `style.water.*` → `engine.water.uniforms.uWave | uWaveScale | uWaveSpeed | uFresnel.value = ...`.
262
+ - `look.water.set({ depthColor | foam })`, `style.water.depthColor | foam`, `look.water.patch('wave' | 'surface', glsl)`, `water({ uniforms })` → `engine.water.shader({ depthColor, foam, wave, surface, uniforms })`.
263
+ - `look.water.set({ normalMap | normalScale | normalRepeat | normalSpeed })` → `engine.water.normalMap(name, { scale, repeat, speed })`; the texture field `engine.water.normalMap` → `engine.water.normalTexture`.
264
+ - `look.water.set({ shininess | specular })` → your own `MeshPhongMaterial` through `engine.water.material`.
265
+ - `look.water.replace((engine, { uniforms, waves, surface, normalMap }) => m)`, `style.water.material` → `engine.water.material = m`; the four are `engine.water.uniforms`, `.patches` (by `name`), `.normalTexture`.
266
+ - *silent*: `style.water` is no longer read, and the default water is the plain neutral Lambert whatever `style.materials` says.
267
+ ## Plants take plain materials (2026-11-04)
268
+ - `look.wind.set({ frequency, amplitude })` → `engine.uniforms.uWindFreq.value`, `engine.uniforms.uWindAmp.value`.
269
+ - `look.wind.patch('sway', spec)` → `engine.vegetation.sway(spec)` (now reaches planted species too).
270
+ - `look.vegetation.patch('color', spec)` → `engine.vegetation.color(spec)`.
271
+ - `makeMaterial('vegetation')` default → neutral gray; `engine.vegetation.material = myMaterial` for all, `vegetation.define(name, { material })` for one.
272
+
273
+ ## Weather looks are options and plain writes (2026-11-04)
274
+ - `style.weather.rain / snow / area / lightning / lightningBrightness / overcastColor` → the same keys on `weather({ ... })`. `style.weather.snow.cover` → `weather({ snow: { cover } })`.
275
+ - `style.weather.types` → removed; write the numbers in `weather({ types })`.
276
+ - `look.weather.replace({ field: spec })` → `engine.weather.define(field, spec)`; `null` as spec gives the field back.
277
+ - `look.weather.set({ 'rain.speed', 'rain.opacity', 'rain.slant' })` → `engine.weather.particles.rain.spec.speed = 30` (live, no rebuild).
278
+ - `look.weather.set({ 'rain.color', 'rain.length', 'snow.size', 'snow.sway' })` → `engine.weather.particles.rain.uniforms.uColor.value.set(...)`, `uLen`, `uPx`, `uSwayAmp`.
279
+ - `look.weather.set({ 'lightning.brightness', overcastColor })` → `engine.weather.lightningBrightness = 0.5`, `engine.weather.overcastColor.set(...)`.
280
+ - `style.particles.<name>`, `style.particles.default` → `particles({ effects: { name: spec }, default: spec })`; `fx.material` is get / set, `fx.uniforms` holds the `{ value }` objects.
281
+ - `look.weather.patch('rain.fragment', text)` → `engine.weather.define('rain', { glsl: { fragment: text } })`, or set `engine.weather.particles.rain.material`.
282
+
283
+ ## The dev panel writes three.js directly (2026-11-04)
284
+
285
+ - `openPanel(engine, { overrides })` and `?ov=` → `openPanel(engine)`; "apply and rebuild" and "export overrides" are gone, values are written live and saved with "write back".
286
+ - `engine.styleWorkbench` → `engine.devPanel` (`{ pane, tune }`); `describe().stylePanel` → `describe().devPanel`.
287
+ - The panel's environment switch only turns on and off a `scene.environment` that is already there; making one is the game's call.
288
+ - Panel multipliers for sun, ambient and fog → each light's `intensity` and `scene.fog` near / far / density.
289
+ - The `threedog tune` block: `engine.look.<part>.set(...)` and `tunedStyle` → plain writes (`engine.scene.fog.far = 90;`, `engine.water.material.color.set(0x3388aa);`). A `.threedog/tune.json` saved before this: press "write back" again.
290
+
291
+ ## Materials are plain three.js (2026-11-04)
292
+
293
+ - `makeMaterial('role', { color })`, `engine.makeMaterial` → `new THREE.MeshLambertMaterial({ color })` (any three.js material) in your `look/` code; `MATERIAL_PURPOSES` is gone with the roles.
294
+ - `look.materials.set({ role: { key } })`, `look.materials.replace(role, mat)`, `look.materials.object(role)`, `look.materials.rebuild()` → write your own material objects; a module's material is `engine.<module>.material`.
295
+ - `look.materials.add(name, patch, { roles })` → `applyEffects(material, { patches: [patch] })`.
296
+ - Spec keys `type`, `steps`, `ramp`, `soften` → `new THREE.MeshToonMaterial({ gradientMap: rampTexture(ramp, soften) })`.
297
+ - Spec keys `map: 'name'`, `repeat`, `wrap` → `engine.assets.useTexture(name, t => { mat.map = t; })`, then `t.repeat` and `t.wrapS`.
298
+ - `look.surface.set({ lighting })`, `style.lighting`, spec key `lighting`, `look.surface.patch('lighting', glsl)` → `applyEffects(mat, { lighting: { wrap, shadowTint, rim } })` or `{ lighting: { glsl } }`, per material.
299
+ - `look.surface.set({ detail })`, spec key `detail`, `look.surface.patch('detail', glsl)` → `applyEffects(mat, { detail })`, with `detail: { glsl }`.
300
+ - `look.surface.set({ ramp, soften })` → `rampTexture(ramp, soften)` on each toon material.
301
+ - `look.materials.glow(match, { night, day, dusk })` → `mat.emissiveIntensity` from `engine.uniforms.uNight` in your frame code (recipe 09 "Night glow").
302
+ - A Material or a ShaderPatch in `plugins/` → put it on its mesh or module in `look/`; `plugins.off / on` lost `{ rebuild }`, and `reach` / `rebuilt` are gone from their results and from `plugins.list()`.
303
+ - `userData.materialSource` is gone; `inspect.scene` says `from: engine | game`.
304
+ - Hint kind `material` of R40 is gone: remove it from `threedog.hints`.
305
+ ## No style option: the look is game code (2026-11-04)
306
+
307
+ - `createEngine({ style })` → throws. Write the picture as plain three.js in the game's `look/` code; UI colors and CSS go in `createEngine({ ui })`.
308
+ - A style given as a list of parts (deep merge, `null` removes, `describe().look` naming the `pack`) → gone; game code composes plain values however it likes.
309
+ - `engine.style` → gone from the public API; read the three.js object or the module you are after.
310
+ - `style.background` → `engine.scene.background = new THREE.Color(0xefebe4)`.
311
+ - `style.antialias` → `createEngine({ antialias })`.
312
+ - `style.toneMapping`, `style.exposure` → `engine.renderer.toneMapping = THREE.AgXToneMapping`, `engine.renderer.toneMappingExposure = 1.2`.
313
+ - `style.plugins` → the game's `plugins/` folder, or `engine.plugins.add(files)`; plugin names lose the `<pack>/` prefix, `engine.plugins.off('<pack>')` and the `style` field of `engine.plugins.list()` are gone.
314
+ - `style.clouds.shadow / scale / speed` → `engine.uniforms.uCloudShadow.value`, `uCloudScale.value`, `uCloudSpeed.value.set(x, z)`.
315
+ - `style.wind.frequency` → `engine.uniforms.uWindFreq.value`.
316
+ - `style.seasons` → `engine.sky.seasonTints = { mode, strength, autumn: { foliage, ground } }`, plain data read every frame.
317
+ - `style.sky.shadow`, `style.sky.environment`, `style.sky.clouds` → `sky({ shadow, environment, clouds })`.
318
+ - `style.sky.fog` → `engine.scene.fog` or `look.fog.set`; `style.sky.dim` → `engine.sky.dim.tint` / `.stars`; other `style.sky.<key>` → `look.sky.set({ <key> })`.
319
+ - Types `Style`, `StyleInput`, `StyleWater`, `StyleTerrain`, `StyleWind` → gone. `StyleSky` → `SkyLookOptions`, `StyleShadow` → `SkyShadowOptions`, `StyleFog` → `SkyFogOptions`, `StyleEnvironment` → `SkyEnvironmentOptions`, `StyleSkyClouds` → `SkyCloudOptions`, `StyleSkyLayer` → `SkyLayerOptions`, `StyleSeasons` → `SeasonTints`.
320
+ - Error code `style-value` → gone.
@@ -0,0 +1,126 @@
1
+ # Moving a game from 0.5 to 0.6
2
+
3
+ `engine.look.*` is removed: the capabilities stay, as plain three.js or as one entry on the module that owns them. Each row is old -> new.
4
+
5
+ ## Sky: `engine.look.sky` is gone
6
+
7
+ | Old | New |
8
+ |---|---|
9
+ | `engine.look.sky.replace(x)` | `engine.sky.replace(x)` (null gives the dome back) |
10
+ | `engine.look.sky.set({ sunSize, moonColor, starDensity, ... })` | `sky({ ... })` at install; after it `engine.uniforms.uSunSize.value` and friends (recipe 08) |
11
+ | `engine.look.sky.set({ clouds: { coverage, scale, speed } })` | `engine.uniforms.uCloudCover`, `uSkyCloudScale`, `uSkyCloudSpeed` |
12
+ | `engine.look.sky.set({ keyframes })` | `engine.sky.keyframes(rows)` |
13
+ | `engine.look.sky.set({ top, horizon, backdrop, orbitTilt, dim })` | plain fields `engine.sky.top`, `.horizon`, `.backdrop`, `.orbit.tilt`, `.dim`; a color function: write the field in your frame code |
14
+ | `engine.look.sky.patch('clouds', x)`, `patch('layer:<name>', x)` | `engine.sky.clouds(x)`, `engine.sky.layer(name, x)` |
15
+ | `engine.look.env.replace('sky')`, `sky({ environment })`, `style.sky.environment` | `engine.sky.environment({ into: engine.scene })` |
16
+ | `engine.look.env.replace(asset \| Texture \| target)`, `look.env.set({ intensity, rotation })` | `scene.environment`, `scene.environmentIntensity`, `scene.environmentRotation`, `THREE.PMREMGenerator` (recipe 34) |
17
+ | `engine.mod('look.sky.tint' \| 'look.sky.flash' \| 'look.ground.cover', ...)` | `engine.mod('sky.tint' \| 'sky.flash' \| 'ground.cover', ...)` |
18
+ | keyframe rows `[time, zenith, horizon, lightColor, lightIntensity, ambient]` | `[time, zenith, horizon, sunColor, ambient]`: the intensity column drove nothing and six columns now throw; the color is the signal `engine.uniforms.uSunColor` |
19
+ | `engine.sky.setShadowMapSize(n)`, `engine.sky.shadowMapSize` | `engine.shadows.mapSize(light, n)`, `light.shadow.mapSize` |
20
+
21
+ ## Post effects: `engine.look.post` is gone
22
+
23
+ | 0.5 | 0.6 |
24
+ |---|---|
25
+ | `engine.look.post.add(x, { name, slot, order })` | `engine.post.add(x, { name, slot, order })`, returns `{ name, enabled, set(params), remove() }` |
26
+ | `look.post.set({ bloom: false })` | `engine.post.get('bloom').enabled = false` |
27
+ | `look.post.set({ 'bloom.strength': 0.6 })` | `engine.post.get('bloom').set({ strength: 0.6 })` |
28
+ | `look.post.replace([...])` | remove the handles and add the new effects |
29
+ | `look.post.manual('chain')` | `engine.post.own()`, back with `engine.post.own(false)` |
30
+ | settings `{ limits: 'look.post.<name>.enabled' }` | `{ limits: 'post.<name>.enabled' }` |
31
+ | a heavy effect a style brought started off on low-tier devices (`costly`) | the engine no longer decides: read `engine.tier` before adding it |
32
+
33
+ ## Tone: `engine.look.tone` is gone
34
+
35
+ | 0.5 | 0.6 |
36
+ |---|---|
37
+ | `engine.look.tone.set({ exposure })` | `engine.renderer.toneMappingExposure = x` |
38
+ | `engine.look.tone.manual('toneMapping')` | nothing to take: `engine.renderer.toneMapping = THREE.AgXToneMapping` |
39
+
40
+ ## Lights: `engine.look.lights` is gone
41
+
42
+ | 0.5 | 0.6 |
43
+ |---|---|
44
+ | `engine.look.lights.set({ sun: { intensity, color } })`, `hemi` likewise | `engine.lights.sun.intensity = x`, `engine.lights.hemi.color.set(c)`, or `createEngine({ lights: false })` and your own lights |
45
+ | `engine.mod('look.lights.sun.intensity', { mul })`, `settings { limits: 'look.lights.*' }` | keep your own factor in your `picture/` code and multiply when you write the light; weather's is `engine.uniforms.uWeatherLight` |
46
+ | `engine.look.lights.set({ env: { intensity } })` (the neutral room map) | `scene.environment = new THREE.PMREMGenerator(engine.renderer).fromScene(new RoomEnvironment()).texture`, `scene.environmentIntensity = x` (`RoomEnvironment` from `three/addons/environments/RoomEnvironment.js`) |
47
+ | `engine.look.lights.manual('probes')` | `probes.own()`, back with `probes.own(false)` |
48
+
49
+ ## Fog: `engine.look.fog` is gone
50
+
51
+ | 0.5 | 0.6 |
52
+ |---|---|
53
+ | `engine.look.fog.set({ far, near, color })` | `engine.scene.fog = new THREE.Fog(color, near, far)`, or write `.color`, `.near`, `.far` on it; read `engine.uniforms.uViewDistance`, `uSkyHorizon`, `uWeatherFog` |
54
+ | `engine.look.fog.set({ kind: 'exp2', density })` | `engine.scene.fog = new THREE.FogExp2(color, density)` |
55
+ | `engine.look.fog.set({ enabled: false })` | `engine.scene.fog = null` |
56
+ | `engine.look.fog.set({ kind: 'height' })`, `look.fog.patch('fog', x)` | three.js: `onBeforeCompile` on your materials, `scene.fogNode` on `renderer: 'webgpu'` |
57
+ | `engine.mod('look.fog.far', { mul })` | your own factor in your `picture/` code, multiplied in when you write the fog |
58
+
59
+ ## Cloud shadow: `engine.look.cloudShadow` is gone
60
+
61
+ | 0.5 | 0.6 |
62
+ |---|---|
63
+ | `look.cloudShadow.set({ shadow, scale, speed })` | `engine.uniforms.uCloudShadow.value`, `uCloudScale.value`, `uCloudSpeed.value.set(x, z)` |
64
+ | `look.cloudShadow.replace(spec \| false)` | `engine.terms.cloudShadow(spec \| false)`, returns `{ remove() }` |
65
+ | a plain lit material took the cloud shadow on its own; `userData.cloudShadow = false` kept one out | nothing is added unasked: call `applyEffects(mat)` on the materials that should darken |
66
+
67
+ ## Season tint: `engine.look.season` is gone
68
+
69
+ | 0.5 | 0.6 |
70
+ |---|---|
71
+ | `look.season.replace(spec \| kind => spec \| false)` | `engine.terms.season(spec \| kind => spec \| false)`, returns `{ remove() }` |
72
+
73
+ ## Wind: `engine.look.wind` is gone
74
+
75
+ | 0.5 | 0.6 |
76
+ |---|---|
77
+ | `look.wind.set({ frequency, amplitude })` | `engine.uniforms.uWindFreq.value`, `uWindAmp.value` |
78
+ | `look.wind.patch('sway', { glsl, tsl, uniforms })` | the species' `wind: { amplitude, glsl, tsl, uniforms }` in `vegetation.define`, or `applyEffects(mat, { wind: { ... } })` |
79
+
80
+ ## Shadows: one map now follows the camera
81
+
82
+ `engine.shadows.cascades(light)` with one map (`count: 1`, or a low-tier device) used to leave your light where it was, on three's default 10 m shadow box. It now places the light like cascades do: the map follows the camera and covers `maxFar` each way, `remove()` puts everything back, and `engine.shadows.box` on that light is refused while it is on. Nothing to change unless you sized that light's shadow camera yourself for the low tier: leave it to `maxFar`, or call `engine.shadows.box(light, { ... })` instead of `cascades` there.
83
+
84
+ ## The rest of the look and style layer is gone
85
+
86
+ Older parts and every `style.*` key, row by row: [MIGRATING-0.4.md](MIGRATING-0.4.md).
87
+
88
+ | 0.5 | 0.6 |
89
+ |---|---|
90
+ | `createEngine({ style })` | throws `[engine-misuse]`: the picture is plain three.js in the game's `picture/` folder, `createPicture(engine)` (recipes 62, 63); UI colors go in `createEngine({ ui })` |
91
+ | `engine.mod(point, { layer: 'style' })` | throws `[shared-layer]`: use the default `game` layer (recipe 55) |
92
+ | `look.<part>.manual(key)` | `engine.view.manual('far' \| 'fov' \| 'pixelRatio')`; the other values have the entries in the tables above |
93
+ | `engine.look.water` | `engine.water.material`, `.uniforms`, `.patches`, `.shader()`, `.normalMap()` (recipe 44) |
94
+ | `makeMaterial(role)`, `engine.makeMaterial`, `engine.look.materials` | any `new THREE.*Material` in `picture/materials.js`; a module's material is `engine.<module>.material` (recipe 09) |
95
+ | `engine.look.surface` | per material: `applyEffects(mat, { lighting, detail })`, `rampTexture(ramp, soften)` on a toon material (recipe 43) |
96
+ | `look.shadow.set({ enabled })` | `engine.shadows.enabled = false` |
97
+ | `look.shadow.set({ type })` | `engine.renderer.shadowMap.type` |
98
+ | `look.shadow.set({ cascades })`, `look.shadow.include(mat)` | `engine.shadows.cascades(light, { count })`, `engine.shadows.include(mat)` (recipe 45) |
99
+ | `defineLookPart(...)` in a module | module options and a plain `engine.<module>.material` |
100
+ | `threedog style check` | `npm run check` type-checks `picture/` |
101
+ | `threedog style palette \| compare` | `threedog picture palette \| compare` |
102
+ | `engine.styleWorkbench` | `engine.devPanel`, after `openPanel(engine)` from `@threedog/tools/panel` (recipe 35) |
103
+
104
+ ## Names: "look" becomes "picture"
105
+
106
+ The look layer is gone, so the word no longer names picture things. Mouse and camera look (`input.look`, `lookAt`, `mouseLook`) keep their names. No aliases: the old names just stop existing.
107
+
108
+ | Old | New |
109
+ | --- | --- |
110
+ | game folder `look/` | `picture/` (also the `include` line of a game's `tsconfig.json`) |
111
+ | `createLook(engine)`, `const look = ...`, `look.lamp(id)`, `look.materials` | `createPicture(engine)`, `const picture = ...`, `picture.lamp(id)`, `picture.materials` |
112
+ | module type `type: 'look'` | `type: 'picture'` |
113
+ | `engine.terrainLook`, `engine.vegetationLook`, `engine.weatherLook` | `engine.terrainDraw`, `engine.vegetationDraw`, `engine.weatherDraw` |
114
+ | `replaces: 'terrainLook'`, `'vegetationLook'`, `'weatherLook'` | `replaces: 'terrainDraw'`, `'vegetationDraw'`, `'weatherDraw'` |
115
+ | slots `terrain-look`, `vegetation-look`, provides `weatherLook` | `terrain-draw`, `vegetation-draw`, `weatherDraw` |
116
+ | `SkyLookOptions` (types) | `SkyPictureOptions` |
117
+ | `threedog shot --no-look`, `threedog snap --no-look` | `--no-picture` |
118
+ | `look` and `lookMs` in `threedog shot --json`; the printed `Look:` line | `picture` and `pictureMs`; `Picture:` |
119
+ | DESIGN.md line `Look intent:` | `Picture intent:` |
120
+ | `threedog lib add --kind look` | `--kind picture` (an entry of the old kind in a library is re-added under the new one) |
121
+ | `@threedog/tools/look` (`lookHints`, `lookNumbers`, `probeLook`, `pageLook`, `imageLook`, `formatLook`) | `@threedog/tools/picture-check` (`pictureHints`, `pictureNumbers`, `probePicture`, `pagePicture`, `imagePicture`, `formatPicture`) |
122
+ | recipes 35-look-from-reference, 36-sky-ground-plant-looks, 37-terrain-look-hooks, 38-environment-look-hooks, 43-shader-patches-surface-looks, 44-water-weather-look-hooks, 52-look | 35-picture-from-reference, 36-sky-ground-plants, 37-terrain-hooks, 38-environment-hooks, 43-shader-patches-surfaces, 44-water-weather-hooks, 52-around-the-picture |
123
+ | recipe 41-thing-registry | merged into 40-scene (one recipe on what is in the scene and what a save keeps) |
124
+ | example `plain-look` | `plain-picture` |
125
+ | `grids.preview({ look })` | `grids.preview({ draw })` (`false`, or `(engine) => part`) |
126
+ | `layer(name, { tiles: { look } })` | `tiles: { color }`, the same `(data, cell) => color \| null`; an unknown `tiles` key now throws |
@@ -0,0 +1,39 @@
1
+ # Moving a game from 0.6 to 0.7
2
+
3
+ ## Light probes: every pixel takes its own light
4
+
5
+ `engine.bakeProbes` now builds three's probe grid, so the one scene light that followed a point is gone. Bake or load the same way; lit materials pick the grid up by themselves.
6
+
7
+ | 0.6 | 0.7 |
8
+ |---|---|
9
+ | `bakeProbes({ follow })`, `loadProbes(json, { follow })` | delete it: every pixel inside the grid has its own light |
10
+ | `bakeProbes({ height: 1.5 })` (one layer over the ground) | `bounds` around the ground and the air above it; a grid is a box, and needs 2 layers an axis |
11
+ | `probes.probe`, `probes.own()` | `probes.grid`, a plain three.js light; a light of your own from `probes.sample(pos, myProbe)` as before |
12
+ | `probes.probe.intensity` | `probes.grid.intensity` on WebGPU; on WebGL three ignores it, so change the light you bake, or the exposure |
13
+ | a probe file from 0.6 (version 1) | refused with `probes-data`: bake again (the file is now half precision, about a third of the size) |
14
+ | objects anywhere got the light of the follow point | outside the grid there is no probe light: size `bounds` to the scene (`describe().render.probes.outside`) |
15
+
16
+ ## Removed from the public surface
17
+
18
+ | 0.6 | 0.7 |
19
+ |---|---|
20
+ | `engine.level.object` | `engine.level.root` (the same object) |
21
+ | `engine.inventory.defs` | `engine.inventory.item(id)` for one definition; not in the types any more |
22
+ | `engine.quests.defs` | `engine.quests.list()`; not in the types any more |
23
+ | `engine.triggers.action`, `engine.settings.action`, `engine.interactions.action` | the option you passed to `triggers()`, `settings()`, `interactions()` |
24
+
25
+ ## Follow camera and characters
26
+
27
+ | 0.6 | 0.7 |
28
+ |---|---|
29
+ | `collision({ cameraOcclusion })` defaulted to colliders only | the default is `'both'`: meshes added with `engine.rays.addStatic(mesh, { occluder: true })` and level buildings stop the camera arm too; `cameraOcclusion: 'colliders'` keeps the old test |
30
+ | `character.placeAt` over a prop or platform ignored it | it stands on a registered support (recipe 32 says what a support needs) |
31
+ | `mover: 'manual'` skipped the `states` hook | it runs the `states` hook (recipe 57, "Moved by script") |
32
+
33
+ ## Layers 26 to 29 and 31 are reserved
34
+
35
+ The engine keeps these three.js layers for itself (`RESERVED_LAYERS` from `threedog/layers`). A game's own layers are 1 to 25; move anything of yours on layers 26 to 28 down. Layer 30 stays the default camera `hideLayer`.
36
+
37
+ ## Starting a game
38
+
39
+ `threedog new-game --example` and `templates/example` are gone: start from `new-game` itself, and read the engine's `examples/` for finished techniques.
package/docs/THREE.md CHANGED
@@ -2,30 +2,30 @@
2
2
 
3
3
  The scene, camera, lights, characters and models in the engine are **plain three.js objects** (three 0.187). Write the three.js you already
4
4
  know: what the engine can see, it plugs in with no extra call. Only where it cannot know your intent do you write one line.
5
- Looks (materials, shaders, textures, lights, post passes) always take this route first; engine look features are optional conveniences on top.
6
- This is the one place that order is stated: a material is `new THREE.*Material` / `ShaderMaterial` before a slot patch or a style role, a post
7
- pass is a three.js Pass (`engine.look.post.add(pass)`) before a ready-made effect.
5
+ Picture work (materials, shaders, textures, lights, post passes) always take this route first; engine picture features are optional conveniences on top.
6
+ This is the one place that order is stated: a material is `new THREE.*Material` / `ShaderMaterial` before a slot patch, a post
7
+ pass is a three.js Pass (`engine.post.add(pass)`) before a ready-made effect.
8
8
 
9
9
  | You write (plain three.js) | The engine does | The one line, only when you mean it |
10
10
  |---|---|---|
11
11
  | `engine.scene.add(obj)` / `group.add(obj)` | registers each root under the scene like `engine.add`: `engine.thing`, `describe().scene`, `thing.set` / `thing.remove` | a stable id so a save finds it: `engine.add(obj, { id: 'mill' })` |
12
12
  | `new THREE.PointLight(...)` / `SpotLight` added to the scene | a real light, adopted as a thing; counted by `engine.budget` `lights` / `shadowLights`, listed in `describe().render.lights`; a casting light at intensity 0 stops redrawing its shadow map; weather and day-night leave its values alone | many sources, few real lights: `lightPool` (recipe 52) |
13
13
  | `new THREE.MeshStandardMaterial(...)` | scene fog (height fog too), cascaded shadows | wind sway: `applyEffects(mat, { wind: 0.03 })` |
14
- | `engine.look.post.add(pass)`, the one way into the chain (the other renderer's form: recipe 56) | slots it after the scene render and before tone mapping (FXAA / SMAA last), or after tone mapping when you added it after an OutputPass; a pass that renders `engine.scene` itself (RenderPixelatedPass, SSAA, TAA) replaces the scene render, so the scene is drawn once; skips a RenderPass / OutputPass it already has; listed in `post.list()`; `remove()` leaves it undisposed | a settings name and position: `add(pass, { name: 'glow', order })`, then `look.post.set({ glow: false })` |
14
+ | `engine.post.add(pass)`, the one way into the chain (the other renderer's form: recipe 56) | slots it after the scene render and before tone mapping (FXAA / SMAA last), or after tone mapping when you added it after an OutputPass; a pass that renders `engine.scene` itself (RenderPixelatedPass, SSAA, TAA) replaces the scene render, so the scene is drawn once; skips a RenderPass / OutputPass it already has; listed in `post.list()`; `remove()` leaves it undisposed | a settings name and position: `add(pass, { name: 'glow', order })`, then `engine.post.get({ glow: false })` |
15
15
  | your own `EffectComposer` / `renderer.render` of the whole canvas, every frame | yields the frame (stops drawing its own, warns once `[own-frame]`); delete your render call to hand it back. A minimap / HUD layer on top (scissor, smaller viewport, or `autoClear = false` with another scene) is not a takeover | - |
16
16
  | `renderer.setSize` / `setPixelRatio` yourself | the post chain follows on its next draw | - |
17
- | `scene.fog.far = 80`, `sun.intensity = 3`, `renderer.toneMappingExposure = 1.4` | yields that value (recipe 52 "Who writes it") | dim on top of weather instead of taking it: `engine.mod('look.fog.far', { owner: 'storm', mul: 0.6 })` |
18
- | one file per piece in `plugins/` next to index.html (`export default mesh`, a Pass, a post effect such as `grain()`, a Material, a ShaderPatch `{ slot, glsl, roles }`, a module; never a bare function) | plugs each at `engine.start()` by what it exports, through the same calls as above (`scene.add`, `look.post.add`, `look.materials.replace` / `patch`, `engine.use`); order by file name or a `plugins.json` beside them; anything else is a `[plugin-shape]` error naming the file, what it found and the fix (a factory: `export default makeIt({ ... })`; a module with no `type`: add one) | switch one off: `plugins.json` `"off": ["20-bloom"]` or `engine.plugins.off('20-bloom')` |
17
+ | `scene.fog.far = 80`, `sun.intensity = 3`, `renderer.toneMappingExposure = 1.4` | stays: the engine never writes these on its own | - |
18
+ | one file per piece in `plugins/` next to index.html (`export default mesh`, a Pass, a post effect such as `grain()`, a module; never a bare function; a Material goes on its mesh in `picture/`) | plugs each at `engine.start()` by what it exports, through the same calls as above (`scene.add`, `engine.post.add`, `engine.use`); order by file name or a `plugins.json` beside them; anything else is a `[plugin-shape]` error naming the file, what it found and the fix (a factory: `export default makeIt({ ... })`; a module with no `type`: add one) | switch one off: `plugins.json` `"off": ["20-bloom"]` or `engine.plugins.off('20-bloom')` |
19
19
  | a static mesh you want `engine.pick` to hit | - | `engine.rays.addStatic(obj)` (a BVH only pays off for things that do not move) |
20
20
 
21
21
  `describe().slots` is the one table of what is plugged in where: each row is `{ slot, plugged, file, on, affects }`, for the plugins folder,
22
- `scene.add` roots (with the file:line that added them), `look.post.add` effects, modules and plain lights. Without the vite preset, hand the folder over
22
+ `scene.add` roots (with the file:line that added them), `engine.post.add` effects, modules and plain lights. Without the vite preset, hand the folder over
23
23
  yourself: `engine.plugins.add(import.meta.glob('./plugins/*.js', { eager: true }))` before `engine.start()`.
24
24
 
25
25
  ## What the engine changes in three.js (Global changes)
26
26
  Everything else in three is untouched. Every change below is listed in `describe().threePatches` (`{ id, what, scope, on, offable, lost }`);
27
27
  an offable one is undone page-wide with `threePatches.off(id)` (`import { threePatches } from 'threedog'`), call it before creating the objects
28
- that should not see it. `lost` says what stops working; a change that cannot be undone says why and `off` throws.
28
+ that should not see it. It is page-wide: every engine on the page loses the change, and `engine.dispose()` does not undo it (disposing one engine never touches a change another engine or library relies on). A wrapper another library put on `Object3D.prototype.add` stays when `scene-add-hook` is turned off. `lost` says what stops working; a change that cannot be undone says why and `off` throws.
29
29
 
30
30
  | id | Change | Effect on your code | Off |
31
31
  |---|---|---|---|
@@ -33,10 +33,16 @@ that should not see it. `lost` says what stops working; a change that cannot be
33
33
  | `node-setup-position` | `NodeMaterial.prototype.setupPosition` wrapped | WebGPU only: runs the engine's vertex-moving patches (wind) first; other node materials unchanged | yes |
34
34
  | `scene-add-hook` | `Object3D.prototype.add / remove` wrapped (page-wide) | None to the call itself; the engine sees what enters and leaves its scene at any depth (adopting `scene.add`, fog, cascades, cloud shadow, light counts). Another library wrapping the same methods stacks with it | yes (`scene.add` no longer adopted) |
35
35
  | `mesh-material-accessor` | `material` on each object entering the engine's scene: an own get / set on that object (a class accessor, e.g. troika text, still runs) | In devtools `mesh.material` shows as an accessor; `mesh.material = other` works as in three and is seen | yes (new objects) |
36
- | `material-compile-accessor` | `onBeforeCompile` / `customProgramCacheKey` on each material the engine patches (cloud shadow on plain lit materials, wind, fog) | Your own hook, assigned before or after, runs first, then the engine's | yes (new materials) |
36
+ | `material-compile-accessor` | `onBeforeCompile` / `customProgramCacheKey` on each material the engine patches (what applyEffects was asked for, wind, fog) | Your own hook, assigned before or after, runs first, then the engine's | yes (new materials) |
37
37
  | `renderer-render` | `engine.renderer.render` (that instance only) wrapped | Counts your full-canvas draws so the engine yields the frame; a scissored / smaller-viewport / `autoClear = false` layer (minimap, HUD) does not count | yes |
38
38
  | `shader-chunks` | `THREE.ShaderChunk.threedog_*` added (new names, nothing replaced) | None until you `#include` one | no (the engine's patches include them) |
39
39
  | `light-idle-shadow` | `shadow.autoUpdate` of your shadow-casting point / spot lights: off while intensity is 0, back on when lit | Only lights whose autoUpdate was on; writing autoUpdate yourself hands the light back; `light.userData.idleShadow = false` opts one out; `describe().render.lights` shows `shadowIdled` | yes |
40
+ | `picture-writers` | Dev server only (absent from bundles and release builds): an own get / set on the picture values of objects in the engine's scene (light intensity / color / position, `scene.fog` and its values, tone and exposure, environment, background, material color / emissive / opacity), and on the `r g b` / `x y z` of those colors and positions | Every read and write goes through unchanged; in devtools these show as accessors. A write records who made it for `describe('picture').writers` and `engine.explain({ picture })` | yes: `threePatches.off('picture-writers')`, accessors stay and only pass values through |
41
+ | `post-shadow-hold` | `render` of the first pass of the WebGL post chain wrapped (it may be your own Pass) | None to what the pass draws; shadow maps redraw once a frame | yes |
42
+ | `post-background-tone` | `onBeforeRender` of three's own background mesh, while the engine draws straight to the canvas | A texture background is tone-mapped as it is through the post chain; your own `renderer.render` keeps three's rule | yes |
43
+ | `node-twin-dress` | `renderer.library.fromMaterial` of a WebGPURenderer wrapped | WebGPU only: the node twin of a classic material gets its patches | no (patched materials would lose their picture on WebGPU) |
44
+ | `node-builder-hook` | `renderer.debug.onNodeBuilderCreated` of a WebGPURenderer wrapped | WebGPU only: your own hook still runs; a later write of yours replaces the engine's | yes |
45
+ | `device-lost-hook` | `renderer.onDeviceLost` of a WebGPURenderer wrapped | WebGPU only: three's hook still runs; a later write of yours replaces the engine's | yes |
40
46
  | `hlod-visible` | `visible` on meshes registered with `engine.hlod.add` (and their `xxx_LOD1` nodes): an own get / set | Reads "your value and not hidden far"; your writes keep your value | per handle: `remove()` |
41
47
 
42
48
 
@@ -50,17 +56,17 @@ that should not see it. `lost` says what stops working; a change that cannot be
50
56
  | Pickups, template instances | `pickups.spawn(...)` returns a handle with `.object` (Mesh); a template instance's model is `engine.world.view(id)` (exists only near) |
51
57
  | Level | `engine.level.root`; markers `engine.level.marker('spawn').object / .position` |
52
58
  | Sun, ambient light, sky dome, fog | `engine.lights.sun` (DirectionalLight), `engine.lights.hemi` (HemisphereLight), `engine.sky.dome`, `engine.scene.fog` |
53
- | Water | `engine.water.sea` (Mesh; null when the game sets no water level), `water.material`, `water.bodies.get(body)` |
54
- | Particles, weather particles | `.points` (THREE.Points) of the value returned by `particles.define(...)`; the weather's look in the style (`style.weather`) |
59
+ | Water | `engine.water.sea` (Mesh; null when the game sets no water level), `water.material` (get / set), `water.uniforms`, `water.bodies.get(body)` |
60
+ | Particles, weather particles | `.points` and `.material` of the value returned by `particles.define(...)`; `engine.weather.particles[field].material` (the plain material of a weather field) |
55
61
  | Rigid bodies | `engine.rigid.addBox(mesh)` returns a handle `{ object, body, remove() }`, or null before Rapier is ready (object is your mesh; `castShadow` / `receiveShadow` keep the values you set, the engine does not change them) |
56
- | Terrain chunks | `engine.terrain.chunks` (Map of chunk data); a chunk's three.js objects: `engine.terrainLook.meshes.get(chunk)` (`{ group, mesh }`) |
62
+ | Terrain chunks | `engine.terrain.chunks` (Map of chunk data); a chunk's three.js objects: `engine.terrainDraw.meshes.get(chunk)` (`{ group, mesh }`) |
57
63
  | Models, textures, animation | `await engine.assets.model('name or path')` (an Object3D copy), `assets.texture(...)`, `assets.animate(model).mixer` |
58
64
  | Vehicles, navigation, character controller | `engine.rigid.addWheeled(mesh, ...)` returns `{ body, controller }`; `engine.nav.navMesh / query / tileCache / crowd` (they are destroyed and replaced on rebuild; code that caches them compares `engine.nav.version`); `engine.player.mover.controller` (mover: 'rapier') |
59
65
  | glTF / compression decoders | `engine.assets.gltf` (GLTFLoader, Meshopt installed), `assets.draco` (DRACOLoader), `assets.ktx2` (KTX2Loader); the last two are created the first time compressed data is met and are null before that |
60
66
  | Rays | `engine.raycast(origin, direction)` / `engine.pick(ndcX, ndcY)` return three hits (`object` is the mesh, `face` and `point` unchanged); `{ targets: 'all' }` hits rigid bodies too (the hit carries `entry` and `kind: 'rigid'`); the underlying `engine.rays.ray` (THREE.Raycaster, `firstHitOnly` on) |
61
67
  | Ray acceleration (BVH) | three-mesh-bvh, without touching three's prototypes: a static mesh the engine registers (from 256 triangles up) gets `mesh.geometry.boundsTree` and its own `mesh.raycast`, so `engine.raycast / pick` are fast and your own `new THREE.Raycaster()` is plain three. Page-wide BVH for your rays: three-mesh-bvh's documented setup (`Mesh.prototype.raycast = acceleratedRaycast`, ...) |
62
68
  | Streamed-in objects | `.object` of the handle returned by `engine.stream.add({ position, build })` (the Object3D that build returned; null before it is built) |
63
- | Post-processing | `engine.look.post.add(pass)`, the one way in (a Pass, or an effect `{ name, slot, create: ctx => pass }` plus its twin for the other renderer, recipe 56; slots `scene` / `hdr` / `tone` / `ldr` / `final`; on / off with `look.post.set`); `replace([...])` swaps the whole chain |
69
+ | Post-processing | `engine.post.add(pass)`, the one way in (a Pass, or an effect `{ name, slot, create: ctx => pass }` plus its twin for the other renderer, recipe 56; slots `scene` / `hdr` / `tone` / `ldr` / `final`; on / off and params with its handle); `engine.post.own()` hands over the whole chain |
64
70
  | Where the mouse points | Ground: `screenToGround(engine, input.pointer.ndcX, ndcY)` -> Vector3; objects: `engine.pick(input.pointer.ndcX, ndcY)` (registered static objects; for any object pass `{ targets: [object] }`) |
65
71
 
66
72
  Returned positions are all `THREE.Vector3` (the camera's `forward()/right()` are planar directions `{x, z}`; positions in photo records are saveable `{x, z}`).
@@ -72,12 +78,11 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
72
78
 
73
79
  ## Engine conventions when using three.js
74
80
 
75
- 1. **Materials**: `new THREE.MeshStandardMaterial(...)` is fine. Use `makeMaterial('role', { color, ... })` when you want the style's material
76
- for a role (it returns a real three material; the type is decided by the style); afterwards change `.map`, `.transparent` as usual.
81
+ 1. **Materials**: `new THREE.MeshStandardMaterial(...)` is the way; afterwards change `.map`, `.transparent` as usual.
77
82
  Your own shader code works as in three.js: `ShaderMaterial`, `onBeforeCompile` (also on an engine material: yours runs first, the engine's
78
83
  wind / clouds / season patches after it). The engine adds effects only to materials it made; yours opt in with `applyEffects(mat, { wind: 0.03 })`.
79
- One exception, named: with cascaded shadows on (`look.shadow.set({ cascades: 3 })`) every built-in lit material gets the `csm` patch, or it would
80
- be lit N times; a lit `ShaderMaterial` of yours joins with `engine.look.shadow.include(mat)` (recipe 45).
84
+ One exception, named: with cascaded shadows on (`engine.shadows.cascades(light)`) every built-in lit material gets the `csm` patch, or it would
85
+ be lit N times; a lit `ShaderMaterial` of yours joins with `engine.shadows.include(mat)` (recipe 45).
81
86
  2. **Adding to the scene**: `engine.scene.add(obj)` is all it takes: every root under the scene is registered (`engine.thing(obj)` says what it
82
87
  is and what a save keeps). `engine.add(obj, { id })` is only for a stable id, so `thing.set` changes to it are saved. Plain three.js and
83
88
  templates (`engine.content.spawn`, content props) are two doors into one scene (`recipes/40-scene.md`). To attach to a character use `player.object.add(hat)`.
@@ -94,10 +99,7 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
94
99
  and materials (`obj.removeFromParent()` / `scene.remove` leak GPU memory). To take it off only temporarily and `add` it back later use
95
100
  `engine.detach(obj)`. A copy from `assets.model()` shares resources with other copies (`remove` skips them); they are freed together by
96
101
  `assets.release(name)`.
97
- 6. **Sky lighting is recomputed every frame**, and you choose how much of it to keep: adjust it and keep the day cycle with a modifier layer
98
- `engine.mod('look.lights.sun.intensity', { owner: 'cave', mul: 0.3 })` (also `look.lights.hemi.intensity` / `look.fog.far`; entries multiply; `remove()` ends it) or `look.lights.set(...)` as the base they multiply;
99
- take a value with `engine.look.lights.manual('sun')` and then set `engine.lights.sun.intensity` yourself (`manual('sun', false)` gives it back).
100
- Writing it directly without `manual` also takes it (the engine stops writing it and warns once). Every engine-written value: recipe 52
102
+ 6. **The sky lights nothing**: it computes signals and draws the dome, and your `picture/` code writes the lights, the fog and the exposure (recipe 62); weather gives `uWeatherLight` / `uWeatherFog` to multiply in. Every engine-written value: recipe 52
101
103
  "Who writes it". Adding your own point lights (street lamps, campfires) is fine.
102
104
  7. **Camera**: only change properties of `engine.camera`, never replace the object (post-processing is bound to it; `engine.setCamera('follow')` swaps the camera *module*, not the object). When a camera
103
105
  module is installed it places the camera every frame; to control the view yourself take it with `const cam = engine.takeCamera('me')` and `cam.remove()` it
@@ -116,7 +118,7 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
116
118
  cascaded-shadow materials; the engine warns once at load, naming both paths [engine-two-copies].
117
119
 
118
120
  ## Example: a spinning windmill (plain three.js + engine conventions)
119
- This is the plain three.js door: three's own materials, no style needed (`makeMaterial('building')` instead gives the pack's material for a role, when you want it unified with the pack). The same windmill as a template with an id, saved and editable without code, is in `recipes/40-scene.md` §1.
121
+ This is the plain three.js door: three's own materials. The same windmill as a template with an id, saved and editable without code, is in `recipes/40-scene.md` §1.
120
122
 
121
123
  ```js
122
124
  import { THREE } from 'threedog';
@@ -5,7 +5,7 @@
5
5
  - `assets.paramsOf(name: string) → { schema, values, tuned } | null` — The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null
6
6
  - `assets.setParams(name: string, values: Record<string, any>) → Promise<{ why: string; names: str…` — Dev tuning: build a generator with these params (replacing its defaults) and swap every live copy in place; the dev panel's models folder calls it
7
7
  - `assets.preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }) → Promise<{ loaded: number; failed:…` — Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now showing their fallback
8
- - `assets.font(name: string) → Promise<FontFace | null>` — A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. style.ui.fonts calls it at start()
8
+ - `assets.font(name: string) → Promise<FontFace | null>` — A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. ui.fonts calls it at start()
9
9
  - `assets.model(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Promise<Object3D>` — Get a model copy (name or path; geometry and materials are shared with other copies). static: true registers it in engine.rays (builds ray acceleration)
10
10
  - `assets.modelNow(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Object3D | null` — A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs. Code-built models (a build function in the manifest) count too: they are null until one await model(name) or an entry with preload: true ran (dev warns [asset-not-loaded]). Example: `const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');`
11
11
  - `assets.geometry(nameOrUrl: string) → Promise<BufferGeometry>` — Get the geometry of the first mesh in a model
@@ -22,6 +22,7 @@
22
22
  - `assets.reportText(nameOrRoot: string | Object3D) → string` — assets.report as text for the console / describe
23
23
  - Properties:
24
24
  - `cacheMinMs: number` Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20
25
+ - `palette: Record<string, any>` Named colors for what is made in code: a generator written with `function` reads this.palette. Plain data, read, write or replace it freely: it is part of the cache key, so a model or texture asked for after a write is built from the new colors. Copies already placed keep theirs. Example: `engine.assets.palette = { leaf: 0xd98a3a, bark: 0x6b4a30 };`
25
26
  - `shared: WeakSet<object>` Geometry and materials shared by model copies (engine.remove does not release them, use release)
26
27
  - `memory: { geometries: number; textures: number }` Current GPU memory usage (number of geometries and textures)
27
28
  - `gltf: any` three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed)
@@ -35,9 +36,9 @@
35
36
  - `models?: Record<string, AssetEntry>` Models (.glb / .gltf, Draco/Meshopt compression also works): name -> path or generator function
36
37
  - `textures?: Record<string, AssetEntry | Texture | (() => Texture | Prom…` Textures: name -> path, or a texture made in code: a function returning a THREE.Texture (run once, on first use) or the Texture itself. Code textures come back as made (their colorSpace / wrap / repeat are yours) and are never disposed by the engine if passed as a Texture. Example: textures: { brick: () => makeBrickTexture(), sign: mySignTexture }
37
38
  - `sounds?: Record<string, AssetEntry | SynthFn | { build: SynthFn; par…` Sounds: name -> file path, or a sound made in code: a synth function (SynthFn) or { build: synthFn, params } (params: its defaults). Used by name like a file: audio.sfx(name), audio.sounds rules (src / variants), music and ambience. Example: sounds: { step: '/sfx/step.ogg', ding: dingSynth }
38
- - `fonts?: Record<string, string | FontAssetEntry>` Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). style.ui.fonts lists the names the UI uses
39
+ - `fonts?: Record<string, string | FontAssetEntry>` Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). ui.fonts lists the names the UI uses
39
40
  - **AnimatorOptions** Animation state machine parameters
40
- - `fade?: number` Default transition seconds, default 0.25 (style.character.animation.fade)
41
+ - `fade?: number` Default transition seconds, default 0.25 (characters({ animation: { fade } }) for every character)
41
42
  - `states?: Record<string, AnimatorState>` States: name → state
42
43
  - `transitions?: Record<string, number>` Transition seconds for specific pairs: { 'jump>fall': 0.1, '*>idle': 0.3 }
43
44
  - `params?: Record<string, number>` Initial parameter values
@@ -51,6 +52,7 @@
51
52
  - `lock?: boolean` go() cannot interrupt it while playing
52
53
  - `timing?: number | [number, number][]` For sync(): gameplay seconds -> clip seconds. A number = the gameplay length the whole clip is stretched over; [[gameT, clipT], ...] = piecewise linear (land the swing on the hit phase). Without it clip seconds = t
53
54
  - **Animator** Skeletal animation state machine (returned by engine.assets.animate(model, config))
55
+ - `root: Object3D` The animated object
54
56
  - `mixer: any` three.js AnimationMixer
55
57
  - `actions: Map<string, any>` clip name → three.js AnimationAction
56
58
  - `state: string | null` Current state name
package/docs/api/audio.md CHANGED
@@ -4,7 +4,7 @@
4
4
  - `audio.setVolume(bus: string, v: number)` — Set a bus volume 0-1 ('master' for the total). Example: `engine.audio.setVolume('music', 0.3);`
5
5
  - `audio.duck(levels: Record<string, number>, opts?: { fade?: number }) → { remove(fade?: number): void }` — Lower buses until the handle is removed (dialogue, pause menu, a cutscene). Several ducks stack (their levels multiply). Example: `const d = engine.audio.duck({ music: 0.3, ambience: 0.5 }); engine.events.once('dialogue:end', () => d.remove());`
6
6
  - `audio.condition(name: string, test: (value: any, e: any) => boolean) → { remove(): void }` — Add a condition key for music / ambience rule lists: `when: { [name]: value }` calls test(value, engine). Modules add theirs (calendar: time, weather: weather, triggers: zone); the engine has `state` (engine.audio.state). Example: `engine.audio.condition('inside', v => engine.vars.flag('indoors') === v);`
7
- - `audio.measure(name: string, fn: (e: any) => number) → { remove(): void }` — Add a measure: a number rule data compares (`when: { daylight: { gt: 0.15 } }`; gt / gte / lt / lte) and adds up (`volume: { add: { wind: 0.08 } }`). calendar adds daylight, weather rain / snow / wind, ambience nearWater / altitude. A name is a condition or a measure, not both. Example: `engine.audio.measure('danger', e => e.vars.counter('alarm') / 10); // data: when: { danger: { gt: 0.5 } } Measures are not only for sound: render/lookGlow.js reads 'daylight' for night glow, so the calendar (or the sky without one) registers it once and nothing else has to know which module tells day from night. remove() drops only this registration (a later one under the name stays).`
7
+ - `audio.measure(name: string, fn: (e: any) => number) → { remove(): void }` — Add a measure: a number rule data compares (`when: { daylight: { gt: 0.15 } }`; gt / gte / lt / lte) and adds up (`volume: { add: { wind: 0.08 } }`). calendar adds daylight, weather rain / snow / wind, ambience nearWater / altitude. A name is a condition or a measure, not both. Example: `engine.audio.measure('danger', e => e.vars.counter('alarm') / 10); // data: when: { danger: { gt: 0.5 } } Measures are not only for sound: render/daylight.js reads 'daylight' for night glow, so the calendar (or the sky without one) registers it once and nothing else has to know which module tells day from night. remove() drops only this registration (a later one under the name stays).`
8
8
  - `audio.value(name: string) → number | undefined` — The current value of a measure (debug, tests); undefined when none is registered under that name
9
9
  - `audio.matches(when: AudioCondition | undefined, ...extra: any[]) → boolean` — Does a rule's `when` hold now? An object needs every key to hold (condition keys, or measure comparisons); a function gets (engine, ...extra); missing = always. Example: `engine.audio.matches({ time: 'night', zone: 'forest', rain: { lt: 0.2 } });`
10
10
  - `audio.volumeOf(volume: AudioVolume | undefined, ...extra: any[]) → number` — A rule's volume now: a number, a function (engine, ...extra), or data { base, add: { measure: factor }, min, max }; missing = 1. Example: `engine.audio.volumeOf({ base: 0, add: { rain: 0.22 } }); // 0.22 in full rain`
@@ -23,7 +23,7 @@
23
23
  - `running: boolean` Is audio usable (the player has clicked/pressed a key)?
24
24
 
25
25
  ## Data structures
26
- - **AudioConfig** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). Not part of a style
26
+ - **AudioConfig** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio).
27
27
  - `sounds?: Record<string, SoundSource>` Sound name -> play rule: an asset sound name / path, variants, or SoundDef
28
28
  - `ambience?: AmbienceRule[]` ambience() rule table
29
29
  - `music?: { tracks?, rules?, fade?, duckDialogue?, duckFade?, hold?, … }` music() defaults: tracks, rules, fade seconds, duckDialogue (how low the music bus ducks during dialogue; default false = no duck)
@@ -23,6 +23,10 @@
23
23
  - `textures?: number` Texture count
24
24
  - `chunkApplyMs?: number` Terrain chunk upload milliseconds per frame
25
25
  - `rigidBodies?: number` Rigid body count
26
+ - `lights?: number` Lit point + spot lights, a game's own and pooled ones (default limit 8)
27
+ - `shadowLights?: number` Lit point + spot lights that cast shadows
28
+ - `shadowMaps?: number` Shadow maps drawn each frame, sun and cascades included, a point light counts six
29
+ - `shadowMapSize?: number` The largest side of a shadow map, in pixels
26
30
  - `applyTransitMs?: number` Per-frame cost of applying background results, by stage (engine.budget.cost): worker transit (approximate), creating three.js objects, colliders, GPU upload (approximate), stream build()
27
31
  - `applyBuildMs?: number`
28
32
  - `applyColliderMs?: number`
@@ -5,6 +5,7 @@ Characters: createPlayer() (characters() module)
5
5
  - Options `CharactersOptions`:
6
6
  - `npcs?: boolean` Whether to enable NPCs (engine.npcs), default true
7
7
  - `npcTiers?: { fullRadius: number; nearEvery: number }` Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
8
+ - `animation?: AnimatorOptions` What every character's Animator starts from, e.g. { fade: 0.15 }; a model's manifest mapping and the character's own animation win over it
8
9
 
9
10
  ## Methods and properties
10
11
  - `characters.findSpawn(position?: PositionLike, opts?: FindSpawnOptions) → Vector3` — Find a spawn point: searches outward from position (default origin) for walkable (not steep, no obstacle), non-water ground, without assuming terrain height; e.g. findSpawn(v, { minH: 3, maxH: 20 }). Returns a Vector3 (y is the ground height)
@@ -15,6 +16,7 @@ Characters: createPlayer() (characters() module)
15
16
  - `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) → XZ[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }) → PathResult` — Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, z }...], or null if unreachable
16
17
  - `characters.findPathAsync(from: PositionLike, to: PositionLike, done: (path, status) => void, opts?: { radius?, step?, maxNodes? }) → { remove(): void }` — findPath for many callers (NPC crowds, AI squads): solved in engine.threads workers; done(path, status) runs on a fixed step a few steps later (same paths with threads on or off). Recipe 12 section 4
17
18
  - Properties:
19
+ - `material: Material` The three.js material of every placeholder capsule. Set it to swap the look of all of them at once; used as given, with no patches added. A character with colors.body draws with a copy of it in that color. A model's own materials are the model's. Example: `engine.characters.material = new THREE.MeshToonMaterial({ color: 0xd9a066 });`
18
20
  - `pathsPerStep: number` How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps
19
21
 
20
22
  ## Character (engine.player / NPC are both Character)
@@ -113,7 +115,7 @@ Characters: createPlayer() (characters() module)
113
115
  - `control: PlayerControl` Required, no default: 'camera' (keys relative to the camera) / (player, input, dt) => ({ x, z, run? }) (null stands still). presets.player.* fill it. Given once: a game that steers the player for a while takes control (engine.control.take(player, { owner, layer: 'script', step }))
114
116
  - `cameraFollow?: boolean` true: the camera module follows the player (and back after a vehicle, and on a new session). Omitted with a camera installed warns in dev
115
117
  - **CharacterOptions** Character parameters (shared by the player and NPCs)
116
- - `colors?: { body?, skin?, legs?, hair? }` Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair); the style tints by material role
118
+ - `colors?: { body?, skin?, legs?, hair? }` Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair)
117
119
  - `speed?: number` Walking speed (m/s), default 4.5
118
120
  - `runSpeed?: number` Running speed (m/s), default 7
119
121
  - `radius?: number` Collision radius (meters), default 0.4
@@ -8,13 +8,13 @@ Lightweight collision (collision() module): no clipping while walking, the camer
8
8
  - `cameraPad?: number` Margin between the camera and obstacles (meters), default 0.5
9
9
  - `cameraMin?: number` Nearest camera distance (meters), default 1.5
10
10
  - `walkableWaterMargin?: number` Height above the water surface (meters) at which it counts as walkable, default 0.2
11
- - `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'colliders' (default) / 'meshes' registered static meshes (engine.rays) / 'both'
11
+ - `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'both' (default) / 'colliders' / 'meshes' = static meshes registered with engine.rays.addStatic(mesh, { occluder: true })
12
12
 
13
13
  ## Methods and properties
14
14
  - `collision.addCircle(position: PositionLike, opts?: CircleColliderOptions) → Handle` — Add a circle collider (pillar, campfire): position is the center, e.g. addCircle(mesh, { radius: 1 }). Returns a handle { remove() }
15
15
  - `collision.addBox(position: PositionLike, opts?: BoxColliderOptions) → Handle` — Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() }
16
16
  - `collision.addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?, height?, y?, occluder? }) → Handle` — 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() }
17
- - `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — 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() }
17
+ - `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — 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() }
18
18
  - `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — Is a character of this radius touching addBlocked ground at (x, z)
19
19
  - `collision.addObject(obj: Object3D, opts?: { pad?: number; occluder?: boolean }) → Handle` — Add a collider from an object's bounding box, pad expands outward (meters), occluder as in addBox. Returns a handle { remove() }
20
20
  - `collision.forEachStatic(fn: (type, data) => void)` — Iterate all static colliders added by hand