threedog 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +21 -13
  3. package/core/Assets.js +23 -12
  4. package/core/Audio.js +1 -1
  5. package/core/Baked.js +14 -23
  6. package/core/Budget.js +2 -2
  7. package/core/DebugOverrides.js +33 -18
  8. package/core/Describe.js +10 -11
  9. package/core/Engine.js +50 -46
  10. package/core/I18n.js +2 -2
  11. package/core/Input.js +11 -5
  12. package/core/Inspect.js +6 -3
  13. package/core/InspectMaterials.js +2 -3
  14. package/core/InspectPerf.js +11 -4
  15. package/core/MaterialInfo.js +7 -5
  16. package/core/Rays.js +7 -2
  17. package/core/Stream.js +2 -3
  18. package/core/UrlState.js +49 -9
  19. package/core/Views.js +1 -0
  20. package/core/adaptive.js +2 -2
  21. package/core/assetEntry.js +5 -2
  22. package/core/assetLoad.js +13 -15
  23. package/core/assetManifest.js +6 -3
  24. package/core/assetReport.js +4 -4
  25. package/core/batchGroups.js +9 -1
  26. package/core/catalog.js +16 -3
  27. package/core/chunkStream.js +1 -1
  28. package/core/copies.js +1 -1
  29. package/core/debugView.js +4 -4
  30. package/core/describeRender.js +104 -28
  31. package/core/describeText.js +6 -6
  32. package/core/errorCodes.js +72 -45
  33. package/core/errorHints.js +4 -1
  34. package/core/errors.js +4 -4
  35. package/core/events.generated.js +1 -0
  36. package/core/gameLights.js +9 -2
  37. package/core/lifecycle.js +2 -4
  38. package/core/lightWatch.js +5 -3
  39. package/core/loop.js +18 -11
  40. package/core/math.js +7 -0
  41. package/core/moduleSlots.js +32 -7
  42. package/core/moduleTypes.js +20 -7
  43. package/core/modules.js +7 -7
  44. package/core/namedModel.js +8 -4
  45. package/core/owned.js +33 -30
  46. package/core/page.js +43 -10
  47. package/core/pictureSlots.js +33 -0
  48. package/core/pictureWriters.js +343 -0
  49. package/core/plugins.js +64 -96
  50. package/core/sceneDelta.js +12 -4
  51. package/core/sceneMethods.js +2 -9
  52. package/core/services.js +1 -1
  53. package/core/shadowTypes.js +1 -1
  54. package/core/shadows.js +405 -0
  55. package/core/sharedPoint.js +5 -19
  56. package/core/stackFrames.js +16 -5
  57. package/core/stacks.js +6 -6
  58. package/core/startup.js +9 -11
  59. package/core/thingExplain.js +1 -1
  60. package/core/things.js +1 -1
  61. package/core/tier.js +1 -1
  62. package/core/util.js +1 -1
  63. package/core/validate.js +1 -1
  64. package/core/view.js +43 -0
  65. package/docs/AI.md +62 -58
  66. package/docs/API.md +15 -15
  67. package/docs/CODEMAP.md +36 -54
  68. package/docs/COMMANDS.md +28 -25
  69. package/docs/CONVENTIONS.md +36 -30
  70. package/docs/MIGRATING-0.4.md +93 -1
  71. package/docs/MIGRATING-0.6.md +126 -0
  72. package/docs/MIGRATING-0.7.md +39 -0
  73. package/docs/THREE.md +24 -22
  74. package/docs/api/assets.md +5 -3
  75. package/docs/api/audio.md +2 -2
  76. package/docs/api/budget.md +4 -0
  77. package/docs/api/characters.md +3 -1
  78. package/docs/api/collision.md +2 -2
  79. package/docs/api/engine.md +47 -20
  80. package/docs/api/events.md +2 -1
  81. package/docs/api/grids.md +8 -1
  82. package/docs/api/ground.md +1 -1
  83. package/docs/api/hud.md +3 -0
  84. package/docs/api/input.md +3 -2
  85. package/docs/api/interactions.md +3 -1
  86. package/docs/api/inventory.md +1 -2
  87. package/docs/api/level.md +0 -1
  88. package/docs/api/lightPool.md +1 -1
  89. package/docs/api/occlusion.md +5 -0
  90. package/docs/api/particles.md +6 -3
  91. package/docs/api/pickups.md +6 -0
  92. package/docs/api/post.md +5 -3
  93. package/docs/api/sky.md +12 -10
  94. package/docs/api/terrain.md +12 -6
  95. package/docs/api/terrainDraw.md +12 -0
  96. package/docs/api/tools.md +8 -7
  97. package/docs/api/triggers.md +2 -0
  98. package/docs/api/vegetation.md +7 -2
  99. package/docs/api/vegetationDraw.md +10 -0
  100. package/docs/api/water.md +6 -2
  101. package/docs/api/weather.md +5 -0
  102. package/docs/api/weatherDraw.md +10 -0
  103. package/docs/api/world.md +1 -1
  104. package/docs/recipes/01-new-game.md +19 -23
  105. package/docs/recipes/03-items-pickups.md +25 -4
  106. package/docs/recipes/05-props-bake.md +53 -37
  107. package/docs/recipes/06-clock-events.md +3 -3
  108. package/docs/recipes/07-flow-scenes-pause.md +12 -3
  109. package/docs/recipes/08-weather-sky.md +45 -57
  110. package/docs/recipes/09-materials-lights-models.md +185 -0
  111. package/docs/recipes/10-blender-level.md +2 -2
  112. package/docs/recipes/11-vehicles.md +3 -3
  113. package/docs/recipes/13-animation.md +13 -7
  114. package/docs/recipes/14-custom-module.md +7 -5
  115. package/docs/recipes/15-perf.md +3 -3
  116. package/docs/recipes/16-dev-bridge.md +22 -12
  117. package/docs/recipes/18-world.md +10 -8
  118. package/docs/recipes/19-shooting-picking.md +7 -5
  119. package/docs/recipes/20-content-actions-save.md +6 -2
  120. package/docs/recipes/21-camera.md +8 -3
  121. package/docs/recipes/23-ops.md +1 -1
  122. package/docs/recipes/26-ui-parts.md +35 -11
  123. package/docs/recipes/28-terrain.md +12 -12
  124. package/docs/recipes/29-grid.md +14 -5
  125. package/docs/recipes/30-templates.md +8 -3
  126. package/docs/recipes/31-audio.md +4 -4
  127. package/docs/recipes/32-action-game.md +18 -4
  128. package/docs/recipes/34-environment-lighting.md +102 -38
  129. package/docs/recipes/35-picture-from-reference.md +147 -0
  130. package/docs/recipes/36-sky-ground-plants.md +158 -0
  131. package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
  132. package/docs/recipes/38-environment-hooks.md +67 -0
  133. package/docs/recipes/40-scene.md +106 -27
  134. package/docs/recipes/42-terrain-shape.md +1 -1
  135. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
  136. package/docs/recipes/44-water-weather-hooks.md +191 -0
  137. package/docs/recipes/45-cascaded-shadows.md +121 -23
  138. package/docs/recipes/46-blender-art-route.md +17 -20
  139. package/docs/recipes/47-island-snow-backdrop.md +10 -12
  140. package/docs/recipes/49-game-module-contract.md +1 -1
  141. package/docs/recipes/50-own-renderer.md +3 -3
  142. package/docs/recipes/52-around-the-picture.md +181 -0
  143. package/docs/recipes/53-ground-up-close.md +12 -12
  144. package/docs/recipes/54-three-idioms.md +18 -18
  145. package/docs/recipes/55-mods-time-wrap.md +17 -5
  146. package/docs/recipes/56-webgpu-tsl.md +66 -23
  147. package/docs/recipes/57-control.md +39 -0
  148. package/docs/recipes/58-input.md +3 -0
  149. package/docs/recipes/59-depth-post-effects.md +5 -5
  150. package/docs/recipes/60-judge-the-picture.md +39 -24
  151. package/docs/recipes/61-deploy.md +27 -0
  152. package/docs/recipes/62-picture-code.md +244 -0
  153. package/docs/recipes/63-third-person-start.md +77 -0
  154. package/docs/recipes/64-particles.md +35 -0
  155. package/examples/action/.threedog/content-index.json +1 -1
  156. package/examples/action/GAMEMAP.md +7 -5
  157. package/examples/action/main.js +5 -4
  158. package/examples/action/models.js +12 -14
  159. package/examples/action/picture/index.js +13 -0
  160. package/examples/action/picture/lights.js +35 -0
  161. package/examples/action/picture/materials.js +8 -0
  162. package/examples/action/picture/palette.js +33 -0
  163. package/examples/plain-picture/.threedog/content-index.json +1 -0
  164. package/examples/plain-picture/FINDINGS.md +53 -0
  165. package/examples/plain-picture/GAMEMAP.md +90 -0
  166. package/examples/plain-picture/main.js +48 -0
  167. package/examples/plain-picture/picture/index.js +21 -0
  168. package/examples/plain-picture/picture/lights.js +54 -0
  169. package/examples/plain-picture/picture/materials.js +24 -0
  170. package/examples/plain-picture/picture/palette.js +16 -0
  171. package/examples/plain-picture/picture/sky.js +37 -0
  172. package/examples/pullable.json +31 -9
  173. package/examples/rc2d/GAMEMAP.md +8 -3
  174. package/examples/rc2d/README.md +11 -6
  175. package/examples/rc2d/main.js +25 -33
  176. package/examples/rc2d/picture/index.js +18 -0
  177. package/examples/rc2d/picture/lights.js +11 -0
  178. package/examples/rc2d/picture/materials.js +18 -0
  179. package/examples/rc2d/picture/palette.js +15 -0
  180. package/examples/rc2d/picture/post.js +11 -0
  181. package/examples/rc2d/rc2d.js +18 -28
  182. package/examples/sheepisland/.threedog/content-index.json +1 -1
  183. package/examples/sheepisland/GAMEMAP.md +13 -10
  184. package/examples/sheepisland/assets.js +2 -2
  185. package/examples/sheepisland/content/templates.js +1 -1
  186. package/examples/sheepisland/content/vegetation.js +3 -1
  187. package/examples/sheepisland/main.js +15 -9
  188. package/examples/sheepisland/{style/models.js → models.js} +13 -24
  189. package/examples/sheepisland/picture/index.js +20 -0
  190. package/examples/sheepisland/picture/lights.js +34 -0
  191. package/examples/sheepisland/picture/materials.js +61 -0
  192. package/examples/sheepisland/picture/palette.js +60 -0
  193. package/examples/sheepisland/picture/sky.js +20 -0
  194. package/examples/sheepisland/views.js +1 -1
  195. package/examples/styletest/.threedog/content-index.json +1 -1
  196. package/examples/styletest/GAMEMAP.md +15 -11
  197. package/examples/styletest/main.js +20 -30
  198. package/examples/styletest/models.js +29 -29
  199. package/examples/styletest/params.js +1 -4
  200. package/examples/styletest/picture/env.js +38 -0
  201. package/examples/styletest/picture/index.js +16 -0
  202. package/examples/styletest/picture/lights.js +9 -0
  203. package/examples/styletest/picture/materials.js +28 -0
  204. package/examples/styletest/picture/palette.js +22 -0
  205. package/examples/techniques/contact-shadows/README.md +22 -23
  206. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  207. package/examples/techniques/contact-shadows/main.js +20 -18
  208. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  209. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  210. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  211. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  212. package/examples/techniques/day-night-grade/README.md +13 -16
  213. package/examples/techniques/day-night-grade/main.js +15 -25
  214. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  215. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  216. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  217. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  218. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  219. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  220. package/examples/techniques/interior-light/README.md +16 -13
  221. package/examples/techniques/interior-light/interiorLight.js +19 -17
  222. package/examples/techniques/interior-light/main.js +30 -67
  223. package/examples/techniques/interior-light/picture/index.js +24 -0
  224. package/examples/techniques/interior-light/picture/lights.js +52 -0
  225. package/examples/techniques/interior-light/picture/materials.js +13 -0
  226. package/examples/techniques/interior-light/picture/palette.js +32 -0
  227. package/examples/techniques/interior-light/picture/sky.js +40 -0
  228. package/examples/techniques/modular-building/README.md +4 -3
  229. package/examples/techniques/modular-building/kit.js +2 -2
  230. package/examples/techniques/modular-building/main.js +9 -17
  231. package/examples/techniques/modular-building/picture/index.js +17 -0
  232. package/examples/techniques/modular-building/picture/lights.js +26 -0
  233. package/examples/techniques/modular-building/picture/materials.js +13 -0
  234. package/examples/techniques/modular-building/picture/palette.js +23 -0
  235. package/examples/techniques/night-lights/README.md +15 -14
  236. package/examples/techniques/night-lights/main.js +20 -43
  237. package/examples/techniques/night-lights/nightLights.js +25 -21
  238. package/examples/techniques/night-lights/picture/index.js +18 -0
  239. package/examples/techniques/night-lights/picture/lights.js +44 -0
  240. package/examples/techniques/night-lights/picture/materials.js +15 -0
  241. package/examples/techniques/night-lights/picture/palette.js +34 -0
  242. package/examples/techniques/night-lights/picture/post.js +9 -0
  243. package/examples/techniques/night-lights/picture/sky.js +36 -0
  244. package/examples/techniques/outlines-and-rim/README.md +2 -2
  245. package/examples/techniques/outlines-and-rim/main.js +15 -38
  246. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  247. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  248. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  249. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  250. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  251. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  252. package/examples/techniques/procedural-animation/README.md +5 -3
  253. package/examples/techniques/procedural-animation/main.js +9 -7
  254. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  255. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  256. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  257. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  258. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  259. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  260. package/examples/techniques/procedural-surface/README.md +2 -0
  261. package/examples/techniques/procedural-surface/main.js +17 -55
  262. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  263. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  264. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  265. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  266. package/examples/techniques/stylized-shading/README.md +13 -14
  267. package/examples/techniques/stylized-shading/main.js +11 -42
  268. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  269. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  270. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  271. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  272. package/examples/techniques/stylized-shading/shading.js +2 -2
  273. package/examples/techniques/sun-and-key-light/README.md +20 -22
  274. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  275. package/examples/techniques/sun-and-key-light/main.js +19 -63
  276. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  277. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  278. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  279. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  280. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  281. package/examples/techniques/three-looks/README.md +21 -0
  282. package/examples/techniques/three-looks/main.js +58 -0
  283. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  284. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  285. package/examples/techniques/three-looks/picture/comic.js +27 -0
  286. package/examples/techniques/three-looks/picture/index.js +14 -0
  287. package/examples/techniques/three-looks/picture/sun.js +23 -0
  288. package/examples/techniques/wet-road/README.md +7 -4
  289. package/examples/techniques/wet-road/main.js +18 -38
  290. package/examples/techniques/wet-road/picture/index.js +17 -0
  291. package/examples/techniques/wet-road/picture/lights.js +57 -0
  292. package/examples/techniques/wet-road/picture/materials.js +16 -0
  293. package/examples/techniques/wet-road/picture/palette.js +24 -0
  294. package/examples/techniques/wet-road/picture/sky.js +46 -0
  295. package/examples/webgpu-tsl/GAMEMAP.md +9 -4
  296. package/examples/webgpu-tsl/README.md +13 -10
  297. package/examples/webgpu-tsl/main.js +30 -7
  298. package/examples/webgpu-tsl/picture/index.js +18 -0
  299. package/examples/webgpu-tsl/picture/lights.js +25 -0
  300. package/examples/webgpu-tsl/picture/materials.js +36 -0
  301. package/examples/webgpu-tsl/picture/palette.js +23 -0
  302. package/examples/webgpu-tsl/picture/post.js +16 -0
  303. package/examples/webgpu-tsl/picture/sky.js +30 -0
  304. package/examples/world/.threedog/content-index.json +1 -1
  305. package/examples/world/GAMEMAP.md +15 -12
  306. package/examples/world/art/humanoid.js +9 -13
  307. package/examples/world/art/index.js +2 -2
  308. package/examples/world/art/models.js +3 -4
  309. package/examples/world/art/shapes.js +2 -2
  310. package/examples/world/assets.js +2 -2
  311. package/examples/world/content/audio.js +1 -1
  312. package/examples/world/content/items.js +1 -1
  313. package/examples/world/content/props.js +1 -1
  314. package/examples/world/content/templates.js +1 -1
  315. package/examples/world/content/vegetation.js +1 -1
  316. package/examples/world/main.js +10 -10
  317. package/examples/world/models.js +17 -7
  318. package/examples/world/picture/index.js +20 -0
  319. package/examples/world/picture/lights.js +41 -0
  320. package/examples/world/picture/materials.js +34 -0
  321. package/examples/world/picture/palette.js +74 -0
  322. package/examples/world/picture/post.js +9 -0
  323. package/examples/world/picture/sky.js +39 -0
  324. package/index.d.ts +7 -16
  325. package/index.js +7 -7
  326. package/llms.txt +15 -13
  327. package/modules/ambience/Ambience.js +1 -1
  328. package/modules/calendar/Calendar.js +1 -1
  329. package/modules/calendar/index.js +1 -0
  330. package/modules/camera/FirstPersonCamera.js +1 -1
  331. package/modules/camera/FixedCamera.js +2 -2
  332. package/modules/camera/RtsCamera.js +1 -1
  333. package/modules/camera/common.js +7 -5
  334. package/modules/characters/Character.js +15 -10
  335. package/modules/characters/NPC.js +5 -5
  336. package/modules/characters/assetModel.js +5 -4
  337. package/modules/characters/index.js +28 -3
  338. package/modules/characters/movers/common.js +6 -1
  339. package/modules/characters/movers/manual.js +3 -0
  340. package/modules/characters/movers/support.js +25 -11
  341. package/modules/characters/npcSim.js +5 -1
  342. package/modules/characters/proceduralRig.js +18 -4
  343. package/modules/characters/useModel.js +2 -2
  344. package/modules/collision/Collision.js +4 -2
  345. package/modules/content/index.js +8 -0
  346. package/modules/content/models.js +56 -11
  347. package/modules/content/props.js +5 -3
  348. package/modules/content/rules.js +12 -4
  349. package/modules/content/templates.js +5 -3
  350. package/modules/gameplay/Interactions.js +91 -16
  351. package/modules/gameplay/Inventory.js +3 -3
  352. package/modules/gameplay/dialogueBox.js +1 -1
  353. package/modules/gameplay/dialogueBubbles.js +1 -1
  354. package/modules/gameplay/interactionPrompt.js +1 -1
  355. package/modules/gameplay/interactions.contract.js +1 -1
  356. package/modules/gameplay/inventoryOps.js +2 -2
  357. package/modules/gameplay/pickups.js +62 -24
  358. package/modules/gameplay/questLog.js +2 -2
  359. package/modules/grid/Layer.js +13 -0
  360. package/modules/grid/index.js +40 -11
  361. package/modules/grid/preview.js +24 -15
  362. package/modules/grid/tiles.js +15 -19
  363. package/modules/hlod/index.js +3 -2
  364. package/modules/hud/index.js +13 -0
  365. package/modules/hud/parts.js +9 -7
  366. package/modules/level/index.js +5 -4
  367. package/modules/lights/index.js +12 -8
  368. package/modules/music/Music.js +1 -1
  369. package/modules/particles/Particles.js +41 -20
  370. package/modules/particles/effect.js +21 -6
  371. package/modules/photo/Photo.js +11 -10
  372. package/modules/settings/Settings.js +7 -7
  373. package/modules/settings/apply.js +5 -5
  374. package/modules/settings/sections.js +2 -2
  375. package/modules/settings/strings.js +1 -1
  376. package/modules/sky/Sky.js +104 -89
  377. package/modules/sky/clouds.js +16 -17
  378. package/modules/sky/dome.js +100 -0
  379. package/modules/sky/domeLayers.js +5 -5
  380. package/modules/sky/environment.js +45 -169
  381. package/modules/sky/fog.js +5 -180
  382. package/modules/sky/frame.js +26 -90
  383. package/modules/sky/season.js +3 -3
  384. package/modules/sky/shader.js +35 -29
  385. package/modules/sky/skyModule.js +25 -22
  386. package/modules/sky/tint.js +9 -11
  387. package/modules/terrain/ChunkManager.js +29 -12
  388. package/modules/terrain/draw.js +154 -0
  389. package/modules/terrain/index.js +44 -66
  390. package/modules/terrain/terrainDefaults.js +2 -2
  391. package/modules/terrain/terrainEdit.js +1 -1
  392. package/modules/terrain/terrainGen.js +2 -2
  393. package/modules/triggers/index.js +10 -6
  394. package/modules/vegetation/Vegetation.js +58 -17
  395. package/modules/vegetation/draw.js +191 -0
  396. package/modules/vegetation/groundChunks.js +1 -1
  397. package/modules/vegetation/index.js +10 -10
  398. package/modules/water/Water.js +135 -88
  399. package/modules/water/surface.js +53 -53
  400. package/modules/weather/Weather.js +52 -17
  401. package/modules/weather/particles.js +13 -5
  402. package/modules/weather/shaders.js +1 -1
  403. package/modules/weather/weatherDraw.js +141 -0
  404. package/modules/world/World.js +2 -2
  405. package/modules/world/views.js +1 -1
  406. package/package.json +3 -2
  407. package/presets.js +2 -2
  408. package/render/PostFX.js +199 -41
  409. package/render/backend.js +52 -6
  410. package/render/cascades.js +195 -0
  411. package/render/cascades.tsl.js +96 -0
  412. package/render/daylight.js +39 -0
  413. package/render/detail.js +5 -5
  414. package/render/effects.js +41 -26
  415. package/render/fx/cel.tsl.js +42 -0
  416. package/render/fx/index.js +7 -5
  417. package/render/fx/patchNodes.tsl.js +1 -1
  418. package/render/fx/postWebGPU.tsl.js +30 -7
  419. package/render/fx/sky.tsl.js +19 -92
  420. package/render/fx/water.tsl.js +1 -1
  421. package/render/layers.js +14 -0
  422. package/render/lighting.js +6 -5
  423. package/render/lightmap.js +142 -0
  424. package/render/lights.js +23 -201
  425. package/render/materials.js +44 -160
  426. package/render/neutral.js +23 -0
  427. package/render/occlusion.js +184 -0
  428. package/render/ownFrame.js +1 -1
  429. package/render/patches.js +34 -29
  430. package/render/postWebGL.js +11 -3
  431. package/render/probes.js +179 -122
  432. package/render/slots.js +4 -4
  433. package/render/terms.js +53 -101
  434. package/render/uniformDecl.js +1 -1
  435. package/types/core.d.ts +333 -296
  436. package/types/gameplay.d.ts +65 -26
  437. package/types/generated/core/Audio.d.ts +1 -1
  438. package/types/generated/core/DebugOverrides.d.ts +14 -6
  439. package/types/generated/core/Input.d.ts +9 -2
  440. package/types/generated/core/page.d.ts +9 -2
  441. package/types/generated/modules/grid/Layer.d.ts +8 -0
  442. package/types/generated/modules/grid/index.d.ts +29 -5
  443. package/types/generated/modules/particles/Particles.d.ts +13 -6
  444. package/types/generated/modules/sky/Sky.d.ts +85 -18
  445. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  446. package/types/generated/modules/water/Water.d.ts +50 -3
  447. package/types/generated/modules/weather/Weather.d.ts +33 -3
  448. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  449. package/types/generated/modules/world/World.d.ts +2 -2
  450. package/types/generated/render/PostFX.d.ts +53 -10
  451. package/types/generated/render/lighting.d.ts +29 -0
  452. package/types/generated/render/materials.d.ts +19 -44
  453. package/types/generated/render/occlusion.d.ts +13 -0
  454. package/types/physics.d.ts +5 -3
  455. package/types/tsl.d.ts +8 -0
  456. package/types/world.d.ts +376 -57
  457. package/ui/Focus.js +12 -2
  458. package/ui/LoadingScreen.js +2 -2
  459. package/ui/Parts.js +8 -4
  460. package/ui/UI.js +10 -10
  461. package/ui/cursor.js +1 -1
  462. package/ui/theme.js +33 -27
  463. package/ui/touchPart.js +1 -1
  464. package/core/look/coreParts.js +0 -219
  465. package/core/look/part.js +0 -253
  466. package/core/look/points.js +0 -255
  467. package/core/look/report.js +0 -96
  468. package/core/look/shadowPart.js +0 -63
  469. package/core/look/state.js +0 -45
  470. package/core/look/write.js +0 -70
  471. package/core/styleParts.js +0 -114
  472. package/docs/api/style.md +0 -136
  473. package/docs/api/terrainLook.md +0 -10
  474. package/docs/api/vegetationLook.md +0 -10
  475. package/docs/api/weatherLook.md +0 -10
  476. package/docs/recipes/09-style.md +0 -218
  477. package/docs/recipes/35-style-from-reference.md +0 -153
  478. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  479. package/docs/recipes/38-environment-look-hooks.md +0 -99
  480. package/docs/recipes/41-thing-registry.md +0 -97
  481. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  482. package/docs/recipes/48-make-material.md +0 -75
  483. package/docs/recipes/52-look.md +0 -282
  484. package/examples/action/look.js +0 -5
  485. package/examples/sheepisland/style/index.js +0 -79
  486. package/examples/styletest/look.js +0 -11
  487. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  488. package/examples/webgpu-tsl/tslScene.js +0 -75
  489. package/examples/world/style/index.js +0 -61
  490. package/examples/world/style/plugins/10-bloom.js +0 -5
  491. package/modules/sky/cascades.js +0 -186
  492. package/modules/sky/cascades.tsl.js +0 -82
  493. package/modules/sky/look.js +0 -54
  494. package/modules/sky/lookFog.js +0 -76
  495. package/modules/sky/lookShadow.js +0 -62
  496. package/modules/sky/lookSky.js +0 -169
  497. package/modules/sky/shadow.js +0 -98
  498. package/modules/terrain/look.js +0 -83
  499. package/modules/terrain/lookGround.js +0 -66
  500. package/modules/vegetation/look.js +0 -119
  501. package/modules/vegetation/lookWind.js +0 -98
  502. package/modules/water/look.js +0 -91
  503. package/modules/water/surfaceDefaults.js +0 -3
  504. package/modules/weather/look.js +0 -74
  505. package/modules/weather/weatherLook.js +0 -135
  506. package/render/lookGlow.js +0 -139
  507. package/render/lookSurface.js +0 -224
  508. package/render/postLook.js +0 -164
  509. package/render/surface.js +0 -105
  510. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  511. package/types/style.d.ts +0 -671
