threedog 0.8.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/CHANGELOG.md +219 -4
  2. package/README.md +6 -6
  3. package/core/assets/Animator.js +2 -0
  4. package/core/assets/Assets.js +44 -13
  5. package/core/assets/assetEntry.js +87 -22
  6. package/core/assets/assetHot.js +2 -1
  7. package/core/assets/assetReport.js +1 -2
  8. package/core/audio/Audio.js +24 -5
  9. package/core/base/I18n.js +6 -3
  10. package/core/base/Random.js +3 -1
  11. package/core/base/Vars.js +14 -4
  12. package/core/base/errorCodes.js +54 -16
  13. package/core/base/errorHints.js +12 -1
  14. package/core/base/errors.js +6 -4
  15. package/core/base/events.generated.js +10 -0
  16. package/core/base/follows.js +26 -0
  17. package/core/base/math.js +15 -8
  18. package/core/base/params.js +2 -2
  19. package/core/{saves → base}/saveValues.js +24 -6
  20. package/core/base/sections.js +97 -0
  21. package/core/base/spelling.js +32 -0
  22. package/core/base/validate.js +8 -29
  23. package/core/engine/Engine.js +61 -18
  24. package/core/engine/Loading.js +30 -3
  25. package/core/engine/copies.js +1 -1
  26. package/core/engine/headlessLoad.js +30 -13
  27. package/core/engine/lifecycle.js +30 -25
  28. package/core/engine/loop.js +22 -4
  29. package/core/engine/moduleSlots.js +91 -15
  30. package/core/engine/moduleTypes.js +13 -0
  31. package/core/engine/modules.js +248 -62
  32. package/core/engine/page.js +25 -8
  33. package/core/engine/plugins.js +15 -3
  34. package/core/engine/services.js +3 -0
  35. package/core/engine/startup.js +46 -36
  36. package/core/input/Input.js +39 -19
  37. package/core/input/inputKeyboard.js +39 -0
  38. package/core/input/inputPad.js +23 -2
  39. package/core/input/inputPointer.js +3 -1
  40. package/core/input/inputSeat.js +66 -0
  41. package/core/input/inputTouch.js +23 -6
  42. package/core/inspect/DebugOverrides.js +13 -2
  43. package/core/inspect/Describe.js +10 -6
  44. package/core/inspect/Inspect.js +31 -4
  45. package/core/inspect/UrlState.js +14 -10
  46. package/core/inspect/catalog.js +12 -5
  47. package/core/inspect/describeRender.js +3 -2
  48. package/core/inspect/describeText.js +6 -2
  49. package/core/inspect/metadata.generated.js +4140 -0
  50. package/core/inspect/pictureWriters.js +117 -33
  51. package/core/inspect/toolDoor.js +21 -0
  52. package/core/inspect/valueHistory.js +35 -0
  53. package/core/ops/Ops.js +32 -7
  54. package/core/ops/control.js +48 -23
  55. package/core/ops/holds.js +4 -3
  56. package/core/ops/opsAtomic.js +18 -6
  57. package/core/ops/opsCheck.js +7 -5
  58. package/core/ops/opsFail.js +5 -7
  59. package/core/ops/opsRun.js +2 -2
  60. package/core/ops/owned.js +20 -3
  61. package/core/ops/sharedPoint.js +7 -10
  62. package/core/ops/stacks.js +22 -1
  63. package/core/saves/SaveStore.js +52 -26
  64. package/core/saves/Saves.js +122 -27
  65. package/core/saves/saveApply.js +159 -61
  66. package/core/saves/saveFiles.js +30 -25
  67. package/core/saves/saveVersions.js +20 -6
  68. package/core/saves/session.js +76 -33
  69. package/core/saves/stateReplace.js +184 -0
  70. package/core/scene/Rays.js +21 -5
  71. package/core/scene/Views.js +6 -6
  72. package/core/scene/adaptive.js +13 -10
  73. package/core/scene/canvasBox.js +2 -0
  74. package/core/scene/compositeGround.js +72 -0
  75. package/core/scene/floor.js +17 -0
  76. package/core/scene/grid.js +2 -0
  77. package/core/scene/ground.contract.js +14 -0
  78. package/core/scene/ground.js +52 -17
  79. package/core/scene/pixel.js +154 -0
  80. package/core/scene/pixelRatio.js +167 -0
  81. package/core/scene/sceneDelta.js +3 -3
  82. package/core/scene/sceneMethods.js +11 -6
  83. package/core/scene/stepPoses.js +6 -1
  84. package/core/scene/thingExplain.js +1 -1
  85. package/core/scene/thingOps.js +22 -14
  86. package/core/scene/things.js +1 -1
  87. package/core/scene/tier.js +10 -0
  88. package/core/scene/view.js +126 -9
  89. package/core/stream/Batching.js +0 -1
  90. package/core/stream/Stream.js +24 -12
  91. package/core/stream/batchGroups.js +1 -0
  92. package/core/stream/scatter.js +5 -2
  93. package/core/stream/streamSources.js +2 -1
  94. package/core/threads/Commits.js +12 -7
  95. package/core/threads/Jobs.js +15 -5
  96. package/core/threads/Threads.js +5 -2
  97. package/core/time/Clock.js +3 -1
  98. package/core/time/skip.js +10 -4
  99. package/core/time/time.js +16 -10
  100. package/docs/AI.md +89 -72
  101. package/docs/API.md +18 -14
  102. package/docs/CODEMAP.md +68 -40
  103. package/docs/COMMANDS.md +22 -23
  104. package/docs/CONVENTIONS.md +120 -17
  105. package/docs/MIGRATING-0.8.md +2 -0
  106. package/docs/MIGRATING-1.0.md +101 -0
  107. package/docs/THREE.md +65 -12
  108. package/docs/api/cameraRig.md +3 -0
  109. package/docs/api/characters.md +13 -7
  110. package/docs/api/collider3d.md +9 -0
  111. package/docs/api/content.md +16 -15
  112. package/docs/api/dialogue.md +2 -1
  113. package/docs/api/engine.md +18 -16
  114. package/docs/api/events.md +14 -4
  115. package/docs/api/ground.md +2 -2
  116. package/docs/api/i18n.md +1 -1
  117. package/docs/api/input.md +2 -1
  118. package/docs/api/interactions.md +1 -1
  119. package/docs/api/inventory.md +1 -1
  120. package/docs/api/level.md +3 -2
  121. package/docs/api/nav.md +4 -2
  122. package/docs/api/particles.md +8 -5
  123. package/docs/api/pickups.md +1 -1
  124. package/docs/api/post.md +3 -4
  125. package/docs/api/quests.md +4 -2
  126. package/docs/api/rays.md +2 -0
  127. package/docs/api/rigid.md +3 -2
  128. package/docs/api/saves.md +8 -7
  129. package/docs/api/stream.md +4 -5
  130. package/docs/api/terrain.md +3 -4
  131. package/docs/api/terrainDraw.md +1 -1
  132. package/docs/api/timeline.md +2 -2
  133. package/docs/api/tools.md +3 -1
  134. package/docs/api/triggers.md +2 -0
  135. package/docs/api/vegetationDraw.md +1 -1
  136. package/docs/api/water.md +6 -2
  137. package/docs/api/weather.md +19 -4
  138. package/docs/api/weatherDraw.md +1 -1
  139. package/docs/api/world.md +1 -1
  140. package/docs/recipes/01-new-game.md +3 -3
  141. package/docs/recipes/02-npc.md +3 -4
  142. package/docs/recipes/03-items-pickups.md +11 -11
  143. package/docs/recipes/04-quests.md +2 -0
  144. package/docs/recipes/05-props-bake.md +9 -9
  145. package/docs/recipes/06-clock-events.md +6 -6
  146. package/docs/recipes/07-flow-scenes-pause.md +18 -15
  147. package/docs/recipes/08-weather-sky.md +5 -5
  148. package/docs/recipes/09-materials-lights-models.md +3 -3
  149. package/docs/recipes/10-blender-level.md +16 -4
  150. package/docs/recipes/11-vehicles.md +18 -6
  151. package/docs/recipes/12-navmesh.md +52 -8
  152. package/docs/recipes/13-animation.md +34 -8
  153. package/docs/recipes/14-custom-module.md +20 -8
  154. package/docs/recipes/15-perf.md +4 -4
  155. package/docs/recipes/16-dev-bridge.md +9 -8
  156. package/docs/recipes/18-world.md +13 -5
  157. package/docs/recipes/19-shooting-picking.md +3 -2
  158. package/docs/recipes/20-content-actions-save.md +26 -6
  159. package/docs/recipes/21-camera.md +17 -23
  160. package/docs/recipes/22-shop-gold.md +21 -12
  161. package/docs/recipes/23-ops.md +19 -15
  162. package/docs/recipes/26-ui-parts.md +3 -2
  163. package/docs/recipes/27-net.md +3 -3
  164. package/docs/recipes/28-terrain.md +3 -3
  165. package/docs/recipes/29-grid.md +1 -1
  166. package/docs/recipes/30-templates.md +10 -13
  167. package/docs/recipes/31-audio.md +2 -2
  168. package/docs/recipes/32-action-game.md +6 -5
  169. package/docs/recipes/33-stream-sources.md +4 -1
  170. package/docs/recipes/34-environment-lighting.md +7 -8
  171. package/docs/recipes/35-picture-from-reference.md +13 -9
  172. package/docs/recipes/36-ground-plants.md +3 -2
  173. package/docs/recipes/40-scene.md +11 -10
  174. package/docs/recipes/43-shader-patches-surfaces.md +7 -7
  175. package/docs/recipes/44-water-weather-hooks.md +9 -8
  176. package/docs/recipes/45-cascaded-shadows.md +3 -4
  177. package/docs/recipes/46-blender-art-route.md +3 -3
  178. package/docs/recipes/49-game-module-contract.md +2 -1
  179. package/docs/recipes/50-own-renderer.md +1 -0
  180. package/docs/recipes/51-capability-catalog.md +14 -8
  181. package/docs/recipes/52-around-the-picture.md +4 -4
  182. package/docs/recipes/55-mods-time-wrap.md +5 -4
  183. package/docs/recipes/56-webgpu-tsl.md +12 -1
  184. package/docs/recipes/57-control.md +30 -10
  185. package/docs/recipes/58-input.md +13 -0
  186. package/docs/recipes/60-judge-the-picture.md +1 -1
  187. package/docs/recipes/62-picture-code.md +106 -48
  188. package/docs/recipes/63-third-person-start.md +2 -1
  189. package/docs/recipes/64-particles.md +53 -4
  190. package/docs/recipes/65-swarm.md +2 -2
  191. package/docs/recipes/66-common-tasks.md +313 -0
  192. package/examples/action/.threedog/content-index.json +1 -1
  193. package/examples/action/GAMEMAP.md +3 -3
  194. package/examples/perf-island/.threedog/content-index.json +1 -1
  195. package/examples/perf-island/GAMEMAP.md +3 -3
  196. package/examples/perf-island/main.js +2 -2
  197. package/examples/plain-picture/GAMEMAP.md +3 -1
  198. package/examples/rc2d/GAMEMAP.md +1 -1
  199. package/examples/rc2d/rc2d.js +1 -1
  200. package/examples/styletest/.threedog/content-index.json +1 -1
  201. package/examples/styletest/GAMEMAP.md +3 -3
  202. package/examples/webgpu-tsl/GAMEMAP.md +1 -1
  203. package/examples/world/.threedog/content-index.json +1 -1
  204. package/examples/world/GAMEMAP.md +5 -4
  205. package/examples/world/main.js +3 -3
  206. package/index.d.ts +8 -5
  207. package/index.js +22 -1
  208. package/llms.txt +2 -1
  209. package/modules/ambience/Ambience.js +5 -3
  210. package/modules/calendar/index.js +7 -5
  211. package/modules/camera/FirstPersonCamera.js +3 -3
  212. package/modules/camera/FixedCamera.js +34 -20
  213. package/modules/camera/FollowCamera.js +20 -11
  214. package/modules/camera/RtsCamera.js +1 -0
  215. package/modules/camera/common.js +33 -22
  216. package/modules/camera/pixelSnap.js +62 -0
  217. package/modules/characters/Character.js +136 -43
  218. package/modules/characters/NPC.js +60 -28
  219. package/modules/characters/assetModel.js +2 -2
  220. package/modules/characters/astar.js +47 -28
  221. package/modules/characters/character.contract.js +21 -0
  222. package/modules/characters/contract.js +17 -3
  223. package/modules/characters/index.js +94 -34
  224. package/modules/characters/moveHelpers.js +80 -15
  225. package/modules/characters/mover.contract.js +14 -0
  226. package/modules/characters/movers/common.js +6 -4
  227. package/modules/characters/movers/rapier.js +12 -5
  228. package/modules/characters/movers/simple.js +25 -12
  229. package/modules/characters/movers/support.js +18 -7
  230. package/modules/characters/npcAvoid.js +15 -12
  231. package/modules/characters/npcSim.js +75 -25
  232. package/modules/characters/npcView.js +13 -6
  233. package/modules/characters/pathAsync.js +74 -24
  234. package/modules/characters/pathJob.js +38 -21
  235. package/modules/characters/player.js +59 -47
  236. package/modules/characters/seat.js +56 -0
  237. package/modules/characters/vehicle.contract.js +8 -5
  238. package/modules/characters/walkTo.js +31 -18
  239. package/modules/collision/Collision.js +44 -26
  240. package/modules/collision/contract.js +2 -2
  241. package/modules/collision/grid.js +6 -1
  242. package/modules/content/explain.js +1 -1
  243. package/modules/content/fields.js +3 -3
  244. package/modules/content/ids.js +3 -1
  245. package/modules/content/index.js +83 -27
  246. package/modules/content/loader.js +110 -130
  247. package/modules/content/markers.js +1 -1
  248. package/modules/content/models.js +48 -14
  249. package/modules/content/packs.js +2 -1
  250. package/modules/content/places.js +5 -4
  251. package/modules/content/props.js +8 -6
  252. package/modules/content/rules.js +29 -47
  253. package/modules/content/templates.js +66 -35
  254. package/modules/content/words.js +19 -6
  255. package/modules/debug/DebugPanel.js +4 -2
  256. package/modules/flow/contract.js +1 -0
  257. package/modules/flow/index.js +24 -14
  258. package/modules/gameplay/Container.js +5 -2
  259. package/modules/gameplay/Containers.js +9 -1
  260. package/modules/gameplay/Dialogue.js +82 -25
  261. package/modules/gameplay/Interactions.js +61 -32
  262. package/modules/gameplay/Inventory.js +56 -13
  263. package/modules/gameplay/Quests.js +133 -24
  264. package/modules/gameplay/boxOps.js +7 -0
  265. package/modules/gameplay/dialogueBubbles.js +14 -9
  266. package/modules/gameplay/inventoryOps.js +11 -7
  267. package/modules/gameplay/pickups.js +43 -16
  268. package/modules/gameplay/questLog.js +4 -2
  269. package/modules/gameplay/questSave.js +6 -1
  270. package/modules/gameplay/quests.contract.js +1 -1
  271. package/modules/grid/Grid.js +1 -1
  272. package/modules/grid/Layer.js +8 -4
  273. package/modules/grid/index.js +21 -15
  274. package/modules/grid/ops.js +43 -46
  275. package/modules/grid/tiles.js +1 -1
  276. package/modules/hlod/index.js +6 -3
  277. package/modules/hud/index.js +6 -4
  278. package/modules/hud/parts.js +4 -4
  279. package/modules/level/contract.js +2 -2
  280. package/modules/level/heightfield.js +17 -21
  281. package/modules/level/index.js +83 -26
  282. package/modules/level/load.js +165 -48
  283. package/modules/level/nodes.js +34 -16
  284. package/modules/lights/index.js +6 -3
  285. package/modules/lights/sources.js +3 -1
  286. package/modules/music/Music.js +4 -2
  287. package/modules/nav/contract.js +7 -5
  288. package/modules/nav/index.js +174 -44
  289. package/modules/nav/navPath.js +45 -10
  290. package/modules/net/index.js +1 -1
  291. package/modules/particles/Particles.js +85 -22
  292. package/modules/particles/effect.js +80 -28
  293. package/modules/particles/shaders.js +17 -0
  294. package/modules/photo/Photo.js +12 -10
  295. package/modules/rigid/RigidBodies.js +200 -57
  296. package/modules/rigid/Vehicles.js +15 -5
  297. package/modules/rigid/collider3d.contract.js +26 -0
  298. package/modules/rigid/ragdoll.js +55 -44
  299. package/modules/rigid/ragdollBones.js +83 -33
  300. package/modules/rigid/refresh.js +10 -0
  301. package/modules/rigid/sync.js +46 -15
  302. package/modules/settings/Settings.js +84 -37
  303. package/modules/settings/apply.js +15 -8
  304. package/modules/settings/sections.js +7 -4
  305. package/modules/settings/strings.js +2 -2
  306. package/modules/sky/skyModule.js +3 -1
  307. package/modules/swarm/Swarm.js +16 -6
  308. package/modules/terrain/ChunkManager.js +10 -16
  309. package/modules/terrain/index.js +17 -11
  310. package/modules/terrain/terrainEdit.js +13 -2
  311. package/modules/terrain/terrainGen.js +5 -3
  312. package/modules/terrain/terrainShape.js +1 -1
  313. package/modules/timeline/Timeline.js +58 -26
  314. package/modules/timeline/Tween.js +19 -13
  315. package/modules/timeline/shots.js +19 -10
  316. package/modules/triggers/index.js +87 -20
  317. package/modules/vegetation/Vegetation.js +4 -3
  318. package/modules/vegetation/draw.js +16 -0
  319. package/modules/vegetation/groundChunks.js +10 -7
  320. package/modules/vegetation/index.js +30 -7
  321. package/modules/water/Water.js +6 -2
  322. package/modules/weather/Weather.js +16 -15
  323. package/modules/weather/weatherDraw.js +7 -6
  324. package/modules/world/World.js +20 -7
  325. package/modules/world/explain.js +1 -1
  326. package/modules/world/index.js +13 -6
  327. package/modules/world/persist.js +23 -8
  328. package/modules/world/pos.js +4 -4
  329. package/modules/world/records.js +13 -7
  330. package/modules/world/sim.js +74 -23
  331. package/modules/world/simFar.js +2 -2
  332. package/modules/world/state.js +31 -6
  333. package/modules/world/thingSource.js +16 -3
  334. package/modules/world/views.js +19 -8
  335. package/package.json +7 -1
  336. package/render/PostFX.js +47 -29
  337. package/render/backend.js +5 -1
  338. package/render/fx/particles.tsl.js +8 -6
  339. package/render/fx/postWebGPU.tsl.js +3 -3
  340. package/render/layers.js +1 -1
  341. package/render/lightmap.js +23 -3
  342. package/render/occlusion.js +43 -12
  343. package/render/patches.js +2 -2
  344. package/render/postWebGL.js +4 -3
  345. package/render/probes.js +25 -0
  346. package/render/shadows.js +2 -2
  347. package/types/core.d.ts +142 -55
  348. package/types/gameplay.d.ts +92 -40
  349. package/types/generated/core/base/I18n.d.ts +2 -2
  350. package/types/generated/core/input/Input.d.ts +16 -2
  351. package/types/generated/core/input/inputSeat.d.ts +26 -0
  352. package/types/generated/core/inspect/DebugOverrides.d.ts +15 -1
  353. package/types/generated/core/ops/Ops.d.ts +2 -1
  354. package/types/generated/core/ops/control.d.ts +12 -2
  355. package/types/generated/core/saves/Saves.d.ts +26 -6
  356. package/types/generated/core/saves/session.d.ts +1 -1
  357. package/types/generated/core/scene/Views.d.ts +1 -1
  358. package/types/generated/core/stream/Stream.d.ts +6 -4
  359. package/types/generated/modules/grid/Grid.d.ts +1 -0
  360. package/types/generated/modules/particles/Particles.d.ts +4 -3
  361. package/types/generated/modules/timeline/Timeline.d.ts +5 -4
  362. package/types/generated/modules/weather/Weather.d.ts +1 -7
  363. package/types/generated/modules/world/World.d.ts +6 -4
  364. package/types/generated/render/PostFX.d.ts +6 -14
  365. package/types/nav.d.ts +36 -4
  366. package/types/physics.d.ts +55 -7
  367. package/types/pixel.d.ts +75 -0
  368. package/types/world.d.ts +14 -8
  369. package/ui/Parts.js +9 -2
  370. package/ui/theme.js +2 -2
  371. package/core/scene/engineCamera.js +0 -32
  372. package/modules/camera/projection.js +0 -21
