threedog 0.7.0 → 1.0.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 (593) hide show
  1. package/CHANGELOG.md +411 -1
  2. package/README.md +8 -11
  3. package/core/{Animator.js → assets/Animator.js} +30 -18
  4. package/core/{Assets.js → assets/Assets.js} +131 -56
  5. package/core/{Baked.js → assets/Baked.js} +4 -4
  6. package/core/assets/assetEntry.js +302 -0
  7. package/core/{assetHot.js → assets/assetHot.js} +9 -7
  8. package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
  11. package/core/{assetReport.js → assets/assetReport.js} +7 -14
  12. package/core/{namedModel.js → assets/namedModel.js} +17 -13
  13. package/core/{Audio.js → audio/Audio.js} +47 -25
  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} +15 -12
  18. package/core/{Random.js → base/Random.js} +7 -4
  19. package/core/{Vars.js → base/Vars.js} +14 -4
  20. package/core/{easing.js → base/easing.js} +1 -1
  21. package/core/{errorCodes.js → base/errorCodes.js} +151 -125
  22. package/core/{errorHints.js → base/errorHints.js} +17 -10
  23. package/core/{errors.js → base/errors.js} +12 -10
  24. package/core/{events.generated.js → base/events.generated.js} +11 -0
  25. package/core/base/follows.js +26 -0
  26. package/core/base/math.js +66 -0
  27. package/core/{params.js → base/params.js} +5 -6
  28. package/core/base/saveValues.js +81 -0
  29. package/core/base/sections.js +97 -0
  30. package/core/base/spelling.js +32 -0
  31. package/core/base/util.js +32 -0
  32. package/core/{validate.js → base/validate.js} +34 -34
  33. package/core/{Engine.js → engine/Engine.js} +137 -91
  34. package/core/{Loading.js → engine/Loading.js} +34 -5
  35. package/core/{copies.js → engine/copies.js} +4 -4
  36. package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
  37. package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
  38. package/core/{loop.js → engine/loop.js} +88 -49
  39. package/core/engine/moduleSlots.js +176 -0
  40. package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
  41. package/core/engine/modules.js +503 -0
  42. package/core/{page.js → engine/page.js} +59 -29
  43. package/core/{plugins.js → engine/plugins.js} +21 -12
  44. package/core/{services.js → engine/services.js} +50 -40
  45. package/core/{startup.js → engine/startup.js} +66 -54
  46. package/core/{Input.js → input/Input.js} +67 -39
  47. package/core/{inputContext.js → input/inputContext.js} +14 -5
  48. package/core/input/inputKeyboard.js +39 -0
  49. package/core/{inputPad.js → input/inputPad.js} +24 -3
  50. package/core/{inputPointer.js → input/inputPointer.js} +11 -3
  51. package/core/input/inputSeat.js +66 -0
  52. package/core/{inputTouch.js → input/inputTouch.js} +24 -7
  53. package/core/{Budget.js → inspect/Budget.js} +21 -20
  54. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
  55. package/core/{Describe.js → inspect/Describe.js} +34 -26
  56. package/core/{Inspect.js → inspect/Inspect.js} +39 -10
  57. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
  58. package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
  59. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  60. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
  61. package/core/{UrlState.js → inspect/UrlState.js} +60 -24
  62. package/core/{catalog.js → inspect/catalog.js} +15 -8
  63. package/core/{checks.js → inspect/checks.js} +7 -5
  64. package/core/{debugView.js → inspect/debugView.js} +4 -4
  65. package/core/{describeRender.js → inspect/describeRender.js} +24 -22
  66. package/core/{describeText.js → inspect/describeText.js} +17 -8
  67. package/core/inspect/geometryWatch.js +38 -0
  68. package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
  69. package/core/inspect/metadata.generated.js +4140 -0
  70. package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
  71. package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
  72. package/core/inspect/toolDoor.js +21 -0
  73. package/core/inspect/valueHistory.js +35 -0
  74. package/core/{Ops.js → ops/Ops.js} +44 -14
  75. package/core/{control.js → ops/control.js} +57 -31
  76. package/core/ops/holds.js +140 -0
  77. package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
  78. package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
  79. package/core/{opsFail.js → ops/opsFail.js} +5 -7
  80. package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
  81. package/core/{opsRun.js → ops/opsRun.js} +9 -6
  82. package/core/{owned.js → ops/owned.js} +33 -19
  83. package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
  84. package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
  85. package/core/{stacks.js → ops/stacks.js} +34 -15
  86. package/core/{wrap.js → ops/wrap.js} +8 -6
  87. package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
  88. package/core/{Saves.js → saves/Saves.js} +171 -54
  89. package/core/saves/saveApply.js +312 -0
  90. package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
  91. package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
  92. package/core/saves/session.js +231 -0
  93. package/core/saves/stateReplace.js +184 -0
  94. package/core/{Rays.js → scene/Rays.js} +44 -30
  95. package/core/{Views.js → scene/Views.js} +16 -8
  96. package/core/{adaptive.js → scene/adaptive.js} +19 -9
  97. package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
  98. package/core/scene/compositeGround.js +72 -0
  99. package/core/scene/floor.js +17 -0
  100. package/core/{gameLights.js → scene/gameLights.js} +17 -7
  101. package/core/{grayMap.js → scene/grayMap.js} +8 -2
  102. package/core/{grid.js → scene/grid.js} +6 -4
  103. package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
  104. package/core/scene/ground.contract.js +14 -0
  105. package/core/scene/ground.js +139 -0
  106. package/core/{movement.js → scene/movement.js} +3 -3
  107. package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
  108. package/core/scene/pixel.js +154 -0
  109. package/core/scene/pixelRatio.js +167 -0
  110. package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
  111. package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
  112. package/core/scene/stepPoses.js +60 -0
  113. package/core/{targeting.js → scene/targeting.js} +4 -5
  114. package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
  115. package/core/{thingOps.js → scene/thingOps.js} +25 -16
  116. package/core/{things.js → scene/things.js} +18 -5
  117. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  118. package/core/{tier.js → scene/tier.js} +10 -0
  119. package/core/scene/view.js +161 -0
  120. package/core/{Batching.js → stream/Batching.js} +85 -28
  121. package/core/{Stream.js → stream/Stream.js} +80 -38
  122. package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
  123. package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
  124. package/core/{scatter.js → stream/scatter.js} +7 -4
  125. package/core/{streamSources.js → stream/streamSources.js} +14 -8
  126. package/core/{Commits.js → threads/Commits.js} +17 -11
  127. package/core/{Jobs.js → threads/Jobs.js} +25 -13
  128. package/core/{Threads.js → threads/Threads.js} +21 -18
  129. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  130. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  131. package/core/{Clock.js → time/Clock.js} +20 -11
  132. package/core/{dayTime.js → time/dayTime.js} +5 -1
  133. package/core/{skip.js → time/skip.js} +28 -21
  134. package/core/{time.js → time/time.js} +32 -20
  135. package/core/{uiClock.js → time/uiClock.js} +4 -4
  136. package/docs/AI.md +92 -72
  137. package/docs/API.md +33 -28
  138. package/docs/CODEMAP.md +121 -200
  139. package/docs/COMMANDS.md +77 -70
  140. package/docs/CONVENTIONS.md +167 -24
  141. package/docs/MIGRATING-0.8.md +171 -0
  142. package/docs/MIGRATING-1.0.md +101 -0
  143. package/docs/THREE.md +140 -38
  144. package/docs/api/assets.md +12 -13
  145. package/docs/api/audio.md +6 -5
  146. package/docs/api/budget.md +4 -4
  147. package/docs/api/calendar.md +10 -11
  148. package/docs/api/cameraRig.md +32 -29
  149. package/docs/api/characters.md +35 -24
  150. package/docs/api/clock.md +1 -1
  151. package/docs/api/collider3d.md +9 -0
  152. package/docs/api/collision.md +12 -9
  153. package/docs/api/content.md +18 -17
  154. package/docs/api/dialogue.md +5 -4
  155. package/docs/api/engine.md +58 -54
  156. package/docs/api/events.md +17 -6
  157. package/docs/api/flow.md +1 -1
  158. package/docs/api/grids.md +1 -1
  159. package/docs/api/ground.md +6 -7
  160. package/docs/api/hud.md +2 -2
  161. package/docs/api/i18n.md +6 -6
  162. package/docs/api/input.md +9 -8
  163. package/docs/api/interactions.md +5 -5
  164. package/docs/api/inventory.md +10 -10
  165. package/docs/api/jobs.md +5 -5
  166. package/docs/api/level.md +10 -9
  167. package/docs/api/lightPool.md +1 -6
  168. package/docs/api/music.md +3 -3
  169. package/docs/api/nav.md +14 -12
  170. package/docs/api/openWorld.md +1 -1
  171. package/docs/api/particles.md +10 -7
  172. package/docs/api/photo.md +4 -2
  173. package/docs/api/pickups.md +3 -3
  174. package/docs/api/post.md +21 -5
  175. package/docs/api/quests.md +7 -5
  176. package/docs/api/rays.md +7 -7
  177. package/docs/api/rigid.md +29 -19
  178. package/docs/api/saves.md +13 -11
  179. package/docs/api/settings.md +9 -8
  180. package/docs/api/sky.md +8 -7
  181. package/docs/api/stream.md +8 -9
  182. package/docs/api/swarm.md +34 -0
  183. package/docs/api/terrain.md +6 -8
  184. package/docs/api/terrainDraw.md +2 -2
  185. package/docs/api/timeline.md +4 -4
  186. package/docs/api/tools.md +27 -22
  187. package/docs/api/triggers.md +2 -0
  188. package/docs/api/vars.md +1 -1
  189. package/docs/api/vegetation.md +4 -3
  190. package/docs/api/vegetationDraw.md +2 -2
  191. package/docs/api/water.md +7 -3
  192. package/docs/api/weather.md +27 -12
  193. package/docs/api/weatherDraw.md +4 -4
  194. package/docs/api/world.md +6 -6
  195. package/docs/recipes/01-new-game.md +28 -43
  196. package/docs/recipes/02-npc.md +21 -23
  197. package/docs/recipes/03-items-pickups.md +37 -53
  198. package/docs/recipes/04-quests.md +5 -4
  199. package/docs/recipes/05-props-bake.md +34 -44
  200. package/docs/recipes/06-clock-events.md +31 -22
  201. package/docs/recipes/07-flow-scenes-pause.md +30 -32
  202. package/docs/recipes/08-weather-sky.md +91 -37
  203. package/docs/recipes/09-materials-lights-models.md +25 -39
  204. package/docs/recipes/10-blender-level.md +22 -11
  205. package/docs/recipes/11-vehicles.md +44 -24
  206. package/docs/recipes/12-navmesh.md +60 -15
  207. package/docs/recipes/13-animation.md +70 -22
  208. package/docs/recipes/14-custom-module.md +33 -20
  209. package/docs/recipes/15-perf.md +51 -28
  210. package/docs/recipes/16-dev-bridge.md +39 -58
  211. package/docs/recipes/18-world.md +49 -28
  212. package/docs/recipes/19-shooting-picking.md +7 -4
  213. package/docs/recipes/20-content-actions-save.md +55 -40
  214. package/docs/recipes/21-camera.md +47 -25
  215. package/docs/recipes/22-shop-gold.md +21 -16
  216. package/docs/recipes/23-ops.md +28 -24
  217. package/docs/recipes/26-ui-parts.md +25 -14
  218. package/docs/recipes/27-net.md +3 -5
  219. package/docs/recipes/28-terrain.md +119 -23
  220. package/docs/recipes/29-grid.md +3 -3
  221. package/docs/recipes/30-templates.md +63 -30
  222. package/docs/recipes/31-audio.md +7 -7
  223. package/docs/recipes/32-action-game.md +21 -11
  224. package/docs/recipes/33-stream-sources.md +6 -3
  225. package/docs/recipes/34-environment-lighting.md +72 -25
  226. package/docs/recipes/35-picture-from-reference.md +20 -23
  227. package/docs/recipes/36-ground-plants.md +106 -0
  228. package/docs/recipes/40-scene.md +18 -21
  229. package/docs/recipes/43-shader-patches-surfaces.md +27 -48
  230. package/docs/recipes/44-water-weather-hooks.md +56 -50
  231. package/docs/recipes/45-cascaded-shadows.md +41 -20
  232. package/docs/recipes/46-blender-art-route.md +9 -10
  233. package/docs/recipes/49-game-module-contract.md +7 -6
  234. package/docs/recipes/50-own-renderer.md +3 -2
  235. package/docs/recipes/51-capability-catalog.md +14 -8
  236. package/docs/recipes/52-around-the-picture.md +56 -100
  237. package/docs/recipes/53-ground-up-close.md +61 -24
  238. package/docs/recipes/55-mods-time-wrap.md +17 -20
  239. package/docs/recipes/56-webgpu-tsl.md +28 -15
  240. package/docs/recipes/57-control.md +39 -12
  241. package/docs/recipes/58-input.md +15 -2
  242. package/docs/recipes/59-depth-post-effects.md +1 -1
  243. package/docs/recipes/60-judge-the-picture.md +30 -25
  244. package/docs/recipes/62-picture-code.md +129 -39
  245. package/docs/recipes/63-third-person-start.md +19 -5
  246. package/docs/recipes/64-particles.md +54 -5
  247. package/docs/recipes/65-swarm.md +140 -0
  248. package/docs/recipes/66-common-tasks.md +313 -0
  249. package/examples/action/.threedog/content-index.json +1 -1
  250. package/examples/action/GAMEMAP.md +5 -5
  251. package/examples/perf-island/.threedog/content-index.json +1 -0
  252. package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
  253. package/examples/{sheepisland → perf-island}/assets.js +1 -1
  254. package/examples/{sheepisland → perf-island}/main.js +8 -8
  255. package/examples/{sheepisland → perf-island}/models.js +1 -1
  256. package/examples/{sheepisland → perf-island}/params.js +1 -1
  257. package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
  258. package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
  259. package/examples/{sheepisland → perf-island}/views.js +1 -1
  260. package/examples/plain-picture/GAMEMAP.md +4 -1
  261. package/examples/rc2d/GAMEMAP.md +4 -3
  262. package/examples/rc2d/main.js +1 -3
  263. package/examples/rc2d/rc2d.js +1 -1
  264. package/examples/styletest/.threedog/content-index.json +1 -1
  265. package/examples/styletest/GAMEMAP.md +6 -5
  266. package/examples/techniques/contact-shadows/contactShadows.js +1 -1
  267. package/examples/techniques/contact-shadows/main.js +1 -1
  268. package/examples/techniques/interior-light/main.js +1 -1
  269. package/examples/techniques/modular-building/README.md +7 -6
  270. package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
  271. package/examples/techniques/procedural-animation/README.md +1 -1
  272. package/examples/webgpu-tsl/GAMEMAP.md +2 -1
  273. package/examples/world/.threedog/content-index.json +1 -1
  274. package/examples/world/GAMEMAP.md +9 -7
  275. package/examples/world/main.js +3 -3
  276. package/examples/world/picture/sky.js +1 -1
  277. package/index.d.ts +16 -12
  278. package/index.js +53 -32
  279. package/llms.txt +11 -14
  280. package/modules/ambience/Ambience.js +16 -11
  281. package/modules/calendar/Calendar.js +19 -19
  282. package/modules/calendar/index.js +18 -16
  283. package/modules/calendar/schedule.js +11 -6
  284. package/modules/calendar/seasons.js +7 -7
  285. package/modules/camera/FirstPersonCamera.js +5 -5
  286. package/modules/camera/FixedCamera.js +43 -30
  287. package/modules/camera/FollowCamera.js +24 -15
  288. package/modules/camera/RtsCamera.js +12 -11
  289. package/modules/camera/common.js +72 -37
  290. package/modules/camera/contract.js +1 -0
  291. package/modules/camera/pixelSnap.js +62 -0
  292. package/modules/characters/Character.js +166 -70
  293. package/modules/characters/NPC.js +84 -44
  294. package/modules/characters/assetModel.js +16 -12
  295. package/modules/characters/astar.js +48 -27
  296. package/modules/characters/behaviors.js +4 -5
  297. package/modules/characters/character.contract.js +21 -0
  298. package/modules/characters/contract.js +17 -3
  299. package/modules/characters/index.js +240 -226
  300. package/modules/characters/moveHelpers.js +88 -12
  301. package/modules/characters/mover.contract.js +14 -0
  302. package/modules/characters/movers/common.js +22 -18
  303. package/modules/characters/movers/manual.js +1 -1
  304. package/modules/characters/movers/rapier.js +18 -10
  305. package/modules/characters/movers/simple.js +26 -13
  306. package/modules/characters/movers/support.js +24 -13
  307. package/modules/characters/npcAvoid.js +19 -16
  308. package/modules/characters/npcSim.js +88 -32
  309. package/modules/characters/npcView.js +19 -11
  310. package/modules/characters/pathAsync.js +81 -29
  311. package/modules/characters/pathJob.js +38 -21
  312. package/modules/characters/pathWorker.js +1 -1
  313. package/modules/characters/player.js +120 -0
  314. package/modules/characters/playerStrings.js +2 -2
  315. package/modules/characters/proceduralRig.js +2 -2
  316. package/modules/characters/seat.js +56 -0
  317. package/modules/characters/useModel.js +3 -3
  318. package/modules/characters/vehicle.contract.js +8 -5
  319. package/modules/characters/walkTo.js +40 -33
  320. package/modules/collision/Collision.js +69 -45
  321. package/modules/collision/contract.js +15 -0
  322. package/modules/collision/grid.js +6 -1
  323. package/modules/content/explain.js +2 -3
  324. package/modules/content/fields.js +24 -3
  325. package/modules/content/ids.js +5 -3
  326. package/modules/content/index.js +132 -114
  327. package/modules/content/loader.js +117 -140
  328. package/modules/content/markers.js +25 -0
  329. package/modules/content/models.js +54 -17
  330. package/modules/content/packs.js +5 -4
  331. package/modules/content/parts.js +2 -2
  332. package/modules/content/places.js +36 -0
  333. package/modules/content/props.js +22 -17
  334. package/modules/content/rules.js +47 -61
  335. package/modules/content/stages.js +7 -7
  336. package/modules/content/templates.js +80 -49
  337. package/modules/content/words.js +47 -0
  338. package/modules/debug/DebugPanel.js +14 -45
  339. package/modules/flow/contract.js +2 -1
  340. package/modules/flow/index.js +30 -16
  341. package/modules/gameplay/Container.js +17 -13
  342. package/modules/gameplay/Containers.js +23 -6
  343. package/modules/gameplay/Dialogue.js +93 -34
  344. package/modules/gameplay/Interactions.js +93 -51
  345. package/modules/gameplay/Inventory.js +64 -22
  346. package/modules/gameplay/Quests.js +146 -30
  347. package/modules/gameplay/boxOps.js +8 -1
  348. package/modules/gameplay/dialogueBubbles.js +16 -12
  349. package/modules/gameplay/inventoryOps.js +11 -8
  350. package/modules/gameplay/pickups.js +63 -37
  351. package/modules/gameplay/questLog.js +4 -2
  352. package/modules/gameplay/questSave.js +9 -4
  353. package/modules/gameplay/quests.contract.js +1 -1
  354. package/modules/grid/Grid.js +2 -2
  355. package/modules/grid/Layer.js +12 -8
  356. package/modules/grid/index.js +28 -23
  357. package/modules/grid/ops.js +43 -46
  358. package/modules/grid/preview.js +7 -7
  359. package/modules/grid/tiles.js +6 -6
  360. package/modules/hlod/index.js +42 -57
  361. package/modules/hud/index.js +22 -14
  362. package/modules/hud/parts.js +8 -8
  363. package/modules/level/contract.js +16 -0
  364. package/modules/level/heightfield.js +29 -31
  365. package/modules/level/index.js +113 -161
  366. package/modules/level/load.js +196 -0
  367. package/modules/level/meshes.js +65 -0
  368. package/modules/level/nodes.js +40 -23
  369. package/modules/lights/index.js +33 -183
  370. package/modules/lights/slots.js +93 -0
  371. package/modules/lights/sources.js +90 -0
  372. package/modules/music/Music.js +34 -28
  373. package/modules/music/rules.js +1 -1
  374. package/modules/nav/contract.js +16 -0
  375. package/modules/nav/index.js +180 -49
  376. package/modules/nav/navPath.js +45 -10
  377. package/modules/net/Client.js +7 -7
  378. package/modules/net/Host.js +7 -7
  379. package/modules/net/Net.js +1 -1
  380. package/modules/net/index.js +6 -5
  381. package/modules/net/sync.js +2 -2
  382. package/modules/net/transports.js +2 -2
  383. package/modules/particles/Particles.js +95 -29
  384. package/modules/particles/effect.js +86 -32
  385. package/modules/particles/shaders.js +19 -1
  386. package/modules/photo/Photo.js +23 -23
  387. package/modules/rigid/RigidBodies.js +255 -89
  388. package/modules/rigid/Vehicles.js +17 -8
  389. package/modules/rigid/collider3d.contract.js +26 -0
  390. package/modules/rigid/ragdoll.js +298 -0
  391. package/modules/rigid/ragdollBones.js +209 -0
  392. package/modules/rigid/refresh.js +10 -0
  393. package/modules/rigid/sync.js +51 -20
  394. package/modules/settings/Settings.js +177 -61
  395. package/modules/settings/apply.js +20 -13
  396. package/modules/settings/sections.js +19 -14
  397. package/modules/settings/strings.js +2 -2
  398. package/modules/settings/view.js +3 -3
  399. package/modules/sky/Sky.js +29 -22
  400. package/modules/sky/clouds.js +7 -7
  401. package/modules/sky/dome.js +33 -20
  402. package/modules/sky/domeLayers.js +9 -9
  403. package/modules/sky/environment.js +6 -6
  404. package/modules/sky/frame.js +19 -10
  405. package/modules/sky/season.js +7 -1
  406. package/modules/sky/shader.js +24 -25
  407. package/modules/sky/skyModule.js +17 -28
  408. package/modules/sky/tint.js +1 -1
  409. package/modules/swarm/Swarm.js +356 -0
  410. package/modules/swarm/draw.js +68 -0
  411. package/modules/swarm/grid.js +63 -0
  412. package/modules/terrain/ChunkManager.js +71 -59
  413. package/modules/terrain/chunkQueries.js +7 -24
  414. package/modules/terrain/chunkWorker.js +1 -1
  415. package/modules/terrain/draw.js +14 -11
  416. package/modules/terrain/index.js +42 -42
  417. package/modules/terrain/terrainColorMap.js +6 -3
  418. package/modules/terrain/terrainDefaults.js +2 -1
  419. package/modules/terrain/terrainEdit.js +45 -29
  420. package/modules/terrain/terrainGen.js +19 -12
  421. package/modules/terrain/terrainIsland.js +2 -2
  422. package/modules/terrain/terrainMesh.js +7 -6
  423. package/modules/terrain/terrainShape.js +8 -10
  424. package/modules/terrain/terrainShapeMain.js +3 -3
  425. package/modules/timeline/Timeline.js +83 -43
  426. package/modules/timeline/Tween.js +25 -19
  427. package/modules/timeline/shots.js +24 -17
  428. package/modules/triggers/index.js +95 -28
  429. package/modules/vegetation/Vegetation.js +34 -26
  430. package/modules/vegetation/densityMap.js +4 -7
  431. package/modules/vegetation/draw.js +39 -18
  432. package/modules/vegetation/groundChunks.js +21 -38
  433. package/modules/vegetation/index.js +37 -12
  434. package/modules/vegetation/modelGeometry.js +3 -6
  435. package/modules/vegetation/nearFade.js +1 -1
  436. package/modules/water/Water.js +20 -16
  437. package/modules/water/surface.js +3 -3
  438. package/modules/weather/Weather.js +52 -40
  439. package/modules/weather/particles.js +8 -8
  440. package/modules/weather/weatherDraw.js +28 -23
  441. package/modules/world/World.js +28 -15
  442. package/modules/world/explain.js +1 -1
  443. package/modules/world/index.js +30 -17
  444. package/modules/world/persist.js +90 -27
  445. package/modules/world/pos.js +5 -5
  446. package/modules/world/records.js +37 -11
  447. package/modules/world/sim.js +78 -27
  448. package/modules/world/simFar.js +2 -2
  449. package/modules/world/state.js +43 -11
  450. package/modules/world/thingSource.js +20 -5
  451. package/modules/world/views.js +27 -14
  452. package/package.json +48 -7
  453. package/presets.js +1 -3
  454. package/render/PostFX.js +83 -53
  455. package/render/backend.js +31 -33
  456. package/render/cascades.js +17 -12
  457. package/render/cascades.tsl.js +5 -8
  458. package/render/daylight.js +20 -3
  459. package/render/detail.js +8 -7
  460. package/render/effects.js +28 -25
  461. package/render/fuse.js +3 -3
  462. package/render/fx/cloudShadow.tsl.js +3 -3
  463. package/render/fx/detail.tsl.js +1 -1
  464. package/render/fx/index.js +5 -10
  465. package/render/fx/library.tsl.js +11 -0
  466. package/render/fx/lighting.tsl.js +2 -1
  467. package/render/fx/nodeErrors.tsl.js +2 -2
  468. package/render/fx/objectOrigin.tsl.js +1 -2
  469. package/render/fx/particles.tsl.js +8 -6
  470. package/render/fx/patchNodes.tsl.js +5 -15
  471. package/render/fx/postWebGPU.tsl.js +30 -26
  472. package/render/fx/sky.tsl.js +15 -17
  473. package/render/fx/uniforms.tsl.js +4 -4
  474. package/render/fx/wind.tsl.js +1 -1
  475. package/render/fxNumbers.js +3 -0
  476. package/render/layers.js +2 -2
  477. package/render/lighting.js +5 -3
  478. package/render/lightmap.js +41 -21
  479. package/render/lights.js +6 -6
  480. package/render/lit.js +24 -0
  481. package/render/materials.js +8 -7
  482. package/render/mergeCommon.js +22 -0
  483. package/render/modeling.js +2 -2
  484. package/render/occlusion.js +62 -15
  485. package/render/ownFrame.js +4 -4
  486. package/render/patches.js +15 -15
  487. package/render/postWebGL.js +15 -12
  488. package/render/probes.js +41 -19
  489. package/render/recordSweep.js +117 -0
  490. package/render/shaderErrors.js +10 -9
  491. package/render/shadowCache.tsl.js +107 -0
  492. package/render/shadowTypes.js +9 -0
  493. package/{core → render}/shadows.js +59 -13
  494. package/render/slots.js +7 -7
  495. package/render/terms.js +22 -24
  496. package/render/uniformDecl.js +1 -1
  497. package/types/core.d.ts +336 -202
  498. package/types/gameplay.d.ts +254 -130
  499. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
  500. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  501. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  502. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +8 -16
  503. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  504. package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
  505. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +28 -10
  506. package/types/generated/core/input/inputSeat.d.ts +26 -0
  507. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  508. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
  509. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
  510. package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
  511. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
  512. package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
  513. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  514. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
  515. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  516. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
  517. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  518. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  519. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  520. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  521. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  522. package/types/generated/modules/grid/Grid.d.ts +1 -0
  523. package/types/generated/modules/grid/Layer.d.ts +1 -1
  524. package/types/generated/modules/grid/index.d.ts +3 -3
  525. package/types/generated/modules/music/Music.d.ts +7 -5
  526. package/types/generated/modules/particles/Particles.d.ts +5 -4
  527. package/types/generated/modules/sky/Sky.d.ts +21 -10
  528. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  529. package/types/generated/modules/timeline/Timeline.d.ts +7 -5
  530. package/types/generated/modules/water/Water.d.ts +1 -0
  531. package/types/generated/modules/weather/Weather.d.ts +14 -16
  532. package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
  533. package/types/generated/modules/world/World.d.ts +11 -7
  534. package/types/generated/render/PostFX.d.ts +21 -23
  535. package/types/generated/render/materials.d.ts +1 -0
  536. package/types/generated/render/occlusion.d.ts +9 -0
  537. package/types/generated/render/patches.d.ts +1 -0
  538. package/types/generated/ui/Focus.d.ts +1 -0
  539. package/types/generated/ui/UI.d.ts +1 -0
  540. package/types/nav.d.ts +47 -15
  541. package/types/physics.d.ts +150 -73
  542. package/types/pixel.d.ts +75 -0
  543. package/types/tsl.d.ts +37 -4
  544. package/types/world.d.ts +48 -75
  545. package/ui/Focus.js +10 -9
  546. package/ui/Parts.js +13 -5
  547. package/ui/UI.js +7 -7
  548. package/ui/defaults.js +3 -2
  549. package/ui/theme.js +7 -5
  550. package/core/assetEntry.js +0 -109
  551. package/core/engineCamera.js +0 -32
  552. package/core/ground.js +0 -104
  553. package/core/holds.js +0 -134
  554. package/core/math.js +0 -48
  555. package/core/moduleSlots.js +0 -100
  556. package/core/modules.js +0 -314
  557. package/core/saveApply.js +0 -210
  558. package/core/saveValues.js +0 -46
  559. package/core/session.js +0 -174
  560. package/core/shadowTypes.js +0 -16
  561. package/core/util.js +0 -17
  562. package/core/view.js +0 -43
  563. package/docs/MIGRATING-0.3.md +0 -248
  564. package/docs/MIGRATING-0.4.md +0 -320
  565. package/docs/MIGRATING-0.5.md +0 -68
  566. package/docs/MIGRATING-0.6.md +0 -126
  567. package/docs/PERF.md +0 -245
  568. package/docs/recipes/36-sky-ground-plants.md +0 -158
  569. package/docs/recipes/37-terrain-hooks.md +0 -115
  570. package/docs/recipes/38-environment-hooks.md +0 -67
  571. package/docs/recipes/42-terrain-shape.md +0 -64
  572. package/docs/recipes/47-island-snow-backdrop.md +0 -43
  573. package/docs/recipes/54-three-idioms.md +0 -88
  574. package/examples/plain-picture/FINDINGS.md +0 -53
  575. package/examples/sheepisland/.threedog/content-index.json +0 -1
  576. package/modules/camera/projection.js +0 -21
  577. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  578. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  579. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  580. /package/core/{actor.js → ops/actor.js} +0 -0
  581. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  582. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  583. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  584. /package/core/{cells.js → stream/cells.js} +0 -0
  585. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  586. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  587. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  588. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
  589. /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
  590. /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
  591. /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
  592. /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
  593. /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
