threedog 0.5.0 → 0.8.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 (750) hide show
  1. package/CHANGELOG.md +276 -1
  2. package/README.md +18 -13
  3. package/core/{Animator.js → assets/Animator.js} +28 -18
  4. package/core/{Assets.js → assets/Assets.js} +116 -61
  5. package/core/{Baked.js → assets/Baked.js} +16 -25
  6. package/core/assets/assetEntry.js +237 -0
  7. package/core/{assetHot.js → assets/assetHot.js} +7 -6
  8. package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
  11. package/core/{assetReport.js → assets/assetReport.js} +9 -15
  12. package/core/{namedModel.js → assets/namedModel.js} +24 -16
  13. package/core/{Audio.js → audio/Audio.js} +27 -24
  14. package/core/{audioRules.js → audio/audioRules.js} +8 -5
  15. package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
  16. package/core/{Events.js → base/Events.js} +3 -3
  17. package/core/{I18n.js → base/I18n.js} +10 -10
  18. package/core/{Random.js → base/Random.js} +5 -4
  19. package/core/{easing.js → base/easing.js} +1 -1
  20. package/core/{errorCodes.js → base/errorCodes.js} +154 -139
  21. package/core/{errorHints.js → base/errorHints.js} +9 -10
  22. package/core/{errors.js → base/errors.js} +9 -9
  23. package/core/{events.generated.js → base/events.generated.js} +2 -0
  24. package/core/{math.js → base/math.js} +22 -4
  25. package/core/{params.js → base/params.js} +3 -4
  26. package/core/base/util.js +32 -0
  27. package/core/{validate.js → base/validate.js} +29 -8
  28. package/core/{Engine.js → engine/Engine.js} +112 -105
  29. package/core/{Loading.js → engine/Loading.js} +4 -2
  30. package/core/{copies.js → engine/copies.js} +4 -4
  31. package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
  32. package/core/{lifecycle.js → engine/lifecycle.js} +16 -16
  33. package/core/{loop.js → engine/loop.js} +80 -52
  34. package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
  35. package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
  36. package/core/{modules.js → engine/modules.js} +20 -17
  37. package/core/engine/page.js +125 -0
  38. package/core/{plugins.js → engine/plugins.js} +68 -103
  39. package/core/{services.js → engine/services.js} +47 -40
  40. package/core/{startup.js → engine/startup.js} +35 -35
  41. package/core/{Input.js → input/Input.js} +41 -27
  42. package/core/{inputContext.js → input/inputContext.js} +14 -5
  43. package/core/{inputPad.js → input/inputPad.js} +1 -1
  44. package/core/{inputPointer.js → input/inputPointer.js} +8 -2
  45. package/core/{inputTouch.js → input/inputTouch.js} +1 -1
  46. package/core/{Budget.js → inspect/Budget.js} +23 -22
  47. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
  48. package/core/{Describe.js → inspect/Describe.js} +33 -30
  49. package/core/{Inspect.js → inspect/Inspect.js} +14 -9
  50. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
  51. package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
  52. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  53. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
  54. package/core/inspect/UrlState.js +182 -0
  55. package/core/{catalog.js → inspect/catalog.js} +18 -5
  56. package/core/{checks.js → inspect/checks.js} +7 -5
  57. package/core/{debugView.js → inspect/debugView.js} +8 -8
  58. package/core/inspect/describeRender.js +148 -0
  59. package/core/{describeText.js → inspect/describeText.js} +17 -12
  60. package/core/inspect/geometryWatch.js +38 -0
  61. package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
  62. package/core/inspect/pictureWriters.js +342 -0
  63. package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
  64. package/core/{Ops.js → ops/Ops.js} +16 -11
  65. package/core/{control.js → ops/control.js} +13 -12
  66. package/core/ops/holds.js +139 -0
  67. package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
  68. package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
  69. package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
  70. package/core/{opsRun.js → ops/opsRun.js} +7 -4
  71. package/core/{owned.js → ops/owned.js} +37 -37
  72. package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
  73. package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
  74. package/core/{stacks.js → ops/stacks.js} +18 -20
  75. package/core/{wrap.js → ops/wrap.js} +8 -6
  76. package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
  77. package/core/{Saves.js → saves/Saves.js} +58 -36
  78. package/core/{saveApply.js → saves/saveApply.js} +13 -9
  79. package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
  80. package/core/{saveValues.js → saves/saveValues.js} +20 -3
  81. package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
  82. package/core/{session.js → saves/session.js} +31 -17
  83. package/core/{Rays.js → scene/Rays.js} +27 -24
  84. package/core/{Views.js → scene/Views.js} +15 -6
  85. package/core/{adaptive.js → scene/adaptive.js} +15 -8
  86. package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
  87. package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
  88. package/core/{gameLights.js → scene/gameLights.js} +24 -7
  89. package/core/{grayMap.js → scene/grayMap.js} +8 -2
  90. package/core/{grid.js → scene/grid.js} +4 -4
  91. package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
  92. package/core/{ground.js → scene/ground.js} +9 -9
  93. package/core/{movement.js → scene/movement.js} +3 -3
  94. package/core/scene/pictureSlots.js +33 -0
  95. package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
  96. package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
  97. package/core/scene/stepPoses.js +55 -0
  98. package/core/{targeting.js → scene/targeting.js} +4 -5
  99. package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
  100. package/core/{thingOps.js → scene/thingOps.js} +4 -3
  101. package/core/{things.js → scene/things.js} +19 -6
  102. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  103. package/core/{tier.js → scene/tier.js} +1 -1
  104. package/core/scene/view.js +44 -0
  105. package/core/{Batching.js → stream/Batching.js} +85 -27
  106. package/core/{Stream.js → stream/Stream.js} +62 -33
  107. package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
  108. package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
  109. package/core/{scatter.js → stream/scatter.js} +2 -2
  110. package/core/{streamSources.js → stream/streamSources.js} +12 -7
  111. package/core/{Commits.js → threads/Commits.js} +6 -5
  112. package/core/{Jobs.js → threads/Jobs.js} +12 -10
  113. package/core/{Threads.js → threads/Threads.js} +16 -16
  114. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  115. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  116. package/core/{Clock.js → time/Clock.js} +17 -10
  117. package/core/{dayTime.js → time/dayTime.js} +5 -1
  118. package/core/{skip.js → time/skip.js} +18 -17
  119. package/core/{time.js → time/time.js} +18 -12
  120. package/core/{uiClock.js → time/uiClock.js} +4 -4
  121. package/docs/AI.md +70 -63
  122. package/docs/API.md +30 -29
  123. package/docs/CODEMAP.md +98 -223
  124. package/docs/COMMANDS.md +80 -69
  125. package/docs/CONVENTIONS.md +87 -41
  126. package/docs/MIGRATING-0.7.md +39 -0
  127. package/docs/MIGRATING-0.8.md +169 -0
  128. package/docs/THREE.md +100 -49
  129. package/docs/api/assets.md +17 -16
  130. package/docs/api/audio.md +8 -7
  131. package/docs/api/budget.md +8 -4
  132. package/docs/api/calendar.md +10 -11
  133. package/docs/api/cameraRig.md +29 -29
  134. package/docs/api/characters.md +26 -19
  135. package/docs/api/clock.md +1 -1
  136. package/docs/api/collision.md +14 -11
  137. package/docs/api/content.md +6 -6
  138. package/docs/api/dialogue.md +3 -3
  139. package/docs/api/engine.md +82 -53
  140. package/docs/api/events.md +5 -3
  141. package/docs/api/flow.md +1 -1
  142. package/docs/api/grids.md +9 -2
  143. package/docs/api/ground.md +4 -5
  144. package/docs/api/hud.md +4 -1
  145. package/docs/api/i18n.md +6 -6
  146. package/docs/api/input.md +10 -9
  147. package/docs/api/interactions.md +6 -4
  148. package/docs/api/inventory.md +10 -11
  149. package/docs/api/jobs.md +5 -5
  150. package/docs/api/level.md +7 -8
  151. package/docs/api/lightPool.md +2 -7
  152. package/docs/api/music.md +3 -3
  153. package/docs/api/nav.md +10 -10
  154. package/docs/api/occlusion.md +5 -0
  155. package/docs/api/openWorld.md +1 -1
  156. package/docs/api/particles.md +8 -5
  157. package/docs/api/photo.md +4 -2
  158. package/docs/api/pickups.md +7 -1
  159. package/docs/api/post.md +24 -5
  160. package/docs/api/quests.md +3 -3
  161. package/docs/api/rays.md +5 -7
  162. package/docs/api/rigid.md +27 -18
  163. package/docs/api/saves.md +8 -7
  164. package/docs/api/settings.md +9 -8
  165. package/docs/api/sky.md +17 -14
  166. package/docs/api/stream.md +7 -7
  167. package/docs/api/swarm.md +34 -0
  168. package/docs/api/terrain.md +17 -12
  169. package/docs/api/terrainDraw.md +12 -0
  170. package/docs/api/timeline.md +2 -2
  171. package/docs/api/tools.md +30 -26
  172. package/docs/api/triggers.md +2 -0
  173. package/docs/api/vars.md +1 -1
  174. package/docs/api/vegetation.md +11 -5
  175. package/docs/api/vegetationDraw.md +10 -0
  176. package/docs/api/water.md +7 -3
  177. package/docs/api/weather.md +11 -6
  178. package/docs/api/weatherDraw.md +10 -0
  179. package/docs/api/world.md +6 -6
  180. package/docs/recipes/01-new-game.md +38 -57
  181. package/docs/recipes/02-npc.md +19 -20
  182. package/docs/recipes/03-items-pickups.md +47 -42
  183. package/docs/recipes/04-quests.md +3 -4
  184. package/docs/recipes/05-props-bake.md +72 -66
  185. package/docs/recipes/06-clock-events.md +30 -21
  186. package/docs/recipes/07-flow-scenes-pause.md +21 -17
  187. package/docs/recipes/08-weather-sky.md +117 -75
  188. package/docs/recipes/09-materials-lights-models.md +171 -0
  189. package/docs/recipes/10-blender-level.md +6 -7
  190. package/docs/recipes/11-vehicles.md +33 -25
  191. package/docs/recipes/12-navmesh.md +9 -8
  192. package/docs/recipes/13-animation.md +50 -22
  193. package/docs/recipes/14-custom-module.md +20 -17
  194. package/docs/recipes/15-perf.md +52 -29
  195. package/docs/recipes/16-dev-bridge.md +47 -57
  196. package/docs/recipes/18-world.md +45 -30
  197. package/docs/recipes/19-shooting-picking.md +11 -7
  198. package/docs/recipes/20-content-actions-save.md +36 -37
  199. package/docs/recipes/21-camera.md +41 -8
  200. package/docs/recipes/22-shop-gold.md +0 -4
  201. package/docs/recipes/23-ops.md +11 -11
  202. package/docs/recipes/26-ui-parts.md +56 -22
  203. package/docs/recipes/27-net.md +0 -2
  204. package/docs/recipes/28-terrain.md +126 -30
  205. package/docs/recipes/29-grid.md +16 -7
  206. package/docs/recipes/30-templates.md +62 -21
  207. package/docs/recipes/31-audio.md +9 -9
  208. package/docs/recipes/32-action-game.md +32 -9
  209. package/docs/recipes/33-stream-sources.md +2 -2
  210. package/docs/recipes/34-environment-lighting.md +164 -52
  211. package/docs/recipes/35-picture-from-reference.md +140 -0
  212. package/docs/recipes/36-ground-plants.md +105 -0
  213. package/docs/recipes/40-scene.md +105 -30
  214. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
  215. package/docs/recipes/44-water-weather-hooks.md +196 -0
  216. package/docs/recipes/45-cascaded-shadows.md +145 -25
  217. package/docs/recipes/46-blender-art-route.md +21 -25
  218. package/docs/recipes/49-game-module-contract.md +5 -5
  219. package/docs/recipes/50-own-renderer.md +3 -3
  220. package/docs/recipes/52-around-the-picture.md +137 -0
  221. package/docs/recipes/53-ground-up-close.md +65 -28
  222. package/docs/recipes/55-mods-time-wrap.md +25 -17
  223. package/docs/recipes/56-webgpu-tsl.md +73 -28
  224. package/docs/recipes/57-control.md +47 -1
  225. package/docs/recipes/58-input.md +3 -0
  226. package/docs/recipes/59-depth-post-effects.md +5 -5
  227. package/docs/recipes/60-judge-the-picture.md +47 -27
  228. package/docs/recipes/61-deploy.md +27 -0
  229. package/docs/recipes/62-picture-code.md +276 -0
  230. package/docs/recipes/63-third-person-start.md +90 -0
  231. package/docs/recipes/64-particles.md +35 -0
  232. package/docs/recipes/65-swarm.md +140 -0
  233. package/examples/action/.threedog/content-index.json +1 -1
  234. package/examples/action/GAMEMAP.md +9 -7
  235. package/examples/action/main.js +5 -4
  236. package/examples/action/models.js +12 -14
  237. package/examples/action/picture/index.js +13 -0
  238. package/examples/action/picture/lights.js +35 -0
  239. package/examples/action/picture/materials.js +8 -0
  240. package/examples/action/picture/palette.js +33 -0
  241. package/examples/perf-island/.threedog/content-index.json +1 -0
  242. package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
  243. package/examples/{sheepisland → perf-island}/assets.js +2 -2
  244. package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
  245. package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
  246. package/examples/{sheepisland → perf-island}/main.js +22 -16
  247. package/examples/{sheepisland/style → perf-island}/models.js +13 -24
  248. package/examples/{sheepisland → perf-island}/params.js +1 -1
  249. package/examples/perf-island/picture/index.js +20 -0
  250. package/examples/perf-island/picture/lights.js +34 -0
  251. package/examples/perf-island/picture/materials.js +61 -0
  252. package/examples/perf-island/picture/palette.js +60 -0
  253. package/examples/perf-island/picture/sky.js +20 -0
  254. package/examples/{sheepisland → perf-island}/views.js +1 -1
  255. package/examples/plain-picture/.threedog/content-index.json +1 -0
  256. package/examples/plain-picture/GAMEMAP.md +91 -0
  257. package/examples/plain-picture/main.js +48 -0
  258. package/examples/plain-picture/picture/index.js +21 -0
  259. package/examples/plain-picture/picture/lights.js +54 -0
  260. package/examples/plain-picture/picture/materials.js +24 -0
  261. package/examples/plain-picture/picture/palette.js +16 -0
  262. package/examples/plain-picture/picture/sky.js +37 -0
  263. package/examples/pullable.json +31 -9
  264. package/examples/rc2d/GAMEMAP.md +10 -4
  265. package/examples/rc2d/README.md +11 -6
  266. package/examples/rc2d/main.js +26 -36
  267. package/examples/rc2d/picture/index.js +18 -0
  268. package/examples/rc2d/picture/lights.js +11 -0
  269. package/examples/rc2d/picture/materials.js +18 -0
  270. package/examples/rc2d/picture/palette.js +15 -0
  271. package/examples/rc2d/picture/post.js +11 -0
  272. package/examples/rc2d/rc2d.js +18 -28
  273. package/examples/styletest/.threedog/content-index.json +1 -1
  274. package/examples/styletest/GAMEMAP.md +15 -10
  275. package/examples/styletest/main.js +20 -30
  276. package/examples/styletest/models.js +29 -29
  277. package/examples/styletest/params.js +1 -4
  278. package/examples/styletest/picture/env.js +38 -0
  279. package/examples/styletest/picture/index.js +16 -0
  280. package/examples/styletest/picture/lights.js +9 -0
  281. package/examples/styletest/picture/materials.js +28 -0
  282. package/examples/styletest/picture/palette.js +22 -0
  283. package/examples/techniques/contact-shadows/README.md +22 -23
  284. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  285. package/examples/techniques/contact-shadows/main.js +20 -18
  286. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  287. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  288. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  289. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  290. package/examples/techniques/day-night-grade/README.md +13 -16
  291. package/examples/techniques/day-night-grade/main.js +15 -25
  292. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  293. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  294. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  295. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  296. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  297. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  298. package/examples/techniques/interior-light/README.md +16 -13
  299. package/examples/techniques/interior-light/interiorLight.js +19 -17
  300. package/examples/techniques/interior-light/main.js +31 -68
  301. package/examples/techniques/interior-light/picture/index.js +24 -0
  302. package/examples/techniques/interior-light/picture/lights.js +52 -0
  303. package/examples/techniques/interior-light/picture/materials.js +13 -0
  304. package/examples/techniques/interior-light/picture/palette.js +32 -0
  305. package/examples/techniques/interior-light/picture/sky.js +40 -0
  306. package/examples/techniques/modular-building/README.md +8 -6
  307. package/examples/techniques/modular-building/kit.js +2 -2
  308. package/examples/techniques/modular-building/main.js +9 -17
  309. package/examples/techniques/modular-building/picture/index.js +17 -0
  310. package/examples/techniques/modular-building/picture/lights.js +26 -0
  311. package/examples/techniques/modular-building/picture/materials.js +13 -0
  312. package/examples/techniques/modular-building/picture/palette.js +23 -0
  313. package/examples/techniques/night-lights/README.md +15 -14
  314. package/examples/techniques/night-lights/main.js +20 -43
  315. package/examples/techniques/night-lights/nightLights.js +25 -21
  316. package/examples/techniques/night-lights/picture/index.js +18 -0
  317. package/examples/techniques/night-lights/picture/lights.js +44 -0
  318. package/examples/techniques/night-lights/picture/materials.js +15 -0
  319. package/examples/techniques/night-lights/picture/palette.js +34 -0
  320. package/examples/techniques/night-lights/picture/post.js +9 -0
  321. package/examples/techniques/night-lights/picture/sky.js +36 -0
  322. package/examples/techniques/outlines-and-rim/README.md +2 -2
  323. package/examples/techniques/outlines-and-rim/main.js +15 -38
  324. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  325. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  326. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  327. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  328. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  329. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  330. package/examples/techniques/procedural-animation/README.md +6 -4
  331. package/examples/techniques/procedural-animation/main.js +9 -7
  332. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  333. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  334. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  335. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  336. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  337. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  338. package/examples/techniques/procedural-surface/README.md +2 -0
  339. package/examples/techniques/procedural-surface/main.js +17 -55
  340. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  341. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  342. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  343. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  344. package/examples/techniques/stylized-shading/README.md +13 -14
  345. package/examples/techniques/stylized-shading/main.js +11 -42
  346. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  347. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  348. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  349. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  350. package/examples/techniques/stylized-shading/shading.js +2 -2
  351. package/examples/techniques/sun-and-key-light/README.md +20 -22
  352. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  353. package/examples/techniques/sun-and-key-light/main.js +19 -63
  354. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  355. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  356. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  357. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  358. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  359. package/examples/techniques/three-looks/README.md +21 -0
  360. package/examples/techniques/three-looks/main.js +58 -0
  361. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  362. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  363. package/examples/techniques/three-looks/picture/comic.js +27 -0
  364. package/examples/techniques/three-looks/picture/index.js +14 -0
  365. package/examples/techniques/three-looks/picture/sun.js +23 -0
  366. package/examples/techniques/wet-road/README.md +7 -4
  367. package/examples/techniques/wet-road/main.js +18 -38
  368. package/examples/techniques/wet-road/picture/index.js +17 -0
  369. package/examples/techniques/wet-road/picture/lights.js +57 -0
  370. package/examples/techniques/wet-road/picture/materials.js +16 -0
  371. package/examples/techniques/wet-road/picture/palette.js +24 -0
  372. package/examples/techniques/wet-road/picture/sky.js +46 -0
  373. package/examples/webgpu-tsl/GAMEMAP.md +10 -4
  374. package/examples/webgpu-tsl/README.md +13 -10
  375. package/examples/webgpu-tsl/main.js +30 -7
  376. package/examples/webgpu-tsl/picture/index.js +18 -0
  377. package/examples/webgpu-tsl/picture/lights.js +25 -0
  378. package/examples/webgpu-tsl/picture/materials.js +36 -0
  379. package/examples/webgpu-tsl/picture/palette.js +23 -0
  380. package/examples/webgpu-tsl/picture/post.js +16 -0
  381. package/examples/webgpu-tsl/picture/sky.js +30 -0
  382. package/examples/world/.threedog/content-index.json +1 -1
  383. package/examples/world/GAMEMAP.md +16 -12
  384. package/examples/world/art/humanoid.js +9 -13
  385. package/examples/world/art/index.js +2 -2
  386. package/examples/world/art/models.js +3 -4
  387. package/examples/world/art/shapes.js +2 -2
  388. package/examples/world/assets.js +2 -2
  389. package/examples/world/content/audio.js +1 -1
  390. package/examples/world/content/items.js +1 -1
  391. package/examples/world/content/props.js +1 -1
  392. package/examples/world/content/templates.js +1 -1
  393. package/examples/world/content/vegetation.js +1 -1
  394. package/examples/world/main.js +10 -10
  395. package/examples/world/models.js +17 -7
  396. package/examples/world/picture/index.js +20 -0
  397. package/examples/world/picture/lights.js +41 -0
  398. package/examples/world/picture/materials.js +34 -0
  399. package/examples/world/picture/palette.js +74 -0
  400. package/examples/world/picture/post.js +9 -0
  401. package/examples/world/picture/sky.js +39 -0
  402. package/index.d.ts +14 -22
  403. package/index.js +36 -36
  404. package/llms.txt +19 -21
  405. package/modules/ambience/Ambience.js +12 -9
  406. package/modules/calendar/Calendar.js +20 -20
  407. package/modules/calendar/index.js +14 -13
  408. package/modules/calendar/schedule.js +11 -6
  409. package/modules/calendar/seasons.js +7 -7
  410. package/modules/camera/FirstPersonCamera.js +2 -2
  411. package/modules/camera/FixedCamera.js +14 -15
  412. package/modules/camera/FollowCamera.js +4 -4
  413. package/modules/camera/RtsCamera.js +11 -11
  414. package/modules/camera/common.js +51 -25
  415. package/modules/camera/contract.js +1 -0
  416. package/modules/camera/projection.js +2 -2
  417. package/modules/characters/Character.js +47 -39
  418. package/modules/characters/NPC.js +30 -22
  419. package/modules/characters/assetModel.js +18 -13
  420. package/modules/characters/astar.js +7 -5
  421. package/modules/characters/behaviors.js +4 -5
  422. package/modules/characters/contract.js +2 -2
  423. package/modules/characters/index.js +172 -193
  424. package/modules/characters/moveHelpers.js +14 -3
  425. package/modules/characters/movers/common.js +22 -15
  426. package/modules/characters/movers/manual.js +4 -1
  427. package/modules/characters/movers/rapier.js +7 -6
  428. package/modules/characters/movers/simple.js +3 -3
  429. package/modules/characters/movers/support.js +32 -18
  430. package/modules/characters/npcAvoid.js +4 -4
  431. package/modules/characters/npcSim.js +28 -18
  432. package/modules/characters/npcView.js +6 -5
  433. package/modules/characters/pathAsync.js +12 -10
  434. package/modules/characters/pathWorker.js +1 -1
  435. package/modules/characters/player.js +108 -0
  436. package/modules/characters/playerStrings.js +2 -2
  437. package/modules/characters/proceduralRig.js +19 -5
  438. package/modules/characters/useModel.js +5 -5
  439. package/modules/characters/walkTo.js +11 -17
  440. package/modules/collision/Collision.js +30 -22
  441. package/modules/collision/contract.js +15 -0
  442. package/modules/content/explain.js +1 -2
  443. package/modules/content/fields.js +24 -3
  444. package/modules/content/ids.js +2 -2
  445. package/modules/content/index.js +68 -98
  446. package/modules/content/loader.js +14 -17
  447. package/modules/content/markers.js +25 -0
  448. package/modules/content/models.js +66 -18
  449. package/modules/content/packs.js +3 -3
  450. package/modules/content/parts.js +2 -2
  451. package/modules/content/places.js +35 -0
  452. package/modules/content/props.js +19 -14
  453. package/modules/content/rules.js +34 -22
  454. package/modules/content/stages.js +7 -7
  455. package/modules/content/templates.js +24 -22
  456. package/modules/content/words.js +34 -0
  457. package/modules/debug/DebugPanel.js +10 -43
  458. package/modules/flow/contract.js +1 -1
  459. package/modules/flow/index.js +11 -7
  460. package/modules/gameplay/Container.js +12 -11
  461. package/modules/gameplay/Containers.js +14 -5
  462. package/modules/gameplay/Dialogue.js +13 -11
  463. package/modules/gameplay/Interactions.js +115 -27
  464. package/modules/gameplay/Inventory.js +11 -12
  465. package/modules/gameplay/Quests.js +16 -9
  466. package/modules/gameplay/boxOps.js +1 -1
  467. package/modules/gameplay/dialogueBox.js +1 -1
  468. package/modules/gameplay/dialogueBubbles.js +4 -5
  469. package/modules/gameplay/interactionPrompt.js +1 -1
  470. package/modules/gameplay/interactions.contract.js +1 -1
  471. package/modules/gameplay/inventoryOps.js +2 -3
  472. package/modules/gameplay/pickups.js +81 -44
  473. package/modules/gameplay/questLog.js +2 -2
  474. package/modules/gameplay/questSave.js +3 -3
  475. package/modules/grid/Grid.js +1 -1
  476. package/modules/grid/Layer.js +16 -3
  477. package/modules/grid/index.js +47 -19
  478. package/modules/grid/preview.js +29 -20
  479. package/modules/grid/tiles.js +19 -23
  480. package/modules/hlod/index.js +38 -55
  481. package/modules/hud/index.js +27 -8
  482. package/modules/hud/parts.js +13 -11
  483. package/modules/level/contract.js +16 -0
  484. package/modules/level/heightfield.js +12 -10
  485. package/modules/level/index.js +48 -152
  486. package/modules/level/load.js +79 -0
  487. package/modules/level/meshes.js +65 -0
  488. package/modules/level/nodes.js +6 -7
  489. package/modules/lights/index.js +34 -183
  490. package/modules/lights/slots.js +93 -0
  491. package/modules/lights/sources.js +88 -0
  492. package/modules/music/Music.js +31 -27
  493. package/modules/music/rules.js +1 -1
  494. package/modules/nav/contract.js +14 -0
  495. package/modules/nav/index.js +11 -10
  496. package/modules/net/Client.js +7 -7
  497. package/modules/net/Host.js +7 -7
  498. package/modules/net/Net.js +1 -1
  499. package/modules/net/index.js +5 -4
  500. package/modules/net/sync.js +2 -2
  501. package/modules/net/transports.js +2 -2
  502. package/modules/particles/Particles.js +49 -25
  503. package/modules/particles/effect.js +27 -10
  504. package/modules/particles/shaders.js +2 -1
  505. package/modules/photo/Photo.js +26 -27
  506. package/modules/rigid/RigidBodies.js +66 -43
  507. package/modules/rigid/Vehicles.js +2 -3
  508. package/modules/rigid/ragdoll.js +287 -0
  509. package/modules/rigid/ragdollBones.js +159 -0
  510. package/modules/rigid/sync.js +6 -6
  511. package/modules/settings/Settings.js +114 -45
  512. package/modules/settings/apply.js +10 -10
  513. package/modules/settings/sections.js +16 -14
  514. package/modules/settings/strings.js +1 -1
  515. package/modules/settings/view.js +3 -3
  516. package/modules/sky/Sky.js +125 -103
  517. package/modules/sky/clouds.js +22 -23
  518. package/modules/sky/dome.js +113 -0
  519. package/modules/sky/domeLayers.js +13 -13
  520. package/modules/sky/environment.js +47 -171
  521. package/modules/sky/fog.js +5 -180
  522. package/modules/sky/frame.js +42 -97
  523. package/modules/sky/season.js +9 -3
  524. package/modules/sky/shader.js +49 -44
  525. package/modules/sky/skyModule.js +25 -35
  526. package/modules/sky/tint.js +9 -11
  527. package/modules/swarm/Swarm.js +346 -0
  528. package/modules/swarm/draw.js +68 -0
  529. package/modules/swarm/grid.js +63 -0
  530. package/modules/terrain/ChunkManager.js +97 -62
  531. package/modules/terrain/chunkQueries.js +7 -24
  532. package/modules/terrain/chunkWorker.js +1 -1
  533. package/modules/terrain/draw.js +157 -0
  534. package/modules/terrain/index.js +60 -88
  535. package/modules/terrain/terrainColorMap.js +6 -3
  536. package/modules/terrain/terrainDefaults.js +4 -3
  537. package/modules/terrain/terrainEdit.js +32 -27
  538. package/modules/terrain/terrainGen.js +19 -14
  539. package/modules/terrain/terrainIsland.js +2 -2
  540. package/modules/terrain/terrainMesh.js +7 -6
  541. package/modules/terrain/terrainShape.js +8 -10
  542. package/modules/terrain/terrainShapeMain.js +3 -3
  543. package/modules/timeline/Timeline.js +27 -19
  544. package/modules/timeline/Tween.js +6 -6
  545. package/modules/timeline/shots.js +5 -7
  546. package/modules/triggers/index.js +19 -15
  547. package/modules/vegetation/Vegetation.js +87 -39
  548. package/modules/vegetation/densityMap.js +4 -7
  549. package/modules/vegetation/draw.js +196 -0
  550. package/modules/vegetation/groundChunks.js +11 -31
  551. package/modules/vegetation/index.js +18 -16
  552. package/modules/vegetation/modelGeometry.js +3 -6
  553. package/modules/vegetation/nearFade.js +1 -1
  554. package/modules/water/Water.js +140 -93
  555. package/modules/water/surface.js +56 -56
  556. package/modules/weather/Weather.js +84 -38
  557. package/modules/weather/particles.js +18 -10
  558. package/modules/weather/shaders.js +1 -1
  559. package/modules/weather/weatherDraw.js +145 -0
  560. package/modules/world/World.js +10 -10
  561. package/modules/world/explain.js +1 -1
  562. package/modules/world/index.js +18 -12
  563. package/modules/world/persist.js +73 -25
  564. package/modules/world/pos.js +4 -4
  565. package/modules/world/records.js +28 -8
  566. package/modules/world/sim.js +4 -4
  567. package/modules/world/state.js +12 -5
  568. package/modules/world/thingSource.js +4 -2
  569. package/modules/world/views.js +12 -10
  570. package/package.json +44 -8
  571. package/presets.js +3 -5
  572. package/render/PostFX.js +233 -63
  573. package/render/backend.js +72 -32
  574. package/render/cascades.js +200 -0
  575. package/render/cascades.tsl.js +93 -0
  576. package/render/daylight.js +56 -0
  577. package/render/detail.js +13 -12
  578. package/render/effects.js +60 -42
  579. package/render/fuse.js +3 -3
  580. package/render/fx/cel.tsl.js +42 -0
  581. package/render/fx/cloudShadow.tsl.js +3 -3
  582. package/render/fx/detail.tsl.js +1 -1
  583. package/render/fx/index.js +10 -13
  584. package/render/fx/library.tsl.js +11 -0
  585. package/render/fx/lighting.tsl.js +2 -1
  586. package/render/fx/nodeErrors.tsl.js +2 -2
  587. package/render/fx/objectOrigin.tsl.js +1 -2
  588. package/render/fx/patchNodes.tsl.js +6 -16
  589. package/render/fx/postWebGPU.tsl.js +55 -28
  590. package/render/fx/sky.tsl.js +34 -109
  591. package/render/fx/uniforms.tsl.js +4 -4
  592. package/render/fx/water.tsl.js +1 -1
  593. package/render/fx/wind.tsl.js +1 -1
  594. package/render/fxNumbers.js +3 -0
  595. package/render/layers.js +14 -0
  596. package/render/lighting.js +11 -8
  597. package/render/lightmap.js +142 -0
  598. package/render/lights.js +26 -204
  599. package/render/lit.js +24 -0
  600. package/render/materials.js +47 -162
  601. package/render/mergeCommon.js +22 -0
  602. package/render/modeling.js +2 -2
  603. package/render/neutral.js +23 -0
  604. package/render/occlusion.js +200 -0
  605. package/render/ownFrame.js +5 -5
  606. package/render/patches.js +46 -41
  607. package/render/postWebGL.js +19 -9
  608. package/render/probes.js +182 -128
  609. package/render/recordSweep.js +117 -0
  610. package/render/shaderErrors.js +10 -9
  611. package/render/shadowCache.tsl.js +107 -0
  612. package/render/shadowTypes.js +9 -0
  613. package/render/shadows.js +451 -0
  614. package/render/slots.js +11 -11
  615. package/render/terms.js +63 -113
  616. package/render/uniformDecl.js +2 -2
  617. package/types/core.d.ts +489 -405
  618. package/types/gameplay.d.ts +225 -114
  619. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
  620. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  621. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  622. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
  623. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  624. package/types/generated/core/engine/page.d.ts +24 -0
  625. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
  626. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  627. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
  628. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
  629. package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
  630. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
  631. package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
  632. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  633. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
  634. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  635. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
  636. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  637. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  638. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  639. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  640. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  641. package/types/generated/modules/grid/Layer.d.ts +9 -1
  642. package/types/generated/modules/grid/index.d.ts +32 -8
  643. package/types/generated/modules/music/Music.d.ts +7 -5
  644. package/types/generated/modules/particles/Particles.d.ts +14 -7
  645. package/types/generated/modules/sky/Sky.d.ts +101 -23
  646. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  647. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  648. package/types/generated/modules/timeline/Timeline.d.ts +2 -1
  649. package/types/generated/modules/water/Water.d.ts +51 -3
  650. package/types/generated/modules/weather/Weather.d.ts +44 -10
  651. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  652. package/types/generated/modules/world/World.d.ts +7 -5
  653. package/types/generated/render/PostFX.d.ts +69 -20
  654. package/types/generated/render/lighting.d.ts +29 -0
  655. package/types/generated/render/materials.d.ts +20 -44
  656. package/types/generated/render/occlusion.d.ts +22 -0
  657. package/types/generated/render/patches.d.ts +1 -0
  658. package/types/generated/ui/Focus.d.ts +1 -0
  659. package/types/generated/ui/UI.d.ts +1 -0
  660. package/types/nav.d.ts +11 -11
  661. package/types/physics.d.ts +104 -73
  662. package/types/tsl.d.ts +45 -4
  663. package/types/world.d.ts +372 -86
  664. package/ui/Focus.js +21 -10
  665. package/ui/LoadingScreen.js +2 -2
  666. package/ui/Parts.js +12 -7
  667. package/ui/UI.js +17 -17
  668. package/ui/cursor.js +1 -1
  669. package/ui/defaults.js +3 -2
  670. package/ui/theme.js +36 -28
  671. package/ui/touchPart.js +1 -1
  672. package/core/UrlState.js +0 -110
  673. package/core/assetEntry.js +0 -106
  674. package/core/describeRender.js +0 -71
  675. package/core/holds.js +0 -134
  676. package/core/look/coreParts.js +0 -219
  677. package/core/look/part.js +0 -253
  678. package/core/look/points.js +0 -255
  679. package/core/look/report.js +0 -96
  680. package/core/look/shadowPart.js +0 -63
  681. package/core/look/state.js +0 -45
  682. package/core/look/write.js +0 -70
  683. package/core/page.js +0 -79
  684. package/core/shadowTypes.js +0 -16
  685. package/core/styleParts.js +0 -114
  686. package/core/util.js +0 -17
  687. package/docs/MIGRATING-0.3.md +0 -248
  688. package/docs/MIGRATING-0.4.md +0 -228
  689. package/docs/MIGRATING-0.5.md +0 -68
  690. package/docs/PERF.md +0 -245
  691. package/docs/api/style.md +0 -136
  692. package/docs/api/terrainLook.md +0 -10
  693. package/docs/api/vegetationLook.md +0 -10
  694. package/docs/api/weatherLook.md +0 -10
  695. package/docs/recipes/09-style.md +0 -218
  696. package/docs/recipes/35-style-from-reference.md +0 -153
  697. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  698. package/docs/recipes/37-terrain-look-hooks.md +0 -119
  699. package/docs/recipes/38-environment-look-hooks.md +0 -99
  700. package/docs/recipes/41-thing-registry.md +0 -97
  701. package/docs/recipes/42-terrain-shape.md +0 -64
  702. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  703. package/docs/recipes/47-island-snow-backdrop.md +0 -45
  704. package/docs/recipes/48-make-material.md +0 -75
  705. package/docs/recipes/52-look.md +0 -282
  706. package/docs/recipes/54-three-idioms.md +0 -88
  707. package/examples/action/look.js +0 -5
  708. package/examples/sheepisland/.threedog/content-index.json +0 -1
  709. package/examples/sheepisland/style/index.js +0 -79
  710. package/examples/styletest/look.js +0 -11
  711. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  712. package/examples/webgpu-tsl/tslScene.js +0 -75
  713. package/examples/world/style/index.js +0 -61
  714. package/examples/world/style/plugins/10-bloom.js +0 -5
  715. package/modules/sky/cascades.js +0 -186
  716. package/modules/sky/cascades.tsl.js +0 -82
  717. package/modules/sky/look.js +0 -54
  718. package/modules/sky/lookFog.js +0 -76
  719. package/modules/sky/lookShadow.js +0 -62
  720. package/modules/sky/lookSky.js +0 -169
  721. package/modules/sky/shadow.js +0 -98
  722. package/modules/terrain/look.js +0 -83
  723. package/modules/terrain/lookGround.js +0 -66
  724. package/modules/vegetation/look.js +0 -119
  725. package/modules/vegetation/lookWind.js +0 -98
  726. package/modules/water/look.js +0 -91
  727. package/modules/water/surfaceDefaults.js +0 -3
  728. package/modules/weather/look.js +0 -74
  729. package/modules/weather/weatherLook.js +0 -135
  730. package/render/lookGlow.js +0 -139
  731. package/render/lookSurface.js +0 -224
  732. package/render/postLook.js +0 -164
  733. package/render/surface.js +0 -105
  734. package/types/generated/core/page.d.ts +0 -18
  735. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  736. package/types/style.d.ts +0 -671
  737. /package/core/{Vars.js → base/Vars.js} +0 -0
  738. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  739. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  740. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  741. /package/core/{actor.js → ops/actor.js} +0 -0
  742. /package/core/{opsFail.js → ops/opsFail.js} +0 -0
  743. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  744. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  745. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  746. /package/core/{cells.js → stream/cells.js} +0 -0
  747. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  748. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  749. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  750. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
