glre 0.20.0 → 0.22.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.
Files changed (48) hide show
  1. package/README.md +150 -80
  2. package/dist/index.d.ts +442 -236
  3. package/dist/index.js +46 -13
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +46 -13
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/native.d.ts +7 -530
  8. package/dist/native.js +46 -13
  9. package/dist/native.js.map +1 -1
  10. package/dist/native.mjs +46 -13
  11. package/dist/native.mjs.map +1 -1
  12. package/dist/react.d.ts +7 -478
  13. package/dist/react.js +46 -13
  14. package/dist/react.js.map +1 -1
  15. package/dist/react.mjs +46 -13
  16. package/dist/react.mjs.map +1 -1
  17. package/dist/solid.d.ts +7 -424
  18. package/dist/solid.js +46 -13
  19. package/dist/solid.js.map +1 -1
  20. package/dist/solid.mjs +46 -13
  21. package/dist/solid.mjs.map +1 -1
  22. package/package.json +26 -61
  23. package/src/code/glsl.ts +186 -0
  24. package/src/code/wgsl.ts +170 -0
  25. package/src/index.ts +105 -0
  26. package/src/native.ts +24 -0
  27. package/src/node/cache.ts +67 -0
  28. package/src/node/const.ts +147 -0
  29. package/src/node/conv.ts +122 -0
  30. package/src/node/index.ts +96 -0
  31. package/src/node/node.ts +114 -0
  32. package/src/node/types.ts +101 -0
  33. package/src/node/uniform.ts +99 -0
  34. package/src/react.ts +18 -0
  35. package/src/solid.ts +15 -0
  36. package/src/types.ts +90 -0
  37. package/src/utils.ts +53 -0
  38. package/src/webgl/buffer.ts +78 -0
  39. package/src/webgl/index.ts +79 -0
  40. package/src/webgl/program.ts +61 -0
  41. package/src/webgl/shader.ts +60 -0
  42. package/src/webgl/texture.ts +93 -0
  43. package/src/webgpu/buffer.ts +96 -0
  44. package/src/webgpu/device.ts +91 -0
  45. package/src/webgpu/index.ts +40 -0
  46. package/src/webgpu/pipeline.ts +94 -0
  47. package/src/webgpu/texture.ts +139 -0
  48. package/dist/types-2792569d.d.ts +0 -7
package/dist/index.d.ts CHANGED
@@ -1,230 +1,433 @@
1
+ import * as reev from 'reev';
2
+ import { EventState, Nested } from 'reev';
1
3
  import * as refr from 'refr';
2
- import { P as PrecisionMode, U as Uniform, A as Attribute, G as GLClearMode, a as GLDrawMode } from './types-2792569d.js';
4
+ import { Queue, Frame } from 'refr';
5
+ export { Frame, Fun, Queue } from 'refr';
6
+ import * as refr_dist_types_687121c7 from 'refr/dist/types-687121c7';
3
7
 
