threedog 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +21 -13
  3. package/core/Assets.js +23 -12
  4. package/core/Audio.js +1 -1
  5. package/core/Baked.js +14 -23
  6. package/core/Budget.js +2 -2
  7. package/core/DebugOverrides.js +33 -18
  8. package/core/Describe.js +10 -11
  9. package/core/Engine.js +50 -46
  10. package/core/I18n.js +2 -2
  11. package/core/Input.js +11 -5
  12. package/core/Inspect.js +6 -3
  13. package/core/InspectMaterials.js +2 -3
  14. package/core/InspectPerf.js +11 -4
  15. package/core/MaterialInfo.js +7 -5
  16. package/core/Rays.js +7 -2
  17. package/core/Stream.js +2 -3
  18. package/core/UrlState.js +49 -9
  19. package/core/Views.js +1 -0
  20. package/core/adaptive.js +2 -2
  21. package/core/assetEntry.js +5 -2
  22. package/core/assetLoad.js +13 -15
  23. package/core/assetManifest.js +6 -3
  24. package/core/assetReport.js +4 -4
  25. package/core/batchGroups.js +9 -1
  26. package/core/catalog.js +16 -3
  27. package/core/chunkStream.js +1 -1
  28. package/core/copies.js +1 -1
  29. package/core/debugView.js +4 -4
  30. package/core/describeRender.js +104 -28
  31. package/core/describeText.js +6 -6
  32. package/core/errorCodes.js +72 -45
  33. package/core/errorHints.js +4 -1
  34. package/core/errors.js +4 -4
  35. package/core/events.generated.js +1 -0
  36. package/core/gameLights.js +9 -2
  37. package/core/lifecycle.js +2 -4
  38. package/core/lightWatch.js +5 -3
  39. package/core/loop.js +18 -11
  40. package/core/math.js +7 -0
  41. package/core/moduleSlots.js +32 -7
  42. package/core/moduleTypes.js +20 -7
  43. package/core/modules.js +7 -7
  44. package/core/namedModel.js +8 -4
  45. package/core/owned.js +33 -30
  46. package/core/page.js +43 -10
  47. package/core/pictureSlots.js +33 -0
  48. package/core/pictureWriters.js +343 -0
  49. package/core/plugins.js +64 -96
  50. package/core/sceneDelta.js +12 -4
  51. package/core/sceneMethods.js +2 -9
  52. package/core/services.js +1 -1
  53. package/core/shadowTypes.js +1 -1
  54. package/core/shadows.js +405 -0
  55. package/core/sharedPoint.js +5 -19
  56. package/core/stackFrames.js +16 -5
  57. package/core/stacks.js +6 -6
  58. package/core/startup.js +9 -11
  59. package/core/thingExplain.js +1 -1
  60. package/core/things.js +1 -1
  61. package/core/tier.js +1 -1
  62. package/core/util.js +1 -1
  63. package/core/validate.js +1 -1
  64. package/core/view.js +43 -0
  65. package/docs/AI.md +62 -58
  66. package/docs/API.md +15 -15
  67. package/docs/CODEMAP.md +36 -54
  68. package/docs/COMMANDS.md +28 -25
  69. package/docs/CONVENTIONS.md +36 -30
  70. package/docs/MIGRATING-0.4.md +93 -1
  71. package/docs/MIGRATING-0.6.md +126 -0
  72. package/docs/MIGRATING-0.7.md +39 -0
  73. package/docs/THREE.md +24 -22
  74. package/docs/api/assets.md +5 -3
  75. package/docs/api/audio.md +2 -2
  76. package/docs/api/budget.md +4 -0
  77. package/docs/api/characters.md +3 -1
  78. package/docs/api/collision.md +2 -2
  79. package/docs/api/engine.md +47 -20
  80. package/docs/api/events.md +2 -1
  81. package/docs/api/grids.md +8 -1
  82. package/docs/api/ground.md +1 -1
  83. package/docs/api/hud.md +3 -0
  84. package/docs/api/input.md +3 -2
  85. package/docs/api/interactions.md +3 -1
  86. package/docs/api/inventory.md +1 -2
  87. package/docs/api/level.md +0 -1
  88. package/docs/api/lightPool.md +1 -1
  89. package/docs/api/occlusion.md +5 -0
  90. package/docs/api/particles.md +6 -3
  91. package/docs/api/pickups.md +6 -0
  92. package/docs/api/post.md +5 -3
  93. package/docs/api/sky.md +12 -10
  94. package/docs/api/terrain.md +12 -6
  95. package/docs/api/terrainDraw.md +12 -0
  96. package/docs/api/tools.md +8 -7
  97. package/docs/api/triggers.md +2 -0
  98. package/docs/api/vegetation.md +7 -2
  99. package/docs/api/vegetationDraw.md +10 -0
  100. package/docs/api/water.md +6 -2
  101. package/docs/api/weather.md +5 -0
  102. package/docs/api/weatherDraw.md +10 -0
  103. package/docs/api/world.md +1 -1
  104. package/docs/recipes/01-new-game.md +19 -23
  105. package/docs/recipes/03-items-pickups.md +25 -4
  106. package/docs/recipes/05-props-bake.md +53 -37
  107. package/docs/recipes/06-clock-events.md +3 -3
  108. package/docs/recipes/07-flow-scenes-pause.md +12 -3
  109. package/docs/recipes/08-weather-sky.md +45 -57
  110. package/docs/recipes/09-materials-lights-models.md +185 -0
  111. package/docs/recipes/10-blender-level.md +2 -2
  112. package/docs/recipes/11-vehicles.md +3 -3
  113. package/docs/recipes/13-animation.md +13 -7
  114. package/docs/recipes/14-custom-module.md +7 -5
  115. package/docs/recipes/15-perf.md +3 -3
  116. package/docs/recipes/16-dev-bridge.md +22 -12
  117. package/docs/recipes/18-world.md +10 -8
  118. package/docs/recipes/19-shooting-picking.md +7 -5
  119. package/docs/recipes/20-content-actions-save.md +6 -2
  120. package/docs/recipes/21-camera.md +8 -3
  121. package/docs/recipes/23-ops.md +1 -1
  122. package/docs/recipes/26-ui-parts.md +35 -11
  123. package/docs/recipes/28-terrain.md +12 -12
  124. package/docs/recipes/29-grid.md +14 -5
  125. package/docs/recipes/30-templates.md +8 -3
  126. package/docs/recipes/31-audio.md +4 -4
  127. package/docs/recipes/32-action-game.md +18 -4
  128. package/docs/recipes/34-environment-lighting.md +102 -38
  129. package/docs/recipes/35-picture-from-reference.md +147 -0
  130. package/docs/recipes/36-sky-ground-plants.md +158 -0
  131. package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
  132. package/docs/recipes/38-environment-hooks.md +67 -0
  133. package/docs/recipes/40-scene.md +106 -27
  134. package/docs/recipes/42-terrain-shape.md +1 -1
  135. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
  136. package/docs/recipes/44-water-weather-hooks.md +191 -0
  137. package/docs/recipes/45-cascaded-shadows.md +121 -23
  138. package/docs/recipes/46-blender-art-route.md +17 -20
  139. package/docs/recipes/47-island-snow-backdrop.md +10 -12
  140. package/docs/recipes/49-game-module-contract.md +1 -1
  141. package/docs/recipes/50-own-renderer.md +3 -3
  142. package/docs/recipes/52-around-the-picture.md +181 -0
  143. package/docs/recipes/53-ground-up-close.md +12 -12
  144. package/docs/recipes/54-three-idioms.md +18 -18
  145. package/docs/recipes/55-mods-time-wrap.md +17 -5
  146. package/docs/recipes/56-webgpu-tsl.md +66 -23
  147. package/docs/recipes/57-control.md +39 -0
  148. package/docs/recipes/58-input.md +3 -0
  149. package/docs/recipes/59-depth-post-effects.md +5 -5
  150. package/docs/recipes/60-judge-the-picture.md +39 -24
  151. package/docs/recipes/61-deploy.md +27 -0
  152. package/docs/recipes/62-picture-code.md +244 -0
  153. package/docs/recipes/63-third-person-start.md +77 -0
  154. package/docs/recipes/64-particles.md +35 -0
  155. package/examples/action/.threedog/content-index.json +1 -1
  156. package/examples/action/GAMEMAP.md +7 -5
  157. package/examples/action/main.js +5 -4
  158. package/examples/action/models.js +12 -14
  159. package/examples/action/picture/index.js +13 -0
  160. package/examples/action/picture/lights.js +35 -0
  161. package/examples/action/picture/materials.js +8 -0
  162. package/examples/action/picture/palette.js +33 -0
  163. package/examples/plain-picture/.threedog/content-index.json +1 -0
  164. package/examples/plain-picture/FINDINGS.md +53 -0
  165. package/examples/plain-picture/GAMEMAP.md +90 -0
  166. package/examples/plain-picture/main.js +48 -0
  167. package/examples/plain-picture/picture/index.js +21 -0
  168. package/examples/plain-picture/picture/lights.js +54 -0
  169. package/examples/plain-picture/picture/materials.js +24 -0
  170. package/examples/plain-picture/picture/palette.js +16 -0
  171. package/examples/plain-picture/picture/sky.js +37 -0
  172. package/examples/pullable.json +31 -9
  173. package/examples/rc2d/GAMEMAP.md +8 -3
  174. package/examples/rc2d/README.md +11 -6
  175. package/examples/rc2d/main.js +25 -33
  176. package/examples/rc2d/picture/index.js +18 -0
  177. package/examples/rc2d/picture/lights.js +11 -0
  178. package/examples/rc2d/picture/materials.js +18 -0
  179. package/examples/rc2d/picture/palette.js +15 -0
  180. package/examples/rc2d/picture/post.js +11 -0
  181. package/examples/rc2d/rc2d.js +18 -28
  182. package/examples/sheepisland/.threedog/content-index.json +1 -1
  183. package/examples/sheepisland/GAMEMAP.md +13 -10
  184. package/examples/sheepisland/assets.js +2 -2
  185. package/examples/sheepisland/content/templates.js +1 -1
  186. package/examples/sheepisland/content/vegetation.js +3 -1
  187. package/examples/sheepisland/main.js +15 -9
  188. package/examples/sheepisland/{style/models.js → models.js} +13 -24
  189. package/examples/sheepisland/picture/index.js +20 -0
  190. package/examples/sheepisland/picture/lights.js +34 -0
  191. package/examples/sheepisland/picture/materials.js +61 -0
  192. package/examples/sheepisland/picture/palette.js +60 -0
  193. package/examples/sheepisland/picture/sky.js +20 -0
  194. package/examples/sheepisland/views.js +1 -1
  195. package/examples/styletest/.threedog/content-index.json +1 -1
  196. package/examples/styletest/GAMEMAP.md +15 -11
  197. package/examples/styletest/main.js +20 -30
  198. package/examples/styletest/models.js +29 -29
  199. package/examples/styletest/params.js +1 -4
  200. package/examples/styletest/picture/env.js +38 -0
  201. package/examples/styletest/picture/index.js +16 -0
  202. package/examples/styletest/picture/lights.js +9 -0
  203. package/examples/styletest/picture/materials.js +28 -0
  204. package/examples/styletest/picture/palette.js +22 -0
  205. package/examples/techniques/contact-shadows/README.md +22 -23
  206. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  207. package/examples/techniques/contact-shadows/main.js +20 -18
  208. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  209. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  210. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  211. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  212. package/examples/techniques/day-night-grade/README.md +13 -16
  213. package/examples/techniques/day-night-grade/main.js +15 -25
  214. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  215. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  216. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  217. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  218. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  219. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  220. package/examples/techniques/interior-light/README.md +16 -13
  221. package/examples/techniques/interior-light/interiorLight.js +19 -17
  222. package/examples/techniques/interior-light/main.js +30 -67
  223. package/examples/techniques/interior-light/picture/index.js +24 -0
  224. package/examples/techniques/interior-light/picture/lights.js +52 -0
  225. package/examples/techniques/interior-light/picture/materials.js +13 -0
  226. package/examples/techniques/interior-light/picture/palette.js +32 -0
  227. package/examples/techniques/interior-light/picture/sky.js +40 -0
  228. package/examples/techniques/modular-building/README.md +4 -3
  229. package/examples/techniques/modular-building/kit.js +2 -2
  230. package/examples/techniques/modular-building/main.js +9 -17
  231. package/examples/techniques/modular-building/picture/index.js +17 -0
  232. package/examples/techniques/modular-building/picture/lights.js +26 -0
  233. package/examples/techniques/modular-building/picture/materials.js +13 -0
  234. package/examples/techniques/modular-building/picture/palette.js +23 -0
  235. package/examples/techniques/night-lights/README.md +15 -14
  236. package/examples/techniques/night-lights/main.js +20 -43
  237. package/examples/techniques/night-lights/nightLights.js +25 -21
  238. package/examples/techniques/night-lights/picture/index.js +18 -0
  239. package/examples/techniques/night-lights/picture/lights.js +44 -0
  240. package/examples/techniques/night-lights/picture/materials.js +15 -0
  241. package/examples/techniques/night-lights/picture/palette.js +34 -0
  242. package/examples/techniques/night-lights/picture/post.js +9 -0
  243. package/examples/techniques/night-lights/picture/sky.js +36 -0
  244. package/examples/techniques/outlines-and-rim/README.md +2 -2
  245. package/examples/techniques/outlines-and-rim/main.js +15 -38
  246. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  247. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  248. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  249. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  250. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  251. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  252. package/examples/techniques/procedural-animation/README.md +5 -3
  253. package/examples/techniques/procedural-animation/main.js +9 -7
  254. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  255. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  256. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  257. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  258. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  259. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  260. package/examples/techniques/procedural-surface/README.md +2 -0
  261. package/examples/techniques/procedural-surface/main.js +17 -55
  262. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  263. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  264. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  265. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  266. package/examples/techniques/stylized-shading/README.md +13 -14
  267. package/examples/techniques/stylized-shading/main.js +11 -42
  268. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  269. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  270. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  271. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  272. package/examples/techniques/stylized-shading/shading.js +2 -2
  273. package/examples/techniques/sun-and-key-light/README.md +20 -22
  274. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  275. package/examples/techniques/sun-and-key-light/main.js +19 -63
  276. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  277. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  278. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  279. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  280. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  281. package/examples/techniques/three-looks/README.md +21 -0
  282. package/examples/techniques/three-looks/main.js +58 -0
  283. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  284. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  285. package/examples/techniques/three-looks/picture/comic.js +27 -0
  286. package/examples/techniques/three-looks/picture/index.js +14 -0
  287. package/examples/techniques/three-looks/picture/sun.js +23 -0
  288. package/examples/techniques/wet-road/README.md +7 -4
  289. package/examples/techniques/wet-road/main.js +18 -38
  290. package/examples/techniques/wet-road/picture/index.js +17 -0
  291. package/examples/techniques/wet-road/picture/lights.js +57 -0
  292. package/examples/techniques/wet-road/picture/materials.js +16 -0
  293. package/examples/techniques/wet-road/picture/palette.js +24 -0
  294. package/examples/techniques/wet-road/picture/sky.js +46 -0
  295. package/examples/webgpu-tsl/GAMEMAP.md +9 -4
  296. package/examples/webgpu-tsl/README.md +13 -10
  297. package/examples/webgpu-tsl/main.js +30 -7
  298. package/examples/webgpu-tsl/picture/index.js +18 -0
  299. package/examples/webgpu-tsl/picture/lights.js +25 -0
  300. package/examples/webgpu-tsl/picture/materials.js +36 -0
  301. package/examples/webgpu-tsl/picture/palette.js +23 -0
  302. package/examples/webgpu-tsl/picture/post.js +16 -0
  303. package/examples/webgpu-tsl/picture/sky.js +30 -0
  304. package/examples/world/.threedog/content-index.json +1 -1
  305. package/examples/world/GAMEMAP.md +15 -12
  306. package/examples/world/art/humanoid.js +9 -13
  307. package/examples/world/art/index.js +2 -2
  308. package/examples/world/art/models.js +3 -4
  309. package/examples/world/art/shapes.js +2 -2
  310. package/examples/world/assets.js +2 -2
  311. package/examples/world/content/audio.js +1 -1
  312. package/examples/world/content/items.js +1 -1
  313. package/examples/world/content/props.js +1 -1
  314. package/examples/world/content/templates.js +1 -1
  315. package/examples/world/content/vegetation.js +1 -1
  316. package/examples/world/main.js +10 -10
  317. package/examples/world/models.js +17 -7
  318. package/examples/world/picture/index.js +20 -0
  319. package/examples/world/picture/lights.js +41 -0
  320. package/examples/world/picture/materials.js +34 -0
  321. package/examples/world/picture/palette.js +74 -0
  322. package/examples/world/picture/post.js +9 -0
  323. package/examples/world/picture/sky.js +39 -0
  324. package/index.d.ts +7 -16
  325. package/index.js +7 -7
  326. package/llms.txt +15 -13
  327. package/modules/ambience/Ambience.js +1 -1
  328. package/modules/calendar/Calendar.js +1 -1
  329. package/modules/calendar/index.js +1 -0
  330. package/modules/camera/FirstPersonCamera.js +1 -1
  331. package/modules/camera/FixedCamera.js +2 -2
  332. package/modules/camera/RtsCamera.js +1 -1
  333. package/modules/camera/common.js +7 -5
  334. package/modules/characters/Character.js +15 -10
  335. package/modules/characters/NPC.js +5 -5
  336. package/modules/characters/assetModel.js +5 -4
  337. package/modules/characters/index.js +28 -3
  338. package/modules/characters/movers/common.js +6 -1
  339. package/modules/characters/movers/manual.js +3 -0
  340. package/modules/characters/movers/support.js +25 -11
  341. package/modules/characters/npcSim.js +5 -1
  342. package/modules/characters/proceduralRig.js +18 -4
  343. package/modules/characters/useModel.js +2 -2
  344. package/modules/collision/Collision.js +4 -2
  345. package/modules/content/index.js +8 -0
  346. package/modules/content/models.js +56 -11
  347. package/modules/content/props.js +5 -3
  348. package/modules/content/rules.js +12 -4
  349. package/modules/content/templates.js +5 -3
  350. package/modules/gameplay/Interactions.js +91 -16
  351. package/modules/gameplay/Inventory.js +3 -3
  352. package/modules/gameplay/dialogueBox.js +1 -1
  353. package/modules/gameplay/dialogueBubbles.js +1 -1
  354. package/modules/gameplay/interactionPrompt.js +1 -1
  355. package/modules/gameplay/interactions.contract.js +1 -1
  356. package/modules/gameplay/inventoryOps.js +2 -2
  357. package/modules/gameplay/pickups.js +62 -24
  358. package/modules/gameplay/questLog.js +2 -2
  359. package/modules/grid/Layer.js +13 -0
  360. package/modules/grid/index.js +40 -11
  361. package/modules/grid/preview.js +24 -15
  362. package/modules/grid/tiles.js +15 -19
  363. package/modules/hlod/index.js +3 -2
  364. package/modules/hud/index.js +13 -0
  365. package/modules/hud/parts.js +9 -7
  366. package/modules/level/index.js +5 -4
  367. package/modules/lights/index.js +12 -8
  368. package/modules/music/Music.js +1 -1
  369. package/modules/particles/Particles.js +41 -20
  370. package/modules/particles/effect.js +21 -6
  371. package/modules/photo/Photo.js +11 -10
  372. package/modules/settings/Settings.js +7 -7
  373. package/modules/settings/apply.js +5 -5
  374. package/modules/settings/sections.js +2 -2
  375. package/modules/settings/strings.js +1 -1
  376. package/modules/sky/Sky.js +104 -89
  377. package/modules/sky/clouds.js +16 -17
  378. package/modules/sky/dome.js +100 -0
  379. package/modules/sky/domeLayers.js +5 -5
  380. package/modules/sky/environment.js +45 -169
  381. package/modules/sky/fog.js +5 -180
  382. package/modules/sky/frame.js +26 -90
  383. package/modules/sky/season.js +3 -3
  384. package/modules/sky/shader.js +35 -29
  385. package/modules/sky/skyModule.js +25 -22
  386. package/modules/sky/tint.js +9 -11
  387. package/modules/terrain/ChunkManager.js +29 -12
  388. package/modules/terrain/draw.js +154 -0
  389. package/modules/terrain/index.js +44 -66
  390. package/modules/terrain/terrainDefaults.js +2 -2
  391. package/modules/terrain/terrainEdit.js +1 -1
  392. package/modules/terrain/terrainGen.js +2 -2
  393. package/modules/triggers/index.js +10 -6
  394. package/modules/vegetation/Vegetation.js +58 -17
  395. package/modules/vegetation/draw.js +191 -0
  396. package/modules/vegetation/groundChunks.js +1 -1
  397. package/modules/vegetation/index.js +10 -10
  398. package/modules/water/Water.js +135 -88
  399. package/modules/water/surface.js +53 -53
  400. package/modules/weather/Weather.js +52 -17
  401. package/modules/weather/particles.js +13 -5
  402. package/modules/weather/shaders.js +1 -1
  403. package/modules/weather/weatherDraw.js +141 -0
  404. package/modules/world/World.js +2 -2
  405. package/modules/world/views.js +1 -1
  406. package/package.json +3 -2
  407. package/presets.js +2 -2
  408. package/render/PostFX.js +199 -41
  409. package/render/backend.js +52 -6
  410. package/render/cascades.js +195 -0
  411. package/render/cascades.tsl.js +96 -0
  412. package/render/daylight.js +39 -0
  413. package/render/detail.js +5 -5
  414. package/render/effects.js +41 -26
  415. package/render/fx/cel.tsl.js +42 -0
  416. package/render/fx/index.js +7 -5
  417. package/render/fx/patchNodes.tsl.js +1 -1
  418. package/render/fx/postWebGPU.tsl.js +30 -7
  419. package/render/fx/sky.tsl.js +19 -92
  420. package/render/fx/water.tsl.js +1 -1
  421. package/render/layers.js +14 -0
  422. package/render/lighting.js +6 -5
  423. package/render/lightmap.js +142 -0
  424. package/render/lights.js +23 -201
  425. package/render/materials.js +44 -160
  426. package/render/neutral.js +23 -0
  427. package/render/occlusion.js +184 -0
  428. package/render/ownFrame.js +1 -1
  429. package/render/patches.js +34 -29
  430. package/render/postWebGL.js +11 -3
  431. package/render/probes.js +179 -122
  432. package/render/slots.js +4 -4
  433. package/render/terms.js +53 -101
  434. package/render/uniformDecl.js +1 -1
  435. package/types/core.d.ts +333 -296
  436. package/types/gameplay.d.ts +65 -26
  437. package/types/generated/core/Audio.d.ts +1 -1
  438. package/types/generated/core/DebugOverrides.d.ts +14 -6
  439. package/types/generated/core/Input.d.ts +9 -2
  440. package/types/generated/core/page.d.ts +9 -2
  441. package/types/generated/modules/grid/Layer.d.ts +8 -0
  442. package/types/generated/modules/grid/index.d.ts +29 -5
  443. package/types/generated/modules/particles/Particles.d.ts +13 -6
  444. package/types/generated/modules/sky/Sky.d.ts +85 -18
  445. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  446. package/types/generated/modules/water/Water.d.ts +50 -3
  447. package/types/generated/modules/weather/Weather.d.ts +33 -3
  448. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  449. package/types/generated/modules/world/World.d.ts +2 -2
  450. package/types/generated/render/PostFX.d.ts +53 -10
  451. package/types/generated/render/lighting.d.ts +29 -0
  452. package/types/generated/render/materials.d.ts +19 -44
  453. package/types/generated/render/occlusion.d.ts +13 -0
  454. package/types/physics.d.ts +5 -3
  455. package/types/tsl.d.ts +8 -0
  456. package/types/world.d.ts +376 -57
  457. package/ui/Focus.js +12 -2
  458. package/ui/LoadingScreen.js +2 -2
  459. package/ui/Parts.js +8 -4
  460. package/ui/UI.js +10 -10
  461. package/ui/cursor.js +1 -1
  462. package/ui/theme.js +33 -27
  463. package/ui/touchPart.js +1 -1
  464. package/core/look/coreParts.js +0 -219
  465. package/core/look/part.js +0 -253
  466. package/core/look/points.js +0 -255
  467. package/core/look/report.js +0 -96
  468. package/core/look/shadowPart.js +0 -63
  469. package/core/look/state.js +0 -45
  470. package/core/look/write.js +0 -70
  471. package/core/styleParts.js +0 -114
  472. package/docs/api/style.md +0 -136
  473. package/docs/api/terrainLook.md +0 -10
  474. package/docs/api/vegetationLook.md +0 -10
  475. package/docs/api/weatherLook.md +0 -10
  476. package/docs/recipes/09-style.md +0 -218
  477. package/docs/recipes/35-style-from-reference.md +0 -153
  478. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  479. package/docs/recipes/38-environment-look-hooks.md +0 -99
  480. package/docs/recipes/41-thing-registry.md +0 -97
  481. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  482. package/docs/recipes/48-make-material.md +0 -75
  483. package/docs/recipes/52-look.md +0 -282
  484. package/examples/action/look.js +0 -5
  485. package/examples/sheepisland/style/index.js +0 -79
  486. package/examples/styletest/look.js +0 -11
  487. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  488. package/examples/webgpu-tsl/tslScene.js +0 -75
  489. package/examples/world/style/index.js +0 -61
  490. package/examples/world/style/plugins/10-bloom.js +0 -5
  491. package/modules/sky/cascades.js +0 -186
  492. package/modules/sky/cascades.tsl.js +0 -82
  493. package/modules/sky/look.js +0 -54
  494. package/modules/sky/lookFog.js +0 -76
  495. package/modules/sky/lookShadow.js +0 -62
  496. package/modules/sky/lookSky.js +0 -169
  497. package/modules/sky/shadow.js +0 -98
  498. package/modules/terrain/look.js +0 -83
  499. package/modules/terrain/lookGround.js +0 -66
  500. package/modules/vegetation/look.js +0 -119
  501. package/modules/vegetation/lookWind.js +0 -98
  502. package/modules/water/look.js +0 -91
  503. package/modules/water/surfaceDefaults.js +0 -3
  504. package/modules/weather/look.js +0 -74
  505. package/modules/weather/weatherLook.js +0 -135
  506. package/render/lookGlow.js +0 -139
  507. package/render/lookSurface.js +0 -224
  508. package/render/postLook.js +0 -164
  509. package/render/surface.js +0 -105
  510. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  511. package/types/style.d.ts +0 -671