@@ -2,24 +2,17 @@
2
2
  // Technique example: interior light (page /interior-light.html, README.md next to this file). A neutral gray room (8 x 6 m, 3 m high) with a
3
3
  // window in the west wall and a door in the south wall. One skill: lighting a room from outside (sun through the opening, sky light through the
4
4
  // window), filling the shadowed side with bounce, the exposure change between outside and inside, and lamps at night.
5
- // (time and view are the engine's own URL scenario keys, see core/UrlState.js: page params use other names)
5
+ // (time and view are the engine's own URL scenario keys, see core/inspect/UrlState.js: page params use other names)
6
6
  // URL: ?night=1 ?cam=inside|doorway|outside ?fill=probes|light|none ?area=0 (no window area light) ?leak=1 (keep outdoor ambient indoors)
7
- // Test page for tests/specs/techniques-light.mjs: window.interiorTest = { THREE, ready, points, zone }.
7
+ // Test page for tests/specs/techniques-light.mjs: window.interiorTest = { THREE, ready, points, picture }. Shapes only here; the whole picture is picture/.
8
8
  import { createEngine, sky, fixedCamera, THREE } from 'threedog';
9
- import { exposureZones, windowLight } from './interiorLight.js';
9
+ import { createPicture } from './picture/index.js';
10
10
 