@@ -1,4 +1,4 @@
1
- # Shadows: cascades, box, budget, the switch
1
+ # Shadows: cascades, box, budget, cache, the switch
2
2
 
3
3
  **In this recipe**: `engine.shadows` works on a light you hand it and leaves every other light alone: cascades, a box that follows, an update budget, the master
4
4
  switch. Filter, bias, softness and map size are plain three.js (last section).
@@ -24,7 +24,7 @@ The engine sun takes the same entry: `engine.shadows.cascades(engine.lights.sun,
24
24
 
25
25
  | field | default | meaning |
26
26
  |---|---|---|
27
- | `count` | 3 | 1 = one map that follows the camera (`maxFar` each way); 2-4 = cascades |
27
+ | `count` | 3 | 1 = one map (see the rules below); 2-4 = cascades |
28
28
  | `maxFar` | 120 | meters from the camera they cover; no sun shadow beyond |
29
29
  | `split` | `'practical'` | where borders fall: `'practical'` / `'uniform'` / `'logarithmic'` / `(count, near, far, out) => void` |
30
30
  | `lightMargin` | 100 | meters behind each cascade box toward the light still caught as casters |
@@ -48,7 +48,6 @@ follow the camera frustum and snap to whole shadow pixels themselves, so edges d
48
48
  `lights_fragment_begin` (it would clash with `csm`, reported when added).
49
49
  - three's `ShaderChunk` is never changed (the addon's constructor does that globally; the engine swaps the chunk per material instead).
50
50
  - Under `engine.shadows.budget` cascades move only on frames whose maps re-render (or when the camera jumps), so lights and maps agree.
51
- - `engine.shadows.mapSize(sun, n)` resizes every cascade's map, on both renderers.
52
51
 
53
52
  On WebGPURenderer (recipe 56) the same call is three's
54
53
  `CSMShadowNode` on `light.shadow.shadowNode`: one light, so no material is patched, nothing is listed in `describe().owned`,
@@ -57,39 +56,35 @@ lights). The cascade shadow cameras reach `lightMargin + 2 * maxFar` meters, as
57
56
 
58
57
  ## Costs and stalls
59
58
  - Each cascade draws the shadow casters once more (each culls to its own box; near ones see little). `engine.budget.byTag()` counts a
60
- caster once per shadow map (each cascade, on both renderers), an upper bound. In the styletest acceptance test (software renderer, relative only) 3 cascades
61
- went from 1 to 3 shadow passes and roughly doubled frame time; do not expect frame rate to improve.
59
+ caster once per shadow map (each cascade, on both renderers), an upper bound. Do not expect frame rate to improve.
62
60
  - Switching cascades on, off or changing any cascade field recompiles every lit material once (a stall), and each material keeps the
63
61
  old program until it is disposed (three would otherwise reuse a stale program whose uniforms no longer update). Do it on a settings
64
62
  screen, not during play.
65
63
  - Ladder for weaker devices: `count: 3` -> `2` -> `1` (one map); before dropping a cascade try a smaller `maxFar` or `mapSize`.
66
- Low-tier devices get 1 unless you ask: `{ count: 3, low: { count: 2 } }`.
67
64
 
68
65
  ## Rules of the entry
69
- `engine.shadows.cascades(light, options)` takes `count`, `maxFar`, `split`, `fade`, `lightMargin` (the table above) and `low: { count }`, with and without a
70
- sky, on both renderers (WebGPU needs `import 'threedog/tsl'`, or the call says so).
66
+ It works with and without a sky, on both renderers (WebGPU needs `import 'threedog/tsl'`, or the call says so).
71
67
  - The light must be a DirectionalLight, a direct child of `engine.scene`, with `castShadow = true`; anything else throws at the call.
72
- - Color, intensity, `visible`, `castShadow` and `light.shadow` values stay yours and are read every frame: `mapSize`, `bias`, `normalBias`,
73
- `radius` and `blurSamples` written on the light reach every cascade. The cascades only place the light. On WebGL, while they are on,
68
+ - Color, intensity, `visible`, `castShadow` and `light.shadow` values stay yours and are read every frame. The cascades only place the light. On WebGL, while they are on,
74
69
  `light.position` and `light.target` hold that placement: writes to `light.position` or a new `light.target` still set the direction, and
75
70
  `remove()` puts both back as you left them, with the shadow camera box. A `light.target` you assigned (your player, say) is never moved.
76
- - `engine.tier === 'low'` gets one map unless you pass `low: { count: 2 }`. That map follows the camera and covers `maxFar` each way, so it is blurrier than cascades but never stops at the
77
- origin; `handle.csm` is three's CSM object, null while there is one map. Like cascades it places the light, so `engine.shadows.box` on that light is refused.
71
+ - `engine.tier === 'low'` gets one map unless you pass `low: { count: 2 }`. On a game's light that map follows the camera and covers `maxFar` each way, so it is blurrier than cascades but never stops at the
72
+ origin; like cascades it places the light, so `engine.shadows.box` on that light is refused. On `engine.lights.sun` the one map stays the engine's own box around the focus, with its size. `handle.csm` is null while there is one map.
78
73
  - An engine draws one set of cascades: a second handle throws. A box on the same light throws too, except the engine's own box on `engine.lights.sun`, which waits
79
74
  until `remove()`.
80
- - Materials work as described above (the `csm` patch, `engine.shadows.include(mat)`, `describe().owned`). Never call `CSM.setupMaterial` yourself.
81
75
  - Another shadow-casting DirectionalLight next to cascades breaks the cascade order on WebGL (three sorts shadow casters first): one warning
82
76
  names it; keep extra lights shadowless.
83
77
 
84
78
  ## A box that follows
85
- One shadow map stays sharp when it covers little. `box` keeps that little around the action:
79
+ One shadow map stays sharp when it covers little: one texel covers `2 x extent / mapSize` meters (the engine sun's 30 m on a 2048 map is about 3 cm, twice that on the 1024 map of low tier). A box much bigger than
80
+ what the camera sees blurs the shadows of small things; a box smaller than it cuts shadows off. A depth bias scales with the texel, so re-check `bias` / `normalBias` after changing either. `box` keeps that little around the action:
86
81
 
87
82
  ```js
