threedog 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +21 -13
  3. package/core/Assets.js +23 -12
  4. package/core/Audio.js +1 -1
  5. package/core/Baked.js +14 -23
  6. package/core/Budget.js +2 -2
  7. package/core/DebugOverrides.js +33 -18
  8. package/core/Describe.js +10 -11
  9. package/core/Engine.js +50 -46
  10. package/core/I18n.js +2 -2
  11. package/core/Input.js +11 -5
  12. package/core/Inspect.js +6 -3
  13. package/core/InspectMaterials.js +2 -3
  14. package/core/InspectPerf.js +11 -4
  15. package/core/MaterialInfo.js +7 -5
  16. package/core/Rays.js +7 -2
  17. package/core/Stream.js +2 -3
  18. package/core/UrlState.js +49 -9
  19. package/core/Views.js +1 -0
  20. package/core/adaptive.js +2 -2
  21. package/core/assetEntry.js +5 -2
  22. package/core/assetLoad.js +13 -15
  23. package/core/assetManifest.js +6 -3
  24. package/core/assetReport.js +4 -4
  25. package/core/batchGroups.js +9 -1
  26. package/core/catalog.js +16 -3
  27. package/core/chunkStream.js +1 -1
  28. package/core/copies.js +1 -1
  29. package/core/debugView.js +4 -4
  30. package/core/describeRender.js +104 -28
  31. package/core/describeText.js +6 -6
  32. package/core/errorCodes.js +72 -45
  33. package/core/errorHints.js +4 -1
  34. package/core/errors.js +4 -4
  35. package/core/events.generated.js +1 -0
  36. package/core/gameLights.js +9 -2
  37. package/core/lifecycle.js +2 -4
  38. package/core/lightWatch.js +5 -3
  39. package/core/loop.js +18 -11
  40. package/core/math.js +7 -0
  41. package/core/moduleSlots.js +32 -7
  42. package/core/moduleTypes.js +20 -7
  43. package/core/modules.js +7 -7
  44. package/core/namedModel.js +8 -4
  45. package/core/owned.js +33 -30
  46. package/core/page.js +43 -10
  47. package/core/pictureSlots.js +33 -0
  48. package/core/pictureWriters.js +343 -0
  49. package/core/plugins.js +64 -96
  50. package/core/sceneDelta.js +12 -4
  51. package/core/sceneMethods.js +2 -9
  52. package/core/services.js +1 -1
  53. package/core/shadowTypes.js +1 -1
  54. package/core/shadows.js +405 -0
  55. package/core/sharedPoint.js +5 -19
  56. package/core/stackFrames.js +16 -5
  57. package/core/stacks.js +6 -6
  58. package/core/startup.js +9 -11
  59. package/core/thingExplain.js +1 -1
  60. package/core/things.js +1 -1
  61. package/core/tier.js +1 -1
  62. package/core/util.js +1 -1
  63. package/core/validate.js +1 -1
  64. package/core/view.js +43 -0
  65. package/docs/AI.md +62 -58
  66. package/docs/API.md +15 -15
  67. package/docs/CODEMAP.md +36 -54
  68. package/docs/COMMANDS.md +28 -25
  69. package/docs/CONVENTIONS.md +36 -30
  70. package/docs/MIGRATING-0.4.md +93 -1
  71. package/docs/MIGRATING-0.6.md +126 -0
  72. package/docs/MIGRATING-0.7.md +39 -0
  73. package/docs/THREE.md +24 -22
  74. package/docs/api/assets.md +5 -3
  75. package/docs/api/audio.md +2 -2
  76. package/docs/api/budget.md +4 -0
  77. package/docs/api/characters.md +3 -1
  78. package/docs/api/collision.md +2 -2
  79. package/docs/api/engine.md +47 -20
  80. package/docs/api/events.md +2 -1
  81. package/docs/api/grids.md +8 -1
  82. package/docs/api/ground.md +1 -1
  83. package/docs/api/hud.md +3 -0
  84. package/docs/api/input.md +3 -2
  85. package/docs/api/interactions.md +3 -1
  86. package/docs/api/inventory.md +1 -2
  87. package/docs/api/level.md +0 -1
  88. package/docs/api/lightPool.md +1 -1
  89. package/docs/api/occlusion.md +5 -0
  90. package/docs/api/particles.md +6 -3
  91. package/docs/api/pickups.md +6 -0
  92. package/docs/api/post.md +5 -3
  93. package/docs/api/sky.md +12 -10
  94. package/docs/api/terrain.md +12 -6
  95. package/docs/api/terrainDraw.md +12 -0
  96. package/docs/api/tools.md +8 -7
  97. package/docs/api/triggers.md +2 -0
  98. package/docs/api/vegetation.md +7 -2
  99. package/docs/api/vegetationDraw.md +10 -0
  100. package/docs/api/water.md +6 -2
  101. package/docs/api/weather.md +5 -0
  102. package/docs/api/weatherDraw.md +10 -0
  103. package/docs/api/world.md +1 -1
  104. package/docs/recipes/01-new-game.md +19 -23
  105. package/docs/recipes/03-items-pickups.md +25 -4
  106. package/docs/recipes/05-props-bake.md +53 -37
  107. package/docs/recipes/06-clock-events.md +3 -3
  108. package/docs/recipes/07-flow-scenes-pause.md +12 -3
  109. package/docs/recipes/08-weather-sky.md +45 -57
  110. package/docs/recipes/09-materials-lights-models.md +185 -0
  111. package/docs/recipes/10-blender-level.md +2 -2
  112. package/docs/recipes/11-vehicles.md +3 -3
  113. package/docs/recipes/13-animation.md +13 -7
  114. package/docs/recipes/14-custom-module.md +7 -5
  115. package/docs/recipes/15-perf.md +3 -3
  116. package/docs/recipes/16-dev-bridge.md +22 -12
  117. package/docs/recipes/18-world.md +10 -8
  118. package/docs/recipes/19-shooting-picking.md +7 -5
  119. package/docs/recipes/20-content-actions-save.md +6 -2
  120. package/docs/recipes/21-camera.md +8 -3
  121. package/docs/recipes/23-ops.md +1 -1
  122. package/docs/recipes/26-ui-parts.md +35 -11
  123. package/docs/recipes/28-terrain.md +12 -12
  124. package/docs/recipes/29-grid.md +14 -5
  125. package/docs/recipes/30-templates.md +8 -3
  126. package/docs/recipes/31-audio.md +4 -4
  127. package/docs/recipes/32-action-game.md +18 -4
  128. package/docs/recipes/34-environment-lighting.md +102 -38
  129. package/docs/recipes/35-picture-from-reference.md +147 -0
  130. package/docs/recipes/36-sky-ground-plants.md +158 -0
  131. package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
  132. package/docs/recipes/38-environment-hooks.md +67 -0
  133. package/docs/recipes/40-scene.md +106 -27
  134. package/docs/recipes/42-terrain-shape.md +1 -1
  135. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
  136. package/docs/recipes/44-water-weather-hooks.md +191 -0
  137. package/docs/recipes/45-cascaded-shadows.md +121 -23
  138. package/docs/recipes/46-blender-art-route.md +17 -20
  139. package/docs/recipes/47-island-snow-backdrop.md +10 -12
  140. package/docs/recipes/49-game-module-contract.md +1 -1
  141. package/docs/recipes/50-own-renderer.md +3 -3
  142. package/docs/recipes/52-around-the-picture.md +181 -0
  143. package/docs/recipes/53-ground-up-close.md +12 -12
  144. package/docs/recipes/54-three-idioms.md +18 -18
  145. package/docs/recipes/55-mods-time-wrap.md +17 -5
  146. package/docs/recipes/56-webgpu-tsl.md +66 -23
  147. package/docs/recipes/57-control.md +39 -0
  148. package/docs/recipes/58-input.md +3 -0
  149. package/docs/recipes/59-depth-post-effects.md +5 -5
  150. package/docs/recipes/60-judge-the-picture.md +39 -24
  151. package/docs/recipes/61-deploy.md +27 -0
  152. package/docs/recipes/62-picture-code.md +244 -0
  153. package/docs/recipes/63-third-person-start.md +77 -0
  154. package/docs/recipes/64-particles.md +35 -0
  155. package/examples/action/.threedog/content-index.json +1 -1
  156. package/examples/action/GAMEMAP.md +7 -5
  157. package/examples/action/main.js +5 -4
  158. package/examples/action/models.js +12 -14
  159. package/examples/action/picture/index.js +13 -0
  160. package/examples/action/picture/lights.js +35 -0
  161. package/examples/action/picture/materials.js +8 -0
  162. package/examples/action/picture/palette.js +33 -0
  163. package/examples/plain-picture/.threedog/content-index.json +1 -0
  164. package/examples/plain-picture/FINDINGS.md +53 -0
  165. package/examples/plain-picture/GAMEMAP.md +90 -0
  166. package/examples/plain-picture/main.js +48 -0
  167. package/examples/plain-picture/picture/index.js +21 -0
  168. package/examples/plain-picture/picture/lights.js +54 -0
  169. package/examples/plain-picture/picture/materials.js +24 -0
  170. package/examples/plain-picture/picture/palette.js +16 -0
  171. package/examples/plain-picture/picture/sky.js +37 -0
  172. package/examples/pullable.json +31 -9
  173. package/examples/rc2d/GAMEMAP.md +8 -3
  174. package/examples/rc2d/README.md +11 -6
  175. package/examples/rc2d/main.js +25 -33
  176. package/examples/rc2d/picture/index.js +18 -0
  177. package/examples/rc2d/picture/lights.js +11 -0
  178. package/examples/rc2d/picture/materials.js +18 -0
  179. package/examples/rc2d/picture/palette.js +15 -0
  180. package/examples/rc2d/picture/post.js +11 -0
  181. package/examples/rc2d/rc2d.js +18 -28
  182. package/examples/sheepisland/.threedog/content-index.json +1 -1
  183. package/examples/sheepisland/GAMEMAP.md +13 -10
  184. package/examples/sheepisland/assets.js +2 -2
  185. package/examples/sheepisland/content/templates.js +1 -1
  186. package/examples/sheepisland/content/vegetation.js +3 -1
  187. package/examples/sheepisland/main.js +15 -9
  188. package/examples/sheepisland/{style/models.js → models.js} +13 -24
  189. package/examples/sheepisland/picture/index.js +20 -0
  190. package/examples/sheepisland/picture/lights.js +34 -0
  191. package/examples/sheepisland/picture/materials.js +61 -0
  192. package/examples/sheepisland/picture/palette.js +60 -0
  193. package/examples/sheepisland/picture/sky.js +20 -0
  194. package/examples/sheepisland/views.js +1 -1
  195. package/examples/styletest/.threedog/content-index.json +1 -1
  196. package/examples/styletest/GAMEMAP.md +15 -11
  197. package/examples/styletest/main.js +20 -30
  198. package/examples/styletest/models.js +29 -29
  199. package/examples/styletest/params.js +1 -4
  200. package/examples/styletest/picture/env.js +38 -0
  201. package/examples/styletest/picture/index.js +16 -0
  202. package/examples/styletest/picture/lights.js +9 -0
  203. package/examples/styletest/picture/materials.js +28 -0
  204. package/examples/styletest/picture/palette.js +22 -0
  205. package/examples/techniques/contact-shadows/README.md +22 -23
  206. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  207. package/examples/techniques/contact-shadows/main.js +20 -18
  208. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  209. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  210. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  211. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  212. package/examples/techniques/day-night-grade/README.md +13 -16
  213. package/examples/techniques/day-night-grade/main.js +15 -25
  214. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  215. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  216. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  217. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  218. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  219. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  220. package/examples/techniques/interior-light/README.md +16 -13
  221. package/examples/techniques/interior-light/interiorLight.js +19 -17
  222. package/examples/techniques/interior-light/main.js +30 -67
  223. package/examples/techniques/interior-light/picture/index.js +24 -0
  224. package/examples/techniques/interior-light/picture/lights.js +52 -0
  225. package/examples/techniques/interior-light/picture/materials.js +13 -0
  226. package/examples/techniques/interior-light/picture/palette.js +32 -0
  227. package/examples/techniques/interior-light/picture/sky.js +40 -0
  228. package/examples/techniques/modular-building/README.md +4 -3
  229. package/examples/techniques/modular-building/kit.js +2 -2
  230. package/examples/techniques/modular-building/main.js +9 -17
  231. package/examples/techniques/modular-building/picture/index.js +17 -0
  232. package/examples/techniques/modular-building/picture/lights.js +26 -0
  233. package/examples/techniques/modular-building/picture/materials.js +13 -0
  234. package/examples/techniques/modular-building/picture/palette.js +23 -0
  235. package/examples/techniques/night-lights/README.md +15 -14
  236. package/examples/techniques/night-lights/main.js +20 -43
  237. package/examples/techniques/night-lights/nightLights.js +25 -21
  238. package/examples/techniques/night-lights/picture/index.js +18 -0
  239. package/examples/techniques/night-lights/picture/lights.js +44 -0
  240. package/examples/techniques/night-lights/picture/materials.js +15 -0
  241. package/examples/techniques/night-lights/picture/palette.js +34 -0
  242. package/examples/techniques/night-lights/picture/post.js +9 -0
  243. package/examples/techniques/night-lights/picture/sky.js +36 -0
  244. package/examples/techniques/outlines-and-rim/README.md +2 -2
  245. package/examples/techniques/outlines-and-rim/main.js +15 -38
  246. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  247. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  248. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  249. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  250. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  251. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  252. package/examples/techniques/procedural-animation/README.md +5 -3
  253. package/examples/techniques/procedural-animation/main.js +9 -7
  254. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  255. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  256. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  257. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  258. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  259. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  260. package/examples/techniques/procedural-surface/README.md +2 -0
  261. package/examples/techniques/procedural-surface/main.js +17 -55
  262. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  263. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  264. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  265. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  266. package/examples/techniques/stylized-shading/README.md +13 -14
  267. package/examples/techniques/stylized-shading/main.js +11 -42
  268. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  269. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  270. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  271. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  272. package/examples/techniques/stylized-shading/shading.js +2 -2
  273. package/examples/techniques/sun-and-key-light/README.md +20 -22
  274. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  275. package/examples/techniques/sun-and-key-light/main.js +19 -63
  276. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  277. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  278. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  279. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  280. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  281. package/examples/techniques/three-looks/README.md +21 -0
  282. package/examples/techniques/three-looks/main.js +58 -0
  283. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  284. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  285. package/examples/techniques/three-looks/picture/comic.js +27 -0
  286. package/examples/techniques/three-looks/picture/index.js +14 -0
  287. package/examples/techniques/three-looks/picture/sun.js +23 -0
  288. package/examples/techniques/wet-road/README.md +7 -4
  289. package/examples/techniques/wet-road/main.js +18 -38
  290. package/examples/techniques/wet-road/picture/index.js +17 -0
  291. package/examples/techniques/wet-road/picture/lights.js +57 -0
  292. package/examples/techniques/wet-road/picture/materials.js +16 -0
  293. package/examples/techniques/wet-road/picture/palette.js +24 -0
  294. package/examples/techniques/wet-road/picture/sky.js +46 -0
  295. package/examples/webgpu-tsl/GAMEMAP.md +9 -4
  296. package/examples/webgpu-tsl/README.md +13 -10
  297. package/examples/webgpu-tsl/main.js +30 -7
  298. package/examples/webgpu-tsl/picture/index.js +18 -0
  299. package/examples/webgpu-tsl/picture/lights.js +25 -0
  300. package/examples/webgpu-tsl/picture/materials.js +36 -0
  301. package/examples/webgpu-tsl/picture/palette.js +23 -0
  302. package/examples/webgpu-tsl/picture/post.js +16 -0
  303. package/examples/webgpu-tsl/picture/sky.js +30 -0
  304. package/examples/world/.threedog/content-index.json +1 -1
  305. package/examples/world/GAMEMAP.md +15 -12
  306. package/examples/world/art/humanoid.js +9 -13
  307. package/examples/world/art/index.js +2 -2
  308. package/examples/world/art/models.js +3 -4
  309. package/examples/world/art/shapes.js +2 -2
  310. package/examples/world/assets.js +2 -2
  311. package/examples/world/content/audio.js +1 -1
  312. package/examples/world/content/items.js +1 -1
  313. package/examples/world/content/props.js +1 -1
  314. package/examples/world/content/templates.js +1 -1
  315. package/examples/world/content/vegetation.js +1 -1
  316. package/examples/world/main.js +10 -10
  317. package/examples/world/models.js +17 -7
  318. package/examples/world/picture/index.js +20 -0
  319. package/examples/world/picture/lights.js +41 -0
  320. package/examples/world/picture/materials.js +34 -0
  321. package/examples/world/picture/palette.js +74 -0
  322. package/examples/world/picture/post.js +9 -0
  323. package/examples/world/picture/sky.js +39 -0
  324. package/index.d.ts +7 -16
  325. package/index.js +7 -7
  326. package/llms.txt +15 -13
  327. package/modules/ambience/Ambience.js +1 -1
  328. package/modules/calendar/Calendar.js +1 -1
  329. package/modules/calendar/index.js +1 -0
  330. package/modules/camera/FirstPersonCamera.js +1 -1
  331. package/modules/camera/FixedCamera.js +2 -2
  332. package/modules/camera/RtsCamera.js +1 -1
  333. package/modules/camera/common.js +7 -5
  334. package/modules/characters/Character.js +15 -10
  335. package/modules/characters/NPC.js +5 -5
  336. package/modules/characters/assetModel.js +5 -4
  337. package/modules/characters/index.js +28 -3
  338. package/modules/characters/movers/common.js +6 -1
  339. package/modules/characters/movers/manual.js +3 -0
  340. package/modules/characters/movers/support.js +25 -11
  341. package/modules/characters/npcSim.js +5 -1
  342. package/modules/characters/proceduralRig.js +18 -4
  343. package/modules/characters/useModel.js +2 -2
  344. package/modules/collision/Collision.js +4 -2
  345. package/modules/content/index.js +8 -0
  346. package/modules/content/models.js +56 -11
  347. package/modules/content/props.js +5 -3
  348. package/modules/content/rules.js +12 -4
  349. package/modules/content/templates.js +5 -3
  350. package/modules/gameplay/Interactions.js +91 -16
  351. package/modules/gameplay/Inventory.js +3 -3
  352. package/modules/gameplay/dialogueBox.js +1 -1
  353. package/modules/gameplay/dialogueBubbles.js +1 -1
  354. package/modules/gameplay/interactionPrompt.js +1 -1
  355. package/modules/gameplay/interactions.contract.js +1 -1
  356. package/modules/gameplay/inventoryOps.js +2 -2
  357. package/modules/gameplay/pickups.js +62 -24
  358. package/modules/gameplay/questLog.js +2 -2
  359. package/modules/grid/Layer.js +13 -0
  360. package/modules/grid/index.js +40 -11
  361. package/modules/grid/preview.js +24 -15
  362. package/modules/grid/tiles.js +15 -19
  363. package/modules/hlod/index.js +3 -2
  364. package/modules/hud/index.js +13 -0
  365. package/modules/hud/parts.js +9 -7
  366. package/modules/level/index.js +5 -4
  367. package/modules/lights/index.js +12 -8
  368. package/modules/music/Music.js +1 -1
  369. package/modules/particles/Particles.js +41 -20
  370. package/modules/particles/effect.js +21 -6
  371. package/modules/photo/Photo.js +11 -10
  372. package/modules/settings/Settings.js +7 -7
  373. package/modules/settings/apply.js +5 -5
  374. package/modules/settings/sections.js +2 -2
  375. package/modules/settings/strings.js +1 -1
  376. package/modules/sky/Sky.js +104 -89
  377. package/modules/sky/clouds.js +16 -17
  378. package/modules/sky/dome.js +100 -0
  379. package/modules/sky/domeLayers.js +5 -5
  380. package/modules/sky/environment.js +45 -169
  381. package/modules/sky/fog.js +5 -180
  382. package/modules/sky/frame.js +26 -90
  383. package/modules/sky/season.js +3 -3
  384. package/modules/sky/shader.js +35 -29
  385. package/modules/sky/skyModule.js +25 -22
  386. package/modules/sky/tint.js +9 -11
  387. package/modules/terrain/ChunkManager.js +29 -12
  388. package/modules/terrain/draw.js +154 -0
  389. package/modules/terrain/index.js +44 -66
  390. package/modules/terrain/terrainDefaults.js +2 -2
  391. package/modules/terrain/terrainEdit.js +1 -1
  392. package/modules/terrain/terrainGen.js +2 -2
  393. package/modules/triggers/index.js +10 -6
  394. package/modules/vegetation/Vegetation.js +58 -17
  395. package/modules/vegetation/draw.js +191 -0
  396. package/modules/vegetation/groundChunks.js +1 -1
  397. package/modules/vegetation/index.js +10 -10
  398. package/modules/water/Water.js +135 -88
  399. package/modules/water/surface.js +53 -53
  400. package/modules/weather/Weather.js +52 -17
  401. package/modules/weather/particles.js +13 -5
  402. package/modules/weather/shaders.js +1 -1
  403. package/modules/weather/weatherDraw.js +141 -0
  404. package/modules/world/World.js +2 -2
  405. package/modules/world/views.js +1 -1
  406. package/package.json +3 -2
  407. package/presets.js +2 -2
  408. package/render/PostFX.js +199 -41
  409. package/render/backend.js +52 -6
  410. package/render/cascades.js +195 -0
  411. package/render/cascades.tsl.js +96 -0
  412. package/render/daylight.js +39 -0
  413. package/render/detail.js +5 -5
  414. package/render/effects.js +41 -26
  415. package/render/fx/cel.tsl.js +42 -0
  416. package/render/fx/index.js +7 -5
  417. package/render/fx/patchNodes.tsl.js +1 -1
  418. package/render/fx/postWebGPU.tsl.js +30 -7
  419. package/render/fx/sky.tsl.js +19 -92
  420. package/render/fx/water.tsl.js +1 -1
  421. package/render/layers.js +14 -0
  422. package/render/lighting.js +6 -5
  423. package/render/lightmap.js +142 -0
  424. package/render/lights.js +23 -201
  425. package/render/materials.js +44 -160
  426. package/render/neutral.js +23 -0
  427. package/render/occlusion.js +184 -0
  428. package/render/ownFrame.js +1 -1
  429. package/render/patches.js +34 -29
  430. package/render/postWebGL.js +11 -3
  431. package/render/probes.js +179 -122
  432. package/render/slots.js +4 -4
  433. package/render/terms.js +53 -101
  434. package/render/uniformDecl.js +1 -1
  435. package/types/core.d.ts +333 -296
  436. package/types/gameplay.d.ts +65 -26
  437. package/types/generated/core/Audio.d.ts +1 -1
  438. package/types/generated/core/DebugOverrides.d.ts +14 -6
  439. package/types/generated/core/Input.d.ts +9 -2
  440. package/types/generated/core/page.d.ts +9 -2
  441. package/types/generated/modules/grid/Layer.d.ts +8 -0
  442. package/types/generated/modules/grid/index.d.ts +29 -5
  443. package/types/generated/modules/particles/Particles.d.ts +13 -6
  444. package/types/generated/modules/sky/Sky.d.ts +85 -18
  445. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  446. package/types/generated/modules/water/Water.d.ts +50 -3
  447. package/types/generated/modules/weather/Weather.d.ts +33 -3
  448. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  449. package/types/generated/modules/world/World.d.ts +2 -2
  450. package/types/generated/render/PostFX.d.ts +53 -10
  451. package/types/generated/render/lighting.d.ts +29 -0
  452. package/types/generated/render/materials.d.ts +19 -44
  453. package/types/generated/render/occlusion.d.ts +13 -0
  454. package/types/physics.d.ts +5 -3
  455. package/types/tsl.d.ts +8 -0
  456. package/types/world.d.ts +376 -57
  457. package/ui/Focus.js +12 -2
  458. package/ui/LoadingScreen.js +2 -2
  459. package/ui/Parts.js +8 -4
  460. package/ui/UI.js +10 -10
  461. package/ui/cursor.js +1 -1
  462. package/ui/theme.js +33 -27
  463. package/ui/touchPart.js +1 -1
  464. package/core/look/coreParts.js +0 -219
  465. package/core/look/part.js +0 -253
  466. package/core/look/points.js +0 -255
  467. package/core/look/report.js +0 -96
  468. package/core/look/shadowPart.js +0 -63
  469. package/core/look/state.js +0 -45
  470. package/core/look/write.js +0 -70
  471. package/core/styleParts.js +0 -114
  472. package/docs/api/style.md +0 -136
  473. package/docs/api/terrainLook.md +0 -10
  474. package/docs/api/vegetationLook.md +0 -10
  475. package/docs/api/weatherLook.md +0 -10
  476. package/docs/recipes/09-style.md +0 -218
  477. package/docs/recipes/35-style-from-reference.md +0 -153
  478. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  479. package/docs/recipes/38-environment-look-hooks.md +0 -99
  480. package/docs/recipes/41-thing-registry.md +0 -97
  481. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  482. package/docs/recipes/48-make-material.md +0 -75
  483. package/docs/recipes/52-look.md +0 -282
  484. package/examples/action/look.js +0 -5
  485. package/examples/sheepisland/style/index.js +0 -79
  486. package/examples/styletest/look.js +0 -11
  487. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  488. package/examples/webgpu-tsl/tslScene.js +0 -75
  489. package/examples/world/style/index.js +0 -61
  490. package/examples/world/style/plugins/10-bloom.js +0 -5
  491. package/modules/sky/cascades.js +0 -186
  492. package/modules/sky/cascades.tsl.js +0 -82
  493. package/modules/sky/look.js +0 -54
  494. package/modules/sky/lookFog.js +0 -76
  495. package/modules/sky/lookShadow.js +0 -62
  496. package/modules/sky/lookSky.js +0 -169
  497. package/modules/sky/shadow.js +0 -98
  498. package/modules/terrain/look.js +0 -83
  499. package/modules/terrain/lookGround.js +0 -66
  500. package/modules/vegetation/look.js +0 -119
  501. package/modules/vegetation/lookWind.js +0 -98
  502. package/modules/water/look.js +0 -91
  503. package/modules/water/surfaceDefaults.js +0 -3
  504. package/modules/weather/look.js +0 -74
  505. package/modules/weather/weatherLook.js +0 -135
  506. package/render/lookGlow.js +0 -139
  507. package/render/lookSurface.js +0 -224
  508. package/render/postLook.js +0 -164
  509. package/render/surface.js +0 -105
  510. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  511. package/types/style.d.ts +0 -671
