glre 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,6 @@
1
- import { fragment, isNodeProxy, vertex } from '../node'
2
- import type { NodeProxy } from '../node'
3
-
4
- export const defaultVertexGLSL = /* cpp */ `
5
- #version 300 es
6
- void main() {
7
- float x = float(gl_VertexID % 2) * 4.0 - 1.0;
8
- float y = float(gl_VertexID / 2) * 4.0 - 1.0;
9
- gl_Position = vec4(x, y, 0.0, 1.0);
10
- }
11
- `
12
-
13
- export const defaultFragmentGLSL = /* cpp */ `
14
- #version 300 es
15
- precision mediump float;
16
- uniform vec2 iResolution;
17
- out vec4 fragColor;
18
- void main() {
19
- fragColor = vec4(fract(gl_FragCoord.xy / iResolution), 0, 1);
20
- }
21
- `
1
+ import { fragment, vertex } from '../node'
2
+ import type { X } from '../node'
3
+ import { is } from './helpers'
22
4
 
23
5
  const createShader = (c: WebGLRenderingContext, source: string, type: number) => {
24
6
  const shader = c.createShader(type)
@@ -31,14 +13,10 @@ const createShader = (c: WebGLRenderingContext, source: string, type: number) =>
31
13
  console.warn(`Could not compile shader: ${error}`)
32
14
  }
33
15
 
34
- export const createProgram = (
35
- c: WebGLRenderingContext,
36
- vs: string | NodeProxy = defaultVertexGLSL,
37
- fs: string | NodeProxy = defaultFragmentGLSL,
38
- onError = () => {}
39
- ) => {
40
- if (isNodeProxy(fs)) fs = fragment(fs, { isWebGL: true })
41
- if (isNodeProxy(vs)) vs = vertex(fs, { isWebGL: true })
16
+ export const createProgram = (c: WebGLRenderingContext, vs: X, fs: string | X, onError = () => {}, gl?: any) => {
17
+ const config = { isWebGL: true, gl }
18
+ if (!is.str(fs)) fs = fragment(fs, config)
19
+ if (!is.str(vs)) vs = vertex(vs, config)
42
20
  const pg = c.createProgram()
43
21
  const _vs = createShader(c, vs, c.VERTEX_SHADER)
44
22
  const _fs = createShader(c, fs, c.FRAGMENT_SHADER)
package/src/webgl.ts CHANGED
@@ -5,13 +5,12 @@ import type { GL, WebGLState } from './types'
5
5
 
6
6
  export const webgl = async (gl: Partial<GL>) => {
7
7
  const c = gl.el!.getContext('webgl2')!
8
- const pg = createProgram(c, gl.vs, gl.fs, () => void (gl.isLoop = false))!
8
+ const pg = createProgram(c, gl.vs, gl.fs, () => void (gl.isLoop = false), gl)!
9
9
  c.useProgram(pg)
10
10
  let _activeUnit = 0
11
11
  const uniforms = cached((key) => c.getUniformLocation(pg, key))
12
12
  const attribs = cached((key) => c.getAttribLocation(pg, key))
13
13
  const units = cached(() => _activeUnit++)
14
- const state = { context: c, program: pg } as WebGLState
15
14
 
16
15
  const clean = () => c.deleteProgram(pg)
17
16
 
@@ -48,5 +47,5 @@ export const webgl = async (gl: Partial<GL>) => {
48
47
  })
49
48
  }
50
49
 
51
- return { webgl: state, render, clean, _attribute, _uniform, _texture }
50
+ return { render, clean, _attribute, _uniform, _texture, webgl: { context: c, program: pg } as WebGLState }
52
51
  }
package/src/webgpu.ts CHANGED
@@ -1,84 +1,85 @@
1
1
  import { nested as cached } from 'reev'
2
2
  import { is } from './utils/helpers'
3
3
  import {
4
+ createAttribBuffer,
5
+ createBindGroup,
6
+ createBindings,
7
+ createDepthTexture,
8
+ createDescriptor,
4
9
  createDevice,
5
10
  createPipeline,
6
- createDescriptor,
7
- createUniformBuffer,
8
- createBindGroup,
9
11
  createTextureSampler,
10
- createVertexBuffer,
11
- createBufferLayout,
12
+ createUniformBuffer,
13
+ createVertexBuffers,
12
14
  } from './utils/pipeline'
13
15
  import type { GL, WebGPUState } from './types'
14
16
 