88
83
  const sun = new THREE.DirectionalLight('#fff', 3);
89
84
  sun.position.set(40, 80, 30); sun.castShadow = true;
90
85
  engine.scene.add(sun);
91
86
 
92
- const box = engine.shadows.box(sun, { follow: player, extent: 40, snap: 'texel' });
87
+ const box = engine.shadows.box(sun, { follow: engine.player.root, extent: 40, snap: 'texel' });
93
88
  box.set({ extent: 60 }); // a wider view
94
89
  box.remove(); // position, target and the shadow camera come back
95
90
  ```
@@ -101,11 +96,38 @@ box.remove(); // position, target and the shadow camera come back
101
96
  | `snap` | 0.5 | center snap grid in meters, or `'texel'`: one shadow pixel, no shimmer on a moving camera |
102
97
  | `ahead` | 0 | meters the center is shifted in front of the view |
103
98
 
104
- - A game light gets no box unless you call this. The light keeps its direction, which is its position minus its target, so aim it as usual; a `light.target` you assigned
105
- (your player, say) is never moved. It works like cascades here: `position` and `target` hold the placement while the box is on, and writes to `light.position` or a new `light.target` set the direction.
99
+ - A game light gets no box unless you call this. The light keeps its direction, which is its position minus its target, so aim it as usual. `position`, `target` and a `light.target` you assigned work as under cascades above.
106
100
  - The engine's placeholder sun under `sky()` has a box already, following `engine.focus`, 30 m each way. `engine.shadows.box(engine.lights.sun, { follow: false, extent: 9 })` changes that one
107
101
  box and `remove()` restores it. Writing `engine.lights.sun.target.position` yourself takes the box's center over, with one warning; `{ follow: 'focus' }` gives it back.
108
102
 
103
+ ## Keep what does not move
104
+
105
+ ```js fragment
106
+ const kept = engine.shadows.cache(sun, { static: mesh => mesh !== cars.mesh }); // a test on each mesh; or an Object3D, or a list of them
107
+ kept.redraw(); // a static object moved, hid or left
108
+ kept.set({ static: town }); // say again what is static
109
+ kept.remove(); // three's own shadow node again
110
+ ```
111
+
112
+ Off until you call it, and only on the light you hand in. Static casters are drawn once into a second depth map. Each shadow frame copies that map into the light's own
113
+ shadow map and draws the rest on top, so no material or shadow filter changes. Whatever you did not name static keeps redrawing: forgetting one costs time, never a
114
+ wrong shadow. A static object added later (a streamed block) casts at once, drawn with the moving things until the next redraw. A batch counts as static when all its originals do, by a subtree or by a test; one moving original keeps the whole batch
115
+ redrawing.
116
+
117
+ **You must call `redraw()`** when a static object moves, hides or is removed: its old shadow stays until then. The engine does not watch for this, with one exception: an
118
+ `InstancedMesh` whose instances changed, or that left the scene (a batch too), redraws the kept map by itself.
119
+
120
+ It does not help when:
121
+ - **The sun moves.** Any change to the light or its box redraws everything, on top of the copy, so a day cycle costs more than plain shadows. Under a box the map holds
122
+ still until the center has left a quarter of the box; the shadows reach that much less far on the side the camera moves toward, and each step is one full redraw.
123
+ - **Wind or vertex animation moves a "static" object.** Its kept shadow does not sway. Leave those objects out of `static`.
124
+ - **Terrain detail changes.** A chunk that swaps its detail leaves the old shape in the kept map until `redraw()`. Leave it out, or call `redraw()` on the swap.
125
+ - **Few things cast.** The copy and the second map (mapSize x mapSize x 4 bytes, and float depth on the light's own map) are a fixed price. Frame time has not been measured yet.
126
+
127
+ WebGPU backend only, one plain map only: with cascades it is refused, and three's `CSMShadowNode` gives no way in. On WebGLRenderer and on WebGPURenderer's WebGL2 backend
128
+ the light draws everything, with one warning: the same picture, no saving. A budget on the same light still sets how often the moving things redraw.
129
+ Listed in `describe().threePatches` as `shadow-cache`.
130
+
109
131
  ## An update budget
110
132
  A shadow map of a still scene need not redraw every frame:
111
133
 
@@ -149,9 +171,8 @@ sun.shadow.bias = -0.0001; sun.shadow.normalBias = 0.03;
149
171
  sun.shadow.mapSize.setScalar(2048); // before the first frame; later also sun.shadow.map?.dispose(); sun.shadow.map = null;
150
172
  ```