package/docs/CODEMAP.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Each module's requires, order, params, ops, saves: `threedog catalog <module>`.
8
8
 
9
- Type = what the module may own (core/moduleTypes.js): world, look, actor, rules, ui, net, tool.
9
+ Type = what the module may own (core/moduleTypes.js): world, picture, actor, rules, ui, net, tool.
10
10
 
11
11
  | Module (engine.xxx) | Type | File |
12
12
  |---|---|---|
@@ -18,17 +18,16 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
18
18
  | vegetation | world | modules/vegetation/index.js |
19
19
  | world | world | modules/world/index.js |
20
20
  | calendar | world | modules/calendar/index.js |
21
- | sky | look | modules/sky/skyModule.js |
22
- | water | look | modules/water/Water.js |
21
+ | sky | picture | modules/sky/skyModule.js |
22
+ | water | picture | modules/water/Water.js |
23
23
  | weather | world | modules/weather/Weather.js |
24
- | weatherLook | look | modules/weather/weatherLook.js |
25
- | interactions | rules | modules/gameplay/Interactions.js |
24
+ | weatherDraw | picture | modules/weather/weatherDraw.js |
26
25
  | pickups | rules | modules/gameplay/pickups.js |
27
26
  | grids | world | modules/grid/index.js |
28
27
  | triggers | rules | modules/triggers/index.js |