4
- declare const createGL: (props?: EventState<{
5
- id: string;
6
- width: number;
7
- height: number;
8
- size: [number, number];
9
- mouse: [number, number];
10
- count: number;
11
- vs: string;
12
- fs: string;
13
- vert: string;
14
- frag: string;
15
- vertex: string;
16
- fragment: string;
17
- varying: string;
18
- int: PrecisionMode;
19
- float: PrecisionMode;
20
- sampler2D: PrecisionMode;
21
- samplerCube: PrecisionMode;
22
- lastActiveUnit: number;
23
- gl: any;
24
- pg: any;
25
- el: any;
26
- frame: refr.Queue;
27
- target: any;
28
- stride: Nested<number>;
29
- location: Nested<any>;
30
- activeUnit: Nested<number>;
31
- default: any;
32
- ref?: any;
33
- init(varying?: string[]): void;
34
- mount(): void;
35
- clean(): void;
36
- render(): void;
37
- mousemove(e: Event): void;
38
- resize(e?: Event, width?: number, height?: number): void;
39
- load(e?: Event, image?: HTMLImageElement): void;
40
- uniform(key: string, value: Uniform): EventState<any>;
41
- uniform(target: {
42
- [key: string]: Uniform;
43
- }): EventState<any>;
44
- texture(key: string, value: string): EventState<any>;
45
- texture(target: {
46
- [key: string]: string;
47
- }): EventState<any>;
48
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
49
- attribute(target: {
50
- [key: string]: Attribute;
51
- }): EventState<any>;
52
- clear(key?: GLClearMode): void;
53
- viewport(size?: [number, number]): void;
54
- drawArrays(key?: GLDrawMode): void;
55
- drawElements(key?: GLDrawMode): void;
56
- }>) => EventState<{
8
+ declare const TYPES: readonly ["float", "int", "uint", "bool", "color", "vec2", "vec3", "vec4", "mat2", "mat3", "mat4", "ivec2", "ivec3", "ivec4", "uvec2", "uvec3", "uvec4", "bvec2", "bvec3", "bvec4"];
9
+ type NodeType = (typeof TYPES)[number];
10
+ declare const SWIZZLES: readonly ["x", "y", "z", "w", "r", "g", "b", "a", "s", "t", "p", "q"];
11
+ type AllSwizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
12
+ type Swillzes = AllSwizzles<'x' | 'y' | 'z' | 'w'> | AllSwizzles<'r' | 'g' | 'b' | 'a'> | AllSwizzles<'p' | 'q'> | AllSwizzles<'s' | 't'>;
13
+ declare const OPERATORS: readonly ["add", "sub", "mul", "div", "mod", "equal", "notEqual", "lessThan", "lessThanEqual", "greaterThan", "greaterThanEqual", "and", "or", "not", "assign", "xor", "bitAnd", "bitNot", "bitOr", "bitXor", "shiftLeft", "shiftRight"];
14
+ type Operator = (typeof OPERATORS)[number];
15
+ declare const FUNCTIONS: readonly ["abs", "acos", "asin", "atan", "atan2", "ceil", "clamp", "cos", "cross", "degrees", "distance", "dot", "exp", "exp2", "faceforward", "floor", "fract", "length", "all", "any", "bitcast", "cbrt", "dFdx", "dFdy", "difference", "equals", "fwidth", "inverseSqrt", "lengthSq", "log", "log2", "max", "min", "mix", "negate", "normalize", "oneMinus", "pow", "pow2", "pow3", "pow4", "radians", "reciprocal", "reflect", "refract", "round", "saturate", "sign", "sin", "smoothstep", "sqrt", "step", "tan", "transformDirection", "trunc"];
16
+ type MathFunction = (typeof FUNCTIONS)[number];
17
+ declare const CACHE_BOOLS: readonly [true, false];
18
+ declare const CACHE_INTS: readonly [0, 1, 2, 3, 4, 5];
19
+ declare const CACHE_FLOATS: readonly [0, 1, 0.5, 2];
20
+
21
+ interface Node {
57
22
  id: string;
23
+ type: NodeType;
24
+ value?: any;
25
+ property?: string;
26
+ parent?: Node;
27
+ children?: Node[];
28
+ operator?: Operator;
29
+ mathFunction?: MathFunction;
30
+ }
31
+ interface ProxyCallback {
32
+ path: string[];
33
+ args: any[];
34
+ }
35
+ type NodeCreator = (value?: any) => X;
36
+ interface OperatorMethods {
37
+ add(x: X | number): X;
38
+ sub(x: X | number): X;
39
+ mul(x: X | number): X;
40
+ div(x: X | number): X;
41
+ mod(x: X | number): X;
42
+ equal(x: X | number): X;
43
+ notEqual(x: X | number): X;
44
+ lessThan(x: X | number): X;
45
+ lessThanEqual(x: X | number): X;
46
+ greaterThan(x: X | number): X;
47
+ greaterThanEqual(x: X | number): X;
48
+ and(x: X): X;
49
+ or(x: X): X;
50
+ not(): X;
51
+ }
52
+ interface MathMethods {
53
+ abs(): X;
54
+ acos(): X;
55
+ asin(): X;
56
+ atan(): X;
57
+ ceil(): X;
58
+ cos(): X;
59
+ floor(): X;
60
+ fract(): X;
61
+ length(): X;
62
+ normalize(): X;
63
+ sin(): X;
64
+ sqrt(): X;
65
+ tan(): X;
66
+ toVar(): X;
67
+ }
68
+ type SwizzleProperties = {
69
+ [k in Swillzes]: X;
70
+ };
71
+ interface X extends MathMethods, OperatorMethods, SwizzleProperties {
72
+ readonly id: string;
73
+ readonly type: NodeType;
74
+ readonly value: any;
75
+ readonly property: string;
76
+ (...args: any[]): X;
77
+ }
78
+ interface UniformNode extends X {
79
+ set(value: any): void;
80
+ onObjectUpdate(callback: (context: any) => any): UniformNode;
81
+ onRenderUpdate(callback: (context: any) => any): UniformNode;
82
+ }
83
+ interface FunctionNode {
84
+ (...args: any[]): X;
85
+ call(x: X[]): X;
86
+ }
87
+ interface ConditionalNode {
88
+ ElseIf(condition: X, callback: () => void): ConditionalNode;
89
+ Else(callback: () => void): void;
90
+ }
91
+ interface ConversionContext {
92
+ target: 'webgl' | 'webgpu';
93
+ nodes: Map<string, Node>;
94
+ variables: Map<string, string>;
95
+ functions: Map<string, string>;
96
+ }
97
+
98
+ declare const getCachedBool: (x: boolean) => X;
99
+ declare const getCachedInt: (x: number) => X;
100
+ declare const getCachedFloat: (x: number) => X;
101
+ declare const findDuplicateNodes: (nodes: X[]) => Map<string, X[]>;
102
+
103
+ declare const convertToNode: (x: unknown) => X;
104
+ declare const float: (x: unknown) => X;
105
+ declare const int: (x: unknown) => X;
106
+ declare const bool: (x: unknown) => X;
107
+ declare const vec2: (x?: any, y?: any) => X;
108
+ declare const vec3: (x?: any, y?: any, z?: any) => X;
109
+ declare const vec4: (x?: any, y?: any, z?: any, w?: any) => X;
110
+ declare const color: (r?: any, g?: any, b?: any) => X;
111
+
112
+ declare const createNode: (type: NodeType, value?: any, options?: Partial<Node>) => Node;
113
+ declare const node: (type: NodeType, value?: any, options?: Partial<Node>) => X;
114
+
115
+ interface UpdateContext {
116
+ object?: any;
117
+ camera?: any;
118
+ renderer?: any;
119
+ scene?: any;
120
+ time?: number;
121
+ }
122
+ declare const uniform: (initialValue: any) => UniformNode;
123
+ declare const iPrevTime: UniformNode;
124
+ declare const iDeltaTime: UniformNode;
125
+ declare const updateUniforms: (context: UpdateContext) => void;
126
+
127
+ declare const Fn: (jsFunc: Function) => FunctionNode;
128
+ declare const If: (condition: X, callback: () => void) => ConditionalNode;
129
+ declare const gl_FragCoord: X;
130
+ declare const gl_Position: X;
131
+ declare const iTime: UniformNode;
132
+ declare const iResolution: UniformNode;
133
+ declare const iMouse: UniformNode;
134
+ declare const abs: (x: X) => X;
135
+ declare const sin: (x: X) => X;
136
+ declare const cos: (x: X) => X;
137
+ declare const tan: (x: X) => X;
138
+ declare const sqrt: (x: X) => X;
139
+ declare const floor: (x: X) => X;
140
+ declare const ceil: (x: X) => X;
141
+ declare const fract: (x: X) => X;
142
+ declare const normalize: (x: X) => X;
143
+ declare const length: (x: X) => X;
144
+
145
+ type Uniform = number | number[];
146
+ type Attribute = number[];
147
+ type Attributes = Record<string, Attribute>;
148
+ type Uniforms = Record<string, Uniform>;
149
+ type PrecisionMode = 'highp' | 'mediump' | 'lowp';
150
+ type GLClearMode = 'COLOR_BUFFER_BIT' | 'DEPTH_BUFFER_BIT' | 'STENCIL_BUFFER_BIT';
151
+ type GLDrawMode = 'POINTS' | 'LINE_STRIP' | 'LINE_LOOP' | 'LINES' | 'TRIANGLE_STRIP' | 'TRIANGLE_FAN' | 'TRIANGLES';
152
+ type GLDrawType = 'UNSIGNED_BYTE' | 'UNSIGNED_SHORT' | 'UNSIGNED_INT';
153
+ type GL = EventState<{
154
+ /**
155
+ * initial value
156
+ */
157
+ isNative: boolean;
158
+ isWebGL: boolean;
159
+ isLoop: boolean;
160
+ isGL: true;
58
161
  width: number;
59
162
  height: number;
60
163
  size: [number, number];
61
164
  mouse: [number, number];
62
165
  count: number;
63
- vs: string;
64
- fs: string;
65
- vert: string;
66
- frag: string;
67
- vertex: string;
68
- fragment: string;
69
- varying: string;
166
+ vs: string | X;
167
+ fs: string | X;
168
+ vert: string | X;
169
+ frag: string | X;
170
+ vertex: string | X;
171
+ fragment: string | X;
172
+ /**
173
+ * for webgl
174
+ */
70
175
  int: PrecisionMode;
71
176
  float: PrecisionMode;
72
177
  sampler2D: PrecisionMode;
73
178
  samplerCube: PrecisionMode;
74
179
  lastActiveUnit: number;
180
+ /**
181
+ * core state
182
+ */
75
183
  gl: any;
76
184
  pg: any;
77
185
  el: any;
78
- frame: refr.Queue;
79
- target: any;
186
+ queue: Queue;
187
+ frame: Frame;
80
188
  stride: Nested<number>;
81
189
  location: Nested<any>;
82
190
  activeUnit: Nested<number>;
83
191
  default: any;
192
+ /**
193
+ * events
194
+ */
84
195
  ref?: any;
85
- init(varying?: string[]): void;
196
+ init(): void;
197
+ loop(): void;
86
198
  mount(): void;
87
199
  clean(): void;
88
200
  render(): void;
201
+ resize(e?: Event): void;
89
202
  mousemove(e: Event): void;
90
- resize(e?: Event, width?: number, height?: number): void;
91
- load(e?: Event, image?: HTMLImageElement): void;
92
- uniform(key: string, value: Uniform): EventState<any>;
203
+ /**
204
+ * setter
205
+ */
206
+ _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
207
+ uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
93
208
  uniform(target: {
94
209
  [key: string]: Uniform;
95
- }): EventState<any>;
96
- texture(key: string, value: string): EventState<any>;
210
+ }): GL;
211
+ _texture?(key: string, value: string): GL;
212
+ texture(key: string, value: string): GL;
97
213
  texture(target: {
98
214
  [key: string]: string;
99
- }): EventState<any>;
100
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
215
+ }): GL;
216
+ _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
217
+ attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
101
218
  attribute(target: {
102
219
  [key: string]: Attribute;
103
- }): EventState<any>;
104
- clear(key?: GLClearMode): void;
105
- viewport(size?: [number, number]): void;
106
- drawArrays(key?: GLDrawMode): void;
107
- drawElements(key?: GLDrawMode): void;
220
+ }): GL;
108
221
  }>;