@@ -1,14 +1,14 @@
1
1
  # Props and baking
2
2
 
3
3
  **In this recipe**: 1. Prop data · 2. Large code-generated models and baking · 2a. Models in plain three.js · 2b. Many copies of one model ·
4
- 2c. Art iteration loop · 2d. Where art comes from · 3. Loading: what is it waiting for, what failed, does it… · 3b. Asset packs · 4. Verify ·
4
+ 2c. Art iteration loop · 2d. Where art comes from · 2e. Plants on your own geometry and spots · 3. Loading: what is it waiting for, what failed, does it… · 3b. Asset packs · 4. Verify ·
5
5
  5. Deleting objects
6
6
 
7
7
  **Props** are a small number of hand-placed objects (a tree next to a cabin, rocks, street lamps). Write them as data; each entry becomes an ordinary
8
8
  `kind: 'prop'` record in `engine.world` (needs `world()`, which `openWorld()` already includes). The model is created only when the player gets close
9
9
  (within terrain view distance), and **the collision body and ray registration are built with the model and removed when the player leaves** (only
10
10
  things near the player need to block the way).
11
- Large repeated areas (forests, grass) don't use this; use `content/vegetation.js` (instanced vegetation).
11
+ Large repeated areas (forests, grass) don't use this; use `content/vegetation.js` (instanced vegetation), or section 2e for plants on your own geometry.
12
12
 
