threedog 2.2.0 → 2.3.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 (197) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +4 -4
  3. package/core/assets/Animator.js +66 -12
  4. package/core/assets/ik.js +144 -18
  5. package/core/assets/maskLayer.js +377 -0
  6. package/core/assets/rootMotion.js +148 -0
  7. package/core/audio/Audio.js +100 -4
  8. package/core/base/errorCodes.js +6 -369
  9. package/core/base/errorCodesModules.js +378 -0
  10. package/core/engine/Engine.js +8 -5
  11. package/core/engine/Loading.js +8 -4
  12. package/core/engine/copies.js +1 -1
  13. package/core/engine/headlessLoad.js +15 -4
  14. package/core/engine/lifecycle.js +1 -0
  15. package/core/engine/loop.js +23 -3
  16. package/core/engine/moduleSlots.js +3 -7
  17. package/core/engine/modules.js +30 -58
  18. package/core/engine/startup.js +3 -3
  19. package/core/input/Input.js +7 -3
  20. package/core/input/inputContext.js +3 -2
  21. package/core/input/inputSeat.js +1 -1
  22. package/core/inspect/DebugOverrides.js +1 -1
  23. package/core/inspect/Describe.js +7 -2
  24. package/core/inspect/describeRender.js +4 -1
  25. package/core/inspect/describeText.js +2 -2
  26. package/core/inspect/metadata.generated.js +380 -74
  27. package/core/inspect/pictureMenu.js +2 -0
  28. package/core/inspect/pictureWriters.js +4 -3
  29. package/core/ops/Ops.js +9 -3
  30. package/core/ops/actor.js +10 -0
  31. package/core/ops/control.js +17 -6
  32. package/core/ops/holds.js +1 -1
  33. package/core/ops/opsAtomic.js +6 -1
  34. package/core/ops/opsGuard.js +2 -2
  35. package/core/ops/owned.js +37 -11
  36. package/core/ops/sharedPoint.js +5 -1
  37. package/core/ops/stacks.js +30 -7
  38. package/core/saves/Saves.js +0 -2
  39. package/core/saves/saveApply.js +7 -7
  40. package/core/saves/session.js +6 -3
  41. package/core/saves/stateReplace.js +71 -41
  42. package/core/scene/Rays.js +74 -26
  43. package/core/scene/canvasBox.js +9 -0
  44. package/core/scene/gameLights.js +19 -11
  45. package/core/scene/sceneDelta.js +8 -4
  46. package/core/scene/sceneMethods.js +2 -1
  47. package/core/stream/chunkStream.js +21 -0
  48. package/core/stream/dirtyWatch.js +37 -0
  49. package/core/time/skip.js +9 -6
  50. package/core/time/time.js +72 -18
  51. package/docs/AI.md +22 -21
  52. package/docs/API.md +5 -4
  53. package/docs/CODEMAP.md +16 -10
  54. package/docs/COMMANDS.md +5 -5
  55. package/docs/CONVENTIONS.md +9 -25
  56. package/docs/api/ambience.md +1 -0
  57. package/docs/api/assets.md +10 -3
  58. package/docs/api/audio.md +5 -3
  59. package/docs/api/decals.md +16 -0
  60. package/docs/api/engine.md +1 -0
  61. package/docs/api/tools.md +3 -1
  62. package/docs/api/water.md +3 -0
  63. package/docs/recipes/09-materials-lights-models.md +15 -1
  64. package/docs/recipes/13-animation.md +51 -10
  65. package/docs/recipes/16-dev-bridge.md +4 -4
  66. package/docs/recipes/31-audio.md +15 -9
  67. package/docs/recipes/34-environment-lighting.md +11 -1
  68. package/docs/recipes/44-water-weather-hooks.md +1 -0
  69. package/examples/action/.threedog/content-index.json +1 -0
  70. package/examples/perf-island/.threedog/content-index.json +1 -0
  71. package/examples/plain-picture/.threedog/content-index.json +1 -0
  72. package/examples/rc2d/.threedog/content-index.json +1 -0
  73. package/examples/styletest/.threedog/content-index.json +1 -0
  74. package/examples/techniques/outlines-and-rim/main.js +1 -1
  75. package/examples/techniques/procedural-surface/main.js +1 -1
  76. package/examples/techniques/stylized-shading/main.js +1 -1
  77. package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
  78. package/examples/world/.threedog/content-index.json +1 -0
  79. package/index.d.ts +6 -2
  80. package/index.js +3 -2
  81. package/llms.txt +11 -10
  82. package/modules/ambience/Ambience.js +97 -15
  83. package/modules/camera/common.js +18 -12
  84. package/modules/characters/Character.js +30 -3
  85. package/modules/characters/NPC.js +2 -5
  86. package/modules/characters/astar.js +45 -14
  87. package/modules/characters/movers/rapier.js +53 -41
  88. package/modules/characters/movers/simple.js +37 -24
  89. package/modules/characters/npcView.js +2 -2
  90. package/modules/characters/pathAsync.js +3 -3
  91. package/modules/collision/contract.js +2 -2
  92. package/modules/content/index.js +3 -0
  93. package/modules/content/models.js +11 -4
  94. package/modules/content/templates.js +11 -11
  95. package/modules/debug/DebugPanel.js +1 -0
  96. package/modules/decals/Decals.js +393 -0
  97. package/modules/decals/index.js +1 -0
  98. package/modules/gameplay/Container.js +2 -0
  99. package/modules/gameplay/Containers.js +17 -3
  100. package/modules/gameplay/Dialogue.js +1 -1
  101. package/modules/gameplay/Interactions.js +7 -6
  102. package/modules/gameplay/Inventory.js +5 -1
  103. package/modules/gameplay/Quests.js +4 -3
  104. package/modules/gameplay/inventoryOps.js +2 -2
  105. package/modules/gameplay/pickups.js +32 -12
  106. package/modules/gameplay/questSave.js +2 -2
  107. package/modules/grid/index.js +8 -2
  108. package/modules/hud/index.js +1 -1
  109. package/modules/level/heightfield.js +1 -0
  110. package/modules/level/index.js +3 -2
  111. package/modules/level/nodes.js +2 -1
  112. package/modules/lights/index.js +27 -4
  113. package/modules/lights/slots.js +33 -16
  114. package/modules/nav/contract.js +4 -4
  115. package/modules/nav/index.js +6 -2
  116. package/modules/net/Client.js +24 -11
  117. package/modules/net/Host.js +73 -20
  118. package/modules/net/index.js +33 -21
  119. package/modules/net/sync.js +38 -8
  120. package/modules/net/transports.js +7 -3
  121. package/modules/particles/Particles.js +11 -4
  122. package/modules/particles/contract.js +6 -6
  123. package/modules/particles/effect.js +0 -1
  124. package/modules/rigid/RigidBodies.js +69 -57
  125. package/modules/rigid/Vehicles.js +8 -7
  126. package/modules/rigid/ragdoll.js +4 -6
  127. package/modules/rigid/rapierCompat.js +90 -0
  128. package/modules/rigid/sync.js +2 -5
  129. package/modules/settings/Settings.js +10 -4
  130. package/modules/sky/Sky.js +10 -2
  131. package/modules/sky/environment.js +29 -13
  132. package/modules/sky/frame.js +2 -2
  133. package/modules/sky/shader.js +5 -2
  134. package/modules/sky/skyModule.js +2 -2
  135. package/modules/swarm/Swarm.js +3 -2
  136. package/modules/swarm/grid.js +12 -7
  137. package/modules/terrain/ChunkManager.js +16 -26
  138. package/modules/triggers/index.js +5 -6
  139. package/modules/vegetation/draw.js +62 -26
  140. package/modules/vegetation/groundChunks.js +8 -22
  141. package/modules/water/Water.js +152 -24
  142. package/modules/water/surface.js +43 -20
  143. package/modules/weather/weatherDraw.js +4 -1
  144. package/modules/world/World.js +21 -2
  145. package/modules/world/index.js +5 -0
  146. package/modules/world/persist.js +1 -0
  147. package/modules/world/records.js +3 -1
  148. package/modules/world/sim.js +3 -2
  149. package/modules/world/simFar.js +4 -2
  150. package/modules/world/state.js +7 -1
  151. package/package.json +2 -2
  152. package/presets.js +30 -0
  153. package/render/PostFX.js +24 -17
  154. package/render/backend.js +72 -31
  155. package/render/cascades.js +25 -14
  156. package/render/cascades.tsl.js +32 -21
  157. package/render/fogLook.js +2 -1
  158. package/render/fx/detail.tsl.js +3 -0
  159. package/render/fx/library.tsl.js +1 -1
  160. package/render/fx/particles.tsl.js +4 -18
  161. package/render/fx/pcss.tsl.js +2 -2
  162. package/render/fx/postWebGPU.tsl.js +47 -25
  163. package/render/fx/sky.tsl.js +6 -18
  164. package/render/fx/uniforms.tsl.js +16 -0
  165. package/render/fx/water.tsl.js +24 -5
  166. package/render/fxNumbers.js +2 -0
  167. package/render/impostor.tsl.js +10 -6
  168. package/render/lights.js +6 -6
  169. package/render/occlusion.js +17 -6
  170. package/render/patches.js +40 -28
  171. package/render/postWebGL.js +6 -4
  172. package/render/reflectionProbes.js +302 -0
  173. package/render/shaderErrors.js +18 -8
  174. package/render/shadowCache.tsl.js +10 -5
  175. package/render/shadows.js +70 -49
  176. package/render/threeCompat.js +166 -0
  177. package/types/core.d.ts +33 -3
  178. package/types/gameplay.d.ts +80 -0
  179. package/types/generated/core/audio/Audio.d.ts +18 -1
  180. package/types/generated/core/ops/Ops.d.ts +2 -1
  181. package/types/generated/core/ops/control.d.ts +7 -3
  182. package/types/generated/core/saves/session.d.ts +4 -1
  183. package/types/generated/modules/ambience/Ambience.d.ts +6 -0
  184. package/types/generated/modules/debug/DebugPanel.d.ts +1 -0
  185. package/types/generated/modules/grid/index.d.ts +27 -3
  186. package/types/generated/modules/net/index.d.ts +8 -3
  187. package/types/generated/modules/sky/Sky.d.ts +1 -0
  188. package/types/generated/modules/water/Water.d.ts +15 -0
  189. package/types/generated/modules/world/index.d.ts +5 -0
  190. package/types/generated/render/patches.d.ts +5 -0
  191. package/types/physics.d.ts +66 -9
  192. package/types/tsl.d.ts +2 -0
  193. package/types/world.d.ts +2 -0
  194. package/ui/Parts.js +3 -2
  195. package/docs/MIGRATING-0.7.md +0 -39
  196. package/docs/MIGRATING-0.8.md +0 -171
  197. package/modules/rigid/refresh.js +0 -10