11
11
  // ---- parameters: change these ----------------------------------------------------------------------------------------------------------
12
12
  const ROOM = { min: [-4, 0, -3], max: [4, 3, 3], wall: 0.2 };
13
13
  const WINDOW = { z: [-1.1, 1.1], y: [0.8, 2.4] }; // opening in the west wall (x = -4)
14
14
  const DOOR = { x: [1.4, 2.5], y: [0, 2.2] }; // opening in the south wall (z = +3)
15
- const SUN = { elevation: 32, azimuth: -90 + 12, intensity: 3.2, color: '#fff0dc' }; // azimuth: compass degrees from north (-Z), -90 = from the west
16
- // outdoor ambient (hemisphere + room environment) is not blocked by walls: indoors it is turned down and the fill comes from bounce instead
17
- const AMBIENT = { outside: { hemi: 1.0, env: 0.3 }, inside: { hemi: 0.06, env: 0.04 } };
18
- const WINDOW_LIGHT = { color: '#cfe0ff', intensity: 2.2 }; // RectAreaLight: the sky seen through the window (nits-like units, Standard / Physical only)
19
- const BOUNCE_LIGHT = { color: '#ffe2c0', intensity: 1.2, distance: 7 }; // ?fill=light: one unshadowed point light standing in for the sun patch's bounce
20
- // exposure per zone, eased over EASE seconds when the camera crosses the doorway (an eye adapting)
21
- const EXPOSURE = { day: { outside: 1, inside: 1.9 }, night: { outside: 1.6, inside: 1 }, ease: 1.2 };
22
- const LAMPS = [{ at: [2.6, 1.55, -2.2], intensity: 5, color: '#ffc58a', shadow: true }, { at: [-2.8, 1.0, 2.2], intensity: 2.5, color: '#ffb874', shadow: false }];
15
+ const LAMPS = /** @type {{ at: number[], kind: 'main' | 'side' }[]} */ ([{ at: [2.6, 1.55, -2.2], kind: 'main' }, { at: [-2.8, 1.0, 2.2], kind: 'side' }]);
23
16
  const VIEWS = {
24
17
  inside: { position: [3.4, 1.65, 2.4], lookAt: [-3, 0.8, -0.6] },
25
18
  doorway: { position: [1.95, 1.65, 5.2], lookAt: [0.6, 1.1, -3] },
@@ -31,40 +24,32 @@ const url = new URLSearchParams(location.search);
31
24
  const night = url.get('night') === '1', fill = url.get('fill') ?? 'probes', view = /** @type {keyof typeof VIEWS} */ (url.get('cam') ?? 'inside');
32
25
  if (!VIEWS[view]) throw new Error(`?cam=${view}: use one of ${Object.keys(VIEWS).join(', ')}`);
33
26
 
34
- const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), ui: { loading: false }, saveKey: 'threedog-interior' });
27
+ const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-interior' });
35
28
  engine.use(sky({ time: night ? '22:30' : '15:00' }));