package/types/style.d.ts DELETED
@@ -1,671 +0,0 @@
1
- // Style (style): looks only (render / post, materials and shaders, sky, lighting, environment colors, particle looks, UI look). Every item is optional;
2
- // the engine ships no art and falls back to neutral gray placeholders for what is omitted. Not here: sounds (createEngine({ audio })), model and texture
3
- // files or generators (asset packs, engine.assets.manifest), gameplay data (content packs, engine.content.load), and anything that changes the world or
4
- // the rules: water level / sea / size go to water({ level, sea, size }), terrain shape and size to terrain({...}) (a dev error says so). Swapping the style must
5
- // never move the map. A style may be a list of parts (StyleInput).
6
- // Example: any style, a folder with index.js (the game's own); see recipes/09-style.md.
7
- import type { ColorLike, BufferGeometry, Object3D, Material, Loose } from './common';
8
- import type { Engine } from './core';
9
- import type { SteepRule, WeatherPreset, TerrainConfig, Sky } from './world';
10
- import type { ParticleOptions } from './gameplay';
11
- import type { ShaderPatch } from './generated/render/patches';
12
-
13
- /** What a function-valued look key is called with every frame (core/look/state.js); state is what the game gave engine.look.state(...) */
14
- export interface LookContext { time: number; weather: string | null; season: string | null; day: number; state: Record<string, any>; sky: Sky }
15
-
16
-
17
- /** Material finish: 'lambert' matte | 'phong' with highlights | 'standard' realistic | 'physical' | 'toon' cel-shaded steps | 'basic' unlit */
18
- export type MaterialType = Loose<'lambert' | 'phong' | 'standard' | 'physical' | 'toon' | 'basic'>;
19
- /** A material texture slot: an asset name, a THREE.Texture, or per-slot settings. Example: aoMap: { texture: 'ao', channel: 1 } */
20
- export type TextureSlot = string | import('three').Texture | {
21
- /** Asset name (manifest textures, a file path) or your THREE.Texture */
22
- texture: string | import('three').Texture;
23
- /** uv set the slot reads: 0 = uv, 1 = uv1 (aoMap / lightMap baked on a second uv) */
24
- channel?: number;
25
- /** Repeat for this slot only (a number or [x, y]); overrides the spec-wide repeat */
26
- repeat?: number | [number, number];
27
- /** Wrap for this slot only */
28
- wrap?: Loose<'repeat' | 'clamp' | 'mirror'>;
29
- /** 'srgb' (color), 'linear' (data), 'none' */
30
- colorSpace?: Loose<'srgb' | 'linear' | 'none'>;
31
- };
32
-
33
- /** Material parameters for one role (other fields are set on the three.js material as is, e.g. roughness, shininess, specular) */
34
- export interface MaterialSpec {
35
- /** Material type, default 'lambert' */
36
- type?: MaterialType;
37
- /** Number of light/dark steps for the toon type, default 3 */
38
- steps?: number;
39
- /** toon only: the light ramp, dark to light: grays 0-1 (light strength in the band) or colors (tint the band). Replaces steps */
40
- ramp?: (number | ColorLike)[];
41
- /** toon only, with ramp: 0 = hard bands, up to 1 = the bands melt into each other */
42
- soften?: number;
43
- color?: ColorLike;
44
- /**
45
- * Texture slots take an asset name: map, emissiveMap (sRGB), normalMap, roughnessMap, metalnessMap, aoMap, bumpMap, alphaMap, displacementMap... (linear).
46
- * Loaded through engine.assets.texture, a neutral stand-in until the image arrives; the key must be a slot the type has (roughnessMap needs 'standard').
47
- * A THREE.Texture also works and keeps its own repeat / wrap / colorSpace unless the spec writes one (then a copy is changed, never yours).
48
- * Per slot: { texture, channel, repeat, wrap, colorSpace }, e.g. aoMap: { texture: 'ao', channel: 1 } reads the second uv set (uv1).
49
- * Example: { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', repeat: 4 }
50
- */
51
- map?: TextureSlot;
52
- normalMap?: TextureSlot;
53
- roughnessMap?: TextureSlot;
54
- aoMap?: TextureSlot;
55
- lightMap?: TextureSlot;
56
- /** How many times the textures of this material repeat (a number, or [x, y]); default 1 */
57
- repeat?: number | [number, number];
58
- /** Texture wrapping: 'repeat' (default for files loaded by name; your own textures keep theirs) | 'clamp' | 'mirror' */
59
- wrap?: Loose<'repeat' | 'clamp' | 'mirror'>;
60
- /** Grain, paper, strokes or a texture laid over the surface in world space (no UVs needed); off unless given */
61
- detail?: MaterialDetail;
62
- /** Extra light shaping (shadow tint, rim, wrap, your own GLSL); merged over style.lighting, false opts out */
63
- lighting?: MaterialLighting | false;
64
- [prop: string]: any;
65
- }
66
-
67
- /**
68
- * The `detail` surface patch. Source: texture (asset name) or noise ('grain' | 'paper' | 'stroke' | 'dabs', default grain) or glsl (your own sampler
69
- * function). Effects: color (strength, mode), normal (relief height in meters), roughness (amount). Every number is a uniform, so many materials
70
- * with different values share one shader program. Channels (color / normal / roughness) are fixed when the material is made.
71
- */
72
- export interface MaterialDetail {
73
- /** Read as data, not color: 50% gray (128) is neutral. An asset name is loaded without sRGB decoding; a THREE.Texture you pass should use NoColorSpace */
74
- texture?: string | import('three').Texture;
75
- noise?: Loose<'grain' | 'paper' | 'stroke' | 'dabs'>;
76
- /** Replaces the noise: `vec4 threedogDetailSample(vec2 p)` returns vec4(color rgb, height 0-1); p is scaled, turned, stretched */
77
- glsl?: string;
78
- /** Uniforms for glsl: numbers, colors, [x, y(, z, w)] arrays or textures */
79
- uniforms?: Record<string, any>;
80
- /**
81
- * 'world' (default, looks straight down) | 'triplanar' (three axis planes blended by the surface normal; for walls and rocks) |
82
- * 'screen' (on the screen pixels: the same grain size near and far, for illustrated / printed looks; scale is pixels per cell)
83
- */
84
- projection?: Loose<'world' | 'triplanar' | 'screen'>;
85
- /** Repeats per meter, default 0.25; with projection 'screen' pixels per pattern cell, default 2 */
86
- scale?: number;
87
- /** Color effect 0-1, default 0.35 (0 turns the color part off) */
88
- strength?: number;
89
- /** How the color is applied: 'multiply' (default) | 'add' (lighter and darker) | 'mix' (towards the sample color) */
90
- mode?: Loose<'multiply' | 'add' | 'mix'>;
91
- /** Colors the sample (default white) */
92
- tint?: ColorLike;
93
- /** Default true: the effect fades out where the pattern is smaller than about a pixel (far away, grazing angles), so it does not shimmer. `false` keeps it. In `glsl`, `threedogDetailFootprint` is one pixel in pattern units */
94
- fade?: boolean;
95
- /** Degrees; turns the pattern (strokes run along it) */
96
- direction?: number;
97
- /** Stretches the pattern along direction (default 1, strokes 6) */
98
- stretch?: number;
99
- /** Noise layers 1-4, default 2 */
100
- octaves?: number;
101
- /** Relief height in meters (bumps the normal); needs a lit material */
102
- normal?: number;
103
- /** How much the sample moves roughness (standard / physical only) */
104
- roughness?: number;
105
- }
106
-
107
- /**
108
- * The `lighting` surface patch, on a spec (materials.x.lighting) or for all lit materials (style.lighting). three has no shadow color: a shadow only
109
- * removes the sun's light. These shape the summed light afterwards, from the first directional light (the sun) and its shadow for this pixel.
110
- * Limits: one directional light; point / spot lights are untouched; cloud shadows are not 'shadow' here. Values are uniforms (shared program).
111
- */
112
- export interface MaterialLighting {
113
- /** Half-lambert: diffuse = (n.l + wrap) / (1 + wrap) from the sun; 0 = off, 0.5 soft, 1 full half-lambert. Ignores a toon ramp */
114
- wrap?: number;
115
- /** Shadowed (or sun-averted) parts shift hue towards this color at the same brightness: strength 0-1 (default 0.5),
116
- * soft = terminator width in n.l (default 0.3) */
117
- shadowTint?: { color: ColorLike; strength?: number; soft?: number };
118
- /** Fresnel edge light added to the ambient part: strength (0.4), power (3, higher = thinner rim),
119
- * shadowSide 0-1 (1 = only on the side away from the sun) */
120
- rim?: { color: ColorLike; strength?: number; power?: number; shadowSide?: number };
121
- /**
122
- * Your own shaping, replaces wrap / shadowTint / rim:
123
- * `void threedogLighting(inout ReflectedLight light, vec3 normal, vec3 viewDir, vec3 sunDir, float sunShadow, vec3 albedo)`
124
- */
125
- glsl?: string;
126
- uniforms?: Record<string, any>;
127
- }
128
-
129
- /** Sky keyframe: [time 0–1, zenith color, horizon color (= fog color), sun color, sun intensity, ambient intensity] */
130
- export type SkyKeyframe = (number | ColorLike)[];
131
-
132
- export interface StyleSeasons {
133
- mode?: Loose<'multiply' | 'mix'>;
134
- strength?: number;
135
- [season: string]: any;
136
- }
137
-
138
- export interface StyleSky {
139
- /**
140
- * Rows [time, zenith, horizon, lightColor, lightIntensity, ambient]. time: share of the day (0 = 00:00, 0.5 = noon), sorted, first row 0,
141
- * last 1 (midnight again: same values as 0). horizon is also the fog color. light*: engine.lights.sun (the moon at night). ambient: the
142
- * hemisphere fill, also dims the room environment (recipe 08).
143
- * @example [[0, 0x0b1030, 0x1c2440, 0x8090c0, 0.3, 0.25], [0.5, 0x5a8fd0, 0xbcd4ea, 0xfff4e0, 3, 1.1], [1, 0x0b1030, 0x1c2440, 0x8090c0, 0.3, 0.25]]
144
- */
145
- keyframes?: SkyKeyframe[];
146
- /**
147
- * A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds), or ({ time, weather, season, state, sky }) => color per
148
- * frame. Drawn as written (no tone mapping); the keyframes still light the world; fog in its default horizon color follows it (a
149
- * fog.color of your own still wins). Leave out for the dome. Not with skybox. recipes/47
150
- * @example backdrop: ({ sky }) => sky.isDay ? 0xefebe4 : 0x2c3346
151
- */
152
- backdrop?: ColorLike | ((ctx: LookContext) => ColorLike);
153
- /** Sharpness exponent of the sun disk, default 900 (about 2 deg); larger = smaller. Not a size in degrees: 10 is ~20 deg, under ~3 the "disk" washes most of the sky toward the sun color */
154
- sunSize?: number;
155
- /** Sun glow, default 0.18 */
156
- sunGlow?: number;
157
- /** Sun brightness, default 6 */
158
- sunBrightness?: number;
159
- /** Larger means a smaller moon */
160
- moonSize?: number;
161
- moonColor?: ColorLike;
162
- moonBrightness?: number;
163
- /** North-south tilt of the sun path */
164
- orbitTilt?: number;
165
- /** East-west swing of the sun path */
166
- orbitSway?: number;
167
- /** Share of the sky grid cells (0-1) that hold a star at night, default 0.0025 (0 = no stars). A probability, not a brightness: near 1 every cell is lit and the upper sky turns into a white sheet. The cell size is starScale */
168
- starDensity?: number;
169
- /** Star grid resolution (cells per unit of view direction), default 260: larger means smaller and more numerous stars */
170
- starScale?: number;
171
- /**
172
- * What the sky dims for every game unless the style says no (each default true; false turns that one off, the rest stay). The one place these
173
- * look decisions are switched:
174
- * - tint: a sky.tint color (weather grey, a cave tint) dims with the sky's own light, so a grey rain tint stays dark at night. false: the tint
175
- * keeps its full color at any hour (a fantasy sky that stays bright at night)
176
- * - stars: stars fade with the weather's cloud cover, not only behind drawn clouds. false: stars shine through an overcast / rainy sky
177
- * @example style.sky.dim = { stars: false } // or engine.look.sky.set({ dim: { tint: false } })
178
- */
179
- dim?: { tint?: boolean; stars?: boolean };
180
- /**
181
- * Gradient curve from horizon to zenith, default 0.55 (color = mix(horizon, zenith, elevation^curve), mixed in linear light, then tone mapped
182
- * and exposed like the scene). The keyframe zenith shows only high up: a level camera (55 deg fov) sees the lowest ~25 deg, where a warm
183
- * horizon and a deep-blue zenith mix to a gray-lavender (desert R4: e8d4a8 / 1858c8 read as #9b99bd at the frame's top). Lower curve = more
184
- * zenith color near the horizon; or bring the horizon color closer to the zenith hue. toneMapping 'aces' also turns a saturated blue toward
185
- * violet ('agx' / 'neutral' keep the hue closer). Check with threedog shot
186
- */
187
- gradientCurve?: number;
188
- /** Ground bounce color of the ambient light */
189
- groundTint?: ColorLike;
190
- /** Clouds in the sky (cloud cover follows the weather); see StyleSkyClouds */
191
- clouds?: StyleSkyClouds;
192
- /** Panorama (equirectangular) replacing the gradient sky, asset name or path (at run time engine.look.sky.replace(name)) */
193
- skybox?: string;
194
- /** Shadows: mapSize resolution (pixels), extent coverage (meters), etc., see StyleShadow */
195
- shadow?: StyleShadow;
196
- /** Environment lighting (scene.environment), off unless a source is given; see engine.look.env. A pack can give defaults, sky({ environment }) overrides */
197
- environment?: StyleEnvironment;
198
- /** Fog model and color (default: linear fog in the horizon color); see StyleFog */
199
- fog?: StyleFog;
200
- /** Extra dome layers drawn after the clouds and stars (rainbow, aurora), default none; see StyleSkyLayer */
201
- layers?: StyleSkyLayer[];
202
- }
203
-
204
- /**
205
- * Fog (modules/sky/fog.js). Defaults draw three's linear fog in the dome's horizon color, exactly as before.
206
- * @example fog: { kind: 'height', height: 2, falloff: 0.08, density: 0.02 } // valley mist, thin above
207
- * @example fog: { kind: 'exp2', color: 0xb8c4d0 } // own color: the dome's lower band fades to it so the horizon line does not show
208
- */
209
- export interface StyleFog {
210
- /** 'linear' (default, near = 0.3 x far) | 'exp' | 'exp2' | 'height' (thick below `height`, thinning above it) */
211
- kind?: Loose<'linear' | 'exp' | 'exp2' | 'height'>;
212
- /** 'horizon' (default: the dome's horizon color) | a color | ({ time, state, sky }) => either (e.g. to darken it at night) */
213
- color?: 'horizon' | ColorLike | ((ctx: LookContext) => 'horizon' | ColorLike);
214
- /** Per meter, exp / exp2 / height (default: derived from look.fog far, so fog reaches the same distance as linear); an explicit density is kept as given */
215
- density?: number;
216
- /** Linear fog start (meters); default 0.3 x far. Same keys as engine.look.fog.set */
217
- near?: number;
218
- /** Linear fog end (meters); default 600 (look.fog far: the terrain view, a game set and the weather act on it) */
219
- far?: number;
220
- /** false: no fog; default true */
221
- enabled?: boolean;
222
- /** 'height': world y of the fog floor, default 0 */
223
- height?: number;
224
- /** 'height': how fast the fog thins above the floor, per meter, default 0.05 */
225
- falloff?: number;
226
- // Your own fog math is not a style key: engine.look.fog.patch('fog', glsl) (vec4 threedogFog(vec3 color, float depth, vec3 worldPos))
227
- }
228
-
229
- /**
230
- * One extra sky layer (modules/sky/domeLayers.js)
231
- * @example layers: [{ blend: 'add', uniforms: { uAurora: [0.2, 1, 0.6] }, glsl: `vec4 threedogSkyLayer(vec3 d, float time, vec3 sunDir, float night){
232
- * float band = smoothstep(0.25, 0.45, d.y) * (1.0 - smoothstep(0.55, 0.8, d.y)) * threedogNoise(vec2(d.x * 4.0 + time * 0.05, d.z * 2.0));
233
- * return vec4(uAurora, band * night); }` }]
234
- */
235
- export interface StyleSkyLayer {
236
- /** The layer's name, the key for engine.look.sky.patch('layer:<name>'); default layer0, layer1 ... by position */
237
- name?: string;
238
- /** Defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount 0..1); renamed per layer, so layers never clash. WebGLRenderer draws it */
239
- glsl?: string;
240
- /** WebGPURenderer form: (ctx) => vec4 node (rgb, amount); ctx = { dir, time, sunDir, night, color (sky so far), uniforms, fx: { noise, hash }, tsl } (recipe 52 'tsl forms') */
241
- tsl?: (ctx: any) => any;
242
- /** Custom uniforms (numbers, THREE.Color, [x, y(, z, w)], THREE.Texture), live in engine.sky.dome.material.uniforms */
243
- uniforms?: Record<string, any>;
244
- /** Draw order among the layers, smaller first (default 0) */
245
- order?: number;
246
- /** 'mix' (default: mix(sky, rgb, amount)) | 'add' (sky + rgb * amount, for glows) */
247
- blend?: Loose<'mix' | 'add'>;
248
- }
249
-
250
- /** Environment lighting parameters */
251
- export interface StyleEnvironment {
252
- /** 'sky' (built from the procedural sky) or an HDR / panorama asset name or path; omitted or null = off */
253
- source?: string | null;
254
- /** Light scale, default 1 */
255
- intensity?: number;
256
- /** Turn around Y, radians, default 0 */
257
- rotation?: number;
258
- /** Seconds between rebuilds of a 'sky' source (only when the sky changed), default 1 */
259
- interval?: number;
260
- /** Low-tier override: fields to replace there (a 'sky' source already rebuilds 4 times less often), or false to turn it off */
261
- low?: Omit<StyleEnvironment, 'low'> | false;
262
- }
263
-
264
- /**
265
- * Sky cloud layer. The defaults are the original look ('plane': one plane projected onto the sky, 3 noise layers), so a style
266
- * that sets nothing here draws what it always drew. Values below marked (plane) are the defaults of kind 'plane'.
267
- * @example clouds: { kind: 'cumulus', coverage: 1, scale: 0.5, color: 0xfff6ea, shade: 0x8fa0b8 } // full-sky billowy clouds with sun-side light
268
- * Your own cloud function is not a style key: engine.look.sky.patch('clouds', { glsl, uniforms }) (modules/sky/clouds.js has the signature).
269
- */
270
- export interface StyleSkyClouds {
271
- color?: ColorLike; shade?: ColorLike;
272
- /** 0-1+, multiplies the weather cloud amount (default 1) */
273
- coverage?: number;
274
- /** Cloud cell size: larger = smaller clouds (plane 0.35) */
275
- scale?: number;
276
- /** Drift per second [x, z] (plane [0.004, 0.002]) */
277
- speed?: number[];
278
- /**
279
- * 'plane' (default): cheap, 3 noise samples, cells shrink and crowd towards the horizon.
280
- * 'cumulus': 8 noise samples per cloudy pixel, flatter projection (clouds fill the whole sky), sun-side light and shaded undersides.
281
- * Both are one 2D pass, no ray marching.
282
- */
283
- kind?: Loose<'plane' | 'cumulus'>;
284
- /** Added to dir.y in the plane projection: smaller = stronger crowding at the horizon (plane 0.08, cumulus 0.5) */
285
- horizon?: number;
286
- /** Horizon fade [from, to] in dir.y: clouds are invisible below `from` and full above `to` (plane [0, 0.18], cumulus [0, 0.12]) */
287
- fade?: number[];
288
- /** Cloud opacity 0-1 (plane 0.9, cumulus 0.95) */
289
- opacity?: number;
290
- /** Width of the cloud edge in noise units: larger = softer edge (plane 0.3, cumulus 0.35) */
291
- softness?: number;
292
- /** 'plane' only: the 3 noise layers. scales = frequency multipliers of layers 2 and 3 (default [2.7, 6.1]), weights = their mix (default [0.6, 0.3, 0.1]) */
293
- noise?: { scales?: number[]; weights?: number[] };
294
- /** 'cumulus' only: contrast of the sun-side light (default 5) */
295
- relief?: number;
296
- }
297
-
298
- /**
299
- * Wind look. frequency multiplies the sway speed. Your own sway shape is not a style key: engine.look.wind.patch('sway', { glsl, uniforms })
300
- * before vegetation.define replaces it for every swaying material made through vegetation.define: define `void threedogWind(inout vec3 transformed, vec3 ip, vec3 position)` that moves
301
- * `transformed` (object space); ip = world position of this instance's origin (own phase per plant), position = the vertex. In scope: uTime, uWind
302
- * (weather multiplier), uWindFreq, THREEDOG_WIND_AMP (the species' amplitude), your `uniforms`. The shadow sways with it. The default is in
303
- * render/effects.js (threedog_wind_vertex): two sines, height-weighted, a lean with the wind strength.
304
- * @example engine.look.wind.patch('sway', `void threedogWind(inout vec3 t, vec3 ip, vec3 p){ float s = floor(sin(uTime * uWindFreq + ip.x) * 3.0) / 3.0; t.x += s * max(p.y, 0.0) * THREEDOG_WIND_AMP * uWind; }`)
305
- */
306
- export interface StyleWind {
307
- frequency?: number;
308
- }
309
-
310
- /** engine.sky.shadow: the shadow params in use (engine.look.shadow.set changes them); field meanings as in StyleShadow */
311
- export interface SkyShadowParams {
312
- bias: number; normalBias: number; updateEvery: number; snap: number | 'texel'; ahead: number; radius: number; blurSamples: number;
313
- cascades: number; maxFar: number; fade: boolean; lightMargin: number; split: StyleShadow['split'];
314
- /** Same keys as engine.look.shadow.set */
315
- mapSize?: number; enabled?: boolean;
316
- }
317
-
318
- /** Sun shadow parameters (defaults are the current look) */
319
- export interface StyleShadow {
320
- /** Shadow resolution (pixels), default 2048 */
321
- mapSize?: number;
322
- /** Coverage radius (meters), default 70 */
323
- extent?: number;
324
- /** Distance of the light from the shadow center (meters), default 160 */
325
- distance?: number;
326
- /** Anti shadow-acne depth bias (0-1 shadow depth over the 419 m light range: -0.00005 = 2 cm), default -0.00005 */
327
- bias?: number;
328
- /** Normal-offset anti-acne, default 0.04 */
329
- normalBias?: number;
330
- /** Update shadows every N frames, default 1 (every frame); larger saves more, still updates promptly when the focus moves */
331
- updateEvery?: number;
332
- /** Shadow center snapping grid (meters), default 0.5; 'texel' snaps to shadow pixels (shadow edges do not shimmer while moving) */
333
- snap?: number | 'texel';
334
- /** How far ahead of the view direction the shadow center is shifted (meters), default 0 */
335
- ahead?: number;
336
- /** Shadow filter: 'basic' (hard edge, cheapest) | 'pcf' (default, soft edge) | 'vsm' (softest, costliest). Default 'pcf' (look.shadow type) */
337
- type?: Loose<'basic' | 'pcf' | 'vsm'>;
338
- /** Edge softness for 'pcf' and 'vsm' (no effect on 'basic'), default 1 */
339
- radius?: number;
340
- /** Blur sample count, 'vsm' only, default 8 */
341
- blurSamples?: number;
342
- /**
343
- * Cascaded shadows (recipes/45): 1 (default) = one shadow map around the focus, the plain path; 2-4 split the sun's shadow along the view,
344
- * sharp near the camera and wide far away. Each cascade draws the casters once more. Low-tier devices stay at 1 unless low.cascades says so.
345
- * Switching recompiles every lit material once (the light count changes); extent / snap / ahead do not apply while cascades are on
346
- * @example shadow: { cascades: 3, maxFar: 150, low: { cascades: 2, fade: false } } // low-tier devices: 2 cascades instead of one map
347
- */
348
- cascades?: number;
349
- /** Cascades: meters from the camera they cover (no sun shadow beyond), default 120 */
350
- maxFar?: number;
351
- /** Cascades: cross-fade at each border so no seam shows (two shadow lookups there), default true */
352
- fade?: boolean;
353
- /** Cascades: meters behind each cascade box toward the light still caught as casters (tall things outside the view), default 100 */
354
- lightMargin?: number;
355
- /** Cascades: where borders fall, 'practical' (default) | 'uniform' | 'logarithmic' | (count, near, far, out: number[]) => void (three CSM customSplitsCallback) */
356
- split?: Loose<'practical' | 'uniform' | 'logarithmic'> | ((count: number, near: number, far: number, out: number[]) => void);
357
- /**
358
- * Overrides used on low-tier devices (engine.tier 'low'), default { mapSize: 1024, cascades: 1 }. updateEvery above 1 saves more but makes
359
- * wind-swayed shadows step visibly. sky({ shadow }) options replace the whole shadow block, low included.
360
- */
361
- low?: Omit<StyleShadow, 'low'>;
362
- }
363
-
364
- export interface StyleWeather {
365
- /** Rain / snow coverage (meters, centered on the camera) */
366
- area?: number;
367
- /** Target color the sky turns to when overcast */
368
- overcastColor?: ColorLike;
369
- /** Lightning brightness multiplier */
370
- lightningBrightness?: number;
371
- /**
372
- * Lightning look: flash (1 at the strike, fading in a third of a second) -> sky flash amount; default flickers. Return 0 and draw your own bolt
373
- * on the weather:lightning event for a whole replacement
374
- * @example lightning: f => f * f * 0.8
375
- */
376
- lightning?: (flash: number, engine: Engine) => number;
377
- /** Rain particles (default streaks: color 0xc8c8c8, opacity 0.55, length 0.7 m, speed 22 m/s, slant 1); a texture or a sprite shape draws drops */
378
- rain?: StyleWeatherParticles;
379
- /** Snow particles (default round sprites: color 0xffffff, opacity 0.9, size 20, maxSize 5 px, speed 1.6 m/s, sway 1.5 m) */
380
- snow?: StyleWeatherSnow;
381
- /** Retune the look of weather types the game has (e.g. a darker storm); never adds a type: the list is the game's weather({ types }) */
382
- types?: Record<string, Partial<WeatherPreset>>;
383
- }
384
-
385
- /** style.weather.snow: the snow particles' look plus the cover it leaves */
386
- export interface StyleWeatherSnow extends StyleWeatherParticles {
387
- /** Snow lying on foliage / ground while it snows (StyleSnowCover); leave out for particles only */
388
- cover?: StyleSnowCover;
389
- }
390
-
391
- /**
392
- * Snow cover (style.weather.snow.cover): the season tint of foliage / ground (vegetation, terrain, materials with season) moves toward
393
- * these colors as the weather's snow amount rises, `strength` of the way at full snow, and melts back as it falls. Rides the season
394
- * patch (mix over style.seasons; a 'multiply' season gives way while snow lies). Leave it out and snow only draws particles.
395
- * The same cover for anything else (ash, frost): engine.mod('look.ground.cover', { owner: 'ash', value: { ground: 0x555555, amount: 0.6 } }). recipes/47
396
- * @example cover: { foliage: 0xf2f4f6, ground: 0xeef0f2, strength: 0.8 }
397
- */
398
- export interface StyleSnowCover {
399
- /** Snow color on foliage (leave out: foliage keeps its season color) */
400
- foliage?: ColorLike;
401
- /** Snow color on the ground (leave out: ground keeps its season color) */
402
- ground?: ColorLike;
403
- /** How far toward the color at full snow, 0-1, default 0.8 */
404
- strength?: number;
405
- }
406
-
407
- /** Falling weather particles: style.weather.rain / snow and engine.look.weather.replace({ field: spec }). See recipes/44-water-weather-look-hooks.md */
408
- export interface StyleWeatherParticles {
409
- /** 'line' streaks slant with the wind; 'round' | 'soft' | 'square' sprites drift (sway) */
410
- shape?: Loose<'line' | 'round' | 'soft' | 'square'>;
411
- /** Sprite image (asset name), replaces the shape */
412
- texture?: string | null;
413
- color?: ColorLike;
414
- opacity?: number;
415
- /** Sprite size (pixels at 3 m) and its pixel cap */
416
- size?: number;
417
- maxSize?: number;
418
- /** Streak length (meters, lines) */
419
- length?: number;
420
- /** Fall speed (m/s) */
421
- speed?: number;
422
- /** Streak lean per unit of wind (lines) */
423
- slant?: number;
424
- /** Sprite drift (meters) */
425
- sway?: number;
426
- /** Particle count (default weather({ particles }); halved on low-tier devices) */
427
- count?: number;
428
- /** Weather amount 0..1 -> share of particles drawn (rain default a => min(1, a * 1.2), snow () => 1; opacity follows the amount too) */
429
- density?: (amount: number) => number;
430
- /**
431
- * Whole shader text (copy modules/weather/shaders.js). In scope: uCam uSize uFallOff uOpacity uColor, lines uWindDir uLen (attribute aEnd),
432
- * sprites uPx uMaxPx uSway uSwayAmp uMap uUseMap, and your uniforms (declared for you)
433
- */
434
- glsl?: { vertex?: string; fragment?: string };
435
- /** Uniforms for your glsl: numbers, colors, [x, y(, z, w)] arrays, textures; live in engine.weatherLook.systems.get(field).uniforms */
436
- uniforms?: Record<string, any>;
437
- /** A system of your own instead (engine.look.weather.replace only): the engine adds object, shows it while the amount is above 0.02, calls update */
438
- create?: (engine: Engine, ctx: { area: number; count: number }) => {
439
- object: Object3D; update?: (amount: number, ctx: { camera: any; time: number; wind: number }) => void };
440
- }
441
-
442
- export interface StyleWater {
443
- /**
444
- * Replace the whole water surface material (the built-in role 'water', waves and fresnel are skipped). Receives the shared
445
- * uniforms (uTime, uWave, uWaveScale, uWaveSpeed), the built-in wave patch, the surface patch (depthColor / foam / the 'surface' hook; null
446
- * without them; put it after waves) and the scrolling normal map (null without one). Reflections: recipes/44-water-weather-look-hooks.md
447
- * @example material: (engine, { waves }) => applyEffects(new THREE.MeshToonMaterial({ color: 0x3a8acf }), { clouds: false, patches: [waves] })
448
- */
449
- material?: (engine: Engine, ctx: { uniforms: Record<string, { value: any }>; waves: ShaderPatch; surface: ShaderPatch | null;
450
- normalMap: import('three').Texture | null }) => Material;
451
- /**
452
- * Water color from the view angle (by 'view', default: shallow looking down, deep at grazing angles) or the wave height (by 'wave': shallow on
453
- * crests); replaces color. curve shapes the blend (default 1)
454
- */
455
- depthColor?: StyleWaterDepth;
456
- /**
457
- * Crest foam from the wave height (start / end: fraction of waveMax (the 'wave' hook's, default 0.29) where foam begins / is full, default 0.55 / 0.85); true = defaults.
458
- * Shore foam needs depth: recipes/44
459
- */
460
- foam?: StyleWaterFoam | true;
461
- // Your own GLSL is not a style key: engine.look.water.patch('wave', glsl | { glsl, waveMax }) / patch('surface', glsl) (recipes/44)
462
- /** Uniforms for your look.water hooks' GLSL, in both stages: numbers, colors, [x, y(, z, w)] arrays or textures; live in engine.water.material.uniforms */
463
- uniforms?: Record<string, any>;
464
- color?: ColorLike;
465
- /** Opacity 0–1 */
466
- opacity?: number;
467
- /** Flat shading (low poly) */
468
- flat?: boolean;
469
- /** Wave height multiplier */
470
- waveHeight?: number;
471
- waveScale?: number;
472
- waveSpeed?: number;
473
- /** Grazing-angle reflection strength 0–1 */
474
- fresnel?: number;
475
- /** Normal map (asset name or path) */
476
- normalMap?: string;
477
- normalScale?: number;
478
- normalRepeat?: number;
479
- /** Normal map flow speed [x, z] */
480
- normalSpeed?: number[];
481
- shininess?: number;
482
- specular?: ColorLike;
483
- /** Mesh subdivision of the global water (quality, not the world; default 150) */
484
- segments?: number;
485
- // level, sea and size are not style: water({ level, sea, size }) (WaterOptions)
486
- }
487
-
488
- export interface StyleWaterDepth {
489
- /** Color looking down / on crests. Missing: neutral light gray (the engine picks no water color; set both) */
490
- shallow?: ColorLike;
491
- /** Color at grazing angles / in troughs. Missing: neutral dark gray */
492
- deep?: ColorLike;
493
- by?: Loose<'view' | 'wave'>;
494
- curve?: number;
495
- }
496
-
497
- export interface StyleWaterFoam {
498
- color?: ColorLike;
499
- start?: number;
500
- end?: number;
501
- /** 0-1, foam opacity on top of the water (default 1) */
502
- opacity?: number;
503
- }
504
-
505
- export interface StyleTerrain {
506
- /** Palette: color name → color (e.g. sand, meadowA, rock) */
507
- colors?: Record<string, ColorLike>;
508
- /** Landform → palette color name (two names are blended by noise) */
509
- biomeColors?: Record<string, string[]>;
510
- /** Color rule for steep slopes */
511
- steep?: SteepRule[];
512
- /**
513
- * How ground colors vary (plain data, sent to the terrain workers). Every default is the original look; set only what you want to change.
514
- * blend: the two-color noise (size = wavelength in meters, default 33; strength = contrast, default 1). jitter: per-cell brightness grain
515
- * (size = cell in meters, default 0.33; min = darkest multiplier 0.92; range = how much brighter it gets 0.12). patches: a second, much larger
516
- * layer for painted color blocks (size in meters, default 90; strength 0-1, default 0.15; levels > 0 snaps it to flat blocks; tint = pull
517
- * towards this color instead of lighten/darken).
518
- * @example variation: { blend: { size: 14 }, jitter: { range: 0.04 }, patches: { size: 60, strength: 0.25, levels: 4, tint: 0xb59a5a } }
519
- */
520
- variation?: {
521
- blend?: { size?: number; strength?: number };
522
- jitter?: { size?: number; min?: number; range?: number };
523
- patches?: { size?: number; strength?: number; levels?: number; tint?: number };
524
- };
525
- /**
526
- * Looks of the ground mesh only. shading: 'flat' one color and normal per triangle (facets) | 'smooth' (engine default) | 'texture' (per-chunk color
527
- * map, colors independent of the mesh); colorResolution: color map pixels per chunk edge; normals: 'smooth' | 'flat' lighting in texture mode;
528
- * normalFn: custom grid-point normal. Shape, size, seed, water level, resolution, diagonal: terrain({...}). See recipes/37-terrain-look-hooks.md
529
- */
530
- config?: { shading?: Loose<'flat' | 'smooth' | 'texture'>; colorResolution?: number; normals?: Loose<'smooth' | 'flat'>; normalFn?: TerrainConfig['normalFn'] };
531
- /** Whole ground material: a Material or (engine) => Material (uv = world xz / chunk size; terrain({ material }) wins) */
532
- material?: Material | ((engine: Engine) => Material);
533
- /**
534
- * Detail layer over the ground, the same object as a material spec's `detail`: a noise ('grain' | 'paper' | 'stroke' | 'dabs'), a texture
535
- * asset name, or your own `glsl`; plus scale, strength, fade ... (top-down world projection by default). Live: look.ground.set({ detail }).
536
- * See recipes/53-ground-up-close.md
537
- */
538
- detail?: MaterialDetail;
539
- }
540
-
541
- /** UI template function: (data, helpers) => HTML string */
542
- export type UITemplate = (data: any, tools: { esc: (s: any) => string; t: (key: string, params?: Record<string, any>) => string; icon?: (def: any) => string }) => string;
543
-
544
- export interface StyleUI {
545
- /** Background color */
546
- bg?: string;
547
- /** Text color */
548
- fg?: string;
549
- /** Secondary text color */
550
- muted?: string;
551
- /** Accent color */
552
- accent?: string;
553
- /** Color for good news such as "done" */
554
- good?: string;
555
- /** Divider color */
556
- line?: string;
557
- /** Font (CSS font-family) */
558
- font?: string;
559
- /** Corner radius (CSS, e.g. '12px') */
560
- radius?: string;
561
- /** Loading screen background */
562
- loadingBg?: string;
563
- /** Window shadow (CSS) */
564
- shadow?: string;
565
- /** Height of the interaction prompt above the object (meters) */
566
- promptHeight?: number;
567
- /** Fade color for scene transitions (CSS), default '#000' */
568
- fadeBg?: string;
569
- /** Background / text / accent colors of objective markers, counters and progress bars (CSS) */
570
- hudBg?: string;
571
- hudFg?: string;
572
- hudAccent?: string;
573
- /**
574
- * Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in font: '"pixel", system-ui'. A style never holds
575
- * a font file path
576
- */
577
- fonts?: string[];
578
- /** Extra CSS (overrides .threedog-* classes) */
579
- css?: string;
580
- /** Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar… */
581
- templates?: Record<string, UITemplate>;
582
- /** Other CSS variables (become --threedog-name) */
583
- [cssVar: string]: any;
584
- }
585
-
586
- export interface Style {
587
- /** Style name */
588
- name?: string;
589
- /**
590
- * Exposure, default 1: a number, or over the day [[time 0-1, exposure], ...] (sorted, wraps across midnight) or ({ time, state, sky }) => number,
591
- * evaluated by the sky module every frame. engine.look.tone.set changes it at run time
592
- * @example exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // brighter nights
593
- */
594
- exposure?: number | number[][] | ((ctx: LookContext) => number);
595
- /** Tone mapping curve, written once when the engine creates its renderer (default 'agx', the render baseline). Later changes are plain three.js: engine.renderer.toneMapping = THREE.ACESFilmicToneMapping; the engine never writes it again */
596
- toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>;
597
- /** Background color (when there is no sky module) */
598
- background?: ColorLike;
599
- /**
600
- * Material per role (default, terrain, vegetation, character, water, building, pickup…): a spec, a three.js Material instance (cloned per use), or a
601
- * function (params, purpose) => Material. This table is the style layer of engine.look.materials (the one entry makeMaterial reads): the game's
602
- * look.materials.set / replace go on top
603
- */
604
- materials?: Record<string, MaterialSpec | import('three').Material
605
- | ((params: Record<string, any>, purpose: string, engine: Engine) => import('three').Material)>;
606
- /**
607
- * The style's own look plugins: what engine.plugins.add takes (import.meta.glob('./plugins/*.js', { eager: true }) from the style folder, or
608
- * { name: { default: value } }), each file exporting the same shapes as the game's plugins/ folder. Plugged through engine.plugins before the
609
- * game's folder, named '<style name>/<file>'; materials and material patches sit on the style layer. engine.plugins.off('<style name>') takes them all out
610
- * @example plugins: import.meta.glob('./plugins/*.js', { eager: true })
611
- */
612
- plugins?: Record<string, any>;
613
- /**
614
- * Anti-aliasing: true = MSAA (also inside post-processing), false = off (pixel art, sharp edges). Default: on for desktop, off for low tier;
615
- * createEngine({ antialias }) wins
616
- */
617
- antialias?: boolean;
618
- /** Light shaping for every lit material of the pack (shadow tint, rim, wrap, glsl); a material's `lighting` wins, `lighting: false` opts out */
619
- lighting?: MaterialLighting;
620
- /**
621
- * Seasonal tint: { spring: { foliage, ground }, ... }. mode 'multiply' (default) multiplies the color onto the surface
622
- * (pick tints near white: orange times green is muddy); 'mix' moves the surface `strength` (0-1, default 0.5) of the
623
- * way to the color. Season names are the other keys, so none can be called mode or strength
624
- */
625
- seasons?: StyleSeasons;
626
- /** Cloud shadow: shadow darkest level 0–1 (default 0 = no cloud shadows), scale cloud size (smaller means bigger clouds), speed [x, z] */
627
- clouds?: { shadow?: number; scale?: number; speed?: number[] };
628
- /**
629
- * Named colors the procedural model generators read (trees, rocks, grass: a generator written with `function` gets them as this.palette; a pack may use keys like
630
- * bark, pine, leaf, rock, grassTip...). One place to retint all of them, e.g. style: [basePack, { palette: { leaf: 0xd98a3a } }]; keys left out keep the pack's values
631
- */
632
- palette?: Record<string, ColorLike>;
633
- /** Wind: frequency sway frequency multiplier */
634
- wind?: StyleWind;
635
- /** Terrain colors etc. */
636
- terrain?: StyleTerrain;
637
- /** Sky */
638
- sky?: StyleSky;
639
- /** Weather look */
640
- weather?: StyleWeather;
641
- /** Water look */
642
- water?: StyleWater;
643
- /**
644
- * Default look of pickups on the ground: color (the item's own color wins), size (meters, of the gray placeholder box), lift height above ground
645
- * (meters). The shape is not style: it is a model name from an asset pack (item model, else 'pickup:<item>', else 'pickup'); a generator that
646
- * returns bare geometry is shaded by materials.pickup in the item's color
647
- */
648
- pickup?: { color?: ColorLike; size?: number; lift?: number };
649
- /**
650
- * How character motion looks: animation.fade skeletal animation transition seconds. Bodies are assets, not style ({ model: 'yourBody' } from
651
- * an asset pack); a style tints body parts through materials roles (cloth, skin, trousers, hair).
652
- */
653
- character?: { animation?: { fade?: number } };
654
- /** UI colors, fonts, templates */
655
- ui?: StyleUI;
656
- /** Particle presets: name → parameters; default is the fallback for all effects */
657
- particles?: Record<string, ParticleOptions>;
658
- /** Trigger zone debug wireframe */
659
- triggers?: { debugColor?: ColorLike; debugOpacity?: number };
660
- /**
661
- * Grid placement (grids() module): preview ok / bad colors and opacity, tile lift (m), and per-layer tile colors { layer: { field: color } } (first
662
- * truthy field of a cell's data wins)
663
- */
664
- grid?: { ok?: ColorLike; bad?: ColorLike; previewOpacity?: number; previewHeight?: number; tileLift?: number; tiles?: Record<string, Record<string, ColorLike>> };
665
- }
666
- /**
667
- * What createEngine({ style }) takes: one style object, or a list of parts deep-merged left to right (plain objects merge, everything else replaces,
668
- * null removes; core/styleParts.js)
669
- */
670
- export type StyleInput = Style | null | undefined | false | StyleInput[];
671
-