package/core/time/time.js CHANGED
@@ -32,7 +32,12 @@ export class Time {
32
32
  /** @internal ambient seconds (public: now('ambient'), uniforms.uTime) */ this._amb = 0;
33
33
  /** @type {Map<string, { name: string, parent: string | null, now: number, stack: string }>} */
34
34
  this._ch = new Map();
35
- /** @internal listeners of onMove */ this._onMove = [];
35
+ /** @internal cached channel list for zero-GC stepping */ this._chList = [];
36
+ /** @internal reusable scale buffer for _move() */ this._scales = new Float64Array(8);
37
+ /** @internal cached fire order for _runTimers() */ this._order = null;
38
+ /** @internal reusable due timer scratch array */ this._due = [];
39
+ /** @internal re-entrancy guard for this._due */ this._dueBusy = false;
40
+ /** @internal listeners of onMove (copy-on-write on add/remove) */ this._onMove = [];
36
41
  /** @internal the one timer queue: { ch, due, fn?, event?, data?, every?, dead? } (due is in that channel's seconds) */ this._timers = [];
37
42
  /** @internal saved now of channels the game has not defined yet (a load before channel()): applied when it does */ this._pending = {};
38
43
  this._local = engine.stacks.define('time.local', { per: true, min: 0 });
@@ -86,7 +91,11 @@ export class Time {
86
91
  if (parent != null && !this._ch.has(parent)) throw codedError('unknown-name', `engine.time.channel('${name}', { parent: '${parent}' }): no channel '${parent}'. Channels: ${this.channels().join(', ')}`);
87
92
  const saved = this._pending[name]; delete this._pending[name];
88
93
  // put now in place before defining the speed stack: entries in the stack saved against this channel's clock restore the remaining time from its now
89
- this._ch.set(name, { name, parent, now: saved ?? 0, stack });
94
+ const ch = { name, parent, now: saved ?? 0, stack };
95
+ this._ch.set(name, ch);
96
+ this._chList.push(ch);
97
+ if (this._chList.length > this._scales.length) this._scales = new Float64Array(this._chList.length * 2);
98
+ this._order = null;
90
99
  this.engine.stacks.define(stack, { min: 0 });
91
100
  return this;
92
101
  }
@@ -98,8 +107,8 @@ export class Time {
98
107
  * @example ctx.track(engine.time.onMove(() => { if (engine.clock.now > nextTide) tide.turn(); }))
99
108
  */
100
109
  onMove(fn) {
101
- this._onMove.push(fn);
102
- return { remove: () => { const i = this._onMove.indexOf(fn); if (i >= 0) this._onMove.splice(i, 1); } };
110
+ this._onMove = [...this._onMove, fn];
111
+ return { remove: () => { const i = this._onMove.indexOf(fn); if (i >= 0) { const next = this._onMove.slice(); next.splice(i, 1); this._onMove = next; } } };
103
112
  }
104
113
  /** Channel names */
105
114
  channels() { return [...this._ch.keys()]; }
@@ -147,20 +156,56 @@ export class Time {
147
156
  /** Timers in the queue (engine.counts) */
148
157
  get size() { return this._timers.length; }
149
158
  /** @internal timers fire per view in this order: real, the channels as defined, the calendar last (calendar timers see this step's channel results) */
150
- _fireOrder() { const names = this.channels().filter(n => n !== 'calendar'); return ['real', ...names, 'calendar']; }
159
+ _fireOrder() {
160
+ if (!this._order) {
161
+ const out = ['real'];
162
+ for (let i = 0; i < this._chList.length; i++) { const n = this._chList[i].name; if (n !== 'calendar') out.push(n); }
163
+ out.push('calendar');
164
+ this._order = out;
165
+ }
166
+ return this._order;
167
+ }
151
168
  /** @internal */
152
169
  _runTimers() {
153
- if (!this._timers.length) return;
154
- for (const ch of this._fireOrder()) {
155
- const at = this.now(ch) + EPS;
156
- const due = this._timers.filter(t => t.ch === ch && t.due <= at).sort((a, b) => a.due - b.due);
157
- if (!due.length) continue;
158
- this._timers = this._timers.filter(t => !(t.ch === ch && t.due <= at) || t.every);
159
- for (const t of due) {
160
- if (this.engine.disposed) return; // a callback of this list disposed the engine: dispose cannot reach the ones already taken out of the queue
161
- if (t.every) { while (!t.dead && t.due <= at) { t.due += t.every; this._call(t); } continue; }
162
- if (!t.dead) { t.dead = true; this._call(t); }
170
+ const timers = this._timers, len = timers.length;
171
+ if (!len) return;
172
+ // Fast scalar scan: skip with 0 allocations when no timer is due
173
+ let anyDue = false;
174
+ for (let i = 0; i < len; i++) {
175
+ const t = timers[i];
176
+ if (t.dead || (t.ch !== 'real' && !this._ch.has(t.ch))) continue;
177
+ if (t.due <= this.now(t.ch) + EPS) { anyDue = true; break; }
178
+ }
179
+ if (!anyDue) return;
180
+ const order = this._fireOrder();
181
+ const due = this._dueBusy ? [] : this._due;
182
+ if (due === this._due) this._dueBusy = true;
183
+ try {
184
+ for (let oi = 0; oi < order.length; oi++) {
185
+ const ch = order[oi], at = this.now(ch) + EPS, cur = this._timers;
186
+ due.length = 0;
187
+ let w = 0;
188
+ for (let i = 0; i < cur.length; i++) {
189
+ const t = cur[i];
190
+ if (t.dead) continue;
191
+ if (t.ch === ch && t.due <= at) {
192
+ due.push(t);
193
+ if (t.every) cur[w++] = t;
194
+ } else cur[w++] = t;
195
+ }
196
+ cur.length = w;
197
+ if (!due.length) continue;
198
+ if (due.length > 1) due.sort((a, b) => a.due - b.due);
199
+ for (let i = 0; i < due.length; i++) {
200
+ if (this.engine.disposed) return; // a callback of this list disposed the engine: dispose cannot reach the ones already taken out of the queue
201
+ const t = due[i];
202
+ if (t.every) { while (!t.dead && t.due <= at) { t.due += t.every; this._call(t); } continue; }
203
+ if (!t.dead) { t.dead = true; this._call(t); }
204
+ }
163
205
  }
206
+ } finally {
207
+ due.length = 0;
208
+ if (due === this._due) this._dueBusy = false;
164
209
  }
165
210
  }
166
211
  /** @internal a callback that throws is a gameplay error; the other timers still run */
@@ -214,10 +259,19 @@ export class Time {
214
259
  * (earliest first, mod:end each), then timers fire.
215
260
  */
216
261
  _move(fixed, calendar) {
217
- const scales = [...this._ch.values()].map(c => [c, this.scale(c.name)]);
262
+ const list = this._chList, scales = this._scales, n = list.length;
263
+ for (let i = 0; i < n; i++) scales[i] = this.scale(list[i].name);
218
264
  this._setAmbient(this._amb + fixed);
219
- for (const [c, s] of scales) c.now += c.name === 'calendar' && calendar != null ? calendar : fixed * s;
220
- for (const fn of [...this._onMove]) { if (!this._onMove.includes(fn)) continue; /* removed earlier in this pass, or by a dispose */ try { fn(); } catch (err) { reportError(this.engine, err, STRINGS.onMove); } }
265
+ for (let i = 0; i < n; i++) {
266
+ const c = list[i];
267
+ c.now += c.name === 'calendar' && calendar != null ? calendar : fixed * scales[i];
268
+ }
269
+ const moves = this._onMove;
270
+ for (let i = 0; i < moves.length; i++) {
271
+ const fn = moves[i];
272
+ if (this._onMove !== moves && !this._onMove.includes(fn)) continue; // removed earlier in this pass, or by a dispose
273
+ try { fn(); } catch (err) { reportError(this.engine, err, STRINGS.onMove); }
274
+ }
221
275
  if (this.engine.disposed) return;
222
276
  this.engine.stacks._expire();
223
277
  this._runTimers();
package/docs/AI.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # threedog.js tasks (on demand)
2
2
 
3
- threedog.js: a web 3D game engine on plain three.js 0.187, **core** -> **modules** (`engine.use`); all art is the game's own.
4
- Paths: `node_modules/threedog/docs/`. `threedog how "<2-4 English words>"`; no words: browse.
3
+ threedog.js: web 3D engine on plain three.js 0.187, **core** -> **modules** (`engine.use`); all art is the game's.
4
+ Paths: `node_modules/threedog/docs/`. `threedog how "<task>"` (EN/ZH); no words: browse.
5
5
 
6
6
  ## Three rules
7
- 1. **Each thing has a name**: `engine.describe()` lists it; `engine.explain({ module: name })` says why.
8
- 2. **Each thing has an owner**: `add*` / `on*` return a handle, `h.remove()` undoes it (except `engine.add`, `world.add`, `addPlayer`: CONVENTIONS.md); `define` names a kind.
9
- 3. **What several sides change has one owner**; the rest use it: values `engine.mod` (add / mul / clamp by layer), services `provides` / `replaces`, control and keys: top layer; time: one clock.
7
+ 1. **Name everything**: `engine.describe()` lists it; `engine.explain({ module: name })` says why.
8
+ 2. **One owner**: `add*`/`on*` return `{ remove() }` (except `engine.add`, `world.add`, `addPlayer`: CONVENTIONS.md); `define` names a kind.
9
+ 3. **Shared state**: values `engine.mod`, services `provides`/`replaces`, control/keys: top layer; time: one clock.
10
10
  Verbs: `define`, `add`, `set`, `remove`, `describe`.
11
11
 
12
12
  ## Common mistakes
13
- - `Math.random()`, `setTimeout`, `performance.now()`, `addEventListener('keydown')` in game logic: `engine.random.next()`, `engine.clock.after`, fixed `dt`, `input.bind`.
14
- - Changing gameplay state from a frame hook or a raw callback: do it in `onFixed`, in an op, or via `engine.nextFixed(fn)`.
15
- - Saving positions or object references: save stable ids; `await` every `saves.*` call; a mesh a save must know about gets `engine.add(obj, { id })`.
16
- - Awaiting `level.load` / `content.load` in a save part's `load(data, turn)`: pass `{ turn }`, or it waits for ever.
17
- - Guessing a name: `how --read <name>`, `api/<module>.md`; errors carry `err.code` / `fix` / `docs`.
18
- - Generated docs (API.md, api/, CODEMAP): edit the source, then `npm run map`.
13
+ - Never `Math.random()`, `setTimeout`, `performance.now()`, `addEventListener('keydown')` in logic: use `engine.random.next()`, `engine.clock.after`, fixed `dt`, `input.bind`.
14
+ - Gameplay state changes only in `onFixed`, ops, or `engine.nextFixed(fn)`.
15
+ - Save stable ids (never positions/refs); `await` every `saves.*`; saved meshes need `engine.add(obj, { id })`.
16
+ - `level.load`/`content.load` inside save `load(data, turn)`: pass `{ turn }`.
17
+ - Never guess API names: `how --read <name>`, `api/<module>.md`; errors carry `err.code`/`fix`/`docs`.
18
+ - Generated docs (API.md, api/, CODEMAP): edit source, then `npm run map`.
19
19
 
20
20
  ## Reading order
21
21
  A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`, `THREE.md`, `COMMANDS.md`.
@@ -41,19 +41,20 @@ A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`,
41
41
  | Picture, writers; try a value | `describe().picture`, `explain({ value })`, `debug.watch`, `debug.override` | 52-around-the-picture.md §"Who writes it", 62-picture-code.md §3c |
42
42
  | Materials, textures, a module's picture | `engine.water.material` | 09-materials-lights-models.md §1 |
43
43
  | Own material or shader (toon, cel shading) | TSL (WebGPU), `ShaderMaterial` (WebGL), `rampTexture`, `celLighting` | 43-shader-patches-surfaces.md §"Your own material", 56-webgpu-tsl.md §"A minimal TSL material" |
44
- | WebGPU (new games' default), TSL node materials, WebGL fallback | `renderer: 'webgpu'`, `import 'threedog/tsl'` | 56-webgpu-tsl.md §"WebGPU or WebGL" |
45
- | three.js idioms, own renderer | the idiom table in `THREE.md`, `createEngine({ renderer })` | 50-own-renderer.md |
44
+ | WebGPU, TSL node materials, WebGL fallback | `renderer: 'webgpu'`, `import 'threedog/tsl'` | 56-webgpu-tsl.md §"WebGPU or WebGL" |
45
+ | three.js idioms, own renderer | `THREE.md`, `createEngine({ renderer })` | 50-own-renderer.md |
46
46
  | Dust, smoke (`lit: true`) | `engine.particles` | 64-particles.md |
47
+ | Bullet holes, footprints, ground rings (decals) | `engine.decals` | 09-materials-lights-models.md §"Surface decals" |
47
48
  | Sky, season tints, weather, wet roads | `engine.sky`, `engine.weather`, `engine.weatherDraw` | 08-weather-sky.md §1 |
48
49
  | Water, rain, snow cover (own rain: `THREE.md`) | `engine.water`, `weather({ rain, snow })` | 44-water-weather-hooks.md |
49
50
  | Shadows: blur, follow, cost | `engine.shadows` | 45-cascaded-shadows.md |
50
51
  | Own far, fov; clouds | `engine.autoView`, `engine.shaderTerms` | 52-around-the-picture.md §"Atmosphere" |
51
- | Environment light, reflections, probes, lightmaps, GI, culling, shafts | `engine.sky.environment`, `engine.bakeProbes`, `engine.loadLightmap`, `engine.occlusion`, `lightShaft` | 34-environment-lighting.md §"Environment maps" |
52
+ | Environment light, reflections, probes, lightmaps, GI, culling, shafts | `engine.sky.environment`, `engine.bakeProbes`, `engine.addReflectionProbe`, `engine.loadLightmap`, `engine.occlusion`, `lightShaft` | 34-environment-lighting.md §"Environment maps" |
52
53
  | Post passes: color grading, bloom, outline, depth, AO | `engine.post.add(pass)`, `@threedog/post-effects` | 52-around-the-picture.md §"Post effect chain", 59-depth-post-effects.md |
53
54
  | Many lights (torches); windows, signs at night | `engine.lightPool`, `uNight` | 09-materials-lights-models.md §1b |
54
55
  | Picture from a reference; judge | `threedog picture palette`, `threedog examples list` | 35-picture-from-reference.md §"The loop", 60-judge-the-picture.md |
55
56
  | Reuse effects, models of old games | `threedog lib` | 05-props-bake.md |
56
- | Sound, music, ambience, bus nodes | `engine.audio`, `engine.music`, `engine.ambience` | 31-audio.md |
57
+ | Sound, music, ambience, reverb, filter, bus nodes | `engine.audio`, `audio.filter`, `engine.music`, `engine.ambience` | 31-audio.md |
57
58
 
58
59
  ### Rules, state, time
59
60
  | To do | Use | Recipe |
@@ -62,8 +63,8 @@ A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`,
62
63
  | Quests, objective markers | `engine.quests`, `engine.hud.marker()` | 04-quests.md §1 |
63
64
  | What can the player do here, why not | `engine.inspect`, `engine.explain`, `engine.catalog` | 51-capability-catalog.md §1 |
64
65
  | New game / continue, scene flow, fades, pause for a menu, cutscenes | `engine.session`, `engine.flow`, `engine.freeze`, `engine.timeline` | 07-flow-scenes-pause.md §4 |
65
- | Slow or speed up time, bullet time | `engine.mod('clock.rate')` | 55-mods-time-wrap.md §"Time channels" |
66
- | Time of day, day / night, seasons | `engine.calendar` | 08-weather-sky.md §4, 06-clock-events.md |
66
+ | Slow motion, speed up time, bullet time | `engine.mod('clock.rate')` | 55-mods-time-wrap.md §"Time channels" |
67
+ | Time of day, day / night, seasons | `engine.calendar` | 08-weather-sky.md §4, 06-clock-events.md §"The time table" |
67
68
  | Multiplayer | `engine.net` | 27-net.md §1 |
68
69
 
69
70
  ### Characters, input, UI
@@ -75,7 +76,7 @@ A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`,
75
76
  | Camera: followCamera (third person), first person, fixedCamera, rts; setCamera | `engine.cameraRig`, `engine.page` | 21-camera.md §1 |
76
77
  | 2D, side-scroller, orthographic; 2D lights | `presets.player.sideScroller`; example `rc2d` | 21-camera.md §6 |
77
78
  | Pixel art | `pixelSize`, `pixelSnap` | 62-picture-code.md §4b |
78
- | Skeletal animation, IK | `engine.assets.animate`, `anim.addAim`, `.addFeet`, `engine.hlod` | 13-animation.md §3, 15-perf.md |
79
+ | Skeletal animation, IK, bone mask, blend2d, root motion | `engine.assets.animate`, `anim.addAim`, `.addFeet`, `.addLimb`, `.addLayer`, `engine.hlod` | 13-animation.md §3, 15-perf.md |
79
80
  | Pathfinding, navmesh, NPC jumps and gaps, gates | `engine.characters.findPath`, `engine.nav` | 12-navmesh.md §2 |
80
81
  | Physics, ragdoll, collision, vehicles | `engine.collision`, `engine.rigid`, `engine.collider3d` | 11-physics.md §3 |
81
82
  | Ray / mouse picking, shooting, lock-on | `engine.rays` | 19-shooting-picking.md §1 |
@@ -94,7 +95,7 @@ A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`,
94
95
  ### Project, world, content
95
96
  | To do | Use | Recipe |
96
97
  |---|---|---|
97
- | New game, project layout, preset start | `npx threedog init` (repo: `new-game`), `createEngine`, `openWorld()` | 01-new-game.md §0 |
98
+ | New game, project layout, preset start | `npx threedog init`, `createEngine`, `openWorld()` | 01-new-game.md §0 |
98
99
  | Put something in the scene | `scene.add(obj)`; saved: `engine.add(obj, { id })` | 40-scene.md §1 |
99
100
  | Reusable objects (prefabs), groups of them | `templates`, flat `props` | 30-templates.md §1 |
100
101
  | Props, many repeated objects, static batching | content `props`, `engine.batching` | 05-props-bake.md §2b |
@@ -119,13 +120,13 @@ A row or `threedog how` -> recipe -> `api/<module>.md`. Also: `CONVENTIONS.md`,
119
120
  | To do | Use | Recipe |
120
121
  |---|---|---|
121
122
  | Own ground or plant drawing, keep collision | `engine.terrain.view`, `engine.terrainDraw`, `engine.vegetationDraw` | 28-terrain.md §6 |
122
- | Worker results, far records' models, raw navmesh or physics, content sections, own mover | `ctx.commits`, `world.present`, `nav.query`, `rigid.world`, module `content`, `characters.kit` | 15-perf.md, 18-world.md, 12-navmesh.md, 11-physics.md, 14-custom-module.md, 57-control.md |
123
+ | Workers, far models, raw nav/physics, own mover | `ctx.commits`, `world.present`, `nav.query`, `rigid.world`, `characters.kit` | 15-perf.md, 18-world.md, 12-navmesh.md, 11-physics.md, 57-control.md |
123
124
 
124
125
  ### Troubleshooting and speed
125
126
  | To do | Use | Recipe |
126
127
  |---|---|---|
127
128
  | Broke; describe, explain, shot: which tool | `.threedog/errors.log`, `engine.describe`, `engine.explain` | 16-dev-bridge.md §11 |
128
- | Picture looks wrong: judge it | `threedog shot` (points in `shots.json`; `threedog hub` re-shoots them) | 60-judge-the-picture.md §"How to judge" |
129
+ | Picture looks wrong: judge it | `threedog shot` (`shots.json`, `threedog hub`) | 60-judge-the-picture.md §"How to judge" |
129
130
  | Drive and check the live game | the dev bridge (`verify <scenario>`) | 16-dev-bridge.md §1 |
130
131
  | Slow, low fps | `engine.jobs`, `engine.threads`, `engine.budget`, `engine.debug` | 15-perf.md §1 |
131
132
  | Deploy | `npm run build` | 61-deploy.md |
package/docs/API.md CHANGED
@@ -37,7 +37,7 @@
37
37
  - [`engine.vars`](api/vars.md) story flags and counters (autosaved): flag setFlag counter bump
38
38
  - [`engine.saves`](api/saves.md) engine.saves handles saving: define putAttachment removeAttachment attachments storageKey flush collect check apply save load list remove export …
39
39
  - [`engine.assets`](api/assets.md) Assets: manifest builder paramsOf setParams preload font model lod modelNow onModel geometry gridFromImage texture useTexture …
40
- - [`engine.audio`](api/audio.md) buses: addBus addNode setVolume reverb duck condition measure value matches volumeOf sfx noiseBurst tone load …
40
+ - [`engine.audio`](api/audio.md) buses: addBus addNode setVolume reverb duck filter condition measure value matches volumeOf sfx noiseBurst tone …
41
41
  - [`engine.i18n`](api/i18n.md) string tables: add setLocale has
42
42
  - [`engine.rays`](api/rays.md) engine.rays is the ray registry…: addStatic addProvider
43
43
  - [`engine.jobs`](api/jobs.md) engine.jobs queues build work in a binary heap: add run
@@ -53,7 +53,7 @@
53
53
  - [`engine.sky`](api/sky.md) sky() Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog: keyframes clouds layer replace environment
54
54
  - [`engine.calendar`](api/calendar.md) calendar() Time of day, day, seasons and clock-time timers: at between daily onSeason untilMark
55
55
  - [`engine.weather`](api/weather.md) weather() Weather state: defineField set label
56
- - [`engine.water`](api/water.md) water() Water surface: shader normalMap
56
+ - [`engine.water`](api/water.md) water() Water surface: ripple shader normalMap
57
57
  - [`engine.world`](api/world.md) World data: add origin idOf get set move remove query forEachNear present view refresh …
58
58
  - [`engine.net`](api/net.md) net: reconnect
59
59
  - [`engine.grids`](api/grids.md) grids: add get list define preview
@@ -65,6 +65,7 @@
65
65
  - [`engine.level`](api/level.md) level() Hand-built level: marker markersWith unload load track
66
66
  - [`engine.triggers`](api/triggers.md) triggers() Trigger zones: list add clear byTag fromMarkers
67
67
  - [`engine.particles`](api/particles.md) particles() Particles: define has emit attach count clear
68
+ - [`engine.decals`](api/decals.md) decals() Surface decals: define add remove count
68
69
  - [`engine.swarm`](api/swarm.md) swarm
69
70
  - [`engine.settings`](api/settings.md) settings() Settings menu: get set preset define addSection reset resetBindings rebind actionList save
70
71
  - [`engine.music`](api/music.md) music() Background music: define play stop stinger rules override pick
@@ -75,7 +76,7 @@
75
76
  - [`engine.pickups`](api/pickups.md) pickups() pickups: spawn nearest
76
77
  - [`engine.quests`](api/quests.md) quests() Quests: define start state advance isDone isActive isFailed check list
77
78
  - [`engine.photo`](api/photo.md) photo() Photo mode: take trace subject
78
- - [`engine.ambience`](api/ambience.md) ambience() Ambience: add rules nearWater
79
+ - [`engine.ambience`](api/ambience.md) ambience() Ambience: add stop rules nearWater
79
80
  - [`engine.nav`](api/nav.md) nav() Navmesh: findPath dispose
80
81
  - [`engine.hlod`](api/hlod.md) hlod() hlod: add
81
82
  - [`engine.lightPool`](api/lightPool.md) lightPool() Light pool: add
@@ -89,4 +90,4 @@
89
90
  - [`engine.weatherDraw`](api/weatherDraw.md) weather() weatherDraw
90
91
 
91
92
  ## Other
92
- - [Utility functions](api/tools.md): PICTURE_SLOTS presets world net fakeNetwork webSocket grids swarm screenToGround sampleGrid ease checkOptions contentParts readParams threePatches createTerrain terrainMaterial mergeColored applyEffects rampTexture bakeVertexAO materialPatches toast makeWindow …
93
+ - [Utility functions](api/tools.md): PICTURE_SLOTS presets world net fakeNetwork webSocket grids swarm screenToGround sampleGrid ease checkOptions contentParts readParams threePatches createTerrain terrainMaterial mergeColored applyEffects rampTexture bakeVertexAO materialPatches cloneMaterial toast …
package/docs/CODEMAP.md CHANGED
@@ -40,6 +40,7 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
40
40
  | collision | world | modules/collision/Collision.js |
41
41
  | content | rules | modules/content/index.js |
42
42
  | debugPanel | ui | modules/debug/DebugPanel.js |
43
+ | decals | picture | modules/decals/Decals.js |
43
44
  | flow | rules | modules/flow/index.js |
44
45
  | hlod | picture | modules/hlod/index.js |
45
46
  | inventory | rules | modules/gameplay/Inventory.js |
@@ -58,16 +59,16 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
58
59
  - index.js: Engine entry
59
60
 
60
61
  **core/**
61
- - assets/ Asset management: Asset manifest: register every model, tex… — Animator.js, Assets.js, Baked.js, assetEntry.js, assetHot.js, assetLoad.js, assetLod.js, assetManifest.js, assetPart.js, assetReport.js, ik.js, modelNeeds.js, namedModel.js, nodeVisibility.js
62
+ - assets/ Asset management: Asset manifest: register every model, tex… — Animator.js, Assets.js, Baked.js, assetEntry.js, assetHot.js, assetLoad.js, assetLod.js, assetManifest.js, assetPart.js, assetReport.js, ik.js, maskLayer.js, modelNeeds.js, namedModel.js, nodeVisibility.js, rootMotion.js
62
63
  - audio/ Audio core: buses (master, music, sfx, ambience, ui + the g… — Audio.js, audioReverb.js, audioRules.js, audioVoice.js
63
- - base/ Stable error codes: errors the engine raises by name end th… — Events.js, I18n.js, Random.js, Vars.js, docRef.js, easing.js, errorCodes.js, errorHints.js, errors.js, events.generated.js, follows.js, freeParts.js, math.js, mulberry32.js, params.js, saveValues.js, sections.js, spelling.js, util.js, validate.js
64
- - engine/ Module installation (part of Engine, mixed into Engine.prot… — Engine.js, Loading.js, copies.js, headlessLoad.js, lifecycle.js, loop.js, moduleSlots.js, moduleTypes.js, modules.js, page.js, plugins.js, services.js, startup.js
64
+ - base/ Module and domain error codes (merged into ERROR_CODES by e… — Events.js, I18n.js, Random.js, Vars.js, docRef.js, easing.js, errorCodes.js, errorCodesModules.js, errorHints.js, errors.js, events.generated.js, follows.js, freeParts.js, math.js, mulberry32.js, params.js, saveValues.js, sections.js, spelling.js, util.js, validate.js
65
+ - engine/ Module installation and lifecycle (mixed into Engine.protot… — Engine.js, Loading.js, copies.js, headlessLoad.js, lifecycle.js, loop.js, moduleSlots.js, moduleTypes.js, modules.js, page.js, plugins.js, services.js, startup.js
65
66
  - input/ Input: read by "action", not by "key" — Input.js, inputContext.js, inputDefaults.js, inputKeyboard.js, inputPad.js, inputPointer.js, inputSeat.js, inputTouch.js
66
67
  - inspect/ Generated by npm run map, do not edit by hand — Budget.js, DebugOverrides.js, Describe.js, Inspect.js, InspectMaterials.js, InspectPerf.js, InspectScene.js, MaterialInfo.js, UrlState.js, catalog.js, checks.js, debugView.js, describeRender.js, describeText.js, geometryWatch.js, lightWatch.js, metadata.generated.js, pictureChecks.js, pictureMenu.js, pictureWriters.js, shaderCost.js, textureBytes.js, toolDoor.js, valueHistory.js
67
68
  - ops/ Shared points: the ONE way several owners change a shared t… — Ops.js, actor.js, control.js, holds.js, opsAtomic.js, opsCheck.js, opsFail.js, opsGuard.js, opsHistory.js, opsRun.js, owned.js, sharedPoint.js, stackFrames.js, stacks.js, wrap.js
68
69
  - saves/ Saves: each module registers "how to save and load", and sa… — SaveStore.js, Saves.js, saveApply.js, saveFiles.js, saveIds.js, saveVersions.js, session.js, stateReplace.js
69
- - scene/ Adaptive quality by frame cost: one controller, one ladder … — Rays.js, Views.js, adaptive.js, canvasBox.js, compositeGround.js, drawOnly.js, floor.js, gameLights.js, grayMap.js, grid.js, gridLoad.js, ground.contract.js, ground.js, movement.js, pictureSlots.js, pixel.js, pixelRatio.js, sceneDelta.js, sceneMethods.js, screenToGround.js, stepPoses.js, targeting.js, thingExplain.js, thingOps.js, things.js, threePatches.js, tier.js, view.js
70
- - stream/ Automatic batching, engine.batching: the same static model … — Batching.js, Stream.js, batchGroups.js, cells.js, chunkStream.js, prepare.js, scatter.js, streamCells.js, streamSources.js
70
+ - scene/ Rays: engine.raycast / engine.pick, with the registry engin… — Rays.js, Views.js, adaptive.js, canvasBox.js, compositeGround.js, drawOnly.js, floor.js, gameLights.js, grayMap.js, grid.js, gridLoad.js, ground.contract.js, ground.js, movement.js, pictureSlots.js, pixel.js, pixelRatio.js, sceneDelta.js, sceneMethods.js, screenToGround.js, stepPoses.js, targeting.js, thingExplain.js, thingOps.js, things.js, threePatches.js, tier.js, view.js
71
+ - stream/ Automatic batching, engine.batching: the same static model … — Batching.js, Stream.js, batchGroups.js, cells.js, chunkStream.js, dirtyWatch.js, prepare.js, scatter.js, streamCells.js, streamSources.js
71
72
  - threads/ engine.threads: a small worker pool — Commits.js, Jobs.js, Threads.js, pureWorker.js, threadPure.js, threadServe.js
72
73
  - time/ engine.time: the one time source — Clock.js, dayTime.js, skip.js, time.js, uiClock.js
73
74
 
@@ -79,6 +80,7 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
79
80
  - collision/ Lightweight collision: characters are upright cylinders, trees/… — Collision.js, grid.js
80
81
  - content/ Content loader: game data files into the engine — explain.js, fields.js, ids.js, loader.js, markers.js, models.js, packs.js, parts.js, places.js, props.js, rules.js, stages.js, templates.js, words.js
81
82
  - debug/ Performance panel + time/weather debugging — DebugPanel.js
83
+ - decals/ — Decals.js
82
84
  - flow/ Game flow: states and scene transitions —
83
85
  - gameplay/ Interactions module: a prompt appears near an object ("E · Talk… — Container.js, Containers.js, Dialogue.js, Interactions.js, Inventory.js, Quests.js, boxOps.js, dialogue.contract.js, dialogueBox.js, dialogueBubbles.js, interactionPrompt.js, interactions.contract.js, inventory.contract.js, inventoryOps.js, pickups.js, questLog.js, questSave.js, quests.contract.js
84
86
  - grid/ grids() module: placement grids — Grid.js, Layer.js, ops.js, preview.js, strings.js, tiles.js
@@ -91,7 +93,7 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
91
93
  - net/ net() module: optional co-op multiplayer, host-authoritative st… — Client.js, Host.js, Net.js, sync.js, transports.js
92
94
  - particles/ Particles module: dust, falling leaves, splashes, chimney smoke… — Particles.js, effect.js, lit.js, shaders.js
93
95
  - photo/ Photo mode: a sharper shot, then restore — Photo.js, pathTrace.js
94
- - rigid/ Real physics (Rapier): objects that topple, roll, get pushed an… — RigidBodies.js, Vehicles.js, collider3d.contract.js, ragdoll.js, ragdollBones.js, refresh.js, sync.js
96
+ - rigid/ Real physics (Rapier): objects that topple, roll, get pushed an… — RigidBodies.js, Vehicles.js, collider3d.contract.js, ragdoll.js, ragdollBones.js, rapierCompat.js, sync.js
95
97
  - settings/ Settings menu module entry — Settings.js, apply.js, sections.js, strings.js, view.js
96
98
  - sky/ Sky module: signals (engine.uniforms: uSunDir, uSunColor, uSkyT… — Sky.js, clouds.js, dome.js, domeLayers.js, environment.js, fog.js, frame.js, season.js, shader.js, skyModule.js, tint.js
97
99
  - swarm/ Swarm module: many same-kind gameplay objects (bullets, enemy c… — Swarm.js, draw.js, grid.js
@@ -135,12 +137,14 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
135
137
  - postWebGL.js: Post chain on WebGLRenderer (EffectComposer)
136
138
  - probes.js: Baked light probes
137
139
  - recordSweep.js: WebGPURenderer keeps one RenderObject per drawn mesh in a s…
140
+ - reflectionProbes.js: Local reflection probes (mixed into Engine.prototype): pref…
138
141
  - shaderErrors.js: Shader errors naming the patch and slot
139
142
  - shadowCache.tsl.js: Kept shadows on WebGPURenderer: what stays still is drawn i…
140
143
  - shadowTypes.js: three 0.187 shadow filters
141
144
  - shadows.js: engine.shadows: the shadow engineering in three.js shape: e…
142
145
  - slots.js: Semantic patch slots
143
146
  - terms.js: Built-in material terms a game can take over whole: the clo…
147
+ - threeCompat.js: Three.js 0.187 compatibility layer: centralizes internal/pr…
144
148
  - uniformDecl.js: Declares style-supplied GLSL uniforms
145
149
  - vertexInputs.js: Vertex inputs of a WebGPURenderer program, counted before t…
146
150
 
@@ -158,7 +162,7 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
158
162
 
159
163
  | Event | Emitted by | Listened by |
160
164
  |---|---|---|
161
- | anim:end | core/assets/Animator.js | — |
165
+ | anim:end | core/assets/Animator.js, core/assets/maskLayer.js | — |
162
166
  | audio:ready | core/audio/Audio.js | — |
163
167
  | camera:change | camera | settings |
164
168
  | camera:shot | core/scene/Views.js, camera | lights |
@@ -203,9 +207,10 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
203
207
  | net:open | net | — |
204
208
  | net:result | net | — |
205
209
  | net:sync | net | — |
210
+ | op:rolledBack | (the game) | net |
206
211
  | page:blur | core/engine/page.js | core/input/Input.js |
207
212
  | page:contextlost | core/engine/page.js | — |
208
- | page:contextrestored | core/engine/page.js | sky |
213
+ | page:contextrestored | core/engine/page.js | sky, render/reflectionProbes.js |
209
214
  | page:focus | core/engine/page.js | — |
210
215
  | page:pointerlock | core/engine/page.js | camera, ui/Focus.js |
211
216
  | photo:denied | photo | — |
@@ -229,11 +234,11 @@ Type = what the module may own (core/engine/moduleTypes.js): world, picture, act
229
234
  | settings:change | settings | — |
230
235
  | state:applied | core/inspect/UrlState.js | — |
231
236
  | state:placed | core/inspect/UrlState.js | camera |
232
- | state:replaced | core/engine/startup.js, core/saves/stateReplace.js | calendar |
237
+ | state:replaced | core/engine/startup.js, core/saves/stateReplace.js | calendar, net |
233
238
  | template:stage | content | — |
234
239
  | terrain:chunkFailed | terrain | — |
235
240
  | terrain:void | rigid, terrain | — |
236
- | tier:change | core/engine/services.js | — |
241
+ | tier:change | core/engine/services.js | decals |
237
242
  | time:skip | core/time/skip.js | — |
238
243
  | timeline:end | timeline | — |
239
244
  | timeline:start | timeline | — |
@@ -299,6 +304,7 @@ Modules declare actions without keys; the game binds them (createEngine({ bindin
299
304
  - modules/collision/Collision.js: module.* (1)
300
305
  - modules/content/index.js: module.* (1)
301
306
  - modules/debug/DebugPanel.js: debug.* (1), module.* (1)
307
+ - modules/decals/Decals.js: module.* (1)
302
308
  - modules/flow/index.js: module.* (1)
303
309
  - modules/gameplay/Dialogue.js: module.* (1), dialogue.* (2)
304
310
  - modules/gameplay/Interactions.js: module.* (1)
package/docs/COMMANDS.md CHANGED
@@ -67,7 +67,7 @@ export const specs = [{
67
67
  | `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
68
68
  | `threedog shot --cam x,y,z,tx,ty,tz[,fov]` | A camera pose (position, target, optional fov in degrees) with no view declared in the game (`--pos` only places the player). Not with `--view`; negative numbers work with or without `=`. |
69
69
  | `threedog shot --view name [--compare before.png]` | A named camera view (`engine.views.define`) and a pixel diff against an earlier picture. `recipes/46-blender-art-route.md` |
70
- | Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game loop halted, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|halted|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / busy / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. |
70
+ | Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game loop halted, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|halted|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / busy / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, js, resume, reload. Everything else only observes. js and describe with a path or --full / --all print no state line (parseable); runtime still has it. |
71
71
  | `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
72
72
  | `npm run shot -- / --time 18:30 --weather rain --pos x,z` (or `--at place`: in play at a named place) | Only when you need to see the picture: 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`** (`--json` gives the whole state). `/<page>.html` switches the page, `-w game` the game, `--wait seconds` advances time, `--play` starts in play past the title screen. The shot waits for loading and for the game's own code after `await engine.start()`, and fails naming what is still pending. `--point name`: a shots.json point; checks the game's expectations. Other options: `threedog shot --help` |
73
73
  | `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`): picture numbers measured on the 3D canvas and at most four one-sentence hints (contradictions, facts, intent; recipes/35 "Picture check after every shot"). Nothing fails and nothing is changed; every value touched by its few extra renders is put back. `--json` gives every hint in full. A full URL opens an already running page without a build; `--image` reads a picture taken another way and gives the pixel part only. A screenshot of your own skips the check: take pictures with `shot` or `snap` |
@@ -116,13 +116,13 @@ They drive the running game. Run them inside the game folder or with `-w game`;
116
116
  | `threedog resume` | resume real-time running (the page is halted after step / press) |
117
117
  | `threedog ops` | what the player can do now (each op offer checked with can): ✓ shop.buy shop=bakery item=bread · ✗ … (reason); recipes/23-ops.md |
118
118
  | `threedog op` | run an op as source bridge (no time passes): op shop.buy shop=bakery item=bread n=2 (values converted by the op args shape) |
119
- | `threedog inspect` | what is around the player (or inspect npc_3 / inspect 10,-4) and which ops it can do now, with reasons. inspect materials (engine.inspect.materials(), plain three.js: scene.traverse + texture.colorSpace) = every material: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with ×N; wrong color spaces first (color map not sRGB = washed out; normal / roughness map marked sRGB). inspect perf (engine.inspect.perf(), plain three.js: renderer.info) = the last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; ✗ lines name the next call. Budgets: engine.budget limits, else a desktop reference. The engine benchmark suite is npm run perf |
119
+ | `threedog inspect` | what is around the player (or inspect npc_3 / inspect 10,-4) and which ops it can do now, with reasons. inspect materials (engine.inspect.materials(), plain three.js: scene.traverse + texture.colorSpace) = every material: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with ×N; wrong color spaces first (color map not sRGB = washed out; normal / roughness map marked sRGB). inspect perf (engine.inspect.perf(), plain three.js: renderer.info) = the last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; ✗ lines name the next call. Budgets: engine.budget limits, else desktop ref; benchmark: npm run perf. [--max N] |
120
120
  | `threedog scene` | the mesh exists but is not drawn: use this first. Counts, one Not drawn because: line over every Mesh / Points / Line / Sprite, then the first 6 undrawn ones (surprising before plain view culling) with every reason, most likely first: visible=false on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond camera.far, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. scene [--hidden (only undrawn)] [--limit N \| --full (40)] [--json]. Code: engine.inspect.scene(). Cannot see shader output |
121
121
  | `threedog pick` | what is at screen pixel x,y (from the canvas top-left): pick 480,270 -> record id, kind, template, where it is defined (content file:line), fields |
122
- | `threedog explain` | why: explain op shop.buy shop=bakery item=bread (can it run; --full adds its last attempt) / explain quest first-light (where it is stuck) / explain value fog.far (which line last changed it) / explain thing player-chest (where it is defined; --full: everything about the id as JSON) / explain module quests / explain capability ground. engine.explain; recipes/23-ops.md, recipes/40-scene.md section 9, recipes/62-picture-code.md |
122
+ | `threedog explain` | why: explain op shop.buy shop=bakery item=bread (--full: last attempt) / quest first-light / explain value fog.far / thing player-chest (--full: JSON) / module quests / capability ground [--max N]. engine.explain; recipes/23-ops.md, 40-scene.md §9, 62-picture-code.md |
123
123
  | `threedog scenario` | run one scenario test (tests/scenarios/<name>.json) on this page: scenario barter [--freeze-reload: saves do not reload the page during the run] (prints failed checks and the Coverage block of verify; the scenario leaves the page halted) |
124
- | `threedog catalog` | what the game can do: catalog = a line per module with ops or problems, the rest named on one line (--full: a line each); catalog shop = one module (dependencies, params + defaults, ops with args and failure codes, saved parts, time hooks, problems, doc / recipe / source files); catalog shop.buy = one op; catalog picture = picture menu + checks; catalog --find throw; --json for the raw data; recipes/51-capability-catalog.md |
125
- | `threedog loading` | what loading waits for / what failed / does it block the start (answers while start() is stuck); loading hero: one task with its manifest and path; recipes/05-props-bake.md |
124
+ | `threedog catalog` | what the game can do: catalog [--full] [--max N] [--json]; catalog shop (deps, params, ops, saves, hooks, problems, files); catalog shop.buy; catalog picture; catalog --find throw; recipes/51-capability-catalog.md |
125
+ | `threedog loading` | what loading waits for / failed / blocks start (works while start() is stuck); loading <name> [--max N]: task details; recipes/05-props-bake.md |
126
126
  | `threedog play` | start the game for the AI: starts the dev server if none runs (detached, output in .threedog/dev.log), waits for the bridge and the engine, prints the page address and whether a headless or a live browser page is connected (play --stop stops the server play started) |
127
127
  | `threedog impact` | before a change, what it touches, from the files alone: impact coin / impact shop.buy / impact stack / impact collider3d lists content, calls, saved parts, templates, tests and engine facts, then says what it cannot see (names computed in game code, what only a page or a save holds). --full lists every place |
128
128
  | `threedog report` | one file another AI can rerun a problem from: engine version, seed, tick, describe, recent ops, errors with hints, modules and capability state, steps to reproduce and a derived scenario; no tokens or user paths. Writes .threedog/reports/ (--out file); --scenario also writes tests/scenarios/report.json for threedog verify report. Works with no page, and says what is then missing |
@@ -113,49 +113,33 @@ into, or a convenience for after.
113
113
  | Next map, next stage, change level | `engine.level.load(name)` (recipe 10) | a fade around it: `engine.flow` (recipe 07) |
114
114
  | Background song that changes in a fight or a place | `engine.music`, rules as data (recipe 31) | one track: `engine.audio.play` |
115
115
  | An enemy walks around obstacles to reach someone | `engine.characters.findPath` on `engine.nav` (recipe 12) | a search of your own is fine: it reads `engine.collision.walkable` |
116
- | Two people play together over the internet | `engine.net` (recipe 27) | |
117
116
  | Take a snapshot in the game and keep it | `photo()`, `engine.photo.take()` | the raw image: `renderer.domElement.toBlob` |
118
117
  | A cutscene: steps in order; tween a value | `engine.timeline`, `engine.timeline.tween(target, to)` (recipe 07) | one delay: `engine.clock.after` |
119
118
  | Something happens when the player enters a zone | `engine.triggers` (recipe 20) | a press inside it: `engine.interactions` |
120
119
  | Raindrops and snow drawn on screen | `engine.weatherDraw` (recipe 08) | your own drawing: `THREE.md` |
121
120
  | Lower the resolution when the frame rate drops | `engine.adaptive` (recipe 15) | a fixed size: `engine.setPixelRatio` |
122
121
  | Draw many copies of one mesh in one call | `engine.batching` (recipe 05) | your own `InstancedMesh`: plain three.js |
123
- | What each frame costs, against limits | `engine.budget` (recipe 15) | |
124
122
  | A cutscene takes the view for a moment | `engine.takeCamera(owner)`, read `engine.cameraOverride` | a whole shot list: `engine.timeline` |
125
123
  | Sweep a shape through solid things, overlap tests | `engine.collider3d` (recipe 11) | a line: `engine.rays` |
126
- | Message when the game crashes, the last error | `engine.error` and `.threedog/errors.log` (recipe 16) | |
127
- | Tell other systems something happened | `engine.events` (recipe 06) | |
128
124
  | Height of the floor under a point | `engine.surface(x, z)` (recipe 28) | whether there is floor at all, or a fall out of the map: `engine.ground.has(x, z)` / `voidY()` |
129
125
  | Heavy work done bit by bit without freezing a frame | `engine.jobs` (recipe 15) | off the main thread: `engine.threads` |
130
- | Loading screen, progress bar while files load | `engine.loading` (recipe 07) | |
131
- | Pause when the browser tab is hidden | `engine.page` does it: gameplay freezes under owner `page` (recipe 07) | |
132
- | Style files that plug in with no main.js line | `plugins/`, `engine.plugins` (recipe 40) | |
133
- | Seeded dice roll that replays the same | `engine.random` (recipe 06) | |
134
- | What is the mouse pointing at, click an object | `engine.rays`, `engine.pick(x, y)` (recipe 19) | |
135
- | Which systems are stopped and who stopped them | `engine.runState` (recipe 16) | |
136
- | Remember progress between visits | `engine.saves` (recipe 20) | |
137
- | New game and continue from the menu | `engine.session` (recipe 07) | |
138
- | Cloud shadow and season in your own material | `engine.shaderTerms` (recipe 52) | |
126
+ | Style files that plug in with no main.js line | `plugins/`, `engine.plugins` (recipe 40) | wire by hand in order: `engine.use()` in `main.js` |
127
+ | What is the mouse pointing at, click an object | `engine.rays`, `engine.pick(x, y)` (recipe 19) | raw three.js ray against any mesh: `new THREE.Raycaster` |
128
+ | Which systems are stopped and who stopped them | `engine.runState` (recipe 16) | every active lock with when it was taken: `describe().holds` |
129
+ | Remember progress between visits | `engine.saves` (recipe 20) | preferences outside a save (volume, language): `saves.storageKey` |
130
+ | Cloud shadow and season in your own material | `engine.shaderTerms` (recipe 52) | your own uniform on a material: plain three.js |
139
131
  | Stack bonuses from several sources on one value | `engine.stacks` (recipe 55) | one value, no bookkeeping: `engine.mod` |
140
- | How long the first frame took to load | `engine.startup` (recipe 15) | |
141
- | Load far parts of a big map only when near | `engine.stream` (recipe 33) | |
132
+ | How long the first frame took to load | `engine.startup` (recipe 15) | per-frame timing against budgets: `engine.inspect.perf()` |
142
133
  | Heavy work in a web worker | `engine.threads` (recipe 15) | bit by bit on the main thread: `engine.jobs` |
143
- | How many seconds passed in the game | `engine.time.now()` (recipe 06) | |
134
+ | How many seconds passed in the game | `engine.time.now()` (recipe 06) | time of day / days: `engine.calendar`; a timer: `engine.clock` |
144
135
  | Hit stop, bullet time | `engine.mod('time.world', { owner, set: 0, layer: 'system', for: 0.06 })`; `for` is real seconds (or `clock: '<channel>'`) | not `clock.rate` (the calendar) |
145
- | Remember a flag or a count, a door was opened | `engine.vars` (recipe 20) | |
146
- | A named fixed view, a second camera to show | `engine.views` (recipe 46) | |
136
+ | Remember a flag or a count, a door was opened | `engine.vars` (recipe 20) | structured per-system state: `engine.saves.define` |
137
+ | A named fixed view, a second camera to show | `engine.views` (recipe 46) | render into your own texture: `engine.onRender` |
147
138
  | Load a model, texture or sound file | `engine.assets` (recipe 05) | a format it does not read: a three.js loader |
148
- | Something at a set hour of game time (a shop opens at nine) | `engine.clock`, `engine.calendar` (recipe 06) | |
149
- | A guard patrols or wanders between points | `engine.characters` with `findPath` (recipe 12, 57) | |
150
139
  | Back to the main menu after losing, game over, retry | `engine.flow`, `engine.session` (recipe 07) | the rules of the ending: recipe 32 |
151
140
  | Sunset, sunrise, the sky's colors | `engine.sky`, `engine.calendar` (recipe 08) | your own sky: `THREE.md` |
152
- | Mission marker, an arrow on screen | `engine.hud.marker()` (recipe 04) | |
153
- | Place furniture and merge it for speed | content `props` (recipe 05) | |
154
- | Your own colors, textures and models | plain three.js in `picture/` (recipe 09) | |
155
141
  | A map or model from a 3D modeling tool (Blender) | `engine.level` (recipe 10) | art only: recipe 46 |
156
142
  | Write your own engine system | a module (recipe 14) | one that plugs into saves and time: recipe 49 |
157
- | Match the look of a reference painting or picture | recipe 35 | |
158
- | The image looks flat, what to adjust | recipe 60 | |
159
143
 
160
144
  ### Look-alike entries
161
145
  Each of these does one job. Take the row for your job; none replaces another.
@@ -8,6 +8,7 @@ Ambience (ambience() module)
8
8
 
9
9
  ## Methods and properties
10
10
  - `ambience.add(rule: AmbienceRule) → { remove(): void }` — Add one rule; returns a handle whose remove() fades the sound out and drops the rule. Example: `const h = engine.ambience.add({ sound: 'storm-wind', when: { weather: 'storm' }, volume: 0.5 });`
11
+ - `ambience.stop(fade?: number)` — Stop all playing ambience voices and release any active acoustic zone filter / reverb override.
11
12
  - `ambience.rules(list: AmbienceRule[] | null)` — Replace the whole rule table (null or [] = silence)
12
13
  - `ambience.nearWater(radius?: number) → number` — How much of the ground within `radius` meters of the listener is water (0-1), sampled at 6 points: for a water rule's volume. Example: `{ sound: 'river', volume: (e, a) => a.nearWater(20) * 0.12 } // in data: volume: { add: { nearWater: 0.12 } } (12 m)`
13
14
  - Properties:
@@ -41,15 +41,19 @@
41
41
  - `states?: Record<string, AnimatorState>` States: name → state
42
42
  - `transitions?: Record<string, number>` Transition seconds for specific pairs: { 'jump>fall': 0.1, '*>idle': 0.3 }
43
43
  - `params?: Record<string, number>` Initial parameter values
44
+ - `rootMotion?: RootMotionOption` Default root motion setting for all states (overridable per state): true, bone name, or { bone?, y? }
44
45
  - **AnimatorState** An animation state: clip is the clip name; or blend is a blend tree (blends several clips by the param parameter); loop: false is a one-shot clip
45
46
  - `clip?: string` Clip name (the clip name in the glTF)
46
47
  - `blend?: { clip: string; at: number }[]` Blend tree: at the parameter value at it is fully this clip, in between they blend proportionally, e.g. [{ clip: 'Walk', at: 1.5 }, { clip: 'Run', at: 6 }]
47
- - `param?: string` Which parameter the blend tree reads (set by anim.set), default 'speed'
48
+ - `blend2d?: { clip, at }[]` 2D directional blend space (polar Gradient Band Interpolation), e.g. 4-way or 8-way strafing across [moveX, moveZ]
49
+ - `param?: string` Which parameter the 1D blend tree reads (set by anim.set), default 'speed'
50
+ - `params?: readonly [string, string] | [string, string]` Which [x, z] parameter pair blend2d reads, default ['moveX', 'moveZ'] (updated automatically on Character)
48
51
  - `sync?: boolean` Align the strides of blended clips, default true
49
52
  - `loop?: boolean` Loop, default true; with false the anim:end event fires when it finishes
50
53
  - `then?: string` Which state a one-shot clip goes to when it finishes
51
54
  - `lock?: boolean` go() cannot interrupt it while playing
52
55
  - `timing?: number | [number, number][]` For sync(): gameplay seconds -> clip seconds. A number = the gameplay length the whole clip is stretched over; [[gameT, clipT], ...] = piecewise linear (land the swing on the hit phase). Without it clip seconds = t
56
+ - `rootMotion?: RootMotionOption` Pin the root/hips bone local X/Z (and Y when { y: true }) after mixer.update so root motion stays in the capsule; overrides AnimatorOptions.rootMotion
53
57
  - **Animator** Skeletal animation state machine (returned by engine.assets.animate(model, config))
54
58
  - `root: Object3D` The animated object
55
59
  - `mixer: any` three.js AnimationMixer
@@ -61,8 +65,11 @@
61
65
  - `go(state: string, opts?: { fade?: number }) → any` — Switch to a state ({ fade }: transition seconds); null (dev warning) if there is no such state / clip; ignored while sync() drives a state
62
66
  - `action(name: string, opts?: { fade?: number }) → any` — One-shot clip: state name or clip name, returns to then or the previous state when done; go() cannot interrupt it while playing
63
67
  - `sync(state: string | null, t?: number) → any` — Gameplay drives the clock: show state at gameplay time t (fixed-step seconds) through its timing. The clip never advances or ends by itself and go() leaves it alone; sync(null) hands control back
68
+ - `rootDelta(state: string, fromT: number, toT: number, opts?: { yaw?, local?, y?, out? }) → { x, y, z }` — Deterministic root motion delta over gameplay interval [fromT, toT], sampled directly from the clip's position VectorKeyframeTrack (independent of render frames and mixer.update). Handles one-shot clamping, looping wrap-around and state timing; rotates by yaw ?? root.rotation.y unless local is true. Example: `const d = anim.rootDelta('roll', prevT, t, { yaw: ch.facing });`
64
69
  - `describe() → AnimatorInfo` — What is showing: state, clip, clip time, progress, driven, weights
65
70
  - `check(actions?: string[]) → string[]` — Check the mapping against the action names the game plays: each problem as text with its fix ([] = all will play). Example: `anim.check(['idle', 'walk', 'attack', 'hurt'])`
66
- - `addAim(opts: { bones, target?, limit?, speed?, weight?, fade?, … }) → AimLayer` — Look-at IK, the last layer on the clips: a bone or a chain from the body out turns toward target, within limit degrees of the animated pose. Weight 0 leaves the pose exactly; target null looks ahead; forward: the last bone's own front axis when the bind pose does not say (recipe 13 §3e). Example: `const look = npc.anim.addAim({ bones: ['Neck', 'Head'], target: engine.player.root, limit: 70 });`
67
- - `addFeet(opts?: { legs?, hips?, reach?, far?, speed?, weight?, … }) → FeetLayer` — Feet on the ground: each [upper, lower, foot] leg bends onto the model's own ground (a Character's includes platforms; off while it jumps or swims, beyond far from the camera, while hidden); the hips lower for the foot that reaches down. legs: bone names when they are not recognised. Example: `const feet = engine.player.anim.addFeet();`
71
+ - `addAim(opts: { bones, weights?, target?, limit?, speed?, weight?, … }) → AimLayer` — Look-at IK, the last layer on the clips: a bone or a chain from the body out turns toward target, within limit degrees of the animated pose. Weight 0 leaves the pose exactly; target null looks ahead; forward: the last bone's own front axis when the bind pose does not say (recipe 13 §3e). Example: `const look = npc.anim.addAim({ bones: ['Spine', 'Neck', 'Head'], weights: [0.2, 0.3, 0.5], target: engine.player.root, limit: 70 });`
72
+ - `addFeet(opts?: { legs?, hips?, reach?, far?, speed?, weight?, … }) → FeetLayer` — Feet on the ground: each [upper, lower, foot] leg bends onto the model's own ground (a Character's includes platforms; off while it jumps or swims, beyond far from the camera, while hidden); the hips lower for the foot that reaches down and ankles tilt onto slopes (alignSlope, maxTilt). Example: `const feet = engine.player.anim.addFeet();`
73
+ - `addLimb(opts: { bones?, limb?, target?, pole?, alignRotation?, weight?, … }) → LimbLayer` — Two-bone limb IK (hands reaching for grips, levers or ledges, or custom legs): pass limb ('leftArm' / 'rightArm' / 'leftLeg' / 'rightLeg') or bones ([upper, mid, end]). Example: `const grip = anim.addLimb({ limb: 'leftArm', target: foregrip, alignRotation: true });`
74
+ - `addLayer(opts?: MaskLayerOptions) → MaskLayer` — Bone-mask animation layer (e.g. mask: 'upper' to swing a sword or aim while legs keep running/strafing). Example: `const upper = anim.addLayer({ mask: 'upper', states: { slash: { clip: 'Sword_Slash', loop: false } } });`
68
75
  - `dispose()` — Stop the per-frame update when no longer needed
package/docs/api/audio.md CHANGED
@@ -5,6 +5,7 @@
5
5
  - `audio.setVolume(bus: string, v: number)` — Set a bus volume 0-1 ('master' for the total). Example: `engine.audio.setVolume('music', 0.3);`
6
6
  - `audio.reverb(opts: { wet?, decay?, size?, sends?, fade? } | null)` — (experimental) 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 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 comes back through master. The impulse is generated (decaying noise, no file): changing size or decay rebuilds it, wet and sends only fade. 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). Example: `engine.audio.reverb({ sends: { sfx: 0.5, ambience: 0.8 }, decay: 3, size: 0.8, wet: 0.4 });`
7
7
  - `audio.duck(levels: Record<string, number>, opts?: { fade?: number }) → { remove(fade?: number): void }` — Lower buses until the handle is removed (dialogue, pause menu, a cutscene). Several ducks stack (their levels multiply). Example: `const d = engine.audio.duck({ music: 0.3, ambience: 0.5 }); engine.events.once('dialogue:end', () => d.remove());`
8
+ - `audio.filter(cutoff: number | Record<string, number>, opts?: { fade?: number }) → { set, remove }` — (experimental) Low-pass filter buses (e.g. underwater, cave, muffled room) until the handle is removed. Several holders stack: each bus takes the lowest active cutoff Hz; removing all restores 20000 Hz. Example: `const f = engine.audio.filter(800, { fade: 0.5 }); f.set(400); f.remove();`
8
9
  - `audio.condition(name: string, test: (value: any, e: any) => boolean) → { remove(): void }` — Add a condition key for music / ambience rule lists: `when: { [name]: value }` calls test(value, engine). Modules add theirs (calendar: time, weather: weather, triggers: zone); the engine has `state` (engine.audio.state). Example: `engine.audio.condition('inside', v => engine.vars.flag('indoors') === v);`
9
10
  - `audio.measure(name: string, fn: (e: any) => number) → { remove(): void }` — Add a measure: a number rule data compares (`when: { daylight: { gt: 0.15 } }`; gt / gte / lt / lte) and adds up (`volume: { add: { wind: 0.08 } }`). calendar adds daylight, weather rain / snow / wind, ambience nearWater / altitude. A name is a condition or a measure, not both. Example: `engine.audio.measure('danger', e => e.vars.counter('alarm') / 10); // data: when: { danger: { gt: 0.5 } } Measures are not only for sound: render/daylight.js reads 'daylight' for night glow, so the calendar (or the sky without one) registers it once and nothing else has to know which module tells day from night. remove() drops only this registration (a later one under the name stays).`
10
11
  - `audio.value(name: string) → number | undefined` — The current value of a measure (debug, tests); undefined when none is registered under that name
@@ -23,7 +24,7 @@
23
24
  - `master: any` The master GainNode (every bus ends here)
24
25
  - `noise: any` 2 s of white noise, reused by synthesized sounds
25
26
  - `running: boolean` (experimental) Is audio usable (the player has clicked/pressed a key)?
26
- - `info: { running, state, levels, ducks, voices, reverb? }` 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. 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). Example: `engine.audio.duck({ music: 0.3 }); engine.audio.info.ducks.music // 0.3`
27
+ - `info: { running, state, levels, ducks, filters, voices, … }` 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. 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). Example: `engine.audio.duck({ music: 0.3 }); engine.audio.info.ducks.music // 0.3`
27
28
 
28
29
  ## Data structures
29
30
  - **AudioConfig** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio).
@@ -44,9 +45,10 @@
44
45
  - `loop?: boolean`
45
46
  - `distance?: { ref?: number; max?: number; rolloff?: number }` 3D falloff for sfx(name, { at }): ref meters at full volume (2), max meters (60), rolloff (1)
46
47
  - **AmbienceRule** One ambience rule: while `when` holds, `sound` plays at `volume`. With `every` it is a one-shot repeated at random gaps, else a loop
47
- - `sound?: string` A name from audio.sounds; required unless the rule is a reverb rule
48
+ - `sound?: string` A name from audio.sounds; required unless the rule is a reverb / filter acoustic zone rule
48
49
  - `when?: AudioCondition`
49
- - `reverb?: number | AudioVolumeData | ((e, ambience) => number)` (experimental) Instead of a sound: the reverb's wet (0-1, or the volume forms) while `when` holds; the highest holding one wins, none gives engine.audio.reverb's own wet back. Not with sound / volume / every / bus
50
+ - `reverb?: number | AudioVolumeData | ((e, ambience) => number)` (experimental) Instead of a sound: the reverb's wet (0-1, or the volume forms) while `when` holds; the highest holding one wins, none gives engine.audio.reverb's own wet back. May combine with filter; not with sound / volume / every / bus
51
+ - `filter?: number | Record<string, number> | ((e, ambience) => number | Record<string, number>) | …` (experimental) Instead of a sound: low-pass filter cutoff Hz (80..20000 for sfx / ambience / music, or bus -> Hz map) while `when` holds; the lowest cutoff per bus wins, none restores 20000 Hz. May combine with reverb; not with sound / volume / every / bus
50
52
  - `volume?: number | AudioVolumeData | ((e, ambience) => number)` 0-1, data { base, add: { measure: factor }, min, max }, or a function of the moment (e, ambience) => 0-1 (code only)
51
53
  - `fade?: number` Fade seconds when the rule turns on / off (1)
52
54
  - `every?: number[]` One-shot: [shortest, longest] seconds between plays
@@ -0,0 +1,16 @@
1
+ # engine.decals — decals(opts?: DecalsOptions)
2
+
3
+ Surface decals (decals() module)
4
+
5
+ - Options `DecalsOptions`:
6
+ - `max?: number` Global live decal cap (default 128, 64 on low tier)
7
+ - `effects?: Record<string, DecalKindOptions>` Named decal kinds defined at install
8
+ - `default?: DecalKindOptions` Base options every decal inherits
9
+
10
+ ## Methods and properties
11
+ - `decals.define(name: string, opts?: DecalKindOptions) → DecalKindOptions` — Define a named decal kind
12
+ - `decals.add(at: PositionLike | { point, normal?, face?, object? }, opts?: DecalAddOptions) → DecalHandle` — Project a decal at a position or raycast hit
13
+ - `decals.remove(kind?: string)` — Remove live decals of `kind`, or every live decal when `kind` is omitted
14
+ - `decals.count(kind?: string) → number` — Live decal count (for one kind, or all when omitted)
15
+ - Properties:
16
+ - `material: Material` Default base material cloned for decals without a material of their own