29
- | particles | look | modules/particles/Particles.js |
30
- | terrainLook | look | modules/terrain/index.js |
31
- | vegetationLook | look | modules/vegetation/index.js |
28
+ | particles | picture | modules/particles/Particles.js |
29
+ | terrainDraw | picture | modules/terrain/index.js |
30
+ | vegetationDraw | picture | modules/vegetation/index.js |
32
31
  | content | rules | modules/content/index.js |
33
32
  | inventory | rules | modules/gameplay/Inventory.js |
34
33
  | quests | rules | modules/gameplay/Quests.js |
@@ -90,7 +89,7 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
90
89
  - copies.js: Two copies of the engine on one page (e.g
91
90
  - dayTime.js: 'HH:MM' <-> day fraction
92
91
  - debugView.js: Diagnostic view modes behind engine.debug.view('albedo' / '…
93
- - describeRender.js: describe().render: renderer, post, lights and probes
92
+ - describeRender.js: describe().picture: what three.js holds right now, read str…
94
93
  - describeText.js: engine.describeText(): write describe() as plain English fo…
95
94
  - easing.js: Easing functions: input progress 0..1, output 0..1 (back/el…
96
95
  - engineCamera.js: engine.camera's class: a THREE.PerspectiveCamera that can a…
@@ -112,7 +111,6 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
112
111
  - inputTouch.js: The touch part of input: which on-screen controls the game …
113
112
  - lifecycle.js: Engine lifecycle: dispose() and counts() for leak hunting
114
113
  - lightWatch.js: Dev-only check (called from loop.js after each render once …
115
- - look/ engine.look.<part>: what a game calls — coreParts.js, part.js, points.js, report.js, shadowPart.js, state.js, write.js
116
114
  - loop.js: Main loop (part of Engine, mixed into Engine.prototype): fi…
117
115
  - math.js: Small shared helpers
118
116
  - moduleSlots.js: Exclusive slots for modules ("only one may hold this": 'sky…
@@ -130,6 +128,8 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
130
128
  - owned.js: One ownership model for every property the engine writes on…
131
129
  - page.js: engine.page: the one place that listens to the browser wind…
132
130
  - params.js: Param schemas: one plain-object description per field, shar…
131
+ - pictureSlots.js: The names of the picture values only one writer may hold: t…
132
+ - pictureWriters.js: "Who wrote this picture value": the last file:line that cha…
133
133
  - plugins.js: engine.plugins: the plugins folder (docs/plans/2026-11-03-s…
134
134
  - pureWorker.js: Worker that runs pure-function batches for engine.threads (…
135
135
  - saveApply.js: Applying a save (split out of Saves.js): every part is chec…
@@ -145,6 +145,7 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
145
145
  - session.js: engine.session: one playthrough, from "new game" or "load" …
146
146
  - shaderCost.js: Approximate shader cost per compiled program, for engine.de…
147
147
  - shadowTypes.js: three 0.187 shadow filters
148
+ - shadows.js: engine.shadows: the shadow engineering in three.js shape: e…
148
149
  - sharedPoint.js: Shared points: the ONE way several owners change a shared t…
149
150
  - skip.js: engine.skip: jump time in segments
150
151
  - stackFrames.js: Read 'file.js:50' places out of an Error stack: where a thi…
@@ -152,7 +153,6 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
152
153
  - startup.js: Startup (part of Engine, mixed into Engine.prototype): star…
153
154
  - streamCells.js: Per-chunk view of stream sources for loaders that sync whol…
154
155
  - streamSources.js: Stream sources (internal half of engine.stream): the places…
155
- - styleParts.js: A style built from parts: createEngine({ style: [basePack, …
156
156
  - targeting.js: Target selection: pure functions (no camera, input or engin…
157
157
  - textureBytes.js: Estimated GPU bytes of a three.js texture (engine.inspect.m…
158
158
  - thingExplain.js: engine.thing(id).explain(): everything known about one id i…
@@ -166,6 +166,7 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
166
166
  - uiClock.js: UI timers on the page clock
167
167
  - util.js: Small shared core helpers
168
168
  - validate.js: Runtime checks: when an option or name is misspelled, print…
169
+ - view.js: engine.view: the camera and drawing-buffer values the engin…
169
170
  - wrap.js: engine.wrap: the one entry for changing what a module's pub…
170
171
 
171
172
  **modules/** (one line per folder: what it does; its files besides the index.js / contract.js every module has)
@@ -190,39 +191,42 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
190
191
  - photo/ Photo mode: a sharper shot, then restore — Photo.js
191
192
  - rigid/ Real physics (Rapier): objects that topple, roll, get pushed an… — RigidBodies.js, Vehicles.js, sync.js
192
193
  - settings/ Settings menu module entry — Settings.js, apply.js, sections.js, strings.js, view.js
193
- - sky/ look.sky: the sky dome as a look part — Sky.js, cascades.js, cascades.tsl.js, clouds.js, domeLayers.js, environment.js, fog.js, frame.js, look.js, lookFog.js, lookShadow.js, lookSky.js, season.js, shader.js, shadow.js, skyModule.js, tint.js
194
- - terrain/ Terrain module: chunked, streamed ground built from a height fu… — ChunkManager.js, chunkJob.js, chunkQueries.js, chunkWorker.js, look.js, lookGround.js, terrainColorMap.js, terrainDefaults.js, terrainEdit.js, terrainGen.js, terrainIsland.js, terrainMesh.js, terrainShape.js, terrainShapeMain.js, terrainTexture.js
194
+ - sky/ Sky module: signals (engine.uniforms: uSunDir, uSunColor, uSkyT… — Sky.js, clouds.js, dome.js, domeLayers.js, environment.js, fog.js, frame.js, season.js, shader.js, skyModule.js, tint.js
195
+ - terrain/ Terrain module: chunked, streamed ground built from a height fu… — ChunkManager.js, chunkJob.js, chunkQueries.js, chunkWorker.js, draw.js, terrainColorMap.js, terrainDefaults.js, terrainEdit.js, terrainGen.js, terrainIsland.js, terrainMesh.js, terrainShape.js, terrainShapeMain.js, terrainTexture.js
195
196
  - timeline/ Timeline: cutscenes, camera moves, scripted movement — Timeline.js, Tween.js, letterbox.js, shots.js
196
197
  - triggers/ Trigger zones: who enters, stays, leaves —
197
- - vegetation/ Vegetation module factory: engine.use(vegetation(...)) installs… — Vegetation.js, densityMap.js, groundChunks.js, look.js, lookWind.js, modelGeometry.js, nearFade.js
198
- - water/ Water module: draws the global water plane (sea, big lakes; sna… — Water.js, look.js, surface.js, surfaceDefaults.js
199
- - weather/ Weather, the state half (type 'world', engine.weather): the gam… — Weather.js, look.js, particles.js, shaders.js, strings.js, weatherLook.js
198
+ - vegetation/ Vegetation module factory: engine.use(vegetation(...)) installs… — Vegetation.js, densityMap.js, draw.js, groundChunks.js, modelGeometry.js, nearFade.js
199
+ - water/ Water module: draws the global water plane (sea, big lakes; sna… — Water.js, surface.js
200
+ - weather/ Weather, the state half (type 'world', engine.weather): the gam… — Weather.js, particles.js, shaders.js, strings.js, weatherDraw.js
200
201
  - world/ world() module: installed as engine.world (world data, see Worl… — World.js, explain.js, persist.js, pos.js, records.js, sim.js, simFar.js, state.js, thingSource.js, views.js
201
202
 
202
203
  **render/**
203
204
  - PostFX.js: Post effects in five slots (both renderers)
204
205
  - backend.js: Renderer facts that differ between WebGLRenderer and WebGPU…
206
+ - cascades.js: Cascaded shadows of one DirectionalLight: 2-4 maps along th…
207
+ - cascades.tsl.js: Cascaded shadows on WebGPURenderer (the WebGPU half of casc…
208
+ - daylight.js: Day and night as a signal
205
209
  - detail.js: The `detail` surface patch: grain, paper, brush strokes or …
206
210
  - effects.js: Built-in shader effects
207
211
  - engineUniforms.js: Engine uniforms (helper of patches.js)
208
212
  - fuse.js: Fused post pass
209
- - fx/ threedog/tsl entry: the TSL Fn library — cloudShadow.tsl.js, detail.tsl.js, lighting.tsl.js, nodeErrors.tsl.js, noise.tsl.js, objectOrigin.tsl.js, particles.tsl.js, patchNodes.tsl.js, postWebGPU.tsl.js, season.tsl.js, sky.tsl.js, uniforms.tsl.js, water.tsl.js, wind.tsl.js
213
+ - fx/ threedog/tsl entry: the TSL Fn library — cel.tsl.js, cloudShadow.tsl.js, detail.tsl.js, lighting.tsl.js, nodeErrors.tsl.js, noise.tsl.js, objectOrigin.tsl.js, particles.tsl.js, patchNodes.tsl.js, postWebGPU.tsl.js, season.tsl.js, sky.tsl.js, uniforms.tsl.js, water.tsl.js, wind.tsl.js
210
214
  - fxNumbers.js: The numbers inside the engine's shared shader functions, wr…
211
215
  - hotGlsl.js: Shader hot reload in dev
212
- - lighting.js: The `lighting` surface patch and the toon ramp
213
- - lights.js: Default lights every engine has (engine.lights, the mechani…
214
- - lookGlow.js: Night glow: emissive following daylight
215
- - lookSurface.js: look.materials and look.surface
216
- - materials.js: Materials and shaders: Material factory makeMaterial(role, …
216
+ - layers.js: The three.js layers the engine keeps for itself, in one tab…
217
+ - lighting.js: The `lighting` patch (applyEffects(mat, { lighting })) and …
218
+ - lightmap.js: Baked lightmaps: reads the file `threedog bake light` write…
219
+ - lights.js: Placeholder lights (engine.lights): a directional "sun" + h…
220
+ - materials.js: Shader effects on plain three.js materials (shadows, fog an…
217
221
  - modeling.js: Modeling gaps three lacks
222
+ - neutral.js: The one way engine code makes a material of its own: plain …
223
+ - occlusion.js: Occlusion culling for the engine's own big things (hlod cel…
218
224
  - ownFrame.js: The game draws the frame itself: the engine notices and yie…
219
225
  - patches.js: Named shader patches
220
- - postLook.js: look.post: the post chain as a look part
221
226
  - postWebGL.js: Post chain on WebGLRenderer (EffectComposer)
222
227
  - probes.js: Baked light probes
223
228
  - shaderErrors.js: Shader errors naming the patch and slot
224
229
  - slots.js: Semantic patch slots
225
- - surface.js: Surface keys of a material spec
226
230
  - terms.js: Built-in material terms a game can take over whole: the clo…
227
231
  - uniformDecl.js: Declares style-supplied GLSL uniforms
228
232
 
@@ -243,7 +247,7 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
243
247
  | anim:end | core/Animator.js | — |
244
248
  | audio:ready | core/Audio.js | — |
245
249
  | camera:change | camera | settings |
246
- | camera:shot | camera | — |
250
+ | camera:shot | core/Views.js, camera | lights |
247
251
  | character:fall | characters | — |
248
252
  | character:jump | characters | — |
249
253
  | character:land | characters | — |
@@ -278,9 +282,9 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
278
282
  | net:sync | net | — |
279
283
  | page:blur | core/page.js | core/Input.js |
280
284
  | page:contextlost | core/page.js | — |
281
- | page:contextrestored | core/page.js | — |
285
+ | page:contextrestored | core/page.js | sky |
282
286
  | page:focus | core/page.js | — |
283
- | page:pointerlock | core/page.js | — |
287
+ | page:pointerlock | core/page.js | ui/Focus.js |
284
288
  | photo:denied | photo | — |
285
289
  | photo:taken | photo | — |
286
290
  | pickup:take | gameplay | — |
@@ -298,8 +302,9 @@ Type = what the module may own (core/moduleTypes.js): world, look, actor, rules,
298
302
  | session:failed | core/session.js | flow, rigid |
299
303
  | session:start | core/session.js | core/things.js, camera, flow |
300
304
  | settings:change | settings | — |
301
- | settings:shadows | (the game) | terrain |
305
+ | settings:shadows | core/shadows.js | terrain |
302
306
  | state:applied | core/UrlState.js | — |
307
+ | state:placed | core/UrlState.js | camera |
303
308
  | template:stage | content | — |
304
309
  | terrain:chunkFailed | terrain | — |
305
310
  | terrain:void | rigid, terrain | — |
@@ -357,8 +362,8 @@ Modules declare actions without keys; the game binds them (createEngine({ bindin
357
362
 
358
363
  ## i18n key groups (engine.t; full keys are in each string table)
359
364
 
360
- - core/I18n.js: common.* (8), loading.* (6), input.* (12), key.* (5), ground.* (1), shop.* (1)
361
- - core/page.js: page.* (2)
365
+ - core/I18n.js: common.* (8), loading.* (6), input.* (13), key.* (5), ground.* (1), shop.* (1)
366
+ - core/page.js: page.* (3)
362
367
  - core/saveFiles.js: saves.* (8)
363
368
  - modules/ambience/Ambience.js: module.* (1)
364
369
  - modules/calendar/index.js: module.* (1)
@@ -394,29 +399,6 @@ Modules declare actions without keys; the game binds them (createEngine({ bindin
394
399
  - modules/vegetation/index.js: module.* (2)
395
400
  - modules/water/Water.js: module.* (1)
396
401
  - modules/weather/strings.js: module.* (1), weather.* (8)
397
- - modules/weather/weatherLook.js: module.* (1)
402
+ - modules/weather/weatherDraw.js: module.* (1)
398
403
  - modules/world/index.js: module.* (1)
399
404
  - ui/defaults.js: title.* (2)
400
-
401
- ## Style keys (who reads engine.style.xxx)
402
-
403
- | Key | Read in |
404
- |---|---|
405
- | character | characters |
406
- | clouds | core/look/coreParts.js |
407
- | exposure | core/look/coreParts.js |
408
- | grid | grid |
409
- | lighting | render/lookSurface.js |
410
- | materials | render/lookSurface.js |
411
- | palette | core/Assets.js, core/assetLoad.js, characters |
412
- | particles | particles |
413
- | pickup | gameplay |
414
- | seasons | sky |
415
- | sky | sky |
416
- | terrain | terrain |
417
- | toneMapping | core/look/coreParts.js |
418
- | triggers | triggers |
419
- | ui | gameplay, hud, ui/LoadingScreen.js, ui/UI.js |
420
- | water | water |
421
- | weather | weather |
422
- | wind | vegetation |
package/docs/COMMANDS.md CHANGED
@@ -11,8 +11,8 @@ After `-w` write the directory or the package name (inside a game directory a pl
11
11
  remaining arguments go to vite untouched; don't add another `--`).
12
12
  - Test: `npm test -w games/my-game`, or `npm test -- -w my-game`; `npm test` at the root tests every workspace (engine + each game).
13
13
  - Build: `npm run build -w games/my-game`; `npm run build` at the root builds all (every *.html in a workspace root is bundled, no change to
14
- vite.config.js needed).
15
- - Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name, look numbers and hints after every shot, `--no-look` skips them, `--ref image` also compares with a reference, `--json` one JSON object; an unknown option fails naming the closest one), `npm run bake -- -w my-game`, `npm run assets -- -w my-game`.
14
+ vite.config.js needed); under a sub-path of a site: `threedog build my-game --base /my-game/` (recipes/61-deploy.md).
15
+ - Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name, picture numbers and hints after every shot, `--no-picture` skips them, `--ref image` also compares with a reference, `--json` one JSON object; an unknown option fails naming the closest one), `npm run bake -- -w my-game`, `npm run assets -- -w my-game`.
16
16
  - A game's tests: every `games/<game>/tests/specs/*.mjs` runs (each exports a `specs` array; the runner finds the files, nothing to register); without
17
17
  `tests/specs/` a smoke test runs automatically (page opens, engine ready, no console errors). Minimal example:
18
18
  ```js
@@ -32,8 +32,8 @@ export const specs = [{
32
32
  ```
33
33
  Tests run against the built bundle (not the dev server): main.js must set `window.engine = engine;` before `await engine.start()`, otherwise the
34
34
  test waits for the engine until timeout (the error explains why).
35
- - New game: `npm run new-game -- name [--open-world] [--example]` (blank scene with a camera by default; `--open-world` adds generated ground, sky, follow camera and a player; `--example` adds a sample on top; see `recipes/01-new-game.md`).
36
- - Game in your own folder (outside this repo): after `npm install threedog@0.5 three@~0.187.0 @threedog/tools@0.5`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--example]` (folder: the one to create, default the current folder): it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
35
+ - New game: `npm run new-game -- name [--open-world] [--webgl]` (blank scene with a camera by default; `--open-world` adds generated ground, sky, follow camera and a player; the game runs on WebGPU and writes shaders in TSL, `--webgl` on WebGL with GLSL; see `recipes/01-new-game.md`).
36
+ - Game in your own folder (outside this repo): after `npm install threedog@0.7 three@~0.187.0 @threedog/tools@0.7`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--webgl]` (folder: the one to create, default the current folder): it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
37
37
 
38
38
  > Git Bash (MSYS) rewrites arguments that start with `/` into a path under the Git install (`/` turns into `C:/Program Files/Git/`). Page arguments (`shot`, `capture`, `--page`) undo that by themselves, through `npm run` too (npm still echoes `> threedog shot C:/...`; shot then prints the page it really opens); if the Git folder cannot be found the error says so: then write `shot styletest`, set `MSYS_NO_PATHCONV=1`, or use PowerShell.
39
39
 
@@ -44,7 +44,7 @@ export const specs = [{
44
44
  |---|---|
45
45
  | `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (tables `core/errorCodes.js` for engine errors, `core/errorHints.js` for browser / JavaScript ones) |
46
46
  | `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): rule checks (`packages/tools/rules/`, the engine's hard rules among them; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule; `-- --verbose` lists them (the first 15 per rule), `-- --all` every one. `-- --rule R4` runs one rule (`R04` works; an unknown id fails and lists them), `-- -w game` (or `threedog check -w game`, or `check` run inside a game folder, as `new-game` does) reports only that game's rule, type and content problems and sets the exit code from them alone, with other games and the engine as one count line each; plain `check` at the repo root stays repo-wide (run it before committing engine changes) |
47
- | R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory or grid/height blending, or hand-colors a material in a file that also takes style materials (`makeMaterial`), is pointed to the engine system that already does it. Hand-made materials elsewhere, and anything in art code (`style/`, `art/`, `assets.js`, `art.js`), are the plain three.js route and not hinted. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
47
+ | R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory, grid/height blending, a localStorage save or its own pause is pointed to the engine system that already does it. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
48
48
  | `npm run types` | Type check only (does game code misuse the engine API). Plain JS TypeScript cannot follow (a field added to your own object later, a union from your own ternary, TSL node inference) is a `!` hint, not an error: no `// @ts-nocheck` needed |
49
49
  | `npm test` | Full browser tests (slow; test pages run in parallel, `-- --jobs N` sets how many, `--jobs 1` one at a time; without `--jobs`, at most 2 software-rendered pages at once; a spec with `serial: true` runs alone; a failure that happens only beside other pages is retried alone and listed). Normally `npm test -- name` runs only the related ones (matched by test-name substring, any case, e.g. `-- hlod`; a word that matches nothing fails), `-- -w game` tests one game. Prints only failed items (with their failed checks), a progress line and the summary; `-- --verbose` prints every check. `-- --update-snapshots` makes tests that use `expectDescribe` write their describe baselines (`tests/snapshots/*.describe.json`) instead of comparing. `npm test -- pack` (the build test): after a real build of each game, open only dist from a static server and check that the engine is ready, no 4xx resources, no console errors |
50
50
  | `threedog snap-describe save|diff name [--only a,b]` | Describe snapshot instead of a screenshot: baseline of the gameplay part of `describe()` (see recipes/16-dev-bridge.md section 7); in tests one line `expectDescribe({ check, ev }, name, { only, tolerance })` from `@threedog/tools/describe-snapshot` |
@@ -53,20 +53,24 @@ export const specs = [{
53
53
  | `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so later bridge commands skip module loading (about 0.1 to 0.15 s less per command); exits by itself after N idle minutes (default 10). Every command works the same without it: no session, a dead one or an unreachable one falls back to a direct call. Restart it after editing the tools |
54
54
  | `threedog describe [path] [--full\|--all]` · `threedog state time=18:30 weather=rain pos=40,-20` | Read the running game as compact text (one item: `describe player.pos`); change the scenario without a reload. Run inside the game folder or with `-w game`; at the repo root the one running dev server is used (several: the error lists them for `-w`). `recipes/16-dev-bridge.md` |
55
55
  | `threedog step 2` · `threedog press interact [--for 0.02]` · `threedog hold moveForward 1.5` | Advance game time: N game seconds / press a key or action (held 0.1 s) / hold a key or action for N seconds. The page stays paused afterwards (`threedog resume`) |
56
- | `threedog eval "expr"` (alias `js`) · `threedog snap name` · `threedog reload` | Evaluate an expression in the page (`engine` available, await works); save a screenshot of the running page to `.threedog/shots/name.png` and print the look check (as `shot`; `--no-look` skips it); reload the page |
56
+ | `threedog eval "expr"` (alias `js`) · `threedog snap name [--play]` · `threedog reload` | Evaluate an expression in the page (`engine` available, await works); save a screenshot of the running page to `.threedog/shots/name.png` and print the picture check (as `shot`; `--no-picture` skips it); reload the page |
57
+ | `threedog bake light [-w game] [--out public/light/level.lightmap] [--size 1024] [--spacing m] [--samples 16] [--page /]` | Bake a lightmap of the meshes marked `userData.static` in system Chrome on the real GPU; stops if WebGPU is not real. `recipes/34-environment-lighting.md` |
57
58
  | `threedog ops` · `threedog op shop.buy shop=bakery item=bread` | What the player can do now (each op offer checked); run one op as source bridge (no time passes). `recipes/23-ops.md` |
58
59
  | `threedog pick 480,270` | What is at a screen pixel (from the canvas top-left): record id, kind, template, content file:line, fields |
59
- | `threedog js --file steps.js [--verbose]` | A script that calls `assert(cond, msg)` or `expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg)` (or `expect(v, msg)`) runs as checks in ONE call; failed checks are recorded and the script goes on, a throw stops it. Output: `✓ 7 checks passed`, or the failures then `✗ 2 of 7 checks failed`; exit code 1 on failure. `--verbose` adds passes, `log` lines and the return value. A script without those calls is the plain eval (prints its return value); both modes get the same globals `engine`, `step(seconds)`, `log(...)`, `assert`, `expect` |
60
+ | `threedog js --file steps.js [--verbose] [--wait seconds]` | `--wait` (default 120) is how long a script may wait on a page that looks stopped: driven by manual step, nothing loading, no clock tick. The command then ends and says the script may be waiting on the game clock; the script may still run in the page. A script that calls `assert(cond, msg)` or `expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg)` (or `expect(v, msg)`) runs as checks in ONE call; failed checks are recorded and the script goes on, a throw stops it. Output: `✓ 7 checks passed`, or the failures then `✗ 2 of 7 checks failed`; exit code 1 on failure. `--verbose` adds passes, `log` lines and the return value. A script without those calls is the plain eval (prints its return value); both modes get the same globals `engine`, `step(seconds)`, `log(...)`, `assert`, `expect` |
60
61
  | `threedog verify scenario` | Run `tests/scenarios/<scenario>.json` on the running page and print PASS / FAIL, **Tested** (ops with outcomes, describe sections compared, time advanced), **Not tested** (ops never run, sections never compared, steps skipped after a failure, key path, picture), a `Layers:` line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the `threedog test` command to re-run. A page error during the run fails it. JSON adds `layers` / `layerCounts` / `evidence` (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more"). `threedog scenario` prints its pass line plus the same Coverage block |
61
62
  | `threedog catalog [id] [--find word] [--full] [--json]` | What this game can do: modules, ops (args, failure codes, last attempt), saves, time. No id: a line per module that has ops or problems, the rest named on one line (`--full`: a line each). `recipes/51-capability-catalog.md` |
62
- | `threedog art list <source>` · `threedog art copy <source> [names…] [--to art/] [--force] [--dry]` | Reuse art code by copying it into this game (no dependency, no link back): the source is a game folder (its `art/`), a local folder or file, or an installed package. `list` shows modules, exported generator functions with their first JSDoc line, asset files; `copy` brings the named modules plus their local imports and the textures / models they name, rewrites relative imports, never overwrites a changed file without `--force` (then nothing is written), prints the `engine.assets.manifest` lines. MCP: `art_list`. `recipes/09-style.md` section 2a |
63
- | `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--preview url|png] [--force]` · `threedog lib list [words]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game (no link back, no update command; the game adapts it) and prints the use line; a code entry goes to `plugins/<name>/` plus the wiring file `plugins/<name>.js` that calls its factory (the entry's plug line, set by `add --plug`, else its exported function; `pull --plug` overrides), so it plugs at start with nothing hand-written; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
63
+ | `threedog art list <source>` · `threedog art copy <source> [names…] [--to art/] [--force] [--dry]` | Reuse art code by copying it into this game (no dependency, no link back): the source is a game folder (its `art/`), a local folder or file, or an installed package. `list` shows modules, exported generator functions with their first JSDoc line, asset files; `copy` brings the named modules plus their local imports and the textures / models they name, rewrites relative imports, never overwrites a changed file without `--force` (then nothing is written), prints the `engine.assets.manifest` lines. MCP: `art_list`. `recipes/09-materials-lights-models.md` section 2a |
64
+ | `threedog art board [-w game] [--out file.html] [--json] [--live] [--lib dir]` | Every art resource of one game on one page (default `.threedog/art-board/index.html`): models, textures, sounds, fonts, materials, shaders and library entries, each with a preview where one exists, its file, size and where it is used as file:line. Status: used, unused, missing, or not traced (a name built at run time or plain text that may mean it; never called unused). Each item copies one line for the AI; several items plus a note copy one request. `--json` prints the same data. `--live` also asks the running game (dev server, dev bridge) what it has really loaded; `?panel=1` shows the same list in folder "art". A model gets a picture once `threedog gallery --shots` has made one. |
65
+ | `threedog lib status [-w game] [--lib dir]` | What this game pulled from the library (read from its `.threedog-lib.json`, which every `lib pull` writes): each entry changed or not, and newer in the library or not. It only reports: a pull belongs to the game and nothing updates it |
66
+ | `threedog lib check [-w game]` | Do the things this game pulled fit together? Fails on a need nothing gives and on two entries writing one three.js value; sizes and styles that do not fit are notes. It reads the game's copies, so an edit clears a clash |
67
+ | `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--style a,b] [--usage s] [--no-proof] [--preview url|png] [--force]` · `threedog lib list [words] [--card] [-w game]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game (no link back, no update command; the game adapts it) and prints the use line; a code entry goes to `plugins/<name>/` plus the wiring file `plugins/<name>.js` that calls its factory (the entry's plug line, set by `add --plug`, else its exported function; `pull --plug` overrides), so it plugs at start with nothing hand-written; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
64
68
  | `threedog examples list` · `threedog examples pull <name> [--out dir] [--force]` | Technique and optional examples you copy and adapt (the list is `examples/pullable.json` in the engine package; the summary is each README's first line). `pull` copies the game-facing files to `<game>/techniques/<name>/` (or `--out`), never overwrites a changed file without `--force` (then nothing is written), prints the import line and the packages the code imports. An unknown name fails with did-you-mean |
65
69
  | `threedog how "<task>"` | Ranks the AI.md task rows and recipe headings for a task in your own words. `recipes/51-capability-catalog.md` section 5 |
66
- | `threedog explain op shop.buy shop=bakery` / `explain quest first-light` | Why an op cannot run now, or what a quest waits on (`engine.explain`). `recipes/23-ops.md` |
67
- | `threedog thing <id>` | Everything about one id: definition file:line, model, materials, state, ops, save tier, how to change it (`thing.explain()`). `recipes/41-thing-registry.md` section 6 |
68
- | `threedog content set <id> x=12 place=home … [--expect x=5] [--in props] [--file content/x.js] [--dry]` | Write a permanent change into the content entry (several fields, one write, all-or-nothing; refused when `--expect` no longer matches). `recipes/41-thing-registry.md` |
69
- | `threedog content add <kind> id=<id> field=value … [--file content/props/town.js]` · `threedog content remove <id> [--in kind]` | Append one entry at the end of a kind (always with an id) / delete one. Reads and checks only that file (id index `.threedog/content-index.json`). `recipes/41-thing-registry.md` |
70
+ | `threedog explain op shop.buy shop=bakery` / `explain quest first-light` / `explain picture fog.far` | Why an op cannot run now, what a quest waits on, or which line last changed a picture value (`engine.explain`). `recipes/23-ops.md`, `recipes/62-picture-code.md` |
71
+ | `threedog thing <id>` | Everything about one id: definition file:line, model, materials, state, ops, save tier, how to change it (`thing.explain()`). `recipes/40-scene.md` section 6 |
72
+ | `threedog content set <id> x=12 place=home … [--expect x=5] [--in props] [--file content/x.js] [--dry]` | Write a permanent change into the content entry (several fields, one write, all-or-nothing; refused when `--expect` no longer matches). `recipes/40-scene.md` |
73
+ | `threedog content add <kind> id=<id> field=value … [--file content/props/town.js]` · `threedog content remove <id> [--in kind]` | Append one entry at the end of a kind (always with an id) / delete one. Reads and checks only that file (id index `.threedog/content-index.json`). `recipes/40-scene.md` |
70
74
  | `threedog loading [task]` | Loading progress and what failed, also while `start()` is stuck. `recipes/05-props-bake.md` |
71
75
  | `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
72
76
  | `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
@@ -75,28 +79,27 @@ export const specs = [{
75
79
  | `threedog errors` / `errors latest [N]` / `errors --since E5` | Page errors with id (E1…), time, tick, source and count; the same error repeated is one line with its first and last id / time and `×N`. Plain `errors` = new since the last read; `latest` = the last N (default 3), same answer every time; `--since` = after an id, never moves the read position. Every result prints a cursor |
76
80
  | Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game paused, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|paused|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. MCP `data` over 3 KB keeps its small fields and names `threedog <cmd> --json` for the rest (the text already summarizes it) |
77
81
  | `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
78
- | `npm run shot -- / --time 18:30 --weather rain --pos x,z` | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. Under a picture it prints only what bears on it (time, weather, camera; the same lines as `threedog snap`); `--describe-only` and `--json` give the whole state. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time. The shot waits until loading is finished (`--load-timeout` seconds, default 120) and fails naming what is still pending; a page error before `window.engine` fails at once with the error. `--no-build` reuses the last dist/ (code unchanged); a playing cutscene is skipped unless `--keep-cutscene`; `--play` starts straight in play, past the title screen the way its Start does (the engine's `?play` URL key) |
79
- | `npm run shot -- / [--ref image] [--no-look] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): look numbers measured on the 3D canvas (mean luminance, contrast = std of luminance and the p5-p95 range, saturation, share clipped white / near black, shadow area and how much shadows darken) and hints. **Contradictions** (always on): shadows on but none measurable, a light the game added that changes no pixel. **Facts** (each a contradiction only where DESIGN.md declares the opposite): glare, naming each light or glowing material that blows pixels out with its current values and the detail lost under it, and large clipped areas (`no-glare`); large near-black areas (`no-pitch-black`); time of day that barely changes the picture or a night not dark from lighting (renders 12:00 and 00:00 when the game runs calendar + sky or the shot sets `--time`; `dark-nights`); `light:` the share of the lit brightness from the sun / key and from the fill (each turned off once) and how much darker shadowed areas are (`strong-light`); the camera standing inside a closed mesh. **Intent** (only against what the game declared): the listed words on DESIGN.md's optional `Look intent:` line (the only place the check reads a wish; the table's free text is never read), or `--ref`. Each hint states the fact and the likely cause with the parameter and its current value, never a target; nothing fails and nothing is changed. Printed short: the numbers line (noon / midnight with each exposure when the two differ), then at most four one-sentence hint lines, contradictions first and then by measured size, and `N more: threedog shot --json (look.hints)`; `--json` has every hint in full. A few extra renders of the current view (about 0.3 s on a GPU), every touched value put back. `--json` prints one object (file, look, probe, hints, describe) for MCP / the dev bridge. A full URL opens that already running page without a build; `--image` reads a picture taken any other way and gives the pixel part only (shares, near-white spots, intent), saying what needs the live page. A screenshot of your own skips the check: take pictures with `shot` or `snap`. recipes/35 |
82
+ | `npm run shot -- / --time 18:30 --weather rain --pos x,z` (or `--at place`: in play at a named place) | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. Under a picture it prints only what bears on it (time, weather, camera; the same lines as `threedog snap`); `--describe-only` and `--json` give the whole state. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time. The shot waits until loading is finished (`--load-timeout` seconds, default 120) and fails naming what is still pending, then for the game's own code after `await engine.start()` (no request open and the scene's objects / lights / materials unchanged for 0.3 s, at most 10 s; it prints how long and what was added; if the scene still changes after the picture, it warns that the picture may be incomplete); a page error before `window.engine` fails at once with the error. `--no-build` reuses the last dist/ (code unchanged); a playing cutscene is skipped unless `--keep-cutscene`; `--play` starts straight in play, past the title screen the way its Start does (the engine's `?play` URL key) |
83
+ | `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): picture numbers measured on the 3D canvas (mean luminance, contrast = std of luminance and the p5-p95 range, saturation, share clipped white / near black, shadow area and how much shadows darken) and hints. **Contradictions** (always on): shadows on but none measurable, a light the game added that changes no pixel. **Facts** (each a contradiction only where DESIGN.md declares the opposite): glare, naming each light or glowing material that blows pixels out with its current values and the detail lost under it, and large clipped areas (`no-glare`); large near-black areas (`no-pitch-black`); time of day that barely changes the picture or a night not dark from lighting (renders 12:00 and 00:00 when the game runs calendar + sky or the shot sets `--time`; `dark-nights`); `light:` the share of the lit brightness from the sun / key and from the fill (each turned off once) and how much darker shadowed areas are (`strong-light`); the camera standing inside a closed mesh; a black frame, naming the material whose hiding alone brings the picture back (newest materials first; a ShaderMaterial is told the usual NaN / Inf causes, and shader programs that failed to compile are listed); fog that is most of the color in a large share of the picture, with its near / far and color. **Intent** (only against what the game declared): the listed words on DESIGN.md's optional `Picture intent:` line (the only place the check reads a wish; the table's free text is never read), or `--ref`. Each hint states the fact and the likely cause with the parameter and its current value, never a target; nothing fails and nothing is changed. Printed short: the numbers line (noon / midnight with each exposure when the two differ), then at most four one-sentence hint lines, contradictions first and then by measured size, and `N more: threedog shot --json (picture.hints)`; `--json` has every hint in full. A few extra renders of the current view (about 0.3 s on a GPU), every touched value put back. `--json` prints one object (file, look, probe, hints, describe) for MCP / the dev bridge. A full URL opens that already running page without a build, and a local server of another game's folder is refused (one that cannot say which game it serves gets a printed note); `--image` reads a picture taken any other way and gives the pixel part only (shares, near-white spots, intent), saying what needs the live page. A screenshot of your own skips the check: take pictures with `shot` or `snap`. recipes/35 |
80
84
  | `npm run shot -- styletest --view room --time dusk --weather rain` | The fixed style-judging scene (`examples/styletest`, page `/styletest.html`; a bare name is a page of the workspace). `--view` = a named camera (overview, character, water, room, path, ui), `--time` also takes day / dusk / night, `--weather` clear / rain / snow; same arguments every round, so only the style differs. `--panel` is not a shot option: open `/styletest.html?panel=1` in a browser for the workbench (recipes/35) |
81
85
  | `threedog capture [page] [--top N] [--no-spector] [--spector-url url] [--full] [--no-build]` | Find out what a frame draws: renders one steady frame headless and prints draw calls, shadow-map draws, render passes (post effects) and the largest draws with world record id, budget tag and material purpose. Also records the WebGL command stream of that frame with Spector.js (fetched on first use into `.threedog/cache/`, not a dependency) to `.threedog/captures/`; `--no-spector` skips it, `--spector-url` fetches it from another source |
82
86
  | `npm run bake` | Before release, or to take code-generated models into Blender: exports public/models/baked/*.glb (`-- -w game`) |
83
- | `npm run assets` | Compress glTF from art/models/ into public/models/ (names such as col_ and spawn are kept; `-- -w game`). Skips files whose source content, options and tool versions are unchanged. Prints a report per file (sizes, meshes / materials / textures / animations, final texture format, texture transfer size vs GPU memory; also `.threedog/assets-report.json`). `-- --ktx2` makes KTX2 textures; without the ktx tool it falls back to WebP and says so, `-- --ktx2 --strict` fails instead |
84
87
  | `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/): the level manifest (spawns, col_ colliders, trigger_ zones, npcs, markers, template / id nodes, missing templates, duplicate ids), material and color-space suspicions (data texture in a color slot, BLEND, texture without UV, oversized texture), statistics. `--json` for tools, exit 1 on errors (`--strict`: on warnings too). `npm run check` also reads the level glbs for content validation |
88
+ | `threedog assets [optimize] [-w game] [--dry] [--force] [--budget MB] [--strict]` (`npm run assets -- optimize`) | Make game-ready copies of the models in art/models/ without touching them: Meshopt geometry, KTX2 textures encoded by slot (normal / occlusion / roughness maps as linear UASTC, color maps as sRGB ETC1S; each output texture is read back and checked against its slot), into public/optimized/. Writes `assets.optimized.js` and adds its import to assets.js, so the names point at the results. A rerun handles only changed files (content hash, options, tool versions). Per file: size before / after, estimated GPU memory, and problems (over `--budget` MB of texture memory, color space, texture without UV or without the second UV set it asks for). `--dry` writes nothing and reports the estimate. Needs `@gltf-transform/cli` and, for textures, the `ktx` command from KTX-Software 4.3+ (Apache-2.0); a missing one fails only this command and says what to install. Baked lightmaps are left as baked (banding after compression is not measured). Report: `.threedog/optimize-report.json` |
85
89
  | `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld); compare with `PERF.md`. Prints the renderer first |
86
90
  | `threedog stress [--only a,b] [--frames 30] [--json]` | Load ramps, one axis at a time, on the neutral page `tests/stress/`: per step CPU / GPU / frame ms, then the load that fits 16.7 and 33 ms per axis (`PERF.md` "Load budget"). About 1-2 minutes |
87
91
  | `--gpu` · `--software` · `THREEDOG_RENDER=gpu` or `software` | Renderer of the headless browser. `shot`, `gallery --shots`, `perf` and `stress` prefer the hardware GPU (ANGLE d3d11 / metal / vulkan), check the renderer string after launch and fall back to SwiftShader with one note line; tests that read rendered pixels (`software: true` on the spec; unmarked ones are caught at the end of a GPU run) start on SwiftShader (same pixels everywhere), the others on the GPU when it is reachable |
88
92
  | `threedog content ids [-w game \| folder] [--write]` | Stateful content entries (pickups, template instances with state / container / interact / body) that rely on their index id: prints the id each has now as `-`/`+` lines (dry run); `--write` writes them into `content/*.js`. Rename later through `content/renames.js` (recipe 30) | <!-- r18-ignore-line -->
89
93
  | `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems; `-- --json` prints one verdict `{ healthy, items, render }`; exit code 0 only when healthy. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, the physical copy (real path, version, package.json mtime) of engine / tools / three per context (check, run/build per game; a `MISMATCH` line when contexts use different copies, e.g. vendor/ vs node_modules), port 5173, the dev server recorded in `.threedog/dev.json`, then renders one real engine frame on software rendering (what tests use; failing is a problem) and on the GPU path (whether a hardware GPU is available to headless; info only), and whether `EXT_disjoint_timer_query_webgl2` gives GPU ms. Run it first when the environment acts strange |
90
- | `threedog api-count [--unused] [--json]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, look parts and verbs, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
91
- | `threedog style check [folder\|file\|game] [--json] [--assets file]` | Check the final merged style (no argument: the `style/` folder of the game in the current folder; a game folder or workspace name means its `style/`): unknown fields (did-you-mean), world-state fields, palette keys read but not defined, color formats, post-effect conflicts, misspelled material roles / types, asset names the style does not register; plus R34 on those files. Exit 1 on errors. Static: it cannot prove a style has no gameplay logic. See `recipes/35-style-from-reference.md` |
92
- | `threedog style palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png] [--json]` | Dominant colors of a reference picture and a one-line summary (headless Chromium reads the pixels). `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured; `--json` prints the JSON only (summary inside). A path that starts with `-` goes after `--`. A measurement, not a design decision |
93
- | `threedog style compare <reference> <screenshot> [--region x,y,w,h] [--ref-region ..] [--shot-region ..] [--json]` | Differences as numbers: brightness, saturation, contrast (std of luma), fine detail (variance of the Laplacian of luma; read as a ratio), average and main color (hue / saturation / lightness), plus one neutral sentence ("18% darker, 2.3x more broken up"). Both pictures are scaled down to one size, never enlarged (detail is measured at the smaller picture's scale), and the notes say so. Regions are matched by position: a shifted feature shows as a large hue difference, so cut the same content with `--ref-region` / `--shot-region`. **An aid to judging, not a replacement for looking; no number is a quality score and there is no "similarity %".** recipes/35 |
94
+ | `threedog api-count [--unused] [--json]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
95
+ | `threedog picture palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png] [--json]` | Dominant colors of a reference picture and a one-line summary (headless Chromium reads the pixels). `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured; `--json` prints the JSON only (summary inside). A path that starts with `-` goes after `--`. A measurement, not a design decision |
96
+ | `threedog picture compare <reference> <screenshot> [--region x,y,w,h] [--ref-region ..] [--shot-region ..] [--json]` | Differences as numbers: brightness, saturation, contrast (std of luma), fine detail (variance of the Laplacian of luma; read as a ratio), average and main color (hue / saturation / lightness), plus one neutral sentence ("18% darker, 2.3x more broken up"). Both pictures are scaled down to one size, never enlarged (detail is measured at the smaller picture's scale), and the notes say so. Regions are matched by position: a shifted feature shows as a large hue difference, so cut the same content with `--ref-region` / `--shot-region`. **An aid to judging, not a replacement for looking; no number is a quality score and there is no "similarity %".** recipes/35 |
94
97
  | `threedog scene [--hidden] [--limit N] [--json]` | **The mesh exists but is not drawn: use this first** (needs the running game). Lists every Mesh / Points / Line / Sprite and for each undrawn one every reason, most likely first: `visible = false` on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond `camera.far`, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. `--hidden` = only undrawn. Answer first: a `Not drawn because:` line counts every undrawn object by reason, then the first 6 (surprising ones before plain view culling); `--limit N` or `--full` (40) for more. Code: `engine.inspect.scene()`; MCP tool `scene`. Cannot see shader output |
95
98
  | `threedog inspect materials` | Every material in the running game: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with `×N`; **wrong color spaces first** (color map not sRGB = washed out; normal / roughness map marked sRGB). Code: `engine.inspect.materials()`; MCP `inspect` target `materials`. Plain three.js: `scene.traverse` + `texture.colorSpace` |
96
99
  | `threedog inspect perf` | The last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; `✗` lines name the next call. Budgets: `engine.budget` limits, else a desktop reference. Code: `engine.inspect.perf()`; MCP `inspect` target `perf`. Plain three.js: `renderer.info`. The engine benchmark suite is `npm run perf` |
97
- | `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live look / post / UI sliders, materials by name, `engine.uniforms`, export of style overrides, "write back" for `threedog tune`. Needs the optional dev package `tweakpane`; production builds of the vite preset get a stub. `recipes/35-style-from-reference.md` |
98
- | `threedog tune show` · `threedog tune write [file] [--apply]` | Values dragged in the dev panel (`?panel=1` "tune" folder, then "write back" -> `.threedog/tune.json`) as one `// threedog:tune begin ... end` block of plain calls (`engine.look.<part>.set`, `material.setValues` by name, `engine.uniforms`, a `tunedStyle` literal) in `file`; model generator params (the panel's models folder) become the `default` in that model's `params` schema where it is registered (no file needed for those). Without `--apply` it only prints the diff. `recipes/35-style-from-reference.md` |
99
- | `threedog gallery [-w game] [--port 5181]` · `threedog gallery --shots [--size 256] [--only a,b] [--mode silhouette,value]` | Every registered model and texture on a turntable under three neutral light setups (midday, low sun, overcast; tone mapping copied from the game). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL (any dev page opens it with `?gallery=1`); `--shots` writes `.threedog/gallery/<name>-<light>.png`, `index.html` and `index.json` headless. `--mode` adds review pictures beside them: `silhouette` (each model pure black on white: `fill`, `boxFill`, `aspect`) and `value` (the midday shot as grayscale luminance: `p5` / `p50` / `p95` inside the outline); the facts are printed per asset and stored in `index.json`, with no thresholds. Compare one with a reference: `threedog style compare <ref> <png> --out diff.png`. `recipes/05-props-bake.md` section 2c |
100
+ | `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live sliders straight on the three.js objects (exposure, `scene.fog`, lights, module materials and uniforms, materials by name, `engine.uniforms`), post effects, UI colors, "write back" for `threedog tune`. Needs the optional dev package `tweakpane`; production builds of the vite preset get a stub. `recipes/35-picture-from-reference.md` |
101
+ | `threedog tune show` · `threedog tune write [file] [--apply]` | Values dragged in the dev panel (`?panel=1`, then "write back" -> `.threedog/tune.json`) as one `// threedog:tune begin ... end` block of plain three.js writes (`engine.scene.fog.far = 90;`, `material.setValues` by name, UI CSS variables) in `file`; model generator params (the panel's models folder) become the `default` in that model's `params` schema where it is registered (no file needed for those). Without `--apply` it only prints the diff. `recipes/35-picture-from-reference.md` |
102
+ | `threedog gallery [-w game] [--port 5181]` · `threedog gallery --shots [--size 256] [--only a,b] [--mode silhouette,value]` | Every registered model and texture on a turntable under three neutral light setups (midday, low sun, overcast; tone mapping copied from the game). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL (any dev page opens it with `?gallery=1`); `--shots` writes `.threedog/gallery/<name>-<light>.png`, `index.html` and `index.json` headless. `--mode` adds review pictures beside them: `silhouette` (each model pure black on white: `fill`, `boxFill`, `aspect`) and `value` (the midday shot as grayscale luminance: `p5` / `p50` / `p95` inside the outline); the facts are printed per asset and stored in `index.json`, with no thresholds. Compare one with a reference: `threedog picture compare <ref> <png> --out diff.png`. `recipes/05-props-bake.md` section 2c |
100
103
  | `npm run build` | Bundle each workspace into its own dist/ |
101
104
  | `threedog preview [game]` (or `-w game`, as for dev and build) | Serve a workspace's built dist/ (vite preview) to open the production build in a browser |
102
105
  | `threedog relay [port]` | The WebSocket relay for the net module (default port 8787, no dependencies). `recipes/27-net.md` |
@@ -119,10 +122,10 @@ export const specs = [{
119
122
  - `modules/` modules, one folder each, installed with `engine.use`; list in `CODEMAP.md`.
120
123
  - `render/ ui/` material factory, post-processing; UI basics (windows, UI focus stack, toast, fadeScreen, worldToScreen).
121
124
  - `index.js index.d.ts types/` entry and API declarations (`types/generated/` is generated from source JSDoc, never edited by hand).
122
- - `examples/world/style/` is the world example's own small look (starting values and material roles), not a recommended one; `examples/world/art/`
125
+ - `examples/world/picture/` is the world example's own small picture (plain three.js), not a recommended one; `examples/world/art/`
123
126
  is its art: `index.js` exports the asset pack `assets`, `models.js` the procedural trees / rocks, `humanoid.js` the humanoid body asset, `shapes.js` the pickup shape.
124
127
  The bloom / outline / ao effects are in `packages/post-effects/` (`@threedog/post-effects`). The terrain preset `terrainPreset()` is a separate package, `packages/terrain-noise/` (`@threedog/terrain-noise`).
125
- - `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, no style, top-down) and
128
+ - `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, top-down) and
126
129
  the co-op page are test pages in the engine repository (`tests/city/`, `tests/coop/`), opened at `/tests/city/index.html` and `/tests/coop/index.html`.
127
130
  - `tests/` specs/*.mjs test items (found by the runner), `<name>/index.html` test pages, fixtures/ test assets. `public/` art for the examples.
128
131
  - Each game `games/<game>/`: package.json, vite.config.js (one line, gameConfig), index.html, main.js, `content/` (items npcs dialogues quests pickups
@@ -12,14 +12,14 @@ one line; the detail is here.
12
12
  - **Level ownership**: world data carrying `zone: engine.world.zone` (= the current level name) gets its model built and is simulated only in that
13
13
  level; when you leave, the data stays (content NPCs, pickups and props already work this way);
14
14
  things that need not be kept (trigger zones, etc.) use `level.track(handle)` and are deleted automatically on level change.
15
- - **Module type**: every module says what it may own with `type` (`'rules'` for game logic; `'world'` state that draws nothing, `'look'` what is
15
+ - **Module type**: every module says what it may own with `type` (`'rules'` for game logic; `'world'` state that draws nothing, `'picture'` what is
16
16
  seen and heard, `'ui'` panels, `'actor'`, `'net'`, `'tool'`; recipes/14). Modules depend on capabilities (`requires: ['inventory']`), never on
17
- another module's name or private fields; a module doing two kinds of thing is two definitions from one factory (`weather()`: state + look).
17
+ another module's name or private fields; a module doing two kinds of thing is two definitions from one factory (`weather()`: state + drawing).
18
18
  - **Who owns a handle**: every `{ remove() }` handle has one owner that removes it, chosen by how long it should live: the module
19
19
  (`ctx.track(h)` in its install / init: until the module goes), the playthrough (`engine.session.track(h)`: until newGame / load / quit), or
20
20
  the level (`level.track(h)`: until the level changes). A handle with none lives until `engine.dispose()`.
21
21
  - **Two doors, one scene**: plain three.js (`engine.add(mesh, { id })`) and templates (`engine.content.spawn`, props) land in the same registry;
22
- `engine.thing(id)` says what it is and what a save keeps (`recipes/41-thing-registry.md`). What must be saved with its own state or edited without
22
+ `engine.thing(id)` says what it is and what a save keeps (`recipes/40-scene.md`). What must be saved with its own state or edited without
23
23
  code goes in `content/` (templates + props with ids, pickups, npcs, containers, game kinds) or the level model; a save stores only changes on top.
24
24
  Startup code never creates what a save stores whole (rule R33): things that appear during play come from `engine.content.spawn` inside an op.
25
25
  - To find leaks read `engine.counts()` (listeners, timers, geometry count; they should not grow when entering and leaving a level repeatedly).
@@ -27,13 +27,21 @@ one line; the detail is here.
27
27
  ## Textures
28
28
  The opts of `assets.texture(name, opts)` are part of the cache key: the same image with different opts gives two separately configured textures.
29
29
 
30
- ## Values the engine drives (sun, hemi, fog, camera)
31
- With a sky or camera module installed the engine writes `engine.lights.sun / hemi` (intensity, color, position), `scene.fog` and the `camera` pose
32
- every frame. Setting them directly is plain three.js and works: the engine yields that value (stops writing it, warns once). Say it on purpose with
33
- `engine.look.<part>.manual(key)` (no warning; `manual(key, false)` gives it back), or adjust without taking it, keeping the day cycle, with
34
- `look.<part>.set(...)`: the game's value is the base, weather and the sunset still multiply it and the settings menu can only turn it down
35
- (the "Customization ladder" below; how they stack: `recipes/52-look.md` "How look values stack"). The camera: `engine.takeCamera(owner)`
36
- or a timeline camera step.
30
+ ## Values the engine writes on its own (camera, shadow box)
31
+ Lights, fog, exposure and the environment have one writer, the game's `picture/` code: the sky computes signals and no module writes them (`recipes/62-picture-code.md`). With a camera module the
32
+ engine writes the `camera` pose every frame, and a sky keeps the shadow box around the focus. Setting one of those directly is plain three.js and works: the engine yields that value (stops
33
+ writing it, warns once). The camera: `engine.takeCamera(owner)` or a timeline camera step.
34
+
35
+ ## Layers the engine keeps
36
+ The three.js layers below belong to the engine (one table: `RESERVED_LAYERS` in `threedog/layers`, file `render/layers.js`). A game's own layers are 1 to 25; 30 is the default camera `hideLayer`.
37
+
38
+ | Layer | Name | What sits there |
39
+ | --- | --- | --- |
40
+ | 26 | `lightVolumes` | the box of air and the lights `lightVolumes` reads |
41
+ | 27 | `occlusionBox` | occlusion culling's query boxes, seen by the scene render of the view camera alone |
42
+ | 28 | `occlusionHidden` | what culling is not drawing now, still seen by shadows, `engine.rays` and `voxelGI` |
43
+ | 29 | `outlineOff` | objects `outline({ offLayer })` leaves without lines; `OUTLINE_OFF_LAYER` from `@threedog/post-effects` is this same layer |
44
+ | 31 | `batched` | originals drawn through `engine.batching`, still hit by `engine.rays` |
37
45
 
38
46
  ## Customization ladder
39
47
  Pick the row for what you want; each row is the one entry for it (take the first that fully works). Plain JS fields and your own `onFixed`
@@ -46,11 +54,11 @@ logic need none of this.
46
54
  | Run code before / after / around a module method (a weight limit on `inventory.add`) | `engine.wrap(engine.inventory, 'add', (next, ...a) => next(...a), { owner })` | `recipes/55-mods-time-wrap.md` |
47
55
  | Close one action for a while (stunned: no jump) | `engine.input.gate(action, { owner, for })` | `recipes/55-mods-time-wrap.md` |
48
56
  | Replace a whole system (your own inventory, interactions, dialogue, quests, flow, characters, camera; your own vehicle for `character.enter`) | `engine.use(mine(), { replaces: '<slot>' })` for a part that `provides` that slot; a module (or object) that meets that contract (`<module>.contract.js`; vehicle: `modules/characters/vehicle.contract.js`), checked with `runContract` | `recipes/55-mods-time-wrap.md` "Replacing a module" |
49
- | Change a look value (light, fog, sky, water, tone, post, materials) | `engine.look.<part>.set(values, { owner })`; take a value the engine drives: `manual(key)`; swap a named shader hook: `patch(hook, code)` (never a `glsl` key in an option); one more named thing: `add(...)` (`look.post.add`, `look.materials.add`); swap the one three.js thing a part draws: `replace(thing)`; read: `value(key)`; a whole module: `engine.use(mine(), { replaces })`; your own fog: `scene.fog = ...` | `recipes/52-look.md#verbs` |
50
- | Write the look yourself | plain three.js on `engine.scene / camera / renderer` (own material, `ShaderMaterial`, pass); a direct write takes that value over and the engine yields | `THREE.md`, `recipes/54-three-idioms.md` |
57
+ | Change a picture value (light, fog, sky, water, tone, post) | write it in your `picture/` code on the three.js object or the module's `material` (recipe 62); a value the engine drives (camera far, fov, pixel ratio): `engine.view.manual(key)` first; a screen effect: `engine.post.add(x)` |
58
+ | Write the picture yourself | plain three.js on `engine.scene / camera / renderer` (own material, `ShaderMaterial`, pass); a direct write takes that value over and the engine yields | `THREE.md`, `recipes/54-three-idioms.md` |
51
59
 
52
- The starting look comes from the game's `style/` folder; what a style section builds as a factory can also be passed at the call site, and the
53
- call site wins (`terrain({ material })` and the like; the water surface has only `look.water.replace`); a new style factory ships with its call-site option. No module option starts a value taken over.
60
+ The starting picture comes from the game's `picture/` folder; what it builds as a factory can also be passed at the call site, and the
61
+ call site wins (`terrain({ material })` and the like; the water surface is `engine.water.material`); a new style factory ships with its call-site option. No module option starts a value taken over.
54
62
 
55
63
  **Time channels**: most games use only the default (fixed `dt` in real seconds, `engine.clock` for calendar time). A channel exists so one group
56
64
  of things can run slower or faster than the rest (bullet time on enemies, haste on the player): `engine.onFixed(fn, { channel: 'enemies' })` gets
@@ -58,21 +66,21 @@ that channel's scaled `dt`, and `engine.mod('time.enemies', { owner, mul })` sca
58
66
 
59
67
  ### One task, which entry
60
68
  Where a task has more than one entry they are layers of the ladder above, not alternatives: take the first, go down only for the reason given.
61
- Look rows (light, glow, environment, post) follow the order in `THREE.md` (plain three.js first): they name the hook your three.js code plugs
69
+ Picture rows (light, glow, environment, post) follow the order in `THREE.md` (plain three.js first): they name the hook your three.js code plugs
62
70
  into, or a convenience for after.
63
71
 
64
72
  | Task | First | Go down a layer when |
65
73
  |---|---|---|
66
- | Windows, signs, screens glow at night | `look.materials.glow(match, { night })` | your own emissive logic: plain three.js. `lightPool.add(obj, { glow })` is something else: the stand-in a pooled lamp shows while it holds no real light |
74
+ | Windows, signs, screens glow at night | a material whose `emissiveIntensity` reads `engine.uniforms.uNight` (recipe 09 §1b) | `lightPool.add(obj, { glow })` is something else: the stand-in a pooled lamp shows while it holds no real light |
67
75
  | Time of day | `engine.calendar` (`calendar({ time })`) | no calendar at all (one fixed scene): `sky({ time })`; timers: `engine.clock`; one group faster / slower: a time channel |
68
- | Sun / light strength | `look.lights.set(values, { owner })`: a layer over the day keyframes, `remove()` gives them back | take it over (the day cycle stops writing it): write `engine.lights.sun` directly, or `look.lights.manual('sun')` |
76
+ | Sun / light strength | your own three.js light in `picture/`, reading `engine.uniforms` (recipe 62) | the placeholders: write `engine.lights.sun` directly |
69
77
  | A game test (write one for your game) | a spec file `tests/specs/<name>.mjs` exporting `specs` (COMMANDS.md "A game's tests": minimal example, `npm test -- <name>`) | the test is steps and checks only: a scenario JSON `tests/scenarios/<name>.json` (recipes/23 §7); compare whole state: describe snapshots (recipes/16 §7) |
70
78
  | Teleport the player | `player.placeAt(p)` in an op | not streamed in yet: `await engine.stream.teleport(p)` (waits, then places); a test or scenario: `applyState({ pos })` |
71
- | Camera | install one: `openWorld({ camera })`, `engine.use(fixedCamera({ position, lookAt }))` | switch kinds at run time: `setCamera(kind)`; a shot of your own: `takeCamera(owner)` |
72
- | Sky | the style's sky layers, tuned with `look.sky.set` | a custom sky of your own (shader dome, skybox, painted backdrop): `look.sky.replace(obj)` (recipe 08 "Your own sky object"); on WebGPU three's `SkyMesh` the same way |
73
- | Environment light | the style, then `look.env.replace('sky' \| asset)` / `look.env.set` | light that changes from place to place: `bakeProbes` |
74
- | Post effects | your own three.js Pass in the engine's chain: `look.post.add(pass)`, the one way in (the engine renders through its composer) | ready-made effects as an optional convenience: `@threedog/post-effects` through the same call or a plugin file, tuned with `look.post.set`; a whole chain of your own: `look.post.replace([...])` |
75
- | Ambient occlusion | `look.post.set({ 'ao.enabled': true })` (screen space) | a model made in code: `bakeVertexAO(geometry)`; bounce light between places: `bakeProbes` |
79
+ | Camera | install one: `openWorld({ camera })`, `engine.use(fixedCamera({ position, lookAt }))` | switch kinds at runtime: `setCamera(kind)`; a shot of your own: `takeCamera(owner)` |
80
+ | Sky | `sky({ ... })` start values, tuned through `engine.uniforms` and `engine.sky` | a custom sky of your own (shader dome, skybox, painted backdrop): `engine.sky.replace(obj)` (recipe 08 "Your own sky object"); on WebGPU three's `SkyMesh` the same way |
81
+ | Environment light | `engine.sky.environment({ into: engine.scene })`, or `scene.environment` | light that changes from place to place: `bakeProbes` |
82
+ | Post effects | your own three.js Pass in the engine's chain: `engine.post.add(pass)`, the one way in (the engine renders through its composer) | ready-made effects as an optional convenience: `@threedog/post-effects` through the same call or a plugin file, tuned with its handle; a whole chain of your own: `engine.post.own()` |
83
+ | Ambient occlusion | `engine.post.add(ao())` (screen space) | a model made in code: `bakeVertexAO(geometry)`; bounce light between places: `bakeProbes` |
76
84
 
77
85
  ## Owners
78
86
  Everything that holds the engine is named by an owner, and only that owner releases it. Positional `pause('menu')` and `pause({ owner: 'menu' })` are the same.
@@ -84,7 +92,6 @@ Everything that holds the engine is named by an owner, and only that owner relea
84
92
  | Camera | `takeCamera(owner, { focus? })` | `handle.remove()` | handle |
85
93
  | Where a character goes | `control.take(character, { owner, layer, step? })` (layers base < script < cutscene < net; higher pauses lower) | `handle.remove()` | handle `{ active, move(), remove() }` |
86
94
  | Debug override / view | `debug.override(owner, ...)`, `debug.view(mode, { owner })` | `debug.clear(owner)` | handle / state |
87
- | Look values | `look.<part>.set(values, { owner })` | `handle.remove()` | handle |
88
95
 
89
96
  ## Worker limits
90
97
  `modules/terrain/terrainGen.js` (via `chunkJob.js`) runs in a Worker and must not import three.js; a vegetation `rule` is sent to the Worker and must
@@ -167,8 +174,8 @@ inside template strings, which then throw on the first call).
167
174
 
168
175
  ## Core conventions
169
176
  - Lighting without `sky`: every engine has `engine.lights = { sun, hemi }` (neutral); to light the scene yourself hide or adjust them and add three.js
170
- lights. The engine ships no art: the humanoid, pickup shapes and flat shading come from the game's `style/` folder and `assets.js` (e.g.
171
- `terrain.config.shading: 'flat'` in its style); without them the engine shows a gray capsule, a gray box and flat gray ground at y = 0, with a
177
+ lights. The engine ships no art: the humanoid, pickup shapes and flat shading come from the game's `picture/` folder and `assets.js` (e.g.
178
+ `terrain({ shading: 'flat' })`); without them the engine shows a gray capsule, a gray box and flat gray ground at y = 0, with a
172
179
  dev warning naming the fix.
173
180
  - Gameplay state (world, containers, vars, quests) changes only in fixed steps or inside ops; dev warns otherwise (`npm test` prints the first place, all in
174
181
  `<game>/.threedog/ops-guard.log`). (game side)
@@ -184,8 +191,7 @@ inside template strings, which then throw on the first call).
184
191
  so `await` them. Saved data names things by stable ids, never positions; when it changes shape raise `version` and add a `migrate` step
185
192
  (`recipes/20-content-actions-save.md` "Save format").
186
193
  - Day / night in gameplay comes from the calendar: read `calendar.isDay`, use `calendar.daylight` (0-1) for fades (they work with no sky); don't judge by clock text yourself.
187
- - A game's own look parameters (colors, materials) can live anywhere plain three.js code lives; put them in its `style/` folder when you want
188
- them in one place (mixed, tuned with `look.<part>.set`).
194
+ - A game's own picture parameters (colors, materials) can live anywhere plain three.js code lives; its `picture/` folder keeps them in one place (recipe 62).
189
195
  - Vegetation `rule` must not contain functions (it is sent to a Worker).
190
196
  - Terrain is editable: `engine.terrain.edit(pos, { lower|raise|flatten|paint })`, only inside an op or fixed step; custom
191
197
  `terrain({ height, groundType })` must be pure functions.
@@ -193,13 +199,13 @@ inside template strings, which then throw on the first call).
193
199
  never removes its world record.
194
200
  - Window blur, tab hidden, pointer lock and WebGL context loss are listened to only in `core/page.js`; modules read `engine.page` or listen to
195
201
  `page:*`. Show "saved" only after `saves.save` returns true.
196
- - Character bodies are assets, not style: `createPlayer({ ...presets.player.thirdPerson, model: 'humanoid' | 'hero' })` (a procedural builder is built
202
+ - Character bodies are assets: `createPlayer({ ...presets.player.thirdPerson, model: 'humanoid' | 'hero' })` (a procedural builder is built
197
203
  now; a file shows a gray capsule and is swapped in when it loads: `await player.whenReady`, event `character:model`), or `{ rig }`; a name no model
198
- asset has throws. The style tints bodies through material roles (cloth, skin, trousers, hair).
204
+ asset has throws. Per-character colors: `colors: { body, skin, legs, hair }` on meshes marked `userData.part`.
199
205
  - Importing the engine makes `Mesh.prototype.customDepthMaterial` / `customDistanceMaterial` default to a depth material carrying the mesh material's
200
206
  vertex patches, so wind-swayed meshes cast swaying shadows with nothing to set up; assigning your own value still wins. Shader time, wind and cloud
201
207
  cover are per engine in `engine.uniforms` (share them in your own `ShaderMaterial`); with two engines on a page, pass the engine to
202
- `makeMaterial(role, params, engine)`.
208
+ `applyEffects(mat, { engine })`.
203
209
 
204
210
  ## Failures: which shape
205
211
  A runtime "can't" (not enough money, shelf empty) is returned as `{ ok: false, code, facts, nextActions }` (ops.run / can / undo, and direct calls such as `container.trade`, which a module builds by returning that shape, or a code string from an op's `can`). Misuse (a wrong call, a typo) is a thrown `codedError`. Documented exceptions: `checkSkip` / `checkSave` return `{ ok, diffs }`, `walkTo` returns `{ status }`. Read `code` (there is no `reason` field). Predicates (op `can`, `grid.can()`) may return a plain code string.