threedog 1.0.1 → 1.2.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 (364) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +1 -1
  3. package/core/assets/Animator.js +41 -3
  4. package/core/assets/Assets.js +100 -24
  5. package/core/assets/assetEntry.js +73 -20
  6. package/core/assets/assetHot.js +68 -16
  7. package/core/assets/assetLoad.js +6 -6
  8. package/core/assets/assetLod.js +9 -2
  9. package/core/assets/assetManifest.js +12 -2
  10. package/core/assets/assetPart.js +54 -0
  11. package/core/assets/ik.js +271 -0
  12. package/core/assets/modelNeeds.js +37 -0
  13. package/core/assets/namedModel.js +102 -29
  14. package/core/assets/nodeVisibility.js +15 -0
  15. package/core/audio/Audio.js +36 -4
  16. package/core/audio/audioReverb.js +99 -0
  17. package/core/audio/audioRules.js +1 -1
  18. package/core/audio/audioVoice.js +1 -1
  19. package/core/base/Events.js +14 -4
  20. package/core/base/Random.js +1 -1
  21. package/core/base/Vars.js +1 -1
  22. package/core/base/docRef.js +51 -0
  23. package/core/base/errorCodes.js +178 -126
  24. package/core/base/errorHints.js +9 -7
  25. package/core/base/errors.js +25 -10
  26. package/core/base/events.generated.js +2 -0
  27. package/core/base/freeParts.js +76 -0
  28. package/core/base/math.js +28 -0
  29. package/core/base/sections.js +5 -5
  30. package/core/base/validate.js +31 -3
  31. package/core/engine/Engine.js +16 -6
  32. package/core/engine/Loading.js +5 -3
  33. package/core/engine/copies.js +1 -1
  34. package/core/engine/headlessLoad.js +4 -1
  35. package/core/engine/lifecycle.js +32 -16
  36. package/core/engine/loop.js +71 -27
  37. package/core/engine/moduleSlots.js +2 -2
  38. package/core/engine/moduleTypes.js +3 -3
  39. package/core/engine/modules.js +65 -39
  40. package/core/engine/page.js +6 -3
  41. package/core/engine/services.js +6 -5
  42. package/core/engine/startup.js +5 -5
  43. package/core/input/Input.js +28 -14
  44. package/core/input/inputContext.js +28 -16
  45. package/core/input/inputKeyboard.js +31 -3
  46. package/core/input/inputPad.js +4 -0
  47. package/core/input/inputPointer.js +2 -1
  48. package/core/input/inputSeat.js +1 -1
  49. package/core/inspect/Budget.js +109 -19
  50. package/core/inspect/DebugOverrides.js +28 -4
  51. package/core/inspect/Describe.js +17 -9
  52. package/core/inspect/Inspect.js +4 -2
  53. package/core/inspect/InspectMaterials.js +3 -1
  54. package/core/inspect/InspectPerf.js +19 -9
  55. package/core/inspect/InspectScene.js +32 -7
  56. package/core/inspect/MaterialInfo.js +19 -2
  57. package/core/inspect/UrlState.js +46 -27
  58. package/core/inspect/catalog.js +28 -9
  59. package/core/inspect/debugView.js +2 -1
  60. package/core/inspect/describeRender.js +25 -13
  61. package/core/inspect/describeText.js +14 -6
  62. package/core/inspect/lightWatch.js +1 -1
  63. package/core/inspect/metadata.generated.js +35 -17
  64. package/core/inspect/pictureChecks.js +148 -0
  65. package/core/inspect/pictureMenu.js +84 -0
  66. package/core/inspect/pictureWriters.js +26 -6
  67. package/core/inspect/textureBytes.js +12 -2
  68. package/core/inspect/toolDoor.js +2 -4
  69. package/core/ops/Ops.js +11 -4
  70. package/core/ops/holds.js +27 -10
  71. package/core/ops/opsAtomic.js +15 -7
  72. package/core/ops/opsGuard.js +2 -2
  73. package/core/ops/opsRun.js +8 -7
  74. package/core/ops/sharedPoint.js +72 -21
  75. package/core/ops/stacks.js +56 -16
  76. package/core/saves/SaveStore.js +9 -3
  77. package/core/saves/Saves.js +32 -23
  78. package/core/saves/saveApply.js +96 -44
  79. package/core/saves/saveIds.js +1 -1
  80. package/core/saves/saveVersions.js +7 -5
  81. package/core/saves/session.js +17 -8
  82. package/core/saves/stateReplace.js +34 -15
  83. package/core/scene/Rays.js +52 -10
  84. package/core/scene/Views.js +13 -7
  85. package/core/scene/adaptive.js +144 -21
  86. package/core/scene/drawOnly.js +17 -0
  87. package/core/scene/gameLights.js +44 -3
  88. package/core/scene/sceneMethods.js +13 -11
  89. package/core/scene/stepPoses.js +11 -3
  90. package/core/scene/targeting.js +5 -3
  91. package/core/scene/thingOps.js +1 -1
  92. package/core/scene/tier.js +15 -0
  93. package/core/stream/Batching.js +30 -7
  94. package/core/stream/Stream.js +26 -7
  95. package/core/stream/batchGroups.js +2 -2
  96. package/core/stream/chunkStream.js +7 -5
  97. package/core/stream/prepare.js +77 -0
  98. package/core/time/skip.js +3 -1
  99. package/core/time/time.js +4 -2
  100. package/docs/AI.md +82 -83
  101. package/docs/API.md +16 -16
  102. package/docs/CODEMAP.md +16 -11
  103. package/docs/COMMANDS.md +31 -33
  104. package/docs/CONVENTIONS.md +37 -49
  105. package/docs/MIGRATING-0.8.md +2 -2
  106. package/docs/MIGRATING-1.0.md +2 -2
  107. package/docs/THREE.md +28 -35
  108. package/docs/api/assets.md +3 -1
  109. package/docs/api/audio.md +4 -2
  110. package/docs/api/budget.md +5 -0
  111. package/docs/api/cameraRig.md +2 -2
  112. package/docs/api/characters.md +10 -8
  113. package/docs/api/collision.md +6 -4
  114. package/docs/api/engine.md +16 -16
  115. package/docs/api/events.md +3 -2
  116. package/docs/api/ground.md +6 -5
  117. package/docs/api/hud.md +4 -2
  118. package/docs/api/input.md +5 -5
  119. package/docs/api/particles.md +2 -1
  120. package/docs/api/photo.md +3 -0
  121. package/docs/api/post.md +7 -4
  122. package/docs/api/quests.md +2 -2
  123. package/docs/api/rays.md +1 -2
  124. package/docs/api/saves.md +7 -7
  125. package/docs/api/settings.md +2 -2
  126. package/docs/api/tools.md +3 -1
  127. package/docs/api/vars.md +1 -1
  128. package/docs/api/vegetation.md +4 -2
  129. package/docs/api/world.md +1 -1
  130. package/docs/recipes/01-new-game.md +16 -17
  131. package/docs/recipes/02-npc.md +22 -18
  132. package/docs/recipes/03-items-pickups.md +37 -35
  133. package/docs/recipes/04-quests.md +15 -10
  134. package/docs/recipes/05-props-bake.md +101 -95
  135. package/docs/recipes/06-clock-events.md +28 -28
  136. package/docs/recipes/07-flow-scenes-pause.md +29 -26
  137. package/docs/recipes/08-weather-sky.md +52 -64
  138. package/docs/recipes/09-materials-lights-models.md +26 -17
  139. package/docs/recipes/10-blender-level.md +15 -10
  140. package/docs/recipes/11-vehicles.md +12 -7
  141. package/docs/recipes/12-navmesh.md +44 -26
  142. package/docs/recipes/13-animation.md +56 -45
  143. package/docs/recipes/14-custom-module.md +21 -18
  144. package/docs/recipes/15-perf.md +61 -55
  145. package/docs/recipes/16-dev-bridge.md +23 -33
  146. package/docs/recipes/18-world.md +36 -42
  147. package/docs/recipes/19-shooting-picking.md +20 -15
  148. package/docs/recipes/20-content-actions-save.md +48 -56
  149. package/docs/recipes/21-camera.md +45 -54
  150. package/docs/recipes/22-shop-gold.md +12 -7
  151. package/docs/recipes/23-ops.md +25 -23
  152. package/docs/recipes/26-ui-parts.md +67 -47
  153. package/docs/recipes/27-net.md +12 -7
  154. package/docs/recipes/28-terrain.md +24 -21
  155. package/docs/recipes/29-grid.md +32 -27
  156. package/docs/recipes/30-templates.md +21 -20
  157. package/docs/recipes/31-audio.md +39 -22
  158. package/docs/recipes/32-action-game.md +19 -14
  159. package/docs/recipes/33-stream-sources.md +15 -11
  160. package/docs/recipes/34-environment-lighting.md +126 -70
  161. package/docs/recipes/35-picture-from-reference.md +8 -8
  162. package/docs/recipes/36-ground-plants.md +27 -21
  163. package/docs/recipes/40-scene.md +19 -28
  164. package/docs/recipes/43-shader-patches-surfaces.md +15 -12
  165. package/docs/recipes/44-water-weather-hooks.md +34 -31
  166. package/docs/recipes/45-cascaded-shadows.md +35 -26
  167. package/docs/recipes/46-blender-art-route.md +6 -1
  168. package/docs/recipes/49-game-module-contract.md +13 -8
  169. package/docs/recipes/50-own-renderer.md +6 -2
  170. package/docs/recipes/51-capability-catalog.md +15 -8
  171. package/docs/recipes/52-around-the-picture.md +34 -32
  172. package/docs/recipes/53-ground-up-close.md +6 -1
  173. package/docs/recipes/55-mods-time-wrap.md +27 -19
  174. package/docs/recipes/56-webgpu-tsl.md +74 -43
  175. package/docs/recipes/57-control.md +18 -13
  176. package/docs/recipes/58-input.md +26 -16
  177. package/docs/recipes/59-depth-post-effects.md +8 -3
  178. package/docs/recipes/60-judge-the-picture.md +9 -8
  179. package/docs/recipes/61-deploy.md +5 -0
  180. package/docs/recipes/62-picture-code.md +70 -79
  181. package/docs/recipes/63-third-person-start.md +47 -45
  182. package/docs/recipes/64-particles.md +22 -10
  183. package/docs/recipes/65-swarm.md +18 -13
  184. package/docs/recipes/66-common-tasks.md +38 -35
  185. package/examples/action/GAMEMAP.md +2 -3
  186. package/examples/action/main.js +3 -3
  187. package/examples/action/picture/lights.js +3 -1
  188. package/examples/perf-island/GAMEMAP.md +3 -3
  189. package/examples/perf-island/picture/lights.js +2 -1
  190. package/examples/plain-picture/GAMEMAP.md +1 -1
  191. package/examples/rc2d/GAMEMAP.md +1 -1
  192. package/examples/styletest/GAMEMAP.md +2 -2
  193. package/examples/styletest/main.js +1 -1
  194. package/examples/techniques/interior-light/README.md +3 -3
  195. package/examples/techniques/interior-light/interiorLight.js +2 -4
  196. package/examples/techniques/interior-light/picture/lights.js +2 -1
  197. package/examples/techniques/modular-building/picture/lights.js +3 -1
  198. package/examples/techniques/outlines-and-rim/picture/lights.js +3 -1
  199. package/examples/techniques/procedural-animation/README.md +1 -1
  200. package/examples/techniques/procedural-animation/main.js +1 -1
  201. package/examples/webgpu-tsl/GAMEMAP.md +1 -1
  202. package/examples/world/GAMEMAP.md +2 -3
  203. package/examples/world/art/humanoid.js +1 -1
  204. package/examples/world/main.js +6 -3
  205. package/index.d.ts +2 -2
  206. package/llms.txt +101 -0
  207. package/modules/ambience/Ambience.js +21 -5
  208. package/modules/calendar/index.js +9 -5
  209. package/modules/calendar/schedule.js +23 -8
  210. package/modules/camera/FirstPersonCamera.js +3 -1
  211. package/modules/camera/FollowCamera.js +10 -5
  212. package/modules/camera/RtsCamera.js +4 -3
  213. package/modules/camera/common.js +70 -8
  214. package/modules/camera/contract.js +1 -1
  215. package/modules/characters/Character.js +16 -10
  216. package/modules/characters/NPC.js +31 -19
  217. package/modules/characters/assetModel.js +14 -9
  218. package/modules/characters/astar.js +6 -1
  219. package/modules/characters/contract.js +2 -2
  220. package/modules/characters/index.js +34 -22
  221. package/modules/characters/movers/manual.js +1 -1
  222. package/modules/characters/movers/rapier.js +17 -2
  223. package/modules/characters/movers/simple.js +1 -1
  224. package/modules/characters/movers/support.js +16 -7
  225. package/modules/characters/npcAvoid.js +2 -2
  226. package/modules/characters/npcSim.js +3 -2
  227. package/modules/characters/pathAsync.js +24 -8
  228. package/modules/characters/pathJob.js +1 -1
  229. package/modules/characters/player.js +10 -9
  230. package/modules/characters/playerStrings.js +5 -5
  231. package/modules/characters/proceduralRig.js +5 -5
  232. package/modules/characters/useModel.js +6 -0
  233. package/modules/characters/walkTo.js +1 -1
  234. package/modules/collision/Collision.js +29 -18
  235. package/modules/collision/grid.js +22 -4
  236. package/modules/content/index.js +3 -1
  237. package/modules/content/loader.js +1 -1
  238. package/modules/content/models.js +82 -33
  239. package/modules/content/props.js +2 -1
  240. package/modules/content/rules.js +11 -5
  241. package/modules/content/templates.js +3 -3
  242. package/modules/content/words.js +2 -2
  243. package/modules/debug/DebugPanel.js +9 -9
  244. package/modules/flow/index.js +9 -6
  245. package/modules/gameplay/Dialogue.js +34 -20
  246. package/modules/gameplay/Interactions.js +19 -15
  247. package/modules/gameplay/Inventory.js +9 -4
  248. package/modules/gameplay/Quests.js +12 -10
  249. package/modules/gameplay/pickups.js +23 -11
  250. package/modules/grid/index.js +1 -1
  251. package/modules/grid/preview.js +2 -2
  252. package/modules/grid/tiles.js +1 -1
  253. package/modules/hlod/index.js +4 -1
  254. package/modules/hud/index.js +47 -10
  255. package/modules/hud/parts.js +28 -9
  256. package/modules/level/geometry.js +8 -3
  257. package/modules/level/index.js +10 -5
  258. package/modules/level/load.js +4 -2
  259. package/modules/lights/sources.js +1 -1
  260. package/modules/music/Music.js +22 -4
  261. package/modules/nav/index.js +20 -10
  262. package/modules/particles/Particles.js +31 -14
  263. package/modules/particles/effect.js +20 -5
  264. package/modules/particles/lit.js +72 -0
  265. package/modules/photo/Photo.js +72 -28
  266. package/modules/photo/pathTrace.js +106 -0
  267. package/modules/rigid/RigidBodies.js +23 -14
  268. package/modules/rigid/Vehicles.js +3 -13
  269. package/modules/rigid/sync.js +2 -1
  270. package/modules/settings/Settings.js +52 -20
  271. package/modules/settings/apply.js +23 -9
  272. package/modules/settings/sections.js +39 -6
  273. package/modules/settings/strings.js +2 -0
  274. package/modules/settings/view.js +19 -3
  275. package/modules/sky/dome.js +15 -3
  276. package/modules/sky/environment.js +28 -12
  277. package/modules/sky/fog.js +1 -1
  278. package/modules/sky/frame.js +6 -1
  279. package/modules/sky/shader.js +4 -3
  280. package/modules/sky/skyModule.js +8 -4
  281. package/modules/swarm/Swarm.js +1 -1
  282. package/modules/terrain/ChunkManager.js +61 -15
  283. package/modules/terrain/chunkJob.js +2 -2
  284. package/modules/terrain/index.js +20 -5
  285. package/modules/terrain/terrainEdit.js +8 -4
  286. package/modules/terrain/terrainTexture.js +4 -2
  287. package/modules/timeline/Timeline.js +4 -3
  288. package/modules/timeline/Tween.js +3 -0
  289. package/modules/timeline/letterbox.js +1 -0
  290. package/modules/triggers/index.js +36 -17
  291. package/modules/vegetation/Vegetation.js +81 -19
  292. package/modules/vegetation/densityMap.js +13 -8
  293. package/modules/vegetation/draw.js +147 -24
  294. package/modules/vegetation/groundChunks.js +20 -5
  295. package/modules/vegetation/index.js +3 -3
  296. package/modules/vegetation/modelGeometry.js +9 -4
  297. package/modules/water/Water.js +11 -8
  298. package/modules/weather/Weather.js +7 -2
  299. package/modules/weather/shaders.js +25 -5
  300. package/modules/weather/weatherDraw.js +20 -6
  301. package/modules/world/World.js +2 -1
  302. package/modules/world/index.js +2 -2
  303. package/modules/world/persist.js +6 -2
  304. package/modules/world/views.js +15 -2
  305. package/package.json +4 -1
  306. package/presets.js +5 -5
  307. package/render/PostFX.js +84 -41
  308. package/render/backend.js +137 -16
  309. package/render/cascades.js +3 -1
  310. package/render/cascades.tsl.js +2 -0
  311. package/render/daylight.js +7 -1
  312. package/render/detail.js +7 -4
  313. package/render/effects.js +27 -8
  314. package/render/fogLook.js +24 -0
  315. package/render/fuse.js +5 -2
  316. package/render/fx/detail.tsl.js +9 -7
  317. package/render/fx/index.js +7 -2
  318. package/render/fx/library.tsl.js +1 -0
  319. package/render/fx/lightShaft.tsl.js +114 -0
  320. package/render/fx/noise.tsl.js +25 -8
  321. package/render/fx/objectOrigin.tsl.js +39 -10
  322. package/render/fx/particles.tsl.js +23 -6
  323. package/render/fx/patchNodes.tsl.js +17 -12
  324. package/render/fx/pcss.tsl.js +51 -0
  325. package/render/fx/postWebGPU.tsl.js +89 -29
  326. package/render/fx/sky.tsl.js +3 -9
  327. package/render/fxNumbers.js +10 -4
  328. package/render/impostor.tsl.js +107 -0
  329. package/render/lighting.js +33 -1
  330. package/render/lightmap.js +42 -28
  331. package/render/lights.js +19 -3
  332. package/render/materials.js +6 -4
  333. package/render/mergeCommon.js +4 -1
  334. package/render/occlusion.js +14 -4
  335. package/render/patches.js +79 -41
  336. package/render/postRuns.js +32 -0
  337. package/render/postWebGL.js +97 -10
  338. package/render/probes.js +10 -14
  339. package/render/shaderErrors.js +2 -1
  340. package/render/shadowCache.tsl.js +33 -5
  341. package/render/shadows.js +42 -16
  342. package/render/slots.js +8 -5
  343. package/render/vertexInputs.js +52 -0
  344. package/types/core.d.ts +114 -46
  345. package/types/gameplay.d.ts +56 -23
  346. package/types/generated/core/audio/Audio.d.ts +27 -1
  347. package/types/generated/core/base/Random.d.ts +1 -1
  348. package/types/generated/core/input/Input.d.ts +6 -8
  349. package/types/generated/core/input/inputSeat.d.ts +1 -1
  350. package/types/generated/core/inspect/Budget.d.ts +26 -0
  351. package/types/generated/core/inspect/DebugOverrides.d.ts +0 -2
  352. package/types/generated/core/saves/Saves.d.ts +10 -7
  353. package/types/generated/core/saves/session.d.ts +8 -2
  354. package/types/generated/core/scene/Rays.d.ts +1 -3
  355. package/types/generated/modules/particles/Particles.d.ts +1 -1
  356. package/types/generated/modules/world/World.d.ts +2 -1
  357. package/types/generated/render/PostFX.d.ts +35 -9
  358. package/types/physics.d.ts +43 -11
  359. package/types/pixel.d.ts +1 -1
  360. package/types/tsl.d.ts +62 -1
  361. package/types/world.d.ts +12 -3
  362. package/ui/Focus.js +7 -5
  363. package/ui/Parts.js +1 -1
  364. package/ui/touchPart.js +6 -3
