threedog 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (593) hide show
  1. package/CHANGELOG.md +411 -1
  2. package/README.md +8 -11
  3. package/core/{Animator.js → assets/Animator.js} +30 -18
  4. package/core/{Assets.js → assets/Assets.js} +131 -56
  5. package/core/{Baked.js → assets/Baked.js} +4 -4
  6. package/core/assets/assetEntry.js +302 -0
  7. package/core/{assetHot.js → assets/assetHot.js} +9 -7
  8. package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
  11. package/core/{assetReport.js → assets/assetReport.js} +7 -14
  12. package/core/{namedModel.js → assets/namedModel.js} +17 -13
  13. package/core/{Audio.js → audio/Audio.js} +47 -25
  14. package/core/{audioRules.js → audio/audioRules.js} +8 -5
  15. package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
  16. package/core/{Events.js → base/Events.js} +3 -3
  17. package/core/{I18n.js → base/I18n.js} +15 -12
  18. package/core/{Random.js → base/Random.js} +7 -4
  19. package/core/{Vars.js → base/Vars.js} +14 -4
  20. package/core/{easing.js → base/easing.js} +1 -1
  21. package/core/{errorCodes.js → base/errorCodes.js} +151 -125
  22. package/core/{errorHints.js → base/errorHints.js} +17 -10
  23. package/core/{errors.js → base/errors.js} +12 -10
  24. package/core/{events.generated.js → base/events.generated.js} +11 -0
  25. package/core/base/follows.js +26 -0
  26. package/core/base/math.js +66 -0
  27. package/core/{params.js → base/params.js} +5 -6
  28. package/core/base/saveValues.js +81 -0
  29. package/core/base/sections.js +97 -0
  30. package/core/base/spelling.js +32 -0
  31. package/core/base/util.js +32 -0
  32. package/core/{validate.js → base/validate.js} +34 -34
  33. package/core/{Engine.js → engine/Engine.js} +137 -91
  34. package/core/{Loading.js → engine/Loading.js} +34 -5
  35. package/core/{copies.js → engine/copies.js} +4 -4
  36. package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
  37. package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
  38. package/core/{loop.js → engine/loop.js} +88 -49
  39. package/core/engine/moduleSlots.js +176 -0
  40. package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
  41. package/core/engine/modules.js +503 -0
  42. package/core/{page.js → engine/page.js} +59 -29
  43. package/core/{plugins.js → engine/plugins.js} +21 -12
  44. package/core/{services.js → engine/services.js} +50 -40
  45. package/core/{startup.js → engine/startup.js} +66 -54
  46. package/core/{Input.js → input/Input.js} +67 -39
  47. package/core/{inputContext.js → input/inputContext.js} +14 -5
  48. package/core/input/inputKeyboard.js +39 -0
  49. package/core/{inputPad.js → input/inputPad.js} +24 -3
  50. package/core/{inputPointer.js → input/inputPointer.js} +11 -3
  51. package/core/input/inputSeat.js +66 -0
  52. package/core/{inputTouch.js → input/inputTouch.js} +24 -7
  53. package/core/{Budget.js → inspect/Budget.js} +21 -20
  54. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
  55. package/core/{Describe.js → inspect/Describe.js} +34 -26
  56. package/core/{Inspect.js → inspect/Inspect.js} +39 -10
  57. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
  58. package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
  59. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  60. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
  61. package/core/{UrlState.js → inspect/UrlState.js} +60 -24
  62. package/core/{catalog.js → inspect/catalog.js} +15 -8
  63. package/core/{checks.js → inspect/checks.js} +7 -5
  64. package/core/{debugView.js → inspect/debugView.js} +4 -4
  65. package/core/{describeRender.js → inspect/describeRender.js} +24 -22
  66. package/core/{describeText.js → inspect/describeText.js} +17 -8
  67. package/core/inspect/geometryWatch.js +38 -0
  68. package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
  69. package/core/inspect/metadata.generated.js +4140 -0
  70. package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
  71. package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
  72. package/core/inspect/toolDoor.js +21 -0
  73. package/core/inspect/valueHistory.js +35 -0
  74. package/core/{Ops.js → ops/Ops.js} +44 -14
  75. package/core/{control.js → ops/control.js} +57 -31
  76. package/core/ops/holds.js +140 -0
  77. package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
  78. package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
  79. package/core/{opsFail.js → ops/opsFail.js} +5 -7
  80. package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
  81. package/core/{opsRun.js → ops/opsRun.js} +9 -6
  82. package/core/{owned.js → ops/owned.js} +33 -19
  83. package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
  84. package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
  85. package/core/{stacks.js → ops/stacks.js} +34 -15
  86. package/core/{wrap.js → ops/wrap.js} +8 -6
  87. package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
  88. package/core/{Saves.js → saves/Saves.js} +171 -54
  89. package/core/saves/saveApply.js +312 -0
  90. package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
  91. package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
  92. package/core/saves/session.js +231 -0
  93. package/core/saves/stateReplace.js +184 -0
  94. package/core/{Rays.js → scene/Rays.js} +44 -30
  95. package/core/{Views.js → scene/Views.js} +16 -8
  96. package/core/{adaptive.js → scene/adaptive.js} +19 -9
  97. package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
  98. package/core/scene/compositeGround.js +72 -0
  99. package/core/scene/floor.js +17 -0
  100. package/core/{gameLights.js → scene/gameLights.js} +17 -7
  101. package/core/{grayMap.js → scene/grayMap.js} +8 -2
  102. package/core/{grid.js → scene/grid.js} +6 -4
  103. package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
  104. package/core/scene/ground.contract.js +14 -0
  105. package/core/scene/ground.js +139 -0
  106. package/core/{movement.js → scene/movement.js} +3 -3
  107. package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
  108. package/core/scene/pixel.js +154 -0
  109. package/core/scene/pixelRatio.js +167 -0
  110. package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
  111. package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
  112. package/core/scene/stepPoses.js +60 -0
  113. package/core/{targeting.js → scene/targeting.js} +4 -5
  114. package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
  115. package/core/{thingOps.js → scene/thingOps.js} +25 -16
  116. package/core/{things.js → scene/things.js} +18 -5
  117. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  118. package/core/{tier.js → scene/tier.js} +10 -0
  119. package/core/scene/view.js +161 -0
  120. package/core/{Batching.js → stream/Batching.js} +85 -28
  121. package/core/{Stream.js → stream/Stream.js} +80 -38
  122. package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
  123. package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
  124. package/core/{scatter.js → stream/scatter.js} +7 -4
  125. package/core/{streamSources.js → stream/streamSources.js} +14 -8
  126. package/core/{Commits.js → threads/Commits.js} +17 -11
  127. package/core/{Jobs.js → threads/Jobs.js} +25 -13
  128. package/core/{Threads.js → threads/Threads.js} +21 -18
  129. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  130. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  131. package/core/{Clock.js → time/Clock.js} +20 -11
  132. package/core/{dayTime.js → time/dayTime.js} +5 -1
  133. package/core/{skip.js → time/skip.js} +28 -21
  134. package/core/{time.js → time/time.js} +32 -20
  135. package/core/{uiClock.js → time/uiClock.js} +4 -4
  136. package/docs/AI.md +92 -72
  137. package/docs/API.md +33 -28
  138. package/docs/CODEMAP.md +121 -200
  139. package/docs/COMMANDS.md +77 -70
  140. package/docs/CONVENTIONS.md +167 -24
  141. package/docs/MIGRATING-0.8.md +171 -0
  142. package/docs/MIGRATING-1.0.md +101 -0
  143. package/docs/THREE.md +140 -38
  144. package/docs/api/assets.md +12 -13
  145. package/docs/api/audio.md +6 -5
  146. package/docs/api/budget.md +4 -4
  147. package/docs/api/calendar.md +10 -11
  148. package/docs/api/cameraRig.md +32 -29
  149. package/docs/api/characters.md +35 -24
  150. package/docs/api/clock.md +1 -1
  151. package/docs/api/collider3d.md +9 -0
  152. package/docs/api/collision.md +12 -9
  153. package/docs/api/content.md +18 -17
  154. package/docs/api/dialogue.md +5 -4
  155. package/docs/api/engine.md +58 -54
  156. package/docs/api/events.md +17 -6
  157. package/docs/api/flow.md +1 -1
  158. package/docs/api/grids.md +1 -1
  159. package/docs/api/ground.md +6 -7
  160. package/docs/api/hud.md +2 -2
  161. package/docs/api/i18n.md +6 -6
  162. package/docs/api/input.md +9 -8
  163. package/docs/api/interactions.md +5 -5
  164. package/docs/api/inventory.md +10 -10
  165. package/docs/api/jobs.md +5 -5
  166. package/docs/api/level.md +10 -9
  167. package/docs/api/lightPool.md +1 -6
  168. package/docs/api/music.md +3 -3
  169. package/docs/api/nav.md +14 -12
  170. package/docs/api/openWorld.md +1 -1
  171. package/docs/api/particles.md +10 -7
  172. package/docs/api/photo.md +4 -2
  173. package/docs/api/pickups.md +3 -3
  174. package/docs/api/post.md +21 -5
  175. package/docs/api/quests.md +7 -5
  176. package/docs/api/rays.md +7 -7
  177. package/docs/api/rigid.md +29 -19
  178. package/docs/api/saves.md +13 -11
  179. package/docs/api/settings.md +9 -8
  180. package/docs/api/sky.md +8 -7
  181. package/docs/api/stream.md +8 -9
  182. package/docs/api/swarm.md +34 -0
  183. package/docs/api/terrain.md +6 -8
  184. package/docs/api/terrainDraw.md +2 -2
  185. package/docs/api/timeline.md +4 -4
  186. package/docs/api/tools.md +27 -22
  187. package/docs/api/triggers.md +2 -0
  188. package/docs/api/vars.md +1 -1
  189. package/docs/api/vegetation.md +4 -3
  190. package/docs/api/vegetationDraw.md +2 -2
  191. package/docs/api/water.md +7 -3
  192. package/docs/api/weather.md +27 -12
  193. package/docs/api/weatherDraw.md +4 -4
  194. package/docs/api/world.md +6 -6
  195. package/docs/recipes/01-new-game.md +28 -43
  196. package/docs/recipes/02-npc.md +21 -23
  197. package/docs/recipes/03-items-pickups.md +37 -53
  198. package/docs/recipes/04-quests.md +5 -4
  199. package/docs/recipes/05-props-bake.md +34 -44
  200. package/docs/recipes/06-clock-events.md +31 -22
  201. package/docs/recipes/07-flow-scenes-pause.md +30 -32
  202. package/docs/recipes/08-weather-sky.md +91 -37
  203. package/docs/recipes/09-materials-lights-models.md +25 -39
  204. package/docs/recipes/10-blender-level.md +22 -11
  205. package/docs/recipes/11-vehicles.md +44 -24
  206. package/docs/recipes/12-navmesh.md +60 -15
  207. package/docs/recipes/13-animation.md +70 -22
  208. package/docs/recipes/14-custom-module.md +33 -20
  209. package/docs/recipes/15-perf.md +51 -28
  210. package/docs/recipes/16-dev-bridge.md +39 -58
  211. package/docs/recipes/18-world.md +49 -28
  212. package/docs/recipes/19-shooting-picking.md +7 -4
  213. package/docs/recipes/20-content-actions-save.md +55 -40
  214. package/docs/recipes/21-camera.md +47 -25
  215. package/docs/recipes/22-shop-gold.md +21 -16
  216. package/docs/recipes/23-ops.md +28 -24
  217. package/docs/recipes/26-ui-parts.md +25 -14
  218. package/docs/recipes/27-net.md +3 -5
  219. package/docs/recipes/28-terrain.md +119 -23
  220. package/docs/recipes/29-grid.md +3 -3
  221. package/docs/recipes/30-templates.md +63 -30
  222. package/docs/recipes/31-audio.md +7 -7
  223. package/docs/recipes/32-action-game.md +21 -11
  224. package/docs/recipes/33-stream-sources.md +6 -3
  225. package/docs/recipes/34-environment-lighting.md +72 -25
  226. package/docs/recipes/35-picture-from-reference.md +20 -23
  227. package/docs/recipes/36-ground-plants.md +106 -0
  228. package/docs/recipes/40-scene.md +18 -21
  229. package/docs/recipes/43-shader-patches-surfaces.md +27 -48
  230. package/docs/recipes/44-water-weather-hooks.md +56 -50
  231. package/docs/recipes/45-cascaded-shadows.md +41 -20
  232. package/docs/recipes/46-blender-art-route.md +9 -10
  233. package/docs/recipes/49-game-module-contract.md +7 -6
  234. package/docs/recipes/50-own-renderer.md +3 -2
  235. package/docs/recipes/51-capability-catalog.md +14 -8
  236. package/docs/recipes/52-around-the-picture.md +56 -100
  237. package/docs/recipes/53-ground-up-close.md +61 -24
  238. package/docs/recipes/55-mods-time-wrap.md +17 -20
  239. package/docs/recipes/56-webgpu-tsl.md +28 -15
  240. package/docs/recipes/57-control.md +39 -12
  241. package/docs/recipes/58-input.md +15 -2
  242. package/docs/recipes/59-depth-post-effects.md +1 -1
  243. package/docs/recipes/60-judge-the-picture.md +30 -25
  244. package/docs/recipes/62-picture-code.md +129 -39
  245. package/docs/recipes/63-third-person-start.md +19 -5
  246. package/docs/recipes/64-particles.md +54 -5
  247. package/docs/recipes/65-swarm.md +140 -0
  248. package/docs/recipes/66-common-tasks.md +313 -0
  249. package/examples/action/.threedog/content-index.json +1 -1
  250. package/examples/action/GAMEMAP.md +5 -5
  251. package/examples/perf-island/.threedog/content-index.json +1 -0
  252. package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
  253. package/examples/{sheepisland → perf-island}/assets.js +1 -1
  254. package/examples/{sheepisland → perf-island}/main.js +8 -8
  255. package/examples/{sheepisland → perf-island}/models.js +1 -1
  256. package/examples/{sheepisland → perf-island}/params.js +1 -1
  257. package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
  258. package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
  259. package/examples/{sheepisland → perf-island}/views.js +1 -1
  260. package/examples/plain-picture/GAMEMAP.md +4 -1
  261. package/examples/rc2d/GAMEMAP.md +4 -3
  262. package/examples/rc2d/main.js +1 -3
  263. package/examples/rc2d/rc2d.js +1 -1
  264. package/examples/styletest/.threedog/content-index.json +1 -1
  265. package/examples/styletest/GAMEMAP.md +6 -5
  266. package/examples/techniques/contact-shadows/contactShadows.js +1 -1
  267. package/examples/techniques/contact-shadows/main.js +1 -1
  268. package/examples/techniques/interior-light/main.js +1 -1
  269. package/examples/techniques/modular-building/README.md +7 -6
  270. package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
  271. package/examples/techniques/procedural-animation/README.md +1 -1
  272. package/examples/webgpu-tsl/GAMEMAP.md +2 -1
  273. package/examples/world/.threedog/content-index.json +1 -1
  274. package/examples/world/GAMEMAP.md +9 -7
  275. package/examples/world/main.js +3 -3
  276. package/examples/world/picture/sky.js +1 -1
  277. package/index.d.ts +16 -12
  278. package/index.js +53 -32
  279. package/llms.txt +11 -14
  280. package/modules/ambience/Ambience.js +16 -11
  281. package/modules/calendar/Calendar.js +19 -19
  282. package/modules/calendar/index.js +18 -16
  283. package/modules/calendar/schedule.js +11 -6
  284. package/modules/calendar/seasons.js +7 -7
  285. package/modules/camera/FirstPersonCamera.js +5 -5
  286. package/modules/camera/FixedCamera.js +43 -30
  287. package/modules/camera/FollowCamera.js +24 -15
  288. package/modules/camera/RtsCamera.js +12 -11
  289. package/modules/camera/common.js +72 -37
  290. package/modules/camera/contract.js +1 -0
  291. package/modules/camera/pixelSnap.js +62 -0
  292. package/modules/characters/Character.js +166 -70
  293. package/modules/characters/NPC.js +84 -44
  294. package/modules/characters/assetModel.js +16 -12
  295. package/modules/characters/astar.js +48 -27
  296. package/modules/characters/behaviors.js +4 -5
  297. package/modules/characters/character.contract.js +21 -0
  298. package/modules/characters/contract.js +17 -3
  299. package/modules/characters/index.js +240 -226
  300. package/modules/characters/moveHelpers.js +88 -12
  301. package/modules/characters/mover.contract.js +14 -0
  302. package/modules/characters/movers/common.js +22 -18
  303. package/modules/characters/movers/manual.js +1 -1
  304. package/modules/characters/movers/rapier.js +18 -10
  305. package/modules/characters/movers/simple.js +26 -13
  306. package/modules/characters/movers/support.js +24 -13
  307. package/modules/characters/npcAvoid.js +19 -16
  308. package/modules/characters/npcSim.js +88 -32
  309. package/modules/characters/npcView.js +19 -11
  310. package/modules/characters/pathAsync.js +81 -29
  311. package/modules/characters/pathJob.js +38 -21
  312. package/modules/characters/pathWorker.js +1 -1
  313. package/modules/characters/player.js +120 -0
  314. package/modules/characters/playerStrings.js +2 -2
  315. package/modules/characters/proceduralRig.js +2 -2
  316. package/modules/characters/seat.js +56 -0
  317. package/modules/characters/useModel.js +3 -3
  318. package/modules/characters/vehicle.contract.js +8 -5
  319. package/modules/characters/walkTo.js +40 -33
  320. package/modules/collision/Collision.js +69 -45
  321. package/modules/collision/contract.js +15 -0
  322. package/modules/collision/grid.js +6 -1
  323. package/modules/content/explain.js +2 -3
  324. package/modules/content/fields.js +24 -3
  325. package/modules/content/ids.js +5 -3
  326. package/modules/content/index.js +132 -114
  327. package/modules/content/loader.js +117 -140
  328. package/modules/content/markers.js +25 -0
  329. package/modules/content/models.js +54 -17
  330. package/modules/content/packs.js +5 -4
  331. package/modules/content/parts.js +2 -2
  332. package/modules/content/places.js +36 -0
  333. package/modules/content/props.js +22 -17
  334. package/modules/content/rules.js +47 -61
  335. package/modules/content/stages.js +7 -7
  336. package/modules/content/templates.js +80 -49
  337. package/modules/content/words.js +47 -0
  338. package/modules/debug/DebugPanel.js +14 -45
  339. package/modules/flow/contract.js +2 -1
  340. package/modules/flow/index.js +30 -16
  341. package/modules/gameplay/Container.js +17 -13
  342. package/modules/gameplay/Containers.js +23 -6
  343. package/modules/gameplay/Dialogue.js +93 -34
  344. package/modules/gameplay/Interactions.js +93 -51
  345. package/modules/gameplay/Inventory.js +64 -22
  346. package/modules/gameplay/Quests.js +146 -30
  347. package/modules/gameplay/boxOps.js +8 -1
  348. package/modules/gameplay/dialogueBubbles.js +16 -12
  349. package/modules/gameplay/inventoryOps.js +11 -8
  350. package/modules/gameplay/pickups.js +63 -37
  351. package/modules/gameplay/questLog.js +4 -2
  352. package/modules/gameplay/questSave.js +9 -4
  353. package/modules/gameplay/quests.contract.js +1 -1
  354. package/modules/grid/Grid.js +2 -2
  355. package/modules/grid/Layer.js +12 -8
  356. package/modules/grid/index.js +28 -23
  357. package/modules/grid/ops.js +43 -46
  358. package/modules/grid/preview.js +7 -7
  359. package/modules/grid/tiles.js +6 -6
  360. package/modules/hlod/index.js +42 -57
  361. package/modules/hud/index.js +22 -14
  362. package/modules/hud/parts.js +8 -8
  363. package/modules/level/contract.js +16 -0
  364. package/modules/level/heightfield.js +29 -31
  365. package/modules/level/index.js +113 -161
  366. package/modules/level/load.js +196 -0
  367. package/modules/level/meshes.js +65 -0
  368. package/modules/level/nodes.js +40 -23
  369. package/modules/lights/index.js +33 -183
  370. package/modules/lights/slots.js +93 -0
  371. package/modules/lights/sources.js +90 -0
  372. package/modules/music/Music.js +34 -28
  373. package/modules/music/rules.js +1 -1
  374. package/modules/nav/contract.js +16 -0
  375. package/modules/nav/index.js +180 -49
  376. package/modules/nav/navPath.js +45 -10
  377. package/modules/net/Client.js +7 -7
  378. package/modules/net/Host.js +7 -7
  379. package/modules/net/Net.js +1 -1
  380. package/modules/net/index.js +6 -5
  381. package/modules/net/sync.js +2 -2
  382. package/modules/net/transports.js +2 -2
  383. package/modules/particles/Particles.js +95 -29
  384. package/modules/particles/effect.js +86 -32
  385. package/modules/particles/shaders.js +19 -1
  386. package/modules/photo/Photo.js +23 -23
  387. package/modules/rigid/RigidBodies.js +255 -89
  388. package/modules/rigid/Vehicles.js +17 -8
  389. package/modules/rigid/collider3d.contract.js +26 -0
  390. package/modules/rigid/ragdoll.js +298 -0
  391. package/modules/rigid/ragdollBones.js +209 -0
  392. package/modules/rigid/refresh.js +10 -0
  393. package/modules/rigid/sync.js +51 -20
  394. package/modules/settings/Settings.js +177 -61
  395. package/modules/settings/apply.js +20 -13
  396. package/modules/settings/sections.js +19 -14
  397. package/modules/settings/strings.js +2 -2
  398. package/modules/settings/view.js +3 -3
  399. package/modules/sky/Sky.js +29 -22
  400. package/modules/sky/clouds.js +7 -7
  401. package/modules/sky/dome.js +33 -20
  402. package/modules/sky/domeLayers.js +9 -9
  403. package/modules/sky/environment.js +6 -6
  404. package/modules/sky/frame.js +19 -10
  405. package/modules/sky/season.js +7 -1
  406. package/modules/sky/shader.js +24 -25
  407. package/modules/sky/skyModule.js +17 -28
  408. package/modules/sky/tint.js +1 -1
  409. package/modules/swarm/Swarm.js +356 -0
  410. package/modules/swarm/draw.js +68 -0
  411. package/modules/swarm/grid.js +63 -0
  412. package/modules/terrain/ChunkManager.js +71 -59
  413. package/modules/terrain/chunkQueries.js +7 -24
  414. package/modules/terrain/chunkWorker.js +1 -1
  415. package/modules/terrain/draw.js +14 -11
  416. package/modules/terrain/index.js +42 -42
  417. package/modules/terrain/terrainColorMap.js +6 -3
  418. package/modules/terrain/terrainDefaults.js +2 -1
  419. package/modules/terrain/terrainEdit.js +45 -29
  420. package/modules/terrain/terrainGen.js +19 -12
  421. package/modules/terrain/terrainIsland.js +2 -2
  422. package/modules/terrain/terrainMesh.js +7 -6
  423. package/modules/terrain/terrainShape.js +8 -10
  424. package/modules/terrain/terrainShapeMain.js +3 -3
  425. package/modules/timeline/Timeline.js +83 -43
  426. package/modules/timeline/Tween.js +25 -19
  427. package/modules/timeline/shots.js +24 -17
  428. package/modules/triggers/index.js +95 -28
  429. package/modules/vegetation/Vegetation.js +34 -26
  430. package/modules/vegetation/densityMap.js +4 -7
  431. package/modules/vegetation/draw.js +39 -18
  432. package/modules/vegetation/groundChunks.js +21 -38
  433. package/modules/vegetation/index.js +37 -12
  434. package/modules/vegetation/modelGeometry.js +3 -6
  435. package/modules/vegetation/nearFade.js +1 -1
  436. package/modules/water/Water.js +20 -16
  437. package/modules/water/surface.js +3 -3
  438. package/modules/weather/Weather.js +52 -40
  439. package/modules/weather/particles.js +8 -8
  440. package/modules/weather/weatherDraw.js +28 -23
  441. package/modules/world/World.js +28 -15
  442. package/modules/world/explain.js +1 -1
  443. package/modules/world/index.js +30 -17
  444. package/modules/world/persist.js +90 -27
  445. package/modules/world/pos.js +5 -5
  446. package/modules/world/records.js +37 -11
  447. package/modules/world/sim.js +78 -27
  448. package/modules/world/simFar.js +2 -2
  449. package/modules/world/state.js +43 -11
  450. package/modules/world/thingSource.js +20 -5
  451. package/modules/world/views.js +27 -14
  452. package/package.json +48 -7
  453. package/presets.js +1 -3
  454. package/render/PostFX.js +83 -53
  455. package/render/backend.js +31 -33
  456. package/render/cascades.js +17 -12
  457. package/render/cascades.tsl.js +5 -8
  458. package/render/daylight.js +20 -3
  459. package/render/detail.js +8 -7
  460. package/render/effects.js +28 -25
  461. package/render/fuse.js +3 -3
  462. package/render/fx/cloudShadow.tsl.js +3 -3
  463. package/render/fx/detail.tsl.js +1 -1
  464. package/render/fx/index.js +5 -10
  465. package/render/fx/library.tsl.js +11 -0
  466. package/render/fx/lighting.tsl.js +2 -1
  467. package/render/fx/nodeErrors.tsl.js +2 -2
  468. package/render/fx/objectOrigin.tsl.js +1 -2
  469. package/render/fx/particles.tsl.js +8 -6
  470. package/render/fx/patchNodes.tsl.js +5 -15
  471. package/render/fx/postWebGPU.tsl.js +30 -26
  472. package/render/fx/sky.tsl.js +15 -17
  473. package/render/fx/uniforms.tsl.js +4 -4
  474. package/render/fx/wind.tsl.js +1 -1
  475. package/render/fxNumbers.js +3 -0
  476. package/render/layers.js +2 -2
  477. package/render/lighting.js +5 -3
  478. package/render/lightmap.js +41 -21
  479. package/render/lights.js +6 -6
  480. package/render/lit.js +24 -0
  481. package/render/materials.js +8 -7
  482. package/render/mergeCommon.js +22 -0
  483. package/render/modeling.js +2 -2
  484. package/render/occlusion.js +62 -15
  485. package/render/ownFrame.js +4 -4
  486. package/render/patches.js +15 -15
  487. package/render/postWebGL.js +15 -12
  488. package/render/probes.js +41 -19
  489. package/render/recordSweep.js +117 -0
  490. package/render/shaderErrors.js +10 -9
  491. package/render/shadowCache.tsl.js +107 -0
  492. package/render/shadowTypes.js +9 -0
  493. package/{core → render}/shadows.js +59 -13
  494. package/render/slots.js +7 -7
  495. package/render/terms.js +22 -24
  496. package/render/uniformDecl.js +1 -1
  497. package/types/core.d.ts +336 -202
  498. package/types/gameplay.d.ts +254 -130
  499. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
  500. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  501. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  502. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +8 -16
  503. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  504. package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
  505. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +28 -10
  506. package/types/generated/core/input/inputSeat.d.ts +26 -0
  507. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  508. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
  509. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
  510. package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
  511. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
  512. package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
  513. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  514. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
  515. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  516. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
  517. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  518. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  519. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  520. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  521. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  522. package/types/generated/modules/grid/Grid.d.ts +1 -0
  523. package/types/generated/modules/grid/Layer.d.ts +1 -1
  524. package/types/generated/modules/grid/index.d.ts +3 -3
  525. package/types/generated/modules/music/Music.d.ts +7 -5
  526. package/types/generated/modules/particles/Particles.d.ts +5 -4
  527. package/types/generated/modules/sky/Sky.d.ts +21 -10
  528. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  529. package/types/generated/modules/timeline/Timeline.d.ts +7 -5
  530. package/types/generated/modules/water/Water.d.ts +1 -0
  531. package/types/generated/modules/weather/Weather.d.ts +14 -16
  532. package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
  533. package/types/generated/modules/world/World.d.ts +11 -7
  534. package/types/generated/render/PostFX.d.ts +21 -23
  535. package/types/generated/render/materials.d.ts +1 -0
  536. package/types/generated/render/occlusion.d.ts +9 -0
  537. package/types/generated/render/patches.d.ts +1 -0
  538. package/types/generated/ui/Focus.d.ts +1 -0
  539. package/types/generated/ui/UI.d.ts +1 -0
  540. package/types/nav.d.ts +47 -15
  541. package/types/physics.d.ts +150 -73
  542. package/types/pixel.d.ts +75 -0
  543. package/types/tsl.d.ts +37 -4
  544. package/types/world.d.ts +48 -75
  545. package/ui/Focus.js +10 -9
  546. package/ui/Parts.js +13 -5
  547. package/ui/UI.js +7 -7
  548. package/ui/defaults.js +3 -2
  549. package/ui/theme.js +7 -5
  550. package/core/assetEntry.js +0 -109
  551. package/core/engineCamera.js +0 -32
  552. package/core/ground.js +0 -104
  553. package/core/holds.js +0 -134
  554. package/core/math.js +0 -48
  555. package/core/moduleSlots.js +0 -100
  556. package/core/modules.js +0 -314
  557. package/core/saveApply.js +0 -210
  558. package/core/saveValues.js +0 -46
  559. package/core/session.js +0 -174
  560. package/core/shadowTypes.js +0 -16
  561. package/core/util.js +0 -17
  562. package/core/view.js +0 -43
  563. package/docs/MIGRATING-0.3.md +0 -248
  564. package/docs/MIGRATING-0.4.md +0 -320
  565. package/docs/MIGRATING-0.5.md +0 -68
  566. package/docs/MIGRATING-0.6.md +0 -126
  567. package/docs/PERF.md +0 -245
  568. package/docs/recipes/36-sky-ground-plants.md +0 -158
  569. package/docs/recipes/37-terrain-hooks.md +0 -115
  570. package/docs/recipes/38-environment-hooks.md +0 -67
  571. package/docs/recipes/42-terrain-shape.md +0 -64
  572. package/docs/recipes/47-island-snow-backdrop.md +0 -43
  573. package/docs/recipes/54-three-idioms.md +0 -88
  574. package/examples/plain-picture/FINDINGS.md +0 -53
  575. package/examples/sheepisland/.threedog/content-index.json +0 -1
  576. package/modules/camera/projection.js +0 -21
  577. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  578. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  579. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  580. /package/core/{actor.js → ops/actor.js} +0 -0
  581. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  582. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  583. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  584. /package/core/{cells.js → stream/cells.js} +0 -0
  585. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  586. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  587. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  588. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
  589. /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
  590. /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
  591. /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
  592. /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
  593. /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