151
173
 
152
- Changing the type later, measured against three 0.187's source:
153
- - WebGLRenderer does the work itself: `WebGLShadowMap.render` sees the new type, sets `needsUpdate` on every material in the scene and rebuilds the maps of the lights it draws that frame. You write
154
- only `shadowMap.type`. Two limits: it happens on the next frame that draws a shadow, and only for lights that draw on that frame. A light under `engine.shadows.budget` is redrawn
174
+ Changing the type later:
175
+ - WebGLRenderer does the work itself on the next frame that draws a shadow, only for lights that draw on that frame. A light under `engine.shadows.budget` is redrawn
155
176
  by the budget at once. A light of your own with `shadow.autoUpdate = false` needs `light.shadow.needsUpdate = true` in the same frame, or it keeps its old map.
156
177
  - WebGPURenderer reads the type when it builds a light's shadow node. Set it before the first frame; there is no switch at run time.
157
178
 
@@ -21,7 +21,7 @@ File > Export > glTF 2.0, into `art/models/` of the game:
21
21
  | Transform > +Y Up | on | three.js is Y-up; the exporter converts from Blender's Z-up |
22
22
  | Mesh > Apply Modifiers | on | the game gets the shape you see |
23
23
  | Mesh > UVs, Normals, Vertex Colors | on if used | missing data cannot be added later |
24
- | Material > Images | Automatic (embedded in the .glb) | `threedog assets` recompresses them anyway |
24
+ | Material > Images | Automatic (embedded in the .glb) | `threedog assets optimize` recompresses them anyway |
25
25
  | Animation > Actions / NLA tracks | on for animated models | each action becomes one clip; name it as the game will (`Idle`, `Walk`, `Slash`) |
26
26
  | Limit to > Visible Objects | off for levels | hidden `col_` boxes must be exported |
27
27
 
@@ -30,10 +30,10 @@ Do not join meshes or decimate a level: node names are its interface.
30
30
  ## 3. Check, then compress
31
31
  ```
32
32
  threedog assets check art/models/town.glb # inspect only: spawns, col_ colliders, trigger_ zones, template / id nodes, material suspicions
33
- threedog assets # compress art/models/*.glb into public/optimized/ (add -w my-game for a game)
33
+ threedog assets optimize # compress art/models/*.glb into public/optimized/ (add -w my-game for a game)
34
34
  ```
35
35
  `assets check` also lists materials, textures with the color space three gives them (by slot), normal maps, clips, `col_` colliders and template / id nodes.
36
- After loading, `engine.assets.report('hero')` (or `.reportText`; pass a copy from `model()` to check what the game shows) lists the same from the scene and
36
+ After loading, `engine.assets.report('hero')` (pass a copy from `model()` to check what the game shows) lists the same from the scene and
37
37
  flags what the file has but the scene lost: `normal-map-lost`, `material-replaced` (your code took over), `clip-lost`, `clip-unmapped` (an animation
38
38
  state names a clip the file lacks), `node-lost`, and wrong color spaces. The engine never recomputes normals or drops a normal map on a GLB; only code
39
39
  that swaps materials as in section 5 does.
@@ -44,9 +44,9 @@ colliders, template / id nodes, spawn / trigger_ / npc_ / marker_ points; warnin
44
44
  | Step | What it does | When it matters |
45
45
  |---|---|---|
46
46
  | Meshopt | compresses geometry; the decoder ships with the engine | always on; smaller download, no visual change |
47
- | KTX2 | textures stay compressed on the GPU too, and the download shrinks | always on for a model with textures; needs the `ktx` tool (KTX-Software): without it that model fails, the command says what to install, and the game's `assets.js` stays as it was |
47
+ | KTX2 | textures stay compressed on the GPU too, and the download shrinks | always on for a model with textures; if no encoder runs (`assets optimize` in `../COMMANDS.md`), that model fails, the command says why, and the game's `assets.js` stays as it was |
48
48
 
49
- It needs `@gltf-transform/cli` (`npm i -D @gltf-transform/cli`). Unchanged files are skipped; `--force` redoes everything.
49
+ It needs `@gltf-transform/cli` (`npm i -D @gltf-transform/cli`); its current release pulls a `glob`/`minimatch` that `npm audit` flags (moderate, build time only), so add `"overrides": { "@donmccurdy/caporal": { "glob": "^14.0.4" } }` to your package.json. `--force` redoes unchanged files too.
50
50
 
51
51
  ### The same shot again, before and after
52
52
  Declare fixed views once: `engine.views.define('gate', { position: [10, 4, 12], target: [0, 1, 0], fov: 50 })` (`views.show(name)` also works in code). Then
@@ -61,7 +61,6 @@ Views can also be content: `content/views.js` = `{ gate: { position: [10, 4, 12]
61
61
  ambient and hemisphere light hidden so shadows read black, `'normals'` the normals as color (a normal map shows here); `'off'` restores everything.
62
62
  A view is temporary and owner-scoped (`{ owner }`; another owner needs `force: true` to clear it), never saved, and `describe().render` / `describe render`
63
63
  start with a DEBUG VIEW line while one is on, so a screenshot of clay is not taken for the real picture. Meshes added after the call are not covered: call it again.
64
- It needs the debug module (`engine.use(debug())`).
65
64
 
66
65
  ## 4. Use it
67
66
  Register the compressed file in the asset pack and refer to it by name everywhere else:
@@ -82,7 +81,7 @@ that is what lets a painted or baked texture show. One scene can mix GLB props a
82
81
 
83
82
  There is no automatic mapping from a GLB material name to anything. To give a GLB your game's materials, do it in your game code, per model: name the
84
83
  material in Blender (`cloth`, `metal`, `glass`) and look it up in your `picture/materials.js`:
85
- ```js
84
+ ```js fragment
86
85
  const m = await engine.assets.model('hat');
87
86
  m.traverse(o => { if (o.isMesh && materials[o.material.name]) o.material = materials[o.material.name]; });
88
87
  ```
@@ -90,7 +89,7 @@ This replaces the painted material, so the texture is gone unless yours sets `ma
90
89
 
91
90
  ## 6. Smallest copyable flow
92
91
  1. Blender: a cube named `well`, UV unwrapped, base color baked to a texture, export `art/models/well.glb` with the settings above.
93
- 2. `threedog assets check art/models/well.glb` (no errors), then `threedog assets`.
92
+ 2. `threedog assets check art/models/well.glb` (no errors), then `threedog assets optimize`.
94
93
  3. Add `well: '/models/well.glb'` to `engine.assets.manifest({ models })`.
95
94
  4. `engine.add(await engine.assets.model('well'))`, then `threedog shot /your-page.html --describe-only` or open the page.
96
95
 
@@ -100,11 +99,11 @@ This replaces the painted material, so the texture is gone unless yours sets `ma
100
99
  | Model too dark, or textures washed out/white | color space: a color map used as data or a data map as color (`assets check` reports `looks like data` / `looks like color`) | color maps (base color, emissive) are sRGB; normal, AO, roughness are Non-Color in Blender; one image per use |
