threedog 2.2.2 → 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 (194) hide show
  1. package/CHANGELOG.md +20 -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 +22 -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 +371 -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/gameLights.js +19 -11
  44. package/core/scene/sceneDelta.js +8 -4
  45. package/core/stream/chunkStream.js +21 -0
  46. package/core/stream/dirtyWatch.js +37 -0
  47. package/core/time/skip.js +9 -6
  48. package/core/time/time.js +72 -18
  49. package/docs/AI.md +22 -21
  50. package/docs/API.md +5 -4
  51. package/docs/CODEMAP.md +16 -10
  52. package/docs/COMMANDS.md +5 -5
  53. package/docs/CONVENTIONS.md +9 -25
  54. package/docs/api/ambience.md +1 -0
  55. package/docs/api/assets.md +10 -3
  56. package/docs/api/audio.md +5 -3
  57. package/docs/api/decals.md +16 -0
  58. package/docs/api/engine.md +1 -0
  59. package/docs/api/tools.md +3 -1
  60. package/docs/api/water.md +3 -0
  61. package/docs/recipes/09-materials-lights-models.md +15 -1
  62. package/docs/recipes/13-animation.md +51 -10
  63. package/docs/recipes/16-dev-bridge.md +1 -1
  64. package/docs/recipes/31-audio.md +15 -9
  65. package/docs/recipes/34-environment-lighting.md +11 -1
  66. package/docs/recipes/44-water-weather-hooks.md +1 -0
  67. package/examples/action/.threedog/content-index.json +1 -0
  68. package/examples/perf-island/.threedog/content-index.json +1 -0
  69. package/examples/plain-picture/.threedog/content-index.json +1 -0
  70. package/examples/rc2d/.threedog/content-index.json +1 -0
  71. package/examples/styletest/.threedog/content-index.json +1 -0
  72. package/examples/techniques/outlines-and-rim/main.js +1 -1
  73. package/examples/techniques/procedural-surface/main.js +1 -1
  74. package/examples/techniques/stylized-shading/main.js +1 -1
  75. package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
  76. package/examples/world/.threedog/content-index.json +1 -0
  77. package/index.d.ts +6 -2
  78. package/index.js +3 -2
  79. package/llms.txt +11 -10
  80. package/modules/ambience/Ambience.js +97 -15
  81. package/modules/camera/common.js +18 -12
  82. package/modules/characters/Character.js +30 -3
  83. package/modules/characters/NPC.js +2 -5
  84. package/modules/characters/astar.js +45 -14
  85. package/modules/characters/movers/rapier.js +53 -41
  86. package/modules/characters/movers/simple.js +37 -24
  87. package/modules/characters/npcView.js +2 -2
  88. package/modules/characters/pathAsync.js +3 -3
  89. package/modules/collision/contract.js +2 -2
  90. package/modules/content/index.js +3 -0
  91. package/modules/content/models.js +11 -4
  92. package/modules/content/templates.js +11 -11
  93. package/modules/debug/DebugPanel.js +1 -0
  94. package/modules/decals/Decals.js +393 -0
  95. package/modules/decals/index.js +1 -0
  96. package/modules/gameplay/Container.js +2 -0
  97. package/modules/gameplay/Containers.js +17 -3
  98. package/modules/gameplay/Dialogue.js +1 -1
  99. package/modules/gameplay/Interactions.js +7 -6
  100. package/modules/gameplay/Inventory.js +5 -1
  101. package/modules/gameplay/Quests.js +4 -3
  102. package/modules/gameplay/inventoryOps.js +2 -2
  103. package/modules/gameplay/pickups.js +32 -12
  104. package/modules/gameplay/questSave.js +2 -2
  105. package/modules/grid/index.js +8 -2
  106. package/modules/hud/index.js +1 -1
  107. package/modules/level/heightfield.js +1 -0
  108. package/modules/level/index.js +3 -2
  109. package/modules/level/nodes.js +2 -1
  110. package/modules/lights/index.js +27 -4
  111. package/modules/lights/slots.js +33 -16
  112. package/modules/nav/contract.js +4 -4
  113. package/modules/nav/index.js +6 -2
  114. package/modules/net/Client.js +24 -11
  115. package/modules/net/Host.js +73 -20
  116. package/modules/net/index.js +33 -21
  117. package/modules/net/sync.js +38 -8
  118. package/modules/net/transports.js +7 -3
  119. package/modules/particles/Particles.js +11 -4
  120. package/modules/particles/contract.js +6 -6
  121. package/modules/particles/effect.js +0 -1
  122. package/modules/rigid/RigidBodies.js +69 -57
  123. package/modules/rigid/Vehicles.js +8 -7
  124. package/modules/rigid/ragdoll.js +4 -6
  125. package/modules/rigid/rapierCompat.js +90 -0
  126. package/modules/rigid/sync.js +2 -5
  127. package/modules/settings/Settings.js +10 -4
  128. package/modules/sky/Sky.js +10 -2
  129. package/modules/sky/environment.js +29 -13
  130. package/modules/sky/frame.js +2 -2
  131. package/modules/sky/shader.js +5 -2
  132. package/modules/sky/skyModule.js +2 -2
  133. package/modules/swarm/Swarm.js +3 -2
  134. package/modules/swarm/grid.js +12 -7
  135. package/modules/terrain/ChunkManager.js +16 -26
  136. package/modules/triggers/index.js +5 -6
  137. package/modules/vegetation/draw.js +62 -26
  138. package/modules/vegetation/groundChunks.js +8 -22
  139. package/modules/water/Water.js +152 -24
  140. package/modules/water/surface.js +43 -20
  141. package/modules/weather/weatherDraw.js +4 -1
  142. package/modules/world/World.js +21 -2
  143. package/modules/world/index.js +5 -0
  144. package/modules/world/persist.js +1 -0
  145. package/modules/world/records.js +3 -1
  146. package/modules/world/sim.js +3 -2
  147. package/modules/world/simFar.js +4 -2
  148. package/modules/world/state.js +7 -1
  149. package/package.json +2 -2
  150. package/presets.js +30 -0
  151. package/render/PostFX.js +24 -17
  152. package/render/backend.js +72 -31
  153. package/render/cascades.js +25 -14
  154. package/render/cascades.tsl.js +32 -21
  155. package/render/fogLook.js +2 -1
  156. package/render/fx/library.tsl.js +1 -1
  157. package/render/fx/particles.tsl.js +4 -18
  158. package/render/fx/pcss.tsl.js +2 -2
  159. package/render/fx/postWebGPU.tsl.js +47 -25
  160. package/render/fx/sky.tsl.js +6 -18
  161. package/render/fx/uniforms.tsl.js +16 -0
  162. package/render/fx/water.tsl.js +24 -5
  163. package/render/fxNumbers.js +2 -0
  164. package/render/impostor.tsl.js +10 -6
  165. package/render/lights.js +6 -6
  166. package/render/occlusion.js +17 -6
  167. package/render/patches.js +40 -28
  168. package/render/postWebGL.js +6 -4
  169. package/render/reflectionProbes.js +302 -0
  170. package/render/shaderErrors.js +18 -8
  171. package/render/shadowCache.tsl.js +10 -5
  172. package/render/shadows.js +70 -49
  173. package/render/threeCompat.js +166 -0
  174. package/types/core.d.ts +33 -3
  175. package/types/gameplay.d.ts +80 -0
  176. package/types/generated/core/audio/Audio.d.ts +18 -1
  177. package/types/generated/core/ops/Ops.d.ts +2 -1
  178. package/types/generated/core/ops/control.d.ts +7 -3
  179. package/types/generated/core/saves/session.d.ts +4 -1
  180. package/types/generated/modules/ambience/Ambience.d.ts +6 -0
  181. package/types/generated/modules/debug/DebugPanel.d.ts +1 -0
  182. package/types/generated/modules/grid/index.d.ts +27 -3
  183. package/types/generated/modules/net/index.d.ts +8 -3
  184. package/types/generated/modules/sky/Sky.d.ts +1 -0
  185. package/types/generated/modules/water/Water.d.ts +15 -0
  186. package/types/generated/modules/world/index.d.ts +5 -0
  187. package/types/generated/render/patches.d.ts +5 -0
  188. package/types/physics.d.ts +66 -9
  189. package/types/tsl.d.ts +2 -0
  190. package/types/world.d.ts +2 -0
  191. package/ui/Parts.js +3 -2
  192. package/docs/MIGRATING-0.7.md +0 -39
  193. package/docs/MIGRATING-0.8.md +0 -171
  194. package/modules/rigid/refresh.js +0 -10
