avbd-babylon 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -1
- package/dist/avbd.global.js +212 -123
- package/dist/avbd.js +212 -123
- package/dist/gpuDevice.d.ts +4 -0
- package/dist/native.js +1 -1
- package/docs/BABYLON_API.md +8 -0
- package/docs/RELEASE.md +49 -4
- package/package.json +63 -65
- package/tests/README.md +2 -0
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# AVBD for Babylon.js
|
|
2
2
|
|
|
3
|
+
**TRY ME!!!** [**babylon-avbd.netlify.app**](https://babylon-avbd.netlify.app/)
|
|
4
|
+
|
|
3
5
|
`avbd-babylon` runs AVBD rigid-body physics and collision detection on WebGPU,
|
|
4
6
|
with an aggregate/body API that follows familiar Babylon.js conventions.
|
|
5
7
|
The package bundles its solver and shaders, with **no Babylon runtime dependency**.
|
|
@@ -58,7 +60,7 @@ npm install avbd-babylon @babylonjs/core
|
|
|
58
60
|
|
|
59
61
|
For local development, run `npm install` and `npm run build` in this repository,
|
|
60
62
|
then run `npm install /absolute/path/to/avbd` in your Babylon project. `npm pack`
|
|
61
|
-
creates an installable `avbd-babylon-0.
|
|
63
|
+
creates an installable `avbd-babylon-0.2.0.tgz` archive too.
|
|
62
64
|
|
|
63
65
|
The package includes ESM, TypeScript declarations and a browser global build.
|
|
64
66
|
Babylon 9 is an optional peer dependency; integration examples are checked with
|
|
@@ -72,6 +74,46 @@ Your application does not need a WGSL loader or the repository's TypeScript sour
|
|
|
72
74
|
WebGPU requires a supported browser on localhost or HTTPS. Small-scene drawing
|
|
73
75
|
can use Babylon's WebGL or WebGPU engine; physics uses WebGPU in either case.
|
|
74
76
|
|
|
77
|
+
The scene browser runs a small 3D floor-contact check once per GPU device before
|
|
78
|
+
opening a 3D GPU scene. A box, sphere and capsule must settle on a thin floor.
|
|
79
|
+
GPUs that pass keep the normal batched execution and scene-based collision
|
|
80
|
+
selection. If it fails, the check tests GPU compatibility alternatives for contact
|
|
81
|
+
data, contact calculations, work sharing and collision search. It uses a path only after it
|
|
82
|
+
passes the same physics checks. These compatibility paths keep the equations,
|
|
83
|
+
timestep and iterations unchanged. The check runs at startup; it adds no
|
|
84
|
+
readbacks during normal simulation.
|
|
85
|
+
If every path fails, the demo stops and offers a diagnostic report under
|
|
86
|
+
**GPU contact check** in the sidebar. The report includes contact results, GPU
|
|
87
|
+
limits, collision counts, contact forces, solver dispatches and browser details.
|
|
88
|
+
It also checks whether the contact inputs and calculated forces agree on the GPU.
|
|
89
|
+
`npm run test:mobile-contacts` checks the same physics
|
|
90
|
+
with eight and nine storage bindings and checks the mobile layout with both
|
|
91
|
+
renderers; testing the layout does not substitute for testing a phone's GPU.
|
|
92
|
+
The [physical-phone floor check](test-results/connected-phone-floor.json) verifies
|
|
93
|
+
boxes, spheres and capsules in Android Brave. `npm run test:connected-phone`
|
|
94
|
+
checks 2D/3D collisions, joints, bounce, triggers, masks, sleeping and queries
|
|
95
|
+
on an authorized, unlocked Android phone running the local demo.
|
|
96
|
+
|
|
97
|
+
`AvbdPhysics.create()` prepares its device automatically. Native 3D applications
|
|
98
|
+
can qualify a new device when creating it, or prepare a renderer-owned device
|
|
99
|
+
once before creating any solvers. A failed check throws instead of running
|
|
100
|
+
physics with broken contacts. 2D does not need the 3D check.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
import { createWebGPUDevice, prepareWebGPUDevice3D } from "avbd-babylon/native";
|
|
104
|
+
|
|
105
|
+
const { device } = await createWebGPUDevice({
|
|
106
|
+
validate3D: true,
|
|
107
|
+
preferredLimits: { maxStorageBuffersPerShaderStage: 9 },
|
|
108
|
+
});
|
|
109
|
+
// Or, for an existing renderer-owned device:
|
|
110
|
+
await prepareWebGPUDevice3D(rendererDevice);
|
|
111
|
+
// scene3D.createSolver(device) now uses the verified GPU path.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
[Direct renderer on a mobile layout](test-results/screenshots/mobile-contact-webgpu.png) ·
|
|
115
|
+
[Babylon renderer on a mobile layout](test-results/screenshots/mobile-contact-babylon.png).
|
|
116
|
+
|
|
75
117
|
## What this package adds
|
|
76
118
|
|
|
77
119
|
The package builds on the upstream AVBD solver with GPU collision detection,
|
|
@@ -140,6 +182,7 @@ and `scene.enablePhysics()`.
|
|
|
140
182
|
| Batched body commands and packed velocity edits | Yes | Yes | `editBodies()` groups motion and property edits; packed linear/angular updates use one dispatch. |
|
|
141
183
|
| Automatic Babylon stepping and disposal | Yes | Yes | `AvbdPhysics` or native `gpu.attachToScene(scene)` in either dimension. |
|
|
142
184
|
| Manual fixed steps / worker execution | Yes | Yes | No renderer or DOM dependency in either solver. |
|
|
185
|
+
| Mobile browsers with WebGPU | Yes | Yes | Verified on Android Brave. Babylon's async factory and the scene browser prepare 3D automatically; native 3D apps use `validate3D:true` or `prepareWebGPUDevice3D()`. Requires WebGPU and HTTPS or localhost. |
|
|
143
186
|
| Automatic grid / HPLOC++ choice | Yes | Grid | 3D auto selection uses body sizes and workload. |
|
|
144
187
|
| GPU work sharing | Yes | Yes | Retains the configured physics and iteration counts. |
|
|
145
188
|
| Mesh / instance rendering | Yes | Yes | Use batch drawing for large scenes; portable builders do not create meshes. |
|