glre 0.25.0 → 0.27.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/README.md CHANGED
@@ -115,7 +115,7 @@ npm install glre
115
115
  ```ts
116
116
  import { createRoot } from 'react-dom/client'
117
117
  import { useGL, vec4, fract, fragCoord, iResolution } from 'glre/react'
118
- const frag = vec4(fract(fragCoord.xy / iResolution), 0, 1)
118
+ const frag = vec4(fract(fragCoord.xy.div(iResolution)), 0, 1)
119
119
 
120
120
  const App = () => {
121
121
  const gl = useGL({ frag })
@@ -136,11 +136,11 @@ react-native supported ([codesandbox demo](https://codesandbox.io/p/sandbox/glre
136
136
  import { GLView } from 'expo-gl'
137
137
  import { registerRootComponent } from 'expo'
138
138
  import { useGL, vec4, fract, fragCoord, iResolution } from 'glre/native'
139
- const frag = vec4(fract(fragCoord.xy / iResolution), 0, 1)
139
+ const frag = vec4(fract(fragCoord.xy.div(iResolution)), 0, 1)
140
140
 
141
141
  const App = () => {
142
- const { gl, ref } = useGL({ frag })
143
- return <GLView style={{ flex: 1 }} onContextCreate={ref} />
142
+ const gl = useGL({ frag })
143
+ return <GLView style={{ flex: 1 }} onContextCreate={gl.ref} />
144
144
  }
145
145
 
146
146
  registerRootComponent(App)
@@ -157,7 +157,7 @@ solid js supported ([codesandbox demo](https://codesandbox.io/p/sandbox/glre-sol
157
157
  ```ts
158
158
  import { render } from 'solid-js/web'
159
159
  import { onGL, vec4, fract, fragCoord, iResolution } from 'glre/solid'
160
- const frag = vec4(fract(fragCoord.xy / iResolution), 0, 1)
160
+ const frag = c4(fract(fragCoord.xy.div(iResolution)), 0, 1)
161
161
 
