glre 0.31.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.
@@ -1,10 +1,9 @@
1
1
  import * as refr from 'refr';
2
2
  import { Queue, Frame } from 'refr';
3
3
  export { Frame, Fun, Queue } from 'refr';
4
- import { EventState } from 'reev';
4
+ import { Nested, EventState } from 'reev';
5
5
 
6
- declare const SWIZZLES: readonly ["x", "y", "z", "w", "r", "g", "b", "a", "s", "t", "p", "q"];
7
- declare const CONSTANTS: readonly ["bool", "uint", "int", "float", "bvec2", "ivec2", "uvec2", "vec2", "bvec3", "ivec3", "uvec3", "vec3", "bvec4", "ivec4", "uvec4", "vec4", "color", "mat2", "mat3", "mat4"];
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"];
8
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"];
9
8
  declare const OPERATORS: {
10
9
  readonly add: "+";
@@ -27,86 +26,7 @@ declare const OPERATORS: {
27
26
  readonly shiftRight: ">>";
28
27
  };
29
28
  declare const OPERATOR_KEYS: (keyof typeof OPERATORS)[];
30
- declare const SCALAR_RETURN_FUNCTIONS: readonly ["dot", "distance", "length", "lengthSq", "determinant", "luminance"];
31
- declare const BOOL_RETURN_FUNCTIONS: readonly ["all", "any"];
32
- declare const PRESERVE_TYPE_FUNCTIONS: readonly ["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"];
33
- declare const VEC3_RETURN_FUNCTIONS: readonly ["cross"];
34
- declare const FIRST_ARG_TYPE_FUNCTIONS: readonly ["reflect", "refract"];
35
- declare const HIGHEST_TYPE_FUNCTIONS: readonly ["min", "max", "mix", "clamp", "step", "smoothstep"];
36
- declare const VEC4_RETURN_FUNCTIONS: readonly ["texture", "textureLod", "textureSize", "cubeTexture"];
37
- declare const ADDITIONAL_FUNCTIONS: readonly ["atan2", "degrees", "faceforward", "bitcast", "cbrt", "difference", "equals", "pow", "pow2", "pow3", "pow4", "radians", "transformDirection"];
38
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"];
39
- declare const TYPE_MAPPING: {
40
- readonly float: "f32";
41
- readonly int: "i32";
42
- readonly uint: "u32";
43
- readonly bool: "bool";
44
- readonly vec2: "vec2f";
45
- readonly vec3: "vec3f";
46
- readonly vec4: "vec4f";
47
- readonly mat2: "mat2x2f";
48
- readonly mat3: "mat3x3f";
49
- readonly mat4: "mat4x4f";
50
- readonly ivec2: "vec2i";
51
- readonly ivec3: "vec3i";
52
- readonly ivec4: "vec4i";
53
- readonly uvec2: "vec2u";
54
- readonly uvec3: "vec3u";
55
- readonly uvec4: "vec4u";
56
- readonly bvec2: "vec2<bool>";
57
- readonly bvec3: "vec3<bool>";
58
- readonly bvec4: "vec4<bool>";
59
- };
60
- declare const COMPONENT_COUNT_TO_TYPE: {
61
- readonly 1: "float";
62
- readonly 2: "vec2";
63
- readonly 3: "vec3";
64
- readonly 4: "vec4";
65
- readonly 9: "mat3";
66
- readonly 16: "mat4";
67
- };
68
- declare const BUILTIN_TYPES: {
69
- readonly position: "vec4";
70
- readonly vertex_index: "uint";
71
- readonly instance_index: "uint";
72
- readonly front_facing: "bool";
73
- readonly frag_depth: "float";
74
- readonly sample_index: "uint";
75
- readonly sample_mask: "uint";
76
- readonly point_coord: "vec2";
77
- readonly positionLocal: "vec3";
78
- readonly positionWorld: "vec3";
79
- readonly positionView: "vec3";
80
- readonly normalLocal: "vec3";
81
- readonly normalWorld: "vec3";
82
- readonly normalView: "vec3";
83
- readonly screenCoordinate: "vec2";
84
- readonly screenUV: "vec2";
85
- readonly gl_FragCoord: "vec4";
86
- readonly gl_VertexID: "uint";
87
- readonly gl_InstanceID: "uint";
88
- readonly gl_FrontFacing: "bool";
89
- readonly gl_FragDepth: "float";
90
- readonly gl_SampleID: "uint";
91
- readonly gl_SampleMask: "uint";
92
- readonly gl_PointCoord: "vec2";
93
- readonly normal: "vec3";
94
- readonly uv: "vec2";
95
- readonly color: "vec4";
96
- };
97
- declare const COMPARISON_OPERATORS: readonly ["equal", "notEqual", "lessThan", "lessThanEqual", "greaterThan", "greaterThanEqual"];
98
- declare const LOGICAL_OPERATORS: readonly ["and", "or"];
99
- declare const WGSL_TO_GLSL_BUILTIN: {
100
- readonly position: "gl_FragCoord";
101
- readonly vertex_index: "gl_VertexID";
102
- readonly instance_index: "gl_InstanceID";
103
- readonly front_facing: "gl_FrontFacing";
104
- readonly frag_depth: "gl_FragDepth";
105
- readonly sample_index: "gl_SampleID";
106
- readonly sample_mask: "gl_SampleMask";
107
- readonly point_coord: "gl_PointCoord";
108
- readonly uv: "gl_FragCoord.xy";
109
- };
110
30
 
111
31
  type Constants = (typeof CONSTANTS)[number] | 'void';
112
32
  type Conversions = (typeof CONVERSIONS)[number];
@@ -120,25 +40,48 @@ interface FnLayout {
120
40
  type: Constants;
121
41
  }>;
122
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';
123
47
  interface NodeProps {
124
48
  id?: string;
125
49
  args?: X[];
126
50
  type?: string;
127
51
  children?: X[];
128
- inferFrom?: X;
52
+ inferFrom?: X[];
129
53
  layout?: FnLayout;
54
+ parent?: NodeProxy;
130
55
  }
131
- interface NodeConfig {
56
+ interface NodeContext {
57
+ isFrag?: boolean;
132
58
  isWebGL?: boolean;
133
59
  binding?: number;
134
60
  infers?: WeakMap<NodeProxy, Constants>;
135
- headers?: Map<string, string>;
136
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>;
137
68
  }
69
+ /**
70
+ * NodeProxy
71
+ */
138
72
  type _Swizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
139
73
  type Swizzles = _Swizzles<'x' | 'y' | 'z' | 'w'> | _Swizzles<'r' | 'g' | 'b' | 'a'> | _Swizzles<'p' | 'q'> | _Swizzles<'s' | 't'>;
140
- type NodeTypes = 'attribute' | 'uniform' | 'varying' | 'constant' | 'variable' | 'swizzle' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare';
141
- interface NodeProxy extends Record<Swizzles, NodeProxy> {
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;
142
85
  add(n: X): NodeProxy;
143
86
  sub(n: X): NodeProxy;
144
87
  mul(n: X): NodeProxy;
@@ -153,8 +96,26 @@ interface NodeProxy extends Record<Swizzles, NodeProxy> {
153
96
  and(n: X): NodeProxy;
154
97
  or(n: X): NodeProxy;
155
98
  not(): NodeProxy;
156
- assign(n: X): NodeProxy;
157
- toVar(name?: string): 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;
158
119
  abs(): NodeProxy;
159
120
  sin(): NodeProxy;
160
121
  cos(): NodeProxy;
@@ -199,53 +160,28 @@ interface NodeProxy extends Record<Swizzles, NodeProxy> {
199
160
  dFdx(): NodeProxy;
200
161
  dFdy(): NodeProxy;
201
162
  fwidth(): NodeProxy;
202
- toBool(): NodeProxy;
203
- toUint(): NodeProxy;
204
- toInt(): NodeProxy;
205
- toFloat(): NodeProxy;
206
- toBvec2(): NodeProxy;
207
- toIvec2(): NodeProxy;
208
- toUvec2(): NodeProxy;
209
- toVec2(): NodeProxy;
210
- toBvec3(): NodeProxy;
211
- toIvec3(): NodeProxy;
212
- toUvec3(): NodeProxy;
213
- toVec3(): NodeProxy;
214
- toBvec4(): NodeProxy;
215
- toIvec4(): NodeProxy;
216
- toUvec4(): NodeProxy;
217
- toVec4(): NodeProxy;
218
- toColor(): NodeProxy;
219
- toMat2(): NodeProxy;
220
- toMat3(): NodeProxy;
221
- toMat4(): NodeProxy;
222
- toString(c?: NodeConfig): string;
223
- type: NodeTypes;
224
- props: NodeProps;
225
- isProxy: true;
226
163
  }
164
+ type NodeProxy = BaseNodeProxy & DynamicProperties;
227
165
  type X = NodeProxy | number | string | boolean | undefined;
228
166
 
229
- declare const code: (target: X, c?: NodeConfig | null) => string;
230
-
231
- declare const inferImpl: (target: NodeProxy, c: NodeConfig) => Constants;
232
- declare const infer: (target: X, c?: NodeConfig | null) => Constants;
167
+ declare const code: (target: X, c?: NodeContext | null) => string;
233
168
 
234
169
  declare const node: (type: NodeTypes, props?: NodeProps | null, ...args: X[]) => NodeProxy;
235
170
  declare const attribute: (x: X, id?: string) => NodeProxy;
236
- declare const uniform: (x: X, id?: string) => NodeProxy;
237
- declare const varying: (x: X, id?: string) => NodeProxy;
238
171
  declare const constant: (x: X, id?: string) => NodeProxy;
239
- declare const variable: (id: string) => NodeProxy;
240
- declare const builtin: (id: string) => NodeProxy;
241
- declare const swizzle: (key: Swizzles, arg: X) => NodeProxy;
242
- declare const operator: (key: Operators, ...args: X[]) => NodeProxy;
243
- declare const function_: (key: Functions, ...args: X[]) => NodeProxy;
244
- declare const conversion: (key: string, ...args: X[]) => 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;
245
180
  declare const select: (x: X, y: X, z: X) => NodeProxy;
246
181
 
247
182
  declare const toVar: (x: X, id?: string) => NodeProxy;
248
183
  declare const assign: (x: X, y: X) => X;
184
+ declare const Return: (x: X) => NodeProxy;
249
185
  declare const If: (x: X, fun: () => void) => {
250
186
  ElseIf: (_x: X, _fun: () => void) => /*elided*/ any;
251
187
  Else: (_fun: () => void) => void;
@@ -267,17 +203,17 @@ declare const isOperator: (key: unknown) => key is Operators;
267
203
  declare const isFunction: (key: unknown) => key is Functions;
268
204
  declare const isConversion: (key: unknown) => key is Conversions;
269
205
  declare const isNodeProxy: (x: unknown) => x is NodeProxy;
206
+ declare const isConstantsType: (type?: Constants | "auto") => type is Constants;
270
207
  declare const hex2rgb: (hex: number) => number[];
271
208
  declare const getId: () => string;
272
- declare const joins: (children: X[], c: NodeConfig) => string;
273
- declare const formatConversions: (x: X, c?: NodeConfig) => string;
274
- declare const getOperator: (op: X) => "/" | "+" | "-" | "*" | "%" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "&&" | "||" | "&" | "|" | "^" | "<<" | ">>";
209
+ declare const joins: (children: X[], c: NodeContext) => string;
210
+ declare const formatConversions: (x: X, c?: NodeContext) => string;
211
+ declare const getOperator: (op: X) => "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "&&" | "||" | "&" | "|" | "^" | "<<" | ">>";
275
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";
276
213
  declare const conversionToConstant: (conversionKey: string) => Constants;
277
- declare const generateDefine: (props: NodeProps, c: NodeConfig) => string;
278
- declare const fragment: (x: X, c?: NodeConfig) => string;
279
- declare const vertex: (x: X, c: NodeConfig) => string;
280
214
 
215
+ declare const vertex: (x: X, c: NodeContext) => string;
216
+ declare const fragment: (x: X, c: NodeContext) => string;
281
217
  declare const position: NodeProxy;
282
218
  declare const vertexIndex: NodeProxy;
283
219
  declare const instanceIndex: NodeProxy;
@@ -313,10 +249,13 @@ declare const uvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
313
249
  declare const bvec2: (x?: X, y?: X) => NodeProxy;
314
250
  declare const bvec3: (x?: X, y?: X, z?: X) => NodeProxy;
315
251
  declare const bvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
252
+ declare const texture2D: () => NodeProxy;
253
+ declare const sampler2D: () => NodeProxy;
316
254
  declare const color: (r?: X, g?: X, b?: X) => NodeProxy;
317
255
  declare const iResolution: NodeProxy;
318
256
  declare const iMouse: NodeProxy;
319
257
  declare const iTime: NodeProxy;
258
+ declare const uv: () => NodeProxy;
320
259
  declare const texture: (x: X, y: X, z?: X) => NodeProxy;
321
260
  declare const cubeTexture: (x: X, y: X, z?: X) => NodeProxy;
322
261
  declare const textureSize: (x: X, y?: X) => NodeProxy;
@@ -376,32 +315,42 @@ declare const tan: (x: X) => NodeProxy;
376
315
  declare const transformDirection: (dir: X, matrix: X) => NodeProxy;
377
316
  declare const trunc: (x: X) => NodeProxy;
378
317
 
379
- type GPUContext = any;
380
- type GPUDevice = any;
381
- type GPUBuffer = any;
382
- type GPUPipeline = any;
383
- type GPUBindGroup = any;
384
- type Uniform = number | number[];
385
- type Attribute = number[];
386
- type Attributes = Record<string, Attribute>;
387
- type Uniforms = Record<string, Uniform>;
388
318
  type PrecisionMode = 'highp' | 'mediump' | 'lowp';
389
319
  type GLClearMode = 'COLOR_BUFFER_BIT' | 'DEPTH_BUFFER_BIT' | 'STENCIL_BUFFER_BIT';
390
320
  type GLDrawType = 'UNSIGNED_BYTE' | 'UNSIGNED_SHORT' | 'UNSIGNED_INT';
391
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
+ }
392
340
  interface WebGLState {
393
341
  context: WebGLRenderingContext;
394
342
  program: WebGLProgram;
395
343
  }
396
344
  interface WebGPUState {
397
345
  device: GPUDevice;
398
- context: GPUContext;
399
- pipeline: GPUPipeline;
400
- groups: any[];
401
- resources: any[];
402
- loadingImg: number;
403
- needsUpdate: boolean;
346
+ uniforms: Nested<UniformData>;
347
+ textures: Nested<TextureData>;
348
+ attribs: Nested<AttribData>;
404
349
  }
350
+ type Uniform = number | number[];
351
+ type Attribute = number[];
352
+ type Attributes = Record<string, Attribute>;
353
+ type Uniforms = Record<string, Uniform>;
405
354
  type GL = EventState<{
406
355
  /**
407
356
  * initial value
@@ -445,6 +394,7 @@ type GL = EventState<{
445
394
  */
446
395
  _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
447
396
  uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
397
+ uniform(node: NodeProxy): GL;
448
398
  uniform(target: {
449
399
  [key: string]: Uniform;
450
400
  }): GL;
@@ -492,53 +442,57 @@ declare const fig: (x?: number) => number;
492
442
  declare const dig: (x?: number) => number;
493
443
  declare const sig: (value?: number, digit?: number) => number;
494
444
 
495
- declare const createDevice: (c: GPUContext) => Promise<{
496
- device: any;
497
- format: any;
445
+ /**
446
+ * initialize
447
+ */
448
+ declare const createDevice: (c: GPUCanvasContext) => Promise<{
449
+ device: GPUDevice;
450
+ format: GPUTextureFormat;
498
451
  }>;
499
- declare const createPipeline: (device: GPUDevice, format: string, bufferLayouts: any[], bindGroupLayouts: any[], vs?: string | NodeProxy, fs?: string | NodeProxy) => GPUPipeline;
500
- declare const createBindGroup: (device: GPUDevice, resources: any[]) => {
501
- layout: any;
502
- bindGroup: any;
503
- };
504
- declare const createDescriptor: (c: GPUContext) => {
505
- colorAttachments: {
506
- view: any;
507
- clearValue: {
508
- r: number;
509
- g: number;
510
- b: number;
511
- a: number;
512
- };
513
- loadOp: string;
514
- storeOp: string;
515
- }[];
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
+ };
516
464
  };
517
- declare const alignTo256: (size: number) => number;
518
- declare const createVertexBuffer: (device: GPUDevice, value: number[]) => {
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[]) => {
519
470
  array: Float32Array<ArrayBuffer>;
520
- buffer: any;
471
+ buffer: GPUBuffer;
521
472
  };
522
- declare const createUniformBuffer: (device: GPUDevice, value: number[]) => {
473
+ declare const createAttribBuffer: (device: GPUDevice, value: number[]) => {
523
474
  array: Float32Array<ArrayBuffer>;
524
- buffer: Buffer;
475
+ buffer: GPUBuffer;
525
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;
526
485
  declare const createTextureSampler: (device: GPUDevice, width?: number, height?: number) => {
527
- texture: any;
528
- sampler: any;
486
+ texture: GPUTexture;
487
+ sampler: GPUSampler;
529
488
  };
530
- declare const createBufferLayout: (shaderLocation: number, dataLength: number, count?: number) => {
531
- arrayStride: number;
532
- attributes: {
533
- shaderLocation: number;
534
- offset: number;
535
- format: string;
536
- }[];
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[];
537
493
  };
538
494
 
539
- declare const defaultVertexGLSL = "\n#version 300 es\nvoid main() {\n float x = float(gl_VertexID % 2) * 4.0 - 1.0;\n float y = float(gl_VertexID / 2) * 4.0 - 1.0;\n gl_Position = vec4(x, y, 0.0, 1.0);\n}\n";
540
- declare const defaultFragmentGLSL = "\n#version 300 es\nprecision mediump float;\nuniform vec2 iResolution;\nout vec4 fragColor;\nvoid main() {\n fragColor = vec4(fract(gl_FragCoord.xy / iResolution), 0, 1);\n}\n";
541
- declare const createProgram: (c: WebGLRenderingContext, vs?: string | NodeProxy, fs?: string | NodeProxy, onError?: () => void) => void | WebGLProgram;
495
+ declare const createProgram: (c: WebGLRenderingContext, vs: X, fs: string | X, onError?: () => void, gl?: any) => void | WebGLProgram;
542
496
  declare const createVbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
543
497
  declare const createIbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
544
498
  declare const getStride: (count: number, value: number[], iboValue?: number[]) => number;
@@ -546,17 +500,18 @@ declare const createAttrib: (c: WebGLRenderingContext, stride: number, loc: any,
546
500
  declare const createTexture: (c: WebGLRenderingContext, img: HTMLImageElement, loc: any, unit: number) => void;
547
501
 
548
502
  declare const webgl: (gl: Partial<GL>) => Promise<{
549
- webgl: WebGLState;
550
503
  render: () => void;
551
504
  clean: () => void;
552
505
  _attribute: (key: string | undefined, value: number[], iboValue: number[]) => void;
553
506
  _uniform: (key: string, value: number | number[]) => void;
554
507
  _texture: (key: string, src: string) => void;
508
+ webgl: WebGLState;
555
509
  }>;
556
510
 
557
511
  declare const webgpu: (gl: Partial<GL>) => Promise<{
558
512
  webgpu: WebGPUState;
559
513
  render: () => void;
514
+ resize: () => void;
560
515
  clean: () => void;
561
516
  _attribute: (key: string | undefined, value: number[]) => void;
562
517
  _uniform: (key: string, value: number | number[]) => void;
@@ -597,6 +552,7 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
597
552
  mousemove(e: Event): void;
598
553
  _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
599
554
  uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
555
+ uniform(node: NodeProxy): GL;
600
556
  uniform(target: {
601
557
  [key: string]: Uniform;
602
558
  }): GL;
@@ -612,4 +568,4 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
612
568
  }): GL;
613
569
  }, any[] | unknown[]>;
614
570
 
615
- export { ADDITIONAL_FUNCTIONS, type Attribute, type Attributes, BOOL_RETURN_FUNCTIONS, BUILTIN_TYPES, COMPARISON_OPERATORS, COMPONENT_COUNT_TO_TYPE, CONSTANTS, CONVERSIONS, type Constants, type Conversions, FIRST_ARG_TYPE_FUNCTIONS, FUNCTIONS, Fn, type FnLayout, type Functions, type GL, type GLClearMode, type GLDrawMode, type GLDrawType, type GPUBindGroup, type GPUBuffer, type GPUContext, type GPUDevice, type GPUPipeline, HIGHEST_TYPE_FUNCTIONS, If, LOGICAL_OPERATORS, Loop, type NodeConfig, type NodeProps, type NodeProxy, type NodeTypes, OPERATORS, OPERATOR_KEYS, type Operators, PRESERVE_TYPE_FUNCTIONS, type PrecisionMode, SCALAR_RETURN_FUNCTIONS, SWIZZLES, Switch, type Swizzles, TYPE_MAPPING, type Uniform, type Uniforms, VEC3_RETURN_FUNCTIONS, VEC4_RETURN_FUNCTIONS, WGSL_TO_GLSL_BUILTIN, type WebGLState, type WebGPUState, type X, abs, acos, alignTo256, all, any, asin, assign, atan, atan2, attribute, bitcast, bool, builtin, bvec2, bvec3, bvec4, cbrt, ceil, clamp, code, color, constant, conversion, conversionToConstant, cos, createAttrib, createBindGroup, createBufferLayout, createDescriptor, createDevice, createGL, createIbo, createPipeline, createProgram, createTexture, createTextureSampler, createUniformBuffer, createVbo, createVertexBuffer, cross, cubeTexture, dFdx, dFdy, createGL as default, defaultFragmentGLSL, defaultVertexGLSL, degrees, difference, dig, distance, dot, each, equals, exp, exp2, ext, faceforward, fig, float, floor, flush, formatConversions, fract, fragDepth, fragment, frontFacing, function_, fwidth, generateDefine, getBluiltin, getId, getOperator, getStride, hex2rgb, iMouse, iResolution, iTime, infer, inferImpl, instanceIndex, int, inverseSqrt, is, 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, saturate, screenCoordinate, screenUV, select, sig, sign, sin, smoothstep, sqrt, step, swizzle, tan, texture, textureSize, toVar, transformDirection, trunc, uint, uniform, uvec2, uvec3, uvec4, variable, varying, vec2, vec3, vec4, vertex, vertexIndex, webgl, webgpu };
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 };