109
- declare const gl: EventState<{
110
- id: string;
111
- width: number;
112
- height: number;
113
- size: [number, number];
114
- mouse: [number, number];
115
- count: number;
116
- vs: string;
117
- fs: string;
118
- vert: string;
119
- frag: string;
120
- vertex: string;
121
- fragment: string;
122
- varying: string;
123
- int: PrecisionMode;
124
- float: PrecisionMode;
125
- sampler2D: PrecisionMode;
126
- samplerCube: PrecisionMode;
127
- lastActiveUnit: number;
128
- gl: any;
129
- pg: any;
130
- el: any;
131
- frame: refr.Queue;
132
- target: any;
133
- stride: Nested<number>;
134
- location: Nested<any>;
135
- activeUnit: Nested<number>;
136
- default: any;
137
- ref?: any;
138
- init(varying?: string[]): void;
139
- mount(): void;
140
- clean(): void;
141
- render(): void;
142
- mousemove(e: Event): void;
143
- resize(e?: Event, width?: number, height?: number): void;
144
- load(e?: Event, image?: HTMLImageElement): void;
145
- uniform(key: string, value: Uniform): EventState<any>;
146
- uniform(target: {
147
- [key: string]: Uniform;
148
- }): EventState<any>;
149
- texture(key: string, value: string): EventState<any>;
150
- texture(target: {
151
- [key: string]: string;
152
- }): EventState<any>;
153
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
154
- attribute(target: {
155
- [key: string]: Attribute;
156
- }): EventState<any>;
157
- clear(key?: GLClearMode): void;
158
- viewport(size?: [number, number]): void;
159
- drawArrays(key?: GLDrawMode): void;
160
- drawElements(key?: GLDrawMode): void;
222
+
223
+ interface GLSLContext extends ConversionContext {
224
+ target: 'webgl';
225
+ precision: 'lowp' | 'mediump' | 'highp';
226
+ version: '100' | '300 es';
227
+ }
228
+ declare const nodeToGLSL: (nodeProxy: X, context?: Partial<GLSLContext>) => string;
229
+ declare const glsl: (fragmentNode: X, options?: {
230
+ precision?: "lowp" | "mediump" | "highp";
231
+ version?: "100" | "300 es";
232
+ uniforms?: Record<string, any>;
233
+ }) => string;
234
+
235
+ interface WGSLContext extends ConversionContext {
236
+ target: 'webgpu';
237
+ }
238
+ declare const nodeToWGSL: (nodeProxy: X, context?: Partial<WGSLContext>) => string;
239
+ declare const wgsl: (fragmentNode: X, options?: {
240
+ uniforms?: Record<string, any>;
241
+ }) => string;
242
+
243
+ declare const is: {
244
+ arr: (arg: any) => arg is any[];
245
+ bol: (a: unknown) => a is boolean;
246
+ str: (a: unknown) => a is string;
247
+ num: (a: unknown) => a is number;
248
+ int: (a: unknown) => a is number;
249
+ fun: (a: unknown) => a is Function;
250
+ und: (a: unknown) => a is undefined;
251
+ nul: (a: unknown) => a is null;
252
+ set: (a: unknown) => a is Set<unknown>;
253
+ map: (a: unknown) => a is Map<unknown, unknown>;
254
+ obj: (a: unknown) => a is object;
255
+ nan: (a: unknown) => a is number;
256
+ };
257
+ declare const isServer: () => boolean;
258
+ declare const isWebGPUSupported: () => boolean;
259
+ /**
260
+ * each
261
+ */
262
+ type EachFn<Value, Key, This> = (this: This, value: Value, key: Key) => void;
263
+ type Eachable<Value = any, Key = any, This = any> = {
264
+ forEach(cb: EachFn<Value, Key, This>, ctx?: This): void;
265
+ };
266
+ declare const each: <Value, Key, This>(obj: Eachable<Value, Key, This>, fn: EachFn<Value, Key, This>) => void;
267
+ declare const flush: <Value extends Function, Key, This>(obj: Eachable<Value, Key, This>, ...args: any[]) => void;
268
+ /**
269
+ * other
270
+ */
271
+ declare const replace: (x?: string, from?: string, to?: string) => string;
272
+ declare const ext: (src?: string) => string;
273
+ declare const fig: (x?: number) => number;
274
+ declare const dig: (x?: number) => number;
275
+ declare const sig: (value?: number, digit?: number) => number;
276
+
277
+ declare const createVbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
278
+ declare const createIbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
279
+ declare const createAttribute: (c: WebGLRenderingContext, stride: number, location: number, vbo: WebGLBuffer, ibo?: WebGLBuffer) => void;
280
+ declare const deleteBuffer: (c: WebGLRenderingContext, buffer: WebGLBuffer) => void;
281
+ declare const vertexStride: (count: number, value: number[], iboValue?: number[]) => number;
282
+ declare const updateVbo: (c: WebGLRenderingContext, buffer: WebGLBuffer, data: number[], usage?: 35044) => void;
283
+ declare const updateIbo: (c: WebGLRenderingContext, buffer: WebGLBuffer, data: number[], usage?: 35044) => void;
284
+
285
+ declare const createProgram: (c: WebGLRenderingContext, vs: WebGLShader, fs: WebGLShader) => WebGLProgram;
286
+ declare const deleteProgram: (c: WebGLRenderingContext, pg: WebGLProgram) => void;
287
+ declare const getProgramInfo: (c: WebGLRenderingContext, pg: WebGLProgram) => {
288
+ linked: any;
289
+ log: string | null;
290
+ activeAttributes: any;
291
+ activeUniforms: any;
292
+ };
293
+ declare const getUniformType: (value: number | number[], isMatrix?: boolean) => string;
294
+ declare const getUniformLocation: (c: WebGLRenderingContext, pg: WebGLProgram, name: string) => WebGLUniformLocation | null;
295
+ declare const getAttribLocation: (c: WebGLRenderingContext, pg: WebGLProgram, name: string) => number;
296
+
297
+ declare const deleteShader: (c: WebGLRenderingContext, shader: WebGLShader) => void;
298
+ declare const createVertexShader: (c: WebGLRenderingContext, source?: string) => WebGLShader;
299
+ declare const createFragmentShader: (c: WebGLRenderingContext, source?: string) => WebGLShader;
300
+ declare const getShaderInfo: (c: WebGLRenderingContext, shader: WebGLShader) => {
301
+ compiled: any;
302
+ log: string | null;
303
+ source: string | null;
304
+ };
305
+
306
+ declare const createTexture: (c: WebGLRenderingContext, img: HTMLImageElement) => WebGLTexture;
307
+ declare const activeTexture: (c: WebGLRenderingContext, location: WebGLUniformLocation | null, unit: number, texture: WebGLTexture) => void;
308
+ declare const deleteTexture: (c: WebGLRenderingContext, texture: WebGLTexture) => void;
309
+ declare const createEmptyTexture: (c: WebGLRenderingContext, w?: number, h?: number, format?: 6408, type?: 5121) => WebGLTexture;
310
+ declare const createCubeTexture: (c: WebGLRenderingContext, imgs: HTMLImageElement[]) => WebGLTexture;
311
+
312
+ declare const webgl: (gl: GL) => GL;
313
+
314
+ declare const createBuffer: (device: any, data: Float32Array | Uint32Array | number[], usage: number) => any;
315
+ declare const createVertexBuffer: (device: any, data: number[]) => any;
316
+ declare const createIndexBuffer: (device: any, data: number[]) => any;
317
+ declare const createUniformBuffer: (device: any, size: number) => any;
318
+ declare const createStorageBuffer: (device: any, size: number) => any;
319
+ declare const updateBuffer: (device: any, buffer: any, data: Float32Array | Uint32Array | number[], offset?: number) => void;
320
+ declare const destroyBuffer: (buffer: any) => any;
321
+ declare const calculateBufferSize: (data: number[]) => number;
322
+ declare const alignBufferSize: (size: number, alignment?: number) => number;
323
+ declare const createBuffers: (device: any, bufferConfigs: Array<{
324
+ data: number[];
325
+ usage: number;
326
+ }>) => any[];
327
+ declare const BufferUsage: {
328
+ readonly VERTEX: 32;
329
+ readonly INDEX: 64;
330
+ readonly UNIFORM: 64;
331
+ readonly STORAGE: 128;
332
+ readonly COPY_SRC: 4;
333
+ readonly COPY_DST: 8;
334
+ readonly MAP_READ: 1;
335
+ readonly MAP_WRITE: 2;
336
+ };
337
+
338
+ declare const requestWebGPUDevice: () => Promise<{
339
+ adapter: any;
340
+ device: any;
161
341
  }>;
162
- declare const createTF: (props?: EventState<{
163
- id: string;
164
- width: number;
165
- height: number;
166
- size: [number, number];
167
- mouse: [number, number];
168
- count: number;
169
- vs: string;
170
- fs: string;
171
- vert: string;
172
- frag: string;
173
- vertex: string;
174
- fragment: string;
175
- varying: string;
176
- int: PrecisionMode;
177
- float: PrecisionMode;
178
- sampler2D: PrecisionMode;
179
- samplerCube: PrecisionMode;
180
- lastActiveUnit: number;
181
- gl: any;
182
- pg: any;
183
- el: any;
184
- frame: refr.Queue;
185
- target: any;
186
- stride: Nested<number>;
187
- location: Nested<any>;
188
- activeUnit: Nested<number>;
189
- default: any;
190
- ref?: any;
191
- init(varying?: string[]): void;
192
- mount(): void;
193
- clean(): void;
194
- render(): void;
195
- mousemove(e: Event): void;
196
- resize(e?: Event, width?: number, height?: number): void;
197
- load(e?: Event, image?: HTMLImageElement): void;
198
- uniform(key: string, value: Uniform): EventState<any>;
199
- uniform(target: {
200
- [key: string]: Uniform;
201
- }): EventState<any>;
202
- texture(key: string, value: string): EventState<any>;
203
- texture(target: {
204
- [key: string]: string;
205
- }): EventState<any>;
206
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
207
- attribute(target: {
208
- [key: string]: Attribute;
209
- }): EventState<any>;
210
- clear(key?: GLClearMode): void;
211
- viewport(size?: [number, number]): void;
212
- drawArrays(key?: GLDrawMode): void;
213
- drawElements(key?: GLDrawMode): void;
214
- }>, self?: EventState<{
215
- id: string;
342
+ declare const checkWebGPUSupport: () => boolean;
343
+ declare const getDeviceLimits: (device: any) => {
344
+ maxTextureDimension1D: any;
345
+ maxTextureDimension2D: any;
346
+ maxTextureDimension3D: any;
347
+ maxTextureArrayLayers: any;
348
+ maxBindGroups: any;
349
+ maxDynamicUniformBuffersPerPipelineLayout: any;
350
+ maxDynamicStorageBuffersPerPipelineLayout: any;
351
+ maxSampledTexturesPerShaderStage: any;
352
+ maxSamplersPerShaderStage: any;
353
+ maxStorageBuffersPerShaderStage: any;
354
+ maxStorageTexturesPerShaderStage: any;
355
+ maxUniformBuffersPerShaderStage: any;
356
+ maxUniformBufferBindingSize: any;
357
+ maxStorageBufferBindingSize: any;
358
+ maxVertexBuffers: any;
359
+ maxVertexAttributes: any;
360
+ maxVertexBufferArrayStride: any;
361
+ maxComputeWorkgroupStorageSize: any;
362
+ maxComputeInvocationsPerWorkgroup: any;
363
+ maxComputeWorkgroupSizeX: any;
364
+ maxComputeWorkgroupSizeY: any;
365
+ maxComputeWorkgroupSizeZ: any;
366
+ maxComputeWorkgroupsPerDimension: any;
367
+ };
368
+ declare const setupDeviceErrorHandling: (device: any) => void;
369
+ declare const configureCanvasContext: (canvas: HTMLCanvasElement, device: any, format?: any) => RenderingContext;
370
+
371
+ declare const createRenderPipeline: (device: any, vertexShader?: string, fragmentShader?: string, format?: string) => any;
372
+ declare const createComputePipeline: (device: any, computeShader: string) => any;
373
+ declare const createShaderModule: (device: any, code: string) => any;
374
+ declare const createBindGroupLayout: (device: any, entries: any[]) => any;
375
+ declare const createBindGroup: (device: any, layout: any, entries: any[]) => any;
376
+ declare const createRenderPass: (encoder: any, colorAttachment: any, depthStencilAttachment?: any) => any;
377
+ declare const createCommandEncoder: (device: any) => any;
378
+
379
+ declare const createTextureFromImage: (device: any, image: HTMLImageElement | ImageBitmap, format?: string) => any;
380
+ declare const createDepthTexture: (device: any, w?: number, h?: number, format?: string) => any;
381
+ declare const createSampler: (device: any, options?: {
382
+ magFilter?: string;
383
+ minFilter?: string;
384
+ addressModeU?: string;
385
+ addressModeV?: string;
386
+ addressModeW?: string;
387
+ }) => any;
388
+ declare const createTextureView: (texture: any, options?: {
389
+ format?: string;
390
+ dimension?: string;
391
+ aspect?: string;
392
+ baseMipLevel?: number;
393
+ mipLevelCount?: number;
394
+ baseArrayLayer?: number;
395
+ arrayLayerCount?: number;
396
+ }) => any;
397
+ declare const updateTexture: (device: any, texture: any, data: Uint8Array | Uint8ClampedArray, w?: number, h?: number) => void;
398
+ declare const destroyTexture: (texture: any) => any;
399
+ declare const TextureUsage: {
400
+ readonly COPY_SRC: 1;
401
+ readonly COPY_DST: 2;
402
+ readonly TEXTURE_BINDING: 4;
403
+ readonly STORAGE_BINDING: 8;
404
+ readonly RENDER_ATTACHMENT: 16;
405
+ };
406
+ declare const TextureFormat: {
407
+ readonly RGBA8_UNORM: "rgba8unorm";
408
+ readonly RGBA8_SRGB: "rgba8unorm-srgb";
409
+ readonly BGRA8_UNORM: "bgra8unorm";
410
+ readonly BGRA8_SRGB: "bgra8unorm-srgb";
411
+ readonly DEPTH24_PLUS: "depth24plus";
412
+ readonly DEPTH32_FLOAT: "depth32float";
413
+ };
414
+
415
+ declare const webgpu: (gl: GL) => reev.EventState<{
416
+ isNative: boolean;
417
+ isWebGL: boolean;
418
+ isLoop: boolean;
419
+ isGL: true;
216
420
  width: number;
217
421
  height: number;
218
422
  size: [number, number];
219
423
  mouse: [number, number];
220
424
  count: number;
221
- vs: string;
222
- fs: string;
223
- vert: string;
224
- frag: string;
225
- vertex: string;
226
- fragment: string;
227
- varying: string;
425
+ vs: string | X;
426
+ fs: string | X;
427
+ vert: string | X;
428
+ frag: string | X;
429
+ vertex: string | X;
430
+ fragment: string | X;
228
431
  int: PrecisionMode;
229
432
  float: PrecisionMode;
230
433
  sampler2D: PrecisionMode;
@@ -233,50 +436,54 @@ declare const createTF: (props?: EventState<{
233
436
  gl: any;
234
437
  pg: any;
235
438
  el: any;
236
- frame: refr.Queue;
237
- target: any;
238
- stride: Nested<number>;
239
- location: Nested<any>;
240
- activeUnit: Nested<number>;
439
+ queue: refr_dist_types_687121c7.Q;
440
+ frame: refr_dist_types_687121c7.a;
441
+ stride: reev.Nested<number>;
442
+ location: reev.Nested<any>;
443
+ activeUnit: reev.Nested<number>;
241
444
  default: any;
242
445
  ref?: any;
243
- init(varying?: string[]): void;
446
+ init(): void;
447
+ loop(): void;
244
448
  mount(): void;
245
449
  clean(): void;
246
450
  render(): void;
451
+ resize(e?: Event): void;
247
452
  mousemove(e: Event): void;
248
- resize(e?: Event, width?: number, height?: number): void;
249
- load(e?: Event, image?: HTMLImageElement): void;
250
- uniform(key: string, value: Uniform): EventState<any>;
453
+ _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
454
+ uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
251
455
  uniform(target: {
252
456
  [key: string]: Uniform;
253
- }): EventState<any>;
254
- texture(key: string, value: string): EventState<any>;
457
+ }): GL;
458
+ _texture?(key: string, value: string): GL;
459
+ texture(key: string, value: string): GL;
255
460
  texture(target: {
256
461
  [key: string]: string;
257
- }): EventState<any>;
258
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
462
+ }): GL;
463
+ _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
464
+ attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
259
465
  attribute(target: {
260
466
  [key: string]: Attribute;
261
- }): EventState<any>;
262
- clear(key?: GLClearMode): void;
263
- viewport(size?: [number, number]): void;
264
- drawArrays(key?: GLDrawMode): void;
265
- drawElements(key?: GLDrawMode): void;
266
- }>) => EventState<{
267
- id: string;
467
+ }): GL;
468
+ }, any[] | unknown[]>;
469
+
470
+ declare const isGL: (a: unknown) => a is EventState<GL>;
471
+ declare const createGL: (props?: Partial<GL>) => EventState<{
472
+ isNative: boolean;
473
+ isWebGL: boolean;
474
+ isLoop: boolean;
475
+ isGL: true;
268
476
  width: number;
269
477
  height: number;
270
478
  size: [number, number];
271
479
  mouse: [number, number];
272
480
  count: number;
273
- vs: string;
274
- fs: string;
275
- vert: string;
276
- frag: string;
277
- vertex: string;
278
- fragment: string;
279
- varying: string;
481
+ vs: string | X;
482
+ fs: string | X;
483
+ vert: string | X;
484
+ frag: string | X;
485
+ vertex: string | X;
486
+ fragment: string | X;
280
487
  int: PrecisionMode;
281
488
  float: PrecisionMode;
282
489
  sampler2D: PrecisionMode;
@@ -285,36 +492,35 @@ declare const createTF: (props?: EventState<{
285
492
  gl: any;
286
493
  pg: any;
287
494
  el: any;
288
- frame: refr.Queue;
289
- target: any;
290
- stride: Nested<number>;
291
- location: Nested<any>;
292
- activeUnit: Nested<number>;
495
+ queue: refr.Queue;
496
+ frame: refr.Frame;
497
+ stride: reev.Nested<number>;
498
+ location: reev.Nested<any>;
499
+ activeUnit: reev.Nested<number>;
293
500
  default: any;
294
501
  ref?: any;
295
- init(varying?: string[]): void;
502
+ init(): void;
503
+ loop(): void;
296
504
  mount(): void;
297
505
  clean(): void;
298
506
  render(): void;
507
+ resize(e?: Event): void;
299
508
  mousemove(e: Event): void;
300
- resize(e?: Event, width?: number, height?: number): void;
301
- load(e?: Event, image?: HTMLImageElement): void;
302
- uniform(key: string, value: Uniform): EventState<any>;
509
+ _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
510
+ uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
303
511
  uniform(target: {
304
512
  [key: string]: Uniform;
305
- }): EventState<any>;
306
- texture(key: string, value: string): EventState<any>;
513
+ }): GL;
514
+ _texture?(key: string, value: string): GL;
515
+ texture(key: string, value: string): GL;
307
516
  texture(target: {
308
517
  [key: string]: string;
309
- }): EventState<any>;
310
- attribute(key: string, value: Attribute, iboValue?: Attribute): EventState<any>;
518
+ }): GL;
519
+ _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
520
+ attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
311
521
  attribute(target: {
312
522
  [key: string]: Attribute;
313
- }): EventState<any>;
314
- clear(key?: GLClearMode): void;
315
- viewport(size?: [number, number]): void;
316
- drawArrays(key?: GLDrawMode): void;
317
- drawElements(key?: GLDrawMode): void;
318
- }>;
523
+ }): GL;
524
+ }, any[] | unknown[]>;
319
525
 