36
29
  engine.use(fixedCamera({ shots: VIEWS, start: view }));
37
30
 
38
- // ---- the sun through the window: aimed by hand, shadow box fitted to the room (8 m wide: 0.6 cm texels at 2048) ----
39
- const sun = engine.lights.sun;
40
- if (!night) {
41
- engine.look.lights.manual('sun.direction');
42
- const az = THREE.MathUtils.degToRad(SUN.azimuth), el = THREE.MathUtils.degToRad(SUN.elevation);
43
- const dir = new THREE.Vector3(Math.sin(az) * Math.cos(el), Math.sin(el), -Math.cos(az) * Math.cos(el));
44
- sun.target.position.set(0, 0, 0);
45
- sun.position.copy(dir).multiplyScalar(160);
46
- engine.look.lights.set({ sun: { intensity: SUN.intensity, color: SUN.color } }, { owner: 'technique' });
47
- }
48
- // thin walls need a small normal bias, or light leaks along the wall's inner edge; the bias is ~1 cm (shadow depth 0-1 x the camera's depth range)
49
- engine.look.shadow.set({ follow: false, extent: 9, normalBias: 0.01, bias: -0.01 / (sun.shadow.camera.far - sun.shadow.camera.near), type: 'pcf', radius: 2 }, { owner: 'technique' });
31
+ const [x0, , z0] = ROOM.min, [x1, h, z1] = ROOM.max, t = ROOM.wall, windowY = (WINDOW.y[0] + WINDOW.y[1]) / 2;
32
+ // the camera inside this box gets indoor ambient and indoor exposure, eased
33
+ const inside = (/** @type {THREE.Vector3} */ p) => p.x > x0 && p.x < x1 && p.z > z0 && p.z < z1 + 0.5 && p.y < h;
34
+ const picture = createPicture(engine, { night, fill, isInside: inside, leak: url.get('leak') === '1',
35
+ // the window as a light: a RectAreaLight in the opening, facing in
36
+ windowOpening: url.get('area') === '0' ? null : { position: [x0 - 0.02, windowY, 0], lookAt: [0, windowY, 0], width: WINDOW.z[1] - WINDOW.z[0], height: WINDOW.y[1] - WINDOW.y[0] } });
37
+ const { mat } = picture;
50
38
 