13
13
  ## 1. Prop data
14
14
  `games/<game>/content/props.js` (a list; remember to add it to `content/index.js`):
@@ -23,7 +23,7 @@ export default [
23
23
  ```
24
24
  Fields: `id` (stable id, see below), `model`, `place` + `x/z` (relative to the place), `floor` (on multi-layer ground — a second storey, a bridge
25
25
  deck, a lower dungeon level — the reference height of the layer it stands on; a level-marker place lends its own height), `y` (height above that
26
- ground), `rot`, `scale`, `collide` (`'box'` / `'circle'` / omitted = does not block), `static: false` (do not register for rays), `batch: false` (see 2b).
26
+ ground), `rot`, `scale`, `collide` (`'box'` / `'circle'` / `{ circle: 0.25, occluder: false }` / omitted = does not block; a circle stands on the model's base, see recipes/30-templates.md), `static: false` (do not register for rays), `batch: false` (see 2b).
27
27
  An entry with `template` instead of `model` (`{ template: 'chest', x: 3, z: 1 }`) places an instance of a content template: a reusable object with
28
28
  interaction, container and saved state (recipe 30).
29
29
  A model is always an **asset name**, never a path or a function (`npm run check` reports both): register it in a manifest or asset pack first.
@@ -61,7 +61,7 @@ there when you come back.
61
61
  Procedural models of an asset pack (props, templates, vegetation, pickups) are built through that one path: if baked, the file in
62
62
  `public/models/baked/` is read; during development the result is cached automatically.
63
63
  Other things made in code have one home each: a texture made in code goes in the manifest's `textures` (a Texture or a function returning one), a
64
- sound made in code (a synth function) in its `sounds`, and a material made in code is a `style.materials` role (recipe 09), not an asset.
64
+ sound made in code (a synth function) in its `sounds`, and a material made in code is plain three.js in the game's `picture/` (recipe 09), not an asset.
65
65
  Models are obtained asynchronously and the loading screen waits for them (`engine.world.ready`: every model that should exist nearby at the start is
66
66
  built); `world.view(id)` works after `start()`; a model built later when the player walks up appears one or two frames late (to wait,
67
67
  `await engine.world.whenReady`).
@@ -77,7 +77,7 @@ const block = await engine.assets.model('city-block');
77
77
  engine.use(level({ url: 'city-block' })); // a level reads it by name (the city example does this): baked file and cache both apply, and loading a save can switch back to this map
78
78
  ```
79
79
  To package a release or edit it in Blender, create `bake.js` in the game folder (`npm run bake -- -w <game>` reads the `bake` export of `bake.js`
80
- in that game's folder). A game's look lives in its own `style/` folder; a model built there is baked the same way, by importing its
80
+ in that game's folder). A game's picture lives in its own `picture/` folder; a model built there is baked the same way, by importing its
81
81
  builder into `bake.js`:
82
82
  ```js
83
83
  // games/<game>/bake.js
@@ -95,27 +95,25 @@ No model file yet? Don't add loose `THREE.Mesh(new THREE.BoxGeometry())` calls t
95
95
  it by name, and use the name everywhere. Later a `.glb` registered under the same name replaces it with no other change.
96
96
 
97
97
  **The generator contract**
98
- - Return a `BufferGeometry` (drawn with `makeMaterial('prop', { vertexColors })` in content, `'default'` from `assets.model`) or an `Object3D`
98
+ - Return a `BufferGeometry` (drawn with a neutral gray material, or white under its vertex colors) or an `Object3D`
99
99
  (a Mesh or a Group, with any number of meshes and materials, used as it is). It may be `async`.
100
100
  - Arguments: `model: ['name', ...args]` in content passes them as written (each argument list is its own cached model). Or declare a schema,
101
101
  `{ build, params: { height: { type: 'number', min: 1, max: 8, default: 3 }, leaf: { type: 'color', default: 0x4a7a3a } } }` (the
102
102
  `core/params.js` format, plus `'color'`): the generator then gets one object, defaults < dev panel values < a call's own `['pine', { height: 5 }]`,
103
103
  and a typo or wrong type throws naming the field.
104
- - Written as `function` (not an arrow), `this` is `{ palette, engine }`: `this.palette` = `style.palette`, `this.engine` for `this.engine.makeMaterial`.
104
+ - Written as `function` (not an arrow), `this` is `{ palette, engine }`: `this.palette` = `engine.assets.palette`, `this.engine` = the engine.
105
105
  - Shadows: `{ build, castShadow: false }` in the manifest turns them off for every mesh. Without it, a generator that set `castShadow` or
106
106
  `receiveShadow` on any of its meshes keeps its own flags (a rug that receives but does not cast); one that set none casts and receives
107
107
  everywhere. The same rule holds for `assets.model(name)` and content props.
108
108
  - It runs once per name + params; every placement is a clone sharing geometry and materials (`engine.assets.model(name)` and content props alike).
109
- - Cache key = name + the generator's source (its file and imports) + params + `style.palette`. Values it reads from outer variables must go in
109
+ - Cache key = name + the generator's source (its file and imports) + params + `engine.assets.palette`. Values it reads from outer variables must go in
110
110
  `params`, or a change keeps the stale model. In dev a build slower than `assets.cacheMinMs` (20 ms) is stored as GLB in `.threedog/cache` and
111
111
  read back next time; `npm run bake` writes the same GLB to `public/models/baked/` (section 2). Neither is needed: unbaked generators run in the
112
112
  built game (`npm run build`) too.
113
113
  - What the GLB round trip keeps: the hierarchy, names, `userData`, shadow flags, visibility, every material's type and settings, and textures in
114
- standard slots (`map`, `normalMap`, ...; also ones made in code like `CanvasTexture`). A material made with `makeMaterial(role)` is rebuilt from
115
- the current style, keeping the call's map strengths (`aoMapIntensity`, `lightMapIntensity`, `normalScale`, `bumpScale`,
116
- `displacementScale`, `envMapIntensity`). A mesh with a material array comes back as one mesh per material. **Lost**: a material's own
117
- `onBeforeCompile`, `lightMap` / `specularMap` / `envMap` and a hand-made toon `gradientMap` (glTF has no slot: the bake warns once naming the
118
- model and slots), `ShaderMaterial` texture uniforms, and the identity of uniform objects (code holding `mat.uniforms.time` stops driving the
114
+ standard slots (`map`, `normalMap`, ...; also ones made in code like `CanvasTexture`). A mesh with a material array comes back as one mesh per
115
+ material. **Lost**: a material's own `onBeforeCompile` and `applyEffects` patches, `lightMap` / `specularMap` / `envMap` and a toon `gradientMap`
116
+ (glTF has no slot: the bake warns once naming the model and slots), `ShaderMaterial` texture uniforms, and the identity of uniform objects (code holding `mat.uniforms.time` stops driving the
119
117
  copy). For such a model write `{ build, cache: false }` (never stored in the dev cache, and don't bake it), or set that material after loading.
120
118
 
121
119
  ```js
@@ -123,8 +121,8 @@ import * as THREE from 'three';
123
121
  import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
124
122
 
125
123
  function lampPost() {
126
- const pole = this.engine.makeMaterial('metal', { color: 0x3a3d42 }); // (a) a role: follows the style
127
- const glass = this.engine.makeMaterial('lamp', { color: 0xfff2c0, emissive: 0xffd27a, emissiveIntensity: 1.5 });
124
+ const pole = new THREE.MeshStandardMaterial({ color: this.palette.metal ?? 0x3a3d42, roughness: 0.5, metalness: 0.8 });
125
+ const glass = new THREE.MeshStandardMaterial({ color: 0xfff2c0, emissive: 0xffd27a, emissiveIntensity: 1.5 });
128
126
  const root = new THREE.Group();
129
127
  const base = new THREE.Mesh(new RoundedBoxGeometry(0.5, 0.3, 0.5, 2, 0.05), pole); base.position.y = 0.15;
130
128
  const post = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.07, 3, 12), pole); post.position.y = 1.8;
@@ -137,15 +135,15 @@ engine.assets.manifest({ name: 'props', models: { lampPost } });
137
135
  // content/props.js: { model: 'lampPost', x: 4, z: 2, collide: 'circle' } code: engine.add(await engine.assets.model('lampPost'), { id: 'lamp-1' })
138
136
  ```
139
137
 
140
- **Where the colors come from: two equal choices**
141
- - (a) **Material roles**, when the model should follow the style: `this.engine.makeMaterial('metal', ...)` (recipe 48). The pack's
142
- `materials.metal` (or `look.materials.set('metal', ...)`) decides type and shading; a color the generator leaves out comes from the pack, so
143
- `style: [pack, { materials: { metal: { color: 0x7a5a3a } } }]` recolors every lamp post, cached and baked copies included (they are rebuilt from
144
- the current pack). A color you pass is this model's own and stays.
145
- - (b) **The model's own three.js materials** (`new THREE.MeshStandardMaterial({ map: canvasTexture })`, a `ShaderMaterial`), when the colors
146
- belong to the asset itself, like the colors painted into a file. A pack swap leaves them as they are.
147
- - Vertex colors are a third option for a merged model: `mergeColored([[geometry, this.palette.wood], ...])` returns one geometry, retinted by
148
- `style.palette`.
138
+ **Where the colors come from**
139
+ - **The model's own three.js materials** (`new THREE.MeshStandardMaterial({ map: canvasTexture })`, a `ShaderMaterial`), any type a game's picture calls for.
140
+ - **Colors shared between models** live in the palette: read `this.palette.metal` in the generator, as the lamp post does.
141
+ - Vertex colors for a merged model: `mergeColored([[geometry, this.palette.wood], ...])` returns one geometry.
142
+
143
+ **The palette.** `engine.assets.palette` is a plain object of named colors: `engine.assets.palette = { wood: 0x8a5a36, leaf: 0xd98a3a }`, or write one key.
144
+ Generators and code-made textures read it as `this.palette`. Set it before the models load; after a write, whatever is asked for next is built from the
145
+ new colors, while copies already placed keep theirs. `.glb` files never follow it, and a baked file (built with no palette) is skipped while the palette
146
+ has keys, unless its bake entry says `source: 'file'`.
149
147
 
150
148
  Very detailed models (faces, sculpted shapes, hand-painted textures) are faster in Blender: export a GLB and register it (recipe 46).
151
149
 
@@ -182,7 +180,7 @@ engine.batching.enabled = false; // global switch; createEngine({
182
180
  geometry `hlod` registered (hlod owns far, batching owns near).
183
181
 
184
182
  ## 2c. Art iteration loop: edit -> hot swap -> gallery -> compare
185
- Works for any model made in code (a hut, a weapon, a coral, a character body), in any art style; the tools only build and show, they add no look.
183
+ Works for any model made in code (a hut, a weapon, a coral, a character body), in any art style; the tools only build and show, they add no picture.
186
184
  For the models that matter (characters, main buildings, props repeated across the level), think through the parts and their proportions before
187
185
  writing code, and afterwards look at the model on its own, not only inside the level: `threedog gallery --shots` draws each one from a single
188
186
  three-quarter view under three lights. When something seems off, turn it on the live turntable (`threedog gallery`) to see it from another side.
@@ -195,15 +193,15 @@ three-quarter view under three lights. When something seems off, turn it on the
195
193
  schema's `default` where the model is registered.
196
194
  - **Review all at once**: `?gallery=1` on the dev page, or `threedog gallery`, puts every registered model and texture on a turntable under
197
195
  three neutral light setups (midday, low sun, overcast). `threedog gallery --shots` writes `.threedog/gallery/<name>-<light>.png` and an
198
- `index.html` of all of them, so one look covers the whole set.
196
+ `index.html` of all of them, so one picture covers the whole set.
199
197
  - **Outline and light/dark on their own**: `--shots --mode silhouette,value` adds `<name>-silhouette.png` (the model pure black on white) and
200
198
  `<name>-value.png` (the midday shot in grayscale) per asset, with facts printed and stored in `index.json`: `fill` (share of the frame),
201
199
  `boxFill` (share of its own bounding box), `aspect`, and luminance `p5` / `p50` / `p95` inside the outline. They are measurements, not
202
200
  grades. Principle for reading them: a shape the player must recognize at play distance usually still reads as a silhouette, and a
203
- narrow p5-p95 spread means hue carries the form; whether that is right depends on the game's look and camera, so compare assets that must
201
+ narrow p5-p95 spread means hue carries the form; whether that is right depends on the game's picture and camera, so compare assets that must
204
202
  be told apart with each other rather than with a fixed number.
205
- - **Compare with the reference**: `threedog style compare <reference.png> .threedog/gallery/<name>-midday.png --out diff.png` gives numbers
206
- for one asset against its reference crop, the same way as for a whole screenshot (`recipes/35-style-from-reference.md`).
203
+ - **Compare with the reference**: `threedog picture compare <reference.png> .threedog/gallery/<name>-midday.png --out diff.png` gives numbers
204
+ for one asset against its reference crop, the same way as for a whole screenshot (`recipes/35-picture-from-reference.md`).
207
205
 
208
206
  ## 2d. Where art comes from
209
207
  The engine ships no art and picks no source: the game records its choice per kind (ground, vegetation, characters, props, effects, sounds) in
@@ -211,12 +209,14 @@ the DESIGN.md "Asset sources" row, and every source ends up the same way, as a n
211
209
 
212
210
  | Source | Good for | How it enters |
213
211
  |---|---|---|
214
- | Code (sections 2 and 2a: three.js geometry, `mergeColored`, material roles) | blockout, props, variations, anything tuned by `params` | a generator function in the manifest |
212
+ | Code (sections 2 and 2a: three.js geometry, `mergeColored`, three.js materials) | blockout, props, variations, anything tuned by `params` | a generator function in the manifest |
215
213
  | Blender -> glTF | sculpted or painted finish, rigs and clips | a `.glb` path; export settings, scale (1 unit = 1 m, Y-up, applied transforms), naming and which materials survive are in `recipes/46-blender-art-route.md` |
216
214
  | Free libraries (for example Kenney and Quaternius models, Poly Haven textures and HDRIs) | a lot of consistent content fast | the files in `public/` or an asset pack (section 3b), then `threedog assets` |
217
215
  | Your own earlier games | an effect, material, model or texture you already made and liked | `threedog lib list` / `lib pull` (below), or `threedog art copy ../earlier-game name` |
218
216
  | AI-generated 3D / textures | one-off props, texture variations | export glTF / PNG, then the same checks as any file: `threedog assets check`, scale, origin, triangle count, UVs |
219
217
 
218
+ **Does it fit?** Every entry has one card, measured at `lib add`: what it needs, what it provides, which shared three.js values it writes, its size (1 unit = 1 meter, up axis, origin, texture color space), its style and a short usage; `threedog lib list <word> --card` prints it. Tag a style with `--style` in your own words (a pixel-art dungeon and a watercolor village both work): only tags can say that, and two entries with no tag in common are reported. After pulling several pieces, `threedog lib check` says what is missing and what clashes, and `threedog lib status` says which copies this game changed. Nothing is forced: fix a clash in your copy, or leave a note you meant.
219
+
220
220
  **Your own library.** `threedog lib add <file|folder|exportName> -w earlier-game` keeps a piece of a finished game in `~/.threedog/library` (outside the engine; `THREEDOG_LIBRARY` or `--lib` moves it) with a summary, the use line and the backends it works on; `threedog lib list [words]` searches it, `threedog lib pull <name>` copies it into this game and prints the use line (a code entry: its files go to `plugins/<name>/` and pull writes `plugins/<name>.js`, the one wiring line that calls its factory, from the entry's plug line: `lib add --plug "makeWater({ size: 4 })"` sets it, otherwise it calls the exported function; change the arguments in that file), `threedog lib page` writes a page with all previews. Look here before writing an effect from scratch. A pulled entry is a copy with no link back and no update: change it to fit this game rather than keeping it as it was, or every game ends up looking alike.
221
221
 
222
222
  **Rules (correctness and licensing):**
@@ -229,12 +229,28 @@ the DESIGN.md "Asset sources" row, and every source ends up the same way, as a n
229
229
 
230
230
  **Principles (style, flexible):**
231
231
  - Mixed sources read as one game when they share one texture language (flat color, painted, or photo-based; one texel density; one
232
- roughness range) and one palette. When a source does not match, re-material it: keep its shape and swap its materials for the game's roles
233
- (`recipes/46-blender-art-route.md` section 5) or tint it from the palette, rather than adding a second look.
232
+ roughness range) and one palette. When a source does not match, re-material it: keep its shape and swap its materials for the game's own
233
+ (`recipes/46-blender-art-route.md` section 5) or tint it from the palette, rather than adding a second style.
234
234
  - AI-generated meshes usually need cleanup: merge stray parts, set the origin at the base, reduce triangles, and replace baked-in lighting in
235
235
  the texture so the game's lights decide the shading.
236
236
  - Put a new asset next to the existing ones in `threedog gallery --shots` (and `--mode silhouette,value`) to see whether it stands apart.
237
237
 
238
+ ## 2e. Plants on your own geometry and spots
239
+ Grass, flowers, bushes and trees need no model files and no random scatter: give `vegetation.define` a three.js geometry and the places you want. One instanced
240
+ mesh per species, wind, shadows, LOD and felling come with it; the geometry (and material) stay yours.
241
+ ```js
242
+ import { THREE, vegetation } from 'threedog'; // collision() must be installed for the collider below
243
+ engine.use(vegetation({ area: { min: [-30, -30], max: [30, 30] } })); // on any ground: setGround, a level, or the flat default
244
+ const crown = new THREE.IcosahedronGeometry(1.2, 1).translate(0, 3, 0); // geometry baked at its final shape; origin at the foot
245
+ engine.vegetation.define('tree', {
246
+ geometry: crown, material: new THREE.MeshStandardMaterial({ color: 0x3f7a3a, flatShading: true }), // omitted: engine.vegetation.material
247
+ positions: [[-8, 4], [6, -3, 1.3], [10, 9, 0.8, 1.2]], // [x, z] | [x, z, scale] | [x, z, scale, yaw], planted at the ground height
248
+ wind: 0.2, castShadow: true, rule: { collider: 0.5 } }); // collider: a trunk radius players and NPCs cannot walk through
249
+ const hit = engine.vegetation.instanceAt(engine.actorPosition(), { radius: 2, species: 'tree' }); // the nearest one, or null
250
+ ```
251
+ `define` with a model name returns a Promise; with a `geometry` it is immediate. Many small spots (grass) use `rule: { perChunk }` and `nearOnly: true` instead
252
+ of `positions`; recipe 10 section 4 has both, `densityMap` and felling (`removeInstance`).
253
+
238
254
  ## 3. Loading: what is it waiting for, what failed, does it block the start
239
255
  Every asset load is a task in `engine.loading` (so are module init / `isReady`, the stream's nearby builds and the game's own steps). Each task has a
240
256
  phase (`queued` → `download` → `decode` → `upload` / `build` → `done` | `failed`), progress, the error (file, HTTP status, a texture or `.bin` the
@@ -272,14 +288,14 @@ engine.assets.manifest({ name: 'mine', models: { oak: '/models/my-oak.glb' } });
272
288
  ```
273
289
  A generator function is also an entry (`models: { pine: () => geometry }`): an asset pack exports its procedural models this way.
274
290
 
275
- Fonts are entries too, and a style names them instead of holding the file (a style is looks only):
291
+ Fonts are entries too, and the UI names them instead of holding the file:
276
292
  ```js
277
- const engine = createEngine({ canvas, style: [basePack, { ui: { fonts: ['pixel', 'pixelBold'], font: '"pixel", system-ui' } }] });
293
+ const engine = createEngine({ canvas, ui: { fonts: ['pixel', 'pixelBold'], theme: { font: '"pixel", system-ui' } } });
278
294
  engine.assets.manifest({ name: 'ui-fonts', base: '/fonts/', fonts: { pixel: 'pixel.woff2', pixelBold: { url: 'pixel-bold.woff2', family: 'pixel', weight: 700 } } });
279
295
  ```
280
296
  `family` defaults to the asset name; the other keys are FontFace descriptors (`weight`, `style`, `unicodeRange`, ...). `start()` loads the fonts
281
- `style.ui.fonts` lists (an unknown name stops it with the line to add); other font entries load only on `engine.assets.font(name)` or with
282
- `preload: true`. A file that fails falls back to the next family of `style.ui.font` unless it is `critical`.
297
+ `createEngine({ ui: { fonts } })` lists (an unknown name stops it with the line to add); other font entries load only on `engine.assets.font(name)` or with
298
+ `preload: true`. A file that fails falls back to the next family of `ui.theme.font` unless it is `critical`.
283
299
 
284
300
  ## 4. Verify
285
301
  - `npm run check`: prop model names and place names are validated. After `npm run map`, GAMEMAP.md has a props table.
@@ -292,4 +308,4 @@ engine.assets.manifest({ name: 'ui-fonts', base: '/fonts/', fonts: { pixel: 'pix
292
308
  ## 5. Deleting objects
293
309
  `engine.remove(obj)` deletes an object and frees its GPU memory; `engine.detach(obj)` only takes it off for a while (add it back with `engine.add`).
294
310
  Don't call `obj.removeFromParent()` or `scene.remove()` on meshes you built: their geometry and materials would leak.
295
- (`thing.remove` (`41-thing-registry.md`) deletes a registered object so that an undo can bring it back; `engine.remove` is final.)
311
+ (`thing.remove` (`40-scene.md`) deletes a registered object so that an undo can bring it back; `engine.remove` is final.)
@@ -66,13 +66,13 @@ The engine itself runs on the fixed step except the wall-clock items in the tabl
66
66
  "After how long / every how long" uses `engine.clock` (part of the core; one timer queue for every view: `{ channel: 'real' | '<channel>' }`, default calendar seconds; a removed timer never fires, not even later in the same step); "at what time every day / within a time window / when the season changes"
67
67
  uses `engine.calendar` (the `calendar()` module with a `dayLength`; at a fixed time of day these never fire).
68
68
 
69
- **The calendar is gameplay, the sky is a look.** `calendar()` owns the time of day, the day, seasons, the timers below and their save; NPC schedules,
69
+ **The calendar is gameplay, the sky is a picture.** `calendar()` owns the time of day, the day, seasons, the timers below and their save; NPC schedules,
70
70
  content `clock` conditions, audio rules `{ time }` / `{ daylight }`, `engine.skip({ to })` and the debug panel read it. `sky()` only reads it to draw
71
71
  the sun, moon, colors and season tint. So each kind of game installs what it needs:
72
72
  - an outdoor day-night game: `calendar(presets.calendar.cycle), sky()` (`openWorld()` installs both; its `calendar` / `time` / `dayLength` go to the calendar);
73
73
  - an indoor shop, office or dungeon with opening hours and NPC shifts: `calendar({ dayLength: 600, hoursPerDay: 24 })` and no sky at all;
74
74
  - a management sim on a painted backdrop or a game with its own sky dome: `calendar()` and the game's own drawing reading `engine.calendar.timeOfDay`
75
- (or `engine.uniforms.uTimeOfDay` from a sky that follows the calendar);
75
+ (or `engine.uniforms.uTimeOfDay`, which the calendar writes even with no sky);
76
76
  - a survival game with a short brutal day and long seasons: `calendar({ dayLength: 240, seasons: [{ name: 'thaw', days: 3 }, { name: 'frost', days: 9 }] })`;
77
77
  - an arena or a level at one frozen hour: `sky({ time: '18:30' })` alone (no calendar: the sky draws that fixed time; nothing has a schedule).
78
78
  A game's own calendar (turns, a lunar calendar) replaces the module by meeting `modules/calendar/contract.js` (recipe 55 "Replacing a module").
@@ -96,7 +96,7 @@ engine.events.on('bread:ready', ({ oven }) => engine.inventory?.add('bread', 1))
96
96
 
97
97
  engine.clock.every(30, () => spawnBird()); // every 30 calendar seconds (not 30 clock seconds)
98
98
  engine.calendar.daily(day => console.log('day', day)); // every day at 00:00
99
- engine.calendar.onSeason('winter', () => engine.weather?.set('snow', 20)); // needs seasons (presets.calendar.fourSeasons) and a 'snow' weather (presets.weather.temperate)
99
+ engine.calendar.onSeason('winter', () => engine.weather?.set('snow', { seconds: 20 })); // needs seasons (presets.calendar.fourSeasons) and a 'snow' weather (presets.weather.temperate)
100
100
 
101
101
  // Clock conversion: 'HH:MM' <-> fraction of a day 0-1
102
102
  engine.calendar.timeOfDay = parseClock('17:30'); // jump straight to 17:30 (see the catch-up rules below)
@@ -1,5 +1,7 @@
1
1
  # Scene transitions and pause (flow)
2
2
 
3
+ **In this recipe**: 1. Pause, title, ending · 1b. Start and continue · 2. Changing scene · 2b. Input contexts · 3. Verify · 4. Sessions · 5. Window and device
4
+
3
5
  Needs the module `flow()` (not in openWorld; add it yourself: `engine.use(openWorld({ camera: 'follow', ...}), flow())`).
4
6
  - **Flow states**: title, playing (built-in `playing`), paused (built-in `paused`: freezes gameplay + locks input), ending, ... Only one is active at a time.
5
7
  - **Scene transition** `transition(fn)`: lock input -> fade to black -> fade music out -> (with `{ autosave: 'auto' }` save slot 'auto'; off by
@@ -46,6 +48,8 @@ A game's own windows made with `makeWindow` are pushed automatically (`onCancel`
46
48
  import { uiFocus } from 'threedog';
47
49
  const h = uiFocus(engine).push('myMap', { cancel: () => closeMap() }); // call h.remove() when closing; h.fresh = opened this very frame
48
50
  ```
51
+ An entry with a `nav` (every window, the settings menu, dialogue choices) lets go of a locked mouse when it opens. For anything else, `engine.page.releaseLock()` frees the mouse
52
+ (recipe 21); neither counts as the player's Esc, so the pause menu stays shut.
49
53
 
50
54
  ## 1b. Title -> start -> continue, and opening straight into a moment (screenshots, tests)
51
55
  `flow({ start: 'title' })` enters the title during `engine.start()` (on `engine:ready`), so when `await engine.start()` returns the title is
@@ -66,10 +70,15 @@ if (moment) setUpMoment(moment); // the game's own data only; in code, time /
66
70
  The engine's ready-made title (`createEngine({ ui: { title } })`, recipe 26 §5) opens in `start()` the same way: leave `title` out for a moment
67
71
  (`ui: { ...(moment ? {} : { title: { title: 'My Game', items: ['continue', 'start'] } }) }`).
68
72
  Shoot it with `npm run shot -- "/?moment=night" --time 22:20 --weather storm`; a game test opens the same URL.
73
+ To start at a named place, write no code: `?at=pier` (dev and tools, like the other URL keys; `npm run shot -- --at pier`, `applyState({ at: 'pier' })`) leaves the
74
+ start screen as `?play` does, stands the player at that place of `content/places.js` (or a level marker) after the game's `session:start` code ran, and puts the
75
+ game's camera there at once. An unknown name stops with the list of places. A camera of your own: listen to `state:placed` ({ x, z }).
76
+
69
77
  To get past the title without a key of your own, use the engine's `?play` URL key (`npm run shot -- --play`, `applyState({ play: true })`): after
70
78
  `engine:ready` it does what the title's Start does (`engine.session.newGame()`, then the title part closes), so `flow({ start: 'title' })` moves to
71
- `'playing'` and the game's `session:start` setup runs; with no title up it does nothing. Two things that make a moment
72
- look half-done in a picture: a headless page advances only on `engine.step` (the shot steps one frame after the game's code, so a
79
+ `'playing'` and the game's `session:start` setup runs; with no title up it does nothing. `?fresh` (`applyState({ fresh: true })`) first deletes this
80
+ page's saves, so the title offers no Continue; on a running page it also ends the run. Two things that make a moment
81
+ drawing half-done in a picture: a headless page advances only on `engine.step` (the shot steps one frame after the game's code, so a
73
82
  `weather.set(name, { seconds: 0.1 })` made after `start()` shows a third of the change: use `seconds: 0`), and an `onFrame` copy of a sky
74
83
  color is one frame old (share `engine.uniforms.uSkyHorizon` instead, recipe 08).
75
84
 
@@ -157,7 +166,7 @@ One place listens to window focus, tab visibility, mouse lock and the WebGL cont
157
166
  `engine.page.pauseOnBlur = false` keeps playing. Coming back resumes with no catch-up burst; a long frame turns into at most 0.1 s of fixed steps,
158
167
  and fewer when the steps are heavy (at most about 33 ms of catch-up work per frame; the rest is dropped as a brief slow-down). `engine.step()` never drops time.
159
168
  - `engine.events.on('page:blur', () => engine.flow?.go('paused'))` also opens the pause menu. Other events: `page:focus`,
160
- `page:pointerlock { locked }` (cameras lock again on the next click), `page:contextlost` / `page:contextrestored` (gameplay waits and the player
169
+ `page:pointerlock { locked, byEngine }` (cameras lock again on the next click; a lock the player ended counts as Esc, because the browser keeps that key), `page:contextlost` / `page:contextrestored` (gameplay waits and the player
161
170
  sees a message; three.js restores the context).
162
171
  - `engine.step()` still advances while away (tests, dev bridge). Held keys are released by Input.
163
172
  - Tests: `npm test -- "Session:" "Window:"`.
@@ -2,34 +2,39 @@
2
2
 
3
3
  **In this recipe**: 1. Switching weather · 2. The game's own weather table · 3. Sky colors, sun, stars (and the sky color for your own shader) · 4. Time and brightness (how a game's value and the weather multiply) · 5. Verify · 6. Day and night in game logic · 7. Wet roads
4
4
 
5
- Modules: `sky()` (draws day/night from `engine.calendar`, sun and moon, fog; the time itself is `calendar()`, recipe 06), `weather()` (needs sky; the game's weather types, smooth transitions, rain and snow,
6
- lightning). All look data lives in the style; the engine has only a neutral fallback.
5
+ Modules: `sky()` (draws the dome from `engine.calendar`, sun and moon, and computes the signals; it writes no light, fog or exposure, those are your `picture/` code, recipe 62; the time itself is `calendar()`, recipe 06), `weather()` (needs sky; the game's weather types, smooth transitions, rain and snow,
6
+ lightning; their picture is `weather({ rain, snow, lightning })`, recipe 44). The engine has only a neutral fallback.
7
7
 
8
8
  ```js
9
- // 1. keyframes (default): style.sky.keyframes / style.exposure lists drive the day; nothing to write
10
- // 2. a function of the frame context, fed by one call: any key marked fn (fog color / near / far / density, sky top / horizon / backdrop, lights, exposure)
11
- engine.look.fog.set({ color: ({ state }) => state.boss ? '#400' : 'horizon' }); engine.look.state({ boss: true });
12
- // 3. your own three.js sky (three/addons Sky, a ShaderMaterial dome, a skybox): never written; time / weather keep flowing through engine.uniforms
13
- engine.look.sky.replace(mySky); mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir; // the same Vector3, refreshed every frame
9
+ engine.use(sky({ keyframes: ROWS, sunSize: 600, clouds: { coverage: 0.6 }, dim: { stars: false } })); // start values
10
+ engine.uniforms.uSunPower.value = 4; // sun, moon, star and dome cloud numbers: engine.uniforms, the dome's own objects, on both renderers
11
+ engine.uniforms.uCloudCover.value = 0.8; // also uSunSize uSunGlow uMoonSize uMoonPower uMoonColor uStars uStarScale uCurve uSkyCloudScale uSkyCloudSpeed uCloudOpacity uCloudSoft uCloudColor uCloudShade
12
+ engine.sky.top = boss ? '#400' : null; // plain fields, read each frame: top, horizon (color over the keyframes, null = keyframes), orbit.tilt / sway, dim.tint / stars
13
+ engine.sky.backdrop = 0x335577; // one flat color in place of the dome; null gives the dome back
14
+ engine.sky.keyframes(NIGHT_ROWS); // the day's rows, live
15
+ engine.sky.clouds({ glsl, tsl }); // your cloud function; null = the built-in kind
16
+ engine.sky.layer('aurora', { glsl, tsl, blend: 'add' }); // a named dome layer; null removes it
17
+ const mySky = new THREE.Mesh(skyGeometry, skyMaterial); // or a skybox name, a Texture
18
+ engine.sky.replace(mySky); // skybox name | Texture | CubeTexture | Object3D, never written; null gives the dome back
19
+ mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir; // the same Vector3, refreshed every frame
14
20
  ```
15
21
 
16
- WebGPU (recipe 56): same dome and fog kinds as node materials. Hooks take `{ glsl, tsl: (ctx) => vec4 }` ([52](52-look.md#tsl-forms)); GLSL alone throws `[webgpu-needs-tsl]`. Own sky: three's `SkyMesh` via `look.sky.replace`.
22
+ WebGPU (recipe 56): same dome as a node material. Hooks take `{ glsl, tsl: (ctx) => vec4 }` ([52](52-around-the-picture.md#tsl-forms)); GLSL alone throws `[webgpu-needs-tsl]`. Own sky: three's `SkyMesh` via `engine.sky.replace`.
17
23
 
18
- The sky follows one contract: **inputs** `{ time, weather, season, day, state, sky }` (state = what the game gave `engine.look.state(...)`),
19
- **outputs** sun direction / color / intensity, hemisphere, fog, environment, exposure and background, plus the shared `engine.uniforms`
20
- (`uSunDir`, `uDaylight`, `uTimeOfDay`, `uWind`, `uCloud`, season tints) and events (`day:start`, `season:change`, `weather:change`) that wind,
21
- rain and vegetation read. The keyframes are only the default implementation: a function replaces one key, `replace` the whole dome, and
22
- everything else keeps running (`replace` swaps the one thing a part draws; the whole sky module with time, lights and fog is
23
- `engine.use(mySky(), { replaces: 'sky' })`, recipe 52 [verbs](52-look.md#verbs)). The function gets `{ time, weather, season, day, state, sky }`: write `({ sky }) => sky.isDay ? ...`.
24
+ The sky follows one contract: **inputs** time, weather, season,
25
+ **outputs** the dome and the background, plus the shared `engine.uniforms`
26
+ (`uSunDir`, `uSunColor`, `uDaylight`, `uTimeOfDay`, `uSkyTop`, `uSkyHorizon`, `uWind`, `uCloud`, `uRain`, `uSnow`, `uWeatherLight`, `uWeatherFog` (the weather state writes the last six every frame), season tints) and events (`day:start`, `season:change`, `weather:change`) that wind,
27
+ rain and vegetation read. The keyframes are only the default implementation: `engine.sky.replace` swaps the whole dome and everything else keeps running (the whole sky module is
28
+ `engine.use(mySky(), { replaces: 'sky' })`).
24
29
 
25
- ### Your own sky object: what `look.sky.replace(obj)` does with it
30
+ ### Your own sky object: what `engine.sky.replace(obj)` does with it
26
31
  The engine hides its dome, adds `obj` to the scene root when it has no parent yet (and removes it again on `replace(null)` only then), and from
27
32
  then on **never moves, scales or writes it**: it does not follow the camera, is not scaled to the far plane and is not exempted from culling.
28
33
  (The built-in dome does all three itself: an `onBeforeRender` copies the camera position and scales it to `0.9 × camera.far`.) So a dome of
29
34
  your own must, on its own:
30
35
 
31
36
  - **contain the camera and stay inside the far plane**: either a fixed sphere big enough for everywhere the camera goes (radius < `camera.far`,
32
- which the engine pulls in to the view range unless you take it: `engine.look.view.manual('far')`), or one that follows the camera; or skip
37
+ which the engine pulls in to the view range unless you take it: `engine.view.manual('far')`), or one that follows the camera; or skip
33
38
  depth altogether as below, so the radius no longer matters;
34
39
  - **compute the view direction per pixel from world space**: pass `worldPosition - cameraPosition` (linear, safe to interpolate) as the
35
40
  varying and do every non-linear step (normalize, `atan`, projecting onto a cloud plane, noise) in the fragment shader. A direction taken from
@@ -59,7 +64,7 @@ const sky = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 16), new THREE.Shader
59
64
  }));
60
65
  sky.frustumCulled = false; sky.renderOrder = -1000;
61
66
  sky.onBeforeRender = (r, s, cam) => { sky.position.copy(cam.position); sky.updateMatrixWorld(); }; // centred on the camera: any radius works
62
- engine.look.sky.replace(sky);
67
+ engine.sky.replace(sky);
63
68
  ```
64
69
  Time of day still reaches it through `engine.uniforms` (`uSunDir`, `uDaylight`, `uTimeOfDay` ...): put them in its `uniforms` to follow the day.
65
70
 
@@ -77,8 +82,7 @@ ones (clear cloudy overcast rain storm snow fog) are an opt-in preset: `weather(
77
82
  `types: { ...presets.weather.temperate.types, dust: {...} }`.
78
83
  The preset supplies types and an `autoPool`; the weather changes by itself only with `auto: true` (or `engine.weather.setAuto(true)`). To pin one
79
84
  for a picture: `engine.weather.set('clear')`, or a shot's `--weather clear` (it also turns `auto` off); a shot prints the weather under the picture.
80
- Left-out fields are calm (no cloud, rain, snow, grey, lightning; sun, fog, wind 1). The style's `style.weather.types` only fills fields the game's
81
- table leaves out, for types the game has (the table's own numbers win, a preset counts as the game's). There is no patch option for one field
85
+ Left-out fields are calm (no cloud, rain, snow, grey, lightning; sun, fog, wind 1). There is no patch option for one field
82
86
  of a preset type: spread that one type, `const T = presets.weather.temperate.types; weather({ types: { ...T, rain: { ...T.rain, fog: 0.5 } } })`.
83
87
  ```js
84
88
  import { createEngine, presets, sky, weather } from 'threedog';
@@ -92,45 +96,37 @@ Fields: `cloud` cloud cover 0-1, `sun` sunlight multiplier, `fog` fog distance m
92
96
  0-1, `grey` how gray the sky turns, `lightning` lightning. A table where nothing rains or snows builds no particles.
93
97
  With openWorld the weather module is already installed; pass its options through the preset: `openWorld({ camera: 'follow', weather: { types, autoPool } })`.
94
98
 
95
- ## 3. Changing sky colors, sun, stars (style)
96
- `sky.keyframes` in the style (your pack's `index.js`):
97
- `[time 0-1, zenith color, horizon color (= fog color), sunlight color, sunlight intensity, ambient intensity]`, interpolated by time; the rows
99
+ ## 3. Changing sky colors, sun, stars
100
+ `sky({ keyframes })`:
101
+ `[time 0-1, zenith color, horizon color, sun color, ambient intensity]`, interpolated by time; the rows
98
102
  run from time 0 to time 1 (both midnight: the first row at 0, the last at 1 with the same values), else the sky throws. What each column drives
99
- (and which light carries the moonlight) is in `api/style.md` under `keyframes`;
100
- also `sunSize sunGlow moonSize starDensity clouds skybox shadow` (defaults and ranges in `api/style.md` too; `hoursPerDay` is timing, so it is a
101
- `calendar()` option, not a style key). At run time every look key of `style.sky` is a `look.sky` param, one entry per value:
102
- `engine.look.sky.set({ keyframes, moonSize, starScale, orbitTilt, dim: { stars: false } })`, a panorama is `engine.look.sky.replace('pano')`.
103
- `sky()` takes only how the game lights its world (`time`, `fog`, `sun`, `hemisphere`, plus the `shadow` / `environment` blocks); `sky({ moonSize })`
104
- throws naming the `look.sky.set` call.
105
- **Day and night brightness** come from two columns: sunlight intensity and ambient intensity. With no `sky.keyframes` the sky uses a neutral gray
106
- curve (night from 19:12 to 04:48, moonlight 0.4, ambient 0.35 against 3 / 1.2 at noon). The ambient column is the whole diffuse fill: the engine's neutral room
107
- environment (the light Standard / Lambert / Phong materials get from `scene.environment`) takes the share `look.lights` `env.share` (0..1) of
108
- it and the hemisphere light the rest, so a dark-night pack is dark on PBR surfaces too and the sun keeps its contrast by day. `env.intensity` keeps
109
- one meaning, the absolute `scene.environmentIntensity`: a game or pack that writes it under a sky gets that value as written (fixed, not following
110
- the day; the hemisphere light then keeps the whole budget, `describe().look.env.source.mode` `'absolute'`). `describe().look.env.source` says which map lights
111
- them (`room` / `sky` / `asset:<name>` / `game`) and `followsTime`; `look.env.replace('sky')` builds it from the dome instead (outdoor reflections
112
- show the sky, not a studio; it darkens by itself), an asset map is a fixed photo and does not follow. Check with `shot --time 12:00` and `--time 22:00`.
113
- The look of rain and snow is in `style.weather.rain / snow` (shape, density, shaders, the game's own particles: recipe 44).
103
+ (and which light carries the moonlight) is on `keyframes` in `SkyPictureOptions`, `types/world.d.ts`;
104
+ also `sunSize sunGlow moonSize starDensity clouds` (defaults and ranges there too; `hoursPerDay` is timing, so it is a
105
+ `calendar()` option, not a sky key). `sky()` takes `time` and the dome's start values: all of these are `sky({ ... })` start values; at run time use the entries at the top of this page. `sky({ sun | hemisphere | fog })`
106
+ throw naming what to write in your `picture/` code.
107
+ **Day and night brightness** is your `picture/` code: the sky lights nothing. Read `uDaylight` and write your own lights (recipe 62), and check with `shot --time 12:00` and
108
+ `--time 22:00`. The keyframes only color the dome; the ambient column also dims a skybox and the weather's sky tint. `engine.sky.environment({ into: engine.scene })` builds an environment map
109
+ from the dome (outdoor reflections show the sky, not a studio; it darkens by itself), recipe 34.
110
+ The look of rain and snow is `weather({ rain, snow })` (shape, density, shaders; the game's own particles with `engine.weather.define`: recipe 44).
114
111
 
115
112
  ### Sky color for my shader (horizon color, zenith color)
116
113
  A shader of your own that should meet the sky (a sea fading to the horizon, distant cards, a reflection) reads the colors the sky draws this frame:
117
- `engine.uniforms.uSkyHorizon` and `engine.uniforms.uSkyTop` (`THREE.Color`, linear). They hold the keyframes, a `look.sky.set({ top, horizon })`,
118
- the weather's grey tint and lightning; with `style.sky.backdrop` the horizon is the backdrop color. The fog in its default color (`'horizon'`) is
119
- this same color every frame, at night and in rain too; it differs only when the game sets `look.fog.set({ color })`, or takes the fog
120
- (`look.fog.manual()`, `scene.fog = ...`). Share the object, do not copy it in `onFrame`: `onFrame` runs before the sky updates, so a copy is one
114
+ `engine.uniforms.uSkyHorizon` and `engine.uniforms.uSkyTop` (`THREE.Color`, linear). They hold the keyframes, `engine.sky.top` / `horizon`,
115
+ the weather's grey tint and lightning; with a backdrop the horizon is the backdrop color. A fog of yours that should melt into the sky copies
116
+ it in `engine.onRender`: `scene.fog.color.copy(engine.uniforms.uSkyHorizon.value)`. Share the object, do not copy it in `onFrame`: `onFrame` runs before the sky updates, so a copy is one
121
117
  frame old (after a time jump, the first picture shows the old hour's color).
122
118
  ```js
123
119
  const sea = new THREE.ShaderMaterial({ uniforms: { uHorizon: engine.uniforms.uSkyHorizon, uTop: engine.uniforms.uSkyTop, uSunDir: engine.uniforms.uSunDir },
124
120
  fragmentShader: '... gl_FragColor = vec4(mix(base, uHorizon, fresnel), 1.0); #include <tonemapping_fragment> #include <colorspace_fragment>' /* ... */ });
125
121
  engine.uniforms.uSkyHorizon.value.getHexString(); // read it in JS too (game logic, a HUD swatch)
126
122
  ```
127
- `look.sky.value('horizon')` is the override a game set (`null` = the keyframes), not the drawn color.
123
+ `engine.sky.horizon` is the override a game set (`null` = the keyframes), not the drawn color.
128
124
 
129
125
  ## 4. Time and brightness (game code)
130
126
  ```js
131
127
  await engine.skip({ to: '19:30' }); // jump forward to a time: timers, calendar.at / daily, day:start fire on the way (needs a calendar dayLength; recipe 06)
132
128
  engine.mod('clock.rate', { owner: 'game', set: 0 }); // the calendar and calendar seconds stop together, so the sky stops moving (set: 2 = double speed; remove() undoes it); game seconds per day: calendar({ dayLength: 600 }); the three kinds of time are in recipe 06
133
- engine.look.fog.set({ far: 300 }); // base fog distance (meters); weather multiplies it; terrain({ viewFog: true }) writes the layer below
129
+ engine.scene.fog = new THREE.Fog(0x99aabb, 90, 300); // fog is plain three.js; engine.uniforms.uViewDistance (terrain({ viewFog: true }) writes it) and uWeatherFog are signals your picture/ code reads
134
130
  ```
135
131
  **The sky draws the calendar's time; it does not own it.** Day, time of day and seasons are the `calendar()` module (recipe 06 "The time table");
136
132
  the sky reads `engine.calendar.timeOfDay` each frame to place the sun and blend the keyframes, and `engine.calendar.season` for the season tint.
@@ -148,26 +144,18 @@ Seasons are off by default (`engine.calendar.season` is `null`, no `season:chang
148
144
  calendar({ seasons: ['spring', 'summer', 'autumn', 'winter'], daysPerSeason: 28, dayLength: 360 }); // days advance only with a dayLength; or the preset: openWorld({ camera: 'follow', calendar: presets.calendar.fourSeasons })
149
145
  calendar({ seasons: [{ name: 'wet', days: 10 }, { name: 'dry', days: 20 }], dayLength: 360 }); // seasons of their own length
150
146
  ```
151
- **A direct write to** `engine.lights.sun.intensity / color`, `engine.lights.hemi` or `scene.fog` **takes that value over**: the sky stops writing it and
152
- keeps yours, so the day cycle no longer changes it (warned once). To adjust and keep the cycle: `engine.look.lights.set(...)` / `look.fog.set(...)` or a
153
- modifier layer below; to take it on purpose: `engine.look.lights.manual('sun')` (recipe 52 "Who writes it").
154
- To darken or tint everything (a cave, a horror segment), add multipliers of your own on the look values; they stack with the weather's without
155
- overwriting it ([recipe 52](52-look.md#how-look-values-stack)):
147
+ The lights and the fog are your own three.js objects, so nothing overwrites them. To darken or tint everything (a cave, a horror segment), your `picture/` code reads one signal of yours and multiplies
148
+ it in with the weather's (`uWeatherLight`, `uWeatherFog`); the sky color has its own shared points, which stack with the weather's without overwriting it ([recipe 55](55-mods-time-wrap.md#picture-points-follow-the-same-rule)):
156
149
  ```js
157
- const cave = [engine.mod('look.lights.sun.intensity', { owner: 'cave', mul: 0.3 }), engine.mod('look.lights.hemi.intensity', { owner: 'cave', mul: 0.4 }),
158
- engine.mod('look.fog.far', { owner: 'cave', mul: 0.5 }), // enter the cave: entries multiply
159
- engine.mod('look.sky.tint', { owner: 'cave', value: { color: 0x402030, amount: 0.5 } })]; // amount = zenith, horizon: = horizon
160
- cave.forEach(h => h.remove()); // leave the cave
150
+ const cave = engine.mod('sky.tint', { owner: 'cave', value: { color: 0x402030, amount: 0.5 } }); // amount = zenith, horizon: = horizon
151
+ cave.remove(); // leave the cave
161
152
  ```
162
- These are ordinary shared points (recipe 55): the light and fog values multiply, `look.sky.flash` adds, `look.sky.tint` / `look.ground.cover`
163
- entries blend weighted by their amount, `{ for: 3 }` ends one by itself. A game's own `look.lights.set({ sun: { intensity: 3 } })` is the base they
164
- multiply: rain still dims it and the sunset still fades it (`engine.describe().shared['look.lights.sun.intensity'].how` says `arena 3 × weather 0.6`).
165
- Write once and it stays in effect; no need to write every frame. For a gradual change, write a new value every frame.
153
+ These are ordinary shared points (recipe 55): `sky.flash` adds, `sky.tint` / `ground.cover` entries blend weighted by their amount, `{ for: 3 }` ends one by itself.
166
154
 
167
155
  ## 5. Verify
168
156
  - Text: `npm run shot -- / --time 19:30 --weather dust --wait 2 --describe-only`, then look for "Time: 19:30..." and "Weather: dust (rain 0, snow 0, fog 0.35)".
169
157
  `describe().weather` has `name progress rain snow fog wind cloud`; `describe().time` has `clock day season isDay dayLength rate`.
170
- - Take a screenshot only after the look changed: `npm run shot -- / --time 19:30 --weather dust`.
158
+ - Take a screenshot only after the picture changed: `npm run shot -- / --time 19:30 --weather dust`.
171
159
 
172
160
  ## 6. Day and night in game logic
173
161
  Gameplay reads day and night from the calendar: test `engine.calendar.isDay`, and fade with `engine.calendar.daylight` (0-1); they work with or