320
- export { createGL, createTF, gl as default, gl };
526
+ export { Attribute, Attributes, BufferUsage, CACHE_BOOLS, CACHE_FLOATS, CACHE_INTS, ConditionalNode, ConversionContext, FUNCTIONS, Fn, FunctionNode, GL, GLClearMode, GLDrawMode, GLDrawType, If, MathFunction, MathMethods, Node, NodeCreator, NodeType, OPERATORS, Operator, OperatorMethods, PrecisionMode, ProxyCallback, SWIZZLES, Swillzes, SwizzleProperties, TYPES, TextureFormat, TextureUsage, Uniform, UniformNode, Uniforms, X, abs, activeTexture, alignBufferSize, bool, calculateBufferSize, ceil, checkWebGPUSupport, color, configureCanvasContext, convertToNode, cos, createAttribute, createBindGroup, createBindGroupLayout, createBuffer, createBuffers, createCommandEncoder, createComputePipeline, createCubeTexture, createDepthTexture, createEmptyTexture, createFragmentShader, createGL, createIbo, createIndexBuffer, createNode, createProgram, createRenderPass, createRenderPipeline, createSampler, createShaderModule, createStorageBuffer, createTexture, createTextureFromImage, createTextureView, createUniformBuffer, createVbo, createVertexBuffer, createVertexShader, createGL as default, deleteBuffer, deleteProgram, deleteShader, deleteTexture, destroyBuffer, destroyTexture, dig, each, ext, fig, findDuplicateNodes, float, floor, flush, fract, getAttribLocation, getCachedBool, getCachedFloat, getCachedInt, getDeviceLimits, getProgramInfo, getShaderInfo, getUniformLocation, getUniformType, gl_FragCoord, gl_Position, glsl, iDeltaTime, iMouse, iPrevTime, iResolution, iTime, int, is, isGL, isServer, isWebGPUSupported, length, node, nodeToGLSL, nodeToWGSL, normalize, replace, requestWebGPUDevice, setupDeviceErrorHandling, sig, sin, sqrt, tan, uniform, updateBuffer, updateIbo, updateTexture, updateUniforms, updateVbo, vec2, vec3, vec4, vertexStride, webgl, webgpu, wgsl };