1// WebGPU time-stepping driver for the von Karman plate.
2//
3// The simulation advances in batches of one movie frame (1/fps seconds). A batch
4// encodes one compute dispatch per time step (with a per-step uniform addressed
5// by dynamic offset), a rigid-body projection every RB_INTERVAL steps, one
6// retarded-time audio sum per audio sample, and one movie-frame extraction at
7// the end. Audio, frame, and statistics are read back after every batch.
9import {
10 type PhysParams,
11 type Grid,
12 type Material,
13 makeGrid,
14 makeMaterial,
15 nodeX,
16 nodeY,
17 trapWeight,
18 HIST_LEN,
19 RB_INTERVAL,
20 RB_INTERVAL_HELD,
21 RHO_AIR,
22 SPEED_OF_SOUND,
23} from "../params.ts";
24import { maxAngularFrequency } from "./cpuRef.ts";
25import commonWgsl from "./shaders/common.wgsl?raw";
26import stepWgsl from "./shaders/step.wgsl?raw";
27import rigidWgsl from "./shaders/rigid.wgsl?raw";
28import audioWgsl from "./shaders/audio.wgsl?raw";
29import extractWgsl from "./shaders/extract.wgsl?raw";
31export type Phase = "push" | "hold" | "recording" | "done";
33export interface SimStatus {
34 phase: Phase;
35 /** Simulation time relative to the release [s]. */
36 t: number;
37 totalSteps: number;
38 ke: number;
39 wmax: number;
40 samples: number;
41 frames: number;
42 peakPressure: number;
43 delayClamped: boolean;
44}
46const STATS_LEN = 16;
48export class Simulation {
49 readonly grid: Grid;
50 readonly mat: Material;
51 readonly dt: number;
52 /** Time steps per audio sample. */
53 readonly stepsPerSample: number;
54 readonly samplesPerBatch: number;
55 readonly stepsPerBatch: number;
56 readonly omegaMax: number;
58 /** Raw listener pressure [Pa] at fs, from the release. */
59 audio: Float32Array = new Float32Array(0);
60 samples = 0;
61 /** Movie frames of w [m]; frame k is at t = k / fps. */
62 frames: Float32Array<ArrayBuffer>[] = [];
64 phase: Phase = "push";
65 /** Steps since the start of the current phase clock (prep or recording). */
66 private stepCount = 0;
67 private prepTime = 0;
68 totalSteps = 0;
69 ke = 0;
70 wmax = 0;
71 peakPressure = 0;
72 delayClamped = false;
73 private hpState = { y: 0, x: 0 };
75 private device: GPUDevice;
76 private params: PhysParams;
77 private paramsBuf: GPUBuffer;
78 private stepBuf: GPUBuffer;
79 private stepStride: number;
80 private stepData: ArrayBuffer;
81 private pos: GPUBuffer[];
82 private vel: GPUBuffer[];
83 private hist: GPUBuffer;
84 private react: GPUBuffer;
85 private lw: GPUBuffer;
86 private audioOut: GPUBuffer;
87 private frameBuf: GPUBuffer;
88 private statsBuf: GPUBuffer;
89 private staging: GPUBuffer[];
90 private stagingIdx = 0;
91 /** Index of the buffer pair holding the current state. */
92 private cur = 0;
93 /** The `displayW` buffer is a plain f32 array of w for the renderer. */
94 readonly displayW: GPUBuffer;
96 private stepPipe: GPUComputePipeline;
97 private sumsPipe: GPUComputePipeline;
98 private applyPipe: GPUComputePipeline;
99 private audioPipe: GPUComputePipeline;
100 private extractPipe: GPUComputePipeline;
101 private stepBG: GPUBindGroup[];
102 private rbBG: GPUBindGroup[];
103 private audioBG: GPUBindGroup;
104 private extractBG: GPUBindGroup[];
105 private displayBG: GPUBindGroup[];
106 private stagingSize: number;
108 constructor(device: GPUDevice, params: PhysParams) {
109 this.device = device;
110 this.params = { ...params };
111 const g = makeGrid(params);
112 const m = makeMaterial(params);
113 this.grid = g;
114 this.mat = m;
116 // Stable time step, aligned so that an integer number of steps make one audio sample.
117 this.omegaMax = maxAngularFrequency(g, m);
118 const dtMax = (0.85 * 2) / this.omegaMax;
119 this.stepsPerSample = Math.ceil(1 / (params.fs * dtMax));
120 this.dt = 1 / (params.fs * this.stepsPerSample);
121 this.samplesPerBatch = Math.max(1, Math.round(params.fs / params.fps));
122 this.stepsPerBatch = this.samplesPerBatch * this.stepsPerSample;
124 const n = g.n;
125 const f32 = (size: number, usage = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST) =>
126 device.createBuffer({ size: Math.max(16, size * 4), usage });
128 this.pos = [f32(4 * n), f32(4 * n)]; // [u | v | w | wLo]
129 this.vel = [f32(3 * n), f32(3 * n)]; // [du | dv | dw]
130 this.hist = f32(HIST_LEN * n);
131 this.react = f32(n);
132 this.lw = f32(2 * n);
133 this.audioOut = f32(this.samplesPerBatch);
134 this.frameBuf = f32(n);
135 this.displayW = f32(n);
136 this.statsBuf = f32(STATS_LEN);
137 this.stagingSize = (this.samplesPerBatch + n + STATS_LEN) * 4;
138 this.staging = [0, 1].map(() =>
139 device.createBuffer({ size: this.stagingSize, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST }),
140 );
142 // Constant parameters.
143 let mass = 0, Ix = 0, Iy = 0;
144 for (let j = 0; j < g.ny; j++) {
145 for (let i = 0; i < g.nx; i++) {
146 const mk = m.rhoh * g.hx * g.hy * trapWeight(g, i, j);
147 mass += mk;
148 Ix += mk * nodeY(g, j) ** 2;
149 Iy += mk * nodeX(g, i) ** 2;
150 }
151 }
152 const pf = new Float32Array(20);
153 const pu = new Uint32Array(pf.buffer);
154 pu[0] = g.nx; pu[1] = g.ny; pu[2] = n; pu[3] = HIST_LEN;
155 pf[4] = g.hx; pf[5] = g.hy; pf[6] = this.dt; pf[7] = m.nu;
156 pf[8] = m.D; pf[9] = m.C; pf[10] = m.G; pf[11] = m.rhoh;
157 pf[12] = params.Lx / 2; pf[13] = -params.Ly / 2; pf[14] = params.fingerRadius ** 2; pf[15] = mass;
158 pf[16] = Ix; pf[17] = Iy; pf[18] = Ix + Iy; pf[19] = 0;
159 this.paramsBuf = device.createBuffer({ size: pf.byteLength, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
160 device.queue.writeBuffer(this.paramsBuf, 0, pf);
162 // Per-step parameters, one 48-byte struct per step at a dynamic offset.
163 this.stepStride = Math.max(48, device.limits.minUniformBufferOffsetAlignment);
164 this.stepData = new ArrayBuffer(this.stepStride * this.stepsPerBatch);
165 this.stepBuf = device.createBuffer({ size: this.stepData.byteLength, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
167 const mk = (code: string, entry: string, layout: GPUPipelineLayout | "auto" = "auto") =>
168 device.createComputePipeline({
169 layout,
170 compute: { module: device.createShaderModule({ code: commonWgsl + code }), entryPoint: entry },
171 });
172 const entry = (binding: number, type: GPUBufferBindingType, hasDynamicOffset = false): GPUBindGroupLayoutEntry => ({
173 binding,
174 visibility: GPUShaderStage.COMPUTE,
175 buffer: { type, hasDynamicOffset },
176 });
177 const stepLayout = device.createBindGroupLayout({
178 entries: [
179 entry(0, "uniform"),
180 entry(1, "uniform", true),
181 entry(2, "read-only-storage"),
182 entry(3, "read-only-storage"),
183 entry(4, "storage"),
184 entry(5, "storage"),
185 entry(6, "storage"),
186 entry(7, "storage"),
187 ],
188 });
189 this.stepPipe = mk(stepWgsl, "main", device.createPipelineLayout({ bindGroupLayouts: [stepLayout] }));
190 const audioLayout = device.createBindGroupLayout({
191 entries: [entry(0, "uniform"), entry(1, "uniform", true), entry(2, "read-only-storage"), entry(3, "read-only-storage"), entry(4, "storage")],
192 });
193 const rigidModule = device.createShaderModule({ code: commonWgsl + rigidWgsl });
194 const rbLayout = device.createBindGroupLayout({
195 entries: [
196 { binding: 0, visibility: GPUShaderStage.COMPUTE, buffer: { type: "uniform" } },
197 { binding: 1, visibility: GPUShaderStage.COMPUTE, buffer: { type: "storage" } },
198 { binding: 2, visibility: GPUShaderStage.COMPUTE, buffer: { type: "storage" } },
199 { binding: 3, visibility: GPUShaderStage.COMPUTE, buffer: { type: "storage" } },
200 ],
201 });
202 const rbPipeLayout = device.createPipelineLayout({ bindGroupLayouts: [rbLayout] });
203 this.sumsPipe = device.createComputePipeline({ layout: rbPipeLayout, compute: { module: rigidModule, entryPoint: "sums" } });
204 this.applyPipe = device.createComputePipeline({ layout: rbPipeLayout, compute: { module: rigidModule, entryPoint: "apply" } });
205 this.audioPipe = mk(audioWgsl, "main", device.createPipelineLayout({ bindGroupLayouts: [audioLayout] }));
206 this.extractPipe = mk(extractWgsl, "main");
208 const sp = { buffer: this.stepBuf, size: 48 };
209 this.stepBG = [0, 1].map((p) =>
210 device.createBindGroup({
211 layout: stepLayout,
212 entries: [
213 { binding: 0, resource: { buffer: this.paramsBuf } },
214 { binding: 1, resource: sp },
215 { binding: 2, resource: { buffer: this.pos[p] } },
216 { binding: 3, resource: { buffer: this.vel[p] } },
217 { binding: 4, resource: { buffer: this.pos[1 - p] } },
218 { binding: 5, resource: { buffer: this.vel[1 - p] } },
219 { binding: 6, resource: { buffer: this.hist } },
220 { binding: 7, resource: { buffer: this.react } },
221 ],
222 }),
223 );
224 this.rbBG = [0, 1].map((p) =>
225 device.createBindGroup({
226 layout: rbLayout,
227 entries: [
228 { binding: 0, resource: { buffer: this.paramsBuf } },
229 { binding: 1, resource: { buffer: this.pos[p] } },
230 { binding: 2, resource: { buffer: this.vel[p] } },
231 { binding: 3, resource: { buffer: this.statsBuf } },
232 ],
233 }),
234 );
235 this.audioBG = device.createBindGroup({
236 layout: audioLayout,
237 entries: [
238 { binding: 0, resource: { buffer: this.paramsBuf } },
239 { binding: 1, resource: sp },
240 { binding: 2, resource: { buffer: this.hist } },
241 { binding: 3, resource: { buffer: this.lw } },
242 { binding: 4, resource: { buffer: this.audioOut } },
243 ],
244 });
245 const extractBG = (p: number, out: GPUBuffer) =>
246 device.createBindGroup({
247 layout: this.extractPipe.getBindGroupLayout(0),
248 entries: [
249 { binding: 0, resource: { buffer: this.paramsBuf } },
250 { binding: 1, resource: { buffer: this.pos[p] } },
251 { binding: 2, resource: { buffer: out } },
252 ],
253 });
254 this.extractBG = [0, 1].map((p) => extractBG(p, this.frameBuf));
255 this.displayBG = [0, 1].map((p) => extractBG(p, this.displayW));
257 this.setListener(params.listenerDist, params.listenerAzimuth, params.listenerElevation, params.radiation);
258 }
260 /** Recomputes the per-node weights and delays of the listener sum. Takes effect on later samples. */
261 setListener(dist: number, azimuthDeg: number, elevationDeg: number, radiation: "rayleigh" | "dipole"): void {
262 const g = this.grid;
263 const az = (azimuthDeg * Math.PI) / 180;
264 const el = (elevationDeg * Math.PI) / 180;
265 const L = [dist * Math.sin(az) * Math.cos(el), dist * Math.sin(el), dist * Math.cos(az) * Math.cos(el)];
266 const data = new Float32Array(2 * g.n);
267 let dmin = Infinity;
268 for (let j = 0; j < g.ny; j++) {
269 for (let i = 0; i < g.nx; i++) {
270 const k = j * g.nx + i;
271 const rx = L[0] - nodeX(g, i), ry = L[1] - nodeY(g, j), rz = L[2];
272 const r = Math.sqrt(rx * rx + ry * ry + rz * rz);
273 const dA = g.hx * g.hy * trapWeight(g, i, j);
274 let wgt = (RHO_AIR * dA) / (2 * Math.PI * r);
275 if (radiation === "dipole") wgt *= Math.abs(rz) / r;
276 data[2 * k] = wgt;
277 data[2 * k + 1] = (r / SPEED_OF_SOUND) * this.params.fs;
278 dmin = Math.min(dmin, data[2 * k + 1]);
279 }
280 }
281 this.delayClamped = false;
282 for (let k = 0; k < g.n; k++) {
283 let d = data[2 * k + 1] - dmin;
284 if (d > HIST_LEN - 2) {
285 d = HIST_LEN - 2;
286 this.delayClamped = true;
287 }
288 data[2 * k + 1] = d;
289 }
290 this.device.queue.writeBuffer(this.lw, 0, data);
291 this.params.listenerDist = dist;
292 this.params.listenerAzimuth = azimuthDeg;
293 this.params.listenerElevation = elevationDeg;
294 this.params.radiation = radiation;
295 }
297 setDamping(sigma0: number, sigma1: number): void {
298 this.params.sigma0 = sigma0;
299 this.params.sigma1 = sigma1;
300 }
302 setDuration(duration: number): void {
303 this.params.duration = duration;
304 if (this.phase === "done" && this.samples < this.targetSamples()) this.phase = "recording";
305 }
307 targetSamples(): number {
308 return Math.round(this.params.duration * this.params.fs);
309 }
311 status(): SimStatus {
312 const t = this.phase === "push" || this.phase === "hold" ? this.prepTime - this.prepDuration() : this.stepCount * this.dt;
313 return {
314 phase: this.phase,
315 t,
316 totalSteps: this.totalSteps,
317 ke: this.ke,
318 wmax: this.wmax,
319 samples: this.samples,
320 frames: this.frames.length,
321 peakPressure: this.peakPressure,
322 delayClamped: this.delayClamped,
323 };
324 }
326 private prepDuration(): number {
327 return this.params.rampTime + this.params.holdMax;
328 }
330 /** Enqueues an extraction of the current w field into `displayW` (for the live view). */
331 encodeDisplay(encoder: GPUCommandEncoder): void {
332 const pass = encoder.beginComputePass();
333 pass.setPipeline(this.extractPipe);
334 pass.setBindGroup(0, this.displayBG[this.cur]);
335 pass.dispatchWorkgroups(Math.ceil(this.grid.n / 256));
336 pass.end();
337 }
339 /** Listener audio with the radiation post-processing applied [Pa]. */
340 processedAudio(): Float32Array {
341 return this.processed.subarray(0, this.samples);
342 }
343 private processed: Float32Array = new Float32Array(0);
345 private appendAudio(raw: Float32Array): void {
346 const need = this.samples + raw.length;
347 if (this.audio.length < need) {
348 const grow = Math.max(need, 2 * this.audio.length, this.params.fs);
349 const a = new Float32Array(grow);
350 a.set(this.audio.subarray(0, this.samples));
351 this.audio = a;
352 const b = new Float32Array(grow);
353 b.set(this.processed.subarray(0, this.samples));
354 this.processed = b;
355 }
356 this.audio.set(raw, this.samples);
357 // Dipole option: first-order high-pass at the baffle cutoff c / (2 sqrt(Lx Ly)).
358 const dipole = this.params.radiation === "dipole";
359 const fc = SPEED_OF_SOUND / (2 * Math.sqrt(this.params.Lx * this.params.Ly));
360 const alpha = 1 / (1 + (2 * Math.PI * fc) / this.params.fs);
361 for (let k = 0; k < raw.length; k++) {
362 const x = raw[k];
363 let y = x;
364 if (dipole) {
365 y = alpha * (this.hpState.y + x - this.hpState.x);
366 }
367 this.hpState = { y, x };
368 this.processed[this.samples + k] = y;
369 this.peakPressure = Math.max(this.peakPressure, Math.abs(y));
370 }
371 this.samples = need;
372 }
374 /** Runs one batch (one movie frame of time). Resolves when its results have been read back. */
375 async runBatch(): Promise<void> {
376 if (this.phase === "done") return;
377 const p = this.params;
378 const recording = this.phase === "recording";
379 const nSteps = this.stepsPerBatch;
380 const stepsLeft = recording ? (this.targetSamples() - this.samples) * this.stepsPerSample : nSteps;
381 const steps = Math.min(nSteps, Math.max(0, stepsLeft));
382 if (steps === 0) {
383 this.phase = "done";
384 return;
385 }
387 // Fill the per-step parameters.
388 const u32 = new Uint32Array(this.stepData);
389 const i32 = new Int32Array(this.stepData);
390 const f32 = new Float32Array(this.stepData);
391 const stride = this.stepStride / 4;
392 const audioStepsInBatch: number[] = [];
393 for (let s = 0; s < steps; s++) {
394 const o = s * stride;
395 const local = this.stepCount + s;
396 u32[o] = this.totalSteps + s;
397 let flags = 0, pushW = 0, pushV = 0, sigma0 = p.sigma0, slot = -1, outIdx = -1, releaseGain = 0;
398 if (!recording) {
399 const t = this.prepTime + (s + 1) * this.dt; // state after this step
400 const tau = Math.min(1, t / p.rampTime);
401 const smooth = tau * tau * (3 - 2 * tau);
402 const dsmooth = tau < 1 ? (6 * tau * (1 - tau)) / p.rampTime : 0;
403 flags = 1 | (tau >= 1 ? 2 : 0); // record the reaction once the ramp is complete
404 pushW = p.pushAmount * smooth;
405 pushV = p.pushAmount * dsmooth;
406 sigma0 = p.settleSigma0;
407 } else {
408 const t = local * this.dt;
409 if (p.releaseTime > 0 && t < p.releaseTime) {
410 const tau = t / p.releaseTime;
411 releaseGain = 1 - tau * tau * (3 - 2 * tau);
412 flags = 4;
413 }
414 if (local % this.stepsPerSample === 0) {
415 const sampleIdx = local / this.stepsPerSample;
416 slot = sampleIdx % HIST_LEN;
417 outIdx = audioStepsInBatch.length;
418 audioStepsInBatch.push(s);
419 }
420 }
421 u32[o + 1] = flags;
422 i32[o + 2] = slot;
423 i32[o + 3] = outIdx;
424 f32[o + 4] = pushW;
425 f32[o + 5] = pushV;
426 f32[o + 6] = sigma0;
427 f32[o + 7] = p.sigma1;
428 f32[o + 8] = releaseGain;
429 }
430 this.device.queue.writeBuffer(this.stepBuf, 0, this.stepData, 0, steps * this.stepStride);
432 // Encode the batch in chunks so that the GPU starts while JS is still encoding.
433 const CHUNK = 1024;
434 let enc = this.device.createCommandEncoder();
435 let pass = enc.beginComputePass();
436 const wgX = Math.ceil(this.grid.nx / 16), wgY = Math.ceil(this.grid.ny / 16);
437 const wgN = Math.ceil(this.grid.n / 256);
438 let cur = this.cur;
439 let audioPtr = 0;
440 const rbInterval = recording ? RB_INTERVAL : RB_INTERVAL_HELD;
441 let stepBound = false;
442 for (let s = 0; s < steps; s++) {
443 if (s > 0 && s % CHUNK === 0) {
444 pass.end();
445 this.device.queue.submit([enc.finish()]);
446 enc = this.device.createCommandEncoder();
447 pass = enc.beginComputePass();
448 stepBound = false;
449 }
450 if (!stepBound) {
451 pass.setPipeline(this.stepPipe);
452 stepBound = true;
453 }
454 pass.setBindGroup(0, this.stepBG[cur], [s * this.stepStride]);
455 pass.dispatchWorkgroups(wgX, wgY);
456 cur = 1 - cur;
457 const global = this.totalSteps + s + 1;
458 if (global % rbInterval === 0 || s === steps - 1) {
459 pass.setPipeline(this.sumsPipe);
460 pass.setBindGroup(0, this.rbBG[cur]);
461 pass.dispatchWorkgroups(1);
462 pass.setPipeline(this.applyPipe);
463 pass.setBindGroup(0, this.rbBG[cur]);
464 pass.dispatchWorkgroups(wgN);
465 stepBound = false;
466 }
467 if (audioPtr < audioStepsInBatch.length && audioStepsInBatch[audioPtr] === s) {
468 pass.setPipeline(this.audioPipe);
469 pass.setBindGroup(0, this.audioBG, [s * this.stepStride]);
470 pass.dispatchWorkgroups(1);
471 audioPtr++;
472 stepBound = false;
473 }
474 }
475 pass.setPipeline(this.extractPipe);
476 pass.setBindGroup(0, this.extractBG[cur]);
477 pass.dispatchWorkgroups(wgN);
478 pass.end();
479 const staging = this.staging[this.stagingIdx];
480 this.stagingIdx = 1 - this.stagingIdx;
481 const nAudio = audioStepsInBatch.length;
482 enc.copyBufferToBuffer(this.audioOut, 0, staging, 0, Math.max(4, nAudio * 4));
483 enc.copyBufferToBuffer(this.frameBuf, 0, staging, this.samplesPerBatch * 4, this.grid.n * 4);
484 enc.copyBufferToBuffer(this.statsBuf, 0, staging, (this.samplesPerBatch + this.grid.n) * 4, STATS_LEN * 4);
485 this.device.queue.submit([enc.finish()]);
486 this.cur = cur;
487 this.totalSteps += steps;
488 this.stepCount += steps;
489 if (!recording) this.prepTime += steps * this.dt;
491 await staging.mapAsync(GPUMapMode.READ);
492 const view = new Float32Array(staging.getMappedRange());
493 const stats = view.subarray(this.samplesPerBatch + this.grid.n, this.samplesPerBatch + this.grid.n + STATS_LEN);
494 this.ke = stats[12];
495 this.wmax = stats[13];
496 if (recording) {
497 this.appendAudio(view.slice(0, nAudio));
498 this.frames.push(view.slice(this.samplesPerBatch, this.samplesPerBatch + this.grid.n));
499 } else {
500 this.lastPrepFrame = view.slice(this.samplesPerBatch, this.samplesPerBatch + this.grid.n);
501 }
502 staging.unmap();
504 if (!recording) {
505 if (this.phase === "push" && this.prepTime >= p.rampTime) this.phase = "hold";
506 const settled = this.phase === "hold" && this.ke < p.settleKE;
507 if (settled || this.prepTime >= this.prepDuration()) this.release();
508 } else if (this.samples >= this.targetSamples()) {
509 this.phase = "done";
510 }
511 }
512 private lastPrepFrame: Float32Array<ArrayBuffer> | null = null;
514 private release(): void {
515 this.phase = "recording";
516 this.stepCount = 0;
517 this.totalSteps = 0;
518 // Frame 0 is the held, settled shape.
519 if (this.lastPrepFrame) this.frames.push(this.lastPrepFrame);
520 }
522 /** Reads back the full state (debugging and tests). */
523 async readState(): Promise<{ pos: Float32Array; vel: Float32Array }> {
524 const n = this.grid.n;
525 const stg = this.device.createBuffer({ size: 7 * n * 4, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
526 const enc = this.device.createCommandEncoder();
527 enc.copyBufferToBuffer(this.pos[this.cur], 0, stg, 0, 4 * n * 4);
528 enc.copyBufferToBuffer(this.vel[this.cur], 0, stg, 4 * n * 4, 3 * n * 4);
529 this.device.queue.submit([enc.finish()]);
530 await stg.mapAsync(GPUMapMode.READ);
531 const all = new Float32Array(stg.getMappedRange()).slice();
532 stg.unmap();
533 stg.destroy();
534 // Returned as [u | v | w | wLo] and [du | dv | dw].
535 return { pos: all.subarray(0, 4 * n), vel: all.subarray(4 * n) };
536 }
538 destroy(): void {
539 for (const b of [...this.pos, ...this.vel, this.hist, this.react, this.lw, this.audioOut, this.frameBuf, this.displayW, this.statsBuf, this.paramsBuf, this.stepBuf, ...this.staging]) b.destroy();
540 }
542 get fs(): number {
543 return this.params.fs;
544 }
545 get fps(): number {
546 return this.params.fps;
547 }
548 get physParams(): PhysParams {
549 return this.params;
550 }
551}