51
- // ---- the neutral gray room (plain three.js) ----
52
- const mat = (/** @type {number} */ c, roughness = 0.9) => new THREE.MeshStandardMaterial({ color: c, roughness });
53
- const wallMat = mat(0xb5b5b5), floorMat = mat(0x8f8f8f);
54
- const box = (/** @type {number[]} */ min, /** @type {number[]} */ max, m = wallMat) => {
39
+ // ---- the neutral gray room ----
40
+ const box = (/** @type {number[]} */ min, /** @type {number[]} */ max, m = mat.wall) => {
55
41
  const mesh = new THREE.Mesh(new THREE.BoxGeometry(max[0] - min[0], max[1] - min[1], max[2] - min[2]), m);
56
42
  mesh.position.set((min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2);
57
43
  mesh.castShadow = mesh.receiveShadow = true;
58
44
  engine.scene.add(mesh);
59
45
  return mesh;
60
46
  };
61
- const [x0, , z0] = ROOM.min, [x1, h, z1] = ROOM.max, t = ROOM.wall;
62
- const ground = new THREE.Mesh(new THREE.PlaneGeometry(120, 120), mat(0x8a8a8a, 0.95));
47
+ const ground = new THREE.Mesh(new THREE.PlaneGeometry(120, 120), mat.ground);
63
48
  ground.rotation.x = -Math.PI / 2;
64
49
  ground.position.y = -0.01;
65
50
  ground.receiveShadow = true;
66
51
  engine.scene.add(ground);
67
- box([x0, -0.01, z0], [x1, 0.02, z1], floorMat); // the floor
52
+ box([x0, -0.01, z0], [x1, 0.02, z1], mat.floor); // the floor
68
53
  box([x0 - t, h, z0 - t], [x1 + t, h + t, z1 + t]); // the ceiling
69
54
  box([x0 - t, 0, z0 - t], [x1 + t, h, z0]); // north wall
70
55
  box([x1, 0, z0], [x1 + t, h, z1]); // east wall
@@ -74,51 +59,29 @@ box([x0 - t, 0, WINDOW.z[0]], [x0, WINDOW.y[0], WINDOW.z[1]]); box([x0 - t, WIND
74
59
  // south wall with the door
75
60
  box([x0 - t, 0, z1], [DOOR.x[0], h, z1 + t]); box([DOOR.x[1], 0, z1], [x1 + t, h, z1 + t]); box([DOOR.x[0], DOOR.y[1], z1], [DOOR.x[1], h, z1 + t]);
76
61
  // furniture-sized blocks: a table, a cabinet against the east wall, a sofa-sized block in the corner
77
- box([-1.2, 0, -0.5], [0.4, 0.75, 0.5], mat(0xa0a0a0)); box([3.2, 0, -1.4], [3.95, 1.9, 0.6], mat(0x9c9c9c)); box([-3.9, 0, 1.4], [-2.2, 0.8, 2.9], mat(0xa6a6a6));
78
-
79
- // ---- the window as a light: a RectAreaLight in the opening, facing in. Soft and shaped like the window, but it casts no shadow ----
80
- if (url.get('area') !== '0' && !night) {
81
- windowLight(engine, { position: [x0 - 0.02, (WINDOW.y[0] + WINDOW.y[1]) / 2, 0], lookAt: [0, (WINDOW.y[0] + WINDOW.y[1]) / 2, 0],
82
- width: WINDOW.z[1] - WINDOW.z[0], height: WINDOW.y[1] - WINDOW.y[0], ...WINDOW_LIGHT });
83
- }
62
+ box([-1.2, 0, -0.5], [0.4, 0.75, 0.5], mat.table); box([3.2, 0, -1.4], [3.95, 1.9, 0.6], mat.cabinet); box([-3.9, 0, 1.4], [-2.2, 0.8, 2.9], mat.sofa);
84
63
 
85
- // ---- night: lamps. The bulb hides inside a shade; the light lands on surfaces, the visible emitter stays dim (no glare without bloom) ----
64
+ // ---- night: lamps. The bulb hides inside a shade; the light lands on surfaces, the visible emitter stays dim ----
86
65
  if (night) {
87
- for (const l of LAMPS) {
88
- const p = new THREE.PointLight(l.color, l.intensity, 0, 2); // physical falloff (decay 2); intensity in candela
89
- p.position.set(l.at[0], l.at[1], l.at[2]);
90
- p.castShadow = l.shadow;
91
- if (l.shadow) { p.shadow.mapSize.set(512, 512); p.shadow.bias = -0.002; p.shadow.radius = 4; }
92
- const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.26, 0.28, 24, 1, true),
93
- new THREE.MeshStandardMaterial({ color: 0xe8dccb, emissive: l.color, emissiveIntensity: 0.35, side: THREE.DoubleSide, roughness: 1 }));
94
- shade.position.copy(p.position);
95
- const stand = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, l.at[1] - 0.14, 8), mat(0x777777));
96
- stand.position.set(l.at[0], (l.at[1] - 0.14) / 2, l.at[2]);
97
- engine.scene.add(p, shade, stand);
66
+ for (const { at, kind } of LAMPS) {
67
+ picture.addLamp(kind, at);
68
+ const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.26, 0.28, 24, 1, true), mat.shade[kind]);
69
+ shade.position.set(at[0], at[1], at[2]);
70
+ const stand = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, at[1] - 0.14, 8), mat.stand);
71
+ stand.position.set(at[0], (at[1] - 0.14) / 2, at[2]);
72
+ engine.scene.add(shade, stand);
98
73
  }
99
74
  }
100
75
 
101
- // ---- zones: the camera inside the room gets indoor ambient and indoor exposure, eased. Presentation, so it runs per frame ----
102
- const inside = (/** @type {THREE.Vector3} */ p) => p.x > x0 && p.x < x1 && p.z > z0 && p.z < z1 + 0.5 && p.y < h;
103
- const leak = url.get('leak') === '1';
104
- const { zone, apply: applyZone } = exposureZones(engine, { isInside: inside, exposure: EXPOSURE[night ? 'night' : 'day'], ease: EXPOSURE.ease,
105
- ambient: leak ? { inside: AMBIENT.outside, outside: AMBIENT.outside } : AMBIENT });
106
-
107
- // ---- fill: bounce baked into light probes, one cheap point light, or nothing ----
76
+ // ---- fill: bounce baked into light probes; ?fill=light is one cheap point light in picture/lights.js ----
108
77
  async function setupFill() {
109
- applyZone(true); // bake with indoor ambient, as the room is meant to be seen
110
- if (fill === 'probes') {
111
- // bounds = the room's air; the probe light follows a fixed point in the room (one SH for the whole scene at a time)
112
- const center = new THREE.Vector3(0, 1.2, 0);
113
- await engine.bakeProbes({ bounds: { min: [x0 + 0.5, 0.4, z0 + 0.5], max: [x1 - 0.5, h - 0.4, z1 - 0.5] }, spacing: 2.5, follow: () => center });
114
- } else if (fill === 'light' && !night) {
115
- const bounce = new THREE.PointLight(BOUNCE_LIGHT.color, BOUNCE_LIGHT.intensity, BOUNCE_LIGHT.distance, 1);
116
- bounce.position.set(-1.6, 0.4, 0.2); // just above where the sun patch lands
117
- engine.scene.add(bounce);
118
- }
78
+ picture.snapZone(); // bake with indoor ambient, as the room is meant to be seen
79
+ if (fill !== 'probes') return;
80
+ // bounds = the room's air
81
+ await engine.bakeProbes({ bounds: { min: [x0 + 0.5, 0.4, z0 + 0.5], max: [x1 - 0.5, h - 0.4, z1 - 0.5] }, spacing: 2.5 });
119
82
  }
120
83
  // spots the spec reads: the floor along the north wall and the north wall's lower part, both out of the sun patch
121
84
  const points = { corner: [-0.5, 0.03, -2.5], northWall: [1.5, 0.6, -2.98] };
122
85
  // the bake renders cubes between frames, so it runs after start; tracked in engine.loading so screenshots and tests wait for it
123
86
  const ready = engine.start().then(() => engine.loading.track('fill', setupFill));