@@ -1,17 +1,19 @@
1
1
  // engine.catalog(): what this game can do, read from the registrations that already exist (module definitions, ops.define,
2
- // saves.register, describe.add, module hooks, params schemas). Why a reader and not a registry: a second list would drift from the code;
2
+ // saves.define, describe.add, module hooks, params schemas). Why a reader and not a registry: a second list would drift from the code;
3
3
  // this file runs no gameplay and stores only who registered what (so an op or save part can be traced back to its module).
4
4
  // engine.catalog() -> short list, one line of data per module (+ 'core' and 'game' for what no module registered)
5
5
  // engine.catalog('shop') -> one module expanded: dependencies, ops with args / defaults / failure codes, saved parts, time model
6
6
  // engine.catalog('shop.buy') -> one op expanded (args schema, reasons, its last attempt)
7
7
  // engine.catalog({ find: 'buy' }) -> the short list filtered by id, label, op or save name
8
8
  // engine.catalog('post') -> a capability that is no module (post chain, shadows): its entry names and what it holds now
9
+ // engine.catalog('picture') -> the picture menu: every picture capability, on or not, can it run here, cost, one way on, limits (pictureMenu.js)
9
10
  // Ownership: engine.use / module init take a snapshot of the op, save and describe names before and after (catalogSnap / catalogClaim);