package/types/core.d.ts CHANGED
@@ -7,31 +7,31 @@ 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';
12
- import type { Stream } from './generated/core/Stream';
13
- import type { Batching } from './generated/core/Batching';
14
- import type { Rays } from './generated/core/Rays';
15
- import type { Control } from './generated/core/control';
16
- import type { I18n } from './generated/core/I18n';
17
- import type { Audio } from './generated/core/Audio';
18
- import type { Input } from './generated/core/Input';
19
- import type { Saves } from './generated/core/Saves';
20
- import type { Session } from './generated/core/session';
21
- import type { Page } from './generated/core/page';
22
- import type { Events } from './generated/core/Events';
23
- import type { Commits } from './generated/core/Commits';
24
- import type { Threads } from './generated/core/Threads';
25
- import type { Ops } from './generated/core/Ops';
26
- import type { Views } from './generated/core/Views';
27
- import type { DebugOverrides } from './generated/core/DebugOverrides';
28
- import type { Jobs } from './generated/core/Jobs';
29
- import type { Random } from './generated/core/Random';
10
+ import type { Collision, RigidBodies, Collider3D, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle, Rideable } from './physics';
11
+ import type { Nav, LinkCrossing } from './nav';
12
+ import type { Stream } from './generated/core/stream/Stream';
13
+ import type { Batching } from './generated/core/stream/Batching';
14
+ import type { Rays } from './generated/core/scene/Rays';
15
+ import type { Control } from './generated/core/ops/control';
16
+ import type { I18n } from './generated/core/base/I18n';
17
+ import type { Audio } from './generated/core/audio/Audio';
18
+ import type { Input } from './generated/core/input/Input';
19
+ import type { Saves } from './generated/core/saves/Saves';
20
+ import type { Session } from './generated/core/saves/session';
21
+ import type { Page } from './generated/core/engine/page';
22
+ import type { Events } from './generated/core/base/Events';
23
+ import type { Commits } from './generated/core/threads/Commits';
24
+ import type { Threads } from './generated/core/threads/Threads';
25
+ import type { Ops } from './generated/core/ops/Ops';
26
+ import type { Views } from './generated/core/scene/Views';
27
+ import type { DebugOverrides } from './generated/core/inspect/DebugOverrides';
28
+ import type { Jobs } from './generated/core/threads/Jobs';
29
+ 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,
34
- Particles, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
33
+ Timeline, Level, LevelLoadedEvent, LevelLoadingEvent, LevelFailedEvent, LevelPlayableEvent, LevelUnloadedEvent, Triggers, TriggerEvent, TemplateStageEvent,
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,
37
37
  } from './gameplay';