124
- Object.assign(window, { engine, interiorTest: { THREE, ready, points, zone, fill, night } });
87
+ Object.assign(window, { engine, interiorTest: { THREE, ready, points, picture, fill, night } });
@@ -0,0 +1,24 @@
1
+ // @ts-check
2
+ // The picture of the interior-light demo: wiring only. Each part writes plain three.js.
3
+ import { exposureZones } from '../interiorLight.js';
4
+ import { AMBIENT, EXPOSURE, TONE_MAPPING } from './palette.js';
5
+ import { createLights } from './lights.js';
6
+ import { createMaterials } from './materials.js';
7
+ import { createSky } from './sky.js';
8
+
9
+ /**
10
+ * Returns { mat, sun, hemi, addLamp, zone, snapZone() }. snapZone(): the zone's values at once, without easing, for the bake.
11
+ * @param {any} engine
12
+ * @param {Parameters<typeof createLights>[1] & { isInside: (p: any) => boolean, leak: boolean }} o
13
+ */
14
+ export function createPicture(engine, { isInside, leak, ...o }) {
15
+ engine.renderer.toneMapping = TONE_MAPPING;
16
+ const sky = createSky(engine), lights = createLights(engine, o), { mat } = createMaterials();
17
+ const zones = exposureZones(engine, { hemi: lights.hemi, isInside, exposure: EXPOSURE[o.night ? 'night' : 'day'], ease: EXPOSURE.ease,
18
+ ambient: leak ? { inside: AMBIENT.outside, outside: AMBIENT.outside } : AMBIENT });
19
+ // onRender, not onFrame: onFrame runs before the sky module, so it would read last frame's signals
20
+ engine.onRender(() => { sky.update(engine.uniforms); lights.update(engine.uniforms); });
21
+ // the zones read no signals but must count every second, and a frame that is not drawn still passes time: onFrame sees those, onRender does not
22
+ engine.onFrame((/** @type {number} */ dt) => zones.update(dt));
23
+ return { mat, sun: lights.sun, hemi: lights.hemi, addLamp: lights.addLamp, zone: zones.zone, snapZone: () => zones.update() };
24
+ }
@@ -0,0 +1,52 @@
1
+ // @ts-check
2
+ // The room's lights: sun or moon aimed by hand with its shadow box fitted to the room, the hemisphere, the window as an area light, the bounce
3
+ // stand-in and the lamps. The sun stays fixed all day: this page is about the room, not the clock; only the hemisphere's colors read the signals.
4
+ import { THREE } from 'threedog';
5
+ import { windowLight } from '../interiorLight.js';
6
+ import { BOUNCE_LIGHT, HEMI, LAMPS, LAMP_SHADOW, MOON, SHADOW, SUN, WINDOW_LIGHT } from './palette.js';
7
+
8
+ /**
9
+ * @param {any} engine
10
+ * @param {{ night: boolean, fill: string, windowOpening: { position: number[], lookAt: number[], width: number, height: number } | null }} o
11
+ */
12
+ export function createLights(engine, { night, fill, windowOpening }) {
13
+ const { scene, renderer } = engine, key = night ? MOON : SUN;
14
+ const hemi = new THREE.HemisphereLight(), sun = new THREE.DirectionalLight(key.color, key.intensity);
15
+ const az = THREE.MathUtils.degToRad(key.azimuth), el = THREE.MathUtils.degToRad(key.elevation);
16
+ sun.position.set(Math.sin(az) * Math.cos(el), Math.sin(el), -Math.cos(az) * Math.cos(el)).multiplyScalar(SHADOW.distance);
17
+ sun.castShadow = true;
18
+ renderer.shadowMap.type = SHADOW.type;
19
+ sun.shadow.mapSize.setScalar(SHADOW.mapSize[engine.tier === 'low' ? 'low' : 'high']);
20
+ const { extent: e, distance } = SHADOW;
21
+ Object.assign(sun.shadow.camera, { left: -e, right: e, top: e, bottom: -e, near: 1, far: distance * 2 });
22
+ // three adds bias in the shadow camera's 0-1 depth, i.e. a world offset of bias x (far - near)
23
+ Object.assign(sun.shadow, { normalBias: SHADOW.normalBias, bias: -SHADOW.biasCm / 100 / (distance * 2 - 1), radius: SHADOW.radius });
24
+ scene.add(hemi, sun, sun.target);
25
+
26
+ if (windowOpening && !night) windowLight(engine, { ...windowOpening, ...WINDOW_LIGHT });
27
+ if (fill === 'light' && !night) {
28
+ const { color, intensity, distance: reach, decay, at } = BOUNCE_LIGHT, bounce = new THREE.PointLight(color, intensity, reach, decay);
29
+ bounce.position.set(at[0], at[1], at[2]);
30
+ scene.add(bounce);
31
+ }
32
+
33
+ /** The light of one lamp; the bulb hides inside the shade main.js puts around it @param {keyof typeof LAMPS} kind @param {number[]} at */
34
+ function addLamp(kind, at) {
35
+ const l = LAMPS[kind], p = new THREE.PointLight(l.color, l.intensity, 0, 2);
36
+ p.position.set(at[0], at[1], at[2]);
37
+ p.castShadow = l.shadow;
38
+ if (l.shadow) { p.shadow.mapSize.setScalar(LAMP_SHADOW.mapSize); p.shadow.bias = LAMP_SHADOW.bias; p.shadow.radius = LAMP_SHADOW.radius; }
39
+ scene.add(p);
40
+ }
41
+
42
+ const day = { sky: new THREE.Color(HEMI.day.sky), ground: new THREE.Color(HEMI.day.ground) }, dark = { sky: new THREE.Color(HEMI.night.sky), ground: new THREE.Color(HEMI.night.ground) };
43
+ return {
44
+ sun, hemi, addLamp,
45
+ /** @param {any} s engine.uniforms */
46
+ update(s) {
47
+ const light = s.uDaylight.value;
48
+ hemi.color.copy(dark.sky).lerp(day.sky, light);
49
+ hemi.groundColor.copy(dark.ground).lerp(day.ground, light);
50
+ },
51
+ };
52
+ }
@@ -0,0 +1,13 @@
1
+ // @ts-check
2
+ // Materials by name. Standard everywhere, since a RectAreaLight lights nothing else. Each lamp's shade glows in its own light's color.
3
+ import { THREE } from 'threedog';
4
+ import { COLORS, LAMPS, ROUGHNESS } from './palette.js';
5
+
6
+ export function createMaterials() {
7
+ const flat = (/** @type {number} */ color, roughness = ROUGHNESS.surface) => new THREE.MeshStandardMaterial({ color, roughness });
8
+ const shade = (/** @type {{ color: string, glow: number }} */ l) => new THREE.MeshStandardMaterial({ color: COLORS.shade, emissive: l.color, emissiveIntensity: l.glow, side: THREE.DoubleSide, roughness: ROUGHNESS.shade });
9
+ return {
10
+ mat: { wall: flat(COLORS.wall), floor: flat(COLORS.floor), ground: flat(COLORS.ground, ROUGHNESS.ground), table: flat(COLORS.table), cabinet: flat(COLORS.cabinet),
11
+ sofa: flat(COLORS.sofa), stand: flat(COLORS.stand), shade: { main: shade(LAMPS.main), side: shade(LAMPS.side) } },
12
+ };
13
+ }
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+ // Interior light palette: every value of the picture. Neutral numbers on a gray room; the colors of your game come from its own picture.
3
+ import { THREE } from 'threedog';
4
+
5
+ /** Surfaces of the room, by name */
6
+ export const COLORS = { wall: 0xb5b5b5, floor: 0x8f8f8f, ground: 0x8a8a8a, table: 0xa0a0a0, cabinet: 0x9c9c9c, sofa: 0xa6a6a6, stand: 0x777777, shade: 0xe8dccb };
7
+ export const ROUGHNESS = { surface: 0.9, ground: 0.95, shade: 1 };
8
+ /** azimuth: compass degrees from north (-Z), -90 = from the west. By night the same light is a weak moon */
9
+ export const SUN = { elevation: 32, azimuth: -90 + 12, intensity: 3.2, color: '#fff0dc' };
10
+ export const MOON = { elevation: 40, azimuth: -90 + 40, intensity: 0.12, color: '#8fa4d4' };
11
+ // the walls stop the sun but not these two, so indoors the ambient is turned down and the fill comes from bounce
12
+ export const AMBIENT = { outside: { hemi: 1.0, env: 0.3 }, inside: { hemi: 0.06, env: 0.04 } };
13
+ /** Hemisphere colors, blended by daylight */
14
+ export const HEMI = { day: { sky: '#b9b9b9', ground: '#4a4a4a' }, night: { sky: '#212121', ground: '#3a3a3a' } };
15
+ /** RectAreaLight: the sky seen through the window (nits-like units, Standard / Physical only) */
16
+ export const WINDOW_LIGHT = { color: '#cfe0ff', intensity: 2.2 };
17
+ /** ?fill=light: one unshadowed point light just above the sun patch, standing in for its bounce */
18
+ export const BOUNCE_LIGHT = { color: '#ffe2c0', intensity: 1.2, distance: 7, decay: 1, at: [-1.6, 0.4, 0.2] };
19
+ /** Exposure per zone, eased over `ease` seconds when the camera crosses the doorway (an eye adapting) */
20
+ export const EXPOSURE = { day: { outside: 1, inside: 1.9 }, night: { outside: 1.6, inside: 1 }, ease: 1.2 };
21
+ /** intensity in candela, physical falloff; a point light shadow is six renders, so only the light that needs it gets one. glow: the shade stays dim (no glare without bloom) */
22
+ export const LAMPS = {
23
+ main: { intensity: 5, color: '#ffc58a', shadow: true, glow: 0.35 },
24
+ side: { intensity: 2.5, color: '#ffb874', shadow: false, glow: 0.35 },
25
+ };
26
+ export const LAMP_SHADOW = { mapSize: 512, bias: -0.002, radius: 4 };
27
+ /** Fitted to the room: 8 m wide at 2048 px is 0.6 cm texels. Thin walls need a small normalBias, or light leaks along their inner edge; biasCm is the depth bias in centimeters */
28
+ export const SHADOW = { extent: 9, distance: 160, mapSize: { high: 2048, low: 1024 }, normalBias: 0.01, biasCm: 1, radius: 2, type: THREE.PCFShadowMap };
29
+ /** Sky colors by daylight; horizon is also the fog color */
30
+ export const SKY = { day: { top: '#d4d4d4', horizon: '#d4d4d4' }, night: { top: '#20242c', horizon: '#2a2a2a' } };
31
+ export const FOG = { near: 180, far: 600 };
32
+ export const TONE_MAPPING = THREE.AgXToneMapping;
@@ -0,0 +1,40 @@
1
+ // @ts-check
2
+ // The sky is the game's: a gradient sphere and fog in its horizon color, blended by daylight. The engine's dome is hidden. The environment is
3
+ // three's RoomEnvironment: soft fill with some direction, no asset; the zones write its strength.
4
+ import { THREE } from 'threedog';
5
+ import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
6
+ import { FOG, SKY } from './palette.js';
7
+
8
+ /** @param {any} engine */
9
+ export function createSky(engine) {
10
+ const { scene, renderer } = engine;
11
+ scene.fog = new THREE.Fog(SKY.day.horizon, FOG.near, FOG.far);
12
+ const pmrem = new THREE.PMREMGenerator(renderer);
13
+ scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
14
+ pmrem.dispose();
15
+ const skyMat = new THREE.ShaderMaterial({
16
+ side: THREE.BackSide, depthWrite: false, fog: false,
17
+ uniforms: { uTop: { value: new THREE.Color() }, uHorizon: { value: new THREE.Color() } },
18
+ vertexShader: 'varying vec3 vDir; void main(){ vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
19
+ // tonemapping_fragment: the sky takes the room's curve and exposure, so the window runs bright indoors and calms down outside, as the zones intend
20
+ fragmentShader: `uniform vec3 uTop; uniform vec3 uHorizon; varying vec3 vDir;
21
+ void main(){ gl_FragColor = vec4(mix(uHorizon, uTop, smoothstep(-0.05, 0.45, vDir.y)), 1.0);
22
+ #include <tonemapping_fragment>
23
+ #include <colorspace_fragment>
24
+ }`,
25
+ });
26
+ const dome = new THREE.Mesh(new THREE.SphereGeometry(400, 32, 16), skyMat);
27
+ dome.renderOrder = -1;
28
+ scene.add(dome);
29
+ if (engine.sky) engine.sky.dome.visible = false;
30
+ const day = { top: new THREE.Color(SKY.day.top), horizon: new THREE.Color(SKY.day.horizon) }, night = { top: new THREE.Color(SKY.night.top), horizon: new THREE.Color(SKY.night.horizon) };
31
+ return {
32
+ /** @param {any} s engine.uniforms */
33
+ update(s) {
34
+ const light = s.uDaylight.value, u = skyMat.uniforms;
35
+ u.uTop.value.copy(night.top).lerp(day.top, light);
36
+ u.uHorizon.value.copy(night.horizon).lerp(day.horizon, light);
37
+ /** @type {THREE.Fog} */ (scene.fog).color.copy(u.uHorizon.value);
38
+ },
39
+ };
40
+ }
@@ -4,8 +4,10 @@ Modular buildings on a grid: parameterized wall / window / door / roof / trim mo
4
4
 
5
5
  A kit of building pieces made in code, snapped to a grid and assembled into buildings and whole streets, with the colours and materials left to
6
6
  the game. The pieces are plain on purpose: the same kit draws a cozy town, a gray block-out or a cold sci-fi row by swapping one set of
7
- materials and one set of trim profiles. Run it with `npm run dev` and open `/modular-building.html` (`?set=gray|warm|cool`, `seed=1`,
8
- `count=10`, `view=street|close`, `batch=0|merge`). The engine never imports this folder; copy it and change anything.
7
+ materials and one set of trim profiles. `threedog examples pull modular-building` copies this README and `kit.js`, the whole technique: import `kit.js` from your game
8
+ and give it your materials (the code below shows how). The engine never imports this folder; change anything. The engine repository also has a demo page next to them,
9
+ which a pull does not copy: `main.js` and `picture/`, opened at `/modular-building.html` with `npm run dev` (`?set=gray|warm|cool`, `seed=1`, `count=10`,
10
+ `view=street|close`, `batch=0|merge`). Nothing in a game depends on it.
9
11
 
10
12
  ## The principle
11
13
  A town reads from far to near: skyline first, then the rhythm of openings, then trim, then small detail. A grid makes every piece fit every
