glre 0.44.0 → 0.46.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 +4 -26
- package/dist/addons.d.ts +41 -51
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +43 -91
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +1 -1
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.ts +51 -94
- package/dist/native.js +1 -1
- package/dist/native.js.map +1 -1
- package/dist/node.cjs +15 -15
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +41 -52
- package/dist/node.js +14 -14
- package/dist/node.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +43 -92
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/solid.cjs +1 -1
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.d.ts +43 -92
- package/dist/solid.js +1 -1
- package/dist/solid.js.map +1 -1
- package/package.json +1 -1
- package/src/{utils/helpers.ts → helpers.ts} +10 -32
- package/src/index.ts +45 -42
- package/src/native.ts +6 -7
- package/src/node/build.ts +6 -21
- package/src/node/create.ts +2 -4
- package/src/node/index.ts +8 -20
- package/src/node/types.ts +9 -1
- package/src/node/utils/index.ts +5 -25
- package/src/node/utils/infer.ts +4 -12
- package/src/node/utils/parse.ts +18 -34
- package/src/node/utils/utils.ts +3 -11
- package/src/react.ts +9 -12
- package/src/solid.ts +3 -10
- package/src/types.ts +30 -22
- package/src/webgl/compute.ts +56 -0
- package/src/webgl/graphic.ts +65 -0
- package/src/webgl/index.ts +21 -0
- package/src/{utils/program.ts → webgl/utils.ts} +30 -8
- package/src/webgpu/compute.ts +39 -0
- package/src/webgpu/graphic.ts +89 -0
- package/src/webgpu/index.ts +42 -0
- package/src/{utils/pipeline.ts → webgpu/utils.ts} +75 -78
- package/src/utils/webgl.ts +0 -135
- package/src/utils/webgpu.ts +0 -178
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(r,t)=>{for(var o in t)i(r,o,{get:t[o],enumerable:!0})},f=(r,t,o,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of c(t))!l.call(r,p)&&p!==o&&i(r,p,{get:()=>t[p],enumerable:!(u=L(t,p))||u.enumerable});return r},m=(r,t,o)=>(f(r,t,"default"),o&&f(o,t,"default"));var w=r=>f(i({},"__esModule",{value:!0}),r);var e={};s(e,{useGL:()=>x});module.exports=w(e);var n=require("react"),G=require("./index.cjs");m(e,require("./index.cjs"),module.exports);var x=(...r)=>{let[,t]=(0,n.useState)(null);return r[0]&&!r[0].error&&(r[0].error=(o="")=>t(()=>{throw new Error(o)})),(0,n.useState)(()=>(0,G.createGL)(...r))[0]};0&&(module.exports={useGL,...require("./index.cjs")});
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { useState } from 'react'\nimport { createGL
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { useState } from 'react'\nimport { createGL } from './index'\nimport type { GL } from './types'\nexport * from './index'\n\nexport const useGL = (...args: Partial<GL>[]) => {\n const [, set] = useState(null) // for error boundary // ref: https://github.com/facebook/react/issues/14981\n if (args[0] && !args[0].error)\n args[0].error = (error = '') =>\n set(() => {\n throw new Error(error)\n })\n return useState(() => createGL(...args))[0]\n}\n"],"mappings":"2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,iBACzBC,EAAyB,uBAEzBC,EAAAN,EAAc,uBAHd,gBAKO,IAAME,EAAQ,IAAIK,IAAwB,CACzC,GAAM,CAAC,CAAEC,CAAG,KAAI,YAAS,IAAI,EAC7B,OAAID,EAAK,CAAC,GAAK,CAACA,EAAK,CAAC,EAAE,QAChBA,EAAK,CAAC,EAAE,MAAQ,CAACE,EAAQ,KACjBD,EAAI,IAAM,CACF,MAAM,IAAI,MAAMC,CAAK,CAC7B,CAAC,MACV,YAAS,OAAM,YAAS,GAAGF,CAAI,CAAC,EAAE,CAAC,CAClD","names":["react_exports","__export","useGL","__toCommonJS","import_react","import_index","__reExport","args","set","error"]}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as reev from 'reev';
|
|
2
|
-
import { EventState
|
|
3
|
-
import * as refr from 'refr';
|
|
2
|
+
import { EventState } from 'reev';
|
|
4
3
|
import { Queue, Frame } from 'refr';
|
|
5
4
|
|
|
6
5
|
declare const CONVERSIONS: readonly ["toBool", "toUInt", "toInt", "toFloat", "toBVec2", "toIVec2", "toUVec2", "toVec2", "toBVec3", "toIVec3", "toUVec3", "toVec3", "toBVec4", "toIVec4", "toUVec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
|
|
@@ -70,6 +69,28 @@ declare const OPERATOR_TYPE_RULES: readonly [readonly ["float", "vec2", "vec2"],
|
|
|
70
69
|
*/
|
|
71
70
|
declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverse", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "saturate", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
|
|
72
71
|
|
|
72
|
+
/**
|
|
73
|
+
* binding
|
|
74
|
+
*/
|
|
75
|
+
declare const createBinding: () => {
|
|
76
|
+
uniform: reev.Nested<{
|
|
77
|
+
group: number;
|
|
78
|
+
binding: number;
|
|
79
|
+
}, []>;
|
|
80
|
+
texture: reev.Nested<{
|
|
81
|
+
group: number;
|
|
82
|
+
binding: number;
|
|
83
|
+
}, []>;
|
|
84
|
+
storage: reev.Nested<{
|
|
85
|
+
group: number;
|
|
86
|
+
binding: number;
|
|
87
|
+
}, []>;
|
|
88
|
+
attrib: reev.Nested<{
|
|
89
|
+
location: number;
|
|
90
|
+
}, []>;
|
|
91
|
+
};
|
|
92
|
+
type Binding = ReturnType<typeof createBinding>;
|
|
93
|
+
|
|
73
94
|
type Constants = (typeof CONSTANTS)[number] | 'void';
|
|
74
95
|
type Conversions = (typeof CONVERSIONS)[number];
|
|
75
96
|
type Functions = (typeof FUNCTIONS)[number];
|
|
@@ -102,6 +123,7 @@ interface NodeProps {
|
|
|
102
123
|
}
|
|
103
124
|
interface NodeContext {
|
|
104
125
|
gl?: Partial<GL>;
|
|
126
|
+
binding?: Binding;
|
|
105
127
|
label?: 'vert' | 'frag' | 'compute';
|
|
106
128
|
isWebGL?: boolean;
|
|
107
129
|
units?: any;
|
|
@@ -112,7 +134,7 @@ interface NodeContext {
|
|
|
112
134
|
fragInputs: Map<string, string>;
|
|
113
135
|
vertInputs: Map<string, string>;
|
|
114
136
|
vertOutputs: Map<string, string>;
|
|
115
|
-
vertVaryings: Map<string,
|
|
137
|
+
vertVaryings: Map<string, VaryingInfo>;
|
|
116
138
|
computeInputs: Map<string, string>;
|
|
117
139
|
dependencies: Map<string, Set<string>>;
|
|
118
140
|
structStructFields: Map<string, StructFields>;
|
|
@@ -208,6 +230,10 @@ type Mat4 = XImpl<'mat4'>;
|
|
|
208
230
|
type Texture$1 = XImpl<'texture'>;
|
|
209
231
|
type Sampler2D = XImpl<'sampler2D'>;
|
|
210
232
|
type StructBase = XImpl<'struct'>;
|
|
233
|
+
interface VaryingInfo {
|
|
234
|
+
node: Y;
|
|
235
|
+
code?: string;
|
|
236
|
+
}
|
|
211
237
|
interface ConstantsToType {
|
|
212
238
|
void: Void;
|
|
213
239
|
bool: Bool;
|
|
@@ -244,6 +270,7 @@ type XImpl<T extends C> = _X<T> & {
|
|
|
244
270
|
};
|
|
245
271
|
type C = Constants;
|
|
246
272
|
type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
|
|
273
|
+
type Y<T extends C = C> = number | number[] | string | boolean | undefined | HTMLElement | X<T>;
|
|
247
274
|
type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
|
|
248
275
|
interface _X<T extends C> {
|
|
249
276
|
readonly __nodeType?: T;
|
|
@@ -392,16 +419,17 @@ type GL = EventState<{
|
|
|
392
419
|
isDebug: boolean;
|
|
393
420
|
isDepth: boolean;
|
|
394
421
|
wireframe: boolean;
|
|
395
|
-
isGL: true;
|
|
396
422
|
width?: number;
|
|
397
423
|
height?: number;
|
|
398
424
|
size: [number, number];
|
|
399
425
|
mouse: [number, number];
|
|
400
426
|
count: number;
|
|
427
|
+
triangleCount: number;
|
|
401
428
|
instanceCount: number;
|
|
402
429
|
particleCount: number | [number, number] | [number, number, number];
|
|
403
430
|
precision: 'lowp' | 'mediump' | 'highp';
|
|
404
|
-
|
|
431
|
+
element?: HTMLCanvasElement;
|
|
432
|
+
elem?: HTMLCanvasElement;
|
|
405
433
|
el: HTMLCanvasElement;
|
|
406
434
|
vs?: string | Vec4;
|
|
407
435
|
cs?: string | Void;
|
|
@@ -412,11 +440,16 @@ type GL = EventState<{
|
|
|
412
440
|
vertex?: string | Vec4;
|
|
413
441
|
compute?: string | Void;
|
|
414
442
|
fragment?: string | Vec4;
|
|
443
|
+
program: WebGLProgram;
|
|
444
|
+
gl: WebGL2RenderingContext;
|
|
445
|
+
gpu: GPUCanvasContext;
|
|
446
|
+
device: GPUDevice;
|
|
447
|
+
format: GPUTextureFormat;
|
|
448
|
+
encoder: GPUCommandEncoder;
|
|
449
|
+
binding: Binding;
|
|
415
450
|
/**
|
|
416
451
|
* core state
|
|
417
452
|
*/
|
|
418
|
-
webgpu: WebGPUState;
|
|
419
|
-
webgl: WebGLState;
|
|
420
453
|
queue: Queue;
|
|
421
454
|
frame: Frame;
|
|
422
455
|
/**
|
|
@@ -429,7 +462,6 @@ type GL = EventState<{
|
|
|
429
462
|
render(): void;
|
|
430
463
|
resize(e?: Event): void;
|
|
431
464
|
mousemove(e: MouseEvent): void;
|
|
432
|
-
loop(): void;
|
|
433
465
|
/**
|
|
434
466
|
* setter
|
|
435
467
|
*/
|
|
@@ -492,92 +524,11 @@ interface StorageData {
|
|
|
492
524
|
binding: number;
|
|
493
525
|
group: number;
|
|
494
526
|
}
|
|
495
|
-
interface WebGPUState {
|
|
496
|
-
device: GPUDevice;
|
|
497
|
-
uniforms: Nested<UniformData>;
|
|
498
|
-
textures: Nested<TextureData>;
|
|
499
|
-
attribs: Nested<AttribData>;
|
|
500
|
-
storages: Nested<StorageData>;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* for webgl
|
|
504
|
-
*/
|
|
505
|
-
interface WebGLState {
|
|
506
|
-
context: WebGL2RenderingContext;
|
|
507
|
-
program: WebGLProgram;
|
|
508
|
-
uniforms: Nested<WebGLUniformLocation | null>;
|
|
509
|
-
}
|
|
510
527
|
|
|
511
|
-
declare const isGL: (a: unknown) => a is EventState<GL>;
|
|
512
528
|
declare const isServer: () => boolean;
|
|
513
529
|
declare const isWebGPUSupported: () => boolean;
|
|
514
|
-
declare const createGL: (
|
|
515
|
-
isNative: boolean;
|
|
516
|
-
isWebGL: boolean;
|
|
517
|
-
isError: boolean;
|
|
518
|
-
isLoop: boolean;
|
|
519
|
-
isDebug: boolean;
|
|
520
|
-
isDepth: boolean;
|
|
521
|
-
wireframe: boolean;
|
|
522
|
-
isGL: true;
|
|
523
|
-
width?: number;
|
|
524
|
-
height?: number;
|
|
525
|
-
size: [number, number];
|
|
526
|
-
mouse: [number, number];
|
|
527
|
-
count: number;
|
|
528
|
-
instanceCount: number;
|
|
529
|
-
particleCount: number | [number, number] | [number, number, number];
|
|
530
|
-
precision: "lowp" | "mediump" | "highp";
|
|
531
|
-
loading: number;
|
|
532
|
-
el: HTMLCanvasElement;
|
|
533
|
-
vs?: string | Vec4;
|
|
534
|
-
cs?: string | Void;
|
|
535
|
-
fs?: string | Vec4;
|
|
536
|
-
vert?: string | Vec4;
|
|
537
|
-
comp?: string | Void;
|
|
538
|
-
frag?: string | Vec4;
|
|
539
|
-
vertex?: string | Vec4;
|
|
540
|
-
compute?: string | Void;
|
|
541
|
-
fragment?: string | Vec4;
|
|
542
|
-
webgpu: WebGPUState;
|
|
543
|
-
webgl: WebGLState;
|
|
544
|
-
queue: refr.Queue;
|
|
545
|
-
frame: refr.Frame;
|
|
546
|
-
ref?: any;
|
|
547
|
-
mount(): void;
|
|
548
|
-
clean(): void;
|
|
549
|
-
error(e?: string): void;
|
|
550
|
-
render(): void;
|
|
551
|
-
resize(e?: Event): void;
|
|
552
|
-
mousemove(e: MouseEvent): void;
|
|
553
|
-
loop(): void;
|
|
554
|
-
_uniform?(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
|
|
555
|
-
uniform(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
|
|
556
|
-
uniform(target: {
|
|
557
|
-
[key: string]: number | number[] | Float32Array<ArrayBufferLike>;
|
|
558
|
-
}): GL;
|
|
559
|
-
_texture?(key: string, value: string | HTMLImageElement | HTMLVideoElement): GL;
|
|
560
|
-
texture(key: string, value: string | HTMLImageElement | HTMLVideoElement): GL;
|
|
561
|
-
texture(target: {
|
|
562
|
-
[key: string]: string | HTMLImageElement | HTMLVideoElement;
|
|
563
|
-
}): GL;
|
|
564
|
-
_attribute?(key: string, value: number[] | Float32Array<ArrayBufferLike>, iboValue?: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
565
|
-
attribute(key: string, value: number[] | Float32Array<ArrayBufferLike>, iboValue?: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
566
|
-
attribute(target: {
|
|
567
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
568
|
-
}): GL;
|
|
569
|
-
_instance?(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
|
|
570
|
-
instance(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
|
|
571
|
-
instance(target: {
|
|
572
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
573
|
-
}): GL;
|
|
574
|
-
_storage?(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
575
|
-
storage(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
576
|
-
storage(target: {
|
|
577
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
578
|
-
}): GL;
|
|
579
|
-
}, any[] | unknown[]>;
|
|
530
|
+
declare const createGL: (...args: Partial<GL>[]) => EventState<GL>;
|
|
580
531
|
|
|
581
|
-
declare const useGL: (
|
|
532
|
+
declare const useGL: (...args: Partial<GL>[]) => reev.EventState<GL>;
|
|
582
533
|
|
|
583
|
-
export { type AttribData, type GL, type StorageData, type TextureData, type UniformData,
|
|
534
|
+
export { type AttribData, type GL, type StorageData, type TextureData, type UniformData, createGL, isServer, isWebGPUSupported, useGL };
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as t}from"react";import{createGL as m}from"./index.js";export*from"./index.js";var i=(...r)=>{let[,o]=t(null);return r[0]&&!r[0].error&&(r[0].error=(e="")=>o(()=>{throw new Error(e)})),t(()=>m(...r))[0]};export{i as useGL};
|
|
2
2
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { useState } from 'react'\nimport { createGL
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { useState } from 'react'\nimport { createGL } from './index'\nimport type { GL } from './types'\nexport * from './index'\n\nexport const useGL = (...args: Partial<GL>[]) => {\n const [, set] = useState(null) // for error boundary // ref: https://github.com/facebook/react/issues/14981\n if (args[0] && !args[0].error)\n args[0].error = (error = '') =>\n set(() => {\n throw new Error(error)\n })\n return useState(() => createGL(...args))[0]\n}\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,QACzB,OAAS,YAAAC,MAAgB,aAEzB,WAAc,aAEP,IAAMC,EAAQ,IAAIC,IAAwB,CACzC,GAAM,CAAC,CAAEC,CAAG,EAAIJ,EAAS,IAAI,EAC7B,OAAIG,EAAK,CAAC,GAAK,CAACA,EAAK,CAAC,EAAE,QAChBA,EAAK,CAAC,EAAE,MAAQ,CAACE,EAAQ,KACjBD,EAAI,IAAM,CACF,MAAM,IAAI,MAAMC,CAAK,CAC7B,CAAC,GACVL,EAAS,IAAMC,EAAS,GAAGE,CAAI,CAAC,EAAE,CAAC,CAClD","names":["useState","createGL","useGL","args","set","error"]}
|
package/dist/solid.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var L=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(t,r)=>{for(var o in r)L(t,o,{get:r[o],enumerable:!0})},G=(t,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of n(r))!c.call(t,p)&&p!==o&&L(t,p,{get:()=>r[p],enumerable:!(a=i(r,p))||a.enumerable});return t},m=(t,r,o)=>(G(t,r,"default"),o&&G(o,r,"default"));var x=t=>G(L({},"__esModule",{value:!0}),t);var e={};s(e,{onGL:()=>y});module.exports=x(e);var f=require("./index.cjs");m(e,require("./index.cjs"),module.exports);var y=(...t)=>(0,f.createGL)(...t);0&&(module.exports={onGL,...require("./index.cjs")});
|
|
2
2
|
//# sourceMappingURL=solid.cjs.map
|
package/dist/solid.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/solid.ts"],"sourcesContent":["import { createGL
|
|
1
|
+
{"version":3,"sources":["../src/solid.ts"],"sourcesContent":["import { createGL } from './index'\nimport type { GL } from './types'\nexport * from './index'\n\nexport const onGL = (...args: Partial<GL>[]) => {\n return createGL(...args)\n}\n"],"mappings":"2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,uBAEzBC,EAAAL,EAAc,uBAFd,gBAIO,IAAME,EAAO,IAAII,OACT,YAAS,GAAGA,CAAI","names":["solid_exports","__export","onGL","__toCommonJS","import_index","__reExport","args"]}
|
package/dist/solid.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as reev from 'reev';
|
|
2
|
-
import { EventState
|
|
3
|
-
import * as refr from 'refr';
|
|
2
|
+
import { EventState } from 'reev';
|
|
4
3
|
import { Queue, Frame } from 'refr';
|
|
5
4
|
|
|
6
5
|
declare const CONVERSIONS: readonly ["toBool", "toUInt", "toInt", "toFloat", "toBVec2", "toIVec2", "toUVec2", "toVec2", "toBVec3", "toIVec3", "toUVec3", "toVec3", "toBVec4", "toIVec4", "toUVec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
|
|
@@ -70,6 +69,28 @@ declare const OPERATOR_TYPE_RULES: readonly [readonly ["float", "vec2", "vec2"],
|
|
|
70
69
|
*/
|
|
71
70
|
declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverse", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "saturate", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
|
|
72
71
|
|
|
72
|
+
/**
|
|
73
|
+
* binding
|
|
74
|
+
*/
|
|
75
|
+
declare const createBinding: () => {
|
|
76
|
+
uniform: reev.Nested<{
|
|
77
|
+
group: number;
|
|
78
|
+
binding: number;
|
|
79
|
+
}, []>;
|
|
80
|
+
texture: reev.Nested<{
|
|
81
|
+
group: number;
|
|
82
|
+
binding: number;
|
|
83
|
+
}, []>;
|
|
84
|
+
storage: reev.Nested<{
|
|
85
|
+
group: number;
|
|
86
|
+
binding: number;
|
|
87
|
+
}, []>;
|
|
88
|
+
attrib: reev.Nested<{
|
|
89
|
+
location: number;
|
|
90
|
+
}, []>;
|
|
91
|
+
};
|
|
92
|
+
type Binding = ReturnType<typeof createBinding>;
|
|
93
|
+
|
|
73
94
|
type Constants = (typeof CONSTANTS)[number] | 'void';
|
|
74
95
|
type Conversions = (typeof CONVERSIONS)[number];
|
|
75
96
|
type Functions = (typeof FUNCTIONS)[number];
|
|
@@ -102,6 +123,7 @@ interface NodeProps {
|
|
|
102
123
|
}
|
|
103
124
|
interface NodeContext {
|
|
104
125
|
gl?: Partial<GL>;
|
|
126
|
+
binding?: Binding;
|
|
105
127
|
label?: 'vert' | 'frag' | 'compute';
|
|
106
128
|
isWebGL?: boolean;
|
|
107
129
|
units?: any;
|
|
@@ -112,7 +134,7 @@ interface NodeContext {
|
|
|
112
134
|
fragInputs: Map<string, string>;
|
|
113
135
|
vertInputs: Map<string, string>;
|
|
114
136
|
vertOutputs: Map<string, string>;
|
|
115
|
-
vertVaryings: Map<string,
|
|
137
|
+
vertVaryings: Map<string, VaryingInfo>;
|
|
116
138
|
computeInputs: Map<string, string>;
|
|
117
139
|
dependencies: Map<string, Set<string>>;
|
|
118
140
|
structStructFields: Map<string, StructFields>;
|
|
@@ -208,6 +230,10 @@ type Mat4 = XImpl<'mat4'>;
|
|
|
208
230
|
type Texture$1 = XImpl<'texture'>;
|
|
209
231
|
type Sampler2D = XImpl<'sampler2D'>;
|
|
210
232
|
type StructBase = XImpl<'struct'>;
|
|
233
|
+
interface VaryingInfo {
|
|
234
|
+
node: Y;
|
|
235
|
+
code?: string;
|
|
236
|
+
}
|
|
211
237
|
interface ConstantsToType {
|
|
212
238
|
void: Void;
|
|
213
239
|
bool: Bool;
|
|
@@ -244,6 +270,7 @@ type XImpl<T extends C> = _X<T> & {
|
|
|
244
270
|
};
|
|
245
271
|
type C = Constants;
|
|
246
272
|
type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
|
|
273
|
+
type Y<T extends C = C> = number | number[] | string | boolean | undefined | HTMLElement | X<T>;
|
|
247
274
|
type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
|
|
248
275
|
interface _X<T extends C> {
|
|
249
276
|
readonly __nodeType?: T;
|
|
@@ -392,16 +419,17 @@ type GL = EventState<{
|
|
|
392
419
|
isDebug: boolean;
|
|
393
420
|
isDepth: boolean;
|
|
394
421
|
wireframe: boolean;
|
|
395
|
-
isGL: true;
|
|
396
422
|
width?: number;
|
|
397
423
|
height?: number;
|
|
398
424
|
size: [number, number];
|
|
399
425
|
mouse: [number, number];
|
|
400
426
|
count: number;
|
|
427
|
+
triangleCount: number;
|
|
401
428
|
instanceCount: number;
|
|
402
429
|
particleCount: number | [number, number] | [number, number, number];
|
|
403
430
|
precision: 'lowp' | 'mediump' | 'highp';
|
|
404
|
-
|
|
431
|
+
element?: HTMLCanvasElement;
|
|
432
|
+
elem?: HTMLCanvasElement;
|
|
405
433
|
el: HTMLCanvasElement;
|
|
406
434
|
vs?: string | Vec4;
|
|
407
435
|
cs?: string | Void;
|
|
@@ -412,11 +440,16 @@ type GL = EventState<{
|
|
|
412
440
|
vertex?: string | Vec4;
|
|
413
441
|
compute?: string | Void;
|
|
414
442
|
fragment?: string | Vec4;
|
|
443
|
+
program: WebGLProgram;
|
|
444
|
+
gl: WebGL2RenderingContext;
|
|
445
|
+
gpu: GPUCanvasContext;
|
|
446
|
+
device: GPUDevice;
|
|
447
|
+
format: GPUTextureFormat;
|
|
448
|
+
encoder: GPUCommandEncoder;
|
|
449
|
+
binding: Binding;
|
|
415
450
|
/**
|
|
416
451
|
* core state
|
|
417
452
|
*/
|
|
418
|
-
webgpu: WebGPUState;
|
|
419
|
-
webgl: WebGLState;
|
|
420
453
|
queue: Queue;
|
|
421
454
|
frame: Frame;
|
|
422
455
|
/**
|
|
@@ -429,7 +462,6 @@ type GL = EventState<{
|
|
|
429
462
|
render(): void;
|
|
430
463
|
resize(e?: Event): void;
|
|
431
464
|
mousemove(e: MouseEvent): void;
|
|
432
|
-
loop(): void;
|
|
433
465
|
/**
|
|
434
466
|
* setter
|
|
435
467
|
*/
|
|
@@ -492,92 +524,11 @@ interface StorageData {
|
|
|
492
524
|
binding: number;
|
|
493
525
|
group: number;
|
|
494
526
|
}
|
|
495
|
-
interface WebGPUState {
|
|
496
|
-
device: GPUDevice;
|
|
497
|
-
uniforms: Nested<UniformData>;
|
|
498
|
-
textures: Nested<TextureData>;
|
|
499
|
-
attribs: Nested<AttribData>;
|
|
500
|
-
storages: Nested<StorageData>;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* for webgl
|
|
504
|
-
*/
|
|
505
|
-
interface WebGLState {
|
|
506
|
-
context: WebGL2RenderingContext;
|
|
507
|
-
program: WebGLProgram;
|
|
508
|
-
uniforms: Nested<WebGLUniformLocation | null>;
|
|
509
|
-
}
|
|
510
527
|
|
|
511
|
-
declare const isGL: (a: unknown) => a is EventState<GL>;
|
|
512
528
|
declare const isServer: () => boolean;
|
|
513
529
|
declare const isWebGPUSupported: () => boolean;
|
|
514
|
-
declare const createGL: (
|
|
515
|
-
isNative: boolean;
|
|
516
|
-
isWebGL: boolean;
|
|
517
|
-
isError: boolean;
|
|
518
|
-
isLoop: boolean;
|
|
519
|
-
isDebug: boolean;
|
|
520
|
-
isDepth: boolean;
|
|
521
|
-
wireframe: boolean;
|
|
522
|
-
isGL: true;
|
|
523
|
-
width?: number;
|
|
524
|
-
height?: number;
|
|
525
|
-
size: [number, number];
|
|
526
|
-
mouse: [number, number];
|
|
527
|
-
count: number;
|
|
528
|
-
instanceCount: number;
|
|
529
|
-
particleCount: number | [number, number] | [number, number, number];
|
|
530
|
-
precision: "lowp" | "mediump" | "highp";
|
|
531
|
-
loading: number;
|
|
532
|
-
el: HTMLCanvasElement;
|
|
533
|
-
vs?: string | Vec4;
|
|
534
|
-
cs?: string | Void;
|
|
535
|
-
fs?: string | Vec4;
|
|
536
|
-
vert?: string | Vec4;
|
|
537
|
-
comp?: string | Void;
|
|
538
|
-
frag?: string | Vec4;
|
|
539
|
-
vertex?: string | Vec4;
|
|
540
|
-
compute?: string | Void;
|
|
541
|
-
fragment?: string | Vec4;
|
|
542
|
-
webgpu: WebGPUState;
|
|
543
|
-
webgl: WebGLState;
|
|
544
|
-
queue: refr.Queue;
|
|
545
|
-
frame: refr.Frame;
|
|
546
|
-
ref?: any;
|
|
547
|
-
mount(): void;
|
|
548
|
-
clean(): void;
|
|
549
|
-
error(e?: string): void;
|
|
550
|
-
render(): void;
|
|
551
|
-
resize(e?: Event): void;
|
|
552
|
-
mousemove(e: MouseEvent): void;
|
|
553
|
-
loop(): void;
|
|
554
|
-
_uniform?(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
|
|
555
|
-
uniform(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
|
|
556
|
-
uniform(target: {
|
|
557
|
-
[key: string]: number | number[] | Float32Array<ArrayBufferLike>;
|
|
558
|
-
}): GL;
|
|
559
|
-
_texture?(key: string, value: string | HTMLImageElement | HTMLVideoElement): GL;
|
|
560
|
-
texture(key: string, value: string | HTMLImageElement | HTMLVideoElement): GL;
|
|
561
|
-
texture(target: {
|
|
562
|
-
[key: string]: string | HTMLImageElement | HTMLVideoElement;
|
|
563
|
-
}): GL;
|
|
564
|
-
_attribute?(key: string, value: number[] | Float32Array<ArrayBufferLike>, iboValue?: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
565
|
-
attribute(key: string, value: number[] | Float32Array<ArrayBufferLike>, iboValue?: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
566
|
-
attribute(target: {
|
|
567
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
568
|
-
}): GL;
|
|
569
|
-
_instance?(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
|
|
570
|
-
instance(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
|
|
571
|
-
instance(target: {
|
|
572
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
573
|
-
}): GL;
|
|
574
|
-
_storage?(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
575
|
-
storage(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
|
|
576
|
-
storage(target: {
|
|
577
|
-
[key: string]: number[] | Float32Array<ArrayBufferLike>;
|
|
578
|
-
}): GL;
|
|
579
|
-
}, any[] | unknown[]>;
|
|
530
|
+
declare const createGL: (...args: Partial<GL>[]) => EventState<GL>;
|
|
580
531
|
|
|
581
|
-
declare const onGL: (
|
|
532
|
+
declare const onGL: (...args: Partial<GL>[]) => reev.EventState<GL>;
|
|
582
533
|
|
|
583
|
-
export { type AttribData, type GL, type StorageData, type TextureData, type UniformData,
|
|
534
|
+
export { type AttribData, type GL, type StorageData, type TextureData, type UniformData, createGL, isServer, isWebGPUSupported, onGL };
|
package/dist/solid.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createGL as
|
|
1
|
+
import{createGL as t}from"./index.js";export*from"./index.js";var e=(...r)=>t(...r);export{e as onGL};
|
|
2
2
|
//# sourceMappingURL=solid.js.map
|
package/dist/solid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/solid.ts"],"sourcesContent":["import { createGL
|
|
1
|
+
{"version":3,"sources":["../src/solid.ts"],"sourcesContent":["import { createGL } from './index'\nimport type { GL } from './types'\nexport * from './index'\n\nexport const onGL = (...args: Partial<GL>[]) => {\n return createGL(...args)\n}\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,aAEzB,WAAc,aAEP,IAAMC,EAAO,IAAIC,IACTF,EAAS,GAAGE,CAAI","names":["createGL","onGL","args"]}
|
package/package.json
CHANGED
|
@@ -27,41 +27,22 @@ export const flush = <Value extends Function, Key, This>(obj: Eachable<Value, Ke
|
|
|
27
27
|
each(obj, (f) => f(...args))
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* other
|
|
32
|
-
*/
|
|
33
|
-
export const replace = (x = '', from = '_', to = '/') => x.split(from).join(to)
|
|
34
|
-
export const ext = (src = '.pdf') => src.split('.').pop()?.toLowerCase() ?? ''
|
|
35
|
-
export const fig = (x = 0) => `${x}`.split('.')[1]?.length ?? 0
|
|
36
|
-
export const dig = (x = 0) => `${x}`.split('.')[0]?.length - (x < 0 ? 1 : 0)
|
|
37
|
-
export const sig = (value = 0, digit = -2) => {
|
|
38
|
-
digit *= -1
|
|
39
|
-
digit = Math.pow(10, digit)
|
|
40
|
-
value *= digit
|
|
41
|
-
value = Math.round(value)
|
|
42
|
-
value /= digit
|
|
43
|
-
return value
|
|
44
|
-
}
|
|
45
|
-
|
|
46
30
|
export const isFloat32 = (value: unknown): value is Float32Array => {
|
|
47
31
|
return value instanceof Float32Array
|
|
48
32
|
}
|
|
49
33
|
|
|
50
|
-
const loadingImage = (src: string, fun: (
|
|
51
|
-
const
|
|
52
|
-
Object.assign(
|
|
53
|
-
|
|
34
|
+
const loadingImage = (src: string, fun: (el: HTMLImageElement) => void) => {
|
|
35
|
+
const el = new Image()
|
|
36
|
+
Object.assign(el, { src, crossOrigin: 'anonymous' })
|
|
37
|
+
el.decode().then(() => fun(el))
|
|
54
38
|
}
|
|
55
39
|
|
|
56
40
|
const loadingVideo = (src: string, fun: (source: HTMLVideoElement) => void) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
source.load()
|
|
63
|
-
source.play()
|
|
64
|
-
source.addEventListener('canplay', fun.bind(null, source), { once: true })
|
|
41
|
+
const el = document.createElement('video')
|
|
42
|
+
Object.assign(el, { src, loop: true, muted: true, crossOrigin: 'anonymous' })
|
|
43
|
+
el.load()
|
|
44
|
+
el.play()
|
|
45
|
+
el.addEventListener('canplay', fun.bind(null, el), { once: true })
|
|
65
46
|
}
|
|
66
47
|
|
|
67
48
|
export function loadingTexture(src: string, fun: (source: HTMLVideoElement, isVideo: true) => void): void
|
|
@@ -85,10 +66,7 @@ const calcStride = (arrayLength: number, count = 3) => {
|
|
|
85
66
|
|
|
86
67
|
export const getStride = (arrayLength: number, count = 1, error = console.warn) => {
|
|
87
68
|
const ret = calcStride(arrayLength, count)
|
|
88
|
-
if (!isValidStride(ret))
|
|
89
|
-
error(
|
|
90
|
-
`glre attribute error: Invalid attribute length ${arrayLength}. Must divide by vertex count (${count}) with valid stride (1,2,3,4,9,16)`
|
|
91
|
-
)
|
|
69
|
+
if (!isValidStride(ret)) error(`glre attribute error: Invalid attribute length ${arrayLength}. Must divide by vertex count (${count}) with valid stride (1,2,3,4,9,16)`)
|
|
92
70
|
return ret
|
|
93
71
|
}
|
|
94
72
|
|