threedog 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/CHANGELOG.md +879 -798
  2. package/README.md +1 -1
  3. package/core/assets/Animator.js +41 -3
  4. package/core/assets/Assets.js +100 -24
  5. package/core/assets/assetEntry.js +73 -20
  6. package/core/assets/assetHot.js +68 -16
  7. package/core/assets/assetLoad.js +6 -6
  8. package/core/assets/assetLod.js +9 -2
  9. package/core/assets/assetManifest.js +12 -2
  10. package/core/assets/assetPart.js +54 -0
  11. package/core/assets/ik.js +271 -0
  12. package/core/assets/modelNeeds.js +37 -0
  13. package/core/assets/namedModel.js +102 -29
  14. package/core/assets/nodeVisibility.js +15 -0
  15. package/core/audio/Audio.js +36 -4
  16. package/core/audio/audioReverb.js +99 -0
  17. package/core/audio/audioRules.js +1 -1
  18. package/core/audio/audioVoice.js +1 -1
  19. package/core/base/Events.js +14 -4
  20. package/core/base/Random.js +1 -1
  21. package/core/base/Vars.js +1 -1
  22. package/core/base/docRef.js +51 -0
  23. package/core/base/errorCodes.js +178 -126
  24. package/core/base/errorHints.js +9 -7
  25. package/core/base/errors.js +25 -10
  26. package/core/base/events.generated.js +2 -0
  27. package/core/base/freeParts.js +76 -0
  28. package/core/base/math.js +28 -0
  29. package/core/base/sections.js +5 -5
  30. package/core/base/validate.js +31 -3
  31. package/core/engine/Engine.js +16 -6
  32. package/core/engine/Loading.js +5 -3
  33. package/core/engine/copies.js +1 -1
  34. package/core/engine/headlessLoad.js +4 -1
  35. package/core/engine/lifecycle.js +32 -16
  36. package/core/engine/loop.js +71 -27
  37. package/core/engine/moduleSlots.js +2 -2
  38. package/core/engine/moduleTypes.js +3 -3
  39. package/core/engine/modules.js +65 -39
  40. package/core/engine/page.js +6 -3
  41. package/core/engine/services.js +6 -5
  42. package/core/engine/startup.js +5 -5
  43. package/core/input/Input.js +28 -14
  44. package/core/input/inputContext.js +28 -16
  45. package/core/input/inputKeyboard.js +31 -3
  46. package/core/input/inputPad.js +4 -0
  47. package/core/input/inputPointer.js +2 -1
  48. package/core/input/inputSeat.js +1 -1
  49. package/core/inspect/Budget.js +109 -19
  50. package/core/inspect/DebugOverrides.js +28 -4
  51. package/core/inspect/Describe.js +17 -9
  52. package/core/inspect/Inspect.js +4 -2
  53. package/core/inspect/InspectMaterials.js +3 -1
  54. package/core/inspect/InspectPerf.js +19 -9
  55. package/core/inspect/InspectScene.js +32 -7
  56. package/core/inspect/MaterialInfo.js +19 -2
  57. package/core/inspect/UrlState.js +46 -27
  58. package/core/inspect/catalog.js +28 -9
  59. package/core/inspect/debugView.js +2 -1
  60. package/core/inspect/describeRender.js +25 -13
  61. package/core/inspect/describeText.js +14 -6
  62. package/core/inspect/lightWatch.js +1 -1
  63. package/core/inspect/metadata.generated.js +35 -17
  64. package/core/inspect/pictureChecks.js +148 -0
  65. package/core/inspect/pictureMenu.js +84 -0
  66. package/core/inspect/pictureWriters.js +26 -6
  67. package/core/inspect/textureBytes.js +12 -2
  68. package/core/inspect/toolDoor.js +2 -4
  69. package/core/ops/Ops.js +11 -4
  70. package/core/ops/holds.js +27 -10
  71. package/core/ops/opsAtomic.js +15 -7
  72. package/core/ops/opsGuard.js +2 -2
  73. package/core/ops/opsRun.js +8 -7
  74. package/core/ops/sharedPoint.js +72 -21
  75. package/core/ops/stacks.js +56 -16
  76. package/core/saves/SaveStore.js +9 -3
  77. package/core/saves/Saves.js +32 -23
  78. package/core/saves/saveApply.js +96 -44
  79. package/core/saves/saveIds.js +1 -1
  80. package/core/saves/saveVersions.js +7 -5
  81. package/core/saves/session.js +17 -8
  82. package/core/saves/stateReplace.js +34 -15
  83. package/core/scene/Rays.js +52 -10
  84. package/core/scene/Views.js +13 -7
  85. package/core/scene/adaptive.js +144 -21
  86. package/core/scene/drawOnly.js +17 -0
  87. package/core/scene/gameLights.js +44 -3
  88. package/core/scene/sceneMethods.js +13 -11
  89. package/core/scene/stepPoses.js +11 -3
  90. package/core/scene/targeting.js +5 -3
  91. package/core/scene/thingOps.js +1 -1
  92. package/core/scene/tier.js +15 -0
  93. package/core/stream/Batching.js +30 -7
  94. package/core/stream/Stream.js +26 -7
  95. package/core/stream/batchGroups.js +2 -2
  96. package/core/stream/chunkStream.js +7 -5
  97. package/core/stream/prepare.js +77 -0
  98. package/core/time/skip.js +3 -1
  99. package/core/time/time.js +4 -2
  100. package/docs/AI.md +82 -83
  101. package/docs/API.md +16 -16
  102. package/docs/CODEMAP.md +16 -11
  103. package/docs/COMMANDS.md +139 -142
  104. package/docs/CONVENTIONS.md +37 -49
  105. package/docs/MIGRATING-0.8.md +2 -2
  106. package/docs/MIGRATING-1.0.md +2 -2
  107. package/docs/THREE.md +28 -35
  108. package/docs/api/assets.md +3 -1
  109. package/docs/api/audio.md +4 -2
  110. package/docs/api/budget.md +5 -0
  111. package/docs/api/characters.md +10 -8
  112. package/docs/api/collision.md +6 -4
  113. package/docs/api/engine.md +16 -16
  114. package/docs/api/events.md +3 -2
  115. package/docs/api/ground.md +6 -5
  116. package/docs/api/hud.md +4 -2
  117. package/docs/api/input.md +5 -5
  118. package/docs/api/particles.md +2 -1
  119. package/docs/api/photo.md +3 -0
  120. package/docs/api/post.md +7 -4
  121. package/docs/api/quests.md +2 -2
  122. package/docs/api/rays.md +1 -2
  123. package/docs/api/saves.md +7 -7
  124. package/docs/api/settings.md +2 -2
  125. package/docs/api/tools.md +3 -1
  126. package/docs/api/vars.md +1 -1
  127. package/docs/api/vegetation.md +4 -2
  128. package/docs/api/world.md +1 -1
  129. package/docs/recipes/01-new-game.md +16 -17
  130. package/docs/recipes/02-npc.md +22 -18
  131. package/docs/recipes/03-items-pickups.md +37 -35
  132. package/docs/recipes/04-quests.md +15 -10
  133. package/docs/recipes/05-props-bake.md +101 -95
  134. package/docs/recipes/06-clock-events.md +28 -28
  135. package/docs/recipes/07-flow-scenes-pause.md +29 -26
  136. package/docs/recipes/08-weather-sky.md +52 -64
  137. package/docs/recipes/09-materials-lights-models.md +26 -17
  138. package/docs/recipes/10-blender-level.md +15 -10
  139. package/docs/recipes/11-vehicles.md +12 -7
  140. package/docs/recipes/12-navmesh.md +44 -26
  141. package/docs/recipes/13-animation.md +56 -45
  142. package/docs/recipes/14-custom-module.md +21 -18
  143. package/docs/recipes/15-perf.md +61 -55
  144. package/docs/recipes/16-dev-bridge.md +23 -33
  145. package/docs/recipes/18-world.md +36 -42
  146. package/docs/recipes/19-shooting-picking.md +20 -15
  147. package/docs/recipes/20-content-actions-save.md +48 -56
  148. package/docs/recipes/21-camera.md +45 -54
  149. package/docs/recipes/22-shop-gold.md +12 -7
  150. package/docs/recipes/23-ops.md +25 -23
  151. package/docs/recipes/26-ui-parts.md +67 -47
  152. package/docs/recipes/27-net.md +12 -7
  153. package/docs/recipes/28-terrain.md +24 -21
  154. package/docs/recipes/29-grid.md +32 -27
  155. package/docs/recipes/30-templates.md +21 -20
  156. package/docs/recipes/31-audio.md +39 -22
  157. package/docs/recipes/32-action-game.md +19 -14
  158. package/docs/recipes/33-stream-sources.md +15 -11
  159. package/docs/recipes/34-environment-lighting.md +126 -70
  160. package/docs/recipes/35-picture-from-reference.md +8 -8
  161. package/docs/recipes/36-ground-plants.md +27 -21
  162. package/docs/recipes/40-scene.md +19 -28
  163. package/docs/recipes/43-shader-patches-surfaces.md +15 -12
  164. package/docs/recipes/44-water-weather-hooks.md +34 -31
  165. package/docs/recipes/45-cascaded-shadows.md +35 -26
  166. package/docs/recipes/46-blender-art-route.md +6 -1
  167. package/docs/recipes/49-game-module-contract.md +13 -8
  168. package/docs/recipes/50-own-renderer.md +6 -2
  169. package/docs/recipes/51-capability-catalog.md +15 -8
  170. package/docs/recipes/52-around-the-picture.md +34 -32
  171. package/docs/recipes/53-ground-up-close.md +6 -1
  172. package/docs/recipes/55-mods-time-wrap.md +27 -19
  173. package/docs/recipes/56-webgpu-tsl.md +74 -43
  174. package/docs/recipes/57-control.md +18 -13
  175. package/docs/recipes/58-input.md +26 -16
  176. package/docs/recipes/59-depth-post-effects.md +8 -3
  177. package/docs/recipes/60-judge-the-picture.md +9 -8
  178. package/docs/recipes/61-deploy.md +5 -0
  179. package/docs/recipes/62-picture-code.md +70 -79
  180. package/docs/recipes/63-third-person-start.md +47 -45
  181. package/docs/recipes/64-particles.md +22 -10
  182. package/docs/recipes/65-swarm.md +18 -13
  183. package/docs/recipes/66-common-tasks.md +38 -35
  184. package/examples/action/GAMEMAP.md +2 -3
  185. package/examples/action/main.js +3 -3
  186. package/examples/action/picture/lights.js +3 -1
  187. package/examples/perf-island/GAMEMAP.md +3 -3
  188. package/examples/perf-island/picture/lights.js +2 -1
  189. package/examples/plain-picture/GAMEMAP.md +1 -1
  190. package/examples/rc2d/GAMEMAP.md +1 -1
  191. package/examples/styletest/GAMEMAP.md +2 -2
  192. package/examples/styletest/main.js +1 -1
  193. package/examples/techniques/interior-light/README.md +3 -3
  194. package/examples/techniques/interior-light/interiorLight.js +2 -4
  195. package/examples/techniques/interior-light/picture/lights.js +2 -1
  196. package/examples/techniques/modular-building/picture/lights.js +3 -1
  197. package/examples/techniques/outlines-and-rim/picture/lights.js +3 -1
  198. package/examples/techniques/procedural-animation/README.md +1 -1
  199. package/examples/techniques/procedural-animation/main.js +1 -1
  200. package/examples/webgpu-tsl/GAMEMAP.md +1 -1
  201. package/examples/world/GAMEMAP.md +2 -3
  202. package/examples/world/art/humanoid.js +1 -1
  203. package/examples/world/main.js +6 -3
  204. package/index.d.ts +2 -2
  205. package/llms.txt +101 -0
  206. package/modules/ambience/Ambience.js +21 -5
  207. package/modules/calendar/index.js +9 -5
  208. package/modules/calendar/schedule.js +23 -8
  209. package/modules/camera/FirstPersonCamera.js +3 -1
  210. package/modules/camera/FollowCamera.js +10 -5
  211. package/modules/camera/RtsCamera.js +4 -3
  212. package/modules/camera/common.js +70 -8
  213. package/modules/camera/contract.js +1 -1
  214. package/modules/characters/Character.js +16 -10
  215. package/modules/characters/NPC.js +31 -19
  216. package/modules/characters/assetModel.js +14 -9
  217. package/modules/characters/astar.js +6 -1
  218. package/modules/characters/contract.js +2 -2
  219. package/modules/characters/index.js +34 -22
  220. package/modules/characters/movers/manual.js +1 -1
  221. package/modules/characters/movers/rapier.js +17 -2
  222. package/modules/characters/movers/simple.js +1 -1
  223. package/modules/characters/movers/support.js +16 -7
  224. package/modules/characters/npcAvoid.js +2 -2
  225. package/modules/characters/npcSim.js +3 -2
  226. package/modules/characters/pathAsync.js +24 -8
  227. package/modules/characters/pathJob.js +1 -1
  228. package/modules/characters/player.js +10 -9
  229. package/modules/characters/playerStrings.js +5 -5
  230. package/modules/characters/proceduralRig.js +5 -5
  231. package/modules/characters/useModel.js +6 -0
  232. package/modules/characters/walkTo.js +1 -1
  233. package/modules/collision/Collision.js +29 -18
  234. package/modules/collision/grid.js +22 -4
  235. package/modules/content/index.js +3 -1
  236. package/modules/content/loader.js +1 -1
  237. package/modules/content/models.js +82 -33
  238. package/modules/content/props.js +2 -1
  239. package/modules/content/rules.js +11 -5
  240. package/modules/content/templates.js +3 -3
  241. package/modules/content/words.js +2 -2
  242. package/modules/debug/DebugPanel.js +9 -9
  243. package/modules/flow/index.js +9 -6
  244. package/modules/gameplay/Dialogue.js +34 -20
  245. package/modules/gameplay/Interactions.js +19 -15
  246. package/modules/gameplay/Inventory.js +9 -4
  247. package/modules/gameplay/Quests.js +12 -10
  248. package/modules/gameplay/pickups.js +23 -11
  249. package/modules/grid/index.js +1 -1
  250. package/modules/grid/preview.js +2 -2
  251. package/modules/grid/tiles.js +1 -1
  252. package/modules/hlod/index.js +4 -1
  253. package/modules/hud/index.js +47 -10
  254. package/modules/hud/parts.js +28 -9
  255. package/modules/level/geometry.js +8 -3
  256. package/modules/level/index.js +10 -5
  257. package/modules/level/load.js +4 -2
  258. package/modules/lights/sources.js +1 -1
  259. package/modules/music/Music.js +22 -4
  260. package/modules/nav/index.js +20 -10
  261. package/modules/particles/Particles.js +31 -14
  262. package/modules/particles/effect.js +20 -5
  263. package/modules/particles/lit.js +72 -0
  264. package/modules/photo/Photo.js +72 -28
  265. package/modules/photo/pathTrace.js +106 -0
  266. package/modules/rigid/RigidBodies.js +23 -14
  267. package/modules/rigid/Vehicles.js +3 -13
  268. package/modules/rigid/sync.js +2 -1
  269. package/modules/settings/Settings.js +52 -20
  270. package/modules/settings/apply.js +23 -9
  271. package/modules/settings/sections.js +39 -6
  272. package/modules/settings/strings.js +2 -0
  273. package/modules/settings/view.js +19 -3
  274. package/modules/sky/dome.js +15 -3
  275. package/modules/sky/environment.js +28 -12
  276. package/modules/sky/fog.js +1 -1
  277. package/modules/sky/frame.js +6 -1
  278. package/modules/sky/shader.js +4 -3
  279. package/modules/sky/skyModule.js +8 -4
  280. package/modules/swarm/Swarm.js +1 -1
  281. package/modules/terrain/ChunkManager.js +61 -15
  282. package/modules/terrain/chunkJob.js +2 -2
  283. package/modules/terrain/index.js +20 -5
  284. package/modules/terrain/terrainEdit.js +8 -4
  285. package/modules/terrain/terrainTexture.js +4 -2
  286. package/modules/timeline/Timeline.js +4 -3
  287. package/modules/timeline/Tween.js +3 -0
  288. package/modules/timeline/letterbox.js +1 -0
  289. package/modules/triggers/index.js +36 -17
  290. package/modules/vegetation/Vegetation.js +81 -19
  291. package/modules/vegetation/densityMap.js +13 -8
  292. package/modules/vegetation/draw.js +147 -24
  293. package/modules/vegetation/groundChunks.js +20 -5
  294. package/modules/vegetation/index.js +3 -3
  295. package/modules/vegetation/modelGeometry.js +9 -4
  296. package/modules/water/Water.js +11 -8
  297. package/modules/weather/Weather.js +7 -2
  298. package/modules/weather/shaders.js +25 -5
  299. package/modules/weather/weatherDraw.js +20 -6
  300. package/modules/world/World.js +2 -1
  301. package/modules/world/index.js +2 -2
  302. package/modules/world/persist.js +6 -2
  303. package/modules/world/views.js +15 -2
  304. package/package.json +4 -1
  305. package/presets.js +5 -5
  306. package/render/PostFX.js +84 -41
  307. package/render/backend.js +137 -16
  308. package/render/cascades.js +3 -1
  309. package/render/cascades.tsl.js +2 -0
  310. package/render/daylight.js +7 -1
  311. package/render/detail.js +7 -4
  312. package/render/effects.js +27 -8
  313. package/render/fogLook.js +24 -0
  314. package/render/fuse.js +5 -2
  315. package/render/fx/detail.tsl.js +9 -7
  316. package/render/fx/index.js +7 -2
  317. package/render/fx/library.tsl.js +1 -0
  318. package/render/fx/lightShaft.tsl.js +114 -0
  319. package/render/fx/noise.tsl.js +25 -8
  320. package/render/fx/objectOrigin.tsl.js +39 -10
  321. package/render/fx/particles.tsl.js +23 -6
  322. package/render/fx/patchNodes.tsl.js +17 -12
  323. package/render/fx/pcss.tsl.js +51 -0
  324. package/render/fx/postWebGPU.tsl.js +89 -29
  325. package/render/fx/sky.tsl.js +3 -9
  326. package/render/fxNumbers.js +10 -4
  327. package/render/impostor.tsl.js +107 -0
  328. package/render/lighting.js +33 -1
  329. package/render/lightmap.js +42 -28
  330. package/render/lights.js +19 -3
  331. package/render/materials.js +6 -4
  332. package/render/mergeCommon.js +4 -1
  333. package/render/occlusion.js +14 -4
  334. package/render/patches.js +79 -41
  335. package/render/postRuns.js +32 -0
  336. package/render/postWebGL.js +97 -10
  337. package/render/probes.js +10 -14
  338. package/render/shaderErrors.js +2 -1
  339. package/render/shadowCache.tsl.js +33 -5
  340. package/render/shadows.js +42 -16
  341. package/render/slots.js +8 -5
  342. package/render/vertexInputs.js +52 -0
  343. package/types/core.d.ts +114 -46
  344. package/types/gameplay.d.ts +56 -23
  345. package/types/generated/core/audio/Audio.d.ts +27 -1
  346. package/types/generated/core/base/Random.d.ts +1 -1
  347. package/types/generated/core/input/Input.d.ts +6 -8
  348. package/types/generated/core/input/inputSeat.d.ts +1 -1
  349. package/types/generated/core/inspect/Budget.d.ts +26 -0
  350. package/types/generated/core/inspect/DebugOverrides.d.ts +0 -2
  351. package/types/generated/core/saves/Saves.d.ts +10 -7
  352. package/types/generated/core/saves/session.d.ts +8 -2
  353. package/types/generated/core/scene/Rays.d.ts +1 -3
  354. package/types/generated/modules/particles/Particles.d.ts +1 -1
  355. package/types/generated/modules/world/World.d.ts +2 -1
  356. package/types/generated/render/PostFX.d.ts +35 -9
  357. package/types/physics.d.ts +796 -764
  358. package/types/pixel.d.ts +1 -1
  359. package/types/tsl.d.ts +62 -1
  360. package/types/world.d.ts +12 -3
  361. package/ui/Focus.js +7 -5
  362. package/ui/Parts.js +1 -1
  363. package/ui/touchPart.js +6 -3