@@ -96,7 +96,7 @@ export interface EventMap extends GameEvents {
96
96
  'season:change': [season: string];
97
97
  /** A mod with `for` ran out (engine.mod(target, { owner, for })): target is the quantity's name, id the record for per-record ones */
98
98
  'mod:end': [{ target: string; owner: string; id: string | null }];
99
- /** engine.skip jumped game time forward (seconds = game seconds skipped); timers and world catch-up already ran */
99
+ /** engine.skip jumped game time forward (seconds = calendar seconds skipped); timers and world catch-up already ran */
100
100
  'time:skip': [{ seconds: number }];
101
101
  /** Lightning strike (weather module) */
102
102
  'weather:lightning': [];
@@ -109,9 +109,15 @@ 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 }];
119
+ /** A foot of a walking character came down; character.groundType() is what it stepped on */
120
+ 'character:step': [{ character: Character }];
115
121
  /** A character landed; impact is the landing speed (m/s), the larger the harder the fall */
116
122
  'character:land': [{ character: Character; impact: number }];
117
123
  /**
@@ -152,6 +158,10 @@ export interface EventMap extends GameEvents {
152
158
  'quest:part': [{ id: string; step: number; part: number }];
153
159
  /** A quest failed (its fail condition held); quests.start(id) may begin it again */
154
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 }];
155
165
  /** A photo was taken */
156
166
  'photo:taken': [PhotoShot];
157
167
  /** The photo key was pressed but the op photo.take was refused (reason from photo.canTake(), 'denied' when it returned false) */