15
17
  export const webgpu = async (gl: Partial<GL>) => {
16
- const c = gl.el!.getContext('webgpu') as any
18
+ const c = gl.el!.getContext('webgpu') as GPUCanvasContext
17
19
  const { device, format } = await createDevice(c)
18
- const state = {
19
- device,
20
- context: c,
21
- resources: [[], []],
22
- loadingImg: 0,
23
- needsUpdate: true,
24
- } as WebGPUState
25
-
26
- const bindGroups = [] as any[]
27
- const vertexBuffers = [] as any[]
28
- const bufferLayouts = [] as any[]
29
-
30
- const attributes = cached((_, value: number[]) => {
31
- const { array, buffer } = createVertexBuffer(device, value)
32
- vertexBuffers.push(buffer)
33
- bufferLayouts.push(createBufferLayout(bufferLayouts.length, array.length, gl.count))
34
- state.needsUpdate = true
35
- return { array, buffer }
36
- })
20
+ const bindings = createBindings()
21
+ let imageLoading = 0
22
+ let needsUpdate = true
23
+ let depthTexture: GPUTexture
24
+ let _render = (_pass: GPURenderPassEncoder) => {}
37
25
 
38
- const uniforms = cached((_, value: number[]) => {
26
+ const uniforms = cached((_key, value: number[]) => {
27
+ needsUpdate = true
28
+ const { group, binding } = bindings.uniform()
39
29
  const { array, buffer } = createUniformBuffer(device, value)
40
- state.resources[0].push({ buffer })
41
- state.needsUpdate = true
42
- return { array, buffer }
30
+ return { array, buffer, binding, group }
43
31
  })
44
32
 
45
- const textures = cached((_, { width, height }: HTMLImageElement) => {
33
+ const textures = cached((_key, { width, height }: HTMLImageElement) => {
34
+ needsUpdate = true
35
+ const { group, binding } = bindings.texture()
46
36
  const { texture, sampler } = createTextureSampler(device, width, height)
47
- state.resources[1].push(sampler, texture.createView())
48
- state.needsUpdate = true
49
- return { texture, width, height }
37
+ return { texture, sampler, binding, group }
38
+ })
39
+
40
+ const attribs = cached((_key, value: number[]) => {
41
+ needsUpdate = true
42
+ const stride = value.length / gl.count!
43
+ const { location } = bindings.attrib()
44
+ const { array, buffer } = createAttribBuffer(device, value)
45
+ return { array, buffer, location, stride }
50
46
  })
51
47
 
52
48
  const update = () => {
53
- const bindGroupLayouts = [] as any
54
- bindGroups.length = 0
55
- state.resources.forEach((resource) => {
56
- if (!resource.length) return
57
- const { layout, bindGroup } = createBindGroup(device, resource)
58
- bindGroupLayouts.push(layout)
59
- bindGroups.push(bindGroup)
60
- })
61
- state.pipeline = createPipeline(device, format, bufferLayouts, bindGroupLayouts, gl.vs, gl.fs)
49
+ const { vertexBuffers, bufferLayouts } = createVertexBuffers(attribs.map)
50
+ const { bindGroups, bindGroupLayouts } = createBindGroup(device, uniforms.map, textures.map)
51
+ const pipeline = createPipeline(device, format, bufferLayouts, bindGroupLayouts, webgpu, gl.vs, gl.fs)
52
+ _render = (pass) => {
53
+ pass.setPipeline(pipeline)
54
+ bindGroups.forEach((v, i) => pass.setBindGroup(i, v))
55
+ vertexBuffers.forEach((v, i) => pass.setVertexBuffer(i, v))
56
+ pass.draw(gl.count!, 1, 0, 0)
57
+ pass.end()
58
+ }
62
59
  }
63
60
 
64
61
  const render = () => {
65
- if (state.loadingImg) return // ignore if loading img
66
- if (state.needsUpdate) update() // first rendering
67
- state.needsUpdate = false
62
+ if (imageLoading) return
63
+ if (needsUpdate) update()
64
+ needsUpdate = false
68
65
  const encoder = device.createCommandEncoder()
69
- const pass = encoder.beginRenderPass(createDescriptor(c))
70
- pass.setPipeline(state.pipeline)
71
- bindGroups.forEach((v, i) => pass.setBindGroup(i, v))
72
- vertexBuffers.forEach((v, i) => pass.setVertexBuffer(i, v))
73
- pass.draw(gl.count, 1, 0, 0)
74
- pass.end()
66
+ _render(encoder.beginRenderPass(createDescriptor(c, depthTexture)))
75
67
  device.queue.submit([encoder.finish()])
76
68
  }
77
69
 
78
- const clean = () => {}
70
+ const resize = () => {
71
+ const canvas = gl.el as HTMLCanvasElement
72
+ depthTexture?.destroy()
73
+ depthTexture = createDepthTexture(device, canvas.width, canvas.height)
74
+ }
75
+
76
+ const clean = () => {
77
+ depthTexture?.destroy()
78
+ }
79
79
 
80
80
  const _attribute = (key = '', value: number[]) => {
81
- const { array, buffer } = attributes(key, value)
81
+ const { array, buffer } = attribs(key, value)
82
+ array.set(value)
82
83
  device.queue.writeBuffer(buffer, 0, array)
83
84
  }
84
85
 
@@ -90,14 +91,22 @@ export const webgpu = async (gl: Partial<GL>) => {
90
91
  }
91
92
 
92
93
  const _texture = (key: string, src: string) => {
93
- state.loadingImg++
94
+ imageLoading++
94
95
  const source = Object.assign(new Image(), { src, crossOrigin: 'anonymous' })
95
96
  source.decode().then(() => {
96
- const { texture, width, height } = textures(key, source)
97
- device.queue.copyExternalImageToTexture({ source }, { texture }, { width, height })
98
- state.loadingImg--
97
+ const texture = textures(key, source)
98
+ device.queue.copyExternalImageToTexture(
99
+ { source },
100
+ { texture: texture.texture },
101
+ { width: source.width, height: source.height }
102
+ )
103
+ imageLoading--
99
104
  })
100
105
  }
101
106
 
102
- return { webgpu: state, render, clean, _attribute, _uniform, _texture }
107
+ resize()
108
+
109
+ const webgpu = { device, uniforms, textures, attribs } as WebGPUState
110
+
111
+ return { webgpu, render, resize, clean, _attribute, _uniform, _texture }
103
112
  }
@@ -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 };
package/dist/index.d.cts DELETED
@@ -1,3 +0,0 @@
1
- export { Frame, Fun, Queue } from 'refr';
2
- export { A as Attribute, k as Attributes, G as GL, m as GLClearMode, o as GLDrawMode, n as GLDrawType, j as GPUBindGroup, g as GPUBuffer, e as GPUContext, f as GPUDevice, h as GPUPipeline, P as PrecisionMode, U as Uniform, l as Uniforms, a as WebGLState, W as WebGPUState, C as alignTo256, Q as createAttrib, z as createBindGroup, H as createBufferLayout, B as createDescriptor, x as createDevice, d as createGL, M as createIbo, y as createPipeline, K as createProgram, R as createTexture, F as createTextureSampler, E as createUniformBuffer, L as createVbo, D as createVertexBuffer, d as default, J as defaultFragmentGLSL, I as defaultVertexGLSL, v as dig, q as each, t as ext, u as fig, r as flush, O as getStride, p as is, i as isGL, b as isServer, c as isWebGPUSupported, s as replace, w as sig, S as webgl, T as webgpu } from './index-q8W5cl04.cjs';
3
- import 'reev';
package/dist/native.d.cts DELETED
@@ -1,53 +0,0 @@
1
- import * as reev from 'reev';
2
- import * as refr_dist_types_687121c7 from 'refr/dist/types-687121c7';
3
- import { G as GL, N as NodeProxy, W as WebGPUState, a as WebGLState, U as Uniform, A as Attribute } from './index-q8W5cl04.cjs';
4
- export { k as Attributes, m as GLClearMode, o as GLDrawMode, n as GLDrawType, j as GPUBindGroup, g as GPUBuffer, e as GPUContext, f as GPUDevice, h as GPUPipeline, P as PrecisionMode, l as Uniforms, C as alignTo256, Q as createAttrib, z as createBindGroup, H as createBufferLayout, B as createDescriptor, x as createDevice, d as createGL, M as createIbo, y as createPipeline, K as createProgram, R as createTexture, F as createTextureSampler, E as createUniformBuffer, L as createVbo, D as createVertexBuffer, J as defaultFragmentGLSL, I as defaultVertexGLSL, v as dig, q as each, t as ext, u as fig, r as flush, O as getStride, p as is, i as isGL, b as isServer, c as isWebGPUSupported, s as replace, w as sig, S as webgl, T as webgpu } from './index-q8W5cl04.cjs';
5
- export { Frame, Fun, Queue } from 'refr';
6
-
7
- declare const useGL: (props?: Partial<GL>) => reev.EventState<{
8
- isNative: boolean;
9
- isWebGL: boolean;
10
- isLoop: boolean;
11
- isGL: true;
12
- width: number;
13
- height: number;
14
- size: [number, number];
15
- mouse: [number, number];
16
- count: number;
17
- el: HTMLCanvasElement;
18
- vs: string | NodeProxy;
19
- fs: string | NodeProxy;
20
- vert: string | NodeProxy;
21
- frag: string | NodeProxy;
22
- vertex: string | NodeProxy;
23
- fragment: string | NodeProxy;
24
- webgpu: WebGPUState;
25
- webgl: WebGLState;
26
- queue: refr_dist_types_687121c7.Q;
27
- frame: refr_dist_types_687121c7.a;
28
- ref?: any;
29
- init(): void;
30
- loop(): void;
31
- mount(): void;
32
- clean(): void;
33
- render(): void;
34
- resize(e?: Event): void;
35
- mousemove(e: Event): void;
36
- _uniform?(key: string, value: Uniform, isMatrix?: boolean): GL;
37
- uniform(key: string, value: Uniform, isMatrix?: boolean): GL;
38
- uniform(target: {
39
- [key: string]: Uniform;
40
- }): GL;
41
- _texture?(key: string, value: string): GL;
42
- texture(key: string, value: string): GL;
43
- texture(target: {
44
- [key: string]: string;
45
- }): GL;
46
- _attribute?(key: string, value: Attribute, iboValue?: Attribute): GL;
47
- attribute(key: string, value: Attribute, iboValue?: Attribute): GL;
48
- attribute(target: {
49
- [key: string]: Attribute;
50
- }): GL;
51
- }, any[] | unknown[]>;
52
-
53
- export { Attribute, GL, Uniform, WebGLState, WebGPUState, useGL };
package/dist/react.d.cts DELETED
@@ -1,8 +0,0 @@
1
- import * as reev from 'reev';
2
- import { G as GL } from './index-q8W5cl04.cjs';
3
- export { A as Attribute, k as Attributes, m as GLClearMode, o as GLDrawMode, n as GLDrawType, j as GPUBindGroup, g as GPUBuffer, e as GPUContext, f as GPUDevice, h as GPUPipeline, P as PrecisionMode, U as Uniform, l as Uniforms, a as WebGLState, W as WebGPUState, C as alignTo256, Q as createAttrib, z as createBindGroup, H as createBufferLayout, B as createDescriptor, x as createDevice, d as createGL, M as createIbo, y as createPipeline, K as createProgram, R as createTexture, F as createTextureSampler, E as createUniformBuffer, L as createVbo, D as createVertexBuffer, J as defaultFragmentGLSL, I as defaultVertexGLSL, v as dig, q as each, t as ext, u as fig, r as flush, O as getStride, p as is, i as isGL, b as isServer, c as isWebGPUSupported, s as replace, w as sig, S as webgl, T as webgpu } from './index-q8W5cl04.cjs';
4
- export { Frame, Fun, Queue } from 'refr';
5
-
6
- declare const useGL: (props?: Partial<GL>) => reev.EventState<GL>;
7
-
8
- export { GL, useGL };
package/dist/solid.d.cts DELETED
@@ -1,8 +0,0 @@
1
- import * as reev from 'reev';
2
- import { G as GL } from './index-q8W5cl04.cjs';
3
- export { A as Attribute, k as Attributes, m as GLClearMode, o as GLDrawMode, n as GLDrawType, j as GPUBindGroup, g as GPUBuffer, e as GPUContext, f as GPUDevice, h as GPUPipeline, P as PrecisionMode, U as Uniform, l as Uniforms, a as WebGLState, W as WebGPUState, C as alignTo256, Q as createAttrib, z as createBindGroup, H as createBufferLayout, B as createDescriptor, x as createDevice, d as createGL, M as createIbo, y as createPipeline, K as createProgram, R as createTexture, F as createTextureSampler, E as createUniformBuffer, L as createVbo, D as createVertexBuffer, J as defaultFragmentGLSL, I as defaultVertexGLSL, v as dig, q as each, t as ext, u as fig, r as flush, O as getStride, p as is, i as isGL, b as isServer, c as isWebGPUSupported, s as replace, w as sig, S as webgl, T as webgpu } from './index-q8W5cl04.cjs';
4
- export { Frame, Fun, Queue } from 'refr';
5
-
6
- declare const onGL: (props?: Partial<GL>) => reev.EventState<GL>;
7
-
8
- export { GL, onGL };