@margoengine/shader 0.0.0-stage → 1.0.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +1919 -2
- package/dist/attribute.d.ts +28 -0
- package/dist/black-hole.d.ts +246 -0
- package/dist/black-hole.js +445 -0
- package/dist/clock-BLGNexlt.js +52 -0
- package/dist/clock.d.ts +42 -0
- package/dist/compute-CXGG9qvI.js +360 -0
- package/dist/compute-texture.d.ts +100 -0
- package/dist/compute-texture.js +131 -0
- package/dist/compute-volume.d.ts +57 -0
- package/dist/compute-volume.js +130 -0
- package/dist/compute.d.ts +200 -0
- package/dist/control-CFjkGPBk.js +201 -0
- package/dist/control.d.ts +93 -0
- package/dist/deform.d.ts +111 -0
- package/dist/deform.js +89 -0
- package/dist/display-BrJM_Qkd.js +5 -0
- package/dist/editor-model.d.ts +192 -0
- package/dist/editor-pass.d.ts +71 -0
- package/dist/editor-pass.js +216 -0
- package/dist/editor.d.ts +150 -0
- package/dist/editor.js +1071 -0
- package/dist/effects.d.ts +150 -0
- package/dist/effects.js +87 -0
- package/dist/errors-CsQwshHA.js +7 -0
- package/dist/glsl/emit.d.ts +43 -0
- package/dist/glsl/host.d.ts +55 -0
- package/dist/glsl/material.d.ts +173 -0
- package/dist/glsl/parser.d.ts +76 -0
- package/dist/glsl/preprocess.d.ts +9 -0
- package/dist/glsl/presets.d.ts +33 -0
- package/dist/glsl/program.d.ts +210 -0
- package/dist/glsl/scene.d.ts +9 -0
- package/dist/glsl-material.d.ts +82 -0
- package/dist/glsl-material.js +288 -0
- package/dist/glsl-pass.d.ts +93 -0
- package/dist/glsl-pass.js +186 -0
- package/dist/glsl.d.ts +94 -0
- package/dist/glsl.js +170 -0
- package/dist/gpu-DQJk2xAv.js +55 -0
- package/dist/graph.d.ts +82 -0
- package/dist/graph.js +365 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +103 -0
- package/dist/lighting-JU9yQPfM.js +77 -0
- package/dist/lighting.d.ts +62 -0
- package/dist/lighting.js +1 -0
- package/dist/material-C6bpqlnE.js +1184 -0
- package/dist/material-CZ8V1FeA.js +299 -0
- package/dist/material.d.ts +79 -0
- package/dist/node-B6yoIC9V.js +590 -0
- package/dist/node.d.ts +433 -0
- package/dist/noise.d.ts +38 -0
- package/dist/noise.js +107 -0
- package/dist/own-stack-D1XnXrrz.js +11 -0
- package/dist/own-stack.d.ts +12 -0
- package/dist/pass.d.ts +109 -0
- package/dist/pass.js +239 -0
- package/dist/post-DLpZ110L.js +113 -0
- package/dist/post.d.ts +69 -0
- package/dist/preprocess-CWGWlBWQ.js +1195 -0
- package/dist/raw-0AYej3Ak.js +1500 -0
- package/dist/raw.d.ts +744 -0
- package/dist/raw.js +1 -0
- package/dist/readback.d.ts +42 -0
- package/dist/readback.js +85 -0
- package/dist/scope.d.ts +21 -0
- package/dist/serialization.d.ts +11 -0
- package/dist/serialization.js +192 -0
- package/dist/shadertoy/sound.d.ts +48 -0
- package/dist/shadertoy.d.ts +249 -0
- package/dist/shadertoy.js +909 -0
- package/dist/shared/caster.d.ts +159 -0
- package/dist/shared/fog.d.ts +33 -0
- package/dist/shared/fractal.d.ts +9 -0
- package/dist/shared/msaa.d.ts +30 -0
- package/dist/shared/stack.d.ts +22 -0
- package/dist/sound-CF_dzP41.js +78 -0
- package/dist/storage-format-DWaiSxmq.js +25 -0
- package/dist/storage-format.d.ts +7 -0
- package/dist/subgroups.d.ts +97 -0
- package/dist/subgroups.js +95 -0
- package/dist/texture-BawKO_h9.js +62 -0
- package/dist/texture-array.d.ts +7 -0
- package/dist/texture-array.js +11 -0
- package/dist/texture.d.ts +16 -0
- package/dist/utils.d.ts +106 -0
- package/dist/utils.js +90 -0
- package/dist/view-rect-Bm1ac-TK.js +16 -0
- package/package.json +149 -4
package/dist/raw.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as RawMesh, n as RawPicking, r as RawShaderMaterial, i as RawShaders } from "./raw-0AYej3Ak.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
2
|
+
import { StorageBuffer, type ComputeBody, type ComputeCount, type StorageType } from './compute.js';
|
|
3
|
+
import { type Node } from './node.js';
|
|
4
|
+
/** The typed array holding a `StorageType`'s elements: Float32Array for f32 types, Int32Array for i32, Uint32Array for u32. */
|
|
5
|
+
export type StorageArray<T extends StorageType = StorageType> = T extends 'f32' | 'vec2f' | 'vec4f' ? Float32Array<ArrayBuffer> : T extends 'i32' | 'vec2i' | 'vec4i' ? Int32Array<ArrayBuffer> : Uint32Array<ArrayBuffer>;
|
|
6
|
+
/** Options of {@link computeReadback}. */
|
|
7
|
+
export interface ComputeReadbackOptions {
|
|
8
|
+
/** Invocations per workgroup, integer 1..256. Default 64. */
|
|
9
|
+
workgroupSize?: number;
|
|
10
|
+
/** Label of the job's GPU objects and errors. Default `'shader:readback:<n>'` (n counts jobs). */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** Cancels the job: the promise rejects with `signal.reason` and the job's GPU objects are released. */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
/** Milliseconds before the job rejects with MargoError `'failed'`, more than 0. Default 30,000; `Infinity` waits. */
|
|
15
|
+
timeout?: number;
|
|
16
|
+
}
|
|
17
|
+
/** What {@link computeReadback} resolves with. */
|
|
18
|
+
export interface ComputeReadback<T extends StorageType = StorageType> {
|
|
19
|
+
/** The output buffer's elements after the dispatch: a copy the caller owns, not `output.data` and not GPU memory. */
|
|
20
|
+
readonly data: StorageArray<T>;
|
|
21
|
+
/** Element type of `output`. */
|
|
22
|
+
readonly type: T;
|
|
23
|
+
/** Elements read, `output.count`. */
|
|
24
|
+
readonly count: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Runs `body` once for `count` invocations (one dispatch of one submitted command buffer, outside any frame) and
|
|
28
|
+
* resolves with a copy of `output` read back from the GPU. `target` is a GPUDevice or an engine (its current device).
|
|
29
|
+
* Storage the body reads or writes, `output` included, is uploaded first if its `data` changed; it stays the
|
|
30
|
+
* caller's to dispose. Frame values read 1 x 1 for the resolution and 0 for deltaTime.
|
|
31
|
+
*
|
|
32
|
+
* Settlement, exactly once:
|
|
33
|
+
* - resolves with the copy once the GPU finished;
|
|
34
|
+
* - rejects with `signal.reason` when `signal` aborts first (before the call: without touching the GPU);
|
|
35
|
+
* - rejects with MargoError `'disposed'` when the engine was disposed during the job, `'failed'` when the device was
|
|
36
|
+
* lost (its reason is in the message), the WGSL or a GPU call failed validation or memory, or `timeout` elapsed,
|
|
37
|
+
* and `'unsupported'` for an engine without WebGPU; RangeError for invalid counts or a too-large `output`.
|
|
38
|
+
*
|
|
39
|
+
* Resources: whatever the outcome, the job's readback buffer and uniform buffer are destroyed and its listeners and
|
|
40
|
+
* timer removed when it settles; a pending map is cancelled by that destroy. Nothing of the job outlives its promise.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeReadback<T extends StorageType>(target: GPUDevice | EngineKernel, count: ComputeCount, body: (index: Node<'u32'>) => ComputeBody, output: StorageBuffer<T>, options?: ComputeReadbackOptions): Promise<ComputeReadback<T>>;
|
package/dist/readback.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
const a=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
|
+
import { It as e } from "./node-B6yoIC9V.js";
|
|
5
|
+
import { c as t, n, t as r } from "./compute-CXGG9qvI.js";
|
|
6
|
+
import { MargoError as i } from "@margoengine/math/errors";
|
|
7
|
+
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
8
|
+
//#region src/readback.ts
|
|
9
|
+
var o = 0, s = (e) => typeof e.createCommandEncoder == "function";
|
|
10
|
+
async function c(c, l, u, d, f = {}) {
|
|
11
|
+
let { signal: p, timeout: m = 3e4, workgroupSize: h, name: g = "shader:readback:" + o++ } = f;
|
|
12
|
+
if (p?.throwIfAborted(), !(d instanceof n)) throw TypeError("computeReadback output must be a StorageBuffer");
|
|
13
|
+
if (!(m > 0)) throw RangeError("computeReadback timeout must be more than 0 milliseconds");
|
|
14
|
+
let _ = s(c) ? void 0 : a(c);
|
|
15
|
+
if (_?.disposed) throw new i("disposed", "Engine is disposed; read back compute results with a live engine");
|
|
16
|
+
let v = _ ? _.gpu : c;
|
|
17
|
+
if (!v) throw new i("unsupported", "computeReadback requires WebGPU; the engine runs on the WebGL2 fallback");
|
|
18
|
+
let y = new r(l, u, {
|
|
19
|
+
workgroupSize: h,
|
|
20
|
+
name: g
|
|
21
|
+
}), b = d.data.byteLength;
|
|
22
|
+
if (b > v.limits.maxBufferSize) throw RangeError(`computeReadback output of ${b} bytes exceeds the device's ${v.limits.maxBufferSize}; read back a smaller output.`);
|
|
23
|
+
return new Promise((n, r) => {
|
|
24
|
+
let a, o = !1, s = () => {
|
|
25
|
+
p?.removeEventListener("abort", l), x(), clearTimeout(S), a?.destroy(), y.program.release(v);
|
|
26
|
+
}, c = (e, t) => {
|
|
27
|
+
if (!o) {
|
|
28
|
+
o = !0;
|
|
29
|
+
try {
|
|
30
|
+
s();
|
|
31
|
+
} catch {}
|
|
32
|
+
t ? n(t) : r(e);
|
|
33
|
+
}
|
|
34
|
+
}, l = () => c(p?.reason ?? new DOMException(`Compute readback "${g}" aborted`, "AbortError")), u = () => new i("disposed", `Engine was disposed during compute readback "${g}"; nothing was read back`), f = (e) => c(_?.disposed ? u() : new i("failed", `GPU device was lost (${e.reason}: ${e.message}) during compute readback "${g}"; run it again on a live device`)), h = (e) => {
|
|
35
|
+
if (_?.disposed) return c(u());
|
|
36
|
+
let t = () => c(_?.disposed ? u() : new i("failed", `Compute readback "${g}" failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
37
|
+
(async () => {
|
|
38
|
+
await v.queue.onSubmittedWorkDone(), v.pushErrorScope("validation"), await v.popErrorScope();
|
|
39
|
+
})().then(t, t);
|
|
40
|
+
};
|
|
41
|
+
p?.addEventListener("abort", l, { once: !0 });
|
|
42
|
+
let x = t(v, f), S = m === Infinity ? void 0 : setTimeout(() => c(new i("failed", `Compute readback "${g}" did not finish within ${m} ms; reduce the work or raise the timeout`)), m);
|
|
43
|
+
(async () => {
|
|
44
|
+
v.pushErrorScope("out-of-memory"), v.pushErrorScope("validation");
|
|
45
|
+
let t;
|
|
46
|
+
try {
|
|
47
|
+
let e = v.createCommandEncoder({ label: g });
|
|
48
|
+
y.encode(v, e, {
|
|
49
|
+
width: 1,
|
|
50
|
+
height: 1,
|
|
51
|
+
delta: 0
|
|
52
|
+
}), a = v.createBuffer({
|
|
53
|
+
label: g + ":readback",
|
|
54
|
+
size: b,
|
|
55
|
+
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST
|
|
56
|
+
}), e.copyBufferToBuffer(d.buffer(v), 0, a, 0, b), v.queue.submit([e.finish()]);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
t = e;
|
|
59
|
+
}
|
|
60
|
+
let n = [v.popErrorScope(), v.popErrorScope()];
|
|
61
|
+
if (t !== void 0) return Promise.allSettled(n), c(t);
|
|
62
|
+
let r = (await Promise.all(n)).find(Boolean);
|
|
63
|
+
if (o) return;
|
|
64
|
+
if (r) return c(new i("failed", `Compute readback "${g}" failed on the GPU: ${r.message}`));
|
|
65
|
+
let s = a;
|
|
66
|
+
if (await s.mapAsync(GPUMapMode.READ), o) return;
|
|
67
|
+
let l = s.getMappedRange().slice(0);
|
|
68
|
+
s.unmap();
|
|
69
|
+
let u = {
|
|
70
|
+
f32: Float32Array,
|
|
71
|
+
i32: Int32Array,
|
|
72
|
+
u32: Uint32Array
|
|
73
|
+
}[e(d.type)];
|
|
74
|
+
c(void 0, {
|
|
75
|
+
data: new u(l),
|
|
76
|
+
type: d.type,
|
|
77
|
+
count: d.count
|
|
78
|
+
});
|
|
79
|
+
})().catch((e) => {
|
|
80
|
+
o || h(e);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { c as computeReadback };
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Node } from './node.js';
|
|
2
|
+
/** What a storage write hands to the statement list it is made in. */
|
|
3
|
+
export interface Write {
|
|
4
|
+
readonly buffer: {
|
|
5
|
+
readonly atomic: boolean;
|
|
6
|
+
};
|
|
7
|
+
readonly index: Node;
|
|
8
|
+
readonly value: Node;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Side-effect nodes (atomics, statements) made while a ComputePass, `block` or control-flow body runs, in order; `store`
|
|
12
|
+
* is set inside statement bodies, where a storage write is a statement. Loop and Fn bodies collect nothing: they run
|
|
13
|
+
* their atomics only where the result is used.
|
|
14
|
+
*/
|
|
15
|
+
export declare const effects: {
|
|
16
|
+
list?: Node[];
|
|
17
|
+
store?: (write: Write) => void;
|
|
18
|
+
flush?: () => void;
|
|
19
|
+
};
|
|
20
|
+
/** Runs a loop or Fn body without collecting its effects. */
|
|
21
|
+
export declare const nested: <R>(body: () => R) => R;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type MaterialValueCodec } from '@margoengine/materials/serialization';
|
|
2
|
+
import type { ShaderMaterial as ShaderMaterialClass } from './glsl-material.js';
|
|
3
|
+
/** Owner codecs preserve compiled node programs, live uniforms, sampled textures, storage data and raw WGSL parameters. */
|
|
4
|
+
export declare const shaderMaterialCodecs: readonly MaterialValueCodec[];
|
|
5
|
+
/**
|
|
6
|
+
* The codec of a GLSL `ShaderMaterial` (`@margoengine/shader/glsl-material`): it keeps the GLSL, the options, the live
|
|
7
|
+
* uniform values and the render state, and restoring translates the GLSL again. It takes the class, so this entry
|
|
8
|
+
* stays free of the GLSL front end: `codecs: [...shaderMaterialCodecs, glslMaterialCodec(ShaderMaterial)]`. Without
|
|
9
|
+
* it a ShaderMaterial has no codec, and capturing one throws rather than saving it as plain WGSL.
|
|
10
|
+
*/
|
|
11
|
+
export declare function glslMaterialCodec(ShaderMaterial: typeof ShaderMaterialClass): MaterialValueCodec;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { cn as e, d as t, l as n, sn as r } from "./node-B6yoIC9V.js";
|
|
2
|
+
import { n as i } from "./compute-CXGG9qvI.js";
|
|
3
|
+
import { i as a, n as o, r as s } from "./texture-BawKO_h9.js";
|
|
4
|
+
import { t as c } from "./material-CZ8V1FeA.js";
|
|
5
|
+
import { r as l } from "./raw-0AYej3Ak.js";
|
|
6
|
+
import { t as u } from "./lighting-JU9yQPfM.js";
|
|
7
|
+
import { textureArray as d } from "./texture-array.js";
|
|
8
|
+
import { materialParameters as f, restoreMaterialParameters as p } from "@margoengine/materials/serialization";
|
|
9
|
+
//#region src/serialization.ts
|
|
10
|
+
var m = [
|
|
11
|
+
"fragmentCode",
|
|
12
|
+
"vertexCode",
|
|
13
|
+
"varyingFields",
|
|
14
|
+
"rederived",
|
|
15
|
+
"depthVertex",
|
|
16
|
+
"depthMove",
|
|
17
|
+
"depthFragment",
|
|
18
|
+
"depthFields",
|
|
19
|
+
"colourBindings",
|
|
20
|
+
"surfaceGraph",
|
|
21
|
+
"program"
|
|
22
|
+
], h = [
|
|
23
|
+
"lightingCode",
|
|
24
|
+
"lightModelCode",
|
|
25
|
+
"finalColor"
|
|
26
|
+
], g = (e, t) => Object.fromEntries(t.map((t) => [t, Reflect.get(e, t)])), _ = [
|
|
27
|
+
{
|
|
28
|
+
type: "shader-node-material",
|
|
29
|
+
test: (e) => e.constructor === c || e.constructor === u,
|
|
30
|
+
capture: (e) => ({
|
|
31
|
+
lighting: e instanceof u,
|
|
32
|
+
parameters: f(e),
|
|
33
|
+
compiled: g(e, [...m, ...e instanceof u ? h : []])
|
|
34
|
+
}),
|
|
35
|
+
restore: (e) => {
|
|
36
|
+
let t = e.lighting ? new u() : new c();
|
|
37
|
+
if (!e.compiled || m.some((t) => !Object.hasOwn(e.compiled, t)) || !(e.compiled.program instanceof n)) throw TypeError("Invalid compiled node material; use the matching shader serialization format");
|
|
38
|
+
for (let n of [...m, ...e.lighting ? h : []]) Reflect.set(t, n, e.compiled[n]);
|
|
39
|
+
return p(t, e.parameters), t;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "shader-uniform",
|
|
44
|
+
test: (e) => e instanceof t,
|
|
45
|
+
capture: (e) => ({
|
|
46
|
+
type: e.type,
|
|
47
|
+
name: e.name,
|
|
48
|
+
value: e.value
|
|
49
|
+
}),
|
|
50
|
+
restore: (e) => new t(e.value, e.type, e.name)
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "shader-storage",
|
|
54
|
+
test: (e) => e instanceof i,
|
|
55
|
+
capture: (e) => ({
|
|
56
|
+
data: e.data,
|
|
57
|
+
type: e.type,
|
|
58
|
+
atomic: e.atomic
|
|
59
|
+
}),
|
|
60
|
+
restore: (e) => new i(e.data, e.type, e.atomic)
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "shader-texture-resource",
|
|
64
|
+
test: (e) => e.prefix === "ndt" && !!e.source,
|
|
65
|
+
capture: (e) => ({
|
|
66
|
+
source: e.source,
|
|
67
|
+
dimension: Reflect.get(e.source, "dimension") ?? "2d"
|
|
68
|
+
}),
|
|
69
|
+
restore: (t) => {
|
|
70
|
+
let i = t.dimension === "cube" ? a(t.source, e(1, 0, 0)) : t.dimension === "3d" ? s(t.source, e(0)) : t.dimension === "2d-array" ? d(t.source, 0, r(0)) : o(t.source, r(0)), c = new n();
|
|
71
|
+
return c.stage({
|
|
72
|
+
kind: "fragment",
|
|
73
|
+
builtins: {}
|
|
74
|
+
}, [i]), c.resources[0].resource;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "shader-program",
|
|
79
|
+
test: (e) => e instanceof n,
|
|
80
|
+
capture: (e) => ({
|
|
81
|
+
base: e.base,
|
|
82
|
+
compute: e.compute,
|
|
83
|
+
size: e.size,
|
|
84
|
+
next: e.next,
|
|
85
|
+
members: e.members,
|
|
86
|
+
declarations: [...e.declarations],
|
|
87
|
+
resources: e.resources.map((t) => t === e.block ? {
|
|
88
|
+
name: t.name,
|
|
89
|
+
binding: t.binding,
|
|
90
|
+
block: !0
|
|
91
|
+
} : t)
|
|
92
|
+
}),
|
|
93
|
+
restore: (e) => {
|
|
94
|
+
let t = new n(e.base, e.compute);
|
|
95
|
+
t.size = e.size, t.next = e.next, t.members.push(...e.members);
|
|
96
|
+
for (let [n, r] of e.declarations) t.declarations.set(n, r);
|
|
97
|
+
for (let n of e.resources) {
|
|
98
|
+
let e = {
|
|
99
|
+
name: n.name,
|
|
100
|
+
binding: n.binding,
|
|
101
|
+
resource: n.resource ?? {
|
|
102
|
+
prefix: "ndu",
|
|
103
|
+
bindings: 1,
|
|
104
|
+
declare: () => "",
|
|
105
|
+
entries: () => []
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
t.resources.push(e), n.block && (t.block = e);
|
|
109
|
+
}
|
|
110
|
+
return t;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "shader-raw-material",
|
|
115
|
+
test: (e) => e.constructor === l,
|
|
116
|
+
capture: (e) => ({
|
|
117
|
+
vertexShader: e.vertexShader,
|
|
118
|
+
fragmentShader: e.fragmentShader,
|
|
119
|
+
vertexEntry: e.entries.vertex,
|
|
120
|
+
fragmentEntry: e.entries.fragment,
|
|
121
|
+
gbufferEntry: e.gbufferName,
|
|
122
|
+
velocityEntry: e.velocityName,
|
|
123
|
+
groups: e.groups,
|
|
124
|
+
...g(e, [
|
|
125
|
+
"name",
|
|
126
|
+
"uniforms",
|
|
127
|
+
"textures",
|
|
128
|
+
"storage",
|
|
129
|
+
"transparent",
|
|
130
|
+
"blending",
|
|
131
|
+
"depthTest",
|
|
132
|
+
"depthWrite",
|
|
133
|
+
"depthCompare",
|
|
134
|
+
"depthBias",
|
|
135
|
+
"depthBiasSlopeScale",
|
|
136
|
+
"alphaToCoverage",
|
|
137
|
+
"cull",
|
|
138
|
+
"colorWrite",
|
|
139
|
+
"wireframe",
|
|
140
|
+
"onError"
|
|
141
|
+
])
|
|
142
|
+
}),
|
|
143
|
+
restore: (e) => new l(e)
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
function v(e) {
|
|
147
|
+
if (typeof e != "function" || !(e.prototype instanceof l)) throw TypeError("glslMaterialCodec got no ShaderMaterial class; pass ShaderMaterial from @margoengine/shader/glsl-material");
|
|
148
|
+
return {
|
|
149
|
+
type: "shader-glsl-material",
|
|
150
|
+
test: (t) => t instanceof e,
|
|
151
|
+
capture: (e) => {
|
|
152
|
+
let { uniformNames: t, ...n } = e.source, r = e.uniforms;
|
|
153
|
+
return {
|
|
154
|
+
source: n,
|
|
155
|
+
uniforms: Object.fromEntries(Object.keys(r).map((e) => [e, { value: r[e].value }])),
|
|
156
|
+
state: g(e, [
|
|
157
|
+
"name",
|
|
158
|
+
"transparent",
|
|
159
|
+
"blending",
|
|
160
|
+
"depthTest",
|
|
161
|
+
"depthWrite",
|
|
162
|
+
"depthCompare",
|
|
163
|
+
"polygonOffset",
|
|
164
|
+
"polygonOffsetFactor",
|
|
165
|
+
"polygonOffsetUnits",
|
|
166
|
+
"depthBias",
|
|
167
|
+
"depthBiasSlopeScale",
|
|
168
|
+
"alphaToCoverage",
|
|
169
|
+
"cull",
|
|
170
|
+
"colorWrite",
|
|
171
|
+
"wireframe",
|
|
172
|
+
"onError"
|
|
173
|
+
])
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
restore: (t) => {
|
|
177
|
+
let { name: n, ...r } = t.state, i = new e({
|
|
178
|
+
...t.source,
|
|
179
|
+
uniforms: t.uniforms,
|
|
180
|
+
...n === void 0 ? {} : { name: n }
|
|
181
|
+
}), a = [
|
|
182
|
+
"polygonOffset",
|
|
183
|
+
"polygonOffsetFactor",
|
|
184
|
+
"polygonOffsetUnits"
|
|
185
|
+
];
|
|
186
|
+
for (let e of [...a, ...Object.keys(r).filter((e) => !a.includes(e))]) r[e] !== void 0 && Reflect.set(i, e, r[e]);
|
|
187
|
+
return i;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
export { v as glslMaterialCodec, _ as shaderMaterialCodecs };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PassContext } from '@margoengine/core/extension';
|
|
2
|
+
import type { StageOutput } from '../shared/stack.js';
|
|
3
|
+
type Context = Extract<PassContext, {
|
|
4
|
+
backend: 'webgpu';
|
|
5
|
+
}>;
|
|
6
|
+
/** What `toy.sound()` resolves to. */
|
|
7
|
+
export interface ShadertoySound {
|
|
8
|
+
/** Samples per second: the toy's iSampleRate. */
|
|
9
|
+
readonly sampleRate: number;
|
|
10
|
+
/** Left and right, one value from -1 to 1 per sample. */
|
|
11
|
+
readonly channels: readonly [Float32Array<ArrayBuffer>, Float32Array<ArrayBuffer>];
|
|
12
|
+
/** The samples as a two channel Web Audio buffer of `context`, ready for an `AudioBufferSourceNode`. */
|
|
13
|
+
audioBuffer(context: BaseAudioContext): AudioBuffer;
|
|
14
|
+
}
|
|
15
|
+
/** Samples per block edge: a block is EDGE x EDGE samples, row by row from the first row. */
|
|
16
|
+
export declare const EDGE = 512;
|
|
17
|
+
/** @internal One render of the Sound tab, advanced by the toy's frame pass. */
|
|
18
|
+
export declare class SoundJob {
|
|
19
|
+
private readonly samples;
|
|
20
|
+
private readonly sampleRate;
|
|
21
|
+
/** Draws the block whose first sample is `base` into `output`. */
|
|
22
|
+
private readonly draw;
|
|
23
|
+
readonly done: Promise<ShadertoySound>;
|
|
24
|
+
private resolve;
|
|
25
|
+
private reject;
|
|
26
|
+
private readonly blocks;
|
|
27
|
+
private readonly left;
|
|
28
|
+
private readonly right;
|
|
29
|
+
private next;
|
|
30
|
+
private read;
|
|
31
|
+
private over;
|
|
32
|
+
private device?;
|
|
33
|
+
private texture?;
|
|
34
|
+
private readonly output;
|
|
35
|
+
private frameContext?;
|
|
36
|
+
private readonly submitted;
|
|
37
|
+
constructor(samples: number, sampleRate: number,
|
|
38
|
+
/** Draws the block whose first sample is `base` into `output`. */
|
|
39
|
+
draw: (c: Context, base: number, output: StageOutput) => void, signal?: AbortSignal);
|
|
40
|
+
/** One frame: maps the block drawn last frame, then draws the next one. A new device starts the render again. */
|
|
41
|
+
frame(c: Context): void;
|
|
42
|
+
private map;
|
|
43
|
+
private finish;
|
|
44
|
+
/** Ends the render: the promise rejects with `reason`. */
|
|
45
|
+
stop(reason: unknown): void;
|
|
46
|
+
private release;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
3
|
+
import type { Engine, EnginePlugin, FrameGraph } from '@margoengine/core/extension';
|
|
4
|
+
import { ShaderPass, type ShaderPassOptions } from './glsl-pass.js';
|
|
5
|
+
import { type ShaderMaterialOptions } from './glsl/material.js';
|
|
6
|
+
import type { ShaderMaterial } from './glsl-material.js';
|
|
7
|
+
import type { RawTextureInput } from './raw.js';
|
|
8
|
+
import type { BindableTexture } from './texture.js';
|
|
9
|
+
import type { ShadertoySound } from './shadertoy/sound.js';
|
|
10
|
+
export type { ShadertoySound };
|
|
11
|
+
/** A buffer tab: Buffer A to D. */
|
|
12
|
+
export type ShadertoyBuffer = 'A' | 'B' | 'C' | 'D';
|
|
13
|
+
/** An image or video copied into a channel each frame (a video once it has a frame); iChannelTime is a video's `currentTime`. */
|
|
14
|
+
export type ShadertoyMedia = HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | HTMLImageElement;
|
|
15
|
+
/** Sound read as a 512 x 2 channel: row 0 (GL's lowest) its spectrum, row 1 its waveform, as an `AnalyserNode` gives them. */
|
|
16
|
+
export interface ShadertoyAudio {
|
|
17
|
+
getByteFrequencyData(array: Uint8Array): void;
|
|
18
|
+
getByteTimeDomainData(array: Uint8Array): void;
|
|
19
|
+
/** iChannelTime is its `currentTime`. */
|
|
20
|
+
readonly context?: {
|
|
21
|
+
readonly currentTime: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What a channel reads: a texture, `'input'` (the stack's colour, in a pass), a buffer (`'A'` to `'D'`), `'cubeA'`
|
|
26
|
+
* (the Cube A tab, a samplerCube), `'keyboard'`, a video or image, an `AnalyserNode`, or null (opaque black, as GL's
|
|
27
|
+
* unbound unit). A texture is a GPUTexture or view, a materials Texture, or `(device) => texture`, called once per
|
|
28
|
+
* device so it comes back by itself after a device restore. A plain GPUTexture or view belongs to the device that made
|
|
29
|
+
* it: after a restore the channel reads opaque black, `engine.onError` hears of it once (`'state'`, #borrowed-lost),
|
|
30
|
+
* and `toy.setChannel(index, texture)` gives it a new one.
|
|
31
|
+
*/
|
|
32
|
+
export type ShadertoyInput = RawTextureInput | 'input' | ShadertoyBuffer | 'cubeA' | 'keyboard' | ShadertoyMedia | ShadertoyAudio | null;
|
|
33
|
+
/** One of iChannel0 to iChannel3 with its sampling. */
|
|
34
|
+
export interface ShadertoyChannel {
|
|
35
|
+
/** What the channel reads. */
|
|
36
|
+
readonly texture: ShadertoyInput;
|
|
37
|
+
/**
|
|
38
|
+
* The sampler type the program sees: `'2d'` (sampler2D), `'cube'` (samplerCube) or `'3d'` (sampler3D). Default `'3d'`
|
|
39
|
+
* for a 3D GPUTexture, else `'2d'`; give it for a function that makes a 3D or cube texture.
|
|
40
|
+
*/
|
|
41
|
+
readonly type?: '2d' | 'cube' | '3d';
|
|
42
|
+
/** Default `'linear'`. `'mipmap'` is trilinear: buffers, videos, keyboard and audio get their mip levels made each frame; a texture brings its own. */
|
|
43
|
+
readonly filter?: 'nearest' | 'linear' | 'mipmap';
|
|
44
|
+
/** Default `'clamp'`. */
|
|
45
|
+
readonly wrap?: 'clamp' | 'repeat';
|
|
46
|
+
/** iChannelResolution of the channel in pixels. Default the source's size (a function's: the texture it made), or the target for `'input'` and buffers. */
|
|
47
|
+
readonly resolution?: readonly [number, number, number?];
|
|
48
|
+
}
|
|
49
|
+
/** A pass's source and its four channels. */
|
|
50
|
+
export interface ShadertoyPassSource {
|
|
51
|
+
/** GLSL with `void mainImage(out vec4 fragColor, in vec2 fragCoord)`, as written in Shadertoy's editor. */
|
|
52
|
+
readonly source: string;
|
|
53
|
+
readonly iChannel0?: ShadertoyChannel | ShadertoyInput;
|
|
54
|
+
readonly iChannel1?: ShadertoyChannel | ShadertoyInput;
|
|
55
|
+
readonly iChannel2?: ShadertoyChannel | ShadertoyInput;
|
|
56
|
+
readonly iChannel3?: ShadertoyChannel | ShadertoyInput;
|
|
57
|
+
}
|
|
58
|
+
/** The Cube A tab: a source with `void mainCubemap(out vec4 fragColor, in vec2 fragCoord, in vec3 rayOri, in vec3 rayDir)`. */
|
|
59
|
+
export interface ShadertoyCubeSource extends ShadertoyPassSource {
|
|
60
|
+
/** Pixels along each face's edge, a power of two from 1 to 2048. Default 1024. */
|
|
61
|
+
readonly size?: number;
|
|
62
|
+
}
|
|
63
|
+
/** Options for `toy.sound(options)`. */
|
|
64
|
+
export interface ShadertoySoundOptions {
|
|
65
|
+
/** Length in seconds, above 0 and at most 600. Default 180. */
|
|
66
|
+
readonly seconds?: number;
|
|
67
|
+
/** Stops the render: the promise rejects with the signal's reason. */
|
|
68
|
+
readonly signal?: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
/** Options for `new Shadertoy(options)`. */
|
|
71
|
+
export interface ShadertoyOptions {
|
|
72
|
+
/** The Image tab. */
|
|
73
|
+
readonly image: ShadertoyPassSource;
|
|
74
|
+
/** The Common tab: GLSL placed before every pass's source. */
|
|
75
|
+
readonly common?: string;
|
|
76
|
+
/** Buffer tabs, drawn in the order A, B, C, D before the image each frame into rgba32float targets of the image's size. */
|
|
77
|
+
readonly bufferA?: ShadertoyPassSource;
|
|
78
|
+
readonly bufferB?: ShadertoyPassSource;
|
|
79
|
+
readonly bufferC?: ShadertoyPassSource;
|
|
80
|
+
readonly bufferD?: ShadertoyPassSource;
|
|
81
|
+
/**
|
|
82
|
+
* The Cube A tab, drawn after the buffers each frame into the six faces of an rgba16float cube: rayOri is 0, rayDir
|
|
83
|
+
* the unit direction through the texel's centre (faces as OpenGL ES 3.0.6 Table 3.21), fragCoord the texel's place
|
|
84
|
+
* in its face counted from the face's first row. A channel reads it as `'cubeA'`; Cube A reads its own last frame.
|
|
85
|
+
*/
|
|
86
|
+
readonly cubeA?: ShadertoyCubeSource;
|
|
87
|
+
/** The Sound tab: `vec2 mainSound(int samp, float time)` (or the older `vec2 mainSound(float time)`), rendered by `toy.sound()`. Its channels read textures only. */
|
|
88
|
+
readonly sound?: ShadertoyPassSource;
|
|
89
|
+
/**
|
|
90
|
+
* Calls the Image tab's `void mainVR(out vec4 fragColor, in vec2 fragCoord, in vec3 fragRayOri, in vec3 fragRayDir)`
|
|
91
|
+
* in a pass and on a mesh, with each pixel's ray from the camera that draws it (each eye's in an XR frame);
|
|
92
|
+
* `toy.texture` keeps mainImage. Default false.
|
|
93
|
+
*/
|
|
94
|
+
readonly vr?: boolean;
|
|
95
|
+
/** Where a `'keyboard'` channel listens for keydown and keyup. Default `globalThis` (the window). */
|
|
96
|
+
readonly keyboard?: EventTarget;
|
|
97
|
+
/** Size in pixels of `toy.texture`, and the iResolution of `toy.material()`. Default `[512, 512]`. */
|
|
98
|
+
readonly resolution?: readonly [number, number];
|
|
99
|
+
/** iSampleRate. Default 44100. */
|
|
100
|
+
readonly sampleRate?: number;
|
|
101
|
+
/** Plugin and debug name. Default `'shader:shadertoy:<n>'`. */
|
|
102
|
+
readonly name?: string;
|
|
103
|
+
}
|
|
104
|
+
/** A tab of a toy, as `toy.setChannel(index, texture, tab)` names it. */
|
|
105
|
+
export type ShadertoyTab = 'image' | 'bufferA' | 'bufferB' | 'bufferC' | 'bufferD' | 'cubeA' | 'sound';
|
|
106
|
+
/**
|
|
107
|
+
* A Shadertoy program: `new Shadertoy(source)` or `new Shadertoy({image: {source, iChannel0: 'A'}, bufferA: {source}})`.
|
|
108
|
+
* Draw it as a pass (`PostStack.attach(engine, [toy.pass()])`), into a texture (`engine.use(toy)`, then read
|
|
109
|
+
* `toy.texture`), or on a mesh (`engine.use(toy)` and `shaderMesh(geometry, toy.material())`). `toy.time`,
|
|
110
|
+
* `toy.frame`, `toy.mouse` and `toy.date` are the inputs; the clock runs from the frame delta unless paused.
|
|
111
|
+
*/
|
|
112
|
+
export declare class Shadertoy implements EnginePlugin {
|
|
113
|
+
readonly name: string;
|
|
114
|
+
/** The Image tab's source. */
|
|
115
|
+
readonly source: string;
|
|
116
|
+
/** The GLSL ES 3.00 program around the Image source that a pass and the texture draw, mainImage at gl_FragCoord. */
|
|
117
|
+
readonly fragmentShader: string;
|
|
118
|
+
/** With `vr`: the program a pass draws, mainVR with each pixel's ray. */
|
|
119
|
+
readonly vrShader?: string;
|
|
120
|
+
/** The program `toy.material()` draws: mainImage (mainVR with `vr`) at the mesh's uv times `resolution`. */
|
|
121
|
+
readonly meshShaders: {
|
|
122
|
+
readonly vertexShader: string;
|
|
123
|
+
readonly fragmentShader: string;
|
|
124
|
+
};
|
|
125
|
+
/** The GLSL ES 3.00 program of each buffer tab given, drawn into its rgba32float target. */
|
|
126
|
+
readonly buffers: Readonly<Partial<Record<ShadertoyBuffer, string>>>;
|
|
127
|
+
/** The Cube A program, drawn into a 3 x 2 atlas of faces (+X -X +Y, then -Y +Z -Z) with gl_FragCoord rows from the top. */
|
|
128
|
+
readonly cubeShader?: string;
|
|
129
|
+
/** The Sound program: one sample per pixel, 512 per row from the first row, from the sample `shadertoySoundBase` on. */
|
|
130
|
+
readonly soundShader?: string;
|
|
131
|
+
/** Size of `toy.texture` and iResolution of `toy.material()`, in pixels. */
|
|
132
|
+
readonly resolution: readonly [number, number];
|
|
133
|
+
/** iTime in seconds. Settable. */
|
|
134
|
+
time: number;
|
|
135
|
+
/** iFrame. Settable; while paused, setting it runs the buffers once. */
|
|
136
|
+
frame: number;
|
|
137
|
+
/** iTimeDelta in seconds. Settable. */
|
|
138
|
+
timeDelta: number;
|
|
139
|
+
/** iFrameRate. Default 60 until a frame has run; settable. */
|
|
140
|
+
frameRate: number;
|
|
141
|
+
/** iSampleRate. */
|
|
142
|
+
sampleRate: number;
|
|
143
|
+
/** iMouse: xy the current pixel while a button is down, zw the pixel of the click. Settable. */
|
|
144
|
+
mouse: [number, number, number, number];
|
|
145
|
+
private readonly common;
|
|
146
|
+
private readonly tabs;
|
|
147
|
+
private readonly soundTab?;
|
|
148
|
+
private readonly vr;
|
|
149
|
+
private readonly cubeSize;
|
|
150
|
+
private readonly jobs;
|
|
151
|
+
private readonly today;
|
|
152
|
+
private dateSet?;
|
|
153
|
+
private paused;
|
|
154
|
+
private started;
|
|
155
|
+
private ticker?;
|
|
156
|
+
private ticks;
|
|
157
|
+
private drawn;
|
|
158
|
+
private refreshed?;
|
|
159
|
+
private disposed;
|
|
160
|
+
private engine?;
|
|
161
|
+
private host?;
|
|
162
|
+
private image?;
|
|
163
|
+
private materials;
|
|
164
|
+
private own?;
|
|
165
|
+
private readonly targets;
|
|
166
|
+
private readonly output;
|
|
167
|
+
private frameContext?;
|
|
168
|
+
private readonly made;
|
|
169
|
+
private readonly feeds;
|
|
170
|
+
private feedDevice?;
|
|
171
|
+
private mips?;
|
|
172
|
+
private readonly keys;
|
|
173
|
+
private keyTarget?;
|
|
174
|
+
private readonly onKey;
|
|
175
|
+
/** Same as `engine.use(new Shadertoy(options))`: the attached toy runs the clock and draws `toy.texture`; returns it. */
|
|
176
|
+
static attach(engine: EngineKernel, options: string | ShadertoyOptions): Shadertoy;
|
|
177
|
+
constructor(options: string | ShadertoyOptions);
|
|
178
|
+
/** iDate: year, month (January is 0, as JavaScript's Date), day and seconds since midnight. Settable; default the clock's. */
|
|
179
|
+
get date(): readonly [number, number, number, number];
|
|
180
|
+
set date(value: readonly number[] | undefined);
|
|
181
|
+
/** Stops the clock: time and frame stay until set or `play()`, and the buffers hold their images. */
|
|
182
|
+
pause(): void;
|
|
183
|
+
play(): void;
|
|
184
|
+
/** Back to time 0, frame 0. */
|
|
185
|
+
reset(): void;
|
|
186
|
+
/** @internal One frame of the clock; the first caller of a frame owns it. */
|
|
187
|
+
tick(delta: number, owner: object): void;
|
|
188
|
+
/** @internal What advances the buffers: the frame tick, or the frame number while paused. */
|
|
189
|
+
step(): number;
|
|
190
|
+
/** @internal Fills the keyboard, video and audio channels once a frame. */
|
|
191
|
+
refresh(device: GPUDevice, encoder: GPUCommandEncoder): void;
|
|
192
|
+
private fill;
|
|
193
|
+
private releaseFeeds;
|
|
194
|
+
private uniforms;
|
|
195
|
+
private lent;
|
|
196
|
+
private sizeOf;
|
|
197
|
+
/** @internal A pass of this toy was attached to `engine`: its texture channels report there and belong to its device. */
|
|
198
|
+
adopt(engine: Engine): void;
|
|
199
|
+
private fixSlots;
|
|
200
|
+
/**
|
|
201
|
+
* Gives channel `index` (0 to 3) of `tab` (default the Image tab) something new to read, of the kind it was made
|
|
202
|
+
* with: a texture channel takes a GPUTexture or view of its sampler type, a materials Texture, `(device) => texture`
|
|
203
|
+
* (called once per device) or null (opaque black); a video or image channel takes another, an audio channel another
|
|
204
|
+
* `AnalyserNode`. The toy's own channels (`'input'`, a buffer, `'cubeA'`, `'keyboard'`) are fixed when it is made.
|
|
205
|
+
* After a device restore a plain GPUTexture or view reads opaque black until this gives it a new one.
|
|
206
|
+
* @throws TypeError for a missing tab, a channel of another kind, or a texture of another sampler type
|
|
207
|
+
*/
|
|
208
|
+
setChannel(index: 0 | 1 | 2 | 3, texture: ShadertoyInput, tab?: ShadertoyTab): void;
|
|
209
|
+
private refuseInput;
|
|
210
|
+
private program;
|
|
211
|
+
private chain;
|
|
212
|
+
private imageTab;
|
|
213
|
+
/**
|
|
214
|
+
* The program as a PostStack stage: `PostStack.attach(engine, [toy.pass()])`. iResolution is the target's size (the
|
|
215
|
+
* buffers' too), and a channel given `'input'` reads the colour of the stage before. Runs the clock unless the toy is
|
|
216
|
+
* attached itself.
|
|
217
|
+
*/
|
|
218
|
+
pass(options?: Omit<ShaderPassOptions, 'input' | 'builtins' | 'glslVersion' | 'unfilterable'>): ShaderPass;
|
|
219
|
+
private feedless;
|
|
220
|
+
/**
|
|
221
|
+
* The program as a mesh material: fragCoord is the mesh's uv times `resolution`. Attach the toy
|
|
222
|
+
* (`engine.use(toy)`) so its clock and buffers run. Options are ShaderMaterial's render state.
|
|
223
|
+
*/
|
|
224
|
+
material(options?: Omit<ShaderMaterialOptions, 'vertexShader' | 'fragmentShader' | 'uniforms' | 'builtins' | 'glslVersion' | 'unfilterable' | 'lights' | 'fog' | 'velocity'>): ShaderMaterial;
|
|
225
|
+
/**
|
|
226
|
+
* The image, drawn once a frame at `resolution` while the toy is attached (`engine.use(toy)`), for any raw, node or
|
|
227
|
+
* GLSL material; texels are the values mainImage writes, row 0 at the top as Margo's images.
|
|
228
|
+
*/
|
|
229
|
+
get texture(): BindableTexture;
|
|
230
|
+
private readonly view;
|
|
231
|
+
private target;
|
|
232
|
+
setup(engine: Engine): void;
|
|
233
|
+
/** One frame of the clock (iTime, iFrame) without drawing; each frame update runs it, so `seek` from `@margoengine/cutscene/seek` replays it exactly. */
|
|
234
|
+
advanceTime(delta: number): void;
|
|
235
|
+
onPreUpdate(delta: number): void;
|
|
236
|
+
registerPasses(graph: FrameGraph): void;
|
|
237
|
+
/**
|
|
238
|
+
* Renders the Sound tab over the next frames while the toy is attached (`engine.use(toy)`), 262,144 samples a
|
|
239
|
+
* frame: `mainSound` at each sample number and its time at `sampleRate`, left and right clamped to -1 to 1.
|
|
240
|
+
*/
|
|
241
|
+
sound(options?: ShadertoySoundOptions): Promise<ShadertoySound>;
|
|
242
|
+
private draw;
|
|
243
|
+
/** Resolves when the programs made so far have compiled. */
|
|
244
|
+
ready(): Promise<void>;
|
|
245
|
+
onDeviceRestored(): void;
|
|
246
|
+
/** Releases the textures and the programs this toy made, and stops listening to the keyboard. */
|
|
247
|
+
dispose(): void;
|
|
248
|
+
[Symbol.dispose]: () => void;
|
|
249
|
+
}
|