avbd-babylon 0.1.0 → 0.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.
- package/README.md +2793 -2562
- package/dist/avbd.d.ts +1 -0
- package/dist/avbd.global.js +232 -138
- package/dist/avbd.js +232 -138
- package/dist/gpuDevice.d.ts +4 -0
- package/dist/native.d.ts +1 -0
- package/dist/native.js +1 -1
- package/dist/nativeScenes.d.ts +3 -0
- package/dist/solverPipeline.d.ts +62 -0
- package/docs/BABYLON_API.md +8 -0
- package/docs/README.md +465 -459
- package/docs/RELEASE.md +176 -122
- package/package.json +124 -116
- package/tests/README.md +218 -168
package/dist/gpuDevice.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export function createWebGPUDevice(options?: {
|
|
2
|
+
/** Run the cached 3D floor-contact qualification and select a working GPU path. */
|
|
3
|
+
validate3D?: boolean;
|
|
2
4
|
powerPreference?: GPUPowerPreference;
|
|
3
5
|
requiredLimits?: Record<string, number>;
|
|
4
6
|
/** Desired maximum capacities, clamped to the adapter. Required limits take precedence. */
|
|
5
7
|
preferredLimits?: Record<string, number>;
|
|
6
8
|
}): Promise<{ adapter: GPUAdapter; device: GPUDevice }>;
|
|
9
|
+
/** Prepare an existing renderer-owned device for 3D. Does not take device ownership. */
|
|
10
|
+
export function prepareWebGPUDevice3D(device: GPUDevice): Promise<GPUDevice>;
|
package/dist/native.d.ts
CHANGED
package/dist/native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AvbdScene2D, AvbdScene3D, createWebGPUDevice } from "./avbd.js";
|
|
1
|
+
export { AvbdScene2D, AvbdScene3D, createWebGPUDevice, prepareWebGPUDevice3D, createSolverPipeline } from "./avbd.js";
|
package/dist/nativeScenes.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AvbdSolverPipeline, AvbdSolver2D, AvbdSolver3D } from "./solverPipeline.js";
|
|
1
2
|
export type AvbdTuple3 = readonly [number, number, number];
|
|
2
3
|
export type AvbdTuple2 = readonly [number, number];
|
|
3
4
|
export interface AvbdQueryOptions {
|
|
@@ -620,6 +621,7 @@ export class AvbdScene3D {
|
|
|
620
621
|
},
|
|
621
622
|
): AvbdNativeConstraint;
|
|
622
623
|
createSolver(device: GPUDevice, options?: AvbdGpuOptions): AvbdGpuSolver3D;
|
|
624
|
+
createSolver(pipeline: AvbdSolverPipeline, options?: AvbdGpuOptions): AvbdSolver3D;
|
|
623
625
|
}
|
|
624
626
|
export interface AvbdNativeAngularOptions {
|
|
625
627
|
axisA?: AvbdTuple3;
|
|
@@ -732,4 +734,5 @@ export class AvbdScene2D {
|
|
|
732
734
|
sleeping?: boolean | { speedThreshold?: number; timeThreshold?: number };
|
|
733
735
|
},
|
|
734
736
|
): AvbdGpuSolver2D;
|
|
737
|
+
createSolver(pipeline: AvbdSolverPipeline, options?: AvbdGpuOptions): AvbdSolver2D;
|
|
735
738
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AvbdScene2D,
|
|
3
|
+
AvbdScene3D,
|
|
4
|
+
AvbdGpuOptions,
|
|
5
|
+
AvbdGpuSolver,
|
|
6
|
+
AvbdGpuSolver2D,
|
|
7
|
+
AvbdGpuSolver3D,
|
|
8
|
+
AvbdAdvanceOptions,
|
|
9
|
+
} from "./nativeScenes.js";
|
|
10
|
+
import type { createWebGPUDevice } from "./gpuDevice.js";
|
|
11
|
+
|
|
12
|
+
export type AvbdSolverBackend = "webgpu" | "cpu";
|
|
13
|
+
/** Shared world settings. GPU scheduling fields apply only to GPU execution. */
|
|
14
|
+
export type AvbdSolverOptions = AvbdGpuOptions;
|
|
15
|
+
/** Drawing buffers belong to the selected backend; simulation operations are shared. */
|
|
16
|
+
type SharedMethods<T, Self> = {
|
|
17
|
+
[K in keyof T]: T[K] extends (...args: infer A) => infer R
|
|
18
|
+
? (...args: A) => R extends AvbdGpuSolver ? Self : R
|
|
19
|
+
: T[K];
|
|
20
|
+
};
|
|
21
|
+
export interface AvbdSolver2D extends SharedMethods<
|
|
22
|
+
Omit<AvbdGpuSolver2D, "bodyBuffer" | "shapeBuffer" | "attachToScene">,
|
|
23
|
+
AvbdSolver2D
|
|
24
|
+
> {
|
|
25
|
+
readonly backend: AvbdSolverBackend;
|
|
26
|
+
readonly bodyBuffer?: GPUBuffer;
|
|
27
|
+
readonly shapeBuffer?: GPUBuffer;
|
|
28
|
+
attachToScene(
|
|
29
|
+
scene: Parameters<AvbdGpuSolver2D["attachToScene"]>[0],
|
|
30
|
+
options?: AvbdAdvanceOptions & {
|
|
31
|
+
afterStep?: (solver: AvbdSolver2D) => void;
|
|
32
|
+
},
|
|
33
|
+
): this;
|
|
34
|
+
}
|
|
35
|
+
export interface AvbdSolver3D extends SharedMethods<
|
|
36
|
+
Omit<AvbdGpuSolver3D, "bodyBuffer" | "attachToScene">,
|
|
37
|
+
AvbdSolver3D
|
|
38
|
+
> {
|
|
39
|
+
readonly backend: AvbdSolverBackend;
|
|
40
|
+
readonly bodyBuffer?: GPUBuffer;
|
|
41
|
+
attachToScene(
|
|
42
|
+
scene: Parameters<AvbdGpuSolver3D["attachToScene"]>[0],
|
|
43
|
+
options?: AvbdAdvanceOptions & {
|
|
44
|
+
afterStep?: (solver: AvbdSolver3D) => void;
|
|
45
|
+
},
|
|
46
|
+
): this;
|
|
47
|
+
}
|
|
48
|
+
export interface AvbdSolverPipeline {
|
|
49
|
+
readonly backend: AvbdSolverBackend;
|
|
50
|
+
readonly device?: GPUDevice;
|
|
51
|
+
readonly adapter?: GPUAdapter;
|
|
52
|
+
createSolver(scene: AvbdScene2D, options?: AvbdSolverOptions): AvbdSolver2D;
|
|
53
|
+
createSolver(scene: AvbdScene3D, options?: AvbdSolverOptions): AvbdSolver3D;
|
|
54
|
+
/** Destroys its worlds and its own device. A supplied device remains caller-owned. */
|
|
55
|
+
destroy(): void;
|
|
56
|
+
}
|
|
57
|
+
export function createSolverPipeline(
|
|
58
|
+
options?: NonNullable<Parameters<typeof createWebGPUDevice>[0]> & {
|
|
59
|
+
backend?: AvbdSolverBackend;
|
|
60
|
+
device?: GPUDevice;
|
|
61
|
+
},
|
|
62
|
+
): Promise<AvbdSolverPipeline>;
|
package/docs/BABYLON_API.md
CHANGED
|
@@ -16,6 +16,14 @@ last argument when their mesh belongs to the world’s scene. Both `AvbdShapeTyp
|
|
|
16
16
|
and the supported Babylon `PhysicsShapeType` enum values work. Pass
|
|
17
17
|
`autoAttach: false` when you manage stepping yourself.
|
|
18
18
|
|
|
19
|
+
`AvbdPhysics.create()` checks 3D floor contacts once per device and automatically
|
|
20
|
+
selects a working GPU path. This covers Android drivers that need compatible
|
|
21
|
+
contact calculations or smaller hull workgroups. Desktop devices that pass
|
|
22
|
+
retain their normal shaders and dispatches. The check adds no per-step readbacks.
|
|
23
|
+
For native 3D solvers, use `createWebGPUDevice({validate3D:true})`, or await
|
|
24
|
+
`prepareWebGPUDevice3D(device)` before using a renderer-owned device. Preparation
|
|
25
|
+
is cached and preserves device ownership. 2D does not require the 3D check.
|
|
26
|
+
|
|
19
27
|
```js
|
|
20
28
|
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
21
29
|
import { AvbdPhysics, AvbdPhysicsAggregate, AvbdShapeType } from "avbd-babylon";
|