@@ -53,8 +55,8 @@ vanish at that distance? Does anything flicker at seams when the camera moves?
53
55
  - **Merged hero block**: a fixed set piece merged once for the fewest draws, when it never changes.
54
56
 
55
57
  ## The engine helper (optional convenience)
56
- `kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`. `main.js` is the demo page; it builds the
57
- same seed three times (gray block-out, warm with soft cove trims, cool with hard stepped trims and faintly emissive frames; the two coloured
58
+ `kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`. The demo page in the engine repository (not in a pull)
59
+ has its picture in plain three.js (lights, tone curve, one Lambert material per slot) and builds the same seed three ways (gray block-out, warm with soft cove trims, cool with hard stepped trims and faintly emissive frames; the two coloured
58
60
  sets are demo values, not advice). In the kit, the block-out stage is `facade` strings of `.` (blank walls) and `roof`. A style is the slot
59
61
  materials (`wall`, `trim`, `roof`, `frame`, `glass`, `accent`, `awning`, `sign`) plus `profiles` plus `windows`. The only textures are gray
60
62
  masks (awning stripes, sign text) tinted by the slot material's colour, so a material swap recolours them too. `street` mirrors upper floors
@@ -111,14 +113,14 @@ Rules (correctness):
111
113
  notice". Where pieces meet, either one covers the seam (corner pilasters cover the wall ends; front / back trims run past the corners,
112
114
  side trims stop at the walls) or they are offset by a few millimetres (the sill top sits above the reveal floor).
113
115
  - **Generators get every input from `params`.** The slot materials are live objects, so the kit's manifest entries are `cache: false`
114
- (the dev cache would otherwise keep a model built with old materials). To bake a street, make the slots `makeMaterial` roles inside the
116
+ (the dev cache would otherwise keep a model built with old materials). To bake a street, build the slot materials inside the
115
117
  generator instead (recipe 05, section 2a) and drop `cache: false`.
116
118
 
117
119
  Limits:
118
120
  - Footprints are rectangles of cells (`width` x `depth`); an L-shaped building needs `building` extended to take a cell list (two buildings
119
121
  with `gap: 0` meet wall to wall, and their corner pilasters then overlap).
120
122
  - Gable ridges run along the building's width; hip roofs, dormers and balconies are not in the kit (each is one more module).
121
- - The test is `npm test -- "modular building"` (tests/specs/modular-building.mjs): determinism per seed, grid snapping without gaps,
123
+ - The test is `threedog test "modular building"` (tests/specs/modular-building.mjs): determinism per seed, grid snapping without gaps,
122
124
  shared geometry, batching under 400 draw calls, params changing shape, the optional AO pass.
123
125
 
124
126
  Sources: written for this example; no code copied. Background: the grid-snapped kit of reusable pieces is common modular level design practice
@@ -2,7 +2,7 @@
2
2
  // Modular building kit (optional technique example, see README.md). Shapes only: every module is built from parameters and drawn with the
3
3
  // game's own materials, one per slot (wall, trim, roof, frame, glass, accent, awning, sign). Imports only three and three/addons, so a game can
4
4
  // copy the folder and change anything.
5
- // The pieces are deliberately plain: they teach the method (grid, modules, variation, shared geometry), not a look.
5
+ // The pieces are deliberately plain: they teach the method (grid, modules, variation, shared geometry), not a picture.
6
6
  import * as THREE from 'three';
7
7
  import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
8
8
  import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';
@@ -18,7 +18,7 @@ export const PROFILES = {
18
18
  cove: [[0, 0], [0.35, 0], [0.5, 0.25], [0.75, 0.45], [1, 0.75], [1, 1], [0, 1]],
19
19
  };
20
20
 
21
- /** Window variants a street picks from: a few shared variants (not a random size per window) keep the look designed and the geometry shared */
21
+ /** Window variants a street picks from: a few shared variants (not a random size per window) keep the picture designed and the geometry shared */
22
22
  export const WINDOWS = [
23
23
  { width: 0.9, height: 1.4, sill: 0.9, mullions: 1, planter: false },
24
24
  { width: 1.1, height: 1.5, sill: 0.8, mullions: 2, planter: true },
@@ -2,32 +2,24 @@
2
2
  // Modular building demo (page /modular-building.html): one seeded street from kit.js, drawn with one of three material sets.
3
3
  // URL: ?set=gray|warm|cool (gray = the block-out, the default) &seed=1 &count=10 &view=street|close &batch=0 (draw every piece on its own) | merge (kit.merge: one mesh per material).
4
4
  // The two coloured sets exist to show the kit is style-free: same seed, same shapes, other slots and trim profiles. They are demo values,
5
- // not a recommended look. Test page for tests/specs/modular-building.mjs: window.mbTest = { kit, street, createModularKit, makeSlots, bakeVertexAO, THREE }.
6
- import { createEngine, fixedCamera, makeMaterial, bakeVertexAO, THREE } from '../../../index.js';
5
+ // not a recommended picture. Test page for tests/specs/modular-building.mjs: window.mbTest = { kit, street, createModularKit, bakeVertexAO, THREE }.
6
+ // Shapes only here; the whole picture is picture/.
7
+ import { createEngine, fixedCamera, bakeVertexAO, THREE } from 'threedog';
7
8
  import { createModularKit, PROFILES } from './kit.js';
9
+ import { createPicture } from './picture/index.js';
8
10
 
9
11
  const url = new URLSearchParams(location.search);
10
12
  const set = url.get('set') ?? 'gray', seed = Number(url.get('seed') ?? 1), count = Number(url.get('count') ?? 10);
11
- const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), ui: { loading: false }, saveKey: 'threedog-modular-building',
13
+ const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-modular-building',
12
14
  batching: url.get('batch') === '0' || url.get('batch') === 'merge' ? false : undefined });
15
+ const { mat: { ground: groundMat, ...slots } } = createPicture(engine, { set });
13
16
 
14
- /** Slot materials for one set. A game makes these from its own style (makeMaterial roles, or plain three.js materials) */
15
- function makeSlots(name = 'gray') {
16
- const m = (/** @type {number} */ color, extra = {}) => makeMaterial('prop', { color, ...extra });
17
- if (name === 'gray') return { wall: m(0x9c9c9c), trim: m(0xbdbdbd), roof: m(0x6c6c6c), frame: m(0x5c5c5c), glass: m(0x3c4046, { roughness: 0.3 }),
18
- accent: m(0x7c7c7c), awning: m(0xc4c4c4), sign: m(0xd2d2d2) };
19
- if (name === 'warm') return { wall: m(0xd9c7a3), trim: m(0xf0e9da), roof: m(0xa4553a), frame: m(0x3f5b45), glass: m(0x2e3d4f, { roughness: 0.2 }),
20
- accent: m(0x7a4e33), awning: m(0xb8433a), sign: m(0xe0b54a) };
21
- if (name === 'cool') return { wall: m(0x4a5260), trim: m(0x9aa3ad), roof: m(0x2c3038), frame: m(0x30c0d0, { emissive: 0x1a6a74, emissiveIntensity: 0.6 }),
22
- glass: m(0x1b2a33, { roughness: 0.15, emissive: 0x0e2a33, emissiveIntensity: 0.5 }), accent: m(0xd07a30), awning: m(0x2f8f9a), sign: m(0xe6edf2) };
23
- throw new Error(`modular-building: unknown set "${name}" (gray, warm, cool)`);
24
- }
25
17
  // a style swaps trim profiles too: same names (so a seed picks the same trim slot), other cross-sections. Hard-edged for the cool set
26
18
  const cutProfiles = { flat: PROFILES.flat, step: [[0, 0], [1, 0], [1, 0.35], [0.4, 0.35], [0.4, 1], [0, 1]], cove: [[0, 0], [0.6, 0], [1, 0.4], [1, 1], [0, 1]] };
27
- const kit = createModularKit({ slots: makeSlots(set), profiles: set === 'cool' ? cutProfiles : PROFILES });
19
+ const kit = createModularKit({ slots, profiles: set === 'cool' ? cutProfiles : PROFILES });
28
20
  engine.assets.manifest(kit.pack); // every module, a building and the street, by name: threedog gallery, hot swap, ?panel=1 tuning
29
21
 
30
- const ground = new THREE.Mesh(new THREE.PlaneGeometry(400, 400), makeMaterial('terrain', { color: 0x8c8c86 }));
22
+ const ground = new THREE.Mesh(new THREE.PlaneGeometry(400, 400), groundMat);
31
23
  ground.rotation.x = -Math.PI / 2; ground.receiveShadow = true;
32
24
  engine.scene.add(ground);
33
25
 
@@ -43,5 +35,5 @@ built.userData.batch = true; // opt in to engine.batching before adding: ident
43
35
  const street = url.get('batch') === 'merge' ? kit.merge(built) : built;
44
36
  engine.scene.add(street);
45
37
 
46
- Object.assign(window, { engine, mbTest: { kit, street, createModularKit, makeSlots, bakeVertexAO, THREE } });
38
+ Object.assign(window, { engine, mbTest: { kit, street, createModularKit, bakeVertexAO, THREE } });
47
39
  engine.start();
