avbd-babylon 0.4.3 → 0.4.5
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 +13 -3
- package/dist/babylonAvbd.d.ts +347 -314
- package/dist/gpuDevice.d.ts +15 -10
- package/dist/nativeScenes.d.ts +879 -815
- package/dist/solverPipeline.d.ts +70 -62
- package/dist/utilities.d.ts +165 -161
- package/package.json +1 -1
package/dist/solverPipeline.d.ts
CHANGED
|
@@ -1,62 +1,70 @@
|
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
/**
|
|
49
|
+
* Backend factory shared by multiple worlds. Destroy worlds individually or
|
|
50
|
+
* destroy the pipeline to release them together; supplied devices are borrowed.
|
|
51
|
+
*/
|
|
52
|
+
export interface AvbdSolverPipeline {
|
|
53
|
+
readonly backend: AvbdSolverBackend;
|
|
54
|
+
readonly device?: GPUDevice;
|
|
55
|
+
readonly adapter?: GPUAdapter;
|
|
56
|
+
createSolver(scene: AvbdScene2D, options?: AvbdSolverOptions): AvbdSolver2D;
|
|
57
|
+
createSolver(scene: AvbdScene3D, options?: AvbdSolverOptions): AvbdSolver3D;
|
|
58
|
+
/** Destroys its worlds and its own device. A supplied device remains caller-owned. */
|
|
59
|
+
destroy(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Initialize WebGPU or CPU once; scene builders and live world commands remain
|
|
63
|
+
* compatible. Direct drawing buffers are available only on the GPU backend.
|
|
64
|
+
*/
|
|
65
|
+
export function createSolverPipeline(
|
|
66
|
+
options?: NonNullable<Parameters<typeof createWebGPUDevice>[0]> & {
|
|
67
|
+
backend?: AvbdSolverBackend;
|
|
68
|
+
device?: GPUDevice;
|
|
69
|
+
},
|
|
70
|
+
): Promise<AvbdSolverPipeline>;
|
package/dist/utilities.d.ts
CHANGED
|
@@ -1,161 +1,165 @@
|
|
|
1
|
-
/** Nonblocking GPU pass timestamps; null when timestamp-query is unavailable. */
|
|
2
|
-
export class GpuTimer {
|
|
3
|
-
constructor(device: GPUDevice);
|
|
4
|
-
readonly latestMs: number | null;
|
|
5
|
-
readonly samples: number;
|
|
6
|
-
begin(): object | null;
|
|
7
|
-
descriptor(slot: object | null): {
|
|
8
|
-
timestampWrites?: GPUComputePassTimestampWrites;
|
|
9
|
-
};
|
|
10
|
-
encode(encoder: GPUCommandEncoder, slot: object | null): void;
|
|
11
|
-
resolve(slot: object | null): Promise<void> | undefined;
|
|
12
|
-
settled(): Promise<unknown[]>;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
|
15
|
-
/** Reuse released buffers with compatible usage, without CPU pose transfers. */
|
|
16
|
-
export class GPUBufferRecycler {
|
|
17
|
-
constructor(device: GPUDevice, options?: { maxFreeBytes?: number });
|
|
18
|
-
readonly freeBytes: number;
|
|
19
|
-
acquire(
|
|
20
|
-
byteSize: number,
|
|
21
|
-
usage: GPUBufferUsageFlags,
|
|
22
|
-
label?: string,
|
|
23
|
-
): GPUBuffer;
|
|
24
|
-
release(
|
|
25
|
-
buffer: GPUBuffer,
|
|
26
|
-
byteSize: number,
|
|
27
|
-
usage: GPUBufferUsageFlags,
|
|
28
|
-
): void;
|
|
29
|
-
trim(maxFreeBytes?: number): void;
|
|
30
|
-
destroy(): void;
|
|
31
|
-
}
|
|
32
|
-
export const PARTICLE_BYTE_STRIDE: 48;
|
|
33
|
-
export interface SurfaceParticleStep {
|
|
34
|
-
dt: number;
|
|
35
|
-
count?: number;
|
|
36
|
-
speed?: number;
|
|
37
|
-
life?: number;
|
|
38
|
-
bulletRadius?: number;
|
|
39
|
-
spawnRadius?: number;
|
|
40
|
-
jitter?: number;
|
|
41
|
-
frame?: number;
|
|
42
|
-
}
|
|
43
|
-
/** Spherical emitter aimed at the origin. Particles hit triangle surfaces and
|
|
44
|
-
* respawn; they ignore each other. Five rays approximate the particle sweep. */
|
|
45
|
-
export class GpuSurfaceParticles {
|
|
46
|
-
constructor(
|
|
47
|
-
device: GPUDevice,
|
|
48
|
-
options: { capacity: number; triangleCount: number; readback?: boolean },
|
|
49
|
-
);
|
|
50
|
-
readonly device: GPUDevice;
|
|
51
|
-
readonly capacity: number;
|
|
52
|
-
readonly triangleCount: number;
|
|
53
|
-
/** 48 bytes: position/life vec4f, velocity/radius vec4f, seed vec4u. */
|
|
54
|
-
readonly particleBuffer: GPUBuffer;
|
|
55
|
-
readonly triangleBuffer: GPUBuffer;
|
|
56
|
-
readonly counterBuffer: GPUBuffer;
|
|
57
|
-
readonly timer: GpuTimer;
|
|
58
|
-
/** 12 float32 values per triangle: [ax,ay,az,0,bx,by,bz,0,cx,cy,cz,0]. */
|
|
59
|
-
writeTriangles(vertices: Float32Array): void;
|
|
60
|
-
/** Returns the latest asynchronous counters, or null with readback disabled. */
|
|
61
|
-
step(options: SurfaceParticleStep): { hits: number; alive: number } | null;
|
|
62
|
-
clear(): void;
|
|
63
|
-
destroy(): void;
|
|
64
|
-
}
|
|
65
|
-
export const sampledContactShader: string;
|
|
66
|
-
/** Gather a bounded GPU contact overlay, without reading the full contact set. */
|
|
67
|
-
export class GpuContactSample {
|
|
68
|
-
constructor(device: GPUDevice, options?: { count?: number });
|
|
69
|
-
readonly count: number;
|
|
70
|
-
readonly buffer: GPUBuffer;
|
|
71
|
-
encode(
|
|
72
|
-
encoder: GPUCommandEncoder,
|
|
73
|
-
resources: {
|
|
74
|
-
bodyBuffer: GPUBuffer;
|
|
75
|
-
/** Native 3D camera uniform: mat4 vp, vec4 eye, vec4 light/viewport. */
|
|
76
|
-
cameraBuffer: GPUBuffer;
|
|
77
|
-
contactStorage: {
|
|
78
|
-
manifolds: GPUBuffer;
|
|
79
|
-
contacts: GPUBuffer;
|
|
80
|
-
counters: GPUBuffer;
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
): void;
|
|
84
|
-
dispose(): void;
|
|
85
|
-
}
|
|
86
|
-
/** Optional one-time native constraint-graph seed; live GPU coloring still checks contacts. */
|
|
87
|
-
export function seedConstraintColoring(
|
|
88
|
-
gpu: {
|
|
89
|
-
device: GPUDevice;
|
|
90
|
-
bodyCapacity: number;
|
|
91
|
-
colorBuffer: GPUBuffer;
|
|
92
|
-
colorCap: number;
|
|
93
|
-
gpuIndex(index: number): number;
|
|
94
|
-
},
|
|
95
|
-
world: {
|
|
96
|
-
bodies: { mass: number }[];
|
|
97
|
-
forces: { bodyA: object | null; bodyB: object | null }[];
|
|
98
|
-
},
|
|
99
|
-
minimum?: number,
|
|
100
|
-
): void;
|
|
101
|
-
export const INPUT_WORDS: 9;
|
|
102
|
-
/** Custom compute/copy work in the solver's existing command encoder. Callbacks
|
|
103
|
-
* are synchronous, end their own passes, and must not submit or finish the encoder.
|
|
104
|
-
* Dispose the registration before destroying its buffers. CPU solvers are rejected. */
|
|
105
|
-
export function addGpuStepPass<
|
|
106
|
-
T extends { bodyBuffer: GPUBuffer; step(): void },
|
|
107
|
-
>(
|
|
108
|
-
solver: T,
|
|
109
|
-
hooks: {
|
|
110
|
-
before?: (encoder: GPUCommandEncoder, solver: T) => void;
|
|
111
|
-
after?: (encoder: GPUCommandEncoder, solver: T) => void;
|
|
112
|
-
},
|
|
113
|
-
): () => void;
|
|
114
|
-
/** DOM-free sizing and event adapter around a caller-owned canvas. */
|
|
115
|
-
export class WorkerCanvas {
|
|
116
|
-
constructor(
|
|
117
|
-
canvas: OffscreenCanvas | HTMLCanvasElement,
|
|
118
|
-
width: number,
|
|
119
|
-
height: number,
|
|
120
|
-
);
|
|
121
|
-
readonly offscreenCanvas: OffscreenCanvas | HTMLCanvasElement;
|
|
122
|
-
readonly clientWidth: number;
|
|
123
|
-
readonly clientHeight: number;
|
|
124
|
-
readonly revision: number;
|
|
125
|
-
width: number;
|
|
126
|
-
height: number;
|
|
127
|
-
resize(width: number, height: number): void;
|
|
128
|
-
getContext(type: "webgpu"): GPUCanvasContext | null;
|
|
129
|
-
getContext(type: string, options?: object): unknown;
|
|
130
|
-
getBoundingClientRect(): {
|
|
131
|
-
left: number;
|
|
132
|
-
top: number;
|
|
133
|
-
width: number;
|
|
134
|
-
height: number;
|
|
135
|
-
};
|
|
136
|
-
addEventListener(type: string, callback: (event: any) => void): void;
|
|
137
|
-
removeEventListener(type: string, callback: (event: any) => void): void;
|
|
138
|
-
setPointerCapture(): void;
|
|
139
|
-
dispatch(type: string, data: object): void;
|
|
140
|
-
}
|
|
141
|
-
export interface SharedPointerState {
|
|
142
|
-
clientX: number;
|
|
143
|
-
clientY: number;
|
|
144
|
-
pointerId?: number;
|
|
145
|
-
buttons?: number;
|
|
146
|
-
altKey?: boolean;
|
|
147
|
-
shiftKey?: boolean;
|
|
148
|
-
ctrlKey?: boolean;
|
|
149
|
-
}
|
|
150
|
-
/** Returns null without cross-origin isolation / SharedArrayBuffer support. */
|
|
151
|
-
export function createSharedInput(): Int32Array<SharedArrayBuffer> | null;
|
|
152
|
-
/** One producer; continuous state only. Send discrete events as ordered messages. */
|
|
153
|
-
export function writeSharedInput(
|
|
154
|
-
view: Int32Array<SharedArrayBuffer>,
|
|
155
|
-
event: SharedPointerState,
|
|
156
|
-
wheel?: number,
|
|
157
|
-
): void;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
/** Nonblocking GPU pass timestamps; null when timestamp-query is unavailable. */
|
|
2
|
+
export class GpuTimer {
|
|
3
|
+
constructor(device: GPUDevice);
|
|
4
|
+
readonly latestMs: number | null;
|
|
5
|
+
readonly samples: number;
|
|
6
|
+
begin(): object | null;
|
|
7
|
+
descriptor(slot: object | null): {
|
|
8
|
+
timestampWrites?: GPUComputePassTimestampWrites;
|
|
9
|
+
};
|
|
10
|
+
encode(encoder: GPUCommandEncoder, slot: object | null): void;
|
|
11
|
+
resolve(slot: object | null): Promise<void> | undefined;
|
|
12
|
+
settled(): Promise<unknown[]>;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
/** Reuse released buffers with compatible usage, without CPU pose transfers. */
|
|
16
|
+
export class GPUBufferRecycler {
|
|
17
|
+
constructor(device: GPUDevice, options?: { maxFreeBytes?: number });
|
|
18
|
+
readonly freeBytes: number;
|
|
19
|
+
acquire(
|
|
20
|
+
byteSize: number,
|
|
21
|
+
usage: GPUBufferUsageFlags,
|
|
22
|
+
label?: string,
|
|
23
|
+
): GPUBuffer;
|
|
24
|
+
release(
|
|
25
|
+
buffer: GPUBuffer,
|
|
26
|
+
byteSize: number,
|
|
27
|
+
usage: GPUBufferUsageFlags,
|
|
28
|
+
): void;
|
|
29
|
+
trim(maxFreeBytes?: number): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
32
|
+
export const PARTICLE_BYTE_STRIDE: 48;
|
|
33
|
+
export interface SurfaceParticleStep {
|
|
34
|
+
dt: number;
|
|
35
|
+
count?: number;
|
|
36
|
+
speed?: number;
|
|
37
|
+
life?: number;
|
|
38
|
+
bulletRadius?: number;
|
|
39
|
+
spawnRadius?: number;
|
|
40
|
+
jitter?: number;
|
|
41
|
+
frame?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Spherical emitter aimed at the origin. Particles hit triangle surfaces and
|
|
44
|
+
* respawn; they ignore each other. Five rays approximate the particle sweep. */
|
|
45
|
+
export class GpuSurfaceParticles {
|
|
46
|
+
constructor(
|
|
47
|
+
device: GPUDevice,
|
|
48
|
+
options: { capacity: number; triangleCount: number; readback?: boolean },
|
|
49
|
+
);
|
|
50
|
+
readonly device: GPUDevice;
|
|
51
|
+
readonly capacity: number;
|
|
52
|
+
readonly triangleCount: number;
|
|
53
|
+
/** 48 bytes: position/life vec4f, velocity/radius vec4f, seed vec4u. */
|
|
54
|
+
readonly particleBuffer: GPUBuffer;
|
|
55
|
+
readonly triangleBuffer: GPUBuffer;
|
|
56
|
+
readonly counterBuffer: GPUBuffer;
|
|
57
|
+
readonly timer: GpuTimer;
|
|
58
|
+
/** 12 float32 values per triangle: [ax,ay,az,0,bx,by,bz,0,cx,cy,cz,0]. */
|
|
59
|
+
writeTriangles(vertices: Float32Array): void;
|
|
60
|
+
/** Returns the latest asynchronous counters, or null with readback disabled. */
|
|
61
|
+
step(options: SurfaceParticleStep): { hits: number; alive: number } | null;
|
|
62
|
+
clear(): void;
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
65
|
+
export const sampledContactShader: string;
|
|
66
|
+
/** Gather a bounded GPU contact overlay, without reading the full contact set. */
|
|
67
|
+
export class GpuContactSample {
|
|
68
|
+
constructor(device: GPUDevice, options?: { count?: number });
|
|
69
|
+
readonly count: number;
|
|
70
|
+
readonly buffer: GPUBuffer;
|
|
71
|
+
encode(
|
|
72
|
+
encoder: GPUCommandEncoder,
|
|
73
|
+
resources: {
|
|
74
|
+
bodyBuffer: GPUBuffer;
|
|
75
|
+
/** Native 3D camera uniform: mat4 vp, vec4 eye, vec4 light/viewport. */
|
|
76
|
+
cameraBuffer: GPUBuffer;
|
|
77
|
+
contactStorage: {
|
|
78
|
+
manifolds: GPUBuffer;
|
|
79
|
+
contacts: GPUBuffer;
|
|
80
|
+
counters: GPUBuffer;
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
): void;
|
|
84
|
+
dispose(): void;
|
|
85
|
+
}
|
|
86
|
+
/** Optional one-time native constraint-graph seed; live GPU coloring still checks contacts. */
|
|
87
|
+
export function seedConstraintColoring(
|
|
88
|
+
gpu: {
|
|
89
|
+
device: GPUDevice;
|
|
90
|
+
bodyCapacity: number;
|
|
91
|
+
colorBuffer: GPUBuffer;
|
|
92
|
+
colorCap: number;
|
|
93
|
+
gpuIndex(index: number): number;
|
|
94
|
+
},
|
|
95
|
+
world: {
|
|
96
|
+
bodies: { mass: number }[];
|
|
97
|
+
forces: { bodyA: object | null; bodyB: object | null }[];
|
|
98
|
+
},
|
|
99
|
+
minimum?: number,
|
|
100
|
+
): void;
|
|
101
|
+
export const INPUT_WORDS: 9;
|
|
102
|
+
/** Custom compute/copy work in the solver's existing command encoder. Callbacks
|
|
103
|
+
* are synchronous, end their own passes, and must not submit or finish the encoder.
|
|
104
|
+
* Dispose the registration before destroying its buffers. CPU solvers are rejected. */
|
|
105
|
+
export function addGpuStepPass<
|
|
106
|
+
T extends { bodyBuffer: GPUBuffer; step(): void },
|
|
107
|
+
>(
|
|
108
|
+
solver: T,
|
|
109
|
+
hooks: {
|
|
110
|
+
before?: (encoder: GPUCommandEncoder, solver: T) => void;
|
|
111
|
+
after?: (encoder: GPUCommandEncoder, solver: T) => void;
|
|
112
|
+
},
|
|
113
|
+
): () => void;
|
|
114
|
+
/** DOM-free sizing and event adapter around a caller-owned canvas. */
|
|
115
|
+
export class WorkerCanvas {
|
|
116
|
+
constructor(
|
|
117
|
+
canvas: OffscreenCanvas | HTMLCanvasElement,
|
|
118
|
+
width: number,
|
|
119
|
+
height: number,
|
|
120
|
+
);
|
|
121
|
+
readonly offscreenCanvas: OffscreenCanvas | HTMLCanvasElement;
|
|
122
|
+
readonly clientWidth: number;
|
|
123
|
+
readonly clientHeight: number;
|
|
124
|
+
readonly revision: number;
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
resize(width: number, height: number): void;
|
|
128
|
+
getContext(type: "webgpu"): GPUCanvasContext | null;
|
|
129
|
+
getContext(type: string, options?: object): unknown;
|
|
130
|
+
getBoundingClientRect(): {
|
|
131
|
+
left: number;
|
|
132
|
+
top: number;
|
|
133
|
+
width: number;
|
|
134
|
+
height: number;
|
|
135
|
+
};
|
|
136
|
+
addEventListener(type: string, callback: (event: any) => void): void;
|
|
137
|
+
removeEventListener(type: string, callback: (event: any) => void): void;
|
|
138
|
+
setPointerCapture(): void;
|
|
139
|
+
dispatch(type: string, data: object): void;
|
|
140
|
+
}
|
|
141
|
+
export interface SharedPointerState {
|
|
142
|
+
clientX: number;
|
|
143
|
+
clientY: number;
|
|
144
|
+
pointerId?: number;
|
|
145
|
+
buttons?: number;
|
|
146
|
+
altKey?: boolean;
|
|
147
|
+
shiftKey?: boolean;
|
|
148
|
+
ctrlKey?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** Returns null without cross-origin isolation / SharedArrayBuffer support. */
|
|
151
|
+
export function createSharedInput(): Int32Array<SharedArrayBuffer> | null;
|
|
152
|
+
/** One producer; continuous state only. Send discrete events as ordered messages. */
|
|
153
|
+
export function writeSharedInput(
|
|
154
|
+
view: Int32Array<SharedArrayBuffer>,
|
|
155
|
+
event: SharedPointerState,
|
|
156
|
+
wheel?: number,
|
|
157
|
+
): void;
|
|
158
|
+
/**
|
|
159
|
+
* Read a coherent latest-state snapshot, or null if unchanged or being written.
|
|
160
|
+
* Pass the last sequence to skip repeats; this is not a queue for discrete events.
|
|
161
|
+
*/
|
|
162
|
+
export function readSharedInput(
|
|
163
|
+
view: Int32Array<SharedArrayBuffer>,
|
|
164
|
+
previous?: number,
|
|
165
|
+
): { sequence: number; event: SharedPointerState; wheel: number } | null;
|