101
100
  | Texture shows one flat color | no UV set on that mesh (`texture-without-uv`) | unwrap in Blender, export again |
102
101
  | Emissive never glows | emissive texture with black emissive color (`emissive-hidden`) | set the emissive color to white |
103
- | Node names lost (`spawn`, `col_` not found) | meshes joined before export | keep objects separate; `threedog assets` never flattens or joins; run `assets check` to see what the level finds |
102
+ | Node names lost (`spawn`, `col_` not found) | meshes joined before export | keep objects separate; `threedog assets optimize` never flattens or joins; run `assets check` to see what the level finds |
104
103
  | Custom properties missing (`template`, `id`) | "Custom Properties" off at export | tick it and export again |
105
104
  | Collision does nothing | `col_` object not exported, or no `collision()` module | export hidden objects; `engine.use(level(...), collision())`; test `engine.collision.walkable({ x, z })` |
106
105
  | Painted material replaced by a flat look | game code swapped it (section 5) | remove the swap, or give your material a `map` |
107
- | File too big | large textures or many materials | textures at 2048 or less, share atlases, `threedog assets`; sizes are in the `assets` output and `.threedog/optimize-report.json` |
106
+ | File too big | large textures or many materials | textures at 2048 or less, share atlases, `threedog assets optimize`; sizes are in the `assets` output and `.threedog/optimize-report.json` |
108
107
  | Clip not found | action name differs from the manifest `animation` mapping | rename the action in Blender or change `clip:` |
109
108
 
110
109
  See also: `10-blender-level.md` (level names and markers), `43-shader-patches-surfaces.md` (your own material, shader patches),
@@ -7,15 +7,16 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
7
7
  1. **State.** Prefer world records (`engine.world.add({ kind, ... })`, recipe 18): saved, streamed and far-simulated for you. State that is not a