@@ -38,11 +38,14 @@ export class Session {
38
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.
39
39
  * A save that cannot be read (missing, corrupt, from a newer build) is refused before anything changes: returns false, the current game and the save stay as they were.
40
40
  * @param {string} [slot]
41
+ * @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
41
42
  * @returns {Promise<boolean>}
42
43
  * @example
43
44
  * engine.events.on('player:dead', () => engine.session.load('checkpoint')); // retry; the checkpoint was saved with engine.saves.save('checkpoint')
44
45
  */
45
- load(slot?: string): Promise<boolean>;
46
+ load(slot?: string, { turn }?: {
47
+ turn?: object;
48
+ }): Promise<boolean>;
46
49
  /**
47
50
  * End the playthrough and show the title screen (the title part when the game turned it on; flow returns to its start state).
48
51
  * The state behind the title is the new-game state, so nothing from the old playthrough runs while the title is up.
@@ -19,6 +19,12 @@ export class Ambience {
19
19
  add(rule: AmbienceRule): {
20
20
  remove(): void;
21
21
  };
22
+ /**
23
+ * Stop all playing ambience voices and release any active acoustic zone filter / reverb override.
24
+ * @param {number} [fade] fade-out seconds (0 = at once)
25
+ * @returns {void}
26
+ */
27
+ stop(fade?: number): void;
22
28
  /**
23
29
  * Replace the whole rule table (null or [] = silence)
24
30
  * @param {AmbienceRule[] | null} list
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * Debug panel -> engine.debug.panel: performance panel, time and weather debugging. Collapsed by default; the action 'debugPanel' shows/hides it (presets.bindings.debug: F3); open: true shows it at start. Just do not install it in a release
4
4
  * @param {{ open?: boolean }} [opts]
5
+ * open: show the debug panel expanded at startup instead of collapsed (default false).
5
6
  * @returns {ModuleDef<DebugPanel>}
6
7
  */
7
8
  export function debug(opts?: {
@@ -1,7 +1,13 @@
1
1
  // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/index.js (edit the JSDoc in the source, then run npm run map)
2
2
  /**
3
- * Options of grids()
4
- * @typedef {{ ok?: any, bad?: any, previewOpacity?: number, previewHeight?: number, tiles?: Record<string, Record<string, any>>, tileLift?: number }} GridsOptions
3
+ * Options of grids().
4
+ * @typedef {object} GridsOptions
5
+ * @property {any} [ok] Preview color where an item can be placed (default 0xe0e0e0).
6
+ * @property {any} [bad] Preview color where an item cannot be placed (default 0x3a3a3a).
7
+ * @property {number} [previewOpacity] Opacity of the placement preview box (default 0.45).
8
+ * @property {number} [previewHeight] Height of the placement preview box in meters (default 0.08).
9
+ * @property {Record<string, Record<string, any>>} [tiles] Tile colors by layer name ({ layer: { field: color } }).
10
+ * @property {number} [tileLift] Height of layer tiles above the ground in meters (default 0.03).
5
11
  */
6
12
  /**
7
13
  * Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
@@ -109,14 +115,32 @@ export class Grids {
109
115
  };
110
116
  }
111
117
  /**
112
- * Options of grids()
118
+ * Options of grids().
113
119
  */
114
120
  export type GridsOptions = {
121
+ /**
122
+ * Preview color where an item can be placed (default 0xe0e0e0).
123
+ */
115
124
  ok?: any;
125
+ /**
126
+ * Preview color where an item cannot be placed (default 0x3a3a3a).
127
+ */
116
128
  bad?: any;
129
+ /**
130
+ * Opacity of the placement preview box (default 0.45).
131
+ */
117
132
  previewOpacity?: number;
133
+ /**
134
+ * Height of the placement preview box in meters (default 0.08).
135
+ */
118
136
  previewHeight?: number;
137
+ /**
138
+ * Tile colors by layer name ({ layer: { field: color } }).
139
+ */
119
140
  tiles?: Record<string, Record<string, any>>;
141
+ /**
142
+ * Height of layer tiles above the ground in meters (default 0.03).
143
+ */
120
144
  tileLift?: number;
121
145
  };
122
146
  import { Grid } from './Grid.js';
@@ -10,9 +10,14 @@
10
10
  * @param {{ role: 'host' | 'client', transport: any, sync?: 'auto' | string[], syncEvery?: number, keepAlive?: number, rate?: number, burst?: number, maxSpeed?: number, posEvery?: number,
11
11
  * actorFor?: (peerId: number) => string, actorFields?: string[], avatarFields?: string[], interpolate?: string[], avatar?: boolean,
12
12
  * onJoin?: (e: any, peer: { id: number, actor: string }) => void, onLeave?: (e: any, peer: { id: number, actor: string }) => void }} opts
13
- * sync: save parts to sync ('auto' = world, containers, vars and every other save part except random / level / rigid); syncEvery: steps between diffs (3 = 20/s);
14
- * rate / burst: op requests per second per peer and the burst allowance; actorFields: record fields holding actor ids (swapped like ids, default ['owner']);
15
- * avatarFields: own-avatar fields the client sends with its position; interpolate: record kinds that glide on clients (default ['player']).
13
+ * role: host (owns the game) or client (mirrors the host); transport: message transport such as webSocket(url) or fakeNetwork().connect();
14
+ * sync: save parts to sync (auto syncs world, containers, vars and other save parts except random, level and rigid); syncEvery: fixed steps between state diffs (default 3);
15
+ * keepAlive: fixed steps between idle heartbeat messages (default 60); rate / burst: per-peer op requests per second and burst allowance (default 20);
16
+ * maxSpeed: maximum avatar movement speed in m/s accepted from a client (default 15); posEvery: fixed steps between client position updates (default 3);
17
+ * actorFor: maps a numeric peer id to its actor id (default guest-<id>); actorFields: record fields holding actor ids to remap per peer (default owner);
18
+ * avatarFields: own-avatar record fields sent with client position updates; interpolate: record kinds smoothed on clients between diffs (default player);
19
+ * avatar: automatically create a player world record and bag per joining peer (default true);
20
+ * onJoin: host callback fired after a peer joins; onLeave: host callback fired before a peer leaves.
16
21
  * @returns {import('../../../core').ModuleDef<Net>}
17
22
  * @example
18
23
  * // host
@@ -1,4 +1,5 @@
1
1
  // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/sky/Sky.js (edit the JSDoc in the source, then run npm run map)
2
+
2
3
  /** @import { Object3D, Vector3 } from '../../../common' */
3
4
  /** engine.sky */
4
5
  export class Sky {
@@ -36,6 +36,20 @@ export class Water {
36
36
  * @experimental
37
37
  */
38
38
  sea: THREE.Mesh | null;
39
+ /** Number of currently expanding ripple rings (0..8) @type {number} */
40
+ get activeRipples(): number;
41
+ /**
42
+ * Spawn an expanding concentric ripple ring at `position` (`[x, y, z]`, `{ x, z }`, `Vector3` or `Object3D`), visible on both the global sea and water bodies.
43
+ * @example engine.water.ripple(engine.player.position, { strength: 1.2, duration: 2.5 });
44
+ * @param {PositionLike} position
45
+ * @param {{ strength?: number, speed?: number, duration?: number }} [opts]
46
+ * @returns {void}
47
+ */
48
+ ripple(position: PositionLike, opts?: {
49
+ strength?: number;
50
+ speed?: number;
51
+ duration?: number;
52
+ }): void;
39
53
  set material(m: THREE.Material);
40
54
  /**
41
55
  * Water material, shared by all water. Reading gives the plain three.js material in use (a neutral MeshLambertMaterial until you set one); setting swaps it on every
@@ -74,4 +88,5 @@ import type { WaterOptions } from '../../../world';
74
88
  import type { ModuleDef } from '../../../core';
75
89
  import * as THREE from 'three';
76
90
  import type { WaterBody } from '../../../world';
91
+ import type { PositionLike } from '../../../common';
77
92
  import type { WaterShaderOptions } from '../../../world';
@@ -3,6 +3,11 @@
3
3
  * World data module: installed as engine.world. Put things here that must be saved, survive level changes and keep changing while far away; models are only built while nearby
4
4
  * @example engine.use(world())
5
5
  * @param {{ cellSize?: number, radius?: number, farEvery?: number, farMaxPerTick?: number, buildPerFrame?: number }} [opts]
6
+ * cellSize: spatial hash cell size in meters (default 32);
7
+ * radius: distance in meters around the stream source for presenting models and running near simulation (default 60);
8
+ * farEvery: seconds between far-record simulation ticks (default 1);
9
+ * farMaxPerTick: maximum far records updated per simulation tick (default 128);
10
+ * buildPerFrame: maximum new view models built per frame (default 4).
6
11
  * @returns {import('../../../core').ModuleDef<World>}
7
12
  */
8
13
  export function world(opts?: {
@@ -7,6 +7,11 @@
7
7
  * @experimental
8
8
  */
9
9
  export function materialPatches(material: THREE.Material): string[];
10
+ /**
11
+ * Clone a material keeping engine shader patches and instance hooks (`material.clone()` drops them).
12
+ * @template {Material} M @param {M} from @returns {M}
13
+ */
14
+ export function cloneMaterial<M extends THREE.Material>(from: M): M;
10
15
  /**
11
16
  * code for one anchor (a plain string goes after the include;
12
17
  * replace swaps the include itself for new code, one patch per anchor)
@@ -369,14 +369,20 @@ export interface Rideable {
369
369
  // Skeletal animation state machine Animator (returned by engine.assets.animate)
370
370
  // ======================================================================
371
371
 
372
+ /** Root motion config: true (auto-detect root/hips bone, lock X/Z), bone name, or { bone?, y? } (y: true also locks and extracts vertical delta) */
373
+ export type RootMotionOption = boolean | string | { bone?: string; y?: boolean };
372
374
  /** 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 */
373
375
  export interface AnimatorState {
374
376
  /** Clip name (the clip name in the glTF) */
375
377
  clip?: string;
376
378
  /** 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 }] */
377
379
  blend?: { clip: string; at: number }[];
378
- /** Which parameter the blend tree reads (set by anim.set), default 'speed' */
380
+ /** 2D directional blend space (polar Gradient Band Interpolation), e.g. 4-way or 8-way strafing across [moveX, moveZ] */
381
+ blend2d?: { clip: string; at: readonly [number, number] | [number, number] }[];
382
+ /** Which parameter the 1D blend tree reads (set by anim.set), default 'speed' */
379
383
  param?: string;
384
+ /** Which [x, z] parameter pair blend2d reads, default ['moveX', 'moveZ'] (updated automatically on Character) */
385
+ params?: readonly [string, string] | [string, string];
380
386
  /** Align the strides of blended clips, default true */
381
387
  sync?: boolean;
382
388
  /** Loop, default true; with false the anim:end event fires when it finishes */
@@ -390,6 +396,8 @@ export interface AnimatorState {
390
396
  * [[gameT, clipT], ...] = piecewise linear (land the swing on the hit phase). Without it clip seconds = t
391
397
  */
392
398
  timing?: number | [number, number][];
399
+ /** 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 */
400
+ rootMotion?: RootMotionOption;
393
401
  }
394
402
  /** What an Animator is showing (anim.describe(), describe().player.anim) */
395
403
  export interface AnimatorInfo {
@@ -406,6 +414,10 @@ export interface AnimatorInfo {
406
414
  t?: number;
407
415
  /** Share of each fading state (sums to 1) */
408
416
  weights: Record<string, number>;
417
+ /** Active masked animation layers (anim.addLayer) */
418
+ layers?: { name: string; state: string | null; weight: number; bones: number }[];
419
+ /** Active IK layers (anim.addAim / addFeet / addLimb) */
420
+ ik?: IkLayerInfo[];
409
421
  }
410
422
  /** Animation state machine parameters */
411
423
  export interface AnimatorOptions {
@@ -417,12 +429,35 @@ export interface AnimatorOptions {
417
429
  transitions?: Record<string, number>;
418
430
  /** Initial parameter values */
419
431
  params?: Record<string, number>;
432
+ /** Default root motion setting for all states (overridable per state): true, bone name, or { bone?, y? } */
433
+ rootMotion?: RootMotionOption;
420
434
  }
421
- /** Where a look-at layer looks: an object, a point, [x, y, z] (exactly three numbers, as ik.js checks), or null to look ahead */
435
+ /** Where a look-at or limb IK layer reaches: an object, a point, [x, y, z], or null to fade out */
422
436
  export type AimTarget = Object3D | Vector3 | [number, number, number] | null;
423
- /** What an IK layer reports (anim.addAim / addFeet handles) */
437
+ /** Bone mask selector for anim.addLayer */
438
+ export type BoneMaskSpec = 'upper' | 'lower' | string | string[] | { include: string | string[]; exclude?: string | string[]; subtree?: boolean };
439
+ /** Options of anim.addLayer */
440
+ export interface MaskLayerOptions {
441
+ name?: string;
442
+ mask?: BoneMaskSpec;
443
+ states?: Record<string, AnimatorState>;
444
+ transitions?: Record<string, number>;
445
+ weight?: number;
446
+ fade?: number;
447
+ }
448
+ /** Handle returned by anim.addLayer */
449
+ export interface MaskLayer extends Handle {
450
+ readonly name: string;
451
+ readonly state: string | null;
452
+ go(state: string | null, opts?: { fade?: number }): any;
453
+ action(name: string, opts?: { fade?: number }): any;
454
+ sync(state: string | null, t?: number): any;
455
+ set(opts: { weight?: number; fade?: number }): MaskLayer;
456
+ describe(): { name: string; state: string | null; weight: number; bones: number };
457
+ }
458
+ /** What an IK layer reports (anim.addAim / addFeet / addLimb handles) */
424
459
  export interface IkLayerInfo { kind: string; bones: string[]; weight: number }
425
- /** A look-at layer (anim.addAim): set() takes what addAim took except bones and forward, which are fixed when it is made; remove() puts the pose back at once */
460
+ /** A look-at layer (anim.addAim): set() takes what addAim took except bones, weights and forward, which are fixed when it is made; remove() puts the pose back at once */
426
461
  export interface AimLayer {
427
462
  set(opts: { target?: AimTarget; limit?: number; speed?: number; weight?: number; fade?: number }): AimLayer;
428
463
  remove(): void;
@@ -430,7 +465,13 @@ export interface AimLayer {
430
465
  }
431
466
  /** A feet layer (anim.addFeet): set() takes what addFeet took except legs and hips, which are fixed when it is made; remove() puts the pose back at once */
432
467
  export interface FeetLayer {
433
- set(opts: { reach?: number; far?: number; speed?: number; weight?: number; fade?: number; ground?: (x: number, z: number, y: number) => number }): FeetLayer;
468
+ set(opts: { reach?: number; far?: number; speed?: number; weight?: number; fade?: number; alignSlope?: boolean; maxTilt?: number; footOffset?: number; ground?: (x: number, z: number, y: number) => number }): FeetLayer;
469
+ remove(): void;
470
+ describe(): IkLayerInfo;
471
+ }
472
+ /** A two-bone limb IK layer (anim.addLimb): reaches a hand or foot toward target */
473
+ export interface LimbLayer {
474
+ set(opts: { target?: AimTarget; pole?: AimTarget; alignRotation?: boolean | import('three').Quaternion | [number, number, number, number]; weight?: number; fade?: number; speed?: number }): LimbLayer;
434
475
  remove(): void;
435
476
  describe(): IkLayerInfo;
436
477
  }
@@ -460,6 +501,12 @@ export declare class Animator {
460
501
  * The clip never advances or ends by itself and go() leaves it alone; sync(null) hands control back
461
502
  */
462
503
  sync(state: string | null, t?: number): any;
504
+ /**
505
+ * Deterministic root motion delta over gameplay interval [fromT, toT], sampled directly from the clip's position VectorKeyframeTrack
506
+ * (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
507
+ * @example const d = anim.rootDelta('roll', prevT, t, { yaw: ch.facing });
508
+ */
509
+ rootDelta(state: string, fromT: number, toT: number, opts?: { yaw?: number; local?: boolean; y?: boolean; out?: { x: number; y: number; z: number } }): { x: number; y: number; z: number };
463
510
  /** What is showing: state, clip, clip time, progress, driven, weights */
464
511
  describe(): AnimatorInfo;
465
512
  /**
@@ -470,15 +517,25 @@ export declare class Animator {
470
517
  /**
471
518
  * 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.
472
519
  * 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)
473
- * @example const look = npc.anim.addAim({ bones: ['Neck', 'Head'], target: engine.player.root, limit: 70 });
520
+ * @example const look = npc.anim.addAim({ bones: ['Spine', 'Neck', 'Head'], weights: [0.2, 0.3, 0.5], target: engine.player.root, limit: 70 });
474
521
  */
475
- addAim(opts: { bones: string | string[]; target?: AimTarget; limit?: number; speed?: number; weight?: number; fade?: number; forward?: [number, number, number] }): AimLayer;
522
+ addAim(opts: { bones: string | string[]; weights?: number[]; target?: AimTarget; limit?: number; speed?: number; weight?: number; fade?: number; forward?: [number, number, number] }): AimLayer;
476
523
  /**
477
524
  * 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,
478
- * beyond far from the camera, while hidden); the hips lower for the foot that reaches down. legs: bone names when they are not recognised
525
+ * beyond far from the camera, while hidden); the hips lower for the foot that reaches down and ankles tilt onto slopes (alignSlope, maxTilt).
479
526
  * @example const feet = engine.player.anim.addFeet();
480
527
  */
481
- addFeet(opts?: { legs?: string[][]; hips?: string; reach?: number; far?: number; speed?: number; weight?: number; fade?: number; ground?: (x: number, z: number, y: number) => number }): FeetLayer;
528
+ addFeet(opts?: { legs?: string[][]; hips?: string; reach?: number; far?: number; speed?: number; weight?: number; fade?: number; alignSlope?: boolean; maxTilt?: number; footOffset?: number; ground?: (x: number, z: number, y: number) => number }): FeetLayer;
529
+ /**
530
+ * 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]).
531
+ * @example const grip = anim.addLimb({ limb: 'leftArm', target: foregrip, alignRotation: true });
532
+ */
533
+ addLimb(opts: { bones?: (string | Object3D)[]; limb?: 'leftArm' | 'rightArm' | 'leftLeg' | 'rightLeg'; target?: AimTarget; pole?: AimTarget; alignRotation?: boolean | import('three').Quaternion | [number, number, number, number]; weight?: number; fade?: number; speed?: number }): LimbLayer;
534
+ /**
535
+ * Bone-mask animation layer (e.g. mask: 'upper' to swing a sword or aim while legs keep running/strafing).
536
+ * @example const upper = anim.addLayer({ mask: 'upper', states: { slash: { clip: 'Sword_Slash', loop: false } } });
537
+ */
538
+ addLayer(opts?: MaskLayerOptions): MaskLayer;
482
539
  /** Stop the per-frame update when no longer needed */
483
540
  dispose(): void;
484
541
  }
package/types/tsl.d.ts CHANGED
@@ -131,6 +131,8 @@ declare module 'three/src/lights/LightShadow.js' {
131
131
  * @experimental
132
132
  */
133
133
  export function waterWave(p: Node, t: Node | number): Node;
134
+ /** Concentric expanding wave-packet sum over the water ripple slots (0 when count <= 0.5) @experimental */
135
+ export function waterRipple(xz: Node, count: Node | number, slots: Node[]): Node;
134
136
  /**
135
137
  * The built-in water surface as TSL: returns a function with the GLSL signature threedogWaterSurface(base, wave, facing, worldPos, time) -> vec4 (rgb, opacity).
136
138
  * Only the parts given exist (depth: shallow / deep by viewing angle or wave height; foam on crests); values are numbers / colors or nodes.
package/types/world.d.ts CHANGED
@@ -880,6 +880,8 @@ export interface WaterOptions {
880
880
  size?: number;
881
881
  /** Mesh subdivision of the global water, default 150 */
882
882
  segments?: number;
883
+ /** Automatic wading wakes and raindrop rings, default true */
884
+ ripples?: boolean;
883
885
  // Picture values are not options: water({ color }) throws naming where each is written on engine.water (recipes/44)
884
886
  }
885
887
 
package/ui/Parts.js CHANGED
@@ -46,7 +46,8 @@ export class UIParts {
46
46
  * @param {import('../types/core').UIOptions} [ui] createEngine({ ui }): theme and css are applied by ui/theme.js, every other key names a part
47
47
  * @internal
48
48
  */
49
- constructor(engine, { theme, css, fonts = [], templates = {}, ...parts } = {}) {
49
+ constructor(engine, ui = {}) {
50
+ const { fonts = [], templates = {} } = ui;
50
51
  this.engine = engine;
51
52
  /** Window content by name, read each time a window draws: (data, { esc, t, icon }) => HTML replaces the default layout. Plain and writable @type {Record<string, import('../types/core').UITemplate>} */
52
53
  this.templates = templates;
@@ -57,7 +58,7 @@ export class UIParts {
57
58
  /** @internal name -> { focus } while a full-screen part is open */ this.opened = new Map();
58
59
  /** @internal hide() promises still fading out (see settled) */ this._fading = new Set();
59
60
  /** @internal id -> title screen item a module added (titleItem) */ this.titleItems = new Map();
60
- for (const [k, v] of Object.entries(parts)) this.set(k, v);
61
+ for (const [k, v] of Object.entries(ui)) if (k !== 'theme' && k !== 'css' && k !== 'fonts' && k !== 'templates') this.set(k, v);
61
62
  }
62
63
 
63
64
  /**
@@ -1,39 +0,0 @@
1
- # Moving a game from 0.6 to 0.7
2
-
3
- ## Light probes: every pixel takes its own light
4
-
5
- `engine.bakeProbes` now builds three's probe grid, so the one scene light that followed a point is gone. Bake or load the same way; lit materials pick the grid up by themselves.
6
-
7
- | 0.6 | 0.7 |
8
- |---|---|
9
- | `bakeProbes({ follow })`, `loadProbes(json, { follow })` | delete it: every pixel inside the grid has its own light |
10
- | `bakeProbes({ height: 1.5 })` (one layer over the ground) | `bounds` around the ground and the air above it; a grid is a box, and needs 2 layers an axis |
11
- | `probes.probe`, `probes.own()` | `probes.grid`, a plain three.js light; a light of your own from `probes.sample(pos, myProbe)` as before |
12
- | `probes.probe.intensity` | `probes.grid.intensity` on WebGPU; on WebGL three ignores it, so change the light you bake, or the exposure |
13
- | a probe file from 0.6 (version 1) | refused with `probes-data`: bake again (the file is now half precision, about a third of the size) |
14
- | objects anywhere got the light of the follow point | outside the grid there is no probe light: size `bounds` to the scene (`describe().render.probes.outside`) |
15
-
16
- ## Removed from the public surface
17
-
18
- | 0.6 | 0.7 |
19
- |---|---|
20
- | `engine.level.object` | `engine.level.root` (the same object) |
21
- | `engine.inventory.defs` | `engine.inventory.item(id)` for one definition; not in the types any more |
22
- | `engine.quests.defs` | `engine.quests.list()`; not in the types any more |
23
- | `engine.triggers.action`, `engine.settings.action`, `engine.interactions.action` | the option you passed to `triggers()`, `settings()`, `interactions()` |
24
-
25
- ## Follow camera and characters
26
-
27
- | 0.6 | 0.7 |
28
- |---|---|
29
- | `collision({ cameraOcclusion })` defaulted to colliders only | the default is `'both'`: meshes added with `engine.rays.addStatic(mesh, { occluder: true })` and level buildings stop the camera arm too; `cameraOcclusion: 'colliders'` keeps the old test |
30
- | `character.placeAt` over a prop or platform ignored it | it stands on a registered support (recipe 32 says what a support needs) |
31
- | `mover: 'manual'` skipped the `states` hook | it runs the `states` hook (recipe 57, "Moved by script") |
32
-
33
- ## Layers 26 to 29 and 31 are reserved
34
-
35
- The engine keeps these three.js layers for itself (`RESERVED_LAYERS` from `threedog/layers`). A game's own layers are 1 to 25; move anything of yours on layers 26 to 28 down. Layer 30 stays the default camera `hideLayer`.
36
-
37
- ## Starting a game
38
-
39
- `threedog new-game --example` and `templates/example` are gone: start from `new-game` itself, and read the engine's `examples/` for finished techniques.
@@ -1,171 +0,0 @@
1
- # Moving a game from 0.7 to 0.8
2
-
3
- npm never had 0.7.1, so this page goes from 0.7.0 straight to 0.8.0.
4
-
5
- First run `threedog doctor --fix`: it rewrites the `threedog` and `@threedog/*` pins in each game's `package.json`. A game in `games/` of a clone that still pins `^0.7.1` stops `npm install` with `ETARGET`.
6
-
7
- Names were settled before 1.0: a few were removed, a few renamed. Nothing below keeps working under its old name. A stale uniform name in shader text reads 0 with no error and no warning, so search for the old names below.
8
-
9
- ## Uniforms
10
-
11
- Search your shader strings as well as your JavaScript.
12
-
13
- | 0.7 | 0.8 |
14
- |---|---|
15
- | `engine.uniforms.uCloudScale` | `uCloudShadowScale` (the cloud shadows on the ground) |
16
- | `engine.uniforms.uCloudSpeed` | `uCloudShadowSpeed` |
17
- | `uCloud` | `uWeatherCloud` |
18
- | `uCurve` | `uSkyCurve` |
19
- | `uCover` | `uGroundCover` |
20
- | `uSunPower` | `uSunBrightness` |
21
- | `uMoonPower` | `uMoonBrightness` |
22
- | `uCloudScale`, `uCloudSpeed` on `engine.sky.uniforms`, or in `engine.sky.clouds()` and dome layer GLSL | `uSkyCloudScale`, `uSkyCloudSpeed` (the dome's clouds, the same names as on `engine.uniforms`) |
23
-
24
- The same names apply to `uniforms(engine)` from `threedog/tsl`, `c.fx.uniform('...')`, and `#include <threedog_uniforms>`. A patch that brings its own uniform called `uCover` is yours and is left alone.
25
-
26
- ## Changed shapes
27
-
28
- These do not fail loudly, so search for them.
29
-
30
- | 0.7 | 0.8 |
31
- |---|---|
32
- | `const key = bag.add(id)`; `false` when full | `const r = bag.add(id)`: `{ ok: true, key, added }`, or `{ ok: false, code: 'full', facts }`. The result is always an object, so `if (bag.add(id))` is now `if (bag.add(id).ok)` |
33
- | `clock.after(s, 'ev', data, { channel })` | `clock.after(s, 'ev', { data, channel })`, the same third argument as `clock.every`. The old form throws |
34
- | `player.onStep = type => ...` | `engine.events.on('character:step', ({ character }) => ...)`, ground from `character.groundType()`. Assigning the old property does nothing and says nothing, so search for it |
35
- | `player.onLand = impact => ...` | `engine.events.on('character:land', ({ character, impact }) => ...)`. Assigning the old property does nothing and says nothing, so search for it |
36
- | `grids.get(name)`, `inventory.get(key)`, `container.get(key)`, `interactions.get(id)` return `null` when there is none | `undefined`, like every other `get`; a test `=== null` no longer matches, use `!x` |
37
- | `settings({ presets: { high: { pixelRatio: 1.5 } } })`: a fixed ratio | A share from 0 to 1 of the ratio the engine picked for this device (`high: { pixelRatio: 1 }`); above 1 throws `module-params`. For a fixed ratio call `engine.setPixelRatio` |
38
- | `settings.values` was the stored object; `settings.get('pixelRatio')` kept the last number set | `settings.values` is a read-only copy, change a value with `settings.set`; `pixelRatio` is the renderer's real ratio, the same as `describe().render.scale.current` |
39
- | `mesh.visible` on a registered hlod mesh read `false` while far | It is your own value near and far. To ask whether the camera draws it: `mesh.layers.test(engine.camera.layers)` |
40
- | `await engine.applyState(...)` resolved to nothing, and rejected for `season` with no calendar or an `at` nothing knows | It resolves to `{ ok, refused: [{ key, value, reason }] }`: read `refused`. A `fresh`, `wait` or `pos` it cannot read throws `state-value` |
41
-
42
- ## Removed names
43
-
44
- | 0.7 | 0.8 |
45
- |---|---|
46
- | `engine.rays.cast(...)`, `engine.rays.pick(...)` | `engine.raycast(...)`, `engine.pick(...)` |
47
- | `engine.THREE` | `import { THREE } from 'threedog'`, the same copy of three.js. |
48
- | `model.userData.animations` | `model.animations`, three's own place: `model.clone()` keeps it, where `userData` broke the clips. Clips you add by hand go there too. |
49
- | `engine.i18n.t(key)` | `engine.t(key)` |
50
- | `inventory.slotsUsed` | `inventory.of().slotsUsed` |
51
- | `engine.openWindows` | `engine.ui.isOpen(id)` |
52
- | `engine.decoders` | set it with `createEngine({ decoders })`; it can no longer be read back |
53
- | `EASINGS` | `ease(name)` |
54
- | `assets.reportText(name)` | `assets.report(name)` |
55
- | `assets.users(name)` | no replacement: it was internal |
56
- | `player.object`, `character.object` | `.root`, the same object (`npc.object` stays) |
57
- | `character.addTo()` | `engine.add(character.root)` for a `new Character` of your own; `addPlayer` still adds the player |
58
- | `engine.rigid.R` | `engine.rigid.rapier` |
59
- | `collision.circles`, `collision.boxes` | `collision.forEachStatic((type, data) => ...)` |
60
- | `engine.stream.readyCheck(name, fn)` | `engine.stream.addReadyCheck(name, fn)` |
61
- | `engine.music.addTracks({ a: url, b: url })` | `engine.music.define('a', url)`, one call per track; it no longer returns the music object |
62
- | `debug.startBench()`, `debug.benchmarking`, the debug panel's stress button, `describe().debugPanel.benchmarking` | `threedog stress` |
63
- | The types `Object3D`, `Vector3`, `Vector2`, `Color`, `Quaternion`, `Material`, `BufferGeometry`, `Texture` from `threedog` | import them from `three` |
64
- | `threedog assets` with no verb | `threedog assets optimize` (it writes files) or `threedog assets check`. `npm run assets` becomes `npm run assets -- optimize` |
65
- | `threedog doctor --json`: `{ healthy, items: [{ status, msg, fix }], render }` | `{ ok, summary, items: [{ level, message, fix }] }`, the shape of `check --json`. Items are the problems (`error`) and info lines (`warn`); passed lines are left out; `summary` says whether a hardware GPU is reachable |
66
- | `engine.tick` | `engine.time.tick` |
67
- | `engine.cpuMs`, `engine.cpuPhases` | `engine.inspect.perf()` (`cpuMs`, `cpuPhases`), `engine.budget.values().cpuMs` |
68
- | `saves.queue(fn)` | `saves.putAttachment(group, id, blob, meta)`, `saves.removeAttachment(group, id)`; read with `saves.attachments(group)` |
69
- | `saves.prefix` | `saves.storageKey(name)` for a key of your own |
70
- | `userData.rayVisible = true` on a hidden object | Leave `visible` alone and put the mesh on `RESERVED_LAYERS.batched` (`threedog/layers`): not drawn, no shadows, still hit by `engine.raycast` |
71
- | `engine.adaptive.paused` | `engine.adaptive.on = false` |
72
- | `settings.removeSection(id)` | List the tabs you want: `settings({ sections: [...] })` |
73
- | `sky({ moonSize })`, `sky({ starScale })`, `sky({ gradientCurve })`, `sky({ orbitTilt })`, `sky({ orbitSway })` | Write `engine.uniforms.uMoonSize.value`, `uStarScale.value`, `uSkyCurve.value`, `engine.sky.orbit.tilt`, `engine.sky.orbit.sway` (plain values after `engine.use(sky())`; defaults unchanged) |
74
- | `saves.define(key, { movedFrom })` | No replacement. Only the calendar used it: the time and day of a 0.2 save, kept under the old `sky` part, are no longer read, and such a save starts from `calendar({ time })` |
75
- | The old keys of `sky()` and `water()` (`sky({ fog })`, `sky({ sun })`, `sky({ layers })`, `sky({ dayLength })`, `water({ color })`, `water({ glsl })` and the like) | They are ordinary unknown options now: an error with a did-you-mean in development, one warning in a build. Recipes 08, 44 and 62 say where each value lives |
76
- | `calendar.daysPerSeason` (the field) | Nothing read it and writing it did nothing. The option `calendar({ daysPerSeason })` stays |
77
- | `ground.navGeometry` on a ground API of your own | Nothing read it: the navmesh comes from `staticTrimeshes()` |
78
- | `settings.saved` | No replacement: nothing read it |
79
- | `withHint` from `threedog/error-hints` | `hintText` |
80
- | `threePatches.off('hlod-visible')` | The patch is gone: `hlod` hides a far original on the batch layer |
81
- | `threedog bake light --spacing` | The bake traces rays now, so the option is gone, and `--samples` means rays per texel (default 128). Bake again and compare |
82
-
83
- ## Renamed
84
-
85
- The table below keeps every rename; `engine.page.held` and `describe().page.held` are removed: ask `engine.frozen`, or `engine.stacks.get('freeze').has('page')` for this one holder. A page hold is now a plain freeze by owner `'page'`, so cutscene tweens and `runState` obey it, and `engine.step()` on a page in the background needs the loop stopped first, as the dev bridge already does.
86
-
87
- | 0.7 | 0.8 |
88
- |---|---|
89
- | `hud.add(id, n)` | `hud.bump(id, n)` |
90
- | `dialogue.cps` | `dialogue.charsPerSecond` (the option already had this name) |
91
- | `rtsCamera({ angle })`, `cameraRig.angle` under that camera | `pitch`, as on the other cameras; `angle` is now refused as an unknown option |
92
- | `weather.define(field, spec)` | `weather.defineField(field, spec)` |
93
- | `terrain.T` | `terrain.generator` |
94
- | `terrain.CHUNK` | `terrain.chunkSize` (`createTerrain()` keeps its own `CHUNK`) |
95
- | `engine.pause(owner)` | `engine.haltLoop(owner)`, for tests and tools. It stops rendering too, so a game that wants to pause uses `engine.freeze` or flow `'paused'`. The `{ kind: 'test' }` option is gone |
96
- | `engine.paused`, `describe().time.paused` | `engine.halted`, `describe().time.halted` |
97
- | `engine.mod('pause', ...)`, `describe().holds.pause` | `engine.mod('halt', ...)`, `describe().holds.halt` |
98
- | `runState.state` `'test-paused'`, `'paused'` | `'halted'` (the loop is stopped), `'frozen'` (a game, page or error freeze) |
99
- | `engine.terms`, `terms.cloudShadow`, `terms.season` | `engine.shaderTerms`, with the same two members |
100
- | `engine.view`, `view.manual` | `engine.autoView`, `autoView.manual` |
101
- | `lightPool.usage()` | `engine.describe().lightPool` |
102
- | `terrain.isReadyAround(p)`, `rigid.groundReady(p)` | `engine.stream.addReadyCheck` and `stateApplied` already wait on them |
103
-
104
- ## Error codes
105
-
106
- Search any `e.code === '...'` or `catch` in your game, and any test that names a code.
107
-
108
- | 0.7 | 0.8 |
109
- |---|---|
110
- | `options-object` | `bad-position` |
111
- | `npc-option` | `character-option` |
112
- | `pickup-prop-id` | `world-id` |
113
- | `session-handle` | `module-handle` |
114
- | `world-missing` | `module-needs` |
115
- | `load-failed` | `asset-load` |
116
- | `pause-owner` | `halt-owner` |
117
- | `bad-arg` | Gone: `input.bind` raises `input-keys`, `characters.support` raises `character-option`, `settings({ presets })` raises `module-params` |
118
- | `state-at` | Gone: `applyState` lists the value in `refused` |
119
- | `renamed-field`, `shadow-type` | Gone, nothing raises them: the old names they caught are plain unknown options now |
120
- | `engine.stacks.define` of a known name raised `mod-owner` | `engine-misuse` |
121
- | `weather.set` with bad seconds raised `module-params` | `weather-option` |
122
- | `interaction.use` answered `noKey` | With no key it runs when code asks, `ops.list({ available: true })` leaves it out, and `interaction-no-key` is a dev warning. Code that read `noKey` reads `engine.input.isUnbound(action)` |
123
- | `ground-missing` threw (a prop, spawn or `snapToGround` beyond `terrain({ shape })`) | A warning, and the safe fallback runs: a `catch` for it no longer fires |
124
-
125
- These used to throw and now warn once in dev and go on: `engine.wrap` on a `_private` method, `createEngine({ fallback })` without WebGPU, a vegetation `rule` beside `positions`, `ui.theme.promptHeight`, a module going against its `type`, `engine.sky.environment()` called twice (the second replaces the first), and `sky({ time })` with a calendar.
126
-
127
- ## Behaves differently
128
-
129
- No error tells you about these.
130
-
131
- | 0.7 | 0.8 |
132
- |---|---|
133
- | Physics ran at full speed under `engine.mod('time.world', ...)` | Rigid bodies and vehicles follow the `world` channel, and a hit-stop at speed 0 holds them. To keep them at full speed, slow a channel of your own |
134
- | `engine.freeze(owner, { ambient: true })` left skeletal animation and particles moving | A real still: they stop with `uTime`. A plain freeze keeps them moving as before |
135
- | `engine.batching` cell 64 m | 256 m, about 13-25% more triangles drawn. A game with heavy props sets `createEngine({ batching: { cell: 64 } })` |
136
- | `engine.remove` disposed a shared geometry or material at once | It disposes with the last user. Code that relied on the old timing disposes it itself |
137
- | `engine.stream` unloaded in the same frame | Through `engine.jobs`, so an entry out of range can stay a few frames longer in the real-time loop; `engine.step` still finishes in the frame |
138
- | A low-tier device lowered `particles.define` `max`, `weather({ particles })`, a weather `count` and `sky.environment({ interval })` | It changes defaults only: these stand as the game gave them |
139
- | A skybox reached full brightness at ambient 1.2 | At the brightest row of the game's keyframes |
140
- | `engine.setPixelRatio(p)` was undone by adaptive resolution within two minutes | It is the top adaptive climbs back to; adaptive may still lower it under load |
141
- | Settings stored every value | Only what the player changed, with a preset stored by name. Stored files of version 1 are read: a value equal to the default lets go |
142
- | `music.play`, `music.stinger`, `hud.counter`, `hud.bar`, `calendar.at`, `calendar.daily`, `calendar.between`, `vegetation.removeInstance` ignored an unknown option | They throw on it |
143
- | A class instance in a saved `world` record (`Vector3`, `Color`, `Map`) failed after a load | It throws `world-plain` in dev at `world.add` / `world.set`. Write `{ x, y, z }`, or add the record with `{ save: false }`. `position` stays free |
144
- | A direct write to `engine.sky.sunDir` was undone on the next frame | It is the same vector as `engine.uniforms.uSunDir` and the write stays; `engine.autoView.manual('sunDir', false)` gives it back |
145
- | An `approach` interaction on a held character walked or hung | Refused with `cannotWalk` |
146
- | `characters.findPath` with no navmesh routed to a target inside a wall or water | `null` (`noPath` when detailed) |
147
- | `hud.counter` with no label showed the id | The value alone |
148
- | A quest reward that threw stopped the rest of the list | `content.run` runs every effect, rethrows the first error, and the quest still finishes |
149
- | `inspect.perf()` on a halted page read `cpuMs` and `fps` as 0 | `null`, and `measured` says whether anything was counted |
150
- | Two manifest entries naming each other as `fallback` waited for good | The load fails once with `asset-fallback-cycle`, naming the chain |
151
- | An awaited `model()`, `texture()` or `font()` could reject or resume while the engine was disposed | The promise stays pending for good, and so does any later call: put teardown work in your dispose path, not after the `await` |
152
- | A load ended by `release`, `trim`, a palette write or registering the name again could write its result back | Its result is freed when it arrives; code awaiting it gets a fresh load |
153
- | `release('shrub')` on a name that fell back to `rock` touched `rock`'s data | A name that fell back holds no data: release `rock` |
154
- | A mesh dropped while its material stayed in use held memory on WebGPU | The engine sweeps these every few seconds, so calls you added to work around it can go; `threePatches.off('webgpu-record-sweep')` turns it off |
155
-
156
- ## Tools
157
-
158
- | 0.7 | 0.8 |
159
- |---|---|
160
- | `assets optimize` put the optimized pack anywhere in `assets.js` | It comes last, so `/optimized/x.glb` wins over an original of the same name; the next run moves an older game over |
161
- | `assets optimize --strict` or a lower `--budget` skipped cached models | Cached models count, so a run that passed may now fail |
162
- | `check` passed a kind in `content/index.js` listed without `rules` | An error |
163
- | `check` in a game failed on file size, its own docs, a stale GAMEMAP, a module with no key, or startup creation | Warnings: a CI step that relied on one reads the warnings. New rules: R52 (captured twice), R53 (merge conflict markers in a tracked file) |
164
- | `state`, `step`, `hold`, `press` and scenarios reported success when they did less | They fail with the reason and exit 1: a refused state, seconds that did not pass, a stopped engine |
165
- | `shot` and `capture` ignored a value the page refused (`--weather rian`) | They fail |
166
- | `threedog state` and `threedog snap` added a tick or two | They move no game time, so a script that counted on it steps itself |
167
- | `lib pull` copied an entry the game's renderer cannot draw | Refused, nothing copied; `--force` copies it to port by hand, and `lib check` fails until it is ported |
168
-
169
- ## Stability
170
-
171
- `@experimental` now means one thing everywhere: the name may change or go in any version with no migration note. See "Stability" in `CONVENTIONS.md` for the list. Nothing stops working, but do not build a save format on a marked name. The printed text of commands was never an interface: read `--json`.
@@ -1,10 +0,0 @@
1
- // Rapier 0.21 keeps its query structures in the broad phase, and only a step rebuilds them: World has no updateSceneQueries and no query pipeline, and
2
- // propagateModifiedBodyPositionsToColliders moves colliders without touching the broad phase. So a frozen engine refreshes with a step of no time, here and nowhere else.
3
- // Twice: the first leaves a moved body's collider in the old place, the second catches it up. Tools test `rapier refresh` holds each of these, per Rapier version.
4
-
5
- /** @internal Rebuild what queries read and nothing else (velocities, positions, sleep and contacts stay); the step length comes back even if Rapier throws */
6
- export function refreshQueries(world) {
7
- const dt = world.timestep;
8
- world.timestep = 0;
9
- try { world.step(); world.step(); } finally { world.timestep = dt; }
10
- }