10
11
  // what existed before the first engine.use is 'core', what appeared outside any module is 'game'. An op named '<module>.verb' or a save
11
12
  // part keyed by the module name belongs to that module even when registered later (from game code calling into the module).
12
13
  import { parseSchema, schemaInfo } from '../base/params.js';
13
14
  import { ENGINE_PARAMS } from '../engine/Engine.js';
14
15
  import { SKIP_KINDS, TIME_HOOKS } from '../engine/moduleTypes.js';
16
+ import { pictureMenu } from './pictureMenu.js';
15
17
 
16
18
  const MAX_API = 200; // the dev bridge narrows this to what the api page lists (tools/threedog/catalog.mjs)
17
19
 
@@ -67,7 +69,7 @@ function opInfo(e, name, full) {
67
69
  }
68
70
  function saveInfo(e, key) {
69
71
  const p = e.saves.providers.get(key);
70
- return { key, version: p.version, ...(p.first ? { first: true } : {}), ...(Object.keys(p.migrate || {}).length ? { migrates: Object.keys(p.migrate).map(Number) } : {}) };
72
+ return { key, version: p.version, ...(p.first !== undefined && p.first !== false ? { first: p.first } : {}), ...(Object.keys(p.migrate || {}).length ? { migrates: Object.keys(p.migrate).map(Number) } : {}) };
71
73
  }
72
74
 
73
75
  /** Public methods and properties of a module's api object (own and inherited, no _private ones) */
@@ -139,6 +141,19 @@ const CAPABILITIES = {
139
141
  effects: e.post._list.map(h => ({ name: h.name, slot: h.slot, order: h.order, enabled: h.enabled, params: Object.fromEntries(Object.entries(h.params).map(([k, v]) => [k, toData(v)])) })) } }),
140
142
  shadows: e => ({ describe: 'describe().picture', facts: { enabled: e.shadows.enabled, cascades: !!e.shadows.csm } }),
141
143
  };
