avbd-babylon 0.2.0 → 0.4.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.
- package/README.md +864 -116
- package/dist/avbd.d.ts +2 -0
- package/dist/avbd.global.js +617 -153
- package/dist/avbd.js +617 -153
- package/dist/babylonAvbd.d.ts +31 -6
- package/dist/native.d.ts +1 -0
- package/dist/native.js +1 -1
- package/dist/nativeScenes.d.ts +81 -5
- package/dist/solverPipeline.d.ts +62 -0
- package/dist/utilities.d.ts +161 -0
- package/dist/utilities.js +1 -0
- package/docs/BABYLON_API.md +34 -5
- package/docs/HPLOC.md +119 -115
- package/docs/README.md +58 -14
- package/docs/RELEASE.md +26 -2
- package/package.json +38 -4
- package/tests/README.md +188 -25
package/tests/README.md
CHANGED
|
@@ -1,28 +1,71 @@
|
|
|
1
1
|
# GPU validation and browser benchmarks
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
| `npm
|
|
10
|
-
| `npm run test:
|
|
11
|
-
| `npm run test:
|
|
12
|
-
| `npm run test:
|
|
13
|
-
| `npm run test:
|
|
14
|
-
| `npm run test:
|
|
15
|
-
| `npm run test:
|
|
16
|
-
| `npm run test:
|
|
17
|
-
| `npm run test:
|
|
18
|
-
| `npm run test:
|
|
19
|
-
| `npm run
|
|
20
|
-
| `npm run test:
|
|
21
|
-
| `npm run test:
|
|
22
|
-
| `npm run
|
|
23
|
-
| `npm run
|
|
3
|
+
Numerical and stability validation runs physics on the GPU. Shared API checks
|
|
4
|
+
also run CPU compatibility worlds. Package, type and source-integrity checks
|
|
5
|
+
run on the host because they inspect files and JavaScript APIs.
|
|
6
|
+
|
|
7
|
+
| Command | Scope |
|
|
8
|
+
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `npm test` | GPU numerical and stability regressions |
|
|
10
|
+
| `npm run test:complete` | GPU suite, shared pipeline contract, package, pinned-source integrity and live Babylon example |
|
|
11
|
+
| `npm run test:pipelines` | Same 2D/3D package application calls on CPU and WebGPU: bulk edits, queries, joints, triggers, bounce, sleeping, scene attachment and disposal |
|
|
12
|
+
| `npm run test:cpu` | CPU compatibility scene views, controls, screenshots and physics measurements |
|
|
13
|
+
| `npm run test:web` | All GPU scene views, benchmarks, motion, controls, screenshots and reports |
|
|
14
|
+
| `npm run test:package` | ESM/global bundles, declarations and production dependencies |
|
|
15
|
+
| `npm run test:types` | Public declarations with real Babylon types and portable API consumers |
|
|
16
|
+
| `npm run test:playgrounds` | Tornado debris and mortar breakage, domino chain propagation, 40,000-marble normal-distribution checks, worker/rendering controls, stable forts and slingshot victory |
|
|
17
|
+
| `npm run test:castle` | Mortar settling, local impacts, rotating debris and responsive layout |
|
|
18
|
+
| `npm run test:cloth` | Thirty-second limb/net checks, central cloth tearing and screenshots |
|
|
19
|
+
| `npm run test:features` | 2D/3D hinge stops, motor reversal/braking, sensors, live masks and casts |
|
|
20
|
+
| `npm run test:mobile-contacts` | 3D floor contacts, device-verified fallback selection, 8/9 binding limits and mobile drawing |
|
|
21
|
+
| `npm run test:connected-phone` | Physical Android GPU: prepared native/Babylon APIs, floor contacts, 2D/3D features and grid/HPLOC++ collisions |
|
|
22
|
+
| `npm run test:connected-demos` | Physical Android: ten production scenes, screenshots, short GPU/completion timings, hinges, sensors, terrain, cloth and 40K marble flow |
|
|
23
|
+
| `npm run test:renderers` | Every canonical scene and the slingshot in Babylon; shared-state renderer benchmark checks |
|
|
24
|
+
| `npm run benchmark:renderers` | Direct WebGPU versus Babylon: GPU drawing/copies, CPU submission and completion; three repeats |
|
|
25
|
+
| `npm run test:fracture` | Voronoi partition, breakable face bonds, wrecking-ball impact and persistent rubble |
|
|
26
|
+
| `npm run test:reference` | Explicitly requested upstream CPU comparison; excluded from normal validation |
|
|
27
|
+
| `npm run benchmark:native` | 2D/3D movement/spin, property edits, grouped queries, sleeping and selected reads; three repeats |
|
|
28
|
+
| `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 |
|
|
29
|
+
| `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 |
|
|
30
|
+
| `npm run benchmark:native-edits` | 100K motion updates, 10K property edits and 64 ray queries in 2D/3D; API overhead and GPU completion |
|
|
31
|
+
|
|
32
|
+
The [benchmark source index](../README.md#benchmark-sample-code) links to the
|
|
33
|
+
copyable examples, scene builders and measurement runners. The
|
|
34
|
+
[demo source guide](../demo/README.md) shows where each demo is configured and initialized.
|
|
24
35
|
|
|
25
36
|
Set `AVBD_TEST_BROWSER` to a Chromium executable if browser discovery fails.
|
|
37
|
+
|
|
38
|
+
`node scripts/check-galton-startup.mjs` measures startup of the 40,000-marble
|
|
39
|
+
playground and verifies default worker execution, an explicit main-thread choice,
|
|
40
|
+
and automatic fallback when workers are unavailable. `test:playgrounds` also
|
|
41
|
+
checks that at least 99.5% of marbles reach the bins, compares GPU counts with real
|
|
42
|
+
body positions, and measures the shape of the distribution.
|
|
43
|
+
|
|
44
|
+
`check-galton-pegs.mjs` checks mouse and touch retraction, restoration and live
|
|
45
|
+
poses with direct drawing, Babylon, shared-input workers and CPU compatibility.
|
|
46
|
+
`check-lab-timing.mjs` checks fixed-step clocks at 30–240 display frames per second
|
|
47
|
+
and bounded catch-up under load. `check-lab-sleep.mjs` checks live sleeping
|
|
48
|
+
toggles, large-scene defaults and bowling balls in all sixteen wall lanes.
|
|
49
|
+
These checks run through `test:playgrounds` and `test:web`.
|
|
50
|
+
|
|
51
|
+
`check-lab-step-rate.mjs` checks live physics step-rate changes, retained poses,
|
|
52
|
+
scene defaults and URL settings with CPU, WebGPU, Babylon and worker execution.
|
|
53
|
+
The showcase exposes steps per second beside solving iterations. Both settings
|
|
54
|
+
remain fixed while a benchmark measurement runs.
|
|
55
|
+
|
|
56
|
+
`node scripts/check-demo-startup.mjs --all` initializes every scene in a paused
|
|
57
|
+
worker and saves setup times separately from frame performance. Browser and driver
|
|
58
|
+
caches can warm during the run. `node scripts/check-slingshot-input.mjs` uses real
|
|
59
|
+
browser mouse, touch and keyboard events to check aiming, the trajectory line,
|
|
60
|
+
release, touch cancellation and reloading in direct, Babylon and worker views.
|
|
61
|
+
|
|
62
|
+
`npm run test:terrain` checks terrain cooking, floor and roof contacts, mesh
|
|
63
|
+
imports and Babylon transforms. `npm run test:workers` also checks paused
|
|
64
|
+
redrawing, camera input, resizing, queue backpressure, shared status readbacks
|
|
65
|
+
and pixel-identical batched rendering. `npm run benchmark:hploc-refit` measures
|
|
66
|
+
the leaf-bound update separately at 2K, 100K and 510K bodies; its timings describe
|
|
67
|
+
that kernel rather than the whole physics step.
|
|
68
|
+
|
|
26
69
|
The runner uses an isolated temporary profile and a real WebGPU adapter. Missing
|
|
27
70
|
WebGPU, validation errors or failed assertions fail the command; they are not
|
|
28
71
|
silently skipped. Results and screenshots are generated under `test-results/`.
|
|
@@ -83,7 +126,13 @@ Batching checks additionally cover linear/angular masks, reusable packed motion
|
|
|
83
126
|
arrays, atomic property validation, sparse mask/trigger updates before queries,
|
|
84
127
|
single-submission native and Babylon stepping with sleep and bounce enabled,
|
|
85
128
|
motor warm-start preservation, removal ordering, cached pass-constant invalidation,
|
|
86
|
-
and concurrent query-pool reuse/disposal.
|
|
129
|
+
and concurrent query-pool reuse/disposal. Closed small-world tests compare every
|
|
130
|
+
body field through zero iterations, dense contacts, bounce, triggers, teleports
|
|
131
|
+
and the automatic fallback when joints are added. Connected-group sleep tests
|
|
132
|
+
check complete pile waking, unchanged neighboring sleepers on a shared floor,
|
|
133
|
+
and support removal with grid and HPLOC collisions. Sleep and bounce uniform checks compare
|
|
134
|
+
all body fields and sleep records against unconditional uploads while changing
|
|
135
|
+
the timestep, gravity, support, masks and contact capacity. Native API benchmarks measure 100K motion
|
|
87
136
|
edits, 10K property changes with per-body versus grouped flushing, and 64 separate
|
|
88
137
|
versus grouped rays. These API/query measurements exclude solving and rendering.
|
|
89
138
|
|
|
@@ -110,9 +159,9 @@ and capsule-to-triangle intersections deeper than 5 mm every quarter-second
|
|
|
110
159
|
through 30 simulated seconds. The tearable sheet check requires an
|
|
111
160
|
intact, stretched sheet before impact, a central tear with all four attachments
|
|
112
161
|
and the outer fabric intact, the ball passing through, finite
|
|
113
|
-
poses and valid rotations.
|
|
114
|
-
|
|
115
|
-
|
|
162
|
+
poses and valid rotations. Detached fabric checks require retained material,
|
|
163
|
+
mass and live bodies as the pieces fall and settle on the floor. These scenes
|
|
164
|
+
use discrete collisions with rigid patches.
|
|
116
165
|
|
|
117
166
|
Storage growth, resets, warm starts and deterministic repeated runs are checked.
|
|
118
167
|
Forced contact overflows and conflicting solve groups must hold motion until
|
|
@@ -134,6 +183,32 @@ or prove that every possible scene is stable.
|
|
|
134
183
|
|
|
135
184
|
## Browser scene and performance checks
|
|
136
185
|
|
|
186
|
+
`npm run benchmark:particles` measures the D20 surface-only particle test with
|
|
187
|
+
sprites visible, searches for sustained 60 FPS, and repeats counts near the
|
|
188
|
+
boundary. GPU collision and sprite passes are timed separately. Results and
|
|
189
|
+
the method are saved in [the particle capacity report](../test-results/particle-capacity.html).
|
|
190
|
+
`tests/gpu-utilities.js` checks exact particle state across one- and two-dimensional
|
|
191
|
+
dispatches, partial groups, valid counters, surface hits and invalid uploads.
|
|
192
|
+
|
|
193
|
+
`npm run test:workers` checks CPU and GPU worker trajectories, Babylon rendering,
|
|
194
|
+
pointer ordering and operation without shared-memory headers.
|
|
195
|
+
`npm run benchmark:workers` compares matched main-thread, message-worker and
|
|
196
|
+
shared-input execution; open [the interactive comparison](workers.html) to play
|
|
197
|
+
or measure a selected scene. GPU timestamps, CPU work and page delay are separate.
|
|
198
|
+
Recorded results name the measured hardware; shared input is optional.
|
|
199
|
+
|
|
200
|
+
`npm run test:terrain` validates heightfields and concave mesh terrain, floor/roof
|
|
201
|
+
contacts, raycasts and removal on CPU, GPU grid and HPLOC paths. It also checks
|
|
202
|
+
Babylon registration, imported OBJ geometry, smooth source-mesh drawing, worker
|
|
203
|
+
execution and terrain screenshots. `npm run test:naval` checks
|
|
204
|
+
floating, settling under sail forces, local damage, material buoyancy, sinking and persistent fragments, with desktop
|
|
205
|
+
and narrow-layout captures. Naval water physics requires WebGPU.
|
|
206
|
+
|
|
207
|
+
`npm run benchmark:naval` measures the grid and HPLOC collision paths with the
|
|
208
|
+
same water resolution, timestep, iterations and ship geometry. Physics GPU time,
|
|
209
|
+
water GPU time and drawing GPU time are measured separately. Browser timings
|
|
210
|
+
vary; repeat runs before comparing small differences.
|
|
211
|
+
|
|
137
212
|
`check-scenes.mjs` visits the full GPU catalog, advances each scene, checks
|
|
138
213
|
finite positions, rotations and solver counters, and saves screenshots and
|
|
139
214
|
frame/physics/drawing timings. Dedicated checks cover the castle, 100K local
|
|
@@ -163,8 +238,96 @@ samples. Do not run GPU workloads concurrently. `AVBD_PROFILE_SCENES`,
|
|
|
163
238
|
`AVBD_PROFILE_REPEATS` configure these tools. Public benchmarks use production
|
|
164
239
|
automatic selection rather than presenting competing solver versions.
|
|
165
240
|
|
|
241
|
+
`npm run benchmark:gpu-uploads` measures CPU preparation and uploads for the
|
|
242
|
+
WebGPU solver's settings in both dimensions. It isolates that overhead from GPU
|
|
243
|
+
physics and drawing. Stable 2D settings need no upload; a normal 3D step uploads
|
|
244
|
+
the changing generation word. Live setting changes still update their exact
|
|
245
|
+
GPU values. The GPU regression suite checks the serialized words against the
|
|
246
|
+
pinned layouts, including changed flags, wind, timestep and replacement buffers.
|
|
247
|
+
|
|
248
|
+
`npm run benchmark:gpu-scheduling` measures stable GPU color bucketing in 2D and
|
|
249
|
+
3D, with 256, 1,024, 2,416, 100K and 510K bodies, varied color counts and sparse/dense moving
|
|
250
|
+
sets. It compares every rank, histogram word and counter against the pinned
|
|
251
|
+
kernel before timing. Large worlds select bitset ranks automatically. The body
|
|
252
|
+
ordering, collision work, equations and iteration count remain the same. These
|
|
253
|
+
are kernel timings, not total physics or frame-rate improvements.
|
|
254
|
+
|
|
255
|
+
`node scripts/benchmark-workers.mjs --gpu` refreshes just the WebGPU worker
|
|
256
|
+
comparisons and preserves the existing CPU compatibility rows.
|
|
257
|
+
|
|
258
|
+
`npm run benchmark:movement` compares movement-solver batching with the same
|
|
259
|
+
contact equations, timestep and iterations in 100K columns, the 110K ring and
|
|
260
|
+
the half-million walls. Two runs reverse GPU-world creation order and alternate
|
|
261
|
+
execution order every step. Every resulting body-state value must match exactly;
|
|
262
|
+
every step checks contact capacity and conflicting solve groups. GPU timestamps
|
|
263
|
+
separate moving bodies from updating contact forces, with drawing and sleeping
|
|
264
|
+
disabled. Results are saved in `test-results/movement-solve-performance.json`.
|
|
265
|
+
Large rigid worlds select parallel point updates automatically; the shared-point
|
|
266
|
+
layout also uses compact symmetric Newton matrices and packs frequently read
|
|
267
|
+
pose fields during solving. GPU regressions check the restored public buffer
|
|
268
|
+
byte for byte, including partial tiles, unused capacity and appended bodies.
|
|
269
|
+
They also cover zero iterations, failed-step recovery, wind, joints, motors,
|
|
270
|
+
springs, bounce, sensor rebuilds, mode changes, mobile compatibility layouts
|
|
271
|
+
and million-manifold dispatch limits.
|
|
272
|
+
|
|
273
|
+
`npm run benchmark:gpu-encoding` measures CPU command setup for the WebGPU
|
|
274
|
+
feature encoder in 2D and 3D. It compares reused typed and plain offset arrays
|
|
275
|
+
with identical bindings, dispatches and resulting body fields. Alternating
|
|
276
|
+
four-step batches wait for GPU completion before the next sample. The first
|
|
277
|
+
60 batches warm up the code; the next 60 are measured. These are small CPU
|
|
278
|
+
costs, separate from GPU physics and frame rate. Results are saved in
|
|
279
|
+
`test-results/command-encoding-performance.json`. GPU regressions also compare
|
|
280
|
+
the feature encoder against the pinned encoder through combined/split passes,
|
|
281
|
+
joint contacts, VBD and post stabilization. Repeated buffer bindings are skipped
|
|
282
|
+
within a pass and restored after scan, tree and sleeping helpers.
|
|
283
|
+
|
|
284
|
+
WebGL2 is an experimental repository/demo backend, excluded from the npm
|
|
285
|
+
package. The package contract runs only CPU and WebGPU; `npm run test:webgl`
|
|
286
|
+
also runs the shared contract separately against experimental WebGL2.
|
|
287
|
+
|
|
288
|
+
`npm run test:webgl-collisions` compares GPU WebGL2 broadphase and shape
|
|
289
|
+
contacts with exhaustive pairs and the WebGPU equations, including masks,
|
|
290
|
+
large shapes, cell boundaries and overflow.
|
|
291
|
+
|
|
292
|
+
`npm run test:webgl` checks graph coloring, solver stages, complete settling
|
|
293
|
+
worlds, hulls, capsules, joints, welds, motors, springs, ordered body edits,
|
|
294
|
+
nonzero restitution and sleeping/waking in both dimensions. Shared API checks
|
|
295
|
+
also exercise triggers, masking, shape queries, live weld-frame capture and fabric.
|
|
296
|
+
`npm run test:webgl-scenes` checks controls, finite poses, collision counters and
|
|
297
|
+
screenshots across the 2D/3D benchmark previews. WebGL2 worlds retain every contact
|
|
298
|
+
point and the selected equations, timestep and iteration count. Large scenes
|
|
299
|
+
can exceed the contact-texture memory budget; they are reported explicitly.
|
|
300
|
+
|
|
301
|
+
`npm run test:compatibility` builds the package and website, then runs the shared
|
|
302
|
+
API, CPU demos and WebGL2 checks. Browser benchmarks select the backend separately
|
|
303
|
+
from drawing. WebGL2's GPU elapsed queries are separate from submission/completion
|
|
304
|
+
time; unsupported GPU timers leave those fields empty.
|
|
305
|
+
|
|
306
|
+
`npm run test:cpu` includes the slingshot's CPU and WebGPU paths. The checks launch
|
|
307
|
+
and boost a ball, add a new ball and constraint, verify finite live poses, and
|
|
308
|
+
capture each renderer. CPU scene drawing also covers rounded rope links and
|
|
309
|
+
chainmail rings at the same dimensions as the WebGPU scene.
|
|
310
|
+
|
|
166
311
|
`npm run benchmark:sleeping` runs the separate sleeping and selective-pose-copy
|
|
167
312
|
comparisons through the browser controls, with three independent repeats and
|
|
168
313
|
screenshots. The resting stacks have 16,384 boxes in 3D and 10,000 in 2D; times include sleep/wake and
|
|
169
314
|
support checks. Results report asleep counts, awake overhead and settled pose
|
|
170
315
|
differences. This benchmark does not change the always-awake paper comparison.
|
|
316
|
+
|
|
317
|
+
`npm run test:compatibility-performance` checks backend selection, GPU timer labels,
|
|
318
|
+
playable previews and measurements without WebGPU. The `--package` option on
|
|
319
|
+
`check-backend-contract.mjs` checks the built ESM package rather than source imports.
|
|
320
|
+
|
|
321
|
+
WebGL2 scene checks include all 33 original demos and the added collider, hinge,
|
|
322
|
+
trigger, cloth and demolition examples. The behavior checks verify 60 advancing
|
|
323
|
+
steps in the joint grid, both stack dimensions and tearable cloth; explicit 2D
|
|
324
|
+
collision exclusions are checked separately. These checks cover finite runs;
|
|
325
|
+
the largest workloads use WebGPU and may exceed WebGL2's contact-texture budget.
|
|
326
|
+
|
|
327
|
+
`npm run benchmark:backends` records the same 2D stack, 2D joint grid, 3D stack
|
|
328
|
+
and 3D pyramid on WebGPU, experimental WebGL2 and CPU. Each backend uses 60 warmup steps,
|
|
329
|
+
60 measured steps and three fresh-world repeats; order rotates between repeats.
|
|
330
|
+
Drawing and sleeping are disabled. GPU elapsed time and JavaScript CPU time are
|
|
331
|
+
reported separately from submission, initialization and completed-step waiting.
|
|
332
|
+
The raw runs and combined summaries are saved in `test-results/backend-comparison.json`;
|
|
333
|
+
the README compares the mean physics times side by side.
|