162
162
  const App = () => {
163
163
  const gl = onGL({ frag })
@@ -177,8 +177,9 @@ esm supported ([codesandbox demo](https://codesandbox.io/s/glre-basic-demo3-3bhr
177
177
 
178
178
  ```html
179
179
  <script type="module">
180
- import { createGL, vec4, fract, fragCoord, iResolution } from 'https://esm.sh/glre'
181
- const frag = vec4(fract(fragCoord.xy / iResolution), 0, 1)
180
+ import createGL from 'https://esm.sh/glre'
181
+ import { vec4, fract, fragCoord, iResolution } from 'https://esm.sh/glre'
182
+ const frag = vec4(fract(fragCoord.xy.div(iResolution)), 0, 1)
182
183
  function App() {
183
184
  const el = document.createElement('canvas')
184
185
  createGL({ el, frag }).mount()
@@ -207,7 +208,7 @@ The node system provides various types and functions that mirror GLSL functional
207
208
  import { float, int, vec2, vec3, vec4, mat3, mat4 } from 'glre'
208
209
 
209
210
  // Built-in variables
210
- import { fragCoord, gl_Position, iResolution, iTime } from 'glre'
211
+ import { fragCoord, position, iResolution, iTime } from 'glre'
211
212
 
212
213
  // Math functions
213
214
  import { sin, cos, abs, pow, mix, clamp, normalize } from 'glre'
package/dist/index.d.ts CHANGED
@@ -3,142 +3,200 @@ import { Queue, Frame } from 'refr';
3
3
  export { Frame, Fun, Queue } from 'refr';
4
4
  import { EventState } from 'reev';
5
5
 
6
- declare const TYPES: readonly ["float", "int", "uint", "bool", "color", "vec2", "vec3", "vec4", "mat2", "mat3", "mat4", "ivec2", "ivec3", "ivec4", "uvec2", "uvec3", "uvec4", "bvec2", "bvec3", "bvec4"];
7
- type NodeType = (typeof TYPES)[number];
8
6
  declare const SWIZZLES: readonly ["x", "y", "z", "w", "r", "g", "b", "a", "s", "t", "p", "q"];
9
- type AllSwizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
10
- type Swillzes = AllSwizzles<'x' | 'y' | 'z' | 'w'> | AllSwizzles<'r' | 'g' | 'b' | 'a'> | AllSwizzles<'p' | 'q'> | AllSwizzles<'s' | 't'>;
11
- 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"];
12
- type Operator = (typeof OPERATORS)[number];
7
+ declare const NODE_TYPES: readonly ["float", "int", "uint", "bool", "color", "vec2", "vec3", "vec4", "mat2", "mat3", "mat4", "ivec2", "ivec3", "ivec4", "uvec2", "uvec3", "uvec4", "bvec2", "bvec3", "bvec4"];
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)[];
13
29
  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"];
14
- type MathFunction = (typeof FUNCTIONS)[number];
15
- declare const CACHE_BOOLS: readonly [true, false];
16
- declare const CACHE_INTS: readonly [0, 1, 2, 3, 4, 5];
17
- declare const CACHE_FLOATS: readonly [0, 1, 0.5, 2];
18
-
19
- interface Node {
20
- id: string;
21
- type: NodeType;
22
- value?: any;
23
- property?: string;
24
- parent?: Node;
25
- children?: Node[];
26
- operator?: Operator;
27
- mathFunction?: MathFunction;
28
- }
29
- interface ProxyCallback {
30
- path: string[];
31
- args: any[];
32
- }
33
- type NodeCreator = (value?: any) => X;
34
- interface OperatorMethods {
35
- add(x: X | number): X;
36
- sub(x: X | number): X;
37
- mul(x: X | number): X;
38
- div(x: X | number): X;
39
- mod(x: X | number): X;
40
- equal(x: X | number): X;
41
- notEqual(x: X | number): X;
42
- lessThan(x: X | number): X;
43
- lessThanEqual(x: X | number): X;
44
- greaterThan(x: X | number): X;
45
- greaterThanEqual(x: X | number): X;
46
- and(x: X): X;
47
- or(x: X): X;
48
- not(): X;
49
- }
50
- interface MathMethods {
51
- abs(): X;
52
- acos(): X;
53
- asin(): X;
54
- atan(): X;
55
- ceil(): X;
56
- cos(): X;
57
- floor(): X;
58
- fract(): X;
59
- length(): X;
60
- normalize(): X;
61
- sin(): X;
62
- sqrt(): X;
63
- tan(): X;
64
- toVar(): X;
65
- }
66
- type SwizzleProperties = {
67
- [k in Swillzes]: X;
30
+ declare const TYPE_MAPPING: {
31
+ readonly float: "f32";
32
+ readonly int: "i32";
33
+ readonly uint: "u32";
34
+ readonly bool: "bool";
35
+ readonly vec2: "vec2f";
36
+ readonly vec3: "vec3f";
37
+ readonly vec4: "vec4f";
38
+ readonly mat2: "mat2x2f";
39
+ readonly mat3: "mat3x3f";
40
+ readonly mat4: "mat4x4f";
41
+ readonly ivec2: "vec2i";
42
+ readonly ivec3: "vec3i";
43
+ readonly ivec4: "vec4i";
44
+ readonly uvec2: "vec2u";
45
+ readonly uvec3: "vec3u";
46
+ readonly uvec4: "vec4u";
47
+ readonly bvec2: "vec2<bool>";
48
+ readonly bvec3: "vec3<bool>";
49
+ readonly bvec4: "vec4<bool>";
68
50
  };
69
- interface X extends MathMethods, OperatorMethods, SwizzleProperties {
70
- readonly id: string;
71
- readonly type: NodeType;
72
- readonly value: any;
73
- readonly property: string;
74
- (...args: any[]): X;
75
- }
76
- interface UniformNode extends X {
77
- set(value: any): void;
78
- onObjectUpdate(callback: (context: any) => any): UniformNode;
79
- onRenderUpdate(callback: (context: any) => any): UniformNode;
80
- }
81
- interface FunctionNode {
82
- (...args: any[]): X;
83
- call(x: X[]): X;
51
+
52
+ type NodeType = (typeof NODE_TYPES)[number];
53
+ type Functions = (typeof FUNCTIONS)[number];
54
+ type Operators = (typeof OPERATOR_KEYS)[number];
55
+ interface NodeProps {
56
+ id?: string;
57
+ children?: X[];
58
+ defaultValue?: number | number[];
84
59
  }
85
- interface ConditionalNode {
86
- ElseIf(condition: X, callback: () => void): ConditionalNode;
87
- Else(callback: () => void): void;
60
+ interface NodeConfig {
61
+ isWebGL?: boolean;
62
+ uniforms?: Set<string>;
63
+ onUniform?: (name: string, value: any) => void;
88
64
  }
89
- interface ConversionContext {
90
- target: 'webgl' | 'webgpu';
91
- nodes: Map<string, Node>;
92
- variables: Map<string, string>;
93
- functions: Map<string, string>;
65
+ type _Swizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
66
+ type Swizzles = _Swizzles<'x' | 'y' | 'z' | 'w'> | _Swizzles<'r' | 'g' | 'b' | 'a'> | _Swizzles<'p' | 'q'> | _Swizzles<'s' | 't'>;
67
+ type NodeTypes = 'uniform' | 'variable' | 'swizzle' | 'operator' | 'node_type' | 'math_fun' | 'declare' | 'assign' | 'fn' | 'if' | 'loop' | 'scope';
68
+ interface NodeProxy extends Record<Swizzles, NodeProxy> {
69
+ add(n: X): NodeProxy;
70
+ sub(n: X): NodeProxy;
71
+ mul(n: X): NodeProxy;
72
+ div(n: X): NodeProxy;
73
+ mod(n: X): NodeProxy;
74
+ equal(n: X): NodeProxy;
75
+ notEqual(n: X): NodeProxy;
76
+ lessThan(n: X): NodeProxy;
77
+ lessThanEqual(n: X): NodeProxy;
78
+ greaterThan(n: X): NodeProxy;
79
+ greaterThanEqual(n: X): NodeProxy;
80
+ and(n: X): NodeProxy;
81
+ or(n: X): NodeProxy;
82
+ not(): NodeProxy;
83
+ assign(n: X): NodeProxy;
84
+ toVar(name?: string): NodeProxy;
85
+ toString(c?: NodeConfig): string;
86
+ type: NodeTypes;
87
+ props: NodeProps;
88
+ isProxy: true;
94
89
  }
90
+ type X = NodeProxy | number | string | null | undefined;
95
91
 
96
- declare const getCachedBool: (x: boolean) => X;
97
- declare const getCachedInt: (x: number) => X;
98
- declare const getCachedFloat: (x: number) => X;
99
- declare const findDuplicateNodes: (nodes: X[]) => Map<string, X[]>;
92
+ declare const code: (target: X, c?: NodeConfig | null) => string;
100
93
 
101
- declare const convertToNode: (x: unknown) => X;
102
- declare const float: (x: unknown) => X;
103
- declare const int: (x: unknown) => X;
104
- declare const bool: (x: unknown) => X;
105
- declare const vec2: (x?: any, y?: any) => X;
106
- declare const vec3: (x?: any, y?: any, z?: any) => X;
107
- declare const vec4: (x?: any, y?: any, z?: any, w?: any) => X;
108
- declare const color: (r?: any, g?: any, b?: any) => X;
94
+ declare const node: (type: NodeTypes, props?: NodeProps | null, ...args: X[]) => NodeProxy;
95
+ declare const v: (...args: X[]) => NodeProxy;
96
+ declare const u: (key: string, defaultValue?: number | number[]) => NodeProxy;
97
+ declare const s: (key: Swizzles, arg: X) => NodeProxy;
98
+ declare const n: (key: string, ...args: X[]) => NodeProxy;
99
+ declare const o: (key: Operators, ...args: X[]) => NodeProxy;
100
+ declare const f: (key: Functions, ...args: X[]) => NodeProxy;
109
101
 
110
- declare const createNode: (type: NodeType, value?: any, options?: Partial<Node>) => Node;
111
- declare const node: (type: NodeType, value?: any, options?: Partial<Node>) => X;
102
+ declare const If: (x: X, callback: () => void) => {
103
+ ElseIf: (y: X, elseCallback: () => void) => void;
104
+ Else: (elseCallback: () => void) => void;
105
+ };
106
+ declare const Loop: (x: X, callback?: (params: {
107
+ i: NodeProxy;
108
+ }) => void) => NodeProxy;
109
+ declare const Fn: (callback: (args: X[]) => NodeProxy) => (...args: X[]) => NodeProxy;
110
+ declare const toVar: (x: X) => (id: string) => NodeProxy;
111
+ declare const assign: (x: X) => (y: X) => X;
112
112
 
113
- interface UpdateContext {
114
- object?: any;
115
- camera?: any;
116
- renderer?: any;
117
- scene?: any;
118
- time?: number;
119
- }
120
- declare const uniform: (initialValue: any) => UniformNode;
121
- declare const iPrevTime: UniformNode;
122
- declare const iDeltaTime: UniformNode;
123
- declare const updateUniforms: (context: UpdateContext) => void;
113
+ declare const isSwizzle: (key: unknown) => key is Swizzles;
114
+ declare const isOperator: (key: unknown) => key is Operators;
115
+ declare const isNodeType: (key: unknown) => key is NodeType;
116
+ declare const isFunction: (key: unknown) => key is Functions;
117
+ declare const getId: () => string;
118
+ declare const joins: (children: X[], c: NodeConfig) => string;
119
+ declare const inferType: (target: X, c: NodeConfig) => string;
120
+ declare const fragment: (x: X, c: NodeConfig) => string;
121
+ declare const vertex: (x: X, c: NodeConfig) => string;
124
122
 
125
- declare const Fn: (jsFunc: Function) => FunctionNode;
126
- declare const If: (condition: X, callback: () => void) => ConditionalNode;
127
- declare const fragCoord: X;
128
- declare const position: X;
129
- declare const iTime: UniformNode;
130
- declare const iResolution: UniformNode;
131
- declare const iMouse: UniformNode;
132
- declare const abs: (x: X) => X;
133
- declare const sin: (x: X) => X;
134
- declare const cos: (x: X) => X;
135
- declare const tan: (x: X) => X;
136
- declare const sqrt: (x: X) => X;
137
- declare const floor: (x: X) => X;
138
- declare const ceil: (x: X) => X;
139
- declare const fract: (x: X) => X;
140
- declare const normalize: (x: X) => X;
141
- declare const length: (x: X) => X;
123
+ declare const iResolution: NodeProxy;
124
+ declare const iMouse: NodeProxy;
125
+ declare const iTime: NodeProxy;
126
+ declare const fragCoord: NodeProxy;
127
+ declare const float: (x: X) => NodeProxy;
128
+ declare const int: (x: X) => NodeProxy;
129
+ declare const uint: (x: X) => NodeProxy;
130
+ declare const bool: (x: X) => NodeProxy;
131
+ declare const vec2: (x?: X, y?: X) => NodeProxy;
132
+ declare const vec3: (x?: X, y?: X, z?: X) => NodeProxy;
133
+ declare const vec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
134
+ declare const mat2: (...args: X[]) => NodeProxy;
135
+ declare const mat3: (...args: X[]) => NodeProxy;
136
+ declare const mat4: (...args: X[]) => NodeProxy;
137
+ declare const ivec2: (x?: X, y?: X) => NodeProxy;
138
+ declare const ivec3: (x?: X, y?: X, z?: X) => NodeProxy;
139
+ declare const ivec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
140
+ declare const uvec2: (x?: X, y?: X) => NodeProxy;
141
+ declare const uvec3: (x?: X, y?: X, z?: X) => NodeProxy;
142
+ declare const uvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
143
+ declare const bvec2: (x?: X, y?: X) => NodeProxy;
144
+ declare const bvec3: (x?: X, y?: X, z?: X) => NodeProxy;
145
+ declare const bvec4: (x?: X, y?: X, z?: X, w?: X) => NodeProxy;
146
+ declare const abs: (x: X) => NodeProxy;
147
+ declare const acos: (x: X) => NodeProxy;
148
+ declare const all: (x: X) => NodeProxy;
149
+ declare const any: (x: X) => NodeProxy;
150
+ declare const asin: (x: X) => NodeProxy;
151
+ declare const atan: (y: X, x: X) => NodeProxy;
152
+ declare const bitcast: (x: X, y: X) => NodeProxy;
153
+ declare const cbrt: (x: X) => NodeProxy;
154
+ declare const ceil: (x: X) => NodeProxy;
155
+ declare const clamp: (x: X, min: X, max: X) => NodeProxy;
156
+ declare const cos: (x: X) => NodeProxy;
157
+ declare const cross: (x: X, y: X) => NodeProxy;
158
+ declare const dFdx: (p: X) => NodeProxy;
159
+ declare const dFdy: (p: X) => NodeProxy;
160
+ declare const degrees: (radians: X) => NodeProxy;
161
+ declare const difference: (x: X, y: X) => NodeProxy;
162
+ declare const distance: (x: X, y: X) => NodeProxy;
163
+ declare const dot: (x: X, y: X) => NodeProxy;
164
+ declare const equals: (x: X, y: X) => NodeProxy;
165
+ declare const exp: (x: X) => NodeProxy;
166
+ declare const exp2: (x: X) => NodeProxy;
167
+ declare const faceforward: (N: X, I: X, Nref: X) => NodeProxy;
168
+ declare const floor: (x: X) => NodeProxy;
169
+ declare const fract: (x: X) => NodeProxy;
170
+ declare const fwidth: (x: X) => NodeProxy;
171
+ declare const inverseSqrt: (x: X) => NodeProxy;
172
+ declare const length: (x: X) => NodeProxy;
173
+ declare const lengthSq: (x: X) => NodeProxy;
174
+ declare const log: (x: X) => NodeProxy;
175
+ declare const log2: (x: X) => NodeProxy;
176
+ declare const max: (x: X, y: X) => NodeProxy;
177
+ declare const min: (x: X, y: X) => NodeProxy;
178
+ declare const mix: (x: X, y: X, a: X) => NodeProxy;
179
+ declare const negate: (x: X) => NodeProxy;
180
+ declare const normalize: (x: X) => NodeProxy;
181
+ declare const oneMinus: (x: X) => NodeProxy;
182
+ declare const pow: (x: X, y: X) => NodeProxy;
183
+ declare const pow2: (x: X) => NodeProxy;
184
+ declare const pow3: (x: X) => NodeProxy;
185
+ declare const pow4: (x: X) => NodeProxy;
186
+ declare const radians: (degrees: X) => NodeProxy;
187
+ declare const reciprocal: (x: X) => NodeProxy;
188
+ declare const reflect: (I: X, N: X) => NodeProxy;
189
+ declare const refract: (I: X, N: X, eta: X) => NodeProxy;
190
+ declare const round: (x: X) => NodeProxy;
191
+ declare const saturate: (x: X) => NodeProxy;
192
+ declare const sign: (x: X) => NodeProxy;
193
+ declare const sin: (x: X) => NodeProxy;
194
+ declare const smoothstep: (e0: X, e1: X, x: X) => NodeProxy;
195
+ declare const sqrt: (x: X) => NodeProxy;
196
+ declare const step: (edge: X, x: X) => NodeProxy;
197
+ declare const tan: (x: X) => NodeProxy;
198
+ declare const transformDirection: (dir: X, matrix: X) => NodeProxy;
199
+ declare const trunc: (x: X) => NodeProxy;
142
200
 
143
201
  type GPUContext = any;
144
202
  type GPUDevice = any;
@@ -158,12 +216,10 @@ interface WebGLState {
158
216
  program: WebGLProgram;
159
217
  }
160
218
  interface WebGPUState {
161
- uniforms: any;
162
- textures: any;
163
219
  device: GPUDevice;
164
220
  context: GPUContext;
165
- groups: any[];
166
221
  pipeline: GPUPipeline;
222
+ groups: any[];
167
223
  resources: any[];
168
224
  loadingImg: number;
169
225
  needsUpdate: boolean;
@@ -226,26 +282,6 @@ type GL = EventState<{
226
282
  }): GL;
227
283
  }>;
228
284
 
229
- interface GLSLContext extends ConversionContext {
230
- target: 'webgl';
231
- precision: 'lowp' | 'mediump' | 'highp';
232
- version: '100' | '300 es';
233
- }
234
- declare const nodeToGLSL: (nodeProxy: X, context?: Partial<GLSLContext>) => string;
235
- declare const glsl: (fragmentNode: X, options?: {
236
- precision?: "lowp" | "mediump" | "highp";
237
- version?: "100" | "300 es";
238
- uniforms?: Record<string, any>;
239
- }) => string;
240
-
241
- interface WGSLContext extends ConversionContext {
242
- target: 'webgpu';
243
- }
244
- declare const nodeToWGSL: (nodeProxy: X, context?: Partial<WGSLContext>) => string;
245
- declare const wgsl: (fragmentNode: X, options?: {
246
- uniforms?: Record<string, any>;
247
- }) => string;
248
-
249
285
  declare const is: {
250
286
  arr: (arg: any) => arg is any[];
251
287
  bol: (a: unknown) => a is boolean;
@@ -278,12 +314,15 @@ declare const fig: (x?: number) => number;
278
314
  declare const dig: (x?: number) => number;
279
315
  declare const sig: (value?: number, digit?: number) => number;
280
316
 
281
- declare const createDevive: (c: GPUContext) => Promise<{
317
+ declare const createDevice: (c: GPUContext) => Promise<{
282
318
  device: any;
283
319
  format: any;
284
320
  }>;
285
- declare const createPipeline: (device: GPUDevice, format: string, buffers: any[], layouts: any[], vs?: string | X, fs?: string | X) => GPUPipeline;
286
- declare const createBindGroup: (device: GPUDevice, resources: any[]) => any[];
321
+ declare const createPipeline: (device: GPUDevice, format: string, bufferLayouts: any[], bindGroupLayouts: any[], vs?: string | X, fs?: string | X) => GPUPipeline;
322
+ declare const createBindGroup: (device: GPUDevice, resources: any[]) => {
323
+ layout: any;
324
+ bindGroup: any;
325
+ };
287
326
  declare const createDescriptor: (c: GPUContext) => {
288
327
  colorAttachments: {
289
328
  view: any;
@@ -298,15 +337,30 @@ declare const createDescriptor: (c: GPUContext) => {
298
337
  }[];
299
338
  };
300
339
  declare const alignTo256: (size: number) => number;
340
+ declare const createVertexBuffer: (device: GPUDevice, value: number[]) => {
341
+ array: Float32Array<ArrayBuffer>;
342
+ buffer: any;
343
+ };
301
344
  declare const createUniformBuffer: (device: GPUDevice, value: number[]) => {
302
345
  array: Float32Array<ArrayBuffer>;
303
346
  buffer: Buffer;
304
347
  };
305
- declare const createTextureSampler: (device: GPUDevice, width?: number, height?: number) => readonly [any, any];
348
+ declare const createTextureSampler: (device: GPUDevice, width?: number, height?: number) => {
349
+ texture: any;
350
+ sampler: any;
351
+ };
352
+ declare const createBufferLayout: (shaderLocation: number, dataLength: number, count?: number) => {
353
+ arrayStride: number;
354
+ attributes: {
355
+ shaderLocation: number;
356
+ offset: number;
357
+ format: string;
358
+ }[];
359
+ };
306
360
 
307
361
  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";
308
362
  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";
309
- declare const createProgram: (c: WebGLRenderingContext, vs?: string | X, fs?: string | X) => WebGLProgram;
363
+ declare const createProgram: (c: WebGLRenderingContext, vs?: string | X, fs?: string | X) => WebGLProgram | undefined;
310
364
  declare const createVbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
311
365
  declare const createIbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
312
366
  declare const getStride: (count: number, value: number[], iboValue?: number[]) => number;
@@ -319,7 +373,7 @@ declare const webgl: (gl: Partial<GL>) => Promise<{
319
373
  clean: () => void;
320
374
  _attribute: (key: string | undefined, value: number[], iboValue: number[]) => void;
321
375
  _uniform: (key: string, value: number | number[]) => void;
322
- _texture: (alt: string, src: string) => void;
376
+ _texture: (key: string, src: string) => void;
323
377
  }>;
324
378
 
325
379
  declare const webgpu: (gl: Partial<GL>) => Promise<{
@@ -380,4 +434,4 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
380
434
  }): GL;
381
435
  }, any[] | unknown[]>;
382
436
 
383
- export { Attribute, Attributes, CACHE_BOOLS, CACHE_FLOATS, CACHE_INTS, ConditionalNode, ConversionContext, FUNCTIONS, Fn, FunctionNode, GL, GLClearMode, GLDrawMode, GLDrawType, GPUBindGroup, GPUBuffer, GPUContext, GPUDevice, GPUPipeline, If, MathFunction, MathMethods, Node, NodeCreator, NodeType, OPERATORS, Operator, OperatorMethods, PrecisionMode, ProxyCallback, SWIZZLES, Swillzes, SwizzleProperties, TYPES, Uniform, UniformNode, Uniforms, WebGLState, WebGPUState, X, abs, alignTo256, bool, ceil, color, convertToNode, cos, createAttrib, createBindGroup, createDescriptor, createDevive, createGL, createIbo, createNode, createPipeline, createProgram, createTexture, createTextureSampler, createUniformBuffer, createVbo, createGL as default, defaultFragmentGLSL, defaultVertexGLSL, dig, each, ext, fig, findDuplicateNodes, float, floor, flush, fract, fragCoord, getCachedBool, getCachedFloat, getCachedInt, getStride, glsl, iDeltaTime, iMouse, iPrevTime, iResolution, iTime, int, is, isGL, isServer, isWebGPUSupported, length, node, nodeToGLSL, nodeToWGSL, normalize, position, replace, sig, sin, sqrt, tan, uniform, updateUniforms, vec2, vec3, vec4, webgl, webgpu, wgsl };
437
+ export { type Attribute, type Attributes, FUNCTIONS, Fn, type Functions, type GL, type GLClearMode, type GLDrawMode, type GLDrawType, type GPUBindGroup, type GPUBuffer, type GPUContext, type GPUDevice, type GPUPipeline, If, Loop, NODE_TYPES, type NodeConfig, type NodeProps, type NodeProxy, type NodeType, type NodeTypes, OPERATORS, OPERATOR_KEYS, type Operators, type PrecisionMode, SWIZZLES, type Swizzles, TYPE_MAPPING, type Uniform, type Uniforms, type WebGLState, type WebGPUState, type X, abs, acos, alignTo256, all, any, asin, assign, atan, bitcast, bool, bvec2, bvec3, bvec4, cbrt, ceil, clamp, code, cos, createAttrib, createBindGroup, createBufferLayout, createDescriptor, createDevice, createGL, createIbo, createPipeline, createProgram, createTexture, createTextureSampler, createUniformBuffer, createVbo, createVertexBuffer, cross, dFdx, dFdy, createGL as default, defaultFragmentGLSL, defaultVertexGLSL, degrees, difference, dig, distance, dot, each, equals, exp, exp2, ext, f, faceforward, fig, float, floor, flush, fract, fragCoord, fragment, fwidth, getId, getStride, iMouse, iResolution, iTime, inferType, int, inverseSqrt, is, isFunction, isGL, isNodeType, isOperator, isServer, isSwizzle, isWebGPUSupported, ivec2, ivec3, ivec4, joins, length, lengthSq, log, log2, mat2, mat3, mat4, max, min, mix, n, negate, node, normalize, o, oneMinus, pow, pow2, pow3, pow4, radians, reciprocal, reflect, refract, replace, round, s, saturate, sig, sign, sin, smoothstep, sqrt, step, tan, toVar, transformDirection, trunc, u, uint, uvec2, uvec3, uvec4, v, vec2, vec3, vec4, vertex, webgl, webgpu };