@@ -161,11 +171,15 @@ export interface EventMap extends GameEvents {
161
171
  /** Left a trigger zone */
162
172
  'trigger:exit': [TriggerEvent];
163
173
  /** Level finished loading */
174
+ 'level:loading': [LevelLoadingEvent];
164
175
  'level:loaded': [LevelLoadedEvent];
176
+ 'level:unloaded': [LevelUnloadedEvent];
177
+ 'level:playable': [LevelPlayableEvent];
178
+ 'level:failed': [LevelFailedEvent];
165
179
  /** A cutscene started */
166
180
  'timeline:start': [{ id: number }];
167
- /** A cutscene ended; skipped tells whether it was skipped */
168
- '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 }];
169
183
  /** A content template instance entered a new stage by growing (templates with stages) */
170
184
  'template:stage': [TemplateStageEvent];
171
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 */
@@ -187,7 +201,7 @@ export interface EventMap extends GameEvents {
187
201
  /** Background music changed track (null means silence) */
188
202
  'music:change': [MusicChangeEvent];
189
203
  /** A stinger was played */
190
- 'music:stinger': [{ name: string }];
204
+ 'music:stinger': [{ name: string; played: boolean }];
191
205
  /** Scenario parameters were applied (URL parameters or engine.applyState) */
192
206
  'state:applied': [StateParams];
193
207
  /** A scenario (at, pos) moved the player: a camera or view that eases jumps there */
@@ -218,6 +232,9 @@ export interface EventMap extends GameEvents {
218
232
  'engine:error': [EngineError];
219
233
  /** A picture or ui module errored and was disabled (the game continues) */
220
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 }];
221
238
  /** A character boarded a vehicle */
222
239
  'vehicle:enter': [{ character: Character; vehicle: Rideable }];
223
240
  /** A character exited a vehicle */
@@ -231,7 +248,7 @@ export interface EventMap extends GameEvents {
231
248
  /** A playthrough started from a clean slate: kind 'new' (newGame) or 'load' (session.load, with the slot) */
232
249
  'session:start': [{ kind: 'new' | 'load'; slot?: string }];
233
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 */
234
- 'session:failed': [{ kind: 'new' | 'load'; slot?: string }];
251
+ 'session:failed': [{ kind: 'new' | 'load' | 'quit'; slot?: string }];
235
252
  /** The page went away: the window lost focus or the tab was hidden (engine.page) */
236
253
  'page:blur': [{ focused: boolean; visible: boolean }];
237
254
  /** The page came back: focused and visible again */
@@ -267,11 +284,11 @@ export interface EngineUniforms {
267
284
  uWindFreq: { value: number };
268
285
  /** Sway amplitude multiplier: every wind patch's amplitude is scaled by it */
269
286
  uWindAmp: { value: number };
270
- /** Cloud cover 0-1 (weather) */
271
- uCloud: { value: number };
287
+ /** Cloud cover 0-1 (weather) @experimental */
288
+ uWeatherCloud: { value: number };
272
289
  /** Rain amount 0-1 (weather state, every frame): a signal for the game's own wet surfaces */
273
290
  uRain: { value: number };
274
- /** Snow amount 0-1 (weather state, every frame) */
291
+ /** Snow amount 0-1 (weather state, every frame) @experimental */
275
292
  uSnow: { value: number };
276
293
  /** Weather's light multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its own lights by it */
277
294
  uWeatherLight: { value: number };
@@ -281,10 +298,10 @@ export interface EngineUniforms {
281
298
  uViewDistance: { value: number };
282
299
  /** Darkest cloud shadow 0-1 (0 = none) */
283
300
  uCloudShadow: { value: number };
284
- /** Cloud size: smaller = bigger clouds */
285
- uCloudScale: { value: number };
286
- /** Cloud drift per second */
287
- uCloudSpeed: { value: Vector2 };
301
+ /** Cloud size: smaller = bigger clouds @experimental */
302
+ uCloudShadowScale: { value: number };
303
+ /** Cloud drift per second @experimental */
304
+ uCloudShadowSpeed: { value: Vector2 };
288
305
  /** Unit vector toward the sun (sky, every frame); share the object in your own sky: mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir */
289
306
  uSunDir: { value: Vector3 };
290
307
  /** Sun color now, from the sky's keyframes (white with no sky): what a game's own sun takes. Linear, like every THREE.Color */
@@ -299,43 +316,43 @@ export interface EngineUniforms {
299
316
  uSkyTop: { value: Color };
300
317
  /** Horizon color the sky draws this frame (or the backdrop color). Read it for a shader that should meet the sky */
301
318
  uSkyHorizon: { value: Color };
302
- /** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below */
319
+ /** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below @experimental */
303
320
  uSunSize: { value: number };
304
- uSunGlow: { value: number };
321
+ /** @experimental */ uSunGlow: { value: number };
305
322
  /** Sun disk brightness (sky({ sunBrightness })) */
306
- uSunPower: { value: number };
307
- /** Moon disk sharpness (larger = smaller) */
323
+ uSunBrightness: { value: number };
324
+ /** Moon disk sharpness (larger = smaller) @experimental */
308
325
  uMoonSize: { value: number };
309
- /** Moon disk brightness (sky({ moonBrightness })) */
310
- uMoonPower: { value: number };
311
- uMoonColor: { value: Color };
312
- /** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) */
326
+ /** Moon disk brightness (sky({ moonBrightness })) @experimental */
327
+ uMoonBrightness: { value: number };
328
+ /** @experimental */ uMoonColor: { value: Color };
329
+ /** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) @experimental */
313
330
  uStars: { value: number };
314
- /** Star grid resolution: larger = smaller, more numerous stars */
331
+ /** Star grid resolution: larger = smaller, more numerous stars @experimental */
315
332
  uStarScale: { value: number };
316
- /** Horizon-to-zenith gradient exponent (sky({ gradientCurve })) */
317
- uCurve: { value: number };
318
- /** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's uCloud */
333
+ /** Horizon-to-zenith gradient exponent (engine.uniforms.uSkyCurve) @experimental */
334
+ uSkyCurve: { value: number };
335
+ /** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's uWeatherCloud */
319
336
  uCloudCover: { value: number };
320
- /** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } })); uCloudScale is the cloud shadows' */
337
+ /** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } })); uCloudShadowScale is the cloud shadows' */
321
338
  uSkyCloudScale: { value: number };
322
- /** Dome cloud drift [x, z] per second; uCloudSpeed is the cloud shadows' */
339
+ /** Dome cloud drift [x, z] per second; uCloudShadowSpeed is the cloud shadows' */
323
340
  uSkyCloudSpeed: { value: Vector2 };
324
- uCloudOpacity: { value: number };
325
- /** Dome cloud edge softness */
341
+ /** @experimental */ uCloudOpacity: { value: number };
342
+ /** Dome cloud edge softness @experimental */
326
343
  uCloudSoft: { value: number };
327
344
  /** Lit side of the dome's clouds */
328
345
  uCloudColor: { value: Color };
329
346
  /** Shaded side of the dome's clouds */
330
347
  uCloudShade: { value: Color };
331
- /** Season tint of foliage (sky, by the calendar's season) */
348
+ /** Season tint of foliage (sky, by the calendar's season) @experimental */
332
349
  uFoliageTint: { value: Color };
333
- /** Season tint of the ground (sky, by the calendar's season) */
350
+ /** Season tint of the ground (sky, by the calendar's season) @experimental */
334
351
  uGroundTint: { value: Color };
335
- uFoliageMix: { value: number };
336
- uGroundMix: { value: number };
337
- /** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in */
338
- uCover: { value: Vector2 };
352
+ /** @experimental */ uFoliageMix: { value: number };
353
+ /** @experimental */ uGroundMix: { value: number };
354
+ /** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in @experimental */
355
+ uGroundCover: { value: Vector2 };
339
356
  }
340
357
 
341
358
  /** Mouse / touch pointer. ndcX/ndcY are screen coordinates in -1..1 */
@@ -370,6 +387,9 @@ export type StringTables = Record<string, Record<string, string>>;
370
387
  // Saves
371
388
  // ======================================================================
372
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
+
373
393
  /** Save provider: save() returns JSON-able data, load(data) reads it back (may return a Promise, e.g. for changing level;
374
394
  * later parts wait for it to finish before loading).
375
395
  * first: true providers load first (parts such as the level, where the rest only makes sense after it is loaded) */
@@ -378,12 +398,15 @@ export interface SaveProvider {
378
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.
379
399
  * Data that cannot be copied makes a load refuse before anything changes (save-part-threw) */
380
400
  save: () => any;
381
- /** 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 */
382
- 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>;
383
404
  /** Load before the other parts (such as the level) */
384
405
  first?: boolean;
385
406
  /** Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback) */
386
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;
387
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) */
388
411
  checkNewGame?: (data: any) => void;
389
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 */
@@ -391,9 +414,6 @@ export interface SaveProvider {
391
414
  /** Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }.
392
415
  * The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part */
393
416
  migrate?: Record<number, (data: any, save: { parts: Record<string, any>, versions: Record<string, number> }) => any>;
394
- /** This part's data used to be saved under another part's name: { oldPart: data => newData } (newData in this version's shape). An old save without
395
- * this part but with oldPart loads it here; oldPart is then dropped unless a registered part still owns that name */
396
- movedFrom?: Record<string, (data: any) => any>;
397
417
  }
398
418
 
399
419
 
@@ -413,7 +433,7 @@ export type AssetEntry = string | ModelBuilder | {
413
433
  /** Model: generator function (instead of url) */
414
434
  build?: ModelBuilder;
415
435
  /**
416
- * Model: a params schema (core/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
436
+ * Model: a params schema (core/base/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
417
437
  * object (defaults < dev panel values < a call's own ['name', { ... }]) and the dev panel shows the fields
418
438
  */
419
439
  params?: Record<string, string | { type: string; default?: any; min?: number; max?: number; values?: any[]; desc?: string; optional?: boolean }>;
@@ -495,15 +515,16 @@ export interface Assets {
495
515
  * it in engine.loading, base resolves its relative paths
496
516
  */
497
517
  manifest(m: AssetManifest | AssetManifest[]): this;
498
- /** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) */
518
+ /** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) @experimental */
499
519
  builder(name: string): ((...args: any[]) => any) | null;
500
- /** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null */
520
+ /** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null @experimental */
501
521
  paramsOf(name: string): { schema: Record<string, any>; values: Record<string, any>; tuned: Record<string, any> } | null;
502
522
  /** Dev tuning: build a generator with these params (replacing its defaults) and swap every live copy in place; the dev panel's models folder calls it */
503
523
  setParams(name: string, values: Record<string, any>): Promise<{ why: string; names: string[]; copies: Record<string, number>; ms: number; partsChanged?: string[] }>;
504
524
  /**
505
525
  * Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now
506
526
  * showing their fallback
527
+ * @experimental
507
528
  */
508
529
  preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }): Promise<{ loaded: number; failed: string[]; ok: boolean }>;
509
530
  /**
@@ -516,10 +537,19 @@ export interface Assets {
516
537
  * acceleration)
517
538
  */
518
539
  model(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<Object3D>;
540
+ /**
541
+ * A model copy as a plain THREE.LOD: the full model near, the levels of `threedog assets optimize --lod` far away. Default distances follow the model's size;
542
+ * distances (rising meters) replace them, hysteresis is the share of a distance that stops flicker at the line (default 0.1). Rays, collision and saves keep
543
+ * using the full model. A LOD object is never batched. Without levels it warns in dev and draws in full.
544
+ * @example const tower = await engine.assets.lod('tower', { distances: [40, 120] }); engine.add(tower); tower.levels[1].object;
545
+ * @experimental
546
+ */
547
+ lod(nameOrUrl: string, opts?: { distances?: number[]; hysteresis?: number; castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<import('three').LOD>;
519
548
  /**
520
549
  * A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs.
521
550
  * Code-built models (a build function in the manifest) count too: they are null until one await model(name) or an entry with preload: true ran (dev warns [asset-not-loaded])
522
551
  * @example const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');
552
+ * @experimental
523
553
  */
524
554
  modelNow(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Object3D | null;
525
555
  /** Get the geometry of the first mesh in a model */
@@ -528,23 +558,24 @@ export interface Assets {
528
558
  gridFromImage(nameOrUrl: string, opts?: { channel?: 'r' | 'g' | 'b' | 'a' | number; range?: [number, number]; bits?: 8 | 16 }): Promise<{ data: Float32Array; width: number; height: number; bits: number }>;
529
559
  /** Get a texture (.ktx2 compressed textures also work) */
530
560
  texture(nameOrUrl: string, opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] }): Promise<Texture>;
531
- /** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one load-failed dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options */
561
+ /** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one asset-load dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options */
532
562
  useTexture(nameOrUrl: string, use: (texture: Texture) => void, o?: { where?: string; instead?: string; opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] } }): Promise<boolean>;
533
563
  /**
534
- * Release a resource and return GPU memory. Not released while copies of the model are still in the scene; it is released when the last copy is
535
- * removed with engine.remove
564
+ * Release a resource and return its memory. Not released while copies of the model are still in the scene; it is released when the last copy is
565
+ * removed with engine.remove. A sound (name or path) plays on where it is playing and loads again on next use. A load still running ends and its result is thrown away; code awaiting it gets a fresh load, never freed data. A name that
566
+ * fell back holds no data of its own: release the name it fell back to
536
567
  */
537
568
  release(name: string): void;
538
569
  /**
539
- * Release every model that has no copy in use (called automatically after level changes). Models whose shared geometry was taken by geometry() and
540
- * code-generated models are not released automatically. Returns the released names
570
+ * Release every model that has no copy in use and every long decoded sound (music, long loops; short effects stay; a sound still playing plays on), unless
571
+ * marked preload (called automatically after level changes). Models whose shared geometry was taken by geometry() and code-generated models are not released
572
+ * automatically. Returns the released names
541
573
  */
542
574
  trim(): string[];
543
- /** How many copies of this model are in use now (taken with model() and not yet removed with engine.remove) */
544
- users(name: string): number;
545
575
  /**
546
576
  * Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies
547
577
  * under it
578
+ * @experimental
548
579
  */
549
580
  forget(obj: Object3D): void;
550
581
  /** Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20 */
@@ -566,19 +597,18 @@ export interface Assets {
566
597
  animate(root: Object3D, config?: AnimatorOptions): Animator;
567
598
  /** The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping) */
568
599
  mapping(root: Object3D): AnimatorOptions | null;
569
- /** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) */
600
+ /** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) @experimental */
570
601
  gltf: any;
571
602
  /**
572
603
  * three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite
573
604
  * packs it automatically)
605
+ * @experimental
574
606
  */
575
607
  draco: any;
576
- /** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) */
608
+ /** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) @experimental */
577
609
  ktx2: any;
578
610
  /** Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost */
579
611
  report(nameOrRoot: string | Object3D): AssetReport;
580
- /** assets.report as text for the console / describe */
581
- reportText(nameOrRoot: string | Object3D): string;
582
612
  }
583
613
  /** engine.assets.report(): see recipes/46-blender-art-route.md */
584
614
  export interface AssetReport {
@@ -634,8 +664,8 @@ export interface Loading {
634
664
  /** Run the game's own loading step as a task (critical by default: a failure before start() finishes stops start()) */
635
665
  track<T>(name: string, fn: () => Promise<T>, opts?: { critical?: boolean }): Promise<T>;
636
666
  /**
637
- * Resolves when every module installed after start() has finished its init() (also when one failed: see engine.moduleStates).
638
- * @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
639
669
  */
640
670
  settled(): Promise<void>;
641
671
  /** How long start() waits for modules whose isReady(e) stays false before it rejects naming them, in ms (default 120000) */
@@ -649,7 +679,7 @@ export interface Loading {
649
679
  /** Built-in bus names; a game adds its own with createEngine({ audio: { levels: { voice: 1 } } }) or audio.addBus */
650
680
  export type AudioBus = 'master' | 'music' | 'sfx' | 'ambience' | 'ui' | (string & {});
651
681
  /** A playing sound (returned by audio.sfx / audio.play): stop(fade), fade(to, seconds), setPosition(at) */
652
- import type { SoundHandle } from './generated/core/audioVoice';
682
+ import type { SoundHandle } from './generated/core/audio/audioVoice';
653
683
  export type { SoundHandle };
654
684
  /**
655
685
  * One sounds rule in full form: how a sound plays, never what it is made of (that is the asset manifest's: a file or a synth function).
@@ -852,7 +882,7 @@ export interface UIParts {
852
882
  /** Window content by name: a function here replaces that window's default HTML, read each time it draws */
853
883
  templates: Record<string, UITemplate>;
854
884
  /** Declare a part and its default (engine and modules; games use set) */
855
- define(name: string, factory: UIPartFactory, def?: UIPartDef): void;
885
+ define(name: string, factory: UIPartFactory, def?: UIPartDef): Handle;
856
886
  /**
857
887
  * Replace a part, give the default options, or turn it off (before engine.start(); the loading part only via createEngine({ ui }))
858
888
  * @example engine.ui.set('hud.marker', false)
@@ -861,14 +891,14 @@ export interface UIParts {
861
891
  set(name: string, value: UIPartValue): void;
862
892
  /** The live single part (null when off) */
863
893
  get(name: string): UIPart | null;
864
- /** A new part for one item of a multi part (null when off) */
894
+ /** A new part for one item of a multi part (null when off) @experimental */
865
895
  create(name: string): UIPart | null;
866
896
  /** Open a full-screen part (title): shows it, takes Esc, locks input, freezes gameplay, emits ui:open; false when off */
867
897
  open(name: string, data?: object): boolean;
868
898
  /** Close a full-screen part, emits ui:close */
869
899
  close(name: string): void;
870
- isOpen(name: string): boolean;
871
- /** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle */
900
+ /** @experimental */ isOpen(name: string): boolean;
901
+ /** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle @experimental */
872
902
  titleItem(id: string, item: { label: string | ((engine: Engine) => string); run(engine: Engine): any }): { remove(): void };
873
903
  /** name -> 'default' | 'custom' | 'off' */
874
904
  describe(): Record<string, string>;
@@ -883,7 +913,7 @@ export interface UIParts {
883
913
  // Ground interface
884
914
  // ======================================================================
885
915
 
886
- /** Conventional names for the picture values only one writer may hold (core/pictureSlots.js), taken with provides like any other slot */
916
+ /** Conventional names for the picture values only one writer may hold (core/scene/pictureSlots.js), taken with provides like any other slot */
887
917
  export type PictureSlot = 'sky' | 'fog' | 'tone' | 'environment' | 'background' | 'sun';
888
918
 
889
919
  /** Ground: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0) */
@@ -894,9 +924,9 @@ export interface Ground {
894
924
  */
895
925
  height(x: number, z: number, refY?: number): number;
896
926
  /** Slope at (x, z) (height difference / horizontal distance) */
897
- slope(x: number, z: number): number;
927
+ slope(x: number, z: number, refY?: number): number;
898
928
  /** Ground type at (x, z) (landform name, e.g. 'meadow') */
899
- type(x: number, z: number): string;
929
+ type(x: number, z: number, refY?: number): string;
900
930
  /** Global water level (meters); -Infinity when there is no water */
901
931
  waterLevel: number;
902
932
  /**
@@ -910,16 +940,14 @@ export interface Ground {
910
940
  forEachCollider?(x: number, z: number, range: number, fn: (cx: number, cz: number, r: number) => void): void;
911
941
  /** Optional: chunk edge length (meters) */
912
942
  chunkSize?: number;
913
- /** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) */
943
+ /** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) @experimental */
914
944
  viewRange?(): number;
915
- /** Optional: collision data of a chunk (used by the physics module) */
945
+ /** Optional: collision data of a chunk (used by the physics module) @experimental */
916
946
  chunkCollision?(cx: number, cz: number): any;
917
- /** Optional: static triangle mesh (the level module provides it for physics) */
947
+ /** Optional: static triangle mesh (the level module provides it for physics) @experimental */
918
948
  staticTrimeshes?(): { positions: Float32Array; indices: Uint32Array }[];
919
- /** Optional: version number of the static mesh; rebuild when it changes */
949
+ /** Optional: version number of the static mesh; rebuild when it changes @experimental */
920
950
  staticVersion?(): number;
921
- /** Optional: triangle mesh for building the navmesh (walkable surfaces + obstacle volumes), used by the nav module */
922
- navGeometry?(): { positions: Float32Array; indices: Uint32Array };
923
951
  }
924
952
 
925
953
  // ======================================================================
@@ -932,6 +960,12 @@ export interface ModuleCtx {
932
960
  /** Keep handle (anything with remove(): events.on, onFixed, onFrame, clock timers, audio.measure...) until the module goes: removed when its use()
933
961
  * batch rolls back, its init fails, it is replaced, or on engine.dispose() before its dispose hook. Returns the handle */
934
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 };
935
969
  /**
936
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).
937
971
  * @example ctx.mod('time.world', { mul: 0.8, layer: 'effect' })
@@ -952,11 +986,53 @@ export interface ModuleCtx {
952
986
  * @example ctx.whileCompiling(() => { const w = new R.World(g); w.step(); w.free(); })
953
987
  */
954
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 };
955
1013
  }
956
1014
 
957
- /** What a module may own (ModuleDef.type; core/moduleTypes.js) */
1015
+ /** What a module may own (ModuleDef.type; core/engine/moduleTypes.js) */
958
1016
  export type ModuleType = 'world' | 'picture' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
959
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
+
960
1036
  /**
961
1037
  * A module (the argument of engine.use). The name is the property name on the engine once installed.
962
1038
  * Per-frame hook order follows stage, then before / after within a stage, then install order.
@@ -965,11 +1041,11 @@ export interface ModuleDef<Api = any> {
965
1041
  /** Module name; after install, access the object returned by install through engine[name] */
966
1042
  name: string;
967
1043
  /**
968
- * What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'picture' what is seen and heard (changes no
1044
+ * What the module owns (default 'rules'; core/engine/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'picture' what is seen and heard (changes no
969
1045
  * game state: no ops, no world record writes) | 'actor' characters | 'rules' game logic | 'ui' panels and menus (binds no keys, no game save part)
970
- * | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Breaking a rule throws in dev with the fix.
1046
+ * | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Going against one warns once in dev with the fix; the call still goes through.
971
1047
  */
972
- type: ModuleType;
1048
+ type?: ModuleType;
973
1049
  /** Display name (used by the loading screen) */
974
1050
  label?: string;
975
1051
  /**
@@ -995,11 +1071,11 @@ export interface ModuleDef<Api = any> {
995
1071
  * Within a stage use before / after, then install order. What the module may own and how its errors are handled come from type
996
1072
  */
997
1073
  stage?: 'control' | 'ground' | 'environment' | 'gameplay' | 'effects' | 'late' | 'audio';
998
- /** Hooks run before these modules, inside one stage (ignored if not installed;
999
- * 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) */
1000
1076
  before?: string[];
1001
- /** Hooks run after these modules, inside one stage (ignored if not installed;
1002
- * 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) */
1003
1079
  after?: string[];
1004
1080
  /**
1005
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
@@ -1016,10 +1092,12 @@ export interface ModuleDef<Api = any> {
1016
1092
  install?(e: Engine, ctx: ModuleCtx): Api;
1017
1093
  /** Called at startup (download things, wait for assets); may be async. ctx is the same as install's */
1018
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>;
1019
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) */
1020
1098
  isReady?(e: Engine): boolean;
1021
- /** After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves */
1022
- 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>;
1023
1101
  /** Fixed step (60 times per second); dt is in seconds */
1024
1102
  fixed?(dt: number, e: Engine): void;
1025
1103
  /** Once per frame; dt is in seconds */
@@ -1032,6 +1110,14 @@ export interface ModuleDef<Api = any> {
1032
1110
  * Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
1033
1111
  */
1034
1112
  skip?(dt: number, e: Engine, done: boolean): void;
1113
+ /** Why a module with a fixed hook has no skip hook */
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';
1117
+ /** The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it */
1118
+ params?: any;
1119
+ /** Where its docs live, shown by engine.catalog */
1120
+ docs?: string;
1035
1121
  /**
1036
1122
  * Optional: add state to engine.describe(). The (JSON-able) return value goes into the result keyed by the module name; nothing is added if it
1037
1123
  * returns nothing.
@@ -1042,8 +1128,10 @@ export interface ModuleDef<Api = any> {
1042
1128
  counts?(e: Engine): number | Record<string, number>;
1043
1129
  /** Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) } */
1044
1130
  explain?: Record<string, (e: Engine, value: any, query: Record<string, any>) => { ok: boolean; text: string; [k: string]: any }>;
1045
- /** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position */
1046
- applyState?(e: Engine, params: StateParams): void | PositionLike | Promise<void>;
1131
+ /** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position; return { refused: { key: reason } } for a value it cannot apply */
1132
+ applyState?(e: Engine, params: StateParams): void | PositionLike | { refused: Record<string, string> } | Promise<void>;
1133
+ /** Optional: the applyState keys this module handles; a key no module handles is reported in applyState's refused list. Leave out to count for every key */
1134
+ stateKeys?: string[];
1047
1135
  /**
1048
1136
  * Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers,
1049
1137
  * Audio nodes you connected yourself.
@@ -1070,10 +1158,17 @@ export interface EngineOptions {
1070
1158
  * working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
1071
1159
  * Every fallback prints one '[threedog] WebGPU unavailable (...)' line and shows in describe().renderer */
1072
1160
  fallback?: 'webgl2' | 'webgl' | 'error';
1073
- /** 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 */
1074
1162
  antialias?: boolean;
1075
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 */
1076
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;
1077
1172
  /** Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered */
1078
1173
  adaptiveResolution?: boolean;
1079
1174
  /** Target frame rate for automatic resolution lowering, default 55 */
@@ -1112,16 +1207,18 @@ export interface EngineOptions {
1112
1207
  /**
1113
1208
  * Check parameter names at runtime and warn on misspelled names (the console prints "did you mean xxx"), default true; a release build can write false
1114
1209
  * to turn it off
1210
+ * @experimental
1115
1211
  */
1116
1212
  validate?: boolean;
1117
1213
  /**
1118
1214
  * Directory of Draco/KTX2 decoders (a URL containing draco/ and basis/), for when they live on a CDN. Normally not needed: the decoders bundled with
1119
1215
  * three are packed by vite automatically
1216
+ * @experimental
1120
1217
  */
1121
1218
  decoders?: string;
1122
1219
  /** Performance budget limits, e.g. { drawCalls: 250, fps: 55 }; only the given categories are checked; off by default */
1123
1220
  budget?: BudgetLimits;
1124
- /** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development */
1221
+ /** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development @experimental */
1125
1222
  urlState?: boolean;
1126
1223
  /** Seed for engine.random; default 1 in headless mode (reproducible), the current time for live runs (different every game) */
1127
1224
  seed?: number;
@@ -1139,7 +1236,7 @@ export interface EngineOptions {
1139
1236
  pauseOnBlur?: boolean;
1140
1237
  /** false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. No light of the engine's reaches the picture. Default true */
1141
1238
  lights?: boolean;
1142
- /** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: engine.stream.cellSize } */
1239
+ /** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: 4 * engine.stream.cellSize } */
1143
1240
  batching?: false | BatchingOptions;
1144
1241
  }
1145
1242
 
@@ -1177,6 +1274,10 @@ export interface RayHit {
1177
1274
  normal: Vector3 | null;
1178
1275
  object: Object3D | null;
1179
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;
1180
1281
  entry?: any;
1181
1282
  kind?: string;
1182
1283
  /**
@@ -1203,10 +1304,8 @@ export interface Thing extends HitThing {
1203
1304
  id: string; owner: string; at: string | null; phase: 'setup' | 'play'; saved: 'record' | 'code' | 'session' | 'engine'; keeps: string[]; loses: string[];
1204
1305
  /** the live object (the record's current model, null when not built) */
1205
1306
  readonly object: Object3D | null;
1206
- /** 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) */
1207
- explain(): ThingExplanation;
1208
1307
  }
1209
- /** 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 */
1210
1309
  export interface ThingExplanation {
1211
1310
  id: string; kind: string; owner: string;
1212
1311
  /** at: 'content/props.js:14' (null in release builds and for code without a file) */
@@ -1309,7 +1408,7 @@ export interface StreamEntryOptions {
1309
1408
  radius?: number;
1310
1409
  /** Generate the object (called when entering range, run spread over frames through engine.jobs) */
1311
1410
  build: () => Object3D | Promise<Object3D>;
1312
- /** Unload (called when leaving range), default engine.remove (full removal); 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()) */
1313
1412
  dispose?: (obj: Object3D) => void;
1314
1413
  /** Do not unload even when out of range */
1315
1414
  keep?: boolean;
@@ -1361,9 +1460,12 @@ export interface StreamHandle { def: StreamEntryOptions; object: Object3D | null
1361
1460
  * world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
1362
1461
  */
1363
1462
  export interface StartupReport {
1364
- totalMs: number; startMs: number; preloadMs: number; streamMs: number | null; compileMs: number; modules: Record<string, { init?: number; ready?: number }>;
1365
- firstFrameMs: number | null;
1366
- phases: { script: number; construct: number; setup: number; init: number; preload: number; world: number; compile: number; draw: number | null };
1463
+ /** @experimental */ totalMs: number;
1464
+ /** @experimental */ startMs: number;
1465
+ /** @experimental */ preloadMs: number;
1466
+ /** @experimental */ streamMs: number | null; compileMs: number; modules: Record<string, { init?: number; ready?: number }>;
1467
+ /** @experimental */ firstFrameMs: number | null;
1468
+ /** @experimental */ phases: { script: number; construct: number; setup: number; init: number; preload: number; world: number; compile: number; draw: number | null };
1367
1469
  }
1368
1470
 
1369
1471
  // ======================================================================
@@ -1400,8 +1502,9 @@ export interface StateParams {
1400
1502
 
1401
1503
  /** A claim on something only its owner releases (pause, freeze, takeCamera, views) */
1402
1504
  export interface OwnerHandle { owner: string; remove(): void }
1403
- /** engine.runState: state in one word, owners = every pause / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
1404
- export interface RunState { state: 'loading' | 'title-frozen' | 'test-paused' | 'paused' | 'running'; owners: string[]; blockedBy: string[] }
1505
+ /** engine.runState: state in one word, owners = every halt / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
1506
+ export interface RunState { state: 'loading' | 'title-frozen' | 'halted' | 'frozen' | 'running'; owners: string[];
1507
+ /** @experimental */ blockedBy: string[] }
1405
1508
  /** Camera takeover: when non-null no camera module moves the camera (for cutscenes); see engine.takeCamera */
1406
1509
  export interface CameraOverride {
1407
1510
  /** Who took over (any name) */
@@ -1411,7 +1514,8 @@ export interface CameraOverride {
1411
1514
  [key: string]: any;
1412
1515
  }
1413
1516
  /** State of automatic resolution */
1414
- export interface AdaptiveState { paused: boolean; on: boolean; target: number; min: number; max: number; /** true once the render scale was lowered below max (a dev warning was logged) */ lowered?: boolean; [key: string]: any }
1517
+ export interface AdaptiveState { on: boolean; target: number; min: number; max: number; /** The ratio this device or game starts at: the base of the settings presets */ base: number;
1518
+ /** true once the render scale was lowered below max (a dev warning was logged) @experimental */ lowered?: boolean; [key: string]: any }
1415
1519
 
1416
1520
  // ======================================================================
1417
1521
  // Shadows: engine.shadows (recipes/45-cascaded-shadows.md)
@@ -1436,7 +1540,7 @@ export interface ShadowCascadeOptions {
1436
1540
  export interface ShadowCascades {
1437
1541
  /** The game's light it was given */
1438
1542
  readonly light: import('three').DirectionalLight;
1439
- /** three's CSM object (the shadow node on WebGPURenderer); null while there is one map */
1543
+ /** three's CSM object (the shadow node on WebGPURenderer); null while there is one map @experimental */
1440
1544
  readonly csm: any;
1441
1545
  /** Change options (a rebuild recompiles lit materials: a settings screen, not per frame) */
1442
1546
  set(options: ShadowCascadeOptions): void;
@@ -1480,30 +1584,41 @@ export interface TermSpec {
1480
1584
  /** Default 'lighting' for the cloud shadow, 'color' for the season tint */
1481
1585
  slot?: string;
1482
1586
  }
1483
- /** engine.terms */
1587
+ /** engine.shaderTerms */
1484
1588
  export interface Terms {
1485
1589
  /**
1486
1590
  * Your own cloud shadow in place of the engine's on engine materials and on what you passed to applyEffects, built before the call too; false takes it off them
1487
- * all. uCloud*, uTime and threedogCloudShadow(worldPos) stay in scope. remove() gives the engine's back.
1488
- * @example const mine = engine.terms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= 0.5;', tsl: c => ({ directDiffuse: c.directDiffuse.mul(0.5) }) }); mine.remove();
1591
+ * all. uWeatherCloud, uCloudShadow*, uTime and threedogCloudShadow(worldPos) stay in scope. remove() gives the engine's back.
1592
+ * @example const mine = engine.shaderTerms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= 0.5;', tsl: c => ({ directDiffuse: c.directDiffuse.mul(0.5) }) }); mine.remove();
1489
1593
  */
1490
1594
  cloudShadow(spec: TermSpec | false): { remove(): void };
1491
1595
  /**
1492
1596
  * Your own season and snow tint in place of the engine's on engine materials and on what you passed to applyEffects with a season, built before the call too; false
1493
- * takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix, uCover and threedogSeason(color, kind) stay in scope. remove() gives the engine's back.
1494
- * @example const mine = engine.terms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uCover.y);', tsl: c => c.color })); mine.remove();
1597
+ * takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix, uGroundCover and threedogSeason(color, kind) stay in scope. remove() gives the engine's back.
1598
+ * @example const mine = engine.shaderTerms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uGroundCover.y);', tsl: c => c.color })); mine.remove();
1495
1599
  */
1496
1600
  season(spec: TermSpec | ((kind: 'foliage' | 'ground') => TermSpec) | false): { remove(): void };
1497
1601
  }
1498
- /** engine.view */
1602
+ /** engine.autoView */
1499
1603
  export interface View {
1500
1604
  /**
1501
1605
  * Stop the engine changing a camera or drawing-buffer value: it is yours until you hand it back (a direct write takes it too; this says so on purpose, with no
1502
1606
  * warning). 'camera' hands the pose back after a direct write (take it with engine.takeCamera(owner)). Pass false to hand back; remove() does the same.
1503
- * @example const mine = engine.view.manual('far'); engine.camera.far = 5000; mine.remove();
1607
+ * @example const mine = engine.autoView.manual('far'); engine.camera.far = 5000; mine.remove();
1504
1608
  */
1505
1609
  manual(key: 'far' | 'fov' | 'pixelRatio' | 'camera', on?: boolean): { remove(): void };
1506
1610
  }
1611
+ /** engine.shadows.cache options: an Object3D (its whole subtree), a list of them, or a test on each mesh (recipes/45) */
1612
+ export interface ShadowCacheOptions { static: import('three').Object3D | import('three').Object3D[] | ((mesh: import('three').Object3D) => boolean); }
1613
+ /** What engine.shadows.cache returns */
1614
+ export interface ShadowCache {
1615
+ /** Say again what is static; the kept map redraws */
1616
+ set(options: ShadowCacheOptions): void;
1617
+ /** Draw the static casters again on the next shadow frame: after one moved, hid or left */
1618
+ redraw(): void;
1619
+ /** The light's plain shadow again */
1620
+ remove(): void;
1621
+ }
1507
1622
  /** engine.shadows */
1508
1623
  export interface Shadows {
1509
1624
  /**
@@ -1517,6 +1632,13 @@ export interface Shadows {
1517
1632
  box(light: import('three').DirectionalLight, options?: ShadowBoxOptions): ShadowBox;
1518
1633
  /** Redraw one light's shadow map every N frames; other lights are not touched */
1519
1634
  budget(light: import('three').Light, options?: { every?: number }): ShadowBudget;
1635
+ /**
1636
+ * Keep the shadows of what does not move: static casters are drawn once, each shadow frame copies them and draws only the rest. One plain map on WebGPURenderer;
1637
+ * elsewhere the light draws everything, with a warning. A static object that moves, hides or leaves needs redraw(); a moving light redraws everything. recipes/45
1638
+ * @example const kept = engine.shadows.cache(sun, { static: mesh => mesh !== cars.mesh }); kept.redraw(); kept.remove();
1639
+ * @experimental
1640
+ */
1641
+ cache(light: import('three').DirectionalLight, options: ShadowCacheOptions): ShadowCache;
1520
1642
  /** Change a light's shadow resolution at any time, with cascades every cascade's map (light.shadow.mapSize alone does nothing once a map exists) */
1521
1643
  mapSize(light: import('three').Light, width: number, height?: number): void;
1522
1644
  /**
@@ -1524,7 +1646,7 @@ export interface Shadows {
1524
1646
  * @example engine.shadows.include(myShaderMaterial);
1525
1647
  */
1526
1648
  include<M extends import('three').Material>(material: M): M;
1527
- /** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off */
1649
+ /** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off @experimental */
1528
1650
  readonly csm: any;
1529
1651
  }
1530
1652
  /**
@@ -1535,11 +1657,11 @@ export declare class Engine {
1535
1657
  constructor(opts: EngineOptions);
1536
1658
 
1537
1659
  // ---------- Core objects ----------
1538
- /** three.js (a game can also import { THREE } from 'threedog' directly) */
1539
- THREE: typeof import('three');
1660
+ /** False when createEngine({ validate: false }) turned the development checks off for this engine */
1661
+ validate: boolean;
1540
1662
  /** three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer) */
1541
1663
  renderer: EngineRenderer;
1542
- /** 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) */
1543
1665
  tier: 'low' | 'high';
1544
1666
  /** three.js scene */
1545
1667
  scene: import('three').Scene;
@@ -1547,8 +1669,12 @@ export declare class Engine {
1547
1669
  * Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
1548
1670
  */
1549
1671
  lights: { sun: import('three').DirectionalLight; hemi: import('three').HemisphereLight };
1550
- /** three.js PerspectiveCamera (class EngineCamera, core/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
1551
- 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;
1552
1678
  /**
1553
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
1554
1680
  * player by default), which does not follow the camera
@@ -1577,22 +1703,17 @@ export declare class Engine {
1577
1703
  */
1578
1704
  actorPosition(id?: string): { x: number; y: number; z: number } | null;
1579
1705
  /**
1580
- * Where the engine is in its life: 'constructed' (start() not called) -> 'loading' (start() running: frame hooks only, no fixed step, so no game
1706
+ * Where the engine is in its life: 'constructed' (start() not called) -> 'starting' (modules init) -> 'loading' (assets and the world; in both frame hooks only, no fixed step, so no game
1581
1707
  * time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved)
1582
1708
  * -> 'disposed'. engine.step() during loading runs frame hooks only
1583
1709
  */
1584
- readonly phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed';
1710
+ readonly phase: 'constructed' | 'starting' | 'loading' | 'ready' | 'running' | 'disposed';
1585
1711
  /** phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property) */
1586
1712
  readonly ready: boolean;
1587
1713
  /** phase is 'disposed' */
1588
1714
  readonly disposed: boolean;
1589
- /** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" */
1715
+ /** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" @experimental */
1590
1716
  readonly moduleOrder: string[];
1591
- /**
1592
- * Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'.
1593
- * A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
1594
- */
1595
- readonly moduleStates: Record<string, 'registered' | 'initializing' | 'running' | 'failed' | 'disposed'>;
1596
1717
  /**
1597
1718
  * What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas).
1598
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
@@ -1605,8 +1726,6 @@ export declare class Engine {
1605
1726
  * message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
1606
1727
  */
1607
1728
  readonly error: EngineError | null;
1608
- /** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) */
1609
- readonly disabledModules: Set<string>;
1610
1729
  /**
1611
1730
  * The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on
1612
1731
  * dispose()
@@ -1634,6 +1753,8 @@ export declare class Engine {
1634
1753
  audio: Audio;
1635
1754
  /** Assets */
1636
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;
1637
1758
  /** Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest) */
1638
1759
  readonly loading: Loading;
1639
1760
  /** Post-processing: named effects in slots (add / get / enable / list) */
@@ -1644,21 +1765,14 @@ export declare class Engine {
1644
1765
  ui: UIParts;
1645
1766
  /** Automatic resolution state */
1646
1767
  adaptive: AdaptiveState;
1647
- /**
1648
- * Main-thread CPU milliseconds of the last real-time frame: input, fixed steps, frame hooks, render submission and afterRender hooks
1649
- * (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
1650
- */
1651
- cpuMs: number;
1652
- /** cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks */
1653
- cpuPhases: { fixed: number; frame: number; render: number; afterRender: number };
1768
+ /** How far the drawn frame is from the last fixed step to the next, 0-1 (real loop); 1 after step(). Holds still while frozen. For drawing fixed-step state smoothly */
1769
+ stepBlend: number;
1654
1770
  /** The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only */
1655
- cameraOverride: CameraOverride | null;
1771
+ readonly cameraOverride: CameraOverride | null;
1656
1772
  /** Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one */
1657
1773
  takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>): OwnerHandle;
1658
1774
  /** Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is */
1659
1775
  readonly runState: RunState;
1660
- /** Draco/KTX2 decoder directory */
1661
- decoders: string;
1662
1776
  /** Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar) */
1663
1777
  clock: Clock;
1664
1778
  /**
@@ -1666,12 +1780,13 @@ export declare class Engine {
1666
1780
  * @example engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made
1667
1781
  * @example engine.mod('time.player', { owner: 'haste', mul: 1.2, for: 5 }) // haste on the player
1668
1782
  * @example engine.mod('freeze', { owner: 'pause-menu' }) // pause menu (same as engine.freeze('pause-menu'))
1783
+ * @experimental
1669
1784
  */
1670
1785
  mod(name: string, opts: import('./gameplay').ModOptions): import('./gameplay').ModHandle;
1671
- /** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) */
1786
+ /** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) @experimental */
1672
1787
  stacks: import('./gameplay').Stacks;
1673
1788
  /**
1674
- * Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the
1789
+ * Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < physics < net; a higher one pauses the
1675
1790
  * lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57
1676
1791
  * @example const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();
1677
1792
  */
@@ -1681,6 +1796,7 @@ export declare class Engine {
1681
1796
  * for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in
1682
1797
  * describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api.
1683
1798
  * @example engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })
1799
+ * @experimental
1684
1800
  */
1685
1801
  wrap<T extends object>(target: T, method: string, fn: (next: (...args: any[]) => any, ...args: any[]) => any, opts?: { owner?: string }): Handle;
1686
1802
  /** Time channels: read seconds with time.now('real' | 'ambient' | 'calendar' | a channel such as 'world'), speeds with scale(ch, id?) */
@@ -1689,7 +1805,7 @@ export declare class Engine {
1689
1805
  vars: Vars;
1690
1806
  /** Performance budget (off by default) */
1691
1807
  budget: Budget;
1692
- /** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them */
1808
+ /** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/engine/plugins.js); describe().slots lists them */
1693
1809
  plugins: {
1694
1810
  /** Plug a folder's modules yourself (the vite preset does it): import.meta.glob('./plugins/*.js', { eager: true }) */
1695
1811
  add(files: Record<string, any>, o?: { order?: string[]; off?: string[] }): any;
@@ -1707,7 +1823,7 @@ export declare class Engine {
1707
1823
  rays: Rays;
1708
1824
  /** Frame-spread job scheduler */
1709
1825
  jobs: Jobs;
1710
- /** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits */
1826
+ /** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits @experimental */
1711
1827
  commits: Commits;
1712
1828
  /**
1713
1829
  * Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays.
@@ -1718,11 +1834,6 @@ export declare class Engine {
1718
1834
  ops: Ops;
1719
1835
  /** Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md) */
1720
1836
  views: Views;
1721
- /**
1722
- * Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation
1723
- * log use it). Seconds are views of it: engine.time.now('real' | 'ambient' | 'calendar' | channel)
1724
- */
1725
- readonly tick: number;
1726
1837
  /** Seeded random numbers, an object (not a function): engine.random.next() in [0, 1), .range(a, b), .int(a, b), .pick(list), .chance(p). Use it for gameplay randomness: reproducible and saved with the game */
1727
1838
  random: Random;
1728
1839
  /**
@@ -1747,19 +1858,19 @@ export declare class Engine {
1747
1858
  // ---------- Modules (undefined when not installed) ----------
1748
1859
  /** Procedural terrain, data part (terrain() module: chunks, heights, edits, collision) */
1749
1860
  terrain?: Terrain;
1750
- /** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) */
1861
+ /** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) @experimental */
1751
1862
  terrainDraw?: TerrainDraw;
1752
1863
  /** Vegetation (vegetation() module; grows on terrain or on any ground provider) */
1753
1864
  vegetation?: Vegetation;
1754
- /** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) */
1865
+ /** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) @experimental */
1755
1866
  vegetationDraw?: VegetationDraw;
1756
- /** Sky dome, sun / moon light and fog drawn from the calendar's time (sky() module) */
1867
+ /** Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog (sky() module) */
1757
1868
  sky?: Sky;
1758
1869
  /** Time of day, day, seasons and clock-time timers (calendar() module); NPC schedules, content clock conditions and audio time rules read it */
1759
1870
  calendar?: Calendar;
1760
- /** 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 */
1761
1872
  weather?: Weather;
1762
- /** Weather drawing (installed by weather(), needs sky): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky */
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 */
1763
1874
  weatherDraw?: WeatherDraw;
1764
1875
  /** Water surface (water() module) */
1765
1876
  water?: Water;
@@ -1773,6 +1884,8 @@ export declare class Engine {
1773
1884
  collision?: Collision;
1774
1885
  /** Real physics, Rapier (rigid() module, needs collision) */
1775
1886
  rigid?: RigidBodies;
1887
+ /** Collision on all three axes (the collider3d slot, held by rigid() unless replaced) @experimental */
1888
+ collider3d?: Collider3D;
1776
1889
  /** Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamera) */
1777
1890
  cameraRig?: CameraRig;
1778
1891
  /**
@@ -1793,6 +1906,8 @@ export declare class Engine {
1793
1906
  triggers?: Triggers;
1794
1907
  /** Particles (particles() module) */
1795
1908
  particles?: Particles;
1909
+ /** Makes a swarm of same-kind gameplay objects (swarm() module): engine.swarm({ name, capacity, geometry, material, fields }) @experimental */
1910
+ swarm?: SwarmMaker;
1796
1911
  /** Settings menu (settings() module) */
1797
1912
  settings?: Settings;
1798
1913
  /** Background music (music() module) */
@@ -1801,7 +1916,7 @@ export declare class Engine {
1801
1916
  characters?: CharactersApi;
1802
1917
  /** NPC management (characters() module, npcs on by default) */
1803
1918
  npcs?: NPCManager;
1804
- /** 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 */
1805
1920
  interactions?: Interactions;
1806
1921
  /**
1807
1922
  * Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, else go on to the next one) and `dialogue.choose { index }` (pick
@@ -1809,9 +1924,9 @@ export declare class Engine {
1809
1924
  * `engine.ops.run('dialogue.choose', { index: 0 })`
1810
1925
  */
1811
1926
  dialogue?: Dialogue;
1812
- /** 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 */
1813
1928
  inventory?: Inventory;
1814
- /** 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 */
1815
1930
  pickups?: Pickups;
1816
1931
  /** Quests (quests() module) */
1817
1932
  quests?: Quests;
@@ -1828,9 +1943,9 @@ export declare class Engine {
1828
1943
  /** Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there */
1829
1944
  shadows: Shadows;
1830
1945
  /** The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there */
1831
- view: View;
1946
+ autoView: View;
1832
1947
  /** Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there */
1833
- terms: Terms;
1948
+ shaderTerms: Terms;
1834
1949
  /** Light pool: many light sources, a fixed number of real lights (lightPool() module) */
1835
1950
  lightPool?: LightPool;
1836
1951
  /** Content loading (content() module) */
@@ -1853,7 +1968,7 @@ export declare class Engine {
1853
1968
  * @example engine.unuse('rain');
1854
1969
  */
1855
1970
  unuse(name: string): void;
1856
- /** 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 */
1857
1972
  has(name: string): boolean;
1858
1973
 
1859
1974
 
@@ -1870,17 +1985,17 @@ export declare class Engine {
1870
1985
  surface(x: number, z: number, refY?: number): number;
1871
1986
  surface(at: PositionLike, refY?: number): number;
1872
1987
  /** Slope at (x, z); a position or object also works */
1873
- slope(x: number, z: number): number;
1874
- slope(at: PositionLike): number;
1988
+ slope(x: number, z: number, refY?: number): number;
1989
+ slope(at: PositionLike, refY?: number): number;
1875
1990
  /** Ground type at (x, z) (for footsteps, particles); a position or object also works. 'void' off the outline of terrain({ shape }) */
1876
- groundType(x: number, z: number): string;
1877
- groundType(at: PositionLike): string;
1991
+ groundType(x: number, z: number, refY?: number): string;
1992
+ groundType(at: PositionLike, refY?: number): string;
1878
1993
  /**
1879
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
1880
1995
  * object also works
1881
1996
  */
1882
- waterAt(x: number, z: number): number;
1883
- waterAt(at: PositionLike): number;
1997
+ waterAt(x: number, z: number, refY?: number): number;
1998
+ waterAt(at: PositionLike, refY?: number): number;
1884
1999
  /**
1885
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
1886
2001
  * reference height
@@ -1890,7 +2005,10 @@ export declare class Engine {
1890
2005
  addWaterBody(opts: WaterBodyOptions): Handle & { body: WaterBody };
1891
2006
 
1892
2007
  // ---------- Common ----------
1893
- /** Get UI text (i18n) */
2008
+ /**
2009
+ * Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself
2010
+ * @example engine.t('shop.buy', { name: 'Fish' });
2011
+ */
1894
2012
  t(key: string, params?: Record<string, any>): string;
1895
2013
  /**
1896
2014
  * Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set /
@@ -1910,8 +2028,6 @@ export declare class Engine {
1910
2028
  * materials of it and its children (textures and geometry / materials shared by assets are not released)
1911
2029
  */
1912
2030
  remove(...objs: Object3D[]): void;
1913
- /** 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 */
1914
- detach(...objs: Object3D[]): void;
1915
2031
  /**
1916
2032
  * Fixed-step logic (60 times per second, dt in fixed seconds): movement, physics, cooldowns, and gameplay keys (read pressed() here: a per-step
1917
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.
@@ -1953,12 +2069,14 @@ export declare class Engine {
1953
2069
  * bake at start-up, not mid-play.
1954
2070
  * @example const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving });
1955
2071
  * saveFile('probes.json', JSON.stringify(probes.toJSON()));
2072
+ * @experimental
1956
2073
  */
1957
2074
  bakeProbes(opts: { bounds: import('three').Box3 | { min: PositionLike; max: PositionLike }; spacing: number; resolution?: number;
1958
2075
  include?: (o: Object3D) => boolean; owner?: string }): Promise<ProbeSet>;
1959
2076
  /**
1960
2077
  * A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added.
1961
2078
  * @example const probes = engine.loadProbes(await (await fetch('probes.json')).json());
2079
+ * @experimental
1962
2080
  */
1963
2081
  loadProbes(json: ProbeData, opts?: { owner?: string }): ProbeSet;
1964
2082
  /**
@@ -1968,55 +2086,68 @@ export declare class Engine {
1968
2086
  * A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what
1969
2087
  * was skipped, moved or doubled.
1970
2088
  * @example const light = await engine.loadLightmap('light/level.lightmap');
2089
+ * @experimental
1971
2090
  */
1972
2091
  loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }): Promise<Lightmap>;
1973
2092
 
1974
2093
  // ---------- Settings ----------
1975
- /** Render resolution */
2094
+ /** Render resolution, and the top adaptive resolution climbs back to. Throws while pixelSize is on */
1976
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;
1977
2102
 
1978
2103
  // ---------- Rays, scenarios ----------
1979
2104
  /** Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit) */
1980
2105
  raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions): RayHit | null;
1981
- /** Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY) */
2106
+ /**
2107
+ * Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch
2108
+ * write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
2109
+ */
1982
2110
  pick(ndcX: number, ndcY: number, opts?: RaycastOptions): RayHit | null;
1983
2111
  /** Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done */
1984
- applyState(params: StateParams): Promise<void>;
2112
+ applyState(params: StateParams): Promise<{ ok: boolean, refused: { key: string, value: unknown, reason: string }[] }>;
1985
2113
  /** Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name */
1986
2114
  defineState(name: string, params: StateParams, opts?: { owner?: string }): { owner?: string; remove(): void };
1987
2115
  /**
1988
2116
  * Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it:
1989
2117
  * page.waitForFunction(() => window.engine?.stateApplied)
2118
+ * @experimental
1990
2119
  */
1991
2120
  readonly stateApplied: boolean;
2121
+ /** What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied @experimental */
2122
+ readonly stateRefused: { key: string, value: any, reason: string }[];
1992
2123
 
1993
2124
  // ---------- Start, pause, state ----------
1994
2125
  /** Start: initialize modules, preload assets, wait for the world to be ready */
1995
2126
  start(): Promise<this>;
1996
2127
  /** Whether in headless mode (createEngine({ headless: true })) */
1997
2128
  headless: boolean;
1998
- /** Whether paused (headless mode is paused by default, only step() advances) */
1999
- paused: boolean;
2129
+ /** Whether the real-time loop is stopped: only step() advances the game (headless mode starts this way) */
2130
+ halted: boolean;
2000
2131
  /** Smoothed frame rate */
2001
2132
  fps: number;
2002
- /** Ids of the open windows */
2003
- openWindows: Set<string>;
2004
2133
  /**
2005
2134
  * Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu
2006
2135
  * pause
2007
2136
  */
2008
- pause(owner?: string | { owner?: string; kind?: 'test' }, opts?: { kind?: 'test' }): OwnerHandle; // end it with the handle's remove()
2137
+ haltLoop(owner?: string | { owner?: string }): OwnerHandle; // end it with the handle's remove()
2009
2138
  /** Run fn at the start of the next fixed step (via commits); a Promise of fn's value */
2010
2139
  nextFixed<T>(fn: () => T): Promise<T>;
2011
2140
  /**
2012
2141
  * Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame
2013
2142
  * hooks and rendering continue and the UI works.
2014
2143
  * So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's
2015
- * name, default 'game'. uniforms.uTime (wind, water, clouds) keeps moving while frozen; { ambient: true } stops it too
2144
+ * name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { ambient: true } stops them too (a still)
2016
2145
  */
2017
2146
  freeze(owner?: string | { owner?: string; kind?: 'title'; ambient?: boolean }, opts?: { kind?: 'title'; ambient?: boolean }): OwnerHandle;
2018
2147
  /** Is anyone freezing gameplay? */
2019
2148
  readonly frozen: boolean;
2149
+ /** True while a freeze asked for a full still (freeze(owner, { ambient: true })): frame code that moves things reads this, as animation and particles do */
2150
+ readonly still: boolean;
2020
2151
  /**
2021
2152
  * Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render),
2022
2153
  * negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and
@@ -2112,7 +2243,7 @@ export declare class Engine {
2112
2243
  * Budgets are the game's engine.budget limits, else a reference (desktop 60 fps; not enforced). Plain three.js: renderer.info.
2113
2244
  * @example engine.inspect.perf().text
2114
2245
  */
2115
- perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number; compileMs: number; ok: boolean; text: string;
2246
+ perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number | null; compileMs: number; ok: boolean; text: string;
2116
2247
  budgets: { name: string; value: number; budget: number; from: 'engine.budget' | 'reference'; ok: boolean; next?: string }[];
2117
2248
  compiles: { at: number; programs: number; ms: number }[]; [k: string]: any };
2118
2249
  };
@@ -2120,14 +2251,15 @@ export declare class Engine {
2120
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
2121
2252
  * (reason first);
2122
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.
2123
2255
  * Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }.
2124
2256
  * @example engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'
2125
2257
  * @example engine.explain({ quest: 'first-light' }).text // which step it waits on
2126
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…";
2127
2259
  * thing has the rest).
2128
2260
  */
2129
- explain(q: { op: string; args?: any; actor?: string } | Record<string, any>): {
2130
- 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;
2131
2263
  };
2132
2264
  /**
2133
2265
  * Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per
@@ -2154,7 +2286,7 @@ export declare class Engine {
2154
2286
  export interface EngineError {
2155
2287
  /** Where it happened, e.g. "fixed hook of module quests" or "load() of save part 'inventory'" */
2156
2288
  where: string;
2157
- /** The error message (English) */
2289
+ /** The error message (English) @experimental */
2158
2290
  message: string;
2159
2291
  /** Stable code (e.g. 'save-load-threw', 'world-plain'); null for an unknown error */
2160
2292
  code: string | null;
@@ -2194,6 +2326,8 @@ export interface EngineCounts {
2194
2326
  rigid?: number;
2195
2327
  /** Only with particles() installed: alive is the number of live particles, emitters the number of attached emitters */
2196
2328
  particles?: { alive: number; emitters: number };
2329
+ /** Only with swarm() installed: alive is the live objects of all swarms, swarms how many exist */
2330
+ swarm?: { alive: number; swarms: number };
2197
2331
  /** Only with sky() installed: timers is the number of at / between / daily / onSeason timers */
2198
2332
  calendar?: { timers: number };
2199
2333
  /** Any other module's counts(e) hook result, under the module name */
@@ -2224,20 +2358,20 @@ export interface GameState {
2224
2358
  error: EngineError | null;
2225
2359
  /** picture / ui modules disabled after an error */
2226
2360
  disabledModules: string[];
2227
- /** 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) */
2228
2362
  moduleStates?: Record<string, string>;
2229
2363
  /** What loading is waiting for, what failed, whether it blocks the start (engine.loading.view()) */
2230
2364
  loading: LoadingView;
2231
2365
  /** tick / real / ambient / calendar are the time views (engine.time); with the calendar module there are also clock, day, season, isDay, timeOfDay */
2232
2366
  time: {
2233
- tick: number; real: number; ambient: number; calendar: number; paused: boolean; frozen: boolean; headless: boolean; clock?: string; day?: number; season?: string; isDay?: boolean;
2367
+ tick: number; real: number; ambient: number; calendar: number; halted: boolean; frozen: boolean; headless: boolean; clock?: string; day?: number; season?: string; isDay?: boolean;
2234
2368
  [key: string]: any;
2235
2369
  };
2236
2370
  /**
2237
- * Everyone who holds the engine still (empty parts left out): pause / freeze / camera / debugView [{ owner, at? }], input [{ context, owner, pass }]
2371
+ * Everyone who holds the engine still (empty parts left out): halt / freeze / camera / debugView [{ owner, at? }], input [{ context, owner, pass }]
2238
2372
  * (input.push), gates { action: owners } (input.gate). Every other shared value is in `shared`
2239
2373
  */
2240
- holds: { pause?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
2374
+ holds: { halt?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
2241
2375
  gates?: Record<string, string[]>; };
2242
2376
  /**
2243
2377
  * Every shared value and exclusive slot with entries, one row each ('move.speed[player]' for one record): the value, who decides it, how it
@@ -2255,7 +2389,7 @@ export interface GameState {
2255
2389
  state: string | null; [key: string]: any;
2256
2390
  } | null;
2257
2391
  /** Camera: type 'follow' | 'first' | 'fixed' | 'rts', override is the takeover owner's name */
2258
- 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 };
2259
2393
  /** How far counts as nearby (meters) */
2260
2394
  nearbyRadius: number;
2261
2395
  /** Nearby things, sorted by distance (at most 15) */
@@ -2272,7 +2406,7 @@ export interface GameState {
2272
2406
  cutscene: { count: number; skippable: boolean; [key: string]: any } | null;
2273
2407
  /** Installed modules in install order: name, type, and the capabilities it provides / requires when it has any */
2274
2408
  modules: { name: string; type: ModuleType; provides?: string[]; requires?: string[] }[];
2275
- /** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/plugins.js) */
2409
+ /** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/engine/plugins.js) */
2276
2410
  slots: { slot: 'scene' | 'post' | 'module' | 'light'; plugged: string; file: string; on: boolean; affects: string[] }[];
2277
2411
  /**
2278
2412
  * engine.add / world things by save tier (counts only) and what will not survive a load: unsaved ('obj#3 (main.js:88, made during play by op x)'),
@@ -2286,7 +2420,7 @@ export interface GameState {
2286
2420
  perf: {
2287
2421
  fps: number | null; cpuMs: number | null; drawCalls: number; triangles: number; pixelRatio: number;
2288
2422
  chunks?: { loaded: number; visible: number; queued: number }; budget?: BudgetReport | null; startup?: StartupReport | null;
2289
- /** cpuMs by phase (null while paused), see Engine.cpuPhases */
2423
+ /** cpuMs by phase (null while paused), see engine.inspect.perf() */
2290
2424
  cpu?: { fixed: number; frame: number; render: number; afterRender: number } | null;
2291
2425
  /** Cost of applying background results by stage: transit, build, collider, upload, stream (see engine.budget.cost; upload and transit are approximations) */
2292
2426
  apply?: Record<string, { n: number; totalMs: number; maxMs: number; frameMs: number; bytes: number }>;
@@ -2304,7 +2438,7 @@ export interface GameState {
2304
2438
  weatherDraw?: { rainVisible: boolean; snowVisible: boolean; flash: number };
2305
2439
  /**
2306
2440
  * Every value the engine writes on its own (shadow box center, background, camera.far, pixel ratio, camera ...) and who writes it now (writer): 'engine',
2307
- * 'manual:<who>' (engine.view.manual(key), or the entry that hands the value to the game) or 'three (engine yielded)' (the game wrote it directly). manual = the takeover call
2441
+ * 'manual:<who>' (engine.autoView.manual(key), or the entry that hands the value to the game) or 'three (engine yielded)' (the game wrote it directly). manual = the takeover call
2308
2442
  */
2309
2443
  owned?: Record<string, { part: string; key: string; writer: string; manual?: string }>;
2310
2444
  /** Content added by other modules */
@@ -2326,7 +2460,7 @@ export interface DescribeContext {
2326
2460
  export interface SkipOptions {
2327
2461
  /** Until the calendar clock next reads this time ('HH:MM' or 0-1; needs calendar). The current time itself means a full day */
2328
2462
  to?: string | number;
2329
- /** Game seconds to skip (> 0) */
2463
+ /** Calendar seconds to skip (> 0) */
2330
2464
  seconds?: number;
2331
2465
  /** Fade out / in seconds (default 0: no fade, the jump happens before skip returns) */
2332
2466
  fade?: number;