8
8
  record (a counter, a machine's queue) goes in `engine.saves.register(key, { save, load, version?, migrate? })`. Raise `version` by 1 whenever the
9
9
  saved shape changes and add `migrate: { oldVersion: d => newData }`. Never keep game state only in a closure or module variable.
10
- 2. **Time, normal play.** Store *when* something happened in game seconds (`engine.clock.now`), and derive the state from `now - startedAt`. Never use
10
+ 2. **Time, normal play.** Store *when* something happened in calendar seconds (`engine.clock.now`), and derive the state from `now - startedAt`. Never use
11
11
  `Date.now`, `performance.now` or `setTimeout` for game time: they ignore pause, time channels, `step` and saves. If you must accumulate, do it in
12
12
  the module `fixed(dt, e)` hook (dt is real seconds; a speed several systems change goes through `engine.mod`, recipe 06).
13
13
  3. **Time, skipped** (`engine.skip`, the op `time.skip`, recipe 06 section 2). `fixed` hooks, physics and near simulation do **not** run during a skip.
14
14
  A state derived from `clock.now` is exact for free. A module that accumulates in `fixed` must also implement `skip(dt, e, done)` (called once per
15
15
  segment, `done` on the last; do heavy work once when `done`), or put the logic in a world record `far(rec, dt)`, which gets one catch-up call.
16
+ Say which on the definition with `skipKind`: `exact`, `approx`, `step` or `none` (`ModuleDefinition` in the types says what each means); `engine.catalog` reports a module with a `fixed` or `skip` hook that does not.
16
17
  4. **Observable.** Module hook `describe(e, ctx)` puts its return value in `describe().<module name>` (plain JSON; the bridge `describe <name>` and
17
18
  `describeText()` show it). A game without a module uses `engine.describe.add(name, fn)`. The name must be new (it throws on a clash).
18
- Every engine module has one (check rule R44 fails a module without it): keep it compact, the state an AI checks to verify the module worked.
19
+ Keep it compact: the state an AI checks to verify the module worked.
19
20
  5. **Actions are ops.** `engine.ops.define('noun.verb', { args, can, run, offers, reasons, desc })`. `can` is read-only and returns `true` or a reason
20
21
  string (a key of `reasons`); `run` changes state; `offers(e, ctx)` lists the arg sets possible right now (shown by the bridge `ops` command and
21
22
  `describe`). Call with `engine.ops.run(name, args)` -> `{ ok, value }` or `{ ok: false, code, facts, nextActions }` (read `r.code`). Never mutate state from UI code directly.
@@ -23,14 +24,14 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
23
24
  ## Declaring stage and dependencies
24
25
  `stage` only picks where the hooks run (first to last): `control, ground, environment, gameplay, effects, late (default), audio`; `before / after`
25
26
  (module names) only order modules inside one stage; a contradiction with the stage order throws. `requires: ['world']` names a capability that must already be provided (throws
26
- otherwise, naming both fixes: the engine's `world()` first, or your own module with `provides: ['world']`). `type` says what the module may own
27
- (recipe 14: `'rules'` for game logic like this one; a `'picture'` module may not define ops). `optional: { sky: 'what is lost without it' }` is a soft dependency (use `engine.sky?.`). Core never imports
27
+ otherwise, naming both fixes: the engine's `world()` first, or your own module with `provides: ['world']`). `type` says what the module owns
28
+ (recipe 14): none means `'rules'`, game logic like this one, and a module doing what its type does not usually own (a `'picture'` module defining an op) gets a dev warning, never a refusal. `optional: { sky: 'what is lost without it' }` is a soft dependency (use `engine.sky?.`). Core never imports
28
29
  modules. The module `name` must not clash with an existing engine property.
29
30
 
30
31
  ## One copyable module: something that finishes after a delay (a smelter, a turret recharge, a crop)
31
32
  ```js
32
33
  export const machines = () => {
33
- const started = new Map(); // id -> startedAt (game seconds)
34
+ const started = new Map(); // id -> startedAt (calendar seconds)
34
35
  return {
35
36
  name: 'machines', type: 'rules', stage: 'gameplay', requires: ['inventory'],
36
37
  install(e) {
@@ -66,7 +67,7 @@ Both runs must give equal `describe machines` (and `describe time`); if B differ
66
67
  ## Checking it: a contract file and the shared contract test
67
68
  Write the five points down as data in `contract.js` (`{ name, api, ops, events, saves: { key: version }, describe, options, probe }`, see
68
69
  `modules/gameplay/inventory.contract.js`) and run it from your tests (works in a game installed from npm):
69
- ```js
70
+ ```js fragment
70
71
  import { runContract } from '@threedog/tools/contract';
71
72
  runContract(contract, () => myModule(contract.options), { check }); // check(label, ok, detail?)
72
73
  ```
@@ -7,6 +7,7 @@ const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
7
7
  const engine = createEngine({ renderer }); // canvas defaults to renderer.domElement
8
8
  ```
9
9
 
10
- - The engine configures only a renderer it created itself. With yours it sets nothing: pixel ratio (unless `pixelRatio` is given), size, tone mapping, exposure and shadow map stay as you left them, so set them yourself on the renderer. MSAA follows your renderer's `antialias` too (unless `createEngine({ antialias })` or `style.antialias` says otherwise; a value that differs from the renderer's runs the post chain's MSAA targets every frame).
10
+ - The engine configures only a renderer it created itself. With yours it sets nothing: pixel ratio (unless `pixelRatio` is given), size, tone mapping, exposure and shadow map stay as you left them, so set them yourself on the renderer. MSAA follows your renderer's `antialias` too (unless `createEngine({ antialias })` says otherwise; a value that differs from the renderer's runs the post chain's MSAA targets every frame).
11
11
  - **WebGLRenderer or three's WebGPURenderer.** On WebGPURenderer, materials, patches and post effects take their node / TSL forms (recipe 56). Everything else (scene, modules, input, saves, ops) does not depend on the renderer.
12
- - Changing the renderer, lights or post effects is yours to do at any time; the engine never warns. `engine.describe().render` (CLI: `describe render`) lists the current values and tags each `engine` / `style` / `game`, so an AI can see who set a picture.
12
+ - Changing the renderer, lights or post effects is yours to do at any time; the engine never warns. `engine.describe().render` (CLI: `describe render`) lists the current values; `describe().picture.writers` says which line wrote each on the dev server.
13
+ - **A transparent canvas** (the page shows through where nothing is drawn) is this same route; createEngine has no option for it. WebGL: `new THREE.WebGLRenderer({ canvas, alpha: true })` (three's default is opaque). WebGPURenderer: alpha is on by default; pass `alpha: true` to be explicit. Then `renderer.setClearColor(0x000000, 0)` and keep `engine.scene.background` null (a colour or texture background is opaque by definition). Post effects keep the alpha (tested on both backends with vignette). With `fallback: 'webgl'` a WebGPURenderer you built with alpha is replaced by a WebGLRenderer that keeps the alpha (a renderer the engine built itself stays opaque).
@@ -19,7 +19,7 @@ same data and adds the files: `source` (where `name: 'shop'` or `define('shop.bu
19
19
  A module entry has: `state`, `stage`, `runIndex` (place in `engine.moduleOrder`), `critical`, `requires`, `optional` (`{ name, installed, lost }`),
20
20
  `params` (schema, default and the value in use), `ops` (`{ name, desc, args, failures }`), `saves` (`{ key, version, migrates }`),
21
21
  `time` (`hooks`, `step: 'fixed' | 'frame' | 'none'`, `skip`), `queries` (`describe().<id>`, names added with `describe.add`, the api's public names) and
22
- `problems`, such as "fixed hook but no skip hook" or an `optional` module that is missing.
22
+ `problems`, such as "no skipKind" (the module does not say how `engine.skip` advances it) or an `optional` module that is missing.
23
23
 
24
24
  `threedog catalog <id>` lists each param as `key:type=default — sentence`: the type (for `any` params) and sentence are read from the module's api page (its options typedef JSDoc), so the schema keeps only names, defaults and checks; a param with no sentence shows `(no doc)` and counts as a problem (rule R38 lists the modules).
25
25
 
@@ -30,13 +30,18 @@ Who owns what: an op, save part or describe name registered while a module's `in
30
30
  An op arg is `'int?'` or the full schema `{ type, default, min, max, values, desc, optional }`. The same object validates the call in dev, fills the
31
31
  default before `can` and `run`, and is what the catalog and `threedog catalog` show, so the code never needs `n = 1` in two places.
32
32
  ```js
33
+ const PRICE = { bread: 2 };
33
34
  engine.ops.define('shop.buy', {
35
+ atomic: true,
34
36
  args: { item: 'string', n: { type: 'int', default: 1, min: 1, max: 99, desc: 'how many' } },
35
37
  can: (e, { item, n }) => e.inventory.count('gold') >= n * PRICE[item] ? true : 'noMoney',
36
- run: (e, { item, n }) => e.inventory.add(item, n),
37
- reasons: { noMoney: 'Not enough gold' }, // the failure codes the catalog lists
38
+ run(e, { item, n }) {
39
+ e.inventory.remove('gold', n * PRICE[item]);
40
+ return e.inventory.add(item, n).added === n ? n : { ok: false, code: 'bagFull' };
41
+ },
42
+ reasons: { noMoney: 'Not enough gold', bagFull: 'No room in the bag' }, // the failure codes the catalog lists
38
43
  });
39
- engine.ops.run('shop.buy', { item: 'bread', n: 0 }); // dev: throws "n must be >= 1"; release: returns { ok: false, code: 'badArgs' } (run never starts)
44
+ engine.ops.run('shop.buy', { item: 'bread' }); // n: 1; with n: 0, dev throws "n must be >= 1" and release returns { ok: false, code: 'badArgs' } (run never starts)
40
45
  ```
41
46
 
42
47
  ## 3. Declare module options once (`readParams`)
@@ -57,7 +62,8 @@ The schema types are those of op args plus `object`, `array` and `function` (opt
57
62
  time hooks; a `fixed` hook without `skip` is listed under problems (recipe 49).
58
63
 
59
64
  ## 5. "How do I get this effect": `threedog how`
60
- `threedog how "rain"` scores the words of the task against the AI.md task rows and the recipe headings with their first sentence, and prints the
61
- top five: the API in the row, the recipe path with section (`recipes/08-weather-sky.md §1`) and a one-line snippet. It reads the docs only, so it works with no page
62
- and prints the same list every run. When a dev page runs it adds up to three live catalog modules whose name matches the first English word. Words match at a word
63
- start (`rain` does not hit `terrain`). No hit means rephrase, or read AI.md.
65
+ `threedog how "rain"` (the MCP tool `how` is the same answer) scores the words of the task against the AI.md task rows and the recipe headings, then leads with one
66
+ recommended route. That is a first read, never the only allowed way. Under it: whether the route is installed in this game (the game's `engine.use` calls, or the page's catalog when
67
+ one is attached), which dependency is missing, a minimal example, and the next route when it does not fit. `--full` lists the other routes with their paragraphs, your library's
68
+ entries and this game's own modules. It works with no page and answers the same every run. Words match at a word start (`rain` does not hit `terrain`). A weak match
69
+ recommends nothing and lists the closest hits; rephrase, or read AI.md.
@@ -1,6 +1,6 @@
1
1
  # 52 Around the picture: reading it back, the post chain, who writes what
2
2
 
3
- **In this recipe**: Atmosphere · Surfaces · Water, weather · Post effect chain · Who writes it · Lower-level forms that stay
3
+ **In this recipe**: Atmosphere · Surfaces · Post effect chain · Who writes it
4
4
 
5
5
  The picture is plain three.js in a `picture/` folder that reads `engine.uniforms` ([recipe 62](62-picture-code.md)). This page covers what sits around that code: reading the picture back,
6
6
  trying a value out, and the engine pieces it talks to.
@@ -15,72 +15,49 @@ engine.catalog('post'); // a capability's entries and wh
15
15
  Which knob changes what on screen, and how to judge it for your picture: [recipe 60](60-judge-the-picture.md). Where picture code sits among the other ways to customize: `../CONVENTIONS.md` "Customization ladder".
16
16
 
17
17
  - The picture is not saved: after a load, your `picture/` code draws it again from your own state.
18
- - How bright a lit color comes out (three.js light units, with `renderer.toneMapping = THREE.AgXToneMapping`, exposure 1): a diffuse surface facing up receives
19
- `sun.intensity × sin(sun elevation) + hemi.intensity` (the hemisphere's sky color, since it faces up), and three divides by π, so a total of
20
- **about 3 (≈ π) shows mid-tone albedos (sRGB 0.35-0.65) at roughly their own value**: sun 2 high overhead + hemisphere 1, or a low sun 4 at 20° +
21
- hemisphere 1.6. Measured on three's AgX curve: total 2.5 for sRGB 0.35, 2.6 for 0.5, 3.4 for 0.65, 5.5 for 0.8 (AgX darkens light colors and
22
- pales saturated ones, so a pale or vivid palette needs more, or exposure). Walls and faces away from the sun get only their `N·L` share, and
23
- the environment (`scene.environment`) adds on top for Standard / Physical materials.
18
+ - How bright a lit color comes out (three.js light units, exposure 1): a diffuse surface facing up receives `sun.intensity × sin(sun elevation) + hemi.intensity` (the hemisphere's sky color,
19
+ since it faces up), and three divides by π, so a total near π shows mid-tone albedos at roughly their own value under `AgXToneMapping`. AgX darkens light colors and pales saturated ones,
20
+ so a pale or vivid palette needs more, or exposure. Walls and faces away from the sun get only their `N·L` share, and the environment (`scene.environment`) adds on top for Standard / Physical materials.
24
21
 
25
22
  ## Atmosphere: fog, sky
26
23
 
27
- - Fog: `engine.scene.fog` is the game's, [recipe 38](38-environment-hooks.md#fog-plain-threejs-signals-your-own-math).
28
- - The sky: plain values and calls on `engine.sky`, [recipe 08](08-weather-sky.md).
29
- - <a id="tsl-forms"></a>**tsl forms** (`renderer: 'webgpu'`): the GLSL hooks `engine.sky.clouds` and `engine.sky.layer` take `{ glsl, tsl }`; each renderer draws its own form and a missing one throws by name (`[webgpu-needs-tsl]` on WebGPU). `tsl: (ctx) => vec4 node`, ctx = the GLSL function's arguments as nodes plus the value so far (`ctx.clouds` the built-in kind, `ctx.color` the sky under a layer, `ctx.fog` what the fog kind alone draws), `ctx.uniforms` (the dome's, yours included), `ctx.fx.noise` / `hash` and `ctx.tsl` (three/tsl):
30
- `engine.sky.layer('glow', { glsl, tsl: ({ dir, tsl }) => tsl.vec4(1, 0.6, 0.3, tsl.smoothstep(0.3, 0.8, dir.y).mul(0.4)), blend: 'add' })`.
31
- - Shadows are `engine.shadows` and three.js, recipe 45.
32
- - Whether a picture reads as lit is mostly key against fill. The key (the sun or one main light) is the light that casts the shadow; the fill is
33
- everything else (sky and ground light, the environment). Shadowed surfaces see only the fill while lit ones see both, so the balance sets how
34
- deep the shadows look: less fill is harder and more dramatic, more fill softer and more readable, and there is no right ratio, only the one
35
- the game wants. A warm key over a cool fill (or the reverse) separates lit from shaded sides without more contrast. The shot's `light:`
36
- fact measures the ratio; judge the result on a shot with a known-colored object in shadow. To compare afterwards, the `sun-and-key-light`
37
- technique (`threedog examples pull sun-and-key-light`) shows three routes side by side.
38
- - Shadow detail is texels per meter: one shadow-map texel covers `2 x extent / mapSize` meters (for example the default `extent` 70 on a
39
- 2048 map is about 6.8 cm, twice that on the 1024 map of low tier and headless shots). A box much bigger than what the camera sees blurs
40
- the shadows of small things; a box smaller than it cuts shadows off. `engine.shadows.box(light, { extent })` sizes it; a depth bias scales with the
41
- texel, so re-check `bias` / `normalBias` after changing either.
42
- - Fog kinds and the fog hook in detail, the placeholder lights: [recipe 38](38-environment-hooks.md).
24
+ Fog and the placeholder lights: [recipe 34](34-environment-lighting.md). The sky: plain values and calls on `engine.sky`, [recipe 08](08-weather-sky.md). Shadows: `engine.shadows` and three.js, recipe 45. Water and weather: recipe 44.
25
+
26
+ <a id="tsl-forms"></a>**tsl forms** (`renderer: 'webgpu'`): the GLSL hooks `engine.sky.clouds` and `engine.sky.layer` take `{ glsl, tsl }`; each renderer draws its own form and a missing one throws by name (`[webgpu-needs-tsl]` on WebGPU). `tsl: (ctx) => vec4 node`, ctx = the GLSL function's arguments as nodes plus the value so far (`ctx.clouds` the built-in kind, `ctx.color` the sky under a layer, `ctx.fog` what the fog kind alone draws), `ctx.uniforms` (the dome's, yours included), `ctx.fx` (the `threedog/tsl` functions, `ctx.fx.noise` and `hash` among them) and `ctx.tsl` (three/tsl):
27
+ `engine.sky.layer('glow', { glsl, tsl: ({ dir, tsl }) => tsl.vec4(1, 0.6, 0.3, tsl.smoothstep(0.3, 0.8, dir.y).mul(0.4)), blend: 'add' })`.
43
28
 
44
29
  ## Surfaces: ground, plants, cloud shadow, season
45
30
 
46
- ```js
31
+ ```js fragment
47
32
  engine.terrain.material = myGroundMaterial; // plain three.js on the module; terrain({ colors, shading, detail }) are its start values (recipe 28)
48
33
  engine.uniforms.uWindFreq.value = 1.5; engine.uniforms.uWindAmp.value = 0.5; // signals: live on every plant, planted ones too
49
34
  engine.vegetation.define('grass', { geometry, wind: { amplitude: 0.05, glsl, tsl } }); // your own sway: threedogWind(...) / tsl: (ctx) => moved position (recipe 36)
50
35
  engine.vegetation.color({ glsl: 'diffuseColor.rgb *= 0.8;', tsl: c => c.color.mul(0.8) }); // code in the color slot, live on planted species
51
- engine.terms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= myShade(vThreedogWorld);', tsl: c => ({ directDiffuse: c.directDiffuse.mul(myShadeNode) }) });
52
- engine.terms.cloudShadow(false); // no engine cloud shadow anywhere: draw your own
53
- engine.terms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uCover.y);', tsl: c => myTint(c, kind) })); // your own season / snow tint
36
+ engine.shaderTerms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= myShade(vThreedogWorld);', tsl: c => ({ directDiffuse: c.directDiffuse.mul(myShadeNode) }) });
37
+ engine.shaderTerms.cloudShadow(false); // no engine cloud shadow anywhere: draw your own
38
+ engine.shaderTerms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uGroundCover.y);', tsl: c => myTint(c, kind) })); // your own season / snow tint
54
39
  ```
55
40
 
56
- - Wind is signals: `engine.uniforms.uWind` (weather), `uWindFreq`, `uWindAmp`. A three.js material of yours sways with `applyEffects(mat, { wind: 0.03 })`; your own shader calls `threedogWind(position, origin, amplitude)` (`#include <threedog_wind>`) or `wind(position, origin, amplitude)` (`threedog/tsl`). `uWindFreq` is the start value of `uWindFreq`.
57
- - The plants: `engine.vegetation.color(glsl | { glsl, tsl, uniforms })` puts code in the `color` slot of every species' material, changed live. The whole plant picture is replaced as a module: `engine.use(myPlants, { replaces: 'vegetation-draw' })`.
58
- - `engine.terms.cloudShadow(spec)` and `engine.terms.season(spec)` put your own patch (`{ glsl, tsl, uniforms?, pars?, slot? }`, slot `lighting` / `color` by default) in place of the engine's on every material that carries the term, including ones built before the call; `false` removes the term; the handle's `remove()` gives the engine's back. The signals stay bound: `uCloud*` and `threedogCloudShadow(worldPos)`; `uFoliageTint` / `uGroundTint` / `uFoliageMix` / `uGroundMix`, `uCover` (cover amount alone, x foliage, y ground) and `threedogSeason(color, kind)` (TSL: `season(color, kind)`). `season` also takes `kind => spec` (kind `'foliage'` | `'ground'`). Each renderer draws its own form, and a missing one throws by name.
59
- - Cloud shadow values are signals: `engine.uniforms.uCloudShadow` (darkest, 0 = none), `uCloudScale`, `uCloudSpeed`. The term sits on engine materials and on what you pass to `applyEffects(mat)`; your own shader calls `threedogCloudShadow(worldPos)` (GLSL) or `cloudShadow(positionWorld)` (`threedog/tsl`). The engine adds it to no other material.
60
-
61
- ## Water, weather
62
-
63
- - Water is plain three.js on the module (`engine.water.material`, `engine.water.uniforms`, `engine.water.shader`): recipe 44.
64
- - Weather: `weather({ rain, snow })` gives the particles, `engine.weather.define(field, spec)` a game's own (recipe 44).
41
+ - Wind is signals: `engine.uniforms.uWind` (weather), `uWindFreq`, `uWindAmp`. A three.js material of yours sways with `applyEffects(mat, { wind: 0.03 })`; your own shader calls `threedogWind(position, origin, amplitude)` (`#include <threedog_wind>`) or `wind(position, origin, amplitude)` (`threedog/tsl`).
42
+ - The whole plant picture is replaced as a module: `engine.use(myPlants, { replaces: 'vegetation-draw' })`.
43
+ - `engine.shaderTerms.cloudShadow(spec)` and `engine.shaderTerms.season(spec)` put your own patch (`{ glsl, tsl, uniforms?, pars?, slot? }`, slot `lighting` / `color` by default) in place of the engine's on every material that carries the term, including ones built before the call; `false` removes the term; the handle's `remove()` gives the engine's back. The signals stay bound: `uWeatherCloud, uCloudShadow*` and `threedogCloudShadow(worldPos)`; `uFoliageTint` / `uGroundTint` / `uFoliageMix` / `uGroundMix`, `uGroundCover` (cover amount alone, x foliage, y ground) and `threedogSeason(color, kind)` (TSL: `season(color, kind)`). `season` also takes `kind => spec` (kind `'foliage'` | `'ground'`). Each renderer draws its own form, and a missing one throws by name.
44
+ - Cloud shadow values are signals: `engine.uniforms.uCloudShadow` (darkest, 0 = none), `uCloudShadowScale`, `uCloudShadowSpeed`. The term sits on engine materials and on what you pass to `applyEffects(mat)`; your own shader calls `threedogCloudShadow(worldPos)` (GLSL) or `cloudShadow(positionWorld)` (`threedog/tsl`). The engine adds it to no other material.
65
45
 
66
46
  ## Post effect chain
67
47
 
68
48
  Post-processing is an ordered list of named effects, and **`engine.post.add(x, { name, slot, order })` is the one way an effect gets
69
49
  in**: game code and the game's `plugins/` folder (a file that exports the Pass or effect) go through it, so every
70
50
  effect has a name, a handle and a row in `describe().slots` and `describe().render.post`. It returns `{ name, enabled, set(params), remove() }`, and
71
- `engine.post.get(name)` returns the same handle. A wrong shape throws with nothing added. `x` is a plain three.js Pass (WebGL),
72
- a TSL node function `(input, ctx) => node` (WebGPU), or an effect `{ name, create, node, fuse, slot, order, params, needsDepth, needsBuffers, backend, skipOnLowTier, facts }` (both renderers: give
73
- `create` and `node`, or a `fuse`; the last five are optional: `needsBuffers` lists extra scene outputs on WebGPU, `backend: 'webgpu'` marks an effect the WebGL2 backend cannot run, `skipOnLowTier` holds it when `engine.tier` is 'low', `facts` adds a line to `describe().render.post`; all explained on `PostEffect` in `api/post.md`). Each runs in a slot, then by `order` (low first):
74
- `scene` (replaces the scene render, one at a time, e.g. pixelation) -> `hdr` (linear color: outline, AO, bloom) -> tone mapping -> `ldr` (sRGB: LUT,
75
- palette, grain, vignette) -> `final` (FXAA / SMAA). An effect is `{ name, slot, order, params, create(ctx) => pass, update?(pass, params) }`; under
76
- WebGL the pass is any three.js postprocessing Pass, built the first time it is on (on WebGPU an effect gives `node` instead: recipe 56). To read the chain: `engine.post.object()` (the
77
- EffectComposer, null until post first runs) and `engine.post.targets()` (its render targets); both stay the engine's (it rebuilds passes,
78
- resizes, disposes), so change the chain through `engine.post`; to take the built chain over yourself, `engine.post.own()` (the engine stops rebuilding it, `own(false)` gives it back). A plain Pass is placed by its kind: one that renders `engine.scene` itself
79
- (`RenderPixelatedPass`, `SSAARenderPass`, `TAARenderPass`) goes in `scene` and replaces the engine's scene render (the scene is drawn once; a
80
- second one throws), FXAA / SMAA / TAA in `final`, any other in `hdr` after the effects already there; a RenderPass of `engine.scene` and an OutputPass are
81
- skipped (the engine has them). Without `{ name }` it is listed by class or shader name (`CopyShader#1`); its `remove()` does not dispose it.
82
- A game that renders the canvas itself (its own composer) takes the frame: the engine stops drawing and warns once `[own-frame]`.
83
- ```js
51
+ `engine.post.get(name)` returns the same handle. A wrong shape throws with nothing added.
52
+
53
+ `x` is a plain three.js Pass (WebGL), a TSL node function `(input, ctx) => node` (WebGPU), or an effect `{ name, create, node, fuse, slot, order, params, update, needsDepth, needsBuffers, backend, skipOnLowTier, facts }`: both renderers when it gives `create` and `node`, or a `fuse`. `create(ctx) => pass` returns any three.js postprocessing Pass, built the first time the effect is on, and `update?(pass, params)` applies new params (on WebGPU `node`: recipe 56). The optional ones: `needsBuffers` lists extra scene outputs on WebGPU, `backend: 'webgpu'` marks an effect the WebGL2 backend cannot run, `skipOnLowTier` holds it when `engine.tier` is 'low', `facts` adds a line to `describe().render.post`.
54
+
55
+ Each runs in a slot, then by `order` (low first): `scene` (replaces the scene render, one at a time, e.g. pixelation) -> `hdr` (linear color: outline, AO, bloom) -> `tone` (replaces the tone-mapping output, one at a time; it must output display color) -> `ldr` (sRGB: LUT, palette, grain, vignette) -> `final` (FXAA / SMAA).
56
+
57
+ A plain Pass is placed by its kind: one that renders `engine.scene` itself (`RenderPixelatedPass`, `SSAARenderPass`, `TAARenderPass`) goes in `scene` and replaces the engine's scene render (the scene is drawn once; a second one throws), FXAA / SMAA / TAA in `final`, any other in `hdr` after the effects already there (`ldr` when you added it after an OutputPass); a RenderPass of `engine.scene` and an OutputPass are skipped (the engine has them). Without `{ name }` it is listed by class or shader name (`CopyShader#1`); its `remove()` does not dispose it.
58
+
59
+ To read the chain: `engine.post.object()` and `engine.post.targets()`; both stay the engine's (it rebuilds passes, resizes, disposes), so change the chain through `engine.post`; to take the built chain over, `engine.post.own()` (`own(false)` gives it back). A game that renders the canvas itself (its own composer) takes the frame: the engine stops drawing and warns once `[own-frame]`.
60
+ ```js fragment
84
61
  import { bloom, outline, vignette, lut } from '@threedog/post-effects'; // shared effects come from the add-on
85
62
  import { LUTPass } from 'three/addons/postprocessing/LUTPass.js';
86
63
  const line = engine.post.add(outline({ thickness: 1.5 })); engine.post.add(vignette());
@@ -91,42 +68,25 @@ engine.post.add({ name: 'myLut', slot: 'ldr', params: { lut: myLut }, create: ({
91
68
  // a plugin file brings the same effect with no main.js line: plugins/10-bloom.js
92
69
  export default bloom({ strength: 0.2 });
93
70
  ```