package/render/shadows.js CHANGED
@@ -51,7 +51,7 @@ const BUDGET_PARAMS = { every: { type: 'int', default: 1, min: 1, desc: 'redraw
51
51
 
52
52
  function readBox(o) {
53
53
  const v = readParams(BOX, BOX_PARAMS, o), f = v.follow;
54
- if (!(f === false || f === 'focus' || f === 'camera' || f?.isObject3D || typeof f === 'function')) refuse(`${BOX}: follow must be 'focus' | 'camera' | an Object3D | () => Vector3 | false; got ${JSON.stringify(f)}`);
54
+ if (!(f === false || f === 'focus' || f === 'camera' || f?.isObject3D || typeof f === 'function')) refuse(`${BOX}: follow must be 'focus' | 'camera' | an Object3D | () => Vector3 | false; got ${f?.root?.isObject3D ? 'a character: pass its .root' : String(f)}`);
55
55
  if (v.snap !== 'texel' && !(typeof v.snap === 'number' && v.snap >= 0)) refuse(`${BOX}: snap must be meters (a number, 0 = none) or 'texel'; got ${JSON.stringify(v.snap)}`);
56
56
  return v;
57
57
  }
@@ -348,7 +348,7 @@ export function defineShadows(e, { owned }) {
348
348
  * its target, including what you write later. Nothing follows anything until you call this; remove() puts the light back. On engine.lights.sun under a sky it
349
349
  * changes the engine's own box, and remove() restores that.
350
350
  * @example
351
- * const box = engine.shadows.box(sun, { follow: player, extent: 40, snap: 'texel' });
351
+ * const box = engine.shadows.box(sun, { follow: player.root, extent: 40, snap: 'texel' });
352
352
  * box.set({ extent: 60 }); box.remove();
353
353
  * @param {any} light a DirectionalLight in engine.scene
354
354
  * @param {{ follow?: 'focus' | 'camera' | any | (() => any) | false, extent?: number, snap?: number | 'texel', ahead?: number }} [options]
package/types/core.d.ts CHANGED
@@ -7,8 +7,8 @@ import type { World } from './generated/modules/world/World';
7
7
  import type { Net } from './generated/modules/net/Net';
8
8
  import type { PostEffect } from './generated/render/PostFX';
9
9
  import type { Grids } from './generated/modules/grid/index';
10
- import type { Collision, RigidBodies, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle, Rideable } from './physics';
11
- import type { Nav } from './nav';
10
+ import type { Collision, RigidBodies, Collider3D, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle, Rideable } from './physics';
11
+ import type { Nav, LinkCrossing } from './nav';
12
12
  import type { Stream } from './generated/core/stream/Stream';
13
13
  import type { Batching } from './generated/core/stream/Batching';
14
14
  import type { Rays } from './generated/core/scene/Rays';
@@ -30,7 +30,7 @@ import type { Random } from './generated/core/base/Random';
30
30
  import type { PostFX } from './generated/render/PostFX';
31
31
  import type { Occlusion } from './generated/render/occlusion';
32
32
  import type {
33
- Timeline, Level, LevelLoadedEvent, Triggers, TriggerEvent, TemplateStageEvent,
33
+ Timeline, Level, LevelLoadedEvent, LevelLoadingEvent, LevelFailedEvent, LevelPlayableEvent, LevelUnloadedEvent, Triggers, TriggerEvent, TemplateStageEvent,
34
34
  Particles, SwarmMaker, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
35
35
  Interactions, Dialogue, Inventory, ItemEvent, ItemUseEvent, PickupEvent, Pickups, PickupsOptions, Quests, Photo, PhotoShot, Ambience, DebugPanel,
36
36
  Clock, Vars, Content, Flow, Hud,
@@ -109,7 +109,11 @@ export interface EventMap extends GameEvents {
109
109
  /** A character jumped */
110
110
  'character:jump': [{ character: Character; air: boolean; index: number }];
111
111
  'character:launch': [{ character: Character; speed: number; owner: string }];
112
- 'character:fall': [{ character: Character; safe: Vector3 | null; preventDefault(): void }];
112
+ /** A walker reached a nav link. Set crossing.seconds here to say how long it takes @experimental */
113
+ 'link:enter': [{ id: string; character: Character; crossing: LinkCrossing }];
114
+ /** A crossing ended: landed, or cut short (npc.placeAt, walk.remove()). character is null for an NPC that went out of range mid-crossing @experimental */
115
+ 'link:exit': [{ id: string; character: Character | null; crossing: LinkCrossing }];
116
+ 'character:fall': [{ character: Character; safe: Vector3 | null }];
113
117
  /** A character's model named by asset finished loading and replaced the placeholder body (same root; anim is now set) */
114
118
  'character:model': [{ character: Character; model: Object3D }];
115
119
  /** A foot of a walking character came down; character.groundType() is what it stepped on */
@@ -154,6 +158,10 @@ export interface EventMap extends GameEvents {
154
158
  'quest:part': [{ id: string; step: number; part: number }];
155
159
  /** A quest failed (its fail condition held); quests.start(id) may begin it again */
156
160
  'quest:fail': [{ id: string }];
161
+ /** A finished quest's reward was not given. failed: each word that failed; owed: the items the quest still owes, null when none or when onUnpaid took it */
162
+ 'quest:unpaid': [{ id: string; code: string; failed: { word: string; code: string; facts: any }[]; owed: Record<string, number> | null }];
163
+ /** A content effect word failed ({ give } in a full bag, { op } refused), wherever it ran: a dialogue do, a trigger, a reward, content.run. actor: whose effect it was */
164
+ 'content:failed': [{ code: string; failed: { word: string; code: string; facts: any }[]; actor: string | null }];
157
165
  /** A photo was taken */
158
166
  'photo:taken': [PhotoShot];
159
167
  /** The photo key was pressed but the op photo.take was refused (reason from photo.canTake(), 'denied' when it returned false) */
@@ -163,11 +171,15 @@ export interface EventMap extends GameEvents {
163
171
  /** Left a trigger zone */
164
172
  'trigger:exit': [TriggerEvent];
165
173
  /** Level finished loading */
174
+ 'level:loading': [LevelLoadingEvent];
166
175
  'level:loaded': [LevelLoadedEvent];
176
+ 'level:unloaded': [LevelUnloadedEvent];
177
+ 'level:playable': [LevelPlayableEvent];
178
+ 'level:failed': [LevelFailedEvent];
167
179
  /** A cutscene started */
168
180
  'timeline:start': [{ id: number }];
169
- /** A cutscene ended; skipped tells whether it was skipped */
170
- 'timeline:end': [{ id: number; skipped: boolean }];
181
+ /** A cutscene ended; ending says how, error why it failed */
182
+ 'timeline:end': [{ id: number; ending: 'finished' | 'skipped' | 'dropped' | 'failed'; error?: string }];
171
183
  /** A content template instance entered a new stage by growing (templates with stages) */
172
184
  'template:stage': [TemplateStageEvent];
173
185
  /** The ground's shape or type changed in this world-space box (engine.terrain.edit): cached ground samples (path rasters) inside it are stale */
@@ -220,6 +232,9 @@ export interface EventMap extends GameEvents {
220
232
  'engine:error': [EngineError];
221
233
  /** A picture or ui module errored and was disabled (the game continues) */
222
234
  'module:disabled': [{ name: string; message: string }];
235
+ 'module:restored': [{ modules: any[] }];
236
+ /** @internal The state was replaced by something other than a step, from any door (core/saves/stateReplace.js); undone: a failed load put the old state back */
237
+ 'state:replaced': [{ undone: boolean }];
223
238
  /** A character boarded a vehicle */
224
239
  'vehicle:enter': [{ character: Character; vehicle: Rideable }];
225
240
  /** A character exited a vehicle */
@@ -233,7 +248,7 @@ export interface EventMap extends GameEvents {
233
248
  /** A playthrough started from a clean slate: kind 'new' (newGame) or 'load' (session.load, with the slot) */
234
249
  'session:start': [{ kind: 'new' | 'load'; slot?: string }];
235
250
  /** newGame / session.load failed (a save part's load() threw) and the game was rolled back: the old playthrough goes on, no session:start */
236
- 'session:failed': [{ kind: 'new' | 'load'; slot?: string }];
251
+ 'session:failed': [{ kind: 'new' | 'load' | 'quit'; slot?: string }];
237
252
  /** The page went away: the window lost focus or the tab was hidden (engine.page) */
238
253
  'page:blur': [{ focused: boolean; visible: boolean }];
239
254
  /** The page came back: focused and visible again */
@@ -372,6 +387,9 @@ export type StringTables = Record<string, Record<string, string>>;
372
387
  // Saves
373
388
  // ======================================================================
374
389
 
390
+ /** Which state replacement a call belongs to: handed to a part's load() and a module's afterLoad, opaque, valid until that replacement ends */
391
+ export type SaveTurn = Readonly<object>;
392
+
375
393
  /** Save provider: save() returns JSON-able data, load(data) reads it back (may return a Promise, e.g. for changing level;
376
394
  * later parts wait for it to finish before loading).
377
395
  * first: true providers load first (parts such as the level, where the rest only makes sense after it is loaded) */
@@ -380,12 +398,15 @@ export interface SaveProvider {
380
398
  * part keeps: the engine copies it for its rollback point before a load, so a load() that writes into that same object can still be undone.
381
399
  * Data that cannot be copied makes a load refuse before anything changes (save-part-threw) */
382
400
  save: () => any;
383
- /** Read data back; may return a Promise (later parts wait). Listener errors of events it emits count as the load throwing, also after an await */
384
- load: (data: any) => void | Promise<void>;
401
+ /** Read data back; may return a Promise (later parts wait). Listener errors of events it emits count as the load throwing, also after an await.
402
+ * turn: this replacement's identity. Pass it on as level.load(x, { turn }) / content.load(x, { turn }): awaited without it, those wait for this load, so for ever (dev warns after 3 s, save-nested) */
403
+ load: (data: any, turn: SaveTurn) => void | Promise<void>;
385
404
  /** Load before the other parts (such as the level) */
386
405
  first?: boolean;
387
406
  /** Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback) */
388
407
  atomic?: boolean;
408
+ /** Why an atomic op leaves this part alone. Every engine part gives atomic: true or this (rule R66); a game's part may */
409
+ notAtomic?: string;
389
410
  /** Dev only: called once start() finished with this part's data in the new-game state, to warn about what should not be there yet (world: records placed by code) */
390
411
  checkNewGame?: (data: any) => void;
391
412
  /** This part's format version, default 1: raise it by 1 when what save() returns changes shape. A save with a newer version is refused */
@@ -643,8 +664,8 @@ export interface Loading {
643
664
  /** Run the game's own loading step as a task (critical by default: a failure before start() finishes stops start()) */
644
665
  track<T>(name: string, fn: () => Promise<T>, opts?: { critical?: boolean }): Promise<T>;
645
666
  /**
646
- * Resolves when every module installed after start() has finished its init() (also when one failed: see engine.moduleStates).
647
- * @example engine.use(shop()); await engine.loading.settled(); engine.moduleStates.shop // 'running'
667
+ * Resolves when every module installed after start() has finished its init() (also when one failed: engine.explain({ module: name }) says so).
668
+ * @example engine.use(shop()); await engine.loading.settled(); engine.explain({ module: 'shop' }).ok // true
648
669
  */
649
670
  settled(): Promise<void>;
650
671
  /** How long start() waits for modules whose isReady(e) stays false before it rejects naming them, in ms (default 120000) */
@@ -861,7 +882,7 @@ export interface UIParts {
861
882
  /** Window content by name: a function here replaces that window's default HTML, read each time it draws */
862
883
  templates: Record<string, UITemplate>;
863
884
  /** Declare a part and its default (engine and modules; games use set) */
864
- define(name: string, factory: UIPartFactory, def?: UIPartDef): void;
885
+ define(name: string, factory: UIPartFactory, def?: UIPartDef): Handle;
865
886
  /**
866
887
  * Replace a part, give the default options, or turn it off (before engine.start(); the loading part only via createEngine({ ui }))
867
888
  * @example engine.ui.set('hud.marker', false)
@@ -903,9 +924,9 @@ export interface Ground {
903
924
  */
904
925
  height(x: number, z: number, refY?: number): number;
905
926
  /** Slope at (x, z) (height difference / horizontal distance) */
906
- slope(x: number, z: number): number;
927
+ slope(x: number, z: number, refY?: number): number;
907
928
  /** Ground type at (x, z) (landform name, e.g. 'meadow') */
908
- type(x: number, z: number): string;
929
+ type(x: number, z: number, refY?: number): string;
909
930
  /** Global water level (meters); -Infinity when there is no water */
910
931
  waterLevel: number;
911
932
  /**
@@ -939,6 +960,12 @@ export interface ModuleCtx {
939
960
  /** Keep handle (anything with remove(): events.on, onFixed, onFrame, clock timers, audio.measure...) until the module goes: removed when its use()
940
961
  * batch rolls back, its init fails, it is replaced, or on engine.dispose() before its dispose hook. Returns the handle */
941
962
  track<H extends { remove(): void }>(handle: H): H;
963
+ /**
964
+ * Write values on an object the module does not own and give them back when the module goes (or on the handle's remove()). A value goes back only if it is
965
+ * still what this borrow left there, so a later write by the game stands. For a value several parties change at once use a shared value (ctx.mod).
966
+ * @example ctx.borrow(e.renderer, { toneMapping: THREE.AgXToneMapping }); ctx.borrow(e.scene, { fog: new THREE.Fog(0x667788, 10, 200) });
967
+ */
968
+ borrow(obj: object, values: Record<string, any>): { remove(): void };
942
969
  /**
943
970
  * engine.mod with this module as the owner, tracked: the change goes when the module goes. Passing owner throws (use engine.mod for another name).
944
971
  * @example ctx.mod('time.world', { mul: 0.8, layer: 'effect' })
@@ -959,11 +986,53 @@ export interface ModuleCtx {
959
986
  * @example ctx.whileCompiling(() => { const w = new R.World(g); w.step(); w.free(); })
960
987
  */
961
988
  whileCompiling(fn: () => void): void;
989
+ /**
990
+ * This module puts data into whoever holds that capability: fn runs before the use() of a new holder returns, so the next line can read it whole. Leaves with the module.
991
+ * A throw fails that use() and the old holder comes back.
992
+ * @example ctx.feeds('collision', () => addMyWalls());
993
+ */
994
+ feeds(capability: string, fn: () => void): void;
995
+ /** engine.ops.define, owned: the op goes when the module goes */
996
+ ops: { define: Ops['define'] };
997
+ /** engine.saves.register, owned: the part goes when the module goes and its data stays in the save as unattached data, handed back to a later install */
998
+ saves: { register(key: string, provider: SaveProvider): Handle };
999
+ /** engine.ui.define, owned: the part is closed and its definition goes when the module goes */
1000
+ ui: { define(name: string, factory: UIPartFactory, def?: UIPartDef): Handle };
1001
+ /** engine.stream.addReadyCheck, owned */
1002
+ stream: { addReadyCheck(name: string, fn: (source: any) => boolean): Handle };
1003
+ /** engine.budget.metric, owned */
1004
+ budget: { metric(name: string, read: () => number, opts?: { limit?: number }): Handle };
1005
+ /** Where engine.thing finds this module's records, and what engine.explain({ thing }) adds; owned */
1006
+ things: { addSource(source: any): Handle; explainWith(fn: (e: Engine, thing: any, out: any) => void): Handle };
1007
+ /**
1008
+ * Give the ground. provides must name 'ground' (terrain and level hold it too, so two providers are refused at use()); when the module goes the flat ground comes back.
1009
+ * addColliders: more static colliders in engine.ground.forEachCollider, whoever gives the ground.
1010
+ * @example provides: ['ground'], install(e, ctx) { ctx.ground.provide({ height: (x, z) => 0 }); }
1011
+ */
1012
+ ground: { provide(g: Partial<Ground>): Handle; addColliders(forEach: (x: number, z: number, range: number, fn: (x: number, z: number, r: number) => void) => void): Handle };
962
1013
  }
963
1014
 
964
1015
  /** What a module may own (ModuleDef.type; core/engine/moduleTypes.js) */
965
1016
  export type ModuleType = 'world' | 'picture' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
966
1017
 
1018
+ /** One content section: validate and prepare must not change the game, commit is the only step that does. See core/base/sections.js */
1019
+ export interface ContentSection {
1020
+ /** Entry shapes in the params format, read by content.fields */
1021
+ fields?: Record<string, any>;
1022
+ /** The ids this data names in other sections */
1023
+ references?(data: any): { section: string; id: string; at?: string }[];
1024
+ /** Throw to refuse the data */
1025
+ validate?(data: any, c: any): void;
1026
+ /** Everything that can fail, away from live state; may be async */
1027
+ prepare?(data: any, c: any): any;
1028
+ /** Put the prepared data in place */
1029
+ commit(prepared: any, c: any): any;
1030
+ /** This prepare will not commit: let go of what it holds. prepared may be its Promise, still running */
1031
+ cancel?(prepared: any, c: any): void;
1032
+ /** Effect words this section's owner runs: word -> { ref, desc, describe, run } */
1033
+ effects?: Record<string, any>;
1034
+ }
1035
+
967
1036
  /**
968
1037
  * A module (the argument of engine.use). The name is the property name on the engine once installed.
969
1038
  * Per-frame hook order follows stage, then before / after within a stage, then install order.
@@ -1002,11 +1071,11 @@ export interface ModuleDef<Api = any> {
1002
1071
  * Within a stage use before / after, then install order. What the module may own and how its errors are handled come from type
1003
1072
  */
1004
1073
  stage?: 'control' | 'ground' | 'environment' | 'gameplay' | 'effects' | 'late' | 'audio';
1005
- /** Hooks run before these modules, inside one stage (ignored if not installed;
1006
- * use() throws on a cycle, or when the other module's stage already runs earlier) */
1074
+ /** Hooks run before these modules or capabilities, inside one stage (ignored if not installed; a capability means whichever module provides it now;
1075
+ * use() throws on a cycle, or when the other module's stage already runs earlier; reached through a capability that is a dev warning and the stage order stays) */
1007
1076
  before?: string[];
1008
- /** Hooks run after these modules, inside one stage (ignored if not installed;
1009
- * use() throws on a cycle, or when the other module's stage already runs later) */
1077
+ /** Hooks run after these modules or capabilities, inside one stage (ignored if not installed; a capability means whichever module provides it now;
1078
+ * use() throws on a cycle, or when the other module's stage already runs later; reached through a capability that is a dev warning and the stage order stays) */
1010
1079
  after?: string[];
1011
1080
  /**
1012
1081
  * The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of
@@ -1023,10 +1092,12 @@ export interface ModuleDef<Api = any> {
1023
1092
  install?(e: Engine, ctx: ModuleCtx): Api;
1024
1093
  /** Called at startup (download things, wait for assets); may be async. ctx is the same as install's */
1025
1094
  init?(e: Engine, ctx: ModuleCtx): void | Promise<void>;
1095
+ /** Content sections this module owns: their format, checks and how the data becomes live state (validate, prepare, commit). See core/base/sections.js */
1096
+ content?: Record<string, ContentSection>;
1026
1097
  /** The loading screen waits until this returns true before disappearing (the hook is called isReady; in the engine ready is always a boolean property) */
1027
1098
  isReady?(e: Engine): boolean;
1028
- /** After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves */
1029
- afterLoad?(e: Engine): void | Promise<void>;
1099
+ /** After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves. turn: as SaveProvider.load */
1100
+ afterLoad?(e: Engine, turn: SaveTurn): void | Promise<void>;
1030
1101
  /** Fixed step (60 times per second); dt is in seconds */
1031
1102
  fixed?(dt: number, e: Engine): void;
1032
1103
  /** Once per frame; dt is in seconds */
@@ -1039,8 +1110,10 @@ export interface ModuleDef<Api = any> {
1039
1110
  * Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
1040
1111
  */
1041
1112
  skip?(dt: number, e: Engine, done: boolean): void;
1042
- /** Why a module with a fixed hook has no skip hook: engine.catalog shows it instead of a warning */
1113
+ /** Why a module with a fixed hook has no skip hook */
1043
1114
  noSkip?: string;
1115
+ /** How engine.skip advances it. exact: the same state as stepping, from the clock or a hook. approx: a hook catches up with an estimate. step: a hook replays the steps. none: a jump moves nothing here. A module with a fixed or skip hook declares it (engine.catalog reports one that does not); engine modules always do */
1116
+ skipKind?: 'exact' | 'approx' | 'step' | 'none';
1044
1117
  /** The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it */
1045
1118
  params?: any;
1046
1119
  /** Where its docs live, shown by engine.catalog */
@@ -1085,10 +1158,17 @@ export interface EngineOptions {
1085
1158
  * working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
1086
1159
  * Every fallback prints one '[threedog] WebGPU unavailable (...)' line and shows in describe().renderer */
1087
1160
  fallback?: 'webgl2' | 'webgl' | 'error';
1088
- /** MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on) */
1161
+ /** MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. It is fixed with the canvas: a player's settings row changes it at the next launch */
1089
1162
  antialias?: boolean;
1090
1163
  /** Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it */
1091
1164
  pixelRatio?: number;
1165
+ /**
1166
+ * Real screen pixels per art pixel, a whole number from 1 up: art pixels of exactly one size at any display scale, through page zoom and moves to another display.
1167
+ * Sets image-rendering: pixelated, antialias defaults to off, adaptive resolution stops, and the last few real pixels (fewer than k) at the right and bottom stay empty.
1168
+ * Giving pixelRatio or adaptiveResolution: true as well is an error. Recipe 62 section 4b.
1169
+ * @example createEngine({ canvas, pixelSize: 3 })
1170
+ */
1171
+ pixelSize?: number;
1092
1172
  /** Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered */
1093
1173
  adaptiveResolution?: boolean;
1094
1174
  /** Target frame rate for automatic resolution lowering, default 55 */
@@ -1194,6 +1274,10 @@ export interface RayHit {
1194
1274
  normal: Vector3 | null;
1195
1275
  object: Object3D | null;
1196
1276
  face: any;
1277
+ /** Which instance of an InstancedMesh was hit, as in a three.js intersection */
1278
+ instanceId?: number;
1279
+ /** Which item of a BatchedMesh was hit, as in a three.js intersection */
1280
+ batchId?: number;
1197
1281
  entry?: any;
1198
1282
  kind?: string;
1199
1283
  /**
@@ -1220,10 +1304,8 @@ export interface Thing extends HitThing {
1220
1304
  id: string; owner: string; at: string | null; phase: 'setup' | 'play'; saved: 'record' | 'code' | 'session' | 'engine'; keeps: string[]; loses: string[];
1221
1305
  /** the live object (the record's current model, null when not built) */
1222
1306
  readonly object: Object3D | null;
1223
- /** everything about this id in one JSON-able object: definition file:line, template, model, materials, state, collision rules, related ops, save status, how to change it. Not engine.explain(): that answers "why can this op / quest not run" (recipes/41 section 6) */
1224
- explain(): ThingExplanation;
1225
1307
  }
1226
- /** What thing.explain() returns (`threedog thing <id>` prints the same JSON); modules add keys to rules / state through their explainers */
1308
+ /** The detail of engine.explain({ thing: id }) (`threedog explain thing <id> --full` prints the same JSON); modules add keys to rules / state through their explainers */
1227
1309
  export interface ThingExplanation {
1228
1310
  id: string; kind: string; owner: string;
1229
1311
  /** at: 'content/props.js:14' (null in release builds and for code without a file) */
@@ -1326,7 +1408,7 @@ export interface StreamEntryOptions {
1326
1408
  radius?: number;
1327
1409
  /** Generate the object (called when entering range, run spread over frames through engine.jobs) */
1328
1410
  build: () => Object3D | Promise<Object3D>;
1329
- /** Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. engine.detach) */
1411
+ /** Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. obj.removeFromParent()) */
1330
1412
  dispose?: (obj: Object3D) => void;
1331
1413
  /** Do not unload even when out of range */
1332
1414
  keep?: boolean;
@@ -1579,7 +1661,7 @@ export declare class Engine {
1579
1661
  validate: boolean;
1580
1662
  /** three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer) */
1581
1663
  renderer: EngineRenderer;
1582
- /** Device tier: 'low' (phones, integrated graphics) | 'high'. A headless page takes it from ?threedog-tier=low|high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier) */
1664
+ /** The one quality value, what everything that scales by quality reads: the device's tier, 'low' (phones, integrated graphics) | 'high', unless the player's preset says otherwise (shared point 'tier'). A headless page takes the device's from ?threedog-tier=low|high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier) */
1583
1665
  tier: 'low' | 'high';
1584
1666
  /** three.js scene */
1585
1667
  scene: import('three').Scene;
@@ -1587,8 +1669,12 @@ export declare class Engine {
1587
1669
  * Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
1588
1670
  */
1589
1671
  lights: { sun: import('three').DirectionalLight; hemi: import('three').HemisphereLight };
1590
- /** three.js PerspectiveCamera (class EngineCamera, core/scene/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
1591
- camera: import('three').PerspectiveCamera;
1672
+ /**
1673
+ * The camera the engine draws with, a plain THREE.PerspectiveCamera to begin with. Assign a real THREE.PerspectiveCamera or THREE.OrthographicCamera to draw through it; any other class
1674
+ * is refused [camera-option]. A camera rig with projection: 'orthographic' does the same for you, and the next perspective view brings the first camera back: read this where you use it.
1675
+ * describe().camera.projection says which projection is on.
1676
+ */
1677
+ camera: import('three').PerspectiveCamera | import('three').OrthographicCamera;
1592
1678
  /**
1593
1679
  * Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the
1594
1680
  * player by default), which does not follow the camera
@@ -1628,12 +1714,6 @@ export declare class Engine {
1628
1714
  readonly disposed: boolean;
1629
1715
  /** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" @experimental */
1630
1716
  readonly moduleOrder: string[];
1631
- /**
1632
- * Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'.
1633
- * A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
1634
- * @experimental
1635
- */
1636
- readonly moduleStates: Record<string, 'registered' | 'initializing' | 'running' | 'failed' | 'disposed'>;
1637
1717
  /**
1638
1718
  * What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas).
1639
1719
  * No argument: the short list, an ARRAY of { id, kind, label, ops, saves, ... } (read .id, not Object.keys); a module id / op name: that entry
@@ -1646,8 +1726,6 @@ export declare class Engine {
1646
1726
  * message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
1647
1727
  */
1648
1728
  readonly error: EngineError | null;
1649
- /** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) @experimental */
1650
- readonly disabledModules: Set<string>;
1651
1729
  /**
1652
1730
  * The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on
1653
1731
  * dispose()
@@ -1675,6 +1753,8 @@ export declare class Engine {
1675
1753
  audio: Audio;
1676
1754
  /** Assets */
1677
1755
  assets: Assets;
1756
+ /** The API of the module holding the 'picture' slot (recipe 62), undefined when no look is installed: engine.use(next(), { replaces: 'picture' }) changes it, so read it again after a switch */
1757
+ picture: any;
1678
1758
  /** Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest) */
1679
1759
  readonly loading: Loading;
1680
1760
  /** Post-processing: named effects in slots (add / get / enable / list) */
@@ -1788,7 +1868,7 @@ export declare class Engine {
1788
1868
  sky?: Sky;
1789
1869
  /** Time of day, day, seasons and clock-time timers (calendar() module); NPC schedules, content clock conditions and audio time rules read it */
1790
1870
  calendar?: Calendar;
1791
- /** Weather state (weather() module): the table, current values, set / setAuto, save, events */
1871
+ /** Weather state (weather() module): the table, current values, set / auto, save, events */
1792
1872
  weather?: Weather;
1793
1873
  /** Weather drawing (installed by weather(); sky is optional): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky @experimental */
1794
1874
  weatherDraw?: WeatherDraw;
@@ -1804,6 +1884,8 @@ export declare class Engine {
1804
1884
  collision?: Collision;
1805
1885
  /** Real physics, Rapier (rigid() module, needs collision) */
1806
1886
  rigid?: RigidBodies;
1887
+ /** Collision on all three axes (the collider3d slot, held by rigid() unless replaced) @experimental */
1888
+ collider3d?: Collider3D;
1807
1889
  /** Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamera) */
1808
1890
  cameraRig?: CameraRig;
1809
1891
  /**
@@ -1834,7 +1916,7 @@ export declare class Engine {
1834
1916
  characters?: CharactersApi;
1835
1917
  /** NPC management (characters() module, npcs on by default) */
1836
1918
  npcs?: NPCManager;
1837
- /** Interaction prompts (interactions() module) */
1919
+ /** Interaction prompts (interactions() module). Press a key near a thing. Install: engine.use(interactions()); undefined until installed. onUse returning { ok: false, code } fails the use and spends nothing */
1838
1920
  interactions?: Interactions;
1839
1921
  /**
1840
1922
  * Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, else go on to the next one) and `dialogue.choose { index }` (pick
@@ -1842,9 +1924,9 @@ export declare class Engine {
1842
1924
  * `engine.ops.run('dialogue.choose', { index: 0 })`
1843
1925
  */
1844
1926
  dialogue?: Dialogue;
1845
- /** Inventory (inventory() module) */
1927
+ /** Inventory (inventory() module). Items, counts and containers, saved with the game. Install: engine.use(inventory()); undefined until installed. add() answers { ok }, read .ok */
1846
1928
  inventory?: Inventory;
1847
- /** pickups() */
1929
+ /** pickups(). Things on the ground that go in the bag. Install: engine.use(pickups()) with inventory() and interactions(); undefined until installed. A full bag leaves the item on the ground */
1848
1930
  pickups?: Pickups;
1849
1931
  /** Quests (quests() module) */
1850
1932
  quests?: Quests;
@@ -1886,7 +1968,7 @@ export declare class Engine {
1886
1968
  * @example engine.unuse('rain');
1887
1969
  */
1888
1970
  unuse(name: string): void;
1889
- /** Whether a module is installed */
1971
+ /** Whether a module of this name, or a provider of this capability, is installed. Installed only: engine.explain({ module: name }) says whether it is running */
1890
1972
  has(name: string): boolean;
1891
1973
 
1892
1974
 
@@ -1903,17 +1985,17 @@ export declare class Engine {
1903
1985
  surface(x: number, z: number, refY?: number): number;
1904
1986
  surface(at: PositionLike, refY?: number): number;
1905
1987
  /** Slope at (x, z); a position or object also works */
1906
- slope(x: number, z: number): number;
1907
- slope(at: PositionLike): number;
1988
+ slope(x: number, z: number, refY?: number): number;
1989
+ slope(at: PositionLike, refY?: number): number;
1908
1990
  /** Ground type at (x, z) (for footsteps, particles); a position or object also works. 'void' off the outline of terrain({ shape }) */
1909
- groundType(x: number, z: number): string;
1910
- groundType(at: PositionLike): string;
1991
+ groundType(x: number, z: number, refY?: number): string;
1992
+ groundType(at: PositionLike, refY?: number): string;
1911
1993
  /**
1912
1994
  * Water surface height at (x, z): standalone water bodies first, otherwise the global water level; -Infinity when there is no water. A position or
1913
1995
  * object also works
1914
1996
  */
1915
- waterAt(x: number, z: number): number;
1916
- waterAt(at: PositionLike): number;
1997
+ waterAt(x: number, z: number, refY?: number): number;
1998
+ waterAt(at: PositionLike, refY?: number): number;
1917
1999
  /**
1918
2000
  * Put an object on the ground under it (y = ground height + offset) and return the object. With multi-layer ground the object's current y is the
1919
2001
  * reference height
@@ -1946,8 +2028,6 @@ export declare class Engine {
1946
2028
  * materials of it and its children (textures and geometry / materials shared by assets are not released)
1947
2029
  */
1948
2030
  remove(...objs: Object3D[]): void;
1949
- /** Only take it off its parent without releasing GPU memory (use when you will add it back later). Use remove for objects you no longer need */
1950
- detach(...objs: Object3D[]): void;
1951
2031
  /**
1952
2032
  * Fixed-step logic (60 times per second, dt in fixed seconds): movement, physics, cooldowns, and gameplay keys (read pressed() here: a per-step
1953
2033
  * snapshot, independent of frame rate). dt is real seconds (always 1/60) unless { channel } names a time channel: then the channel's scaled dt.
@@ -2011,8 +2091,14 @@ export declare class Engine {
2011
2091
  loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }): Promise<Lightmap>;
2012
2092
 
2013
2093
  // ---------- Settings ----------
2014
- /** Render resolution, and the top adaptive resolution climbs back to */
2094
+ /** Render resolution, and the top adaptive resolution climbs back to. Throws while pixelSize is on */
2015
2095
  setPixelRatio(p: number): void;
2096
+ /**
2097
+ * One art pixel becomes k real screen pixels (createEngine({ pixelSize }) at runtime). While on, adaptive resolution stops, engine.setPixelRatio throws and a photo keeps
2098
+ * the art pixels. null turns it off and brings the ratio from before back.
2099
+ * @example engine.setPixelSize(3);
2100
+ */
2101
+ setPixelSize(k: number | null): void;
2016
2102
 
2017
2103
  // ---------- Rays, scenarios ----------
2018
2104
  /** Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit) */
@@ -2165,14 +2251,15 @@ export declare class Engine {
2165
2251
  * Why something is the way it is. { op, args?, actor? }: text says whether it can run now, and if not the reason and the op's note on fixing it
2166
2252
  * (reason first);
2167
2253
  * detail has the last attempt and the events around it; recent / events are the raw last 5 attempts and event names within a step of the last one.
2254
+ * { value }: who last wrote a watched value, with its history. { thing: id }: where the id comes from; detail is the whole ThingExplanation. { module } / { capability }: whether it runs and what blocks it.
2168
2255
  * Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }.
2169
2256
  * @example engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'
2170
2257
  * @example engine.explain({ quest: 'first-light' }).text // which step it waits on
2171
2258
  * An op whose args.id names a world record also says where that record was authored (text ends with "defined in content/props.js:14: edit it there…";
2172
2259
  * thing has the rest).
2173
2260
  */
2174
- explain(q: { op: string; args?: any; actor?: string } | Record<string, any>): {
2175
- ok: boolean; code?: string | null; text: string; detail?: string; recent?: any[]; events?: string[]; thing?: HitThing;
2261
+ explain(q: { op: string; args?: any; actor?: string } | { value: string } | { thing: string | Object3D } | { module: string } | { capability: string } | Record<string, any>): {
2262
+ ok: boolean; code?: string | null; text: string; detail?: any; recent?: any[]; events?: string[]; thing?: HitThing;
2176
2263
  };
2177
2264
  /**
2178
2265
  * Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per
@@ -2271,7 +2358,7 @@ export interface GameState {
2271
2358
  error: EngineError | null;
2272
2359
  /** picture / ui modules disabled after an error */
2273
2360
  disabledModules: string[];
2274
- /** Modules that are initializing or failed ({ name: state }); absent when every module with an init is running (engine.moduleStates has all) */
2361
+ /** Modules that are initializing, failed or blocked ({ name: state, or 'blocked by provider (state)' }); absent when every module with an init is running (engine.moduleStates has all) */
2275
2362
  moduleStates?: Record<string, string>;
2276
2363
  /** What loading is waiting for, what failed, whether it blocks the start (engine.loading.view()) */
2277
2364
  loading: LoadingView;
@@ -2302,7 +2389,7 @@ export interface GameState {
2302
2389
  state: string | null; [key: string]: any;
2303
2390
  } | null;
2304
2391
  /** Camera: type 'follow' | 'first' | 'fixed' | 'rts', override is the takeover owner's name */
2305
- camera: { type: string | null; /** a camera rig may switch engine.camera (an EngineCamera) to orthographic */ projection: 'perspective' | 'orthographic'; orthoSize?: number; x: number; y: number; z: number; focus: { x: number; z: number }; override: string | null; [key: string]: any };
2392
+ camera: { type: string | null; /** what the camera in engine.camera is, whether a game or a rig's projection put it there */ projection: 'perspective' | 'orthographic'; orthoSize?: number; x: number; y: number; z: number; focus: { x: number; z: number }; override: string | null; [key: string]: any };
2306
2393
  /** How far counts as nearby (meters) */
2307
2394
  nearbyRadius: number;
2308
2395
  /** Nearby things, sorted by distance (at most 15) */