@@ -297,6 +297,8 @@ export interface ParticleOptions {
297
297
  ratePerMeter?: number;
298
298
  /** Meters over which a particle fades where it meets what writes depth; default 0, off. Set at define, not in overrides. On WebGLRenderer it costs one depth-only draw of the scene per render while such an effect is on screen @experimental */
299
299
  soft?: number;
300
+ /** The scene's lights tint each particle's color (dust a lamp lights): point, spot, directional, ambient, hemisphere, as a matte card facing each light. No shadows, environment map or probes. Default false (the color is drawn as given). Set at define, not in overrides; costs live particles x lights per frame on the CPU, the same on both renderers @experimental */
301
+ lit?: boolean;
300
302
  }
301
303
  /** Continuous emitter returned by attach() (a handle) */
302
304
  export interface ParticleEmitter extends Handle {
@@ -434,7 +436,7 @@ export interface Settings {
434
436
  presets: Record<string, QualityPreset>;
435
437
  /** Tabs @experimental */
436
438
  sections: Map<string, any>;
437
- /** Whether the menu is open @experimental */
439
+ /** Whether the menu is open */
438
440
  readonly isOpen: boolean;
439
441
  /** Read a setting, e.g. get('vol.music') */
440
442
  get(key: string): any;
@@ -444,8 +446,14 @@ export interface Settings {
444
446
  preset(name: 'low' | 'medium' | 'high' | (string & {})): void;
445
447
  /** Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row
446
448
  * restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on),
447
- * on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists */
448
- define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | { apply?: (value: T, e: Engine) => void; limits?: string | string[] }): this;
449
+ * on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists.
450
+ * The menu draws the row itself in the tab menu names (default 'options', shown while it has a row): a switch for true/false, a slider for a
451
+ * number (min/max; a limits row has 0..1), buttons for options. label: an i18n key or text, else the key. menu: false when your own tab draws it;
452
+ * a row the menu cannot draw, a missing tab or a row drawn twice warns once */
453
+ define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | {
454
+ apply?: (value: T, e: Engine) => void; limits?: string | string[];
455
+ menu?: string | false; label?: string; options?: (T | [T, string])[]; min?: number; max?: number; step?: number;
456
+ }): this;
449
457
  /** Add a tab of your own, or a built-in / optional one by name: addSection('camera') */
450
458
  addSection(id: string, section?: SettingsSection): this;
451
459
  open(): void;
@@ -535,7 +543,7 @@ export interface CharacterOptions {
535
543
  /**
536
544
  * The game's own states on top of the built-in ones (crouch, climb, glide, dash, roll): run after the mover's state each step, return a state name
537
545
  * or null to keep facts.base. The state picks the clip like any other (clips: { crouch: 'Crouch' }); speed changes stay engine.mod('move.speed')
538
- * @example createPlayer({ ..., clips: { crouch: 'Crouch' }, states: (c, f) => f.grounded && engine.input.down('crouch') ? 'crouch' : null })
546
+ * @example addPlayer({ ..., clips: { crouch: 'Crouch' }, states: (c, f) => f.grounded && engine.input.down('crouch') ? 'crouch' : null })
539
547
  */
540
548
  states?: CharacterStates | null;
541
549
  /** Water depth (meters) at which water counts as deep, default 1 */
@@ -568,12 +576,14 @@ export interface CharacterOptions {
568
576
  fall?: false | { belowY: number | ((character: Character) => boolean) };
569
577
  /** Time channel its movement and animation follow when the engine drives it (player default 'player', others 'world') */
570
578
  channel?: string;
579
+ /** Collider layers it walks through, e.g. ['gate'] (collision.addBox { layer: 'gate' }): its walking, walkTo and NPC paths, navmesh included, follow it. Default: stopped by every collider */
580
+ passes?: string[];
571
581
  /**
572
582
  * The body, one path for every kind: the name of a registered model asset, or what engine.assets.model() returned. A procedural builder name
573
583
  * (from an asset pack) is built at once; a file model name shows a gray capsule and swaps in a copy when it loads (Character.ready / whenReady,
574
584
  * event 'character:model'). Without model and rig: a gray capsule placeholder (warned once)
575
- * @example engine.assets.manifest(yourAssets); engine.characters.createPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack
576
- * @example engine.characters.createPlayer({ model: 'hero' }) // after engine.assets.manifest({ models: { hero: '/models/hero.glb' } })
585
+ * @example engine.assets.manifest(yourAssets); engine.characters.addPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack
586
+ * @example engine.characters.addPlayer({ model: 'hero' }) // after engine.assets.manifest({ models: { hero: '/models/hero.glb' } })
577
587
  */
578
588
  model?: Object3D | string | null;
579
589
  /** A ready procedural body (CharacterRig), used instead of model (a hand-built guard / pet) */
@@ -603,7 +613,7 @@ export type MoveRequest = { x: number; y?: number; z: number; run?: boolean } |
603
613
  * a function returning the move request. The game moving the player itself takes control: engine.control.take(player, { owner, layer: 'script', step })
604
614
  */
605
615
  export type PlayerControl = 'camera' | ((player: Character, input: Input, dt: number) => MoveRequest);
606
- /** Parameters of createPlayer() */
616
+ /** Parameters of addPlayer() */
607
617
  export interface PlayerOptions extends CharacterOptions {
608
618
  /** A further local player's id and world record; left out, the one player (engine.player) */
609
619
  id?: string;
@@ -625,7 +635,7 @@ export type CharacterState = 'idle' | 'walk' | 'run' | 'swim' | 'jump' | 'fall'
625
635
  /** Character (player and NPCs) */
626
636
  export declare class Character {
627
637
  constructor(engine: Engine, opts?: CharacterOptions);
628
- /** Root node: add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it */
638
+ /** Root node, the character's model (there is no character.model; the loaded glTF is a child of root): add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it */
629
639
  root: Object3D;
630
640
  /** Position (= root.position) */
631
641
  readonly position: Vector3;
@@ -670,6 +680,8 @@ export declare class Character {
670
680
  fall: false | { belowY: number | ((character: Character) => boolean) };
671
681
  /** Time channel the engine drives it on (see CharacterOptions.channel) */
672
682
  channel: string;
683
+ /** Collider layers it goes through (the passes option, sorted); undefined = stopped by every collider. Plain: a write counts from its next step and path */
684
+ passes: readonly string[] | undefined;
673
685
  /** The character's id, the one form engine.mod / time.local take: its world record id ('player', an NPC's record id), else the id option, else a generated one */
674
686
  readonly id: string;
675
687
  /**
@@ -727,7 +739,7 @@ export declare class Character {
727
739
  dispose(): void;
728
740
  /**
729
741
  * Request a jump (buffered for jumpBuffer s): the ground jump on the ground or in coyote time, else an air jump while maxJumps allows; air: false = ground only
730
- * @example createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
742
+ * @example addPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
731
743
  */
732
744
  jump(opts?: { air?: boolean }): this;
733
745
  /** Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z }) */
@@ -934,10 +946,10 @@ export interface CharactersApi {
934
946
  */
935
947
  findSpawn(position?: PositionLike, opts?: FindSpawnOptions): Vector3;
936
948
  /**
937
- * Create the player and set engine.player; control is required (no default feel), e.g. createPlayer({ ...presets.player.thirdPerson, spawn }). An
949
+ * Create the player and set engine.player; control is required (no default feel), e.g. addPlayer({ ...presets.player.thirdPerson, spawn }). An
938
950
  * existing player is deleted first
939
951
  */
940
- createPlayer(opts: PlayerOptions): Character;
952
+ addPlayer(opts: PlayerOptions): Character;
941
953
  /**
942
954
  * The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it
943
955
  * inside your own control function to wrap it
@@ -976,7 +988,7 @@ export interface CharactersApi {
976
988
  */
977
989
  findPathAsync(
978
990
  from: PositionLike, to: PositionLike, done: (path: NavPathPoint[] | null, status: 'ok' | 'noPath' | 'notReady') => void,
979
- opts?: { radius?: number; step?: number; maxNodes?: number }
991
+ opts?: { radius?: number; passes?: string[]; step?: number; maxNodes?: number }
980
992
  ): { remove(): void };
981
993
  /** How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps */
982
994
  pathsPerStep: number;
@@ -1005,9 +1017,9 @@ export interface CharactersOptions {
1005
1017
  }
1006
1018
  /**
1007
1019
  * Pathfinding options: step is the grid size (meters, A*), maxNodes the maximum cells searched (A*), radius the character radius (meters,
1008
- * default engine.movement.radius); for detailed see findPath
1020
+ * default engine.movement.radius), passes the collider layers the path goes through (collision.addBox { layer }); for detailed see findPath
1009
1021
  */
1010
- export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; detailed?: boolean; id?: string }
1022
+ export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; passes?: string[]; detailed?: boolean; id?: string }
1011
1023
 
1012
1024
  // ======================================================================
1013
1025
  // Interactions interactions()
@@ -1584,10 +1596,11 @@ export interface Quests {
1584
1596
  state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean; visited: string[] } | null;
1585
1597
  /** Finish the current step from code (its done() is not asked) and go on; the last step completes the quest. false when not active */
1586
1598
  advance(id: string): boolean;
1587
- /** @experimental */ isDone(id: string): boolean;
1599
+ /** Finished (done, not failed) */
1600
+ isDone(id: string): boolean;
1588
1601
  /** Started, not done and not failed */
1589
1602
  isActive(id: string): boolean;
1590
- /** Its fail condition held (start(id) begins it again) @experimental */
1603
+ /** Its fail condition held (start(id) begins it again) */
1591
1604
  isFailed(id: string): boolean;
1592
1605
  /** Check completion conditions once immediately */
1593
1606
  check(): void;
@@ -1642,6 +1655,8 @@ export interface PhotoShot {
1642
1655
  url: string; time: string; position: XZ | null;
1643
1656
  /** What was in the middle of the frame: name is the name, kind the kind (npc, entity, vegetation...), distance in meters */
1644
1657
  subject?: { name: string; kind: string; distance: number } | null;
1658
+ /** Only on a path-traced shot: samples per pixel reached, milliseconds, picture size, and the one line naming what the tracer did not draw as the game does (plus 'no post effects') @experimental */
1659
+ pathTraced?: { samples: number; ms: number; size: [number, number]; untraced: string };
1645
1660
  }
1646
1661
  export interface PhotoTakeOptions {
1647
1662
  /** Resolution multiplier, default 1.6 */
@@ -1658,6 +1673,8 @@ export interface PhotoTakeOptions {
1658
1673
  export interface PhotoOptions extends PhotoTakeOptions {
1659
1674
  /** How many photos the album keeps at most, default 50 @experimental */
1660
1675
  maxAlbum?: number;
1676
+ /** The game's import of its optional path tracer, called on the first photo.trace(): () => import('three-gpu-pathtracer/webgpu') @experimental */
1677
+ pathTracer?: (() => Promise<any>) | null;
1661
1678
  }
1662
1679
  /** engine.photo */
1663
1680
  export interface Photo {
@@ -1670,6 +1687,11 @@ export interface Photo {
1670
1687
  /** @experimental */ maxAlbum: number;
1671
1688
  /** Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged) */
1672
1689
  take(opts?: PhotoTakeOptions): PhotoShot;
1690
+ /** A path-traced photo (WebGPU backend or a WebGLRenderer; the game's photo({ pathTracer })): samples (whole, >= 1, default 128) accumulate on a snapshot while the game
1691
+ * runs, until seconds (>= 1, default 60); resolves to the shot, rejects naming why. scale defaults to 1 here. The op photo.trace starts it (r.value is this Promise) @experimental */
1692
+ trace(opts?: PhotoTakeOptions & { samples?: number; seconds?: number }): Promise<PhotoShot>;
1693
+ /** While a path-traced photo accumulates: samples per pixel so far and the target; null otherwise @experimental */
1694
+ tracing: { samples: number; of: number } | null;
1673
1695
  /** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() @experimental */
1674
1696
  subject(): { name: string; kind: string; distance: number } | null;
1675
1697
  }
@@ -1731,6 +1753,8 @@ export interface FocusHandle extends Handle {
1731
1753
  index: number | null;
1732
1754
  /** The choice cursor used confirm on this entry this frame (the owner's own confirm handling skips this frame) */
1733
1755
  readonly consumed: boolean;
1756
+ /** This entry is the top of the focus stack (a window over it makes it false: its owner must not read confirm / choice keys then) */
1757
+ readonly onTop: boolean;
1734
1758
  /** Change the cursor's controls while pushed (the index starts over); null = no cursor */
1735
1759
  setNav(nav: FocusNav | null): void;
1736
1760
  }
@@ -1836,17 +1860,22 @@ export interface Stack {
1836
1860
  export interface Stacks {
1837
1861
  /**
1838
1862
  * Define your own point: kind 'number' (default, base 1), 'value' (any data, set only), 'any' (true while held), 'top' (latest holder wins),
1839
- * 'one' (exclusive slot); per: true = one value per record id; manual = the takeover call the conflict error offers
1863
+ * 'one' (exclusive slot); per: true = one value per record id; manual = the takeover call the conflict error offers;
1864
+ * important: true = always on the "Values being changed now" line (changed()), even at its base
1840
1865
  */
1841
- define(name: string, opts?: { kind?: 'number' | 'value' | 'any' | 'top' | 'one'; base?: any; min?: number; max?: number; per?: boolean | 'optional'; save?: boolean; manual?: string }): Stack;
1866
+ define(name: string, opts?: { kind?: 'number' | 'value' | 'any' | 'top' | 'one'; base?: any; min?: number; max?: number; per?: boolean | 'optional'; save?: boolean; manual?: string; important?: boolean }): Stack;
1842
1867
  get(name: string): Stack;
1843
1868
  has(name: string): boolean;
1844
1869
  list(): string[];
1845
- mod(name: string, opts: ModOptions): ModHandle;
1846
1870
  /** describe().shared: one row per point with entries */
1847
1871
  describe(): Record<string, SharedRow>;
1848
1872
  /** Everything one owner changes now, e.g. ['time.world (mul 0.8, effect)', 'inventory (holds)'] */
1849
1873
  of(owner: string): string[];
1874
+ /**
1875
+ * The values being changed now, furthest from base first, at most max (default 5): points off their base, capped by a setting, or defined with
1876
+ * { important: true }. describeText's "Values being changed now" line and the dev panel read this.
1877
+ */
1878
+ changed(max?: number): { name: string; base: any; now: any; how: string; text: string }[];
1850
1879
  }
1851
1880
  /** engine.time: time channels (world, player, your own). Speeds change only through engine.mod('time.<channel>', ...) */
1852
1881
  export interface Time {
@@ -1873,7 +1902,7 @@ export interface Vars {
1873
1902
  counters: Record<string, number>;
1874
1903
  /** Read a flag */
1875
1904
  flag(key: string): any;
1876
- /** Set a flag (default true) @experimental */
1905
+ /** Set a flag (default true) */
1877
1906
  setFlag(key: string, value?: any): void;
1878
1907
  /** Read a counter (0 if none) */
1879
1908
  counter(key: string): number;
@@ -2142,8 +2171,8 @@ export interface Hud {
2142
2171
  markers: HudMarker[];
2143
2172
  /** Add an objective marker: target is an object, position or place name */
2144
2173
  marker(target: HudTarget, opts?: HudMarkerOptions): HudMarker;
2145
- /** Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone, no label = the value alone (the id is not shown) */
2146
- counter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): void;
2174
+ /** Counter or text status, returns { set(value), remove() } (calling again with the same id = update; calling every frame is fine): addCounter('fish', { label: '鱼', value: 2, max: 5 }), addCounter('clock', { value: '08:30' }); no value = the label alone, no label = the value alone (the id is not shown) */
2175
+ addCounter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): { id: string; set(value: number | string | { label?: string; icon?: string; value?: number | string; max?: number }): void; remove(): void };
2147
2176
  /** Add n (default 1) to a number counter, return the new value; one not declared yet starts at 0 with its id as the label */
2148
2177
  bump(id: string, n?: number): number;
2149
2178
  /** Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up */
@@ -2151,7 +2180,11 @@ export interface Hud {
2151
2180
  /** Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged),
2152
2181
  * value/max 0–max */
2153
2182
  bar(id: string, opts: { value: number; max?: number; label?: string; anchor?: HudAnchor }): void;
2154
- /** Delete a counter or progress bar */
2183
+ /** Clickable button (calling again with the same id = update): label is text or an i18n key, run() is called on a click / tap. The press never reaches the game and focus goes back to it; a locked mouse has no cursor, so free it first (Esc) */
2184
+ button(id: string, opts: { label: string; run: () => void; icon?: string; anchor?: HudAnchor; action?: string }): void;
2185
+ /** Key hint "E · Talk" (same id = update): the key text is engine.input.label(action) (the input.noKey text when the action needs a key and has none, as in the prompt), so it follows rebinding and keyboard / pad switching; label is text or an i18n key. A button with `action` shows its key too @experimental */
2186
+ hint(id: string, opts: { action: string; label?: string; anchor?: HudAnchor }): void;
2187
+ /** Delete a counter, progress bar, button or key hint */
2155
2188
  remove(id: string): void;
2156
2189
  }
2157
2190
  /**
@@ -45,6 +45,23 @@ export class Audio {
45
45
  * @example engine.audio.setVolume('music', 0.3);
46
46
  */
47
47
  setVolume(bus: string, v: number): void;
48
+ /**
49
+ * The one reverb: a send/return any bus can feed (a cave, a hall, a bathroom). Off until called: nothing is built or heard before. Each call
50
+ * changes only the keys given (sends merge per bus; 0 stops one); null turns it off. The echo of a bus follows its slider and its ducks, and
51
+ * comes back through master. The impulse is generated (decaying noise, no file): changing size or decay rebuilds it, wet and sends only fade.
52
+ * Called before the first click it waits for audio to unlock. Places: an ambience rule { reverb: 0.6, when: { zone: 'cave' } } sets wet while it holds (recipes/31 §9)
53
+ * @param {{ wet?: number, decay?: number, size?: number, sends?: Record<string, number>, fade?: number } | null} opts wet 0-1 (0.3), decay seconds to -60 dB (2), size 0-1 (0.5), fade seconds
54
+ * @returns {void}
55
+ * @example engine.audio.reverb({ sends: { sfx: 0.5, ambience: 0.8 }, decay: 3, size: 0.8, wet: 0.4 });
56
+ * @experimental
57
+ */
58
+ reverb(opts: {
59
+ wet?: number;
60
+ decay?: number;
61
+ size?: number;
62
+ sends?: Record<string, number>;
63
+ fade?: number;
64
+ } | null): void;
48
65
  /**
49
66
  * Lower buses until the handle is removed (dialogue, pause menu, a cutscene). Several ducks stack (their levels multiply).
50
67
  * @param {Record<string, number>} levels bus -> multiplier 0-1
@@ -128,7 +145,8 @@ export class Audio {
128
145
  /**
129
146
  * What is playing (describe().audio shows it while something is ducked or playing): bus levels, the duck multiplier per bus, live voices per sound name.
130
147
  * ducks is the level the active ducks ask for (1 = not lowered), read at once even while a fade is still ramping or the audio clock does not run (headless page).
131
- * @returns {{ running: boolean, state: string | null, levels: Record<string, number>, ducks: Record<string, number>, voices: Record<string, number> }}
148
+ * reverb (only once reverb() was called): its targets, `place` while an ambience rule sets wet, `built` once audio unlocked.
149
+ * @returns {{ running: boolean, state: string | null, levels: Record<string, number>, ducks: Record<string, number>, voices: Record<string, number>, reverb?: { wet: number, decay: number, size: number, sends: Record<string, number>, place?: number, built: boolean } }}
132
150
  * @example engine.audio.duck({ music: 0.3 }); engine.audio.info.ducks.music // 0.3
133
151
  */
134
152
  get info(): {
@@ -137,6 +155,14 @@ export class Audio {
137
155
  levels: Record<string, number>;
138
156
  ducks: Record<string, number>;
139
157
  voices: Record<string, number>;
158
+ reverb?: {
159
+ wet: number;
160
+ decay: number;
161
+ size: number;
162
+ sends: Record<string, number>;
163
+ place?: number;
164
+ built: boolean;
165
+ };
140
166
  };
141
167
  /**
142
168
  * Synth building block: a burst of filtered noise (footsteps, shutter, rain, thunder). dur seconds, freq Hz, vol 0-1; out: the node to
@@ -17,7 +17,7 @@ export class Random {
17
17
  next(): number;
18
18
  /** A decimal between a and b @param {number} a @param {number} b @returns {number} */
19
19
  range(a: number, b: number): number;
20
- /** An integer between a and b (inclusive) @param {number} a @param {number} b @returns {number} @example const dice = engine.random.int(1, 6); @experimental */
20
+ /** An integer between a and b (inclusive) @param {number} a @param {number} b @returns {number} @example const dice = engine.random.int(1, 6); */
21
21
  int(a: number, b: number): number;
22
22
  /**
23
23
  * Pick one element of the array at random (undefined for an empty array).
@@ -29,7 +29,7 @@ export class Input {
29
29
  /** Is this a touch device? @experimental */
30
30
  touch: boolean;
31
31
  /**
32
- * Declare an action: its context and display name, never its keys (the game binds those). Modules call ctx.input.action (owned by the module,
32
+ * Declare an action: its context and display name, never its keys (the game binds those). Modules call ctx.input.define (owned by the module,
33
33
  * removed with it); a game's own action can pass keys to declare and bind in one line.
34
34
  * context: the input context it is read in (default 'walk'); readable only while that context is on the stack and not shadowed, see push().
35
35
  * optional: true = the module works without it (number keys for dialogue choices), so reading it unbound is silent.
@@ -37,10 +37,10 @@ export class Input {
37
37
  * @param {string} name
38
38
  * @param {{ context?: string, label?: string, optional?: boolean, keys?: string | string[], owner?: string }} [o]
39
39
  * @returns {{ name: string, remove(): void }} remove() takes the declaration (and keys given here) away
40
- * @example ctx.input.action('choice1', { context: 'dialog', label: 'dialogue.choice', optional: true }); // in a module: no keys
41
- * @example engine.input.action('brake', { context: 'vehicle', keys: ['KeyB', 'PadLT'] }); // a game's own action, bound at once
40
+ * @example ctx.input.define('choice1', { context: 'dialog', label: 'dialogue.choice', optional: true }); // in a module: no keys
41
+ * @example engine.input.define('brake', { context: 'vehicle', keys: ['KeyB', 'PadLT'] }); // a game's own action, bound at once
42
42
  */
43
- action(name: string, o?: {
43
+ define(name: string, o?: {
44
44
  context?: string;
45
45
  label?: string;
46
46
  optional?: boolean;
@@ -84,7 +84,7 @@ export class Input {
84
84
  */
85
85
  simulate(action: string, down?: boolean): void;
86
86
  /**
87
- * A local player's share of the input on a shared screen: its own keys and gamepad, read like engine.input (axis, down, pressed, released). Pass it to createPlayer({ id, input }).
87
+ * A local player's share of the input on a shared screen: its own keys and gamepad, read like engine.input (axis, down, pressed, released). Pass it to addPlayer({ id, input }).
88
88
  * pad: gamepad index; that pad leaves engine.input and answers the game's pad bindings here. keys: { action: keys } for this seat alone. Two seats on one pad or key throw `input-seat`.
89
89
  * @example const two = engine.input.seat({ pad: 1, keys: { moveForward: 'KeyI', moveBack: 'KeyK', moveLeft: 'KeyJ', moveRight: 'KeyL', jump: 'KeyU' } });
90
90
  * @param {{ pad?: number, keys?: Record<string, string | string[]> }} [opts] @returns {Seat}
@@ -106,7 +106,6 @@ export class Input {
106
106
  /**
107
107
  * All keys bound to an action: the player's rebinding, else the game's bind, else the default preset (basics only); plus its touch button
108
108
  * @param {string} action @returns {readonly string[]}
109
- * @experimental
110
109
  */
111
110
  keysOf(action: string): readonly string[];
112
111
  /**
@@ -131,7 +130,6 @@ export class Input {
131
130
  /**
132
131
  * Just released (which copy is read is the same as pressed; for things like release-to-fire after charging) @param {string} action @returns {boolean}
133
132
  * @example if (engine.input.released('fire')) shoot(charge);
134
- * @experimental
135
133
  */
136
134
  released(action: string): boolean;
137
135
  /**
@@ -143,7 +141,7 @@ export class Input {
143
141
  * Push an input context (an action group, like a Unity Action Map). The top context shadows lower actions bound to the same key.
144
142
  * Opaque by default (nothing below is readable: menus, dialogue, cutscenes); { pass: true } lets unrelated lower actions keep working (vehicle, build mode).
145
143
  * Applies at the start of the next fixed step; actions it blocks lose their held state (no stuck keys after a menu closes). Join a context with
146
- * input.action(name, { context }); menu keys: pressedRaw.
144
+ * input.define(name, { context }); menu keys: pressedRaw.
147
145
  * @param {string} name e.g. 'vehicle', 'dialog', 'menu', 'cutscene', 'build' (the base context is 'walk')
148
146
  * owner (default the name) is who pushed it, listed in describe().holds.input
149
147
  * @param {{ pass?: boolean, owner?: string }} [opts]
@@ -7,7 +7,7 @@ export class Seat {
7
7
  keys?: Record<string, string | string[]>;
8
8
  });
9
9
  /** The gamepad index this seat owns, if any @type {number | undefined} */ pad: number | undefined;
10
- /** Who this seat acts for, as engine.actor for engine.input: createPlayer sets the player's id; interactions read it. Set it to hand the seat to a vehicle or a squad member @type {string | null} */ actor: string | null;
10
+ /** Who this seat acts for, as engine.actor for engine.input: addPlayer sets the player's id; interactions read it. Set it to hand the seat to a vehicle or a squad member @type {string | null} */ actor: string | null;
11
11
  /** Same list as engine.input.actions: actions are the game's, a seat only routes them */
12
12
  get actions(): any;
13
13
  /** Held, as engine.input.down @param {string} action @returns {boolean} */
@@ -7,6 +7,10 @@ export class Budget {
7
7
  limits: BudgetLimits;
8
8
  /** Cost of applying background results, split in stages (see ApplyCost) */
9
9
  cost: ApplyCost;
10
+ /** The recorded run to compare against: { [where]: { drawCalls, triangles, cpuMs?, modules: { name: ms } } } as record() makes it. threedog shot / verify
11
+ * load the game's .threedog/perf-baseline.json (this machine's) here when the game set none (and write it with --save-baseline). null = no comparison
12
+ * @type {Record<string, any> | null} */
13
+ baseline: Record<string, any> | null;
10
14
  /**
11
15
  * Turn on and set limits (only categories given are checked)
12
16
  * @param {BudgetLimits} [limits]
@@ -53,6 +57,28 @@ export class Budget {
53
57
  }[];
54
58
  /** Current value per category (fps/low1/cpuMs exist only once there are frame times) @returns {Record<string, number>} */
55
59
  values(): Record<string, number>;
60
+ /**
61
+ * This run's numbers in the shape baseline keeps: { where, values: { drawCalls, triangles, cpuMs (live runs), modules: { name: median ms, 0 too } } }.
62
+ * threedog shot / verify --save-baseline write it into the game's .threedog/perf-baseline.json (this machine's, not committed)
63
+ * @returns {{ where: string, values: { drawCalls: number, triangles: number, cpuMs?: number, modules: Record<string, number> } }}
64
+ */
65
+ record(): {
66
+ where: string;
67
+ values: {
68
+ drawCalls: number;
69
+ triangles: number;
70
+ cpuMs?: number;
71
+ modules: Record<string, number>;
72
+ };
73
+ };
74
+ /**
75
+ * One line when something is off, null when all is fine: over a limit the game declared (only when the budget is on; the engine's own reference
76
+ * limits never), slower than the baseline recorded at this spot on this machine (medians, past a noise margin), a module with spikes (p95 over 3x
77
+ * its median and over 2 ms), or what adaptive quality lowered (resolution, effects). threedog shot, verify and describeText print it
78
+ * @returns {string | null}
79
+ * @example engine.budget.notice() // 'Perf: over budget drawCalls 312 (limit 250, +25%); slower than baseline: modules.terrain 1.4 ms (was 0.6, +133%) -> threedog inspect perf'
80
+ */
81
+ notice(): string | null;
56
82
  /**
57
83
  * Estimate draw calls and triangles by userData.budgetTag (visible meshes inside the frustum; shadow casters count a second shadow draw).
58
84
  * Returns [{ tag, drawCalls, triangles }], largest first. Called only on overrun (at most once a second) or when debugging
@@ -110,6 +110,4 @@ export class DebugOverrides {
110
110
  overrides(): any[];
111
111
  /** Active overrides on one object, for engine.explain({ thing: id }) */
112
112
  overridesOn(obj: any): any[];
113
- /** Undo everything, drop / restore what the views put back, re-apply */
114
- dispose(): void;
115
113
  }
@@ -24,14 +24,14 @@ export class Saves {
24
24
  /** Resolves once the save index is in memory; await it only to list / load before start() @type {Promise<void>} */
25
25
  whenReady: Promise<void>;
26
26
  /**
27
- * Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later
27
+ * Define "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); first may be a number, lower loads earlier, true counts as 0 (zones that need the level: 1); a load returning a Promise makes later
28
28
  * parts wait.
29
29
  * version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current
30
30
  * shape.
31
31
  * A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept).
32
32
  * load(data, turn): turn is this replacement's identity. Pass it on, level.load(x, { turn }) or content.load(x, { turn }): those wait for a running load to end, except with its turn.
33
33
  * A part registered after a save was loaded (a module installed later) is handed its data from that save: at once when idle, else right after the replacement under way.
34
- * atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback).
34
+ * atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback; load synchronous: an async function is refused here).
35
35
  * checkNewGame(data): 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
36
36
  * (world: records placed by code instead of content). The part knows its own format; core only hands the data over.
37
37
  * Returns a handle: remove() takes the part out and keeps its data as unattached data (it rides in later saves and goes back to a part registered under
@@ -40,11 +40,11 @@ export class Saves {
40
40
  * @param {SaveProvider} provider
41
41
  * @returns {{ remove(o?: { keep?: boolean }): void }}
42
42
  * @example
43
- * engine.saves.register('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
43
+ * engine.saves.define('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
44
44
  * // later the format gains beds: version 2, and a step that upgrades version-1 data
45
- * engine.saves.register('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
45
+ * engine.saves.define('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
46
46
  */
47
- register(key: string, provider: SaveProvider): {
47
+ define(key: string, provider: SaveProvider): {
48
48
  remove(o?: {
49
49
  keep?: boolean;
50
50
  }): void;
@@ -56,7 +56,7 @@ export class Saves {
56
56
  get versions(): Record<string, number>;
57
57
  /**
58
58
  * Store a binary attachment outside the world save (a photo, a replay). It rides in the queue of save writes, so flush() waits for it, and exportFile() carries it.
59
- * Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept.
59
+ * Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept: it rejects with save-write.
60
60
  * Rejects with save-stale, changing nothing, when another tab wrote this id since this tab last saw it; attachments(group) is how a tab looks.
61
61
  * @example await engine.saves.putAttachment('replay', 'run-1', blob, { score: 12 });
62
62
  * @param {string} group what the attachment is for
@@ -151,10 +151,13 @@ export class Saves {
151
151
  * game back.
152
152
  * To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot).
153
153
  * @param {string} [slot]
154
+ * @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
154
155
  * @returns {Promise<boolean>}
155
156
  * @example if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');
156
157
  */
157
- load(slot?: string): Promise<boolean>;
158
+ load(slot?: string, { turn }?: {
159
+ turn?: object;
160
+ }): Promise<boolean>;
158
161
  /** All slots, newest first (synchronous, reads the in-memory index) @returns {{ slot: string, savedAt: number }[]} */
159
162
  list(): {
160
163
  slot: string;
@@ -24,12 +24,15 @@ export class Session {
24
24
  /**
25
25
  * Start a new playthrough from the state the game had right after start(). Returns Promise<boolean> (false only if a save part failed to load: the
26
26
  * old playthrough then goes on, with its data, listeners and timers, and 'session:failed' fires instead of 'session:start').
27
+ * @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
27
28
  * @returns {Promise<boolean>}
28
29
  * @example
29
30
  * // a "Restart" button in a game-over screen
30
31
  * restartBtn.onclick = () => engine.session.newGame();
31
32
  */
32
- newGame(): Promise<boolean>;
33
+ newGame({ turn }?: {
34
+ turn?: object;
35
+ }): Promise<boolean>;
33
36
  /**
34
37
  * Continue from a save (or retry from a checkpoint) with nothing of the current playthrough left over: the new-game state with the save on top,
35
38
  * so a part the save does not have (a module added in a later version of the game) starts from its new-game state.
@@ -43,8 +46,11 @@ export class Session {
43
46
  /**
44
47
  * End the playthrough and show the title screen (the title part when the game turned it on; flow returns to its start state).
45
48
  * The state behind the title is the new-game state, so nothing from the old playthrough runs while the title is up.
49
+ * @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
46
50
  * @returns {Promise<boolean>}
47
51
  * @example settingsBackToTitle.onclick = () => engine.session.quit();
48
52
  */
49
- quit(): Promise<boolean>;
53
+ quit({ turn }?: {
54
+ turn?: object;
55
+ }): Promise<boolean>;
50
56
  }
@@ -9,7 +9,7 @@ export class Rays {
9
9
  /** The three.js Raycaster (firstHitOnly is on) @type {any} @experimental */
10
10
  ray: any;
11
11
  /**
12
- * Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }.
12
+ * Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }. Matrices are read once per tick and frame: a registered mesh moved between two rays of one step needs updateMatrixWorld() first.
13
13
  * Only visible objects are hit. Something that is merely not drawn is still hit: batched originals, far hlod originals and the full model of a far assets.lod sit on a reserved layer, with their visible true.
14
14
  * Unregisters automatically on geometry dispose or engine.remove.
15
15
  * @param {THREE.Object3D | THREE.Object3D[]} obj
@@ -20,8 +20,6 @@ export class Rays {
20
20
  addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: {
21
21
  occluder?: boolean;
22
22
  }): Handle;
23
- /** Unregister every mesh under the object (engine.remove calls this automatically) @param {THREE.Object3D} obj @experimental */
24
- forget(obj: THREE.Object3D): void;
25
23
  /** A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() } @param {RayProvider} fn @returns {Handle} @experimental */
26
24
  addProvider(fn: RayProvider): Handle;
27
25
  }
@@ -32,7 +32,7 @@ export class Particles {
32
32
  */
33
33
  has(name: string): boolean;
34
34
  /**
35
- * Burst: emit count particles at once (default 10) at position (Vector3 / Object3D / [x, y, z] / {x, y, z}). overrides affect this batch only (color, speed, direction...; max/texture/blending/soft cannot be changed temporarily)
35
+ * Burst: emit count particles at once (default 10) at position (Vector3 / Object3D / [x, y, z] / {x, y, z}). overrides affect this batch only (color, speed, direction...; max/texture/blending/soft/lit cannot be changed temporarily)
36
36
  * @param {string} name
37
37
  * @param {PositionLike} position
38
38
  * @param {{ count?: number, overrides?: ParticleOptions | null }} [opts]
@@ -153,7 +153,8 @@ export class World {
153
153
  * Register how a kind of thing looks: models are built automatically within radius meters of any full-detail stream source (engine.stream: player, camera
154
154
  * focus, teleport destination) and torn down when far from all of them (radius × 1.25); tearing down never touches the record. Callbacks:
155
155
  * build(rec) → three.js object (may be async). world adds it to the scene and places it at rec.position; if it throws / fails / returns a non-object:
156
- * reported once, does not block ready, retried when you leave and come back.
156
+ * reported once, does not block ready, retried when you leave and come back. Only the position is world's: rec.rot / rec.scale are the build's to apply
157
+ * (rotate the root or a child, in its own units) and update's to follow.
157
158
  * update(rec, obj, dt): called every frame for records that have a model (change the picture from the data, e.g. an opened chest swaps texture).
158
159
  * dispose(rec, obj): called on teardown (record first, model second); if omitted, engine.remove(obj).
159
160
  * show(rec) → false: this record has no model right now (picked up, waiting to respawn); re-evaluated when world.set changes records of this kind.