avbd-babylon 0.4.1 → 0.4.3

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.
@@ -45,6 +45,10 @@ export interface AvbdWorldOptions {
45
45
  solverMode?: AvbdSolverMode;
46
46
  /** Automatically batch a closed jointless world of up to 32 bodies. */
47
47
  smallGroups?: boolean;
48
+ /** Advanced: reserve 0–64 parallel solve groups for dense or waking contacts. */
49
+ minimumColors?: number;
50
+ /** Advanced: minimum coloring rounds, an even integer from 0–32. */
51
+ minimumColorRounds?: number;
48
52
  bvh?: { rebuildInterval?: number };
49
53
  /** Optional GPU sleeping. Large worlds wake conservative connected groups on impact. */
50
54
  sleeping?: boolean | AvbdSleepOptions;
@@ -242,7 +242,9 @@ export interface AvbdGpuParameters2D extends AvbdGpuParameters {
242
242
  }
243
243
  /** 3D tracks current awake groups and retains sleeping support connections. */
244
244
  export interface AvbdSleepOptions {
245
+ /** Combined linear and radius-scaled angular motion, world units/second. Default 0.03. */
245
246
  speedThreshold?: number;
247
+ /** Seconds continuously below the speed threshold while supported. Default 0.5. */
246
248
  timeThreshold?: number;
247
249
  /** 3D: automatic for large desktop worlds; false selects whole-world waking. */
248
250
  islands?: boolean;
@@ -81,6 +81,12 @@ compatibility. These names identify internal implementations, not quality
81
81
  levels or paper results. Overrides preserve live GPU state; first use may
82
82
  compile pipelines. Start with the automatic default.
83
83
 
84
+ For dense piles that gain many dynamic contacts at once, `minimumColors` reserves
85
+ parallel solve groups (integer 0–64) and `minimumColorRounds` reserves coloring
86
+ rounds (even integer 0–32). Pass them to `AvbdPhysics.create()` before initialization.
87
+ The mixed collider gallery uses `32` for both. These control work scheduling;
88
+ they do not change solver iterations or contact equations.
89
+
84
90
  Box, sphere and capsule collisions are native. Capsules use an exact rounded
85
91
  segment along local Y; height includes both caps and X/Z diameters must match.
86
92
  `CYLINDER` and `CONVEX_HULL` use a polygonal convex hull, with a 32-vertex limit. Mesh geometry,
@@ -147,7 +153,13 @@ reserve storage; `readContactEvents()` reports dropped events or a full pair
147
153
  table. End events do not retain an old position. Callbacks run asynchronously.
148
154
 
149
155
  `sleeping: true` or `{ speedThreshold: 0.03, timeThreshold: 0.5 }` enables an
150
- optional GPU policy. Supported quiet bodies sleep. Large desktop 3D worlds
156
+ optional GPU policy. Supported quiet bodies sleep. Speed combines translation
157
+ and radius-scaled rotation in world units/second; `0.03` is 3 cm/second if units
158
+ are meters. The quiet timer resets above that speed. Thresholds remain manual
159
+ so applications can choose values appropriate to their size and camera distance.
160
+ Sleeping preserves the body's physical mass while skipping its movement solve;
161
+ impacts and support removal restore dynamic participation.
162
+ Large desktop 3D worlds
151
163
  automatically wake conservative connected groups on impact, keeping unrelated
152
164
  piles asleep; the shared static floor does not join them. `islands:true` opts
153
165
  into group waking in smaller worlds, and `islands:false` selects whole-world
@@ -155,8 +167,10 @@ waking. Awake groups rebuild their connections from current contacts; sleeping
155
167
  groups retain the support connections omitted by collision detection. A group
156
168
  settles together after its eligible members stay quiet, so sleeping one course
157
169
  does not repeatedly disturb the courses above it. Contact waking checks closing
158
- speed at each contact point, including rotation. Updating a grab anchor wakes
159
- the held body; ordinary edits and changes to supports wake the world.
170
+ speed at each contact point, including rotation. Adding or removing constraints
171
+ and updating a grab anchor wake their endpoints and sleeping connected groups;
172
+ unrelated groups stay asleep. Ordinary body edits and changes to supports wake
173
+ the world. A connected group can stay awake while any member moves or loses support.
160
174
  Unsupported bodies
161
175
  under gravity stay awake. `wakeAll()`, `body.wakeUp()` and `readSleepStats()` are
162
176
  available. Suspended jointed objects are not guaranteed to sleep. Defaults and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avbd-babylon",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "GPU AVBD rigid-body physics with a Babylon.js aggregate API",
5
5
  "main": "./dist/avbd.js",
6
6
  "types": "./dist/avbd.d.ts",
@@ -15,7 +15,7 @@
15
15
  "test": "node scripts/test-gpu.mjs",
16
16
  "test:reference": "node --experimental-transform-types --test reference/three-avbd/tests/*.test.ts",
17
17
  "test:gpu": "node scripts/test-gpu.mjs",
18
- "test:sleeping": "node scripts/build.mjs && node scripts/check-lab-sleep.mjs && node scripts/check-sleep-stability.mjs --drag && node scripts/check-jointed-settling.mjs",
18
+ "test:sleeping": "node scripts/build.mjs && node scripts/check-lab-sleep.mjs && node scripts/check-sleep-stability.mjs --drag && node scripts/check-sleeping-impact-scenes.mjs && node scripts/check-jointed-settling.mjs",
19
19
  "test:all": "node scripts/test-all.mjs",
20
20
  "test:complete": "node scripts/test-all.mjs --strict",
21
21
  "test:scenes": "node scripts/build.mjs && node scripts/check-scenes.mjs",
@@ -44,6 +44,7 @@
44
44
  "benchmark:backends": "node scripts/build.mjs && node scripts/benchmark-backends.mjs",
45
45
  "benchmark:native": "node scripts/benchmark-package.mjs",
46
46
  "benchmark:sleeping": "node scripts/benchmark-package.mjs",
47
+ "benchmark:scene-sleep": "node scripts/benchmark-scene-sleep.mjs && node scripts/build.mjs && node scripts/report-solver.mjs",
47
48
  "benchmark:connected-sleep": "node scripts/benchmark-connected-sleep.mjs",
48
49
  "benchmark:small-groups": "node scripts/benchmark-small-groups.mjs",
49
50
  "benchmark:native-edits": "node scripts/check-native-performance.mjs",
package/tests/README.md CHANGED
@@ -26,6 +26,7 @@ run on the host because they inspect files and JavaScript APIs.
26
26
  | `npm run test:fracture` | Voronoi partition, breakable face bonds, wrecking-ball impact and persistent rubble |
27
27
  | `npm run test:reference` | Explicitly requested upstream CPU comparison; excluded from normal validation |
28
28
  | `npm run benchmark:native` | 2D/3D movement/spin, property edits, grouped queries, sleeping and selected reads; three repeats |
29
+ | `npm run benchmark:scene-sleep` | Every demo scene: paired sleeping-on/off runs, complete physics timings during motion and later settling, and generated demo defaults |
29
30
  | `npm run benchmark:connected-sleep` | 505,923-body walls: all-awake overhead and later impacts with whole-world versus automatic connected-group waking; two alternating paired runs |
30
31
  | `npm run benchmark:small-groups` | 9- and 32-body closed worlds: automatic workgroup movement versus separate dispatches, three paired runs and exact final body-state comparisons |
31
32
  | `npm run benchmark:native-edits` | 100K motion updates, 10K property edits and 64 ray queries in 2D/3D; API overhead and GPU completion |
@@ -38,7 +39,8 @@ Set `AVBD_TEST_BROWSER` to a Chromium executable if browser discovery fails.
38
39
 
39
40
  `node scripts/check-galton-startup.mjs` measures startup of the 40,000-marble
40
41
  playground and verifies default worker execution, an explicit main-thread choice,
41
- and automatic fallback when workers are unavailable. `test:playgrounds` also
42
+ and automatic fallback when workers are unavailable. It also checks that page
43
+ dependencies stay small before starting the worker. `test:playgrounds` also
42
44
  checks that at least 99.5% of marbles reach the bins, compares GPU counts with real
43
45
  body positions, and measures the shape of the distribution.
44
46
 
@@ -48,7 +50,9 @@ poses with direct drawing, Babylon, shared-input workers and CPU compatibility.
48
50
  and bounded catch-up under load. `check-lab-sleep.mjs` checks live sleeping
49
51
  toggles, large-scene defaults and bowling balls in all sixteen wall lanes.
50
52
  `check-sleep-stability.mjs --drag` follows the 28K brick ring for 900 steps and
51
- checks that repeated grab-anchor updates leave resting debris asleep.
53
+ checks that creating a grab and repeatedly updating its anchor leave a distant,
54
+ disconnected sleeper asleep with unchanged poses. GPU regressions also check
55
+ grab release and stale gravity predictions beside an awake resting body.
52
56
  `check-jointed-settling.mjs` measures GPU collision and movement time while the
53
57
  34K jointed drop lands, comparing sleeping off, whole-world waking and automatic
54
58
  group sleeping. It checks contact capacity and solve-group conflicts on every
@@ -61,6 +65,9 @@ scene defaults and URL settings with CPU, WebGPU, Babylon and worker execution.
61
65
  The showcase exposes steps per second beside solving iterations. Both settings
62
66
  remain fixed while a benchmark measurement runs.
63
67
 
68
+ `check-runtime-efficiency.mjs` also checks that workers finish explicit GPU
69
+ cleanup before termination, with a bounded fallback for an unresponsive worker.
70
+
64
71
  `node scripts/check-demo-startup.mjs --all` initializes every scene in a paused
65
72
  worker and saves setup times separately from frame performance. Browser and driver
66
73
  caches can warm during the run. `node scripts/check-slingshot-input.mjs` uses real