glre 0.30.0 → 0.31.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,358 +0,0 @@
1
- import * as refr from 'refr';
2
- import { Queue, Frame } from 'refr';
3
- import { EventState } from 'reev';
4
-
5
- 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
-
7
- type Constants = (typeof CONSTANTS)[number] | 'void';
8
- interface FnLayout {
9
- name: string;
10
- type: Constants | 'auto';
11
- inputs?: Array<{
12
- name: string;
13
- type: Constants;
14
- }>;
15
- }
16
- interface NodeProps {
17
- id?: string;
18
- args?: X[];
19
- type?: string;
20
- children?: X[];
21
- inferFrom?: X;
22
- layout?: FnLayout;
23
- }
24
- interface NodeConfig {
25
- isWebGL?: boolean;
26
- binding?: number;
27
- infers?: WeakMap<NodeProxy, Constants>;
28
- headers?: Map<string, string>;
29
- onMount?: (name: string) => void;
30
- }
31
- type _Swizzles<T extends string> = T | `${T}${T}` | `${T}${T}${T}` | `${T}${T}${T}${T}`;
32
- type Swizzles = _Swizzles<'x' | 'y' | 'z' | 'w'> | _Swizzles<'r' | 'g' | 'b' | 'a'> | _Swizzles<'p' | 'q'> | _Swizzles<'s' | 't'>;
33
- type NodeTypes = 'attribute' | 'uniform' | 'varying' | 'constant' | 'variable' | 'swizzle' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare';
34
- interface NodeProxy extends Record<Swizzles, NodeProxy> {
35
- add(n: X): NodeProxy;
36
- sub(n: X): NodeProxy;
37
- mul(n: X): NodeProxy;
38
- div(n: X): NodeProxy;
39
- mod(n: X): NodeProxy;
40
- equal(n: X): NodeProxy;
41
- notEqual(n: X): NodeProxy;
42
- lessThan(n: X): NodeProxy;
43
- lessThanEqual(n: X): NodeProxy;
44
- greaterThan(n: X): NodeProxy;
45
- greaterThanEqual(n: X): NodeProxy;
46
- and(n: X): NodeProxy;
47
- or(n: X): NodeProxy;
48
- not(): NodeProxy;
49
- assign(n: X): NodeProxy;
50
- toVar(name?: string): NodeProxy;
51
- abs(): NodeProxy;
52
- sin(): NodeProxy;
53
- cos(): NodeProxy;
54
- tan(): NodeProxy;
55
- asin(): NodeProxy;
56
- acos(): NodeProxy;
57
- atan(): NodeProxy;
58
- atan2(x: X): NodeProxy;
59
- pow(y: X): NodeProxy;
60
- pow2(): NodeProxy;
61
- pow3(): NodeProxy;
62
- pow4(): NodeProxy;
63
- sqrt(): NodeProxy;
64
- inverseSqrt(): NodeProxy;
65
- exp(): NodeProxy;
66
- exp2(): NodeProxy;
67
- log(): NodeProxy;
68
- log2(): NodeProxy;
69
- floor(): NodeProxy;
70
- ceil(): NodeProxy;
71
- round(): NodeProxy;
72
- fract(): NodeProxy;
73
- trunc(): NodeProxy;
74
- min(y: X): NodeProxy;
75
- max(y: X): NodeProxy;
76
- clamp(min: X, max: X): NodeProxy;
77
- saturate(): NodeProxy;
78
- mix(y: X, a: X): NodeProxy;
79
- step(edge: X): NodeProxy;
80
- smoothstep(edge0: X, edge1: X): NodeProxy;
81
- length(): NodeProxy;
82
- distance(y: X): NodeProxy;
83
- dot(y: X): NodeProxy;
84
- cross(y: X): NodeProxy;
85
- normalize(): NodeProxy;
86
- reflect(N: X): NodeProxy;
87
- refract(N: X, eta: X): NodeProxy;
88
- sign(): NodeProxy;
89
- oneMinus(): NodeProxy;
90
- reciprocal(): NodeProxy;
91
- negate(): NodeProxy;
92
- dFdx(): NodeProxy;
93
- dFdy(): NodeProxy;
94
- fwidth(): NodeProxy;
95
- toBool(): NodeProxy;
96
- toUint(): NodeProxy;
97
- toInt(): NodeProxy;
98
- toFloat(): NodeProxy;
99
- toBvec2(): NodeProxy;
100
- toIvec2(): NodeProxy;
101
- toUvec2(): NodeProxy;
102
- toVec2(): NodeProxy;
103
- toBvec3(): NodeProxy;
104
- toIvec3(): NodeProxy;
105
- toUvec3(): NodeProxy;
106
- toVec3(): NodeProxy;
107
- toBvec4(): NodeProxy;
108
- toIvec4(): NodeProxy;
109
- toUvec4(): NodeProxy;
110
- toVec4(): NodeProxy;
111
- toColor(): NodeProxy;
112
- toMat2(): NodeProxy;
113
- toMat3(): NodeProxy;
114
- toMat4(): NodeProxy;
115
- toString(c?: NodeConfig): string;
116
- type: NodeTypes;
117
- props: NodeProps;
118
- isProxy: true;
119
- }
120
- type X = NodeProxy | number | string | boolean | undefined;
121
-
122
- type GPUContext = any;
123
- type GPUDevice = any;
124
- type GPUBuffer = any;
125
- type GPUPipeline = any;
126
- type GPUBindGroup = any;
127
- type Uniform = number | number[];
128
- type Attribute = number[];
129
- type Attributes = Record<string, Attribute>;
130
- type Uniforms = Record<string, Uniform>;
131
- type PrecisionMode = 'highp' | 'mediump' | 'lowp';
132
- type GLClearMode = 'COLOR_BUFFER_BIT' | 'DEPTH_BUFFER_BIT' | 'STENCIL_BUFFER_BIT';
133
- type GLDrawType = 'UNSIGNED_BYTE' | 'UNSIGNED_SHORT' | 'UNSIGNED_INT';
134
- type GLDrawMode = 'POINTS' | 'LINE_STRIP' | 'LINE_LOOP' | 'LINES' | 'TRIANGLE_STRIP' | 'TRIANGLE_FAN' | 'TRIANGLES';
135
- interface WebGLState {
136
- context: WebGLRenderingContext;
137
- program: WebGLProgram;
138
- }
139
- interface WebGPUState {
140
- device: GPUDevice;
141
- context: GPUContext;
142
- pipeline: GPUPipeline;
143
- groups: any[];
144
- resources: any[];
145
- loadingImg: number;
146
- needsUpdate: boolean;
147
- }
148
- type GL = EventState<{
149
- /**
150
- * initial value
151
- */
152
- isNative: boolean;
153
- isWebGL: boolean;
154
- isLoop: boolean;
155
- isGL: true;
156
- width: number;
157
- height: number;
158
- size: [number, number];
159
- mouse: [number, number];
160
- count: number;
161
- el: HTMLCanvasElement;
162
- vs: string | NodeProxy;
163
- fs: string | NodeProxy;
164
- vert: string | NodeProxy;
165
- frag: string | NodeProxy;
166
- vertex: string | NodeProxy;
167
- fragment: string | NodeProxy;
168
- /**
169
- * core state
170
- */
171
- webgpu: WebGPUState;
172
- webgl: WebGLState;
173
- queue: Queue;
174
- frame: Frame;
175
- /**
176
- * events
177
- */
178
- ref?: any;
179
- init(): void;
180
- loop(): void;
181
- mount(): void;
182
- clean(): void;
183
- render(): void;
184
- resize(e?: Event): void;
185
- mousemove(e: Event): void;
186
- /**
187
- * setter
188
- */
189
- _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
190
- uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
191
- uniform(target: {
192
- [key: string]: Uniform;
193
- }): GL;
194
- _texture?(key: string, value: string): GL;
195
- texture(key: string, value: string): GL;
196
- texture(target: {
197
- [key: string]: string;
198
- }): GL;
199
- _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
200
- attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
201
- attribute(target: {
202
- [key: string]: Attribute;
203
- }): GL;
204
- }>;
205
-
206
- declare const is: {
207
- arr: (arg: any) => arg is any[];
208
- bol: (a: unknown) => a is boolean;
209
- str: (a: unknown) => a is string;
210
- num: (a: unknown) => a is number;
211
- int: (a: unknown) => a is number;
212
- fun: (a: unknown) => a is Function;
213
- und: (a: unknown) => a is undefined;
214
- nul: (a: unknown) => a is null;
215
- set: (a: unknown) => a is Set<unknown>;
216
- map: (a: unknown) => a is Map<unknown, unknown>;
217
- obj: (a: unknown) => a is object;
218
- nan: (a: unknown) => a is number;
219
- };
220
- /**
221
- * each
222
- */
223
- type EachFn<Value, Key, This> = (this: This, value: Value, key: Key) => void;
224
- type Eachable<Value = any, Key = any, This = any> = {
225
- forEach(cb: EachFn<Value, Key, This>, ctx?: This): void;
226
- };
227
- declare const each: <Value, Key, This>(obj: Eachable<Value, Key, This>, fn: EachFn<Value, Key, This>) => void;
228
- declare const flush: <Value extends Function, Key, This>(obj: Eachable<Value, Key, This>, ...args: any[]) => void;
229
- /**
230
- * other
231
- */
232
- declare const replace: (x?: string, from?: string, to?: string) => string;
233
- declare const ext: (src?: string) => string;
234
- declare const fig: (x?: number) => number;
235
- declare const dig: (x?: number) => number;
236
- declare const sig: (value?: number, digit?: number) => number;
237
-
238
- declare const createDevice: (c: GPUContext) => Promise<{
239
- device: any;
240
- format: any;
241
- }>;
242
- declare const createPipeline: (device: GPUDevice, format: string, bufferLayouts: any[], bindGroupLayouts: any[], vs?: string | NodeProxy, fs?: string | NodeProxy) => GPUPipeline;
243
- declare const createBindGroup: (device: GPUDevice, resources: any[]) => {
244
- layout: any;
245
- bindGroup: any;
246
- };
247
- declare const createDescriptor: (c: GPUContext) => {
248
- colorAttachments: {
249
- view: any;
250
- clearValue: {
251
- r: number;
252
- g: number;
253
- b: number;
254
- a: number;
255
- };
256
- loadOp: string;
257
- storeOp: string;
258
- }[];
259
- };
260
- declare const alignTo256: (size: number) => number;
261
- declare const createVertexBuffer: (device: GPUDevice, value: number[]) => {
262
- array: Float32Array<ArrayBuffer>;
263
- buffer: any;
264
- };
265
- declare const createUniformBuffer: (device: GPUDevice, value: number[]) => {
266
- array: Float32Array<ArrayBuffer>;
267
- buffer: Buffer;
268
- };
269
- declare const createTextureSampler: (device: GPUDevice, width?: number, height?: number) => {
270
- texture: any;
271
- sampler: any;
272
- };
273
- declare const createBufferLayout: (shaderLocation: number, dataLength: number, count?: number) => {
274
- arrayStride: number;
275
- attributes: {
276
- shaderLocation: number;
277
- offset: number;
278
- format: string;
279
- }[];
280
- };
281
-
282
- 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";
283
- 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";
284
- declare const createProgram: (c: WebGLRenderingContext, vs?: string | NodeProxy, fs?: string | NodeProxy, onError?: () => void) => void | WebGLProgram;
285
- declare const createVbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
286
- declare const createIbo: (c: WebGLRenderingContext, data: number[]) => WebGLBuffer;
287
- declare const getStride: (count: number, value: number[], iboValue?: number[]) => number;
288
- declare const createAttrib: (c: WebGLRenderingContext, stride: number, loc: any, vbo: WebGLBuffer, ibo?: WebGLBuffer) => void;
289
- declare const createTexture: (c: WebGLRenderingContext, img: HTMLImageElement, loc: any, unit: number) => void;
290
-
291
- declare const webgl: (gl: Partial<GL>) => Promise<{
292
- webgl: WebGLState;
293
- render: () => void;
294
- clean: () => void;
295
- _attribute: (key: string | undefined, value: number[], iboValue: number[]) => void;
296
- _uniform: (key: string, value: number | number[]) => void;
297
- _texture: (key: string, src: string) => void;
298
- }>;
299
-
300
- declare const webgpu: (gl: Partial<GL>) => Promise<{
301
- webgpu: WebGPUState;
302
- render: () => void;
303
- clean: () => void;
304
- _attribute: (key: string | undefined, value: number[]) => void;
305
- _uniform: (key: string, value: number | number[]) => void;
306
- _texture: (key: string, src: string) => void;
307
- }>;
308
-
309
- declare const isGL: (a: unknown) => a is EventState<GL>;
310
- declare const isServer: () => boolean;
311
- declare const isWebGPUSupported: () => boolean;
312
- declare const createGL: (props?: Partial<GL>) => EventState<{
313
- isNative: boolean;
314
- isWebGL: boolean;
315
- isLoop: boolean;
316
- isGL: true;
317
- width: number;
318
- height: number;
319
- size: [number, number];
320
- mouse: [number, number];
321
- count: number;
322
- el: HTMLCanvasElement;
323
- vs: string | NodeProxy;
324
- fs: string | NodeProxy;
325
- vert: string | NodeProxy;
326
- frag: string | NodeProxy;
327
- vertex: string | NodeProxy;
328
- fragment: string | NodeProxy;
329
- webgpu: WebGPUState;
330
- webgl: WebGLState;
331
- queue: refr.Queue;
332
- frame: refr.Frame;
333
- ref?: any;
334
- init(): void;
335
- loop(): void;
336
- mount(): void;
337
- clean(): void;
338
- render(): void;
339
- resize(e?: Event): void;
340
- mousemove(e: Event): void;
341
- _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
342
- uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
343
- uniform(target: {
344
- [key: string]: Uniform;
345
- }): GL;
346
- _texture?(key: string, value: string): GL;
347
- texture(key: string, value: string): GL;
348
- texture(target: {
349
- [key: string]: string;
350
- }): GL;
351
- _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
352
- attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
353
- attribute(target: {
354
- [key: string]: Attribute;
355
- }): GL;
356
- }, any[] | unknown[]>;
357
-
358
- export { type Attribute as A, createDescriptor as B, alignTo256 as C, createVertexBuffer as D, createUniformBuffer as E, createTextureSampler as F, type GL as G, createBufferLayout as H, defaultVertexGLSL as I, defaultFragmentGLSL as J, createProgram as K, createVbo as L, createIbo as M, type NodeProxy as N, getStride as O, type PrecisionMode as P, createAttrib as Q, createTexture as R, webgl as S, webgpu as T, type Uniform as U, type WebGPUState as W, type WebGLState as a, isServer as b, isWebGPUSupported as c, createGL as d, type GPUContext as e, type GPUDevice as f, type GPUBuffer as g, type GPUPipeline as h, isGL as i, type GPUBindGroup as j, type Attributes as k, type Uniforms as l, type GLClearMode as m, type GLDrawType as n, type GLDrawMode as o, is as p, each as q, flush as r, replace as s, ext as t, fig as u, dig as v, sig as w, createDevice as x, createPipeline as y, createBindGroup as z };