144
+ /**
145
+ * One lookup scheme for every name: 'module:<id>', 'op:<name>', 'capability:<id>' always mean that kind; a bare name tries the engine's few
146
+ * capability names first (fixed and documented, where a game's module names are not), then modules, ops, 'core' / 'game'.
147
+ */
148
+ const KINDS = ['module', 'op', 'capability'];
149
+ const isCapability = (e, n) => n === 'picture' || (Object.hasOwn(CAPABILITIES, n) && !!e[n]);
150
+ function lookup(e, kind, n, o) {
151
+ if ((!kind || kind === 'capability') && isCapability(e, n)) return n === 'picture' ? pictureMenu(e, o) : capabilityEntry(e, n);
152
+ if ((!kind || kind === 'module') && e.modules.has(n)) return moduleEntry(e, e.modules.get(n));
153
+ if ((!kind || kind === 'op') && e.ops.defs.has(n)) return opInfo(e, n, true);
154
+ if (!kind && (n === 'core' || n === 'game')) return looseEntry(e, n);
155
+ return null;
156
+ }
142
157
  function capabilityEntry(e, id) {
143
158
  const { describe, facts } = CAPABILITIES[id](e);
144
159
  return { id, kind: 'capability', ops: [], saves: [], queries: { describe, extra: [], api: apiNames(e[id]) }, facts, problems: [] };
@@ -169,22 +184,26 @@ function entries(e) {
169
184
  * No argument: a short list (id, state, stage, op and save names, time model, problem count). A module id: that module expanded
170
185
  * (requires / optional, params with defaults and the values in use, ops with args schema and failure codes, saved parts and versions,
171
186
  * time hooks and skip kind, describe fields and api names, problems such as "no skipKind"). An op name: that op expanded, with its last attempt.
187
+ * Names: 'module:<id>', 'op:<name>', 'capability:<id>' pick the kind; a bare name tries the capabilities ('picture', 'post', 'shadows') first, then
188
+ * modules, ops, 'core' / 'game' (a capability sharing its name with a module says sameNameModule: 'module:<id>').
172
189
  * 'post' or 'shadows': that capability's entry names and what it holds now (effects in the chain, cascades on or off).
190
+ * 'picture': the picture menu (three's features and post effects, one row each: on, runs here, cost class, one way on, recipe, main limit) and the
191
+ * combination checks; o.offered: effect factories not in the chain yet (the dev bridge passes @threedog/post-effects).
173
192
  * The dev bridge `threedog catalog [id]` prints the same data and adds the doc, recipe and source files.
174
- * @param {string | { find?: string }} [id]
193
+ * @param {string | { find?: string }} [id] @param {{ offered?: any[] }} [o]
175
194
  * @returns {any}
176
195
  * @example engine.catalog(); // [{ id: 'calendar', kind: 'module', state: 'running', stage: 'environment', ops: [], saves: ['calendar'], time: 'fixed+skip' }, ...]
177
196
  * engine.catalog('shop').ops[0]; // { name: 'shop.buy', args: { n: { type: 'int', optional: true, default: 1 } }, failures: ['soldOut', 'noMoney'] }
178
197
  * engine.catalog('shop.buy').last; // { tick: 812, ok: false, code: 'noMoney', ... }
179
198
  * engine.catalog({ find: 'throw' }); // only entries whose id, label, op or save mentions "throw"
180
199
  */
181
- export function catalog(e, id) {
200
+ export function catalog(e, id, o) {
182
201
  if (typeof id === 'string') {
183
- if (e.modules.has(id)) return moduleEntry(e, e.modules.get(id));
184
- if (e.ops.defs.has(id)) return opInfo(e, id, true);
185
- if (id === 'core' || id === 'game') return looseEntry(e, id);
186
- if (Object.hasOwn(CAPABILITIES, id) && e[id]) return capabilityEntry(e, id);
187
- return null;
202
+ const i = id.indexOf(':'), kind = KINDS.includes(id.slice(0, i)) ? id.slice(0, i) : null, name = kind ? id.slice(i + 1) : id;
203
+ const x = lookup(e, kind, name, o);
204
+ // a capability name the game also gave a module (the game template's 'picture' module): the bare name stays the capability, the module is a prefix away
205
+ if (x && !kind && x.kind !== 'module' && e.modules.has(name)) x.sameNameModule = `module:${name}`;
206
+ return x;
188
207
  }
189
208
  const list = entries(e).map(summary);
190
209
  const q = id?.find?.toLowerCase();
@@ -107,7 +107,8 @@ export class DebugView {
107
107
  if (VIEW_MODES.includes(name) || this._defs.has(name)) throw codedError('debug-view', `engine.debug.defineView('${name}'): this view mode already exists; pick another name`);
108
108
  if (typeof def?.apply !== 'function' || typeof def.what !== 'string') throw codedError('debug-view', `engine.debug.defineView('${name}', { what, apply }): what is a one-line explanation, apply(scene) returns its undo`, TypeError);
109
109
  this._defs.set(name, def);
110
- return { remove: () => { if (this.active?.mode === name) this._off(); this._defs.delete(name); } };
110
+ // by identity: a stale handle (the mode was removed and defined again) must not turn off or delete the newer view of the same name
111
+ return { remove: () => { if (this._defs.get(name) !== def) return; if (this.active?.mode === name) this._off(); this._defs.delete(name); } };
111
112
  }
112
113
  /** Every mode a view can show now: the built-in ones and those modules added @returns {string[]} */
113
114
  modes() { return [...VIEW_MODES, ...this._defs.keys()]; }
@@ -11,6 +11,8 @@ import { slotHolders } from '../scene/pictureSlots.js';
11
11
  import { isShown } from '../base/util.js';
12
12
  import { backendFacts } from '../../render/backend.js';
13
13
  import { pixelSizeOn } from '../scene/pixelRatio.js';
14
+ import { autoLowered } from '../scene/adaptive.js';
15
+ import { pictureChecks } from './pictureChecks.js';
14
16
 
15
17
  const shadowName = v => Object.keys(SHADOW_TYPES).find(k => SHADOW_TYPES[k].three === v) ?? String(v);
16
18
  const TONE_NAMES = { [NoToneMapping]: 'none', [LinearToneMapping]: 'linear', [ReinhardToneMapping]: 'reinhard', [CineonToneMapping]: 'cineon',
@@ -19,12 +21,21 @@ const toneName = v => TONE_NAMES[v] ?? String(v);
19
21
  /** What a build without the dev server says for every picture value (core/inspect/pictureWriters.js stays out of it) */
20
22
  export const NO_WRITERS = 'not tracked: source lines are only known on the dev server (threedog dev or npm run dev); a bundled build has no file:line to give';
21
23
 
22
- /** scene.fog as data @param {any} f */
23
- const fogOf = f => (!f ? null : f.isFogExp2 ? { type: 'FogExp2', color: hex(f.color), density: f.density } : { type: 'Fog', color: hex(f.color), near: f.near, far: f.far });
24
+ /**
25
+ * Whether the scene has fog / an environment: the classic field or its TSL node (WebGPU). The one reading, shared with the picture menu,
26
+ * so a catalog row saying "on" and describe() saying "none" cannot happen for the same scene
27
+ * @param {any} s scene
28
+ */
29
+ export const sceneFog = s => s.fog || s.fogNode || null;
30
+ export const sceneEnvironment = s => s.environment || s.environmentNode || null;
31
+ const NODE = { type: 'Node' }; // a TSL node: its value is shader code, not data to print
32
+
33
+ /** scene.fog as data @param {any} s scene */
34
+ const fogOf = s => { const f = sceneFog(s); return !f ? null : !s.fog ? NODE : f.isFogExp2 ? { type: 'FogExp2', color: hex(f.color), density: f.density } : { type: 'Fog', color: hex(f.color), near: f.near, far: f.far }; };
24
35
  /** scene.background as data: a Color by value, a texture by kind @param {any} s */
25
36
  function backgroundOf(s) {
26
37
  const b = s.background;
27
- if (!b) return null;
38
+ if (!b) return s.backgroundNode ? NODE : null;
28
39
  return b.isColor ? { type: 'Color', color: hex(b) } : { type: b.isCubeTexture ? 'CubeTexture' : 'Texture', name: b.name || null, intensity: s.backgroundIntensity };
29
40
  }
30
41
  /** Whether three draws with this light: every parent visible and on a layer the camera sees (the test three's renderer makes) */
@@ -39,7 +50,7 @@ const lightOf = (l, cam) => ({ type: l.type, name: l.name, color: hex(l.color),
39
50
  export function describePicture(e) {
40
51
  const r = e.renderer, s = e.scene, lights = /** @type {any[]} */ ([]);
41
52
  s.traverse(o => { if (/** @type {any} */ (o).isLight && !(/** @type {any} */ (o).isLightProbeGrid)) lights.push(lightOf(o, e.camera)); }); // a probe grid has its own rows (probes)
42
- return { toneMapping: toneName(r.toneMapping), exposure: r.toneMappingExposure, fog: fogOf(s.fog), environment: { present: !!s.environment, intensity: s.environmentIntensity },
53
+ return { toneMapping: toneName(r.toneMapping), exposure: r.toneMappingExposure, fog: fogOf(s), environment: { present: !!sceneEnvironment(s), intensity: s.environmentIntensity },
43
54
  background: backgroundOf(s), lights, shadows: { enabled: r.shadowMap.enabled, type: shadowName(r.shadowMap.type) }, slots: slotHolders(e), writers: e._picture?.list() ?? { tracked: false, note: NO_WRITERS } };
44
55
  }
45
56
 
@@ -67,7 +78,7 @@ function engineDefaults(e) {
67
78
  const r = e.renderer, s = e.scene, bg = s.background, rows = [];
68
79
  if (bg && bg === e.baseBackground && bg.getHex() === e.baseBackgroundHex) rows.push({ what: 'scene.background', value: `#${bg.getHexString()}`, off: 'scene.background = your color or texture' });
69
80
  for (const [name, l] of Object.entries(e.lights ?? {})) if (l.parent) rows.push({ what: `lights.${name}`, value: `${l.type} ${rv(l.intensity)}`, off: 'createEngine({ lights: false })' });
70
- if (r.shadowMap.enabled) rows.push({ what: 'renderer.shadowMap', value: shadowName(r.shadowMap.type), off: 'renderer.shadowMap.enabled = false' });
81
+ if (r.shadowMap.enabled) rows.push({ what: 'renderer.shadowMap', value: shadowName(r.shadowMap.type), off: 'engine.shadows.enabled = false' });
71
82
  // render/postWebGL.js direct(): only once the game has picked a tone curve, so a Color background agrees with the effect chain's OutputPass
72
83
  if (r.toneMapping !== NoToneMapping && (bg?.isColor || bg == null) && !e.post?.active) rows.push({ what: 'background tone', value: 'drawn as a 1x1 tone-mapped texture during the render; scene.background itself is not changed', off: 'renderer.toneMapping = THREE.NoToneMapping' });
73
84
  return rows;
@@ -104,30 +115,28 @@ export function describeRender(e) {
104
115
  `renderer: ${tone.value}${by(tone)} exposure ${exposure.value} shadows ${shadows.enabled ? shadows.type : 'off'}${b.owned ? '' : ' [game-supplied renderer]'} output ${r.outputColorSpace}${srgb}`,
105
116
  `post: ${post.map(x => `${x.name}${x.held ? ` held off: ${x.held}` : x.on ? '' : ' off'}${Object.keys(x.params).length ? `{${kv(x.params)}}` : ''} (${x.writer})`).join(', ') || 'none'}${antialias.samples ? ` + MSAA x${antialias.samples}` : antialias.replacedBy ? ` + ${antialias.replacedBy} in place of MSAA` : ''}`,
106
117
  `lights: ${lights.map(l => `${l.name} ${l.type} ${l.intensity}${l.writer ? ` (${l.writer}${l.at ? ' ' + l.at : ''})` : ''}`).join(', ')}`,
107
- `scene: background ${sceneWord(backgroundOf(e.scene))} fog ${sceneWord(fogOf(e.scene.fog))} environment ${e.scene.environment ? rv(e.scene.environmentIntensity) : 'none'}`,
118
+ `scene: background ${sceneWord(backgroundOf(e.scene))} fog ${sceneWord(fogOf(e.scene))} environment ${sceneEnvironment(e.scene) ? rv(e.scene.environmentIntensity) : 'none'}`,
108
119
  `engine defaults on the picture: ${defaults.map(d => d.what).join(', ') || 'none'}`,
109
120
  ].join('\n');
110
- // probe sets (render/probes.js): how many, how dense, who made them, what they miss and what doubles them
121
+ // probe sets (render/probes.js): how many, how dense, who made them, what they miss (light counted twice is a picture check, below)
111
122
  const probes = [...(e._probeSets ?? [])].map(s => s.info());
112
123
  if (probes.length) text += `
113
124
  probes: ${probes.map(p => `${p.count} (${p.counts.join('x')}, step ${p.step.join('/')}) from ${p.source} by ${p.owner}`).join('; ')}`
114
125
  + (probes[0].outside.count ? `
115
- outside the probe grid (no probe light): ${probes[0].outside.count} lit object(s), ${probes[0].outside.names.join(', ')}` : '')
116
- + (probes[0].doubled.length ? `
117
- counted twice with the probes: ${probes[0].doubled.join(', ')}` : '');
126
+ outside the probe grid (no probe light): ${probes[0].outside.count} lit object(s), ${probes[0].outside.names.join(', ')}` : '');
118
127
  const dv0 = e.debug?.viewState?.(), dv = dv0 && dv0.mode !== 'off' ? dv0 : null;
119
128
  if (dv) text = `DEBUG VIEW "${dv.mode}" (by ${dv.owner}) is ON: ${dv.what}. This is NOT the real picture; the debug view 'off' restores it.
120
129
  ` + text;
121
130
  // render scale: the canvas resolution against the display. auto: the adaptive resolution lowered it at some point (it raises it back when frames are fast)
122
131
  const dpr = (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1, cur = r.getPixelRatio(), ad = e.adaptive;
123
- const scale = { current: Math.round(cur * 100) / 100, devicePixelRatio: dpr, upscaled: cur < dpr - 0.01 && !pixelSizeOn(e), pixelSize: e._pixelSize, autoLowered: !!ad?.lowered && cur < (ad.max ?? cur) - 0.01,
132
+ const scale = { current: Math.round(cur * 100) / 100, devicePixelRatio: dpr, upscaled: cur < dpr - 0.01 && !pixelSizeOn(e), pixelSize: e._pixelSize, autoLowered: autoLowered(e),
124
133
  adaptive: !!ad?.on, floor: ad?.min ?? null, max: ad?.max ?? null };
125
134
  text += `
126
135
  render scale: ${scale.current} of device pixel ratio ${dpr}${scale.pixelSize ? ` (pixelSize ${scale.pixelSize}: one art pixel is ${scale.pixelSize} screen pixels)` : ''}${scale.upscaled ? ' (picture is upscaled, softer than the screen)' : ''}${scale.autoLowered ? ` (auto-lowered by adaptive resolution, floor ${scale.floor}; adaptiveResolution: false turns it off)` : ''}`;
127
136
  // the lightmap (render/lightmap.js): what is baked, and what no longer matches the bake
128
137
  const lightmap = e._lightmap?.info() ?? null;
129
138
  if (lightmap) text += `\nlightmap: ${lightmap.meshes} mesh(es), ${lightmap.size} map from ${lightmap.file}`
130
- + ['skipped', 'missing', 'moved', 'doubled', 'shared'].map(k => (lightmap[k].length ? `, ${k}: ${lightmap[k].slice(0, 3).map(x => x.name ?? x).join(', ')}` : '')).join('');
139
+ + ['skipped', 'missing', 'moved', 'shared'].map(k => (lightmap[k].length ? `, ${k}: ${lightmap[k].slice(0, 3).map(x => x.name ?? x).join(', ')}` : '')).join('');
131
140
  // occlusion culling (render/occlusion.js): what it skipped this frame, so a game can see whether it pays
132
141
  const occlusion = e.occlusion?.enabled ? e.occlusion.stats : null;
133
142
  if (occlusion) text += `\nocclusion: ${occlusion.hidden} of ${occlusion.watched} big things hidden, ${occlusion.trianglesSkipped} triangles skipped`;
@@ -135,7 +144,10 @@ render scale: ${scale.current} of device pixel ratio ${dpr}${scale.pixelSize ? `
135
144
  let bundles = null;
136
145
  e.scene.traverse(o => { if (o.isBundleGroup) { bundles ??= { groups: 0, meshes: 0, replayed: !!r.backend?.beginBundle }; bundles.groups++; o.traverse(c => { if (c.isMesh) bundles.meshes++; }); } });
137
146
  if (bundles) text += `\nrender bundles: ${bundles.groups} BundleGroup(s), ${bundles.meshes} mesh(es), ${bundles.replayed ? 'replayed as recorded: after changing what is inside, set group.needsUpdate = true' : 'plain groups on this backend, no gain (only WebGPU has bundles)'}`;
138
- return { debugView: dv, scale, toneMapping: tone, exposure, shadows, post, antialias, lights, defaults, probes, lightmap, occlusion, bundles, text };
147
+ // settings wrong together whatever the game wants (core/inspect/pictureChecks.js): one line each, last, so the fix is the last thing read
148
+ const checks = pictureChecks(e);
149
+ for (const c of checks) text += `\npicture ${c.kind === 'mistake' ? 'check' : 'note'} ${c.id}: ${c.text}`;
150
+ return { debugView: dv, scale, toneMapping: tone, exposure, shadows, post, antialias, lights, defaults, probes, lightmap, occlusion, bundles, checks, text };
139
151
  }
140
152
 
141
153
  /**
@@ -9,7 +9,7 @@ const STRINGS = {
9
9
  head: '[Game state] running {s} s{flags}',
10
10
  actions: 'Can do (engine.ops): {list}',
11
11
  error: '[Error, gameplay frozen] {where}: {message}', errorAt: ' ({at})',
12
- errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}', blocked: 'Blocked modules: {list}',
12
+ errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}', blockedModules: 'Blocked modules: {list}',
13
13
  halted: ', halted', headless: ', headless', notReady: ', still loading',
14
14
  waiting: 'Loading: {waiting} ({pending} pending, {done}/{total} done)', loadFailed: 'Load failed{blocked}: {list}', blocked: ' (start blocked)',
15
15
  loadWarn: 'Loaded with missing references: {list}',
@@ -36,9 +36,11 @@ const STRINGS = {
36
36
  nearItem: ' - {name} [{kind}] {dist} m, {dir}, {rel}{use}',
37
37
  use: ', interact: {label}',
38
38
  modules: 'Modules: {list}',
39
- perf: 'Perf: fps {fps}, CPU {cpu} ms/frame, draw calls {calls}, triangles {tris}{chunks}',
39
+ perf: 'Perf: fps {fps}, CPU {cpu} ms/frame{frames}, draw calls {calls}, triangles {tris}{chunks}',
40
+ cpuFrames: ' (median of {n} frames)',
40
41
  chunks: ', chunks loaded {loaded} / visible {visible} / queued {queued}',
41
42
  extra: '{name}: {json}',
43
+ changed: 'Values being changed now: {list}',
42
44
  tables: 'Engine tables (entries; describe <name> for one): {list}',
43
45
  more: '... {n} more modules: {names} (describe <name> for one)',
44
46
  nearMore: ' ... {n} more',
@@ -57,12 +59,12 @@ import { fmt } from '../base/validate.js';
57
59
  import { r1 } from '../base/math.js';
58
60
  import { getPath } from '../base/util.js';
59
61
 
60
- const NEAR_SUMMARY = 5, LINE = 110;
62
+ const NEAR_SUMMARY = 5, LINE = 110, CHANGED_ROW = 120, CHANGED_LINE = 360;
61
63
  const tr = (table, k) => (k != null && STRINGS[table][k]) || (k ?? STRINGS.none);
62
64
  const n1 = v => (typeof v === 'number' ? r1(v) : v);
63
65
  // Standard fields get sentences above; data from other modules is squeezed into one JSON line
64
66
  const SHOWN = new Set(['nearbyRadius', 'ready', 'error', 'disabledModules', 'loading', 'audio', 'time', 'player', 'camera', 'nearby', 'actions', 'ui', 'cutscene',
65
- 'modules', 'perf', 'weather', 'render', 'threePatches']); // threePatches: page-wide, the same every call; describe() JSON carries it, the text stays short
67
+ 'modules', 'perf', 'changed', 'weather', 'render', 'threePatches']); // threePatches: page-wide, the same every call; describe() JSON carries it, the text stays short
66
68
  // engine bookkeeping in describe(): one count each in the summary, the content one describeText({ path }) away
67
69
  const TABLES = new Set(['holds', 'input', 'control', 'shared', 'wraps', 'slots', 'scene', 'owned', 'picture', 'renderer']);
68
70
  const argText = a => Object.entries(a || {}).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(',') : v}`).join(' ');
@@ -108,7 +110,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
108
110
  }
109
111
  if (d.disabledModules?.length) L.push(fmt(STRINGS.disabled, { list: d.disabledModules.join(', ') }));
110
112
  const blocked = Object.entries(d.moduleStates ?? {}).filter(([, s]) => s.startsWith('blocked')).map(([n, s]) => `${n} ${s}`);
111
- if (blocked.length) L.push(fmt(STRINGS.blocked, { list: blocked.join('; ') }));
113
+ if (blocked.length) L.push(fmt(STRINGS.blockedModules, { list: blocked.join('; ') }));
112
114
  if (t.clock) L.push(fmt(STRINGS.time, { clock: t.clock, day: t.day, season: t.season ? ', ' + tr('season', t.season) : '', dayNight: t.isDay ? STRINGS.day
113
115
  : STRINGS.night }));
114
116
  const w = d.weather, wl = d.weatherDraw ?? {}; // weather state, and what of it is drawn (the drawing half)
@@ -143,9 +145,15 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
143
145
  if (d.actions) L.push(fmt(STRINGS.actions,
144
146
  { list: d.actions.map(a => `${a.ok ? '✓' : '✗'} ${a.op}${a.args && Object.keys(a.args).length ? ' ' + argText(a.args) : ''}${a.ok ? '' : ` (${a.code})`}`).join(' · ') }));
145
147
  const pf = d.perf;
146
- L.push(fmt(STRINGS.perf, { fps: pf.fps ?? '-', cpu: pf.cpuMs ?? '-', calls: pf.drawCalls, tris: pf.triangles, chunks: pf.chunks
148
+ L.push(fmt(STRINGS.perf, { fps: pf.fps ?? '-', cpu: pf.cpuMs ?? '-', frames: pf.cpuFrames ? fmt(STRINGS.cpuFrames, { n: pf.cpuFrames }) : '', calls: pf.drawCalls, tris: pf.triangles, chunks: pf.chunks
147
149
  ? fmt(STRINGS.chunks, pf.chunks) : '' }));
150
+ if (pf.notice) L.push(pf.notice); // over the game's budget, slower than its baseline, resolution lowered (engine.budget.notice)
148
151
  if (full && d.render?.text) L.push(d.render.text); // render block only in the full text; the summary stays short (describe render shows it)
152
+ if (d.changed) { // bounded: names, values and how-chains are game data, so each row and the whole line are cut (the full rows are describe shared)
153
+ const rows = d.changed.map(c => { const x = String(c.text).replace(/\s+/g, ' '); return x.length > CHANGED_ROW ? x.slice(0, CHANGED_ROW - 1) + '…' : x; });
154
+ const all = rows.join('; ');
155
+ L.push(fmt(STRINGS.changed, { list: all.length > CHANGED_LINE ? all.slice(0, CHANGED_LINE - 1) + '… (describe shared for all)' : all }));
156
+ }
149
157
  L.push(fmt(STRINGS.modules, { list: d.modules.map(m => `${m.name} (${m.type})`).join(', ') }));
150
158
  if (full) {
151
159
  for (const k in d) if (!SHOWN.has(k)) L.push(fmt(STRINGS.extra, { name: k, json: JSON.stringify(d[k]) }));
@@ -15,7 +15,7 @@ const STRINGS = {
15
15
  changed: 'Shader programs were compiled during play ({from} -> {to}) and, compared with the last observation, the light layout also changed ({was} -> {now}). ' +
16
16
  'three.js compiles every material again for a new light setup, so adding, removing or hiding a light mid-game freezes a frame. ' +
17
17
  'Use engine.use(lightPool({ point: 8 })) and engine.lightPool.add(torch, {...}) for many lights, or fade a fixed set with intensity ' +
18
- '(recipes/09-materials-lights-models.md "Lights and stalls")',
18
+ '(recipes/09-materials-lights-models.md §1b)',
19
19
  };
20
20
 
21
21
  /** Visible lights by the kinds three.js counts in its light setup (ambient and probes do not change programs), as one comparable string */
@@ -333,7 +333,7 @@ export const metadata = {
333
333
  "documented": true,
334
334
  "names": [
335
335
  "findSpawn",
336
- "createPlayer",
336
+ "addPlayer",
337
337
  "moveInput",
338
338
  "addVehicle",
339
339
  "support",
@@ -833,10 +833,12 @@ export const metadata = {
833
833
  "documented": true,
834
834
  "names": [
835
835
  "marker",
836
- "counter",
836
+ "addCounter",
837
837
  "bump",
838
838
  "value",
839
839
  "bar",
840
+ "button",
841
+ "hint",
840
842
  "remove",
841
843
  "markers"
842
844
  ],
@@ -1593,6 +1595,12 @@ export const metadata = {
1593
1595
  "docType": "number",
1594
1596
  "desc": "(experimental) How many photos the album keeps at most, default 50"
1595
1597
  },
1598
+ "pathTracer": {
1599
+ "type": "any",
1600
+ "optional": true,
1601
+ "docType": "(() => Promise<any>) | null",
1602
+ "desc": "(experimental) The game's import of its optional path tracer, called on the first photo.trace(): () => import('three-gpu-pathtracer/webgpu')"
1603
+ },
1596
1604
  "scale": {
1597
1605
  "type": "any",
1598
1606
  "optional": true
@@ -1618,11 +1626,13 @@ export const metadata = {
1618
1626
  "documented": true,
1619
1627
  "names": [
1620
1628
  "take",
1629
+ "trace",
1621
1630
  "subject",
1622
1631
  "album",
1623
1632
  "canTake",
1624
1633
  "format",
1625
- "maxAlbum"
1634
+ "maxAlbum",
1635
+ "tracing"
1626
1636
  ],
1627
1637
  "sections": [],
1628
1638
  "saves": [],
@@ -2667,6 +2677,7 @@ export const metadata = {
2667
2677
  "removeInstance",
2668
2678
  "restoreInstance",
2669
2679
  "instanceAt",
2680
+ "plantOf",
2670
2681
  "material",
2671
2682
  "patches"
2672
2683
  ],
@@ -2781,15 +2792,15 @@ export const metadata = {
2781
2792
  "desc": "Flat shading (low poly), default true"
2782
2793
  },
2783
2794
  "size": {
2784
- "type": "any",
2795
+ "type": "number",
2785
2796
  "optional": true,
2786
- "docType": "number",
2797
+ "min": 5e-324,
2787
2798
  "desc": "Edge length of the global water plane (meters), default 900"
2788
2799
  },
2789
2800
  "segments": {
2790
- "type": "any",
2801
+ "type": "int",
2791
2802
  "optional": true,
2792
- "docType": "number",
2803
+ "min": 1,
2793
2804
  "desc": "Mesh subdivision of the global water, default 150"
2794
2805
  }
2795
2806
  },
@@ -3108,7 +3119,7 @@ export const metadata = {
3108
3119
  },
3109
3120
  "player": {
3110
3121
  "module": "characters",
3111
- "by": "createPlayer"
3122
+ "by": "addPlayer"
3112
3123
  }
3113
3124
  },
3114
3125
  "sections": {
@@ -3258,7 +3269,7 @@ export const metadata = {
3258
3269
  "characters": {
3259
3270
  "file": "packages/engine/modules/characters/contract.js",
3260
3271
  "api": [
3261
- "createPlayer",
3272
+ "addPlayer",
3262
3273
  "removePlayer",
3263
3274
  "findSpawn",
3264
3275
  "findPath",
@@ -3654,7 +3665,7 @@ export const metadata = {
3654
3665
  "collide": {
3655
3666
  "type": "any",
3656
3667
  "optional": true,
3657
- "desc": "collision: 'box', 'circle', { circle: radius, occluder?: false }, or false = none",
3668
+ "desc": "collision: 'box', 'circle', { circle?: radius, occluder?: false, layer?: 'gate' } (layer: characters with passes: ['gate'] walk through), or false = none",
3658
3669
  "label": "Collision",
3659
3670
  "rare": true
3660
3671
  },
@@ -3966,14 +3977,21 @@ export const metadata = {
3966
3977
  "seen": "a hand-made inventory (items kept in your own array / object)",
3967
3978
  "use": "the inventory module: engine.use(inventory()), engine.inventory.add / remove / has (counts, containers, events, saved with the game)",
3968
3979
  "quiet": "/\\b(engine|e|eng)\\.inventory\\b|\\binventory\\(\\s*[{)]/",
3969
- "code": "/(?:\\b(?:const|let|var)\\s+|\\bthis\\.)(inventory|backpack|bag|pockets|inv)(?:Items|Slots|List|Contents|Data|Map|Counts?|s)?\\s*=\\s*(\\[\\s*\\]|\\{\\s*\\}|new Map\\b|new Set\\b)/i",
3980
+ "code": "/\\b(?:inventory|backpack|bag|pockets|inv)(?:Items|Slots|List|Contents|Data|Map|Counts?|s)?\\s*(?:[=:]\\s*\\(?\\s*(?:\\[\\s*\\]|\\{\\s*\\}|new Map\\b|new Set\\b)|\\.(?:push|splice|unshift|reduce)\\()/i",
3981
+ "near": [
3982
+ {
3983
+ "re": "/[<>]=?\\s*(?:[\\w$]+\\.)*(?:capacity|cap|max\\w*|slots?|limit)\\w*\\b(?!\\s*\\()/i",
3984
+ "lines": 3,
3985
+ "on": "code"
3986
+ }
3987
+ ],
3970
3988
  "tags": false,
3971
3989
  "file": "packages/engine/modules/gameplay/Inventory.js"
3972
3990
  },
3973
3991
  "keys": {
3974
3992
  "kind": "keys",
3975
3993
  "seen": "a raw keydown / keyup listener",
3976
- "use": "engine.input.action('jump', { label, keys }) in a module, the game binds keys with engine.input.bind (rebinding, contexts, gamepad); read engine.input.pressed(name) (recipe 58)",
3994
+ "use": "engine.input.define('jump', { label, keys }) in a module, the game binds keys with engine.input.bind (rebinding, contexts, gamepad); read engine.input.pressed(name) (recipe 58)",
3977
3995
  "raw": "/(?:^|[^\\w.])(?:(?:window|document|self|globalThis|canvas|document\\.body|[\\w.]*domElement)\\.)?(?:addEventListener\\s*\\(\\s*['\"]|on)key(?:down|up)\\b/",
3978
3996
  "yields": {
3979
3997
  "kind": "pause",
@@ -4072,7 +4090,7 @@ export const metadata = {
4072
4090
  "quests": {
4073
4091
  "kind": "quests",
4074
4092
  "seen": "a quest list of its own",
4075
- "use": "the quests module: steps, rewards, markers and the log, saved with the game (recipe 04)",
4093
+ "use": "engine.quests (quests()): steps, rewards, markers and the log, saved with the game (recipe 04)",
4076
4094
  "quiet": "/\\b(engine|e|eng|ctx)\\.quests\\b|\\bquests\\(\\s*[{)]/",
4077
4095
  "code": "/(?:\\b(?:const|let|var)\\s+|\\bthis\\.)(?:quests?|questLog|missions?|objectives?)(?:List|Log|Data|s)?\\s*=\\s*(?:\\[\\s*\\]|\\{\\s*\\}|new Map\\b)/i",
4078
4096
  "file": "packages/engine/modules/gameplay/Quests.js"
@@ -4091,10 +4109,10 @@ export const metadata = {
4091
4109
  "seen": "a hand-made reach check for interacting",
4092
4110
  "use": "engine.interactions.add(target, { ... }): prompt, range and the interact action are handled (recipe 20)",
4093
4111
  "quiet": "/\\b(engine|e|eng|ctx)\\.interactions\\b/",
4094
- "code": "/(?:\\bdistanceTo(?:Squared)?\\(|\\bMath\\.hypot\\(|\\bdist(?:ance)?\\w*)[^;]*<=?\\s*\\d/",
4112
+ "code": "/(?:\\bdistanceTo(?:Squared)?\\(|\\bMath\\.hypot\\(|\\bdist(?:ance)?\\w*)[^;]*<=?\\s*[\\w.]/",
4095
4113
  "near": [
4096
4114
  {
4097
- "re": "/KeyE|['\"]e['\"]|interact|press e\\b|talk/i",
4115
+ "re": "/KeyE|['\"]e['\"]|press e\\b|\\.hud\\.hint\\(/i",
4098
4116
  "lines": 3,
4099
4117
  "on": "raw"
4100
4118
  }
@@ -4104,7 +4122,7 @@ export const metadata = {
4104
4122
  "save": {
4105
4123
  "kind": "save",
4106
4124
  "seen": "a save of its own in localStorage",
4107
- "use": "engine.saves: autosave(minutes), register('game', { version: 1, save, load }), and Continue on the start screen (recipe 63); versions, slots and a corrupt save are handled",
4125
+ "use": "engine.saves: autosave(minutes), define('game', { version: 1, save, load }), and Continue on the start screen (recipe 63); versions, slots and a corrupt save are handled",
4108
4126
  "quiet": "/\\bengine\\.saves\\b/",
4109
4127
  "code": "/\\blocalStorage\\.setItem\\s*\\(/",
4110
4128
  "notRaw": "/setItem\\s*\\(\\s*(?![^,)]*(?:save|progress))[^,)]*(?:volume|mute|lang|locale|theme|music|sfx|quality|sensitiv|brightness|fullscreen|tutorial|dismiss|setting|pref|option|keybind)/i",
@@ -4113,7 +4131,7 @@ export const metadata = {
4113
4131
  "settings": {
4114
4132
  "kind": "settings",
4115
4133
  "seen": "a settings menu of its own",
4116
- "use": "the settings module: volume, keys, quality and language in one menu that remembers itself; settings.define adds your own (recipe 26)",
4134
+ "use": "engine.settings (settings()): volume, keys, quality and language in one menu that remembers itself; engine.settings.define adds your own (recipe 26)",
4117
4135
  "quiet": "/\\bsettings\\(|\\bengine\\.settings\\b/",
4118
4136
  "code": "/\\b(createElement|innerHTML|className|classList|getElementById|querySelector|\\.id)\\b/",
4119
4137
  "raw": "/(?:createElement|innerHTML|className|classList|getElementById|querySelector|\\.id\\b)[^,;{}]*(?:settings|options-?(?:menu|panel|screen)|pause-?menu)|(?:settings|options|pause)-?(?:menu|panel|screen)[^,;{}]*(?:createElement|innerHTML|className|classList|getElementById|querySelector|\\.id\\b)/i",
@@ -0,0 +1,148 @@
1
+ // Combination checks: picture settings read together off the three.js objects (no pixels). The one place a combination is judged:
2
+ // describe().render prints the results (field `checks`, one line each), `threedog shot` puts them first in its hint lines
3
+ // (packages/tools/picture/hints.mjs), a probe set or lightmap load warns once with the same text.
4
+ // Two kinds, and the line between them is the rule: kind 'mistake' only when the settings alone prove the picture wrong whatever the game
5
+ // wants (baked light plus the fill it baked counts twice), with a "Fix:"; kind 'note' when the settings make a fault likely but only the
6
+ // drawn picture could prove it (a top-down view never shows the horizon, a metal can glow on its own): the facts, never "must fix".
7
+ // Never taste ("too dark", "too much bloom"), never a target value. Runs on describe() and at load, never per frame: some walk the scene.
8
+ import * as THREE from 'three';
9
+ import { mats, noteFillLight, noteEnvironment } from '../../render/lit.js';
10
+ import { cameraFrustum } from '../base/math.js';
11
+ import { drawnAFrame } from '../../render/backend.js';
12
+ import { fogLook } from '../../render/fogLook.js';
13
+
14
+ const nameOf = o => o.name || `${o.type} ${o.id}`;
15
+ const hex = c => '#' + c.getHexString(THREE.SRGBColorSpace);
16
+ const note = (out, id, text) => out.push({ id, kind: 'note', text });
17
+
18
+ /** Metal with no environment map has only the direct lights to reflect. A note: half metal keeps a diffuse color, an emissive one glows by itself */
19
+ function metalNoEnv(e, out) {
20
+ const s = e.scene;
21
+ if (s.environment || s.environmentNode) return;
22
+ const metal = new Set();
23
+ s.traverseVisible(o => {
24
+ if (!o.isMesh) return;
25
+ // a metalness map or node is the game's own math: its value is unknown here, so it is not counted
26
+ for (const m of mats(o)) if ((m?.isMeshStandardMaterial || m?.isMeshStandardNodeMaterial) && m.metalness >= 0.5 && !m.metalnessNode && !m.metalnessMap && !m.envMap && !m.envNode) metal.add(nameOf(o));
27
+ });
28
+ if (!metal.size) return;
29
+ const bg = s.background?.isTexture ? ' (scene.background is not one: it lights nothing)' : '';
30
+ note(out, 'metal-no-env', `no environment reflection on ${metal.size} metal mesh(es) (${[...metal][0]}): what metal reflects comes from scene.environment or material.envMap, and neither is set${bg}.`);
31
+ }
32
+
33
+ /**
34
+ * Baked light (a probe set or a lightmap) plus a light the bake already saw: that light counts twice. Exported for the load-time warning of
35
+ * render/probes.js and render/lightmap.js (the same words there). @param {any} e @returns {string | null}
36
+ */
37
+ export function litTwice(e) {
38
+ const probes = !!e._probeSets?.size, lightmap = !!e._lightmap;
39
+ if (!probes && !lightmap) return null;
40
+ const doubled = [];
41
+ let mapped = 0;
42
+ e.scene.traverseVisible(o => {
43
+ if (noteFillLight(o, doubled)) return;
44
+ if (lightmap && o.isLightProbeGrid) doubled.push(`probe grid ${o.name}`); // the lightmap baked the bounce the grid adds again
45
+ else if (probes && !lightmap && o.isMesh && mats(o).some(m => m?.lightMap)) mapped++; // a game's own lightMap under a probe grid
46
+ });
47
+ noteEnvironment(e.scene, doubled);
48
+ if (mapped) doubled.push(`material.lightMap on ${mapped} mesh(es)`);
49
+ if (!doubled.length) return null;
50
+ const what = [probes && 'probe', lightmap && 'lightmap'].filter(Boolean).join(' and ');
51
+ const list = doubled.slice(0, 2).join(', ') + (doubled.length > 2 ? ` and ${doubled.length - 2} more` : '');
52
+ if (!bakeSeenScene(e)) return `${what} light is added on top of ${list}. If the bake saw it, it counts twice (a loaded file does not say which lights it saw). Fix: lower it where the bake takes over, or bake without it.`;
53
+ return `${what} light is added on top of ${list}, which the bake already saw, so it counts twice. Fix: lower it where the bake takes over, or bake without it.`;
54
+ }
55
+
56
+ /** True only when every baked light came from a bake made in this session (engine.bakeProbes): it saw this scene's lights. A loaded file or a lightmap carries no record of them */
57
+ const bakeSeenScene = e => !e._lightmap && [...(e._probeSets ?? [])].every(s => s.source === 'bake');
58
+
59
+ /**
60
+ * A glow before the exposure that applies after it: its threshold acts on light the screen shows scaled. A note: how much of the picture passes the
61
+ * threshold depends on the light in view, which only the pixels say. Effects are found by what they declare (about.acts, @threedog/post-effects
62
+ * about.js), never by name, in the order that runs now (held effects are off); an exposure effect keeps its value on the GPU, so with one after the
63
+ * glow the numbers are unknown and the note says so instead of guessing (GPT review l2-render 8)
64
+ */
65
+ function bloomBeforeExposure(e, out) {
66
+ const r = e.renderer, on = e.post?._sorted().filter(h => h.enabled) ?? [], acts = (h, a) => h._def?.about?.acts === a;
67
+ const b = on.find(h => acts(h, 'glow') && (h.slot === 'scene' || h.slot === 'hdr')), t = b?.params?.threshold;
68
+ if (!b || !(b.params.strength > 0) || typeof t !== 'number') return;
69
+ const auto = on.find(h => acts(h, 'exposure') && on.indexOf(h) > on.indexOf(b));
70
+ if (auto) {
71
+ note(out, 'bloom-before-exposure', `${b.name} (threshold ${+t.toFixed(2)}) runs before ${auto.name}, which scales the light by a value it keeps on the GPU: what that threshold ` +
72
+ `is on screen is unknown here and changes with the light in view; ordered after ${auto.name}, its cut is on the exposed light.`);
73
+ return;
74
+ }
75
+ // a game tone stage (slot 'tone') replaces three's output, so whether it applies renderer.toneMappingExposure is the game's code
76
+ const ex = r.toneMappingExposure;
77
+ if (r.toneMapping === THREE.NoToneMapping || on.some(h => h.slot === 'tone') || !(ex < 1)) return;
78
+ if (t * ex > 0.5) return; // why 0.5: a cut at half of white or below reaches past highlights into ordinary lit surfaces
79
+ note(out, 'bloom-before-exposure', `${b.name} runs before exposure ${+ex.toFixed(2)}: its threshold ${+t.toFixed(2)} acts like ${+(t * ex).toFixed(2)} of the screen's white, ` +
80
+ `so more than highlights can glow; threshold ${+(t / ex).toFixed(2)} would keep the cut where it shows.`);
81
+ }
82
+
83
+ /** A visible inside-out mesh around the camera (a sky dome or box, three's Sky addon too): the background color is not what shows behind the world */
84
+ function skyAround(e) {
85
+ const at = e.camera.getWorldPosition(new THREE.Vector3()), sphere = new THREE.Sphere();
86
+ let found = false;
87
+ e.scene.traverseVisible(o => {
88
+ if (found || !o.isMesh || !mats(o).some(m => m?.side === THREE.BackSide || m?.side === THREE.DoubleSide)) return;
89
+ if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
90
+ found = sphere.copy(o.geometry.boundingSphere).applyMatrix4(o.matrixWorld).containsPoint(at);
91
+ });
92
+ return found;
93
+ }
94
+
95
+ /** Far things fade to the fog color; where they meet a visible flat background a band shows. A note: a top-down view may never show the background */
96
+ function fogHorizon(e, out) {
97
+ const s = e.scene, f = fogLook(s, e.renderer), bg = s.background;
98
+ if (!f?.color || !bg?.isColor || s.backgroundNode) return; // a sky mesh, texture or node: its horizon color is not known here
99
+ if (f.isFog ? f.near >= e.camera.far : f.isFogExp2 && !(f.density > 0)) return; // the fog starts past what the camera draws, or has no density: it never shows (a fogNode: its range is not known, so it is taken as shown)
100
+ if (skyAround(e)) return; // a sky dome hides the background color: its horizon is the game's own (found 2026-11-09 on examples/webgpu-tsl)
101
+ const a = f.color.getRGB({ r: 0, g: 0, b: 0 }, THREE.SRGBColorSpace), c = bg.getRGB({ r: 0, g: 0, b: 0 }, THREE.SRGBColorSpace);
102
+ // why 0.25 of the display range: below it a seam is hard to see; above it it reads as a line in every style
103
+ if (Math.max(Math.abs(a.r - c.r), Math.abs(a.g - c.g), Math.abs(a.b - c.b)) < 0.25) return;
104
+ note(out, 'fog-horizon', `fog color ${hex(f.color)} differs from the background ${hex(bg)}: where fogged far things meet visible background, a band shows (none if the background is never in view).`);
105
+ }
106
+
107
+ /** The shadow caster nearest the camera outside every shadow box: it casts no shadow. A note: a light may cover only part of the scene on purpose */
108
+ function shadowBox(e, out) {
109
+ const r = e.renderer, cam = e.camera;
110
+ if (!r.shadowMap?.enabled || e.shadows?.csm) return; // cascades fit their own boxes to the view
111
+ const lights = [];
112
+ let unknown = false;
113
+ e.scene.traverseVisible(l => { if (l.isLight && l.castShadow) { if (l.isPointLight) unknown = true; else if (l.isDirectionalLight || l.isSpotLight) lights.push(l); } });
114
+ if (unknown || !lights.some(l => l.isDirectionalLight)) return; // a point light's six faces are not one box: who shadows what is not known
115
+ cam.updateMatrixWorld();
116
+ const view = cameraFrustum(cam);
117
+ const sphere = new THREE.Sphere(), casters = [];
118
+ e.scene.traverseVisible(o => {
119
+ if (!o.isMesh || !o.castShadow || o.isInstancedMesh || o.isSkinnedMesh) return; // instances and skinned bounds are not the drawn shape
120
+ if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
121
+ sphere.copy(o.geometry.boundingSphere).applyMatrix4(o.matrixWorld);
122
+ if (view.intersectsSphere(sphere)) casters.push({ o, s: sphere.clone(), d: sphere.center.distanceTo(cam.position) });
123
+ });
124
+ if (!casters.length) return;
125
+ casters.sort((a, b) => a.d - b.d);
126
+ // what the shadow pass does each frame (the boxes it is about to draw), worked out on a copy: updateMatrices on the real shadow would move the camera and matrix
127
+ // the renderer samples, so a baked shadow (autoUpdate off) would get the new matrix over the old map. Asking must not change the picture
128
+ const boxes = lights.map(l => { const s = new l.shadow.constructor().copy(l.shadow); s.updateMatrices(l); return s.getFrustum(); });
129
+ const outside = casters.filter(c => !boxes.some(b => b.intersectsSphere(c.s)));
130
+ if (outside[0] !== casters[0]) return;
131
+ note(out, 'shadow-box', `${nameOf(casters[0].o)}, the shadow caster nearest the camera, is outside every shadow box (${lights.map(nameOf).join(', ')}; ${outside.length} of ${casters.length} casters in view are), so it casts no shadow.`);
132
+ }
133
+
134
+ /**
135
+ * Every combination check, in order. @param {any} e @returns {{ id: string, kind: 'mistake' | 'note', text: string }[]}
136
+ */
137
+ export function pictureChecks(e) {
138
+ const out = [];
139
+ // before the first frame the game's per-frame picture code has not run (examples/webgpu-tsl at tick 0: fog still black, sun not aimed), so no claim yet
140
+ if (!drawnAFrame(e.renderer)) return out;
141
+ const twice = litTwice(e);
142
+ if (twice) out.push({ id: 'lit-twice', kind: bakeSeenScene(e) ? 'mistake' : 'note', text: twice }); // without the bake's own record it is only a possibility
143
+ metalNoEnv(e, out);
144
+ bloomBeforeExposure(e, out);
145
+ fogHorizon(e, out);
146
+ shadowBox(e, out);
147
+ return out;
148
+ }