94
- - The engine ships no effects. `@threedog/post-effects` (import only what you use) has `bloom`, `ao`, `outline`, `dof` (all `hdr`; outline and dof
95
- read depth) and `lut` (contrast / saturation / warm-cool / optional 3D LUT, or `paletteLut(colors)` for a fixed palette; it reads display colors after the tone curve), `grain`, `vignette`, `chromatic` (`ldr`). An added effect is on
96
- (`enabled: false` adds it off, for `handle.enabled = true` later). The heavy ones (`bloom`, `ao`, `dof`, outline `normal`/`both`) are the game's
97
- call on weak devices: read `engine.tier` before adding them (`threedog shot` renders the desktop tier, `--tier low` checks the low one). To take one
98
- of a pack's effects out: `engine.plugins.off('<pack>/<file>')` or `engine.post.get('ao').enabled = false`; to add one on top: a game plugin file or `engine.post.add`.
99
- - Where to import from:
100
-
101
- | You want | Import |
102
- |---|---|
103
- | Materials and lighting written as TSL | `threedog/tsl` |
104
- | Post effects that run on both routes (bloom, ao, outline, dof, lut, grain) | `@threedog/post-effects` |
105
- | Post effects that exist only on WebGPU (`voxelGI`, `temporalAA`, `sunShafts`, `lightVolumes`) | `@threedog/post-effects/tsl` |
106
- | The three.js layers the engine keeps (`RESERVED_LAYERS`) | `threedog/layers` |
107
-
71
+ - `bloom({ strength, radius, threshold })`, defaults 0.35, 0.5, 0.85: `strength` is how much glow is added, `radius` how far it spreads (0 to 1), `threshold` the brightness a pixel needs before it
72
+ glows at all. It reads linear color before the tone curve, so a surface brighter than 1 glows hard however small it is: if the frame washes out, raise `threshold` or lower that surface's brightness
73
+ before lowering `strength`. On the WebGPU route three's own `BloomNode` is also open to you through `engine.post.add({ node })`.
74
+ - The engine ships no effects. `@threedog/post-effects` (import only what you use) has `bloom`, `ao`, `outline`, `dof` (all `hdr`; outline and dof read depth) and `lut` (contrast / saturation / warm-cool / optional 3D LUT, or
75
+ `paletteLut(colors)` for a fixed palette), `grain`, `vignette`, `chromatic` (`ldr`), each on both routes. `voxelGI`, `temporalAA`, `sunShafts`, `lightVolumes` exist only on WebGPU: `@threedog/post-effects/tsl`. Materials and lighting as TSL: `threedog/tsl`; the three.js layers the engine keeps (`RESERVED_LAYERS`): `threedog/layers`.
76
+ An added effect is on (`enabled: false` adds it off, for `handle.enabled = true` later). The heavy ones (`bloom`, `ao`, `dof`, outline `normal`/`both`) are the game's call on weak devices (`threedog shot` renders the desktop tier, `--tier low` checks the low one).
108
77
  - Depth: an effect that reads scene depth (`needsDepth: true`, e.g. `outline`) must run before any pass that swaps buffers (a `ShaderPass`, a
109
78
  scene-slot pixelation pass, the tone-mapping output). A chain that breaks this throws when the effect is added or enabled, naming both effects;
110
79
  give the depth reader a lower `order`. `dof` keeps the scene depth (`pass.keepsDepth = true`), so `dof` and `outline` can both be on while `dof`
111
80
  has the lower `order` (default: dof 5, outline 10). The other order throws.
