glre 0.30.0 → 0.32.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/dist/index.cjs +30 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +571 -0
- package/dist/index.js +30 -64
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +30 -64
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.ts +54 -0
- package/dist/native.js +30 -64
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +30 -64
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +8 -0
- package/dist/react.js +30 -64
- package/dist/react.js.map +1 -1
- package/dist/solid.cjs +30 -64
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.d.ts +8 -0
- package/dist/solid.js +30 -64
- package/dist/solid.js.map +1 -1
- package/package.json +7 -6
- package/src/index.ts +20 -5
- package/src/node/code.ts +66 -69
- package/src/node/const.ts +2 -0
- package/src/node/index.ts +78 -8
- package/src/node/infer.ts +19 -14
- package/src/node/node.ts +12 -14
- package/src/node/parse.ts +118 -0
- package/src/node/scope.ts +37 -18
- package/src/node/types.ts +90 -56
- package/src/node/utils.ts +9 -92
- package/src/types.ts +31 -16
- package/src/utils/pipeline.ts +135 -83
- package/src/utils/program.ts +7 -29
- package/src/webgl.ts +2 -3
- package/src/webgpu.ts +67 -58
- package/dist/index-q8W5cl04.d.cts +0 -358
- package/dist/index.d.cts +0 -3
- package/dist/native.d.cts +0 -53
- package/dist/react.d.cts +0 -8
- package/dist/solid.d.cts +0 -8
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import * as refr from 'refr';
|
|
2
|
+
import { Queue, Frame } from 'refr';
|
|
3
|
+
export { Frame, Fun, Queue } from 'refr';
|
|
4
|
+
import { Nested, EventState } from 'reev';
|
|
5
|
+
|
|
6
|
+
declare const CONSTANTS: readonly ["bool", "uint", "int", "float", "bvec2", "ivec2", "uvec2", "vec2", "bvec3", "ivec3", "uvec3", "vec3", "bvec4", "ivec4", "uvec4", "vec4", "color", "mat2", "mat3", "mat4", "texture", "sampler2D"];
|
|
7
|
+
declare const CONVERSIONS: readonly ["toBool", "toUint", "toInt", "toFloat", "toBvec2", "toIvec2", "toUvec2", "toVec2", "toBvec3", "toIvec3", "toUvec3", "toVec3", "toBvec4", "toIvec4", "toUvec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
|
|
8
|
+
declare const OPERATORS: {
|
|
9
|
+
readonly add: "+";
|
|
10
|
+
readonly sub: "-";
|
|
11
|
+
readonly mul: "*";
|
|
12
|
+
readonly div: "/";
|
|
13
|
+
readonly mod: "%";
|
|
14
|
+
readonly equal: "==";
|
|
15
|
+
readonly notEqual: "!=";
|
|
16
|
+
readonly lessThan: "<";
|
|
17
|
+
readonly lessThanEqual: "<=";
|
|
18
|
+
readonly greaterThan: ">";
|
|
19
|
+
readonly greaterThanEqual: ">=";
|
|
20
|
+
readonly and: "&&";
|
|
21
|
+
readonly or: "||";
|
|
22
|
+
readonly bitAnd: "&";
|
|
23
|
+
readonly bitOr: "|";
|
|
24
|
+
readonly bitXor: "^";
|
|
25
|
+
readonly shiftLeft: "<<";
|
|
26
|
+
readonly shiftRight: ">>";
|
|
27
|
+
};
|
|
28
|
+
declare const OPERATOR_KEYS: (keyof typeof OPERATORS)[];
|
|
29
|
+
declare const FUNCTIONS: readonly ["dot", "distance", "length", "lengthSq", "determinant", "luminance", "all", "any", "abs", "sign", "floor", "ceil", "round", "fract", "trunc", "sin", "cos", "tan", "asin", "acos", "atan", "exp", "exp2", "log", "log2", "sqrt", "inverseSqrt", "normalize", "oneMinus", "saturate", "negate", "reciprocal", "dFdx", "dFdy", "fwidth", "cross", "reflect", "refract", "min", "max", "mix", "clamp", "step", "smoothstep", "texture", "textureLod", "textureSize", "cubeTexture", "atan2", "degrees", "faceforward", "bitcast", "cbrt", "difference", "equals", "pow", "pow2", "pow3", "pow4", "radians", "transformDirection"];
|
|
30
|
+
|
|
31
|
+
type Constants = (typeof CONSTANTS)[number] | 'void';
|
|
32
|
+
type Conversions = (typeof CONVERSIONS)[number];
|
|
33
|
+
type Functions = (typeof FUNCTIONS)[number];
|
|
34
|
+
type Operators = (typeof OPERATOR_KEYS)[number];
|
|
35
|
+
interface FnLayout {
|
|
36
|
+
name: string;
|
|
37
|
+
type: Constants | 'auto';
|
|
38
|
+
inputs?: Array<{
|
|
39
|
+
name: string;
|
|
40
|
+
type: Constants;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Node
|
|
45
|
+
*/
|
|
46
|
+
type NodeTypes = 'attribute' | 'uniform' | 'constant' | 'variable' | 'varying' | 'swizzle' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare' | 'return';
|
|
47
|
+
interface NodeProps {
|
|
48
|
+
id?: string;
|
|
49
|
+
args?: X[];
|
|
50
|
+
type?: string;
|
|
51
|
+
children?: X[];
|
|
52
|
+
inferFrom?: X[];
|
|
53
|
+
layout?: FnLayout;
|
|
54
|
+
parent?: NodeProxy;
|
|
55
|
+
}
|
|
56
|
+
interface NodeContext {
|
|
57
|
+
isFrag?: boolean;
|
|
58
|
+
isWebGL?: boolean;
|
|
59
|
+
binding?: number;
|
|
60
|
+
infers?: WeakMap<NodeProxy, Constants>;
|
|
61
|
+
onMount?: (name: string) => void;
|
|
62
|
+
webgpu?: WebGPUState;
|
|
63
|
+
headers?: Map<string, string>;
|
|
64
|
+
fragInputs?: Map<string, string>;
|
|
65
|
+
vertInputs?: Map<string, string>;
|
|
66
|
+
vertOutputs?: Map<string, string>;
|
|
67
|
+
vertVaryings?: Map<string, string>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* NodeProxy
|
|
71
|
+
*/
|
|
72
|
+
type _Swizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
|
|
73
|
+
type Swizzles = _Swizzles<'x' | 'y' | 'z' | 'w'> | _Swizzles<'r' | 'g' | 'b' | 'a'> | _Swizzles<'p' | 'q'> | _Swizzles<'s' | 't'>;
|
|
74
|
+
type NodeProxyMethods = Functions | Operators | Conversions | Swizzles | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString';
|
|
75
|
+
type DynamicProperties = {
|
|
76
|
+
[K in string as K extends NodeProxyMethods ? never : K]: NodeProxy;
|
|
77
|
+
};
|
|
78
|
+
interface BaseNodeProxy extends Record<Swizzles, NodeProxy> {
|
|
79
|
+
assign(n: X): NodeProxy;
|
|
80
|
+
toVar(name?: string): NodeProxy;
|
|
81
|
+
toString(c?: NodeContext): string;
|
|
82
|
+
type: NodeTypes;
|
|
83
|
+
props: NodeProps;
|
|
84
|
+
isProxy: true;
|
|
85
|
+
add(n: X): NodeProxy;
|
|
86
|
+
sub(n: X): NodeProxy;
|
|
87
|
+
mul(n: X): NodeProxy;
|
|
88
|
+
div(n: X): NodeProxy;
|
|
89
|
+
mod(n: X): NodeProxy;
|
|
90
|
+
equal(n: X): NodeProxy;
|
|
91
|
+
notEqual(n: X): NodeProxy;
|
|
92
|
+
lessThan(n: X): NodeProxy;
|
|
93
|
+
lessThanEqual(n: X): NodeProxy;
|
|
94
|
+
greaterThan(n: X): NodeProxy;
|
|
95
|
+
greaterThanEqual(n: X): NodeProxy;
|
|
96
|
+
and(n: X): NodeProxy;
|
|
97
|
+
or(n: X): NodeProxy;
|
|
98
|
+
not(): NodeProxy;
|
|
99
|
+
toBool(): NodeProxy;
|
|
100
|
+
toUint(): NodeProxy;
|
|
101
|
+
toInt(): NodeProxy;
|
|
102
|
+
toFloat(): NodeProxy;
|
|
103
|
+
toBvec2(): NodeProxy;
|
|
104
|
+
toIvec2(): NodeProxy;
|
|
105
|
+
toUvec2(): NodeProxy;
|
|
106
|
+
toVec2(): NodeProxy;
|
|
107
|
+
toBvec3(): NodeProxy;
|
|
108
|
+
toIvec3(): NodeProxy;
|
|
109
|
+
toUvec3(): NodeProxy;
|
|
110
|
+
toVec3(): NodeProxy;
|
|
111
|
+
toBvec4(): NodeProxy;
|
|
112
|
+
toIvec4(): NodeProxy;
|
|
113
|
+
toUvec4(): NodeProxy;
|
|
114
|
+
toVec4(): NodeProxy;
|
|
115
|
+
toColor(): NodeProxy;
|
|
116
|
+
toMat2(): NodeProxy;
|
|
117
|
+
toMat3(): NodeProxy;
|
|
118
|
+
toMat4(): NodeProxy;
|
|
119
|
+
abs(): NodeProxy;
|
|
120
|
+
sin(): NodeProxy;
|
|
121
|
+
cos(): NodeProxy;
|
|
122
|
+
tan(): NodeProxy;
|
|
123
|
+
asin(): NodeProxy;
|
|
124
|
+
acos(): NodeProxy;
|
|
125
|
+
atan(): NodeProxy;
|
|
126
|
+
atan2(x: X): NodeProxy;
|
|
127
|
+
pow(y: X): NodeProxy;
|
|
128
|
+
pow2(): NodeProxy;
|
|
129
|
+
pow3(): NodeProxy;
|
|
130
|
+
pow4(): NodeProxy;
|
|
131
|
+
sqrt(): NodeProxy;
|
|
132
|
+
inverseSqrt(): NodeProxy;
|
|
133
|
+
exp(): NodeProxy;
|
|
134
|
+
exp2(): NodeProxy;
|
|
135
|
+
log(): NodeProxy;
|
|
136
|
+
log2(): NodeProxy;
|
|
137
|
+
floor(): NodeProxy;
|
|
138
|
+
ceil(): NodeProxy;
|
|
139
|
+
round(): NodeProxy;
|
|
140
|
+
fract(): NodeProxy;
|
|
141
|
+
trunc(): NodeProxy;
|
|
142
|
+
min(y: X): NodeProxy;
|
|
143
|
+
max(y: X): NodeProxy;
|
|
144
|
+
clamp(min: X, max: X): NodeProxy;
|
|
145
|
+
saturate(): NodeProxy;
|
|
146
|
+
mix(y: X, a: X): NodeProxy;
|
|
147
|
+
step(edge: X): NodeProxy;
|
|
148
|
+
smoothstep(edge0: X, edge1: X): NodeProxy;
|
|
149
|
+
length(): NodeProxy;
|
|
150
|
+
distance(y: X): NodeProxy;
|
|
151
|
+
dot(y: X): NodeProxy;
|
|
152
|
+
cross(y: X): NodeProxy;
|
|
153
|
+
normalize(): NodeProxy;
|
|
154
|
+
reflect(N: X): NodeProxy;
|
|
155
|
+
refract(N: X, eta: X): NodeProxy;
|
|
156
|
+
sign(): NodeProxy;
|
|
157
|
+
oneMinus(): NodeProxy;
|
|
158
|
+
reciprocal(): NodeProxy;
|
|
159
|
+
negate(): NodeProxy;
|
|
160
|
+
dFdx(): NodeProxy;
|
|
161
|
+
dFdy(): NodeProxy;
|
|
162
|
+
fwidth(): NodeProxy;
|
|
163
|
+
}
|
|
164
|
+
type NodeProxy = BaseNodeProxy & DynamicProperties;
|
|
165
|
+
type X = NodeProxy | number | string | boolean | undefined;
|
|
166
|
+
|
|
167
|
+
declare const code: (target: X, c?: NodeContext | null) => string;
|
|
168
|
+
|
|
169
|
+
declare const node: (type: NodeTypes, props?: NodeProps | null, ...args: X[]) => NodeProxy;
|
|
170
|
+
declare const attribute: (x: X, id?: string) => NodeProxy;
|
|
171
|
+
declare const constant: (x: X, id?: string) => NodeProxy;
|
|
172
|
+
declare const uniform: (x: X, id?: string) => NodeProxy;
|
|
173
|
+
declare const variable: (id?: string) => NodeProxy;
|
|
174
|
+
declare const builtin: (id?: string) => NodeProxy;
|
|
175
|
+
declare const vertexStage: (x: X, id?: string) => NodeProxy;
|
|
176
|
+
declare const swizzle: (key: Swizzles, x: X) => NodeProxy;
|
|
177
|
+
declare const operator: (key: Operators, ...x: X[]) => NodeProxy;
|
|
178
|
+
declare const function_: (key: Functions, ...x: X[]) => NodeProxy;
|
|
179
|
+
declare const conversion: (key: string, ...x: X[]) => NodeProxy;
|
|
180
|
+
declare const select: (x: X, y: X, z: X) => NodeProxy;
|
|
181
|
+
|
|
182
|
+
declare const toVar: (x: X, id?: string) => NodeProxy;
|
|
183
|
+
declare const assign: (x: X, y: X) => X;
|
|
184
|
+
declare const Return: (x: X) => NodeProxy;
|
|
185
|
+
declare const If: (x: X, fun: () => void) => {
|
|
186
|
+
ElseIf: (_x: X, _fun: () => void) => /*elided*/ any;
|
|
187
|
+
Else: (_fun: () => void) => void;
|
|
188
|
+
};
|
|
189
|
+
declare const Loop: (x: X, fun: (params: {
|
|
190
|
+
i: NodeProxy;
|
|
191
|
+
}) => void) => NodeProxy;
|
|
192
|
+
declare const Switch: (x: X) => {
|
|
193
|
+
Case: (...values: X[]) => (fun: () => void) => /*elided*/ any;
|
|
194
|
+
Default: (fun: () => void) => void;
|
|
195
|
+
};
|
|
196
|
+
declare const Fn: (fun: (paramVars: NodeProxy[]) => NodeProxy) => {
|
|
197
|
+
(...args: X[]): NodeProxy;
|
|
198
|
+
setLayout(newLayout: FnLayout): /*elided*/ any;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
declare const isSwizzle: (key: unknown) => key is Swizzles;
|
|
202
|
+
declare const isOperator: (key: unknown) => key is Operators;
|
|
203
|
+
declare const isFunction: (key: unknown) => key is Functions;
|
|
204
|
+
declare const isConversion: (key: unknown) => key is Conversions;
|
|
205
|
+
declare const isNodeProxy: (x: unknown) => x is NodeProxy;
|
|
206
|
+
declare const isConstantsType: (type?: Constants | "auto") => type is Constants;
|
|
207
|
+
declare const hex2rgb: (hex: number) => number[];
|
|
208
|
+
declare const getId: () => string;
|
|
209
|
+
declare const joins: (children: X[], c: NodeContext) => string;
|
|
210
|
+
declare const formatConversions: (x: X, c?: NodeContext) => string;
|
|
211
|
+
declare const getOperator: (op: X) => "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "&&" | "||" | "&" | "|" | "^" | "<<" | ">>";
|
|
212
|
+
declare const getBluiltin: (id: string) => "gl_FragCoord" | "gl_VertexID" | "gl_InstanceID" | "gl_FrontFacing" | "gl_FragDepth" | "gl_SampleID" | "gl_SampleMask" | "gl_PointCoord" | "gl_FragCoord.xy";
|
|
213
|
+
declare const conversionToConstant: (conversionKey: string) => Constants;
|
|
214
|
+
|
|
215
|
+
declare const vertex: (x: X, c: NodeContext) => string;
|
|
216
|
+
declare const fragment: (x: X, c: NodeContext) => string;
|
|
217
|
+
declare const position: NodeProxy;
|
|
218
|
+
declare const vertexIndex: NodeProxy;
|
|
219
|
+
declare const instanceIndex: NodeProxy;
|
|
220
|
+
declare const frontFacing: NodeProxy;
|
|
221
|
+
declare const fragDepth: NodeProxy;
|
|
222
|
+
declare const sampleIndex: NodeProxy;
|
|
223
|
+
declare const sampleMask: NodeProxy;
|
|
224
|
+
declare const pointCoord: NodeProxy;
|
|
225
|
+
declare const normalLocal: NodeProxy;
|
|
226
|
+
declare const normalWorld: NodeProxy;
|
|
227
|
+
declare const normalView: NodeProxy;
|
|
228
|
+
declare const positionLocal: NodeProxy;
|
|
229
|
+
declare const positionWorld: NodeProxy;
|
|
230
|
+
declare const positionView: NodeProxy;
|
|
231
|
+
declare const screenCoordinate: NodeProxy;
|
|
232
|
+
declare const screenUV: NodeProxy;
|
|
233
|
+
declare const float: (x: X) => NodeProxy;
|
|
234
|
+
declare const int: (x: X) => NodeProxy;
|
|
235
|
+
declare const uint: (x: X) => NodeProxy;
|
|
236
|
+
declare const bool: (x: X) => NodeProxy;
|
|
237
|
+
declare const vec2: (x?: X, y?: X) => NodeProxy;
|
|
238
|
+
declare const vec3: (x?: X, y?: X, z?: X) => NodeProxy;
|
|
239
|
+
declare const vec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
|
|
240
|
+
declare const mat2: (...args: X[]) => NodeProxy;
|
|
241
|
+
declare const mat3: (...args: X[]) => NodeProxy;
|
|
242
|
+
declare const mat4: (...args: X[]) => NodeProxy;
|
|
243
|
+
declare const ivec2: (x?: X, y?: X) => NodeProxy;
|
|
244
|
+
declare const ivec3: (x?: X, y?: X, z?: X) => NodeProxy;
|
|
245
|
+
declare const ivec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
|
|
246
|
+
declare const uvec2: (x?: X, y?: X) => NodeProxy;
|
|
247
|
+
declare const uvec3: (x?: X, y?: X, z?: X) => NodeProxy;
|
|
248
|
+
declare const uvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
|
|
249
|
+
declare const bvec2: (x?: X, y?: X) => NodeProxy;
|
|
250
|
+
declare const bvec3: (x?: X, y?: X, z?: X) => NodeProxy;
|
|
251
|
+
declare const bvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
|
|
252
|
+
declare const texture2D: () => NodeProxy;
|
|
253
|
+
declare const sampler2D: () => NodeProxy;
|
|
254
|
+
declare const color: (r?: X, g?: X, b?: X) => NodeProxy;
|
|
255
|
+
declare const iResolution: NodeProxy;
|
|
256
|
+
declare const iMouse: NodeProxy;
|
|
257
|
+
declare const iTime: NodeProxy;
|
|
258
|
+
declare const uv: () => NodeProxy;
|
|
259
|
+
declare const texture: (x: X, y: X, z?: X) => NodeProxy;
|
|
260
|
+
declare const cubeTexture: (x: X, y: X, z?: X) => NodeProxy;
|
|
261
|
+
declare const textureSize: (x: X, y?: X) => NodeProxy;
|
|
262
|
+
declare const abs: (x: X) => NodeProxy;
|
|
263
|
+
declare const acos: (x: X) => NodeProxy;
|
|
264
|
+
declare const all: (x: X) => NodeProxy;
|
|
265
|
+
declare const any: (x: X) => NodeProxy;
|
|
266
|
+
declare const asin: (x: X) => NodeProxy;
|
|
267
|
+
declare const atan: (y: X, x?: X) => NodeProxy;
|
|
268
|
+
declare const atan2: (y: X, x: X) => NodeProxy;
|
|
269
|
+
declare const bitcast: (x: X, y: X) => NodeProxy;
|
|
270
|
+
declare const cbrt: (x: X) => NodeProxy;
|
|
271
|
+
declare const ceil: (x: X) => NodeProxy;
|
|
272
|
+
declare const clamp: (x: X, min: X, max: X) => NodeProxy;
|
|
273
|
+
declare const cos: (x: X) => NodeProxy;
|
|
274
|
+
declare const cross: (x: X, y: X) => NodeProxy;
|
|
275
|
+
declare const dFdx: (p: X) => NodeProxy;
|
|
276
|
+
declare const dFdy: (p: X) => NodeProxy;
|
|
277
|
+
declare const degrees: (radians: X) => NodeProxy;
|
|
278
|
+
declare const difference: (x: X, y: X) => NodeProxy;
|
|
279
|
+
declare const distance: (x: X, y: X) => NodeProxy;
|
|
280
|
+
declare const dot: (x: X, y: X) => NodeProxy;
|
|
281
|
+
declare const equals: (x: X, y: X) => NodeProxy;
|
|
282
|
+
declare const exp: (x: X) => NodeProxy;
|
|
283
|
+
declare const exp2: (x: X) => NodeProxy;
|
|
284
|
+
declare const faceforward: (N: X, I: X, Nref: X) => NodeProxy;
|
|
285
|
+
declare const floor: (x: X) => NodeProxy;
|
|
286
|
+
declare const fract: (x: X) => NodeProxy;
|
|
287
|
+
declare const fwidth: (x: X) => NodeProxy;
|
|
288
|
+
declare const inverseSqrt: (x: X) => NodeProxy;
|
|
289
|
+
declare const length: (x: X) => NodeProxy;
|
|
290
|
+
declare const lengthSq: (x: X) => NodeProxy;
|
|
291
|
+
declare const log: (x: X) => NodeProxy;
|
|
292
|
+
declare const log2: (x: X) => NodeProxy;
|
|
293
|
+
declare const max: (x: X, y: X) => NodeProxy;
|
|
294
|
+
declare const min: (x: X, y: X) => NodeProxy;
|
|
295
|
+
declare const mix: (x: X, y: X, a: X) => NodeProxy;
|
|
296
|
+
declare const negate: (x: X) => NodeProxy;
|
|
297
|
+
declare const normalize: (x: X) => NodeProxy;
|
|
298
|
+
declare const oneMinus: (x: X) => NodeProxy;
|
|
299
|
+
declare const pow: (x: X, y: X) => NodeProxy;
|
|
300
|
+
declare const pow2: (x: X) => NodeProxy;
|
|
301
|
+
declare const pow3: (x: X) => NodeProxy;
|
|
302
|
+
declare const pow4: (x: X) => NodeProxy;
|
|
303
|
+
declare const radians: (degrees: X) => NodeProxy;
|
|
304
|
+
declare const reciprocal: (x: X) => NodeProxy;
|
|
305
|
+
declare const reflect: (I: X, N: X) => NodeProxy;
|
|
306
|
+
declare const refract: (I: X, N: X, eta: X) => NodeProxy;
|
|
307
|
+
declare const round: (x: X) => NodeProxy;
|
|
308
|
+
declare const saturate: (x: X) => NodeProxy;
|
|
309
|
+
declare const sign: (x: X) => NodeProxy;
|
|
310
|
+
declare const sin: (x: X) => NodeProxy;
|
|
311
|
+
declare const smoothstep: (e0: X, e1: X, x: X) => NodeProxy;
|
|
312
|
+
declare const sqrt: (x: X) => NodeProxy;
|
|
313
|
+
declare const step: (edge: X, x: X) => NodeProxy;
|
|
314
|
+
declare const tan: (x: X) => NodeProxy;
|
|
315
|
+
declare const transformDirection: (dir: X, matrix: X) => NodeProxy;
|
|
316
|
+
declare const trunc: (x: X) => NodeProxy;
|
|
317
|
+
|
|
318
|
+
type PrecisionMode = 'highp' | 'mediump' | 'lowp';
|
|
319
|
+
type GLClearMode = 'COLOR_BUFFER_BIT' | 'DEPTH_BUFFER_BIT' | 'STENCIL_BUFFER_BIT';
|
|
320
|
+
type GLDrawType = 'UNSIGNED_BYTE' | 'UNSIGNED_SHORT' | 'UNSIGNED_INT';
|
|
321
|
+
type GLDrawMode = 'POINTS' | 'LINE_STRIP' | 'LINE_LOOP' | 'LINES' | 'TRIANGLE_STRIP' | 'TRIANGLE_FAN' | 'TRIANGLES';
|
|
322
|
+
interface UniformData {
|
|
323
|
+
array: Float32Array;
|
|
324
|
+
buffer: GPUBuffer;
|
|
325
|
+
binding: number;
|
|
326
|
+
group: number;
|
|
327
|
+
}
|
|
328
|
+
interface TextureData {
|
|
329
|
+
binding: number;
|
|
330
|
+
group: number;
|
|
331
|
+
texture: GPUTexture;
|
|
332
|
+
sampler: GPUSampler;
|
|
333
|
+
}
|
|
334
|
+
interface AttribData {
|
|
335
|
+
array: Float32Array;
|
|
336
|
+
buffer: GPUBuffer;
|
|
337
|
+
location: number;
|
|
338
|
+
stride: number;
|
|
339
|
+
}
|
|
340
|
+
interface WebGLState {
|
|
341
|
+
context: WebGLRenderingContext;
|
|
342
|
+
program: WebGLProgram;
|
|
343
|
+
}
|
|
344
|
+
interface WebGPUState {
|
|
345
|
+
device: GPUDevice;
|
|
346
|
+
uniforms: Nested<UniformData>;
|
|
347
|
+
textures: Nested<TextureData>;
|
|
348
|
+
attribs: Nested<AttribData>;
|
|
349
|
+
}
|
|
350
|
+
type Uniform = number | number[];
|
|
351
|
+
type Attribute = number[];
|
|
352
|
+
type Attributes = Record<string, Attribute>;
|
|
353
|
+
type Uniforms = Record<string, Uniform>;
|
|
354
|
+
type GL = EventState<{
|
|
355
|
+
/**
|
|
356
|
+
* initial value
|
|
357
|
+
*/
|
|
358
|
+
isNative: boolean;
|
|
359
|
+
isWebGL: boolean;
|
|
360
|
+
isLoop: boolean;
|
|
361
|
+
isGL: true;
|
|
362
|
+
width: number;
|
|
363
|
+
height: number;
|
|
364
|
+
size: [number, number];
|
|
365
|
+
mouse: [number, number];
|
|
366
|
+
count: number;
|
|
367
|
+
el: HTMLCanvasElement;
|
|
368
|
+
vs: string | NodeProxy;
|
|
369
|
+
fs: string | NodeProxy;
|
|
370
|
+
vert: string | NodeProxy;
|
|
371
|
+
frag: string | NodeProxy;
|
|
372
|
+
vertex: string | NodeProxy;
|
|
373
|
+
fragment: string | NodeProxy;
|
|
374
|
+
/**
|
|
375
|
+
* core state
|
|
376
|
+
*/
|
|
377
|
+
webgpu: WebGPUState;
|
|
378
|
+
webgl: WebGLState;
|
|
379
|
+
queue: Queue;
|
|
380
|
+
frame: Frame;
|
|
381
|
+
/**
|
|
382
|
+
* events
|
|
383
|
+
*/
|
|
384
|
+
ref?: any;
|
|
385
|
+
init(): void;
|
|
386
|
+
loop(): void;
|
|
387
|
+
mount(): void;
|
|
388
|
+
clean(): void;
|
|
389
|
+
render(): void;
|
|
390
|
+
resize(e?: Event): void;
|
|
391
|
+
mousemove(e: Event): void;
|
|
392
|
+
/**
|
|
393
|
+
* setter
|
|
394
|
+
*/
|
|
395
|
+
_uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
|
|
396
|
+
uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
|
|
397
|
+
uniform(node: NodeProxy): GL;
|
|
398
|
+
uniform(target: {
|
|
399
|
+
[key: string]: Uniform;
|
|
400
|
+
}): GL;
|
|
401
|
+
_texture?(key: string, value: string): GL;
|
|
402
|
+
texture(key: string, value: string): GL;
|
|
403
|
+
texture(target: {
|
|
404
|
+
[key: string]: string;
|
|
405
|
+
}): GL;
|
|
406
|
+
_attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
|
|
407
|
+
attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
|
|
408
|
+
attribute(target: {
|
|
409
|
+
[key: string]: Attribute;
|
|
410
|
+
}): GL;
|
|
411
|
+
}>;
|
|
412
|
+
|
|
413
|
+
declare const is: {
|
|
414
|
+
arr: (arg: any) => arg is any[];
|
|
415
|
+
bol: (a: unknown) => a is boolean;
|
|
416
|
+
str: (a: unknown) => a is string;
|
|
417
|
+
num: (a: unknown) => a is number;
|
|
418
|
+
int: (a: unknown) => a is number;
|
|
419
|
+
fun: (a: unknown) => a is Function;
|
|
420
|
+
und: (a: unknown) => a is undefined;
|
|
421
|
+
nul: (a: unknown) => a is null;
|
|
422
|
+
set: (a: unknown) => a is Set<unknown>;
|
|
423
|
+
map: (a: unknown) => a is Map<unknown, unknown>;
|
|
424
|
+
obj: (a: unknown) => a is object;
|
|
425
|
+
nan: (a: unknown) => a is number;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* each
|
|
429
|
+
*/
|
|
430
|
+
type EachFn<Value, Key, This> = (this: This, value: Value, key: Key) => void;
|
|
431
|
+
type Eachable<Value = any, Key = any, This = any> = {
|
|
432
|
+
forEach(cb: EachFn<Value, Key, This>, ctx?: This): void;
|
|
433
|
+
};
|
|
434
|
+
declare const each: <Value, Key, This>(obj: Eachable<Value, Key, This>, fn: EachFn<Value, Key, This>) => void;
|
|
435
|
+
declare const flush: <Value extends Function, Key, This>(obj: Eachable<Value, Key, This>, ...args: any[]) => void;
|
|
436
|
+
/**
|
|
437
|
+
* other
|
|
438
|
+
*/
|
|
439
|
+
declare const replace: (x?: string, from?: string, to?: string) => string;
|
|
440
|
+
declare const ext: (src?: string) => string;
|
|
441
|
+
declare const fig: (x?: number) => number;
|
|
442
|
+
declare const dig: (x?: number) => number;
|
|
443
|
+
declare const sig: (value?: number, digit?: number) => number;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* initialize
|
|
447
|
+
*/
|
|
448
|
+
declare const createDevice: (c: GPUCanvasContext) => Promise<{
|
|
449
|
+
device: GPUDevice;
|
|
450
|
+
format: GPUTextureFormat;
|
|
451
|
+
}>;
|
|
452
|
+
declare const createBindings: () => {
|
|
453
|
+
uniform: () => {
|
|
454
|
+
group: number;
|
|
455
|
+
binding: number;
|
|
456
|
+
};
|
|
457
|
+
texture: () => {
|
|
458
|
+
group: number;
|
|
459
|
+
binding: number;
|
|
460
|
+
};
|
|
461
|
+
attrib: () => {
|
|
462
|
+
location: number;
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
declare const createPipeline: (device: GPUDevice, format: GPUTextureFormat, bufferLayouts: GPUVertexBufferLayout[], bindGroupLayouts: GPUBindGroupLayout[], webgpu: WebGPUState, vs: string | X, fs: string | X) => GPURenderPipeline;
|
|
466
|
+
/**
|
|
467
|
+
* buffers
|
|
468
|
+
*/
|
|
469
|
+
declare const createUniformBuffer: (device: GPUDevice, value: number[]) => {
|
|
470
|
+
array: Float32Array<ArrayBuffer>;
|
|
471
|
+
buffer: GPUBuffer;
|
|
472
|
+
};
|
|
473
|
+
declare const createAttribBuffer: (device: GPUDevice, value: number[]) => {
|
|
474
|
+
array: Float32Array<ArrayBuffer>;
|
|
475
|
+
buffer: GPUBuffer;
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* uniforms
|
|
479
|
+
*/
|
|
480
|
+
declare const createBindGroup: (device: GPUDevice, uniforms: Map<string, UniformData>, textures: Map<string, TextureData>) => {
|
|
481
|
+
bindGroups: GPUBindGroup[];
|
|
482
|
+
bindGroupLayouts: GPUBindGroupLayout[];
|
|
483
|
+
};
|
|
484
|
+
declare const createDescriptor: (c: GPUCanvasContext, depthTexture: GPUTexture) => GPURenderPassDescriptor;
|
|
485
|
+
declare const createTextureSampler: (device: GPUDevice, width?: number, height?: number) => {
|
|
486
|
+
texture: GPUTexture;
|
|
487
|
+
sampler: GPUSampler;
|
|
488
|
+
};
|
|
489
|
+
declare const createDepthTexture: (device: GPUDevice, width: number, height: number) => GPUTexture;
|
|
490
|
+
declare const createVertexBuffers: (attribs: Map<string, AttribData>) => {
|
|
491
|
+
vertexBuffers: GPUBuffer[];
|
|
492
|
+
bufferLayouts: GPUVertexBufferLayout[];
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
declare const createProgram: (c: WebGLRenderingContext, vs: X, fs: string | X, onError?: () => void, gl?: any) => void | WebGLProgram;
|
|
496
|
+
declare const createVbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
|
|
497
|
+
declare const createIbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
|
|
498
|
+
declare const getStride: (count: number, value: number[], iboValue?: number[]) => number;
|
|
499
|
+
declare const createAttrib: (c: WebGLRenderingContext, stride: number, loc: any, vbo: WebGLBuffer, ibo?: WebGLBuffer) => void;
|
|
500
|
+
declare const createTexture: (c: WebGLRenderingContext, img: HTMLImageElement, loc: any, unit: number) => void;
|
|
501
|
+
|
|
502
|
+
declare const webgl: (gl: Partial<GL>) => Promise<{
|
|
503
|
+
render: () => void;
|
|
504
|
+
clean: () => void;
|
|
505
|
+
_attribute: (key: string | undefined, value: number[], iboValue: number[]) => void;
|
|
506
|
+
_uniform: (key: string, value: number | number[]) => void;
|
|
507
|
+
_texture: (key: string, src: string) => void;
|
|
508
|
+
webgl: WebGLState;
|
|
509
|
+
}>;
|
|
510
|
+
|
|
511
|
+
declare const webgpu: (gl: Partial<GL>) => Promise<{
|
|
512
|
+
webgpu: WebGPUState;
|
|
513
|
+
render: () => void;
|
|
514
|
+
resize: () => void;
|
|
515
|
+
clean: () => void;
|
|
516
|
+
_attribute: (key: string | undefined, value: number[]) => void;
|
|
517
|
+
_uniform: (key: string, value: number | number[]) => void;
|
|
518
|
+
_texture: (key: string, src: string) => void;
|
|
519
|
+
}>;
|
|
520
|
+
|
|
521
|
+
declare const isGL: (a: unknown) => a is EventState<GL>;
|
|
522
|
+
declare const isServer: () => boolean;
|
|
523
|
+
declare const isWebGPUSupported: () => boolean;
|
|
524
|
+
declare const createGL: (props?: Partial<GL>) => EventState<{
|
|
525
|
+
isNative: boolean;
|
|
526
|
+
isWebGL: boolean;
|
|
527
|
+
isLoop: boolean;
|
|
528
|
+
isGL: true;
|
|
529
|
+
width: number;
|
|
530
|
+
height: number;
|
|
531
|
+
size: [number, number];
|
|
532
|
+
mouse: [number, number];
|
|
533
|
+
count: number;
|
|
534
|
+
el: HTMLCanvasElement;
|
|
535
|
+
vs: string | NodeProxy;
|
|
536
|
+
fs: string | NodeProxy;
|
|
537
|
+
vert: string | NodeProxy;
|
|
538
|
+
frag: string | NodeProxy;
|
|
539
|
+
vertex: string | NodeProxy;
|
|
540
|
+
fragment: string | NodeProxy;
|
|
541
|
+
webgpu: WebGPUState;
|
|
542
|
+
webgl: WebGLState;
|
|
543
|
+
queue: refr.Queue;
|
|
544
|
+
frame: refr.Frame;
|
|
545
|
+
ref?: any;
|
|
546
|
+
init(): void;
|
|
547
|
+
loop(): void;
|
|
548
|
+
mount(): void;
|
|
549
|
+
clean(): void;
|
|
550
|
+
render(): void;
|
|
551
|
+
resize(e?: Event): void;
|
|
552
|
+
mousemove(e: Event): void;
|
|
553
|
+
_uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
|
|
554
|
+
uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
|
|
555
|
+
uniform(node: NodeProxy): GL;
|
|
556
|
+
uniform(target: {
|
|
557
|
+
[key: string]: Uniform;
|
|
558
|
+
}): GL;
|
|
559
|
+
_texture?(key: string, value: string): GL;
|
|
560
|
+
texture(key: string, value: string): GL;
|
|
561
|
+
texture(target: {
|
|
562
|
+
[key: string]: string;
|
|
563
|
+
}): GL;
|
|
564
|
+
_attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
|
|
565
|
+
attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
|
|
566
|
+
attribute(target: {
|
|
567
|
+
[key: string]: Attribute;
|
|
568
|
+
}): GL;
|
|
569
|
+
}, any[] | unknown[]>;
|
|
570
|
+
|
|
571
|
+
export { AttribData, Attribute, Attributes, BaseNodeProxy, Constants, Conversions, DynamicProperties, Fn, FnLayout, Functions, GL, GLClearMode, GLDrawMode, GLDrawType, If, Loop, NodeContext, NodeProps, NodeProxy, NodeTypes, Operators, PrecisionMode, Return, Switch, Swizzles, TextureData, Uniform, UniformData, Uniforms, WebGLState, WebGPUState, X, abs, acos, all, any, asin, assign, atan, atan2, attribute, bitcast, bool, builtin, bvec2, bvec3, bvec4, cbrt, ceil, clamp, code, color, constant, conversion, conversionToConstant, cos, createAttrib, createAttribBuffer, createBindGroup, createBindings, createDepthTexture, createDescriptor, createDevice, createGL, createIbo, createPipeline, createProgram, createTexture, createTextureSampler, createUniformBuffer, createVbo, createVertexBuffers, cross, cubeTexture, dFdx, dFdy, createGL as default, degrees, difference, dig, distance, dot, each, equals, exp, exp2, ext, faceforward, fig, float, floor, flush, formatConversions, fract, fragDepth, fragment, frontFacing, function_, fwidth, getBluiltin, getId, getOperator, getStride, hex2rgb, iMouse, iResolution, iTime, instanceIndex, int, inverseSqrt, is, isConstantsType, isConversion, isFunction, isGL, isNodeProxy, isOperator, isServer, isSwizzle, isWebGPUSupported, ivec2, ivec3, ivec4, joins, length, lengthSq, log, log2, mat2, mat3, mat4, max, min, mix, negate, node, normalLocal, normalView, normalWorld, normalize, oneMinus, operator, pointCoord, position, positionLocal, positionView, positionWorld, pow, pow2, pow3, pow4, radians, reciprocal, reflect, refract, replace, round, sampleIndex, sampleMask, sampler2D, saturate, screenCoordinate, screenUV, select, sig, sign, sin, smoothstep, sqrt, step, swizzle, tan, texture, texture2D, textureSize, toVar, transformDirection, trunc, uint, uniform, uv, uvec2, uvec3, uvec4, variable, vec2, vec3, vec4, vertex, vertexIndex, vertexStage, webgl, webgpu };
|