@@ -0,0 +1,17 @@
1
+ // @ts-check
2
+ // The picture of the modular-building demo: wiring only.
3
+ import { THREE } from 'threedog';
4
+ import { BACKGROUND, EXPOSURE, TONE_MAPPING } from './palette.js';
5
+ import { createLights } from './lights.js';
6
+ import { createMaterials } from './materials.js';
7
+
8
+ /** Returns { mat, sun, hemi }. @param {any} engine @param {{ set: string }} o */
9
+ export function createPicture(engine, o) {
10
+ engine.renderer.toneMapping = TONE_MAPPING;
11
+ engine.renderer.toneMappingExposure = EXPOSURE;
12
+ engine.scene.background = new THREE.Color(BACKGROUND);
13
+ const lights = createLights(engine), { mat } = createMaterials(o.set);
14
+ // onRender, not onFrame: engine.focus is this frame's only after the camera module ran
15
+ engine.onRender(() => lights.update());
16
+ return { mat, sun: lights.sun, hemi: lights.hemi };
17
+ }
@@ -0,0 +1,26 @@
1
+ // @ts-check
2
+ // One fixed sun and a hemisphere fill: the street has no time of day, the page judges shapes.
3
+ import { THREE } from 'threedog';
4
+ import { LIGHT, SHADOW } from './palette.js';
5
+
6
+ /** @param {any} engine */
7
+ export function createLights(engine) {
8
+ const { sun: key, ambient } = LIGHT, { extent, far, mapSize, lowMapSize, bias, normalBias, radius } = SHADOW;
9
+ const hemi = new THREE.HemisphereLight(ambient.sky, ambient.ground, ambient.intensity);
10
+ const sun = new THREE.DirectionalLight(key.color, key.intensity);
11
+ sun.castShadow = true;
12
+ sun.shadow.mapSize.setScalar(engine.tier === 'low' ? lowMapSize : mapSize);
13
+ Object.assign(sun.shadow.camera, { left: -extent, right: extent, top: extent, bottom: -extent, near: 1, far });
14
+ Object.assign(sun.shadow, { bias, normalBias, radius });
15
+ engine.scene.add(hemi, sun, sun.target);
16
+
17
+ const [ox, oy, oz] = key.offset;
18
+ return {
19
+ sun, hemi,
20
+ update() {
21
+ // the shadow box sits on what the camera looks at, so ?view=close keeps the same shadows as the street shot
22
+ sun.target.position.set(engine.focus.x, 0, engine.focus.z);
23
+ sun.position.set(engine.focus.x + ox, oy, engine.focus.z + oz);
24
+ },
25
+ };
26
+ }
@@ -0,0 +1,13 @@
1
+ // @ts-check
2
+ // Materials by name, plain Lambert: the ground plus one material per kit slot, from one set of the palette.
3
+ import { THREE } from 'threedog';
4
+ import { GROUND, SETS } from './palette.js';
5
+
6
+ /** @param {string} set a name in SETS */
7
+ export function createMaterials(set) {
8
+ const slots = SETS[/** @type {keyof typeof SETS} */ (set)];
9
+ if (!slots) throw new Error(`modular-building: unknown set "${set}" (${Object.keys(SETS).join(', ')})`);
10
+ const mat = /** @type {Record<string, THREE.MeshLambertMaterial>} */ ({ ground: new THREE.MeshLambertMaterial({ color: GROUND }) });
11
+ for (const [name, v] of Object.entries(slots)) mat[name] = new THREE.MeshLambertMaterial(typeof v === 'number' ? { color: v } : v);
12
+ return { mat };
13
+ }
@@ -0,0 +1,23 @@
1
+ // @ts-check
2
+ // Palette of the modular street: every value of the picture. The sets are demo values that prove the kit is style-free, not a recommended picture.
3
+ import { THREE } from 'threedog';
4
+
5
+ /** Slot colors per set. A plain number is the color; an object is the material's own properties */
6
+ export const SETS = {
7
+ // the block-out: gray, so only silhouette and rhythm are left to judge
8
+ gray: { wall: 0x9c9c9c, trim: 0xbdbdbd, roof: 0x6c6c6c, frame: 0x5c5c5c, glass: 0x3c4046, accent: 0x7c7c7c, awning: 0xc4c4c4, sign: 0xd2d2d2 },
9
+ warm: { wall: 0xd9c7a3, trim: 0xf0e9da, roof: 0xa4553a, frame: 0x3f5b45, glass: 0x2e3d4f, accent: 0x7a4e33, awning: 0xb8433a, sign: 0xe0b54a },
10
+ cool: { wall: 0x4a5260, trim: 0x9aa3ad, roof: 0x2c3038, frame: { color: 0x30c0d0, emissive: 0x1a6a74, emissiveIntensity: 0.6 },
11
+ glass: { color: 0x1b2a33, emissive: 0x0e2a33, emissiveIntensity: 0.5 }, accent: 0xd07a30, awning: 0x2f8f9a, sign: 0xe6edf2 },
12
+ };
13
+ export const GROUND = 0x8c8c86;
14
+ export const BACKGROUND = 0x8c8c8c;
15
+ /** A strong, nearly even fill over a modest sun, on purpose: a block-out has to show every facade, so the sides facing away stay as readable as the lit ones */
16
+ export const LIGHT = {
17
+ sun: { color: 0xffffff, intensity: 2, offset: [40, 80, 30] },
18
+ ambient: { sky: 0xffffff, ground: 0x909090, intensity: 3.1 },
19
+ };
20
+ /** A 60 m box around what the camera looks at: most of a ten-building street, at about 3 cm a texel */
21
+ export const SHADOW = { extent: 30, far: 250, mapSize: 2048, lowMapSize: 1024, bias: -0.0001, normalBias: 0.03, radius: 3 };
22
+ export const TONE_MAPPING = THREE.AgXToneMapping;
23
+ export const EXPOSURE = 1;
@@ -14,12 +14,12 @@ colored windows, and a night that is darker than all of them.
14
14
  the facades above dark, like a real cut-off fixture. `distance` only cuts the tail; keep it a few times the lamp height so the edge comes
15
15
  from decay.
16
16
 
17
- **Which pixels bloom is the threshold's choice.** The tone curve (AgX by default) compresses everything above ~1 toward white. Bloom adds light
17
+ **Which pixels bloom is the threshold's choice.** The tone curve (AgX on this page) compresses everything above ~1 toward white. Bloom adds light
18
18
  around pixels above its `threshold` (linear, before the curve). Usually it sits between the windows and the lamp heads, so only the small heads
19
19
  glow and windows and signs read as colored light; if your game wants a hazy, everything-glows night, set it lower on purpose.
20
20
 
21
21
  **Emissive is a color, not a brightness knob.** Saturated emissive colors survive the tone curve; near-white ones have no headroom and clip
22
- to flat white rectangles (why: recipe 52-look "Night glow", headroom). Get the warmth from the color and let bloom carry the halo; the
22
+ to flat white rectangles. Get the warmth from the color and let bloom carry the halo; the
23
23
  intensities in this example are its values, not targets.
24
24
 
25
25
  **Lights read when the night is darker than they are.** If the ambient at night is close to the pool brightness, the lamps look painted on.
@@ -31,7 +31,7 @@ bright, readable night, keep the ambient up and let the lamps be accents instead
31
31
  **Lights fade in.** A hard switch at 18:00 pops; fade by daylight.
32
32
 
33
33
  How to judge it in a shot at the game's camera: the ground under a lamp is clearly brighter than half way to the next one, and the pool fades
34
- without a ring; around a lamp only its core is white (the look check of `threedog shot` / `threedog snap` names each light or glowing material that blows pixels out, and the detail lost under it); the "near black" share stays low enough
34
+ without a ring; around a lamp only its core is white (the picture check of `threedog shot` / `threedog snap` names each light or glowing material that blows pixels out, and the detail lost under it); the "near black" share stays low enough
35
35
  that shapes hold.
36
36
 
37
37
  | Symptom | Cause | Fix |
@@ -39,7 +39,7 @@ that shapes hold.
39
39
  | Lamp heads and windows are flat white blocks | emissive far above the tone curve's shoulder: everything clips to the same white | lower emissiveIntensity, use a saturated color; usually only the small lamp core clips (more if your game wants blinding light) |
40
40
  | A wall next to a lamp is a bright blown-out sheet | `decay: 0` (or 1) and the light close to the wall: no falloff, the whole wall gets the full intensity | `decay: 2`, aim a spot down, move the light off the wall |
41
41
  | The whole night scene glows and looks foggy | bloom threshold below 1: every lit surface blooms | threshold between window and lamp-head brightness |
42
- | Everything is too bright or too gray at night | exposure or ambient set for the day | lower the night ambient (sky keyframes or `engine.mod('look.lights.hemi.intensity')`) rather than the lights |
42
+ | Everything is too bright or too gray at night | exposure or ambient set for the day | lower the night ambient (`NIGHT.hemi` in `picture/palette.js`) rather than the lights |
43
43
  | Halo plus bloom look like a smear | both at full strength | pick one as the main glow, keep the other faint |
44
44
  | Lights pop on at nightfall | a hard switch at 18:00 | fade by daylight (`dusk`) |
45
45
 
@@ -63,32 +63,33 @@ that shapes hold.
63
63
  - **Pixel art**: hard-edged pools in two or three palette steps, no bloom. A texture lookup.
64
64
 
65
65
  ## The engine helper (optional convenience)
66
- `threedog examples pull night-lights` copies it. Only `nightLights.js` is the technique (defaults in `NIGHT_LIGHTS_DEFAULTS`); `main.js` is the
67
- demo scene, in a game change its import to `from 'threedog'`, then:
66
+ `threedog examples pull night-lights` copies it. Only `nightLights.js` is the technique (defaults in `NIGHT_LIGHTS_DEFAULTS`) and it stands alone; `main.js` is the
67
+ demo scene and `picture/` its picture (sun, ambient, sky, fog, bloom, tone curve). In a game:
68
68
  ```js
69
69
  engine.use(lightPool({ point: 4, spot: 8 })); // real lights for the nearest lamps; the rest wait their turn
70
70
  const lights = createNightLights(engine);
71
71
  lights.addLamp(headPosition, { head: headMaterial }); // pooled spot aimed down + emissive head + halo
72
- lights.addGlow(windowMaterial); // look.materials.glow: emissive fades in at dusk
72
+ lights.addGlow(windowMaterial); // emissive fades in at dusk
73
73
  ```
74
74
  This example's current values: 80 cd at 5.5 m, so the pool center is a little under the brightness a sunlit mid-gray gets (recipe 52 "How
75
75
  bright a lit color comes out"); raise it for brighter streets, lower it for moody ones. Lamp heads at 2.5, windows at 0.6, bloom threshold 1.4.
76
- The demo lowers the sky ambient by the same night factor (a game's own sky keyframes normally do this). With bloom on, keep the halo's
76
+ The demo keeps its night ambient far under the pools (`NIGHT.hemi` in `picture/palette.js`). With bloom on, keep the halo's
77
77
  opacity low; they stack.
78
78
 
79
79
  Cost (the demo street): 8 pooled spot lights (no shadows) for any number of lamps; one emissive material per kind of glow; one sprite per lamp
80
- sharing one material and a 64 px texture; bloom is one `UnrealBloomPass` (several half-resolution blur passes; costly on integrated GPUs, the
81
- engine starts it off on low-tier devices). Spot shadows add one shadow map each (another pass over the casters): this example gives none; a game that wants lamp shadows picks its hero lamps and measures the frame time as it adds them.
80
+ sharing one material and a 64 px texture; bloom is one `UnrealBloomPass` (several half-resolution blur passes; costly on integrated GPUs, so
81
+ `picture/post.js` starts it off on low-tier devices). Spot shadows add one shadow map each (another pass over the casters): this example gives none; a game that wants lamp shadows picks its hero lamps and measures the frame time as it adds them.
82
82
 
83
83
  Rules (correctness):
84
84
  - Lamps take their real lights from `engine.lightPool` (`lightPool({ spot })`): a fixed number of three.js lights, so many lamps never
85
85
  recompile shaders or add per-light cost. Without the pool it throws.
86
86
  - The night factor comes from the time of day (`engine.calendar.daylight`, the sky's when there is no calendar). Nothing here is saved: it
87
87
  is recomputed from the time each frame, so loads and time skips are right by construction.
88
- - A glow rule drives every mesh using that material: give dark windows their own material (the demo uses two lit ones and plain wall gray).
89
- - Windows, signs and lamp heads use the engine's night glow (`engine.look.materials.glow(material, { night })`, recipe 52 "Night glow"):
90
- the engine fades their `emissiveIntensity` with daylight. The lamps' real lights need a number, so the technique computes the same fade
91
- from `daylight` (`dusk` is set to the glow's range) and sets the pooled lights; `lights.force(v)` holds it.
88
+ - `addGlow` drives every mesh using that material: give dark windows their own material (the demo uses two lit ones and plain wall gray).
89
+ - The lamps' real lights fade through the pool (`lightPool.add(at, { dusk })`). Windows, signs, lamp heads and halos are not pool sources, so
90
+ the technique applies the same curve at the same `dusk` to their `emissiveIntensity` and the halo opacity, in one `engine.onRender`.
92
91
 
93
92
  Sources: written for this example; no code copied. Light units and falloff as documented for three.js physically based lights; the bloom pass
94
93
  is three's `UnrealBloomPass` through `@threedog/post-effects`.
94
+
95
+ This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). A game on the default WebGPU route writes the same ideas in TSL (recipe 56).