112
- - Order of glow and a step-style grade (posterize, palette snap, toon-style color banding, a few-level LUT). Glow (bloom) is a smooth falloff: the
113
- brightest pixels spread a fading halo. A grade that snaps every pixel to a few levels, run **after** the glow, cuts that falloff into flat plateaus:
114
- each plateau is a hard-edged disc, and the middle ones are a flat mid-tone that reads as a grey stain around a light, not as light. It shows in any
115
- art style that mixes glow with banded color (a pixel-art lantern, a flat-shaded neon sign, a cel-shaded campfire, a palette-locked sun), and it
116
- gets worse the fewer levels the grade has. By default `bloom` is an `hdr` effect and a grade is an `ldr` one, so the default order is the bad one.
117
- Ways out, pick by the picture you want: (1) grade first, glow after: give the grade `slot: 'hdr'` and an `order` lower than bloom's, so the glow is
118
- computed from the banded picture and stays smooth (the halo may then use colors outside the palette: fine for soft light, wrong for a strict
119
- palette); (2) keep the grade last and make the glow itself stepped on purpose, one or two clean rings with a threshold, so the discs are a decision
120
- and not a side effect; (3) drop the glow for that picture and paint the light (emissive sprites, a lighter ring in the art). Judge it with a
121
- `threedog shot` close on one bright light against a dark ground: the falloff should read as a gradient (1) or as deliberate rings (2); a grey flat
122
- disc with no gradient and no ring is the trap. Checked on a one-dimensional model of the two orders (a bright source, a blur, a four-level snap): glow
123
- then snap gave plateaus, snap then glow gave a smooth falloff. Not yet checked in a rendered scene with the real passes.
124
- - Pause or unload: `handle.enabled = false` pauses an effect where it is (its place and params stay); `engine.plugins.off('<file>')`
125
- unloads the plugin (the effect leaves the chain; `on` plugs it again). Either way the effect comes back in the same place: inside a slot,
126
- `order` decides, and equal orders keep the order the names were first added in (a plugin's effects are placed in plugin-list order, even
127
- one that starts off), so off / on never reorders the chain.
128
- - On / off is `engine.post.get('bloom').enabled = false` for every effect, whoever added it (there is no `createEngine({ post })`: the engine ships no
129
- effect to switch on, add one with `engine.post.add(bloom())`). The switch is the shared point `post.<name>.enabled`: `enabled` writes its game layer, a hold of your own goes through `engine.mod('post.bloom.enabled', { owner, set, layer })`, and reading `enabled` gives what runs now. MSAA is `engine.post.setAntialias(on)` and works with every effect on. The settings menu shows `bloom` / `ao` toggles only when effects with those names exist; a toggle the player turns off sits on the settings layer of that point, above the game and any hold (`describe().render.post` reads `writer: 'settings'`), and the menu writes nothing for a value it only re-applies unchanged.
81
+ - Order of glow and a step-style grade (posterize, palette snap, a few-level LUT). Glow is a smooth falloff; a grade that snaps every pixel to a few levels, run **after** it, cuts that falloff into flat
82
+ plateaus, and the middle ones read as a grey stain around a light, not as light. It shows in any style that mixes glow with banded color and gets worse the fewer levels the grade has, and the default
83
+ order is the bad one (`bloom` is `hdr`, a grade `ldr`). Ways out, by the picture you want: (1) grade first, glow after: give the grade `slot: 'hdr'` and an `order` lower than bloom's (the halo may then
84
+ use colors outside the palette: fine for soft light, wrong for a strict palette); (2) keep the grade last and make the glow stepped on purpose, one or two clean rings; (3) drop the glow and paint the light
85
+ (emissive sprites, a lighter ring in the art). Judge it with a `threedog shot` close on one bright light against a dark ground: a gradient (1) or deliberate rings (2) are fine; a grey flat disc is the trap.
86
+ This was reasoned on a one-dimensional model of the two orders, not yet checked with the real passes.
87
+ - On / off: `engine.post.get('bloom').enabled = false` for every effect, whoever added it, pauses it where it is (place and params stay); `engine.plugins.off('<file>')` unloads a plugin (the effect leaves the chain; `on` plugs it again; a pack's file: `'<pack>/<file>'`). Either way
88
+ it comes back in the same place: inside a slot `order` decides, and equal orders keep the order the names were first added in. There is no `createEngine({ post })`. The switch is the shared point `post.<name>.enabled`: `enabled` writes its game layer, a hold of your own goes through `engine.mod('post.bloom.enabled', { owner, set, layer })`, and reading `enabled` gives what runs now.
89
+ The settings menu shows `bloom` / `ao` toggles only when effects with those names exist; a toggle the player turns off sits on the settings layer of that point, above the game and any hold (`describe().render.post` reads `writer: 'settings'`). MSAA is `engine.post.antialias = on` and works with every effect on.
130
90
  - `fuse`: a light color effect can skip its own fullscreen pass by carrying a GLSL snippet instead of `create()`:
131
91
  `fuse: { uniforms: { uMyAmount: 'float' }, values: p => ({ uMyAmount: p.amount }), glsl: 'color.rgb *= 1.0 - uMyAmount * length(vUv - 0.5);' }`.
132
92
  Fused effects that are on and next to each other in one slot (never `scene`) compile into one shader and draw in one pass, in `order`. The
@@ -135,39 +95,38 @@ export default bloom({ strength: 0.2 });
135
95
  `engine.post.add({ name, fuse: { glsl }, slot: 'ldr' })` adds just a snippet.
136
96
  - Outline: `outline({ mode: 'depth' | 'normal' | 'both' })`: `depth` (default, silhouettes), `normal` (creases; draws the scene once more with
137
97
  normals, so it costs more), `both`. `fadeWithDistance: false` keeps lines at any distance; `wobble: 1.5` jitters lines by up to 1.5 px at 8 steps a
138
- second. To exempt objects: `outline({ offLayer: OUTLINE_OFF_LAYER })` and `mesh.layers.enable(OUTLINE_OFF_LAYER)` (one extra render of just
139
- those objects; nothing when `offLayer` is `null`).
140
- - Ambient occlusion (darker creases and contact corners): `ao({ radius, intensity })` wraps three's `GTAOPass`; `radius` is in world units
141
- (default 0.25), `intensity` 0..1 (default 1), both change in place: `engine.post.get('ao').set({ radius: 0.6 })`. Order 20 runs it before bloom and the tone mapping. It follows resize,
142
- render scale and MSAA like every effect. It draws the scene once more with normals: points and lines are skipped, and a vertex-moving shader
143
- patch (wind) is not applied there, so swaying leaves get the AO of their rest pose. Cost on a laptop GPU (AMD 780M, 1280x720, MSAA, a street
144
- scene): about +6 ms a frame (4.4 -> 10.7 ms). Other GTAOPass settings (`samples`, `thickness`, `output`):
145
- `engine.post.object().passes.find(p => p.gtaoMaterial)`.
98
+ second. To exempt objects: `outline({ offLayer: OUTLINE_OFF_LAYER })` and `mesh.layers.enable(OUTLINE_OFF_LAYER)` (one extra render of just those objects; nothing when `offLayer` is `null`).
99
+ - Ambient occlusion (darker creases and contact corners): `ao({ radius, intensity })` wraps three's `GTAOPass`; `radius` is in world units, `intensity` 0..1, both change in place: `engine.post.get('ao').set({ radius: 0.6 })`.
100
+ Order 20 runs it before bloom and the tone mapping. It draws the scene once more with normals: points and lines are skipped, and a vertex-moving shader patch (wind) is not applied there, so swaying leaves get the AO of their rest pose.
101
+ Other GTAOPass settings (`samples`, `thickness`, `output`): `engine.post.object().passes.find(p => p.gtaoMaterial)`.
102
+
103
+ ### dof: blur the background (focus blur, bokeh, miniature, tilt shift, cinematic)
104
+ `dof` from `@threedog/post-effects` blurs what is away from the focus distance: `engine.post.add(dof({ focus: 8, range: 3, maxBlur: 5 }))`, then `engine.post.get('dof').set({ focus: distanceToTarget })` each frame for a follow focus. A small `range` and a large `maxBlur` read as a miniature; a long `range` as a soft cinematic backdrop. It is not a shadow setting (`engine.shadows` blur is edge softness).
146
105
 
147
106
  ## Who writes it: the ownership table
148
107
 
149
108
  Some three.js values the engine writes **on its own**, every frame or on a timer: the camera module places the camera, a sky keeps the shadow box around the focus. Lights, fog, exposure and the environment are not among them: the game's `picture/` code is their one writer (recipe 62).
150
- Each of them is registered once (`core/owned.js`), and every one behaves the same way:
109
+ Each of them is registered once (`core/ops/owned.js`), and every one behaves the same way:
151
110
 
152
111
  - **Engine** (default): the engine writes it. Adjust it while the engine keeps driving: the `set` call in the table.
153
- - **Taken** (`manual`): `engine.view.manual('far' | 'fov' | 'pixelRatio')` stops the engine writing it; the three.js value is yours.
112
+ - **Taken** (`manual`): `engine.autoView.manual('far' | 'fov' | 'pixelRatio')` stops the engine writing it; the three.js value is yours.
154
113
  `manual(key, false)` (or the handle's `remove()`) gives it back. No module option starts a value taken over.
155
114
  - **Written directly** without `manual`: the engine notices, **stops writing it and keeps your value**, and warns once with the `manual` call and the
156
115
  hand-back call. This happens in release builds too (only the warning is dev-only), so a game behaves the same with and without checks.
157
116
  - A `timeline.tween` on an object is a temporary takeover of that object only: no warning, no hand-over (other objects stay checked).
158
117
 
159
- `engine.describe().owned` lists every registered value and who writes it now, as `writer` (`engine`, `manual:game`,
160
- `three (engine yielded)`). A test (`tests/specs/owned.mjs`) runs the three
161
- behaviors for every registered value and fails when one is registered without a row here.
118
+ `engine.describe().owned` lists every registered value and who writes it now, as `writer` (`engine`, `manual:game`, `three (engine yielded)`).
162
119
 
163
120
  | id | part | written when | take it | adjust while the engine drives |
164
121
  |---|---|---|---|---|
165
122
  | `shadow.follow` | shadow | the box on the engine sun: under a sky every frame (center = `sun.target`); without one the placeholder sun follows `engine.focus` | `engine.shadows.box(engine.lights.sun, { follow: false })` | `engine.shadows.box(engine.lights.sun, { extent })` |
166
123
  | `toneMapping` | tone | never: `renderer.toneMapping` stays three.js's default until your code writes it | `engine.renderer.toneMapping = THREE.ACESFilmicToneMapping`; an own curve as a post stage: `engine.post.add({ name, slot: 'tone', create })` (or `node` on WebGPU; replaces OutputPass / renderOutput; outputs display color) | - |
167
124
  | `background` | sky | sky: a backdrop color or skybox every frame; with the dome the dome hides when you take it | `scene.background = x` (the dome hides); whole sky: `engine.sky.replace(texture \| object3D)` | `engine.sky.backdrop = '#335577'` |
168
- | `view.far` | view | terrain view range (`setViewChunks`) | `engine.view.manual('far')` | - |
169
- | `view.fov` | view | the settings menu fov slider, camera modules (first person / rts fov, fixed shots, back to the install fov on a switch) | `engine.view.manual('fov')` | - |
170
- | `view.pixelRatio` | view | adaptive resolution, about once a second while slow | `engine.view.manual('pixelRatio')` | `engine.setPixelRatio(1.5)` |
125
+ | `view.aspect` | view | every resize | `engine.autoView.manual('aspect')` | - |
126
+ | `sky.sunDir` | view | `sky()` each frame, from the time and `engine.sky.orbit` (the same vector as `uSunDir`) | `engine.autoView.manual('sunDir')` | - |
127
+ | `view.far` | view | terrain view range (`terrain.viewChunks`) | `engine.autoView.manual('far')` | - |
128
+ | `view.fov` | view | the settings menu fov slider, camera modules (first person / rts fov, fixed shots, back to the install fov on a switch) | `engine.autoView.manual('fov')` | - |
129
+ | `view.pixelRatio` | view | adaptive resolution, about once a second while slow | `engine.autoView.manual('pixelRatio')` | `engine.setPixelRatio(1.5)` |
171
130
  | `camera` (position, rotation) | view | the camera module, every frame | `const cam = engine.takeCamera('me')` (`cam.remove()` gives it back) | - |
172
131
  | `post.chain` | post | whenever the effect list changes (add / remove / on / off, MSAA): the engine rebuilds the composer passes (WebGL) or `pipeline.outputNode` (WebGPU) | `engine.post.own()`: the built chain stays as you left it in `engine.post.object()`; `own(false)` rebuilds it from the list. A write to `object()` without `own()` does not yield: the next chain change replaces it | `engine.post.get('bloom').set({ strength: 0.6 })` |
173
132
  | `shadow.csm` (not a property: a list) | shadow | while cascades are on: the `csm` patch goes on every built-in lit material, yours too (else N times as bright) | - (`handle.remove()`); your ShaderMaterial is left alone until `engine.shadows.include(mat)` | - |
@@ -176,6 +135,3 @@ Not in this table, because the engine writes them once rather than keeps writing
176
135
  and says so once in the dev console and in `describe().perf.batching`; turn it off per object with `userData.batch = false`, see
177
136
  [05-props-bake.md](05-props-bake.md) §2b) and `castShadow` on generator props (set when the model is made: a generator's own flags are kept, the
178
137
  manifest entry can set them; change it on the object afterwards).
179
-
180
- ## Lower-level forms that stay
181
-