glre 0.45.0 → 0.47.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.
Files changed (52) hide show
  1. package/README.md +4 -26
  2. package/dist/addons.d.ts +35 -50
  3. package/dist/index.cjs +6 -6
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +37 -90
  6. package/dist/index.js +6 -6
  7. package/dist/index.js.map +1 -1
  8. package/dist/native.cjs +1 -1
  9. package/dist/native.cjs.map +1 -1
  10. package/dist/native.d.ts +45 -93
  11. package/dist/native.js +1 -1
  12. package/dist/native.js.map +1 -1
  13. package/dist/node.cjs +15 -15
  14. package/dist/node.cjs.map +1 -1
  15. package/dist/node.d.ts +35 -50
  16. package/dist/node.js +15 -15
  17. package/dist/node.js.map +1 -1
  18. package/dist/react.cjs +1 -1
  19. package/dist/react.cjs.map +1 -1
  20. package/dist/react.d.ts +37 -91
  21. package/dist/react.js +1 -1
  22. package/dist/react.js.map +1 -1
  23. package/dist/solid.cjs +1 -1
  24. package/dist/solid.cjs.map +1 -1
  25. package/dist/solid.d.ts +37 -91
  26. package/dist/solid.js +1 -1
  27. package/dist/solid.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/{utils/helpers.ts → helpers.ts} +10 -32
  30. package/src/index.ts +45 -42
  31. package/src/native.ts +6 -7
  32. package/src/node/build.ts +3 -19
  33. package/src/node/create.ts +2 -4
  34. package/src/node/index.ts +8 -20
  35. package/src/node/types.ts +2 -0
  36. package/src/node/utils/index.ts +5 -2
  37. package/src/node/utils/infer.ts +5 -13
  38. package/src/node/utils/parse.ts +18 -34
  39. package/src/node/utils/utils.ts +15 -10
  40. package/src/react.ts +9 -12
  41. package/src/solid.ts +3 -10
  42. package/src/types.ts +30 -22
  43. package/src/webgl/compute.ts +56 -0
  44. package/src/webgl/graphic.ts +65 -0
  45. package/src/webgl/index.ts +21 -0
  46. package/src/{utils/program.ts → webgl/utils.ts} +30 -8
  47. package/src/webgpu/compute.ts +39 -0
  48. package/src/webgpu/graphic.ts +89 -0
  49. package/src/webgpu/index.ts +42 -0
  50. package/src/{utils/pipeline.ts → webgpu/utils.ts} +75 -78
  51. package/src/utils/webgl.ts +0 -135
  52. package/src/utils/webgpu.ts +0 -178
package/dist/node.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { EventState, Nested } from 'reev';
1
+ import * as reev from 'reev';
2
+ import { EventState } from 'reev';
2
3
  import { Queue, Frame } from 'refr';
3
4
 
4
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"];
@@ -68,6 +69,28 @@ declare const OPERATOR_TYPE_RULES: readonly [readonly ["float", "vec2", "vec2"],
68
69
  */
69
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"];
70
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
+
71
94
  type GL = EventState<{
72
95
  /**
73
96
  * initial value
@@ -79,16 +102,17 @@ type GL = EventState<{
79
102
  isDebug: boolean;
80
103
  isDepth: boolean;
81
104
  wireframe: boolean;
82
- isGL: true;
83
105
  width?: number;
84
106
  height?: number;
85
107
  size: [number, number];
86
108
  mouse: [number, number];
87
109
  count: number;
110
+ triangleCount: number;
88
111
  instanceCount: number;
89
112
  particleCount: number | [number, number] | [number, number, number];
90
113
  precision: 'lowp' | 'mediump' | 'highp';
91
- loading: number;
114
+ element?: HTMLCanvasElement;
115
+ elem?: HTMLCanvasElement;
92
116
  el: HTMLCanvasElement;
93
117
  vs?: string | Vec4;
94
118
  cs?: string | Void;
@@ -99,11 +123,16 @@ type GL = EventState<{
99
123
  vertex?: string | Vec4;
100
124
  compute?: string | Void;
101
125
  fragment?: string | Vec4;
126
+ program: WebGLProgram;
127
+ gl: WebGL2RenderingContext;
128
+ gpu: GPUCanvasContext;
129
+ device: GPUDevice;
130
+ format: GPUTextureFormat;
131
+ encoder: GPUCommandEncoder;
132
+ binding: Binding;
102
133
  /**
103
134
  * core state
104
135
  */
105
- webgpu: WebGPUState;
106
- webgl: WebGLState;
107
136
  queue: Queue;
108
137
  frame: Frame;
109
138
  /**
@@ -116,7 +145,6 @@ type GL = EventState<{
116
145
  render(): void;
117
146
  resize(e?: Event): void;
118
147
  mousemove(e: MouseEvent): void;
119
- loop(): void;
120
148
  /**
121
149
  * setter
122
150
  */
@@ -150,50 +178,6 @@ type Uniform = number | number[] | Float32Array;
150
178
  type Texture$1 = string | HTMLImageElement | HTMLVideoElement;
151
179
  type Attribute = number[] | Float32Array;
152
180
  type Storage = number[] | Float32Array;
153
- /**
154
- * for webgpu
155
- */
156
- interface UniformData {
157
- array: Float32Array;
158
- buffer: GPUBuffer;
159
- binding: number;
160
- group: number;
161
- }
162
- interface TextureData {
163
- binding: number;
164
- group: number;
165
- texture: GPUTexture;
166
- sampler: GPUSampler;
167
- view: GPUTextureView;
168
- }
169
- interface AttribData {
170
- array: Float32Array;
171
- buffer: GPUBuffer;
172
- location: number;
173
- stride: number;
174
- isInstance?: boolean;
175
- }
176
- interface StorageData {
177
- array: Float32Array;
178
- buffer: GPUBuffer;
179
- binding: number;
180
- group: number;
181
- }
182
- interface WebGPUState {
183
- device: GPUDevice;
184
- uniforms: Nested<UniformData>;
185
- textures: Nested<TextureData>;
186
- attribs: Nested<AttribData>;
187
- storages: Nested<StorageData>;
188
- }
189
- /**
190
- * for webgl
191
- */
192
- interface WebGLState {
193
- context: WebGL2RenderingContext;
194
- program: WebGLProgram;
195
- uniforms: Nested<WebGLUniformLocation | null>;
196
- }
197
181
 
198
182
  type Constants = (typeof CONSTANTS)[number] | 'void';
199
183
  type Conversions = (typeof CONVERSIONS)[number];
@@ -235,6 +219,7 @@ interface NodeProps {
235
219
  }
236
220
  interface NodeContext {
237
221
  gl?: Partial<GL>;
222
+ binding?: Binding;
238
223
  label?: 'vert' | 'frag' | 'compute';
239
224
  isWebGL?: boolean;
240
225
  units?: any;
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- var O=["toBool","toUInt","toInt","toFloat","toBVec2","toIVec2","toUVec2","toVec2","toBVec3","toIVec3","toUVec3","toVec3","toBVec4","toIVec4","toUVec4","toVec4","toColor","toMat2","toMat3","toMat4"],w={bool:"bool",uint:"u32",int:"i32",float:"f32",bvec2:"vec2<bool>",ivec2:"vec2i",uvec2:"vec2u",vec2:"vec2f",bvec3:"vec3<bool>",ivec3:"vec3i",uvec3:"vec3u",vec3:"vec3f",bvec4:"vec4<bool>",ivec4:"vec4i",uvec4:"vec4u",vec4:"vec4f",color:"color",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",texture:"texture_2d<f32>",sampler2D:"sampler",struct:"struct"},G=Object.keys(w),P={not:"",add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>",addAssign:"+=",subAssign:"-=",mulAssign:"*=",divAssign:"/=",modAssign:"%=",bitAndAssign:"&=",bitOrAssign:"|=",bitXorAssign:"^=",shiftLeftAssign:"<<=",shiftRightAssign:">>="},q=Object.keys(P),D={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},j={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",global_invocation_id:"uvec3",positionLocal:"vec3",positionWorld:"vec3",positionView:"vec3",normalLocal:"vec3",normalWorld:"vec3",normalView:"vec3",screenCoordinate:"vec2",screenUV:"vec2",gl_FragCoord:"vec4",gl_VertexID:"uint",gl_InstanceID:"uint",gl_FrontFacing:"bool",gl_FragDepth:"float",gl_SampleID:"uint",gl_SampleMask:"uint",gl_PointCoord:"vec2",normal:"vec3",uv:"vec2",color:"vec4"},K=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],Z=["and","or"],J=[["float","vec2","vec2"],["float","vec3","vec3"],["float","vec4","vec4"],["int","ivec2","ivec2"],["int","ivec3","ivec3"],["int","ivec4","ivec4"],["uint","uvec2","uvec2"],["uint","uvec3","uvec3"],["uint","uvec4","uvec4"],["mat2","vec2","vec2"],["mat3","vec3","vec3"],["mat4","vec4","vec4"],["vec2","mat2","vec2"],["vec3","mat3","vec3"],["vec4","mat4","vec4"]],Q={position:"gl_FragCoord",vertex_index:"gl_VertexID",instance_index:"gl_InstanceID",front_facing:"gl_FrontFacing",frag_depth:"gl_FragDepth",sample_index:"gl_SampleID",sample_mask:"gl_SampleMask",point_coord:"gl_PointCoord",uv:"gl_FragCoord.xy"},M={all:"bool",any:"bool",determinant:"float",distance:"float",dot:"float",length:"float",lengthSq:"float",luminance:"float",cross:"vec3",cubeTexture:"vec4",texture:"vec4",texelFetch:"vec4",textureLod:"vec4"},ee=[...Object.keys(M),"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"],N=(e,t)=>e===t,We=(e,t)=>J.some(([n,r,s])=>n===e&&r===t||n===t&&r===e),te=(e,t,n)=>K.includes(n)||Z.includes(n)?N(e,t):N(e,t)?!0:We(e,t),ne=(e,t,n)=>{if(K.includes(n)||Z.includes(n))return"bool";if(N(e,t))return e;let r=J.find(([s,o,a])=>s===e&&o===t||s===t&&o===e);return r?r[2]:e};var l={arr:Array.isArray,bol:e=>typeof e=="boolean",str:e=>typeof e=="string",num:e=>typeof e=="number",int:e=>Number.isInteger(e),fun:e=>typeof e=="function",und:e=>typeof e>"u",nul:e=>e===null,set:e=>e instanceof Set,map:e=>e instanceof Map,obj:e=>!!e&&e.constructor.name==="Object",nan:e=>typeof e=="number"&&Number.isNaN(e)};var Ve=e=>[1,2,3,4,9,16].includes(e),Be=(e,t=3)=>e%t===0?Math.floor(e/t):-1,W=(e,t=1,n=console.warn)=>{let r=Be(e,t);return Ve(r)||n(`glre attribute error: Invalid attribute length ${e}. Must divide by vertex count (${t}) with valid stride (1,2,3,4,9,16)`),r};var xt=`
1
+ var D=["toBool","toUInt","toInt","toFloat","toBVec2","toIVec2","toUVec2","toVec2","toBVec3","toIVec3","toUVec3","toVec3","toBVec4","toIVec4","toUVec4","toVec4","toColor","toMat2","toMat3","toMat4"],P={bool:"bool",uint:"u32",int:"i32",float:"f32",bvec2:"vec2<bool>",ivec2:"vec2i",uvec2:"vec2u",vec2:"vec2f",bvec3:"vec3<bool>",ivec3:"vec3i",uvec3:"vec3u",vec3:"vec3f",bvec4:"vec4<bool>",ivec4:"vec4i",uvec4:"vec4u",vec4:"vec4f",color:"color",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",texture:"texture_2d<f32>",sampler2D:"sampler",struct:"struct"},w=Object.keys(P),W={not:"",add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>",addAssign:"+=",subAssign:"-=",mulAssign:"*=",divAssign:"/=",modAssign:"%=",bitAndAssign:"&=",bitOrAssign:"|=",bitXorAssign:"^=",shiftLeftAssign:"<<=",shiftRightAssign:">>="},j=Object.keys(W),M={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},K={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",global_invocation_id:"uvec3",positionLocal:"vec3",positionWorld:"vec3",positionView:"vec3",normalLocal:"vec3",normalWorld:"vec3",normalView:"vec3",screenCoordinate:"vec2",screenUV:"vec2",gl_FragCoord:"vec4",gl_VertexID:"uint",gl_InstanceID:"uint",gl_FrontFacing:"bool",gl_FragDepth:"float",gl_SampleID:"uint",gl_SampleMask:"uint",gl_PointCoord:"vec2",normal:"vec3",uv:"vec2",color:"vec4"},Z=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],Q=["and","or"],J=[["float","vec2","vec2"],["float","vec3","vec3"],["float","vec4","vec4"],["int","ivec2","ivec2"],["int","ivec3","ivec3"],["int","ivec4","ivec4"],["uint","uvec2","uvec2"],["uint","uvec3","uvec3"],["uint","uvec4","uvec4"],["mat2","vec2","vec2"],["mat3","vec3","vec3"],["mat4","vec4","vec4"],["vec2","mat2","vec2"],["vec3","mat3","vec3"],["vec4","mat4","vec4"]],ee={position:"gl_FragCoord",vertex_index:"gl_VertexID",instance_index:"gl_InstanceID",front_facing:"gl_FrontFacing",frag_depth:"gl_FragDepth",sample_index:"gl_SampleID",sample_mask:"gl_SampleMask",point_coord:"gl_PointCoord",uv:"gl_FragCoord.xy"},V={all:"bool",any:"bool",determinant:"float",distance:"float",dot:"float",length:"float",lengthSq:"float",luminance:"float",cross:"vec3",cubeTexture:"vec4",texture:"vec4",texelFetch:"vec4",textureLod:"vec4"},te=[...Object.keys(V),"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"],G=(e,t)=>e===t,Ve=(e,t)=>J.some(([n,r,s])=>n===e&&r===t||n===t&&r===e),ne=(e,t,n)=>Z.includes(n)||Q.includes(n)?G(e,t):G(e,t)?!0:Ve(e,t),re=(e,t,n)=>{if(Z.includes(n)||Q.includes(n))return"bool";if(G(e,t))return e;let r=J.find(([s,o,a])=>s===e&&o===t||s===t&&o===e);return r?r[2]:e};var c={arr:Array.isArray,bol:e=>typeof e=="boolean",str:e=>typeof e=="string",num:e=>typeof e=="number",int:e=>Number.isInteger(e),fun:e=>typeof e=="function",und:e=>typeof e>"u",nul:e=>e===null,set:e=>e instanceof Set,map:e=>e instanceof Map,obj:e=>!!e&&e.constructor.name==="Object",nan:e=>typeof e=="number"&&Number.isNaN(e)};var A=e=>e instanceof Float32Array;var Be=e=>[1,2,3,4,9,16].includes(e),ze=(e,t=3)=>e%t===0?Math.floor(e/t):-1,B=(e,t=1,n=console.warn)=>{let r=ze(e,t);return Be(r)||n(`glre attribute error: Invalid attribute length ${e}. Must divide by vertex count (${t}) with valid stride (1,2,3,4,9,16)`),r};var mt=`
2
2
  struct In { @builtin(vertex_index) vertex_index: u32 }
3
3
  struct Out { @builtin(position) position: vec4f }
4
4
  @vertex
@@ -9,26 +9,26 @@ fn main(in: In) -> Out {
9
9
  out.position = vec4f(x, y, 0.0, 1.0);
10
10
  return out;
11
11
  }
12
- `.trim();var A=(e=1024)=>{if(l.num(e)){let s=Math.sqrt(e),o=Math.ceil(s);return Number.isInteger(s)||console.warn(`GLRE Storage Warning: particleCount (${e}) is not a square. Using ${o}x${o} texture may waste GPU memory. Consider using [width, height] format for optimal storage.`),{x:o,y:o}}let[t,n,r]=e;if(r!==void 0){let s=n*r;return console.warn(`GLRE Storage Warning: 3D particleCount [${t}, ${n}, ${r}] specified but WebGL storage textures only support 2D. Flattening to 2D by multiplying height=${n} * depth=${r} = ${s}.`),{x:t,y:s}}return{x:t,y:n}};var re=e=>l.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),oe=e=>q.includes(e),se=e=>ee.includes(e),ie=e=>l.obj(e)?!1:e instanceof Element,ae=e=>O.includes(e),S=e=>!e||typeof e!="object"?!1:e.isProxy,V=e=>l.str(e)?G.includes(e):!1,ue=e=>{let t=(e>>16&255)/255,n=(e>>8&255)/255,r=(e&255)/255;return[t,n,r]},ze=0,v=()=>`x${ze++}`,pe=(e,t)=>{if(t==="global_invocation_id")return`uvec3(uint(gl_FragCoord.y) * uint(${A(e.gl?.particleCount).x}) + uint(gl_FragCoord.x), 0u, 0u)`;let n=Q[t];if(!n)throw new Error(`Error: unknown builtin variable ${t}`);return n},C=(e,t)=>l.str(e)?t?.isWebGL?e:w[e]||e:"",B=e=>P[e]||e,fe=e=>{let t=O.indexOf(e);return t!==-1?G[t]:"float"},ce=e=>(e.code||(e.code={headers:new Map,fragInputs:new Map,vertInputs:new Map,vertOutputs:new Map,vertVaryings:new Map,computeInputs:new Map,dependencies:new Map,structStructFields:new Map},e.isWebGL)||(e.code.fragInputs.set("position","@builtin(position) position: vec4f"),e.code.vertOutputs.set("position","@builtin(position) position: vec4f")),e),le=e=>l.num(e)||l.str(e)&&/^\d+$/.test(e),L=(e,t="",n)=>{e.code?.dependencies?.has(t)||e.code.dependencies.set(t,new Set),V(n)||e.code.dependencies.get(t).add(n)},He=(e,t,n)=>e.isWebGL?n==="attribute"?r=>e.gl?.attribute?.(t,r):n==="instance"?r=>e.gl?.instance?.(t,r):n==="texture"?r=>e.gl?.texture?.(t,r):r=>e.gl?.uniform?.(t,r):n==="attribute"?r=>e.gl?._attribute?.(t,r):n==="instance"?r=>e.gl?._instance?.(t,r):n==="texture"?r=>e.gl?._texture?.(t,r):r=>e.gl?._uniform?.(t,r),ke=(e,t)=>{if(l.und(e))return;if(!S(e))return t(e);if(e.type!=="conversion")return;let n=e.props.children?.slice(1);l.und(n?.[0])||t(n.map(r=>r??n[0]))},z=(e,t,n,r,s)=>{let o=He(e,t,n);return ke(s,o),r.listeners.add(o),o};var qe=e=>j[e],je=(e,t,n)=>(te(e,t,n)||console.warn(`GLRE Type Warning: Invalid operator '${n}' between types '${e}' and '${t}'`),ne(e,t,n)),Ke=e=>l.bol(e)?"bool":l.str(e)?"texture":l.num(e)?"float":l.arr(e)?D[e.length]:ie(e)?"texture":"void",U=e=>{let t=D[e];if(!t)throw`glre node system error: Cannot infer type from array length ${e}. Check your data size. Supported: 1(float), 2(vec2), 3(vec3), 4(vec4), 9(mat3), 16(mat4)`;return t},de=(e,t)=>{if(e.length===0)return"void";let[n]=e;return l.str(n)?n:g(n,t)},Ze=e=>M[e],Je=(e,t)=>{let{type:n,props:r}=e,{id:s,children:o=[],inferFrom:a,layout:c}=r,[i,u,m]=o;if(n==="conversion")return i;if(n==="operator")return je(g(u,t),g(m,t),i);if(n==="builtin")return qe(s);if(n==="function")return Ze(i)||g(u,t);if(n==="define")return V(c?.type)?c?.type:!a||a.length===0?"void":de(a,t);if(n==="attribute"&&l.arr(i)){let $=W(i.length,t.gl?.count,t.gl?.error);return U($)}if(n==="instance"&&l.arr(i)){let $=W(i.length,t.gl?.instanceCount,t.gl?.error);return U($)}if(n==="member"){if(re(u))return U(u.length);if(S(i)){let $=g(i,t),h=t.code?.structStructFields?.get($);if(h&&h[u])return g(h[u],t)}return"float"}return a?de(a,t):i?g(i,t):"void"},g=(e,t)=>{if(t||(t={}),!S(e))return Ke(e);if(l.arr(e))return U(e.length);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let n=Je(e,t);return t.infers.set(e,n),n};var y=(e,t)=>e.filter(n=>!l.und(n)&&!l.nul(n)).map(n=>p(n,t)).join(", "),xe=(e,t,n,r)=>{let s=()=>{let u=g(r,e);if(u==="float")return".x";if(u==="vec2")return".xy";if(u==="vec3")return".xyz";if(u==="vec4")return"";throw new Error(`Unsupported storage scatter type: ${u}`)},o=p(n,e),a=A(e.gl?.particleCount),c=`int(${o}) % ${a.x}`,i=`int(${o}) / ${a.x}`;return`texelFetch(${p(t,e)}, ivec2(${c}, ${i}), 0)${s()}`},Te=(e,t,n)=>{let r=p(t,e),s=p(n,e),o=g(n,e);if(o==="float")return`_${r} = vec4(${s}, 0.0, 0.0, 1.0);`;if(o==="vec2")return`_${r} = vec4(${s}, 0.0, 1.0);`;if(o==="vec3")return`_${r} = vec4(${s}, 1.0);`;if(o==="vec4")return`_${r} = ${s};`;throw new Error(`Unsupported storage scatter type: ${o}`)},me=(e,t,n,r)=>{if(e.isWebGL)return`texture(${y(r?[t,n,r]:[t,n],e)})`;let s=p(t,e),o=[s,s+"Sampler",p(n,e)];return r?(o.push(p(r,e)),`textureSampleLevel(${o})`):`textureSample(${o})`},ge=(e,t,n,r)=>{let s=`if (${p(t,e)}) {
12
+ `.trim();var Y=(e=1024)=>{if(c.num(e)){let s=Math.sqrt(e),o=Math.ceil(s);return Number.isInteger(s)||console.warn(`GLRE Storage Warning: particleCount (${e}) is not a square. Using ${o}x${o} texture may waste GPU memory. Consider using [width, height] format for optimal storage.`),{x:o,y:o}}let[t,n,r]=e;if(r!==void 0){let s=n*r;return console.warn(`GLRE Storage Warning: 3D particleCount [${t}, ${n}, ${r}] specified but WebGL storage textures only support 2D. Flattening to 2D by multiplying height=${n} * depth=${r} = ${s}.`),{x:t,y:s}}return{x:t,y:n}};var oe=e=>c.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),se=e=>j.includes(e),ie=e=>te.includes(e),ae=e=>c.obj(e)?!1:e instanceof Element,ue=e=>D.includes(e),S=e=>!e||typeof e!="object"?!1:e.isProxy,z=e=>c.str(e)?w.includes(e):!1,pe=e=>{let t=(e>>16&255)/255,n=(e>>8&255)/255,r=(e&255)/255;return[t,n,r]},He=0,v=()=>`x${He++}`,fe=(e,t)=>{if(t==="global_invocation_id")return`uvec3(uint(gl_FragCoord.y) * uint(${Y(e.gl?.particleCount).x}) + uint(gl_FragCoord.x), 0u, 0u)`;let n=ee[t];if(!n)throw new Error(`Error: unknown builtin variable ${t}`);return n},C=(e,t)=>c.str(e)?t?.isWebGL?e:P[e]||e:"",H=e=>W[e]||e,le=e=>{let t=D.indexOf(e);return t!==-1?w[t]:"float"},ce=e=>(e.code||(e.code={headers:new Map,fragInputs:new Map,vertInputs:new Map,vertOutputs:new Map,vertVaryings:new Map,computeInputs:new Map,dependencies:new Map,structStructFields:new Map},e.isWebGL)||(e.code.fragInputs.set("position","@builtin(position) position: vec4f"),e.code.vertOutputs.set("position","@builtin(position) position: vec4f")),e),de=e=>c.num(e)||c.str(e)&&/^\d+$/.test(e),U=(e,t="",n)=>{e.code?.dependencies?.has(t)||e.code.dependencies.set(t,new Set),z(n)||e.code.dependencies.get(t).add(n)},ke=(e,t,n)=>e.isWebGL?n==="attribute"?e.gl?.attribute?.bind(null,t):n==="instance"?e.gl?.instance?.bind(null,t):n==="texture"?e.gl?.texture?.bind(null,t):n==="storage"?e.gl?.storage?.bind(null,t):r=>e.gl?.uniform?.(t,r):n==="attribute"?e.gl?._attribute?.bind(null,t):n==="instance"?e.gl?._instance?.bind(null,t):n==="texture"?e.gl?._texture?.bind(null,t):n==="storage"?e.gl?._storage?.bind(null,t):r=>e.gl?._uniform?.(t,r),qe=(e,t)=>{if(c.und(e))return;if(!S(e))return t(e);if(e.type!=="conversion")return;let n=e.props.children?.slice(1);if(!c.und(n?.[0])){if(c.arr(n[0])||A(n[0]))return t(n[0]);t(n.map(r=>r??n[0]))}},N=(e,t,n,r,s)=>{let o=ke(e,t,n);if(o)return qe(s,o),r.listeners.add(o),o};var je=e=>K[e],Ke=(e,t,n)=>(ne(e,t,n)||console.warn(`GLRE Type Warning: Invalid operator '${n}' between types '${e}' and '${t}'`),re(e,t,n)),Ze=e=>c.bol(e)?"bool":c.str(e)?"texture":c.num(e)?"float":c.arr(e)||A(e)?M[e.length]:ae(e)?"texture":"void",I=e=>{let t=M[e];if(!t)throw`glre node system error: Cannot infer type from array length ${e}. Check your data size. Supported: 1(float), 2(vec2), 3(vec3), 4(vec4), 9(mat3), 16(mat4)`;return t},xe=(e,t)=>{if(e.length===0)return"void";let[n]=e;return c.str(n)?n:g(n,t)},Qe=e=>V[e],Je=(e,t)=>{let{type:n,props:r}=e,{id:s,children:o=[],inferFrom:a,layout:l}=r,[i,u,m]=o;if(n==="conversion")return i;if(n==="operator")return Ke(g(u,t),g(m,t),i);if(n==="builtin")return je(s);if(n==="function")return Qe(i)||g(u,t);if(n==="define")return z(l?.type)?l?.type:!a||a.length===0?"void":xe(a,t);if(n==="attribute"&&c.arr(i)){let $=B(i.length,t.gl?.count,t.gl?.error);return I($)}if(n==="instance"&&c.arr(i)){let $=B(i.length,t.gl?.instanceCount,t.gl?.error);return I($)}if(n==="member"){if(oe(u))return I(u.length);if(S(i)){let $=g(i,t),h=t.code?.structStructFields?.get($);if(h&&h[u])return g(h[u],t)}return"float"}return a?xe(a,t):i?g(i,t):"void"},g=(e,t)=>{if(t||(t={}),!S(e))return Ze(e);if(c.arr(e))return I(e.length);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let n=Je(e,t);return t.infers.set(e,n),n};var y=(e,t)=>e.filter(n=>!c.und(n)&&!c.nul(n)).map(n=>p(n,t)).join(", "),Te=(e,t,n,r)=>{let s=()=>{let u=g(r,e);if(u==="float")return".x";if(u==="vec2")return".xy";if(u==="vec3")return".xyz";if(u==="vec4")return"";throw new Error(`Unsupported storage scatter type: ${u}`)},o=p(n,e),a=Y(e.gl?.particleCount),l=`int(${o}) % ${a.x}`,i=`int(${o}) / ${a.x}`;return`texelFetch(${p(t,e)}, ivec2(${l}, ${i}), 0)${s()}`},me=(e,t,n)=>{let r=p(t,e),s=p(n,e),o=g(n,e);if(o==="float")return`_${r} = vec4(${s}, 0.0, 0.0, 1.0);`;if(o==="vec2")return`_${r} = vec4(${s}, 0.0, 1.0);`;if(o==="vec3")return`_${r} = vec4(${s}, 1.0);`;if(o==="vec4")return`_${r} = ${s};`;throw new Error(`Unsupported storage scatter type: ${o}`)},ge=(e,t,n,r)=>{if(e.isWebGL)return`texture(${y(r?[t,n,r]:[t,n],e)})`;let s=p(t,e),o=[s,s+"Sampler",p(n,e)];return r?(o.push(p(r,e)),`textureSampleLevel(${o})`):`textureSample(${o})`},ve=(e,t,n,r)=>{let s=`if (${p(t,e)}) {
13
13
  ${p(n,e)}
14
14
  }`;for(let o=2;o<r.length;o+=2){let a=o>=r.length-1;s+=a?` else {
15
15
  ${p(r[o],e)}
16
16
  }`:` else if (${p(r[o],e)}) {
17
17
  ${p(r[o+1],e)}
18
- }`}return s},ve=(e,t,n)=>{let r=`switch (${p(t,e)}) {
18
+ }`}return s},be=(e,t,n)=>{let r=`switch (${p(t,e)}) {
19
19
  `;for(let s=1;s<n.length;s+=2)s>=n.length-1&&n.length%2===0?r+=`default:
20
20
  ${p(n[s],e)}
21
21
  break;
22
22
  `:s+1<n.length&&(r+=`case ${p(n[s],e)}:
23
23
  ${p(n[s+1],e)}
24
24
  break;
25
- `);return r+="}",r},be=(e,t,n)=>{let r=g(t,e),s=n?.props?.id;if(e.isWebGL)return`${r} ${s} = ${p(t,e)};`;let o=C(r);return`var ${s}: ${o} = ${p(t,e)};`},$e=(e,t,n={})=>{e.code?.structStructFields?.set(t,n);let r=[];for(let o in n){let a=n[o],c=g(a,e);e.isWebGL&&L(e,t,c),r.push(e.isWebGL?`${c} ${o};`:`${o}: ${C(c,e)},`)}let s=r.join(`
25
+ `);return r+="}",r},$e=(e,t,n)=>{let r=g(t,e),s=n?.props?.id;if(e.isWebGL)return`${r} ${s} = ${p(t,e)};`;let o=C(r);return`var ${s}: ${o} = ${p(t,e)};`},he=(e,t,n={})=>{e.code?.structStructFields?.set(t,n);let r=[];for(let o in n){let a=n[o],l=g(a,e);e.isWebGL&&U(e,t,l),r.push(e.isWebGL?`${l} ${o};`:`${o}: ${C(l,e)},`)}let s=r.join(`
26
26
  `);return`struct ${t} {
27
27
  ${s}
28
- };`},he=(e,t,n="",r)=>{let s=e.code?.structStructFields?.get(t)||{};if(e.isWebGL)if(r){let o=[];for(let a in s)o.push(r[a]);return`${t} ${n} = ${t}(${y(o,e)});`}else return`${t} ${n};`;else if(r){let o=[];for(let a in s)o.push(r[a]);return`var ${n}: ${t} = ${t}(${y(o,e)});`}else return`var ${n}: ${t};`},Ce=(e,t,n)=>{let{id:r,children:s=[],layout:o}=t,[a,...c]=s,i=[],u=[];for(let x=0;x<c.length;x++){let E=o?.inputs?.[x];E?i.push([E.name,E.type==="auto"?g(c[x],e):E.type]):i.push([`p${x}`,g(c[x],e)])}let m=p(a,e),$=g(n,e),h=[];if(e?.isWebGL){for(let[x,E]of i)L(e,r,E),u.push(`${E} ${x}`);L(e,r,$),h.push(`${$} ${r}(${u}) {`)}else{for(let[E,Me]of i)u.push(`${E}: ${C(Me,e)}`);$==="void"?h.push(`fn ${r}(${u}) {`):h.push(`fn ${r}(${u}) -> ${C($,e)} {`)}return m&&h.push(m),h.push("}"),h.join(`
29
- `)},Ee=(e,t,n)=>e.isWebGL?`${n} ${t};`:`@location(${e.code?.vertVaryings?.size||0}) ${t}: ${C(n,e)}`,_e=(e,t,n)=>{if(e.isWebGL)return`${n} ${t};`;let{location:r=0}=e.gl?.webgpu?.attribs.map.get(t)||{},s=C(n,e);return`@location(${r}) ${t}: ${s}`},ye=(e,t,n)=>{let r=n==="sampler2D"||n==="texture";if(e.isWebGL)return r?`uniform sampler2D ${t};`:`uniform ${n} ${t};`;if(r){let{group:c=1,binding:i=0}=e.gl?.webgpu?.textures.map.get(t)||{};return`@group(${c}) @binding(${i}) var ${t}Sampler: sampler;
30
- @group(${c}) @binding(${i+1}) var ${t}: texture_2d<f32>;`}let{group:s=0,binding:o=0}=e.gl?.webgpu?.uniforms.map.get(t)||{},a=C(n,e);return`@group(${s}) @binding(${o}) var<uniform> ${t}: ${a};`},Xe=(e,t,n)=>{if(e.isWebGL){let a=`uniform sampler2D ${t};`;if(e.label!=="compute")return a;let c=e.units?.(t);return`${a}
31
- layout(location = ${c}) out vec4 _${t};`}let{group:r=0,binding:s=0}=e.gl?.webgpu?.storages.map.get(t)||{},o=C(n,e);return`@group(${r}) @binding(${s}) var<storage, read_write> ${t}: array<${o}>;`},Se=(e,t,n,r)=>{let s=g(t,e),o=p(n,e),a=p(t,e);return e.isWebGL?s==="int"?`for (int ${r} = 0; ${r} < ${a}; ${r} += 1) {
28
+ };`},Ce=(e,t,n="",r)=>{let s=e.code?.structStructFields?.get(t)||{};if(e.isWebGL)if(r){let o=[];for(let a in s)o.push(r[a]);return`${t} ${n} = ${t}(${y(o,e)});`}else return`${t} ${n};`;else if(r){let o=[];for(let a in s)o.push(r[a]);return`var ${n}: ${t} = ${t}(${y(o,e)});`}else return`var ${n}: ${t};`},Ee=(e,t,n)=>{let{id:r,children:s=[],layout:o}=t,[a,...l]=s,i=[],u=[];for(let x=0;x<l.length;x++){let E=o?.inputs?.[x];E?i.push([E.name,E.type==="auto"?g(l[x],e):E.type]):i.push([`p${x}`,g(l[x],e)])}let m=p(a,e),$=g(n,e),h=[];if(e?.isWebGL){for(let[x,E]of i)U(e,r,E),u.push(`${E} ${x}`);U(e,r,$),h.push(`${$} ${r}(${u}) {`)}else{for(let[E,Me]of i)u.push(`${E}: ${C(Me,e)}`);$==="void"?h.push(`fn ${r}(${u}) {`):h.push(`fn ${r}(${u}) -> ${C($,e)} {`)}return m&&h.push(m),h.push("}"),h.join(`
29
+ `)},_e=(e,t,n)=>e.isWebGL?`${n} ${t};`:`@location(${e.code?.vertVaryings?.size||0}) ${t}: ${C(n,e)}`,ye=(e,t,n)=>{if(e.isWebGL)return`${n} ${t};`;let{location:r=0}=e.binding?.attrib(t)||{},s=C(n,e);return`@location(${r}) ${t}: ${s}`},Xe=(e,t,n)=>{let r=n==="sampler2D"||n==="texture";if(e.isWebGL)return r?`uniform sampler2D ${t};`:`uniform ${n} ${t};`;if(r){let{group:l=1,binding:i=0}=e.binding?.texture(t)||{};return`@group(${l}) @binding(${i}) var ${t}Sampler: sampler;
30
+ @group(${l}) @binding(${i+1}) var ${t}: texture_2d<f32>;`}let{group:s=0,binding:o=0}=e.binding?.uniform(t)||{},a=C(n,e);return`@group(${s}) @binding(${o}) var<uniform> ${t}: ${a};`},Se=(e,t,n)=>{if(e.isWebGL){let a=`uniform sampler2D ${t};`;if(e.label!=="compute")return a;let l=e.units?.(t);return`${a}
31
+ layout(location = ${l}) out vec4 _${t};`}let{group:r=0,binding:s=0}=e.binding?.storage(t)||{},o=C(n,e);return`@group(${r}) @binding(${s}) var<storage, read_write> ${t}: array<${o}>;`},Re=(e,t,n,r)=>{let s=g(t,e),o=p(n,e),a=p(t,e);return e.isWebGL?s==="int"?`for (int ${r} = 0; ${r} < ${a}; ${r} += 1) {
32
32
  ${o}
33
33
  }`:s==="float"?`for (float ${r} = 0.0; ${r} < ${a}; ${r} += 1.0) {
34
34
  ${o}
@@ -48,18 +48,18 @@ ${o}
48
48
  ${o}
49
49
  }`:`for (var ${r}: i32 = 0; ${r} < ${a}; ${r}++) {
50
50
  ${o}
51
- }`},Re=(e,t,n,r)=>e.isWebGL?`const ${n} ${t} = ${r};`:`const ${t}: ${C(n,e)} = ${r};`;var p=(e,t)=>{if(t||(t={}),ce(t),l.arr(e))return y(e,t);if(l.str(e))return e;if(l.num(e)){let x=`${e}`;return x.includes(".")?x:x+".0"}if(l.bol(e))return e?"true":"false";if(!e||!S(e))return"";let{type:n,props:r={}}=e,{id:s="i",children:o=[],fields:a,initialValues:c}=r,[i,u,m,$]=o;if(n==="variable")return s;if(n==="member")return`${p(i,t)}.${p(u,t)}`;if(n==="element")return`${p(i,t)}[${p(u,t)}]`;if(n==="gather")return t.isWebGL?xe(t,i,u,e):`${p(i,t)}[${p(u,t)}]`;if(n==="scatter"){let[x,E]=i.props.children??[];return t.isWebGL?Te(t,x,u):`${p(x,t)}[${p(E,t)}] = ${p(u,t)};`}if(n==="ternary")return t.isWebGL?`(${p(m,t)} ? ${p(i,t)} : ${p(u,t)})`:`select(${p(i,t)}, ${p(u,t)}, ${p(m,t)})`;if(n==="conversion")return`${C(i,t)}(${y(o.slice(1),t)})`;if(n==="operator")return i==="not"||i==="bitNot"?`!${p(u,t)}`:i==="mod"?p(Fe(u,m),t):i.endsWith("Assign")?`${p(u,t)} ${B(i)} ${p(m,t)};`:`(${p(u,t)} ${B(i)} ${p(m,t)})`;if(n==="function"){if(i==="negate")return`(-${p(u,t)})`;if(i==="reciprocal")return`(1.0 / ${p(u,t)})`;if(i==="oneMinus")return`(1.0-${p(u,t)})`;if(i==="saturate")return`clamp(${p(u,t)}, 0.0, 1.0)`;if(i==="texture")return me(t,u,m,$);if(i==="atan2"&&t.isWebGL)return`atan(${p(u,t)}, ${p(m,t)})`;if(!t.isWebGL){if(i==="dFdx")return`dpdx(${p(u,t)})`;if(i==="dFdy")return`dpdy(${p(u,t)})`}return`${i}(${y(o.slice(1),t)})`}if(n==="scope")return o.map(x=>p(x,t)).join(`
52
- `);if(n==="assign")return`${p(i,t)} = ${p(u,t)};`;if(n==="return")return`return ${p(i,t)};`;if(n==="break")return"break;";if(n==="continue")return"continue;";if(n==="loop")return Se(t,i,u,s);if(n==="if")return ge(t,i,u,o);if(n==="switch")return ve(t,i,o);if(n==="declare")return be(t,i,u);if(n==="define")return t.code?.headers.has(s)||t.code?.headers.set(s,Ce(t,r,e)),`${s}(${y(o.slice(1),t)})`;if(n==="struct")return t.code?.headers.has(s)||t.code?.headers.set(s,$e(t,s,a)),he(t,s,i.props.id,c);if(n==="varying"){if(t.code?.vertOutputs.has(s))return t.isWebGL?`${s}`:`out.${s}`;let x=Ee(t,s,g(e,t));return t.code?.fragInputs.set(s,x),t.code?.vertOutputs.set(s,x),t.code?.vertVaryings.set(s,{node:i}),t.isWebGL?`${s}`:`out.${s}`}if(n==="builtin"){if(t.isWebGL)return pe(t,s);if(s==="position")return"out.position";let x=`@builtin(${s}) ${s}: ${C(g(e,t),t)}`;return t.label==="compute"?t.code?.computeInputs.set(s,x):t.label==="frag"?t.code?.fragInputs.set(s,x):t.label==="vert"&&t.code?.vertInputs.set(s,x),`in.${s}`}if(n==="attribute"||n==="instance")return z(t,s,n,e,i),t.code?.vertInputs.set(s,_e(t,s,g(e,t))),t.isWebGL?`${s}`:`in.${s}`;if(t.code?.headers.has(s))return s;let h="";if(n==="uniform"){let x=g(e,t);z(t,s,x,e,i),h=ye(t,s,x)}return n==="storage"&&(h=Xe(t,s,g(e,t))),n==="constant"&&(h=Re(t,s,g(e,t),p(i,t))),h?(t.code?.headers.set(s,h),s):p(i,t)};var Qe=(e,t)=>{let n=[],r=new Set,s=new Set,o=a=>{if(s.has(a)||r.has(a))return;s.add(a);let c=t.get(a)||new Set;for(let i of c)e.has(i)&&o(i);s.delete(a),r.add(a),e.has(a)&&n.push([a,e.get(a)])};for(let[a]of e)o(a);return n},H=(e,t)=>{let n=p(e,t),r="";t.isWebGL&&t.code?.dependencies?r=Qe(t.code.headers,t.code.dependencies).map(([,c])=>c).join(`
51
+ }`},Le=(e,t,n,r)=>e.isWebGL?`const ${n} ${t} = ${r};`:`const ${t}: ${C(n,e)} = ${r};`;var p=(e,t)=>{if(t||(t={}),ce(t),c.arr(e))return y(e,t);if(c.str(e))return e;if(c.num(e)){let x=`${e}`;return x.includes(".")?x:x+".0"}if(c.bol(e))return e?"true":"false";if(!e||!S(e))return"";let{type:n,props:r={}}=e,{id:s="i",children:o=[],fields:a,initialValues:l}=r,[i,u,m,$]=o;if(n==="variable")return s;if(n==="member")return`${p(i,t)}.${p(u,t)}`;if(n==="element")return`${p(i,t)}[${p(u,t)}]`;if(n==="gather")return t.isWebGL?Te(t,i,u,e):`${p(i,t)}[${p(u,t)}]`;if(n==="scatter"){let[x,E]=i.props.children??[];return t.isWebGL?me(t,x,u):`${p(x,t)}[${p(E,t)}] = ${p(u,t)};`}if(n==="ternary")return t.isWebGL?`(${p(m,t)} ? ${p(i,t)} : ${p(u,t)})`:`select(${p(i,t)}, ${p(u,t)}, ${p(m,t)})`;if(n==="conversion")return`${C(i,t)}(${y(o.slice(1),t)})`;if(n==="operator")return i==="not"||i==="bitNot"?`!${p(u,t)}`:i==="mod"?p(Fe(u,m),t):i.endsWith("Assign")?`${p(u,t)} ${H(i)} ${p(m,t)};`:`(${p(u,t)} ${H(i)} ${p(m,t)})`;if(n==="function"){if(i==="negate")return`(-${p(u,t)})`;if(i==="reciprocal")return`(1.0 / ${p(u,t)})`;if(i==="oneMinus")return`(1.0-${p(u,t)})`;if(i==="saturate")return`clamp(${p(u,t)}, 0.0, 1.0)`;if(i==="texture")return ge(t,u,m,$);if(i==="atan2"&&t.isWebGL)return`atan(${p(u,t)}, ${p(m,t)})`;if(!t.isWebGL){if(i==="dFdx")return`dpdx(${p(u,t)})`;if(i==="dFdy")return`dpdy(${p(u,t)})`}return`${i}(${y(o.slice(1),t)})`}if(n==="scope")return o.map(x=>p(x,t)).join(`
52
+ `);if(n==="assign")return`${p(i,t)} = ${p(u,t)};`;if(n==="return")return`return ${p(i,t)};`;if(n==="break")return"break;";if(n==="continue")return"continue;";if(n==="loop")return Re(t,i,u,s);if(n==="if")return ve(t,i,u,o);if(n==="switch")return be(t,i,o);if(n==="declare")return $e(t,i,u);if(n==="define")return t.code?.headers.has(s)||t.code?.headers.set(s,Ee(t,r,e)),`${s}(${y(o.slice(1),t)})`;if(n==="struct")return t.code?.headers.has(s)||t.code?.headers.set(s,he(t,s,a)),Ce(t,s,i.props.id,l);if(n==="varying"){if(t.code?.vertOutputs.has(s))return t.isWebGL?`${s}`:`out.${s}`;let x=_e(t,s,g(e,t));return t.code?.fragInputs.set(s,x),t.code?.vertOutputs.set(s,x),t.code?.vertVaryings.set(s,{node:i}),t.isWebGL?`${s}`:`out.${s}`}if(n==="builtin"){if(t.isWebGL)return fe(t,s);if(s==="position")return"out.position";let x=`@builtin(${s}) ${s}: ${C(g(e,t),t)}`;return t.label==="compute"?t.code?.computeInputs.set(s,x):t.label==="frag"?t.code?.fragInputs.set(s,x):t.label==="vert"&&t.code?.vertInputs.set(s,x),`in.${s}`}if(n==="attribute"||n==="instance")return N(t,s,n,e,i),t.code?.vertInputs.set(s,ye(t,s,g(e,t))),t.isWebGL?`${s}`:`in.${s}`;if(t.code?.headers.has(s))return s;let h="";if(n==="uniform"){let x=g(e,t);N(t,s,x,e,i),h=Xe(t,s,x)}return n==="storage"&&(N(t,s,n,e,i),h=Se(t,s,g(e,t))),n==="constant"&&(h=Le(t,s,g(e,t),p(i,t))),h?(t.code?.headers.set(s,h),s):p(i,t)};var et=(e,t)=>{let n=[],r=new Set,s=new Set,o=a=>{if(s.has(a)||r.has(a))return;s.add(a);let l=t.get(a)||new Set;for(let i of l)e.has(i)&&o(i);s.delete(a),r.add(a),e.has(a)&&n.push([a,e.get(a)])};for(let[a]of e)o(a);return n},k=(e,t)=>{let n=p(e,t),r="";t.isWebGL&&t.code?.dependencies?r=et(t.code.headers,t.code.dependencies).map(([,l])=>l).join(`
53
53
  `):r=Array.from(t.code?.headers?.values()||[]).join(`
54
- `);let[s,o]=n.split("return ");return o?o=o.replace(";",""):[s,o]=["",n],[r,s.trim(),o]},I=(e,t)=>`struct ${e} {
54
+ `);let[s,o]=n.split("return ");return o?o=o.replace(";",""):[s,o]=["",n],[r,s.trim(),o]},O=(e,t)=>`struct ${e} {
55
55
  ${Array.from(t.values()).join(`,
56
56
  `)}
57
- }`,Ye=(e,t="highp")=>{e.push(`precision ${t} float;`),e.push(`precision ${t} int;`),e.push(`precision ${t} sampler2D;`),e.push(`precision ${t} samplerCube;`),e.push(`precision ${t} sampler3D;`),e.push(`precision ${t} sampler2DArray;`),e.push(`precision ${t} sampler2DShadow;`),e.push(`precision ${t} samplerCubeShadow;`),e.push(`precision ${t} sampler2DArrayShadow;`),e.push(`precision ${t} isampler2D;`),e.push(`precision ${t} isampler3D;`),e.push(`precision ${t} isamplerCube;`),e.push(`precision ${t} isampler2DArray;`),e.push(`precision ${t} usampler2D;`),e.push(`precision ${t} usampler3D;`),e.push(`precision ${t} usamplerCube;`),e.push(`precision ${t} usampler2DArray;`)},et=(e,t="highp")=>{if(!e)return"highp";if(t==="highp"){let n=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT),r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);if(n&&n.precision>0&&r&&r.precision>0)return"highp";t="mediump"}if(t==="mediump"){let n=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT),r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT);if(n&&n.precision>0&&r&&r.precision>0)return"mediump";t="lowp"}return"lowp"},Ae=(e,t={})=>{t.code?.headers?.clear(),t.label="frag";let[n,r,s]=H(e,t),o=[];if(t.isWebGL){o.push("#version 300 es"),Ye(o,et(t.gl?.webgl?.context,t.gl?.precision)),o.push("out vec4 fragColor;");for(let c of t.code?.fragInputs?.values()||[])o.push(`in ${c}`);o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` fragColor = ${s};`)}else t.code?.fragInputs?.size&&o.push(I("Out",t.code.fragInputs)),o.push(n),o.push(`@fragment
57
+ }`,tt=["float","int","sampler2D","samplerCube","sampler3D","sampler2DArray","sampler2DShadow","samplerCubeShadow","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray"],Ae=(e,t="highp")=>{for(let n of tt)e.push(`precision ${t} ${n};`)},nt=(e,t="highp")=>{if(!e)return"highp";if(t==="highp"){let n=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT),r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);if(n&&n.precision>0&&r&&r.precision>0)return"highp";t="mediump"}if(t==="mediump"){let n=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT),r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT);if(n&&n.precision>0&&r&&r.precision>0)return"mediump"}return"lowp"},Ye=(e,t={})=>{t.code?.headers?.clear(),t.label="frag";let[n,r,s]=k(e,t),o=[];if(t.isWebGL){o.push("#version 300 es"),Ae(o,nt(t.gl?.gl,t.gl?.precision)),o.push("out vec4 fragColor;");for(let l of t.code?.fragInputs?.values()||[])o.push(`in ${l}`);o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` fragColor = ${s};`)}else t.code?.fragInputs?.size&&o.push(O("Out",t.code.fragInputs)),o.push(n),o.push(`@fragment
58
58
  fn main(out: Out) -> @location(0) vec4f {`),o.push(` ${r}`),o.push(` return ${s};`);o.push("}");let a=o.filter(Boolean).join(`
59
59
  `).trim();return t.gl?.isDebug&&console.log(`\u2193\u2193\u2193generated\u2193\u2193\u2193
60
- ${a}`),a},Le=(e,t={})=>{if(t.code?.headers?.clear(),t.label="vert",t.code)for(let[c,{node:i}]of t.code.vertVaryings.entries())t.code.vertVaryings.set(c,{node:i,code:p(i,t)});let[n,r,s]=H(e,t),o=[];if(t.isWebGL){o.push("#version 300 es");for(let c of t.code?.vertInputs?.values()||[])o.push(`in ${c}`);for(let c of t.code?.vertOutputs?.values()||[])o.push(`out ${c}`);if(o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` gl_Position = ${s};`),t.code)for(let[c,i]of t.code.vertVaryings.entries())o.push(` ${c} = ${i.code};`)}else{if(t.code?.vertInputs?.size&&o.push(I("In",t.code.vertInputs)),t.code?.vertOutputs?.size&&o.push(I("Out",t.code.vertOutputs)),o.push(n),o.push("@vertex"),o.push(`fn main(${t.code?.vertInputs?.size?"in: In":""}) -> Out {`),o.push(" var out: Out;"),o.push(` ${r}`),o.push(` out.position = ${s};`),t.code)for(let[c,i]of t.code.vertVaryings.entries())o.push(` out.${c} = ${i.code};`);o.push(" return out;")}o.push("}");let a=o.filter(Boolean).join(`
60
+ ${a}`),a},Ue=(e,t={})=>{if(t.code?.headers?.clear(),t.label="vert",t.code)for(let[l,{node:i}]of t.code.vertVaryings.entries())t.code.vertVaryings.set(l,{node:i,code:p(i,t)});let[n,r,s]=k(e,t),o=[];if(t.isWebGL){o.push("#version 300 es");for(let l of t.code?.vertInputs?.values()||[])o.push(`in ${l}`);for(let l of t.code?.vertOutputs?.values()||[])o.push(`out ${l}`);if(o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` gl_Position = ${s};`),t.code)for(let[l,i]of t.code.vertVaryings.entries())o.push(` ${l} = ${i.code};`)}else{if(t.code?.vertInputs?.size&&o.push(O("In",t.code.vertInputs)),t.code?.vertOutputs?.size&&o.push(O("Out",t.code.vertOutputs)),o.push(n),o.push("@vertex"),o.push(`fn main(${t.code?.vertInputs?.size?"in: In":""}) -> Out {`),o.push(" var out: Out;"),o.push(` ${r}`),o.push(` out.position = ${s};`),t.code)for(let[l,i]of t.code.vertVaryings.entries())o.push(` out.${l} = ${i.code};`);o.push(" return out;")}o.push("}");let a=o.filter(Boolean).join(`
61
61
  `).trim();return t.gl?.isDebug&&console.log(`\u2193\u2193\u2193generated\u2193\u2193\u2193
62
- ${a}`),a},Ue=(e,t={})=>{t.code?.headers?.clear(),t.label="compute";let[n,r,s]=H(e,t),o=[];t.isWebGL?(o.push("#version 300 es"),Ye(o,"highp"),o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` ${s};`),o.push("}")):(t.code?.computeInputs?.size&&o.push(I("In",t.code.computeInputs)),o.push(n),o.push("@compute @workgroup_size(32)"),o.push(`fn main(${t.code?.computeInputs?.size?"in: In":""}) {`),o.push(` ${r}`),o.push(` ${s};`),o.push("}"));let a=o.filter(Boolean).join(`
62
+ ${a}`),a},Ne=(e,t={})=>{t.code?.headers?.clear(),t.label="compute";let[n,r,s]=k(e,t),o=[];t.isWebGL?(o.push("#version 300 es"),Ae(o,"highp"),o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` ${s};`),o.push("}")):(t.code?.computeInputs?.size&&o.push(O("In",t.code.computeInputs)),o.push(n),o.push("@compute @workgroup_size(32)"),o.push(`fn main(${t.code?.computeInputs?.size?"in: In":""}) {`),o.push(` ${r}`),o.push(` ${s};`),o.push("}"));let a=o.filter(Boolean).join(`
63
63
  `).trim();return t.gl?.isDebug&&console.log(`\u2193\u2193\u2193generated\u2193\u2193\u2193
64
- ${a}`),a};var X=null,R=null,_=e=>{if(!X)return;if(X.props.children||(X.props.children=[]),X.props.children.push(e),e.type!=="return"||!R)return e;let{props:t}=R;return t.inferFrom||(t.inferFrom=[]),t.inferFrom.push(e),e};function Ie(e,t){t||(t=v());let n=d("variable",{id:t,inferFrom:[e]}),r=d("declare",null,e,n);return _(r),n}var Ne=(e,t=!1,n)=>{let r=d(t?"scatter":"assign",null,e,n);return _(r),e},tt=e=>_(d("return",{inferFrom:[e]},e)),Vt=()=>_(d("break")),Bt=()=>_(d("continue")),zt=(e,t=v())=>(n={},r=v())=>{let s=d("variable",{id:r,inferFrom:[t]}),o=d("struct",{id:t,fields:e,initialValues:n},s);return _(o),s},Oe=(e,t,n=R)=>{let[r,s]=[X,R];[X,R]=[e,n];let o=t();o&&tt(o),[X,R]=[r,s]},F=e=>{let t=d("scope");return Oe(t,e),t},Ht=(e,t)=>{let n=F(t),r=d("if",null,e,n);_(r);let s=()=>({ElseIf:(o,a)=>{let c=F(a);return r.props.children.push(o,c),s()},Else:o=>{let a=F(o);r.props.children.push(a)}});return s()},kt=(e,t)=>{let n=v(),r=F(()=>t({i:d("variable",{id:n,inferFrom:[T("int",0)]})})),s=d("loop",{id:n},e,r);return _(s)},qt=e=>{let t=d("switch",null,e);_(t);let n=()=>({Case:(...r)=>s=>{let o=F(s);for(let a of r)t.props.children.push(a,o);return n()},Default:r=>{let s=F(r);t.props.children.push(s)}});return n()};function jt(e,t){let n=v(),r=(...s)=>{let o=t?.name||n,a=[],c=[];for(let m=0;m<s.length;m++){let $=t?.inputs?.[m];$?c.push({id:$.name,inferFrom:$.type==="auto"?[s[m]]:[T($.type,s[m])]}):c.push({id:`p${m}`,inferFrom:[s[m]]})}for(let m of c)a.push(d("variable",m));let i=d("scope"),u=d("define",{id:o,layout:t},i,...s);return Oe(i,()=>e(a),u),u};return r.getLayout=()=>t,r.setLayout=s=>(t=s,r),r}var nt=(e,t)=>{if(t==="string")return p(e,null)},d=(e,t,...n)=>{t||(t={}),n.length&&(t.children=n);let r=new Set,s=(c,i)=>{if(i==="type")return e;if(i==="props")return t;if(i==="toVar")return Ie.bind(null,a);if(i==="isProxy")return!0;if(i==="toString")return p.bind(null,a);if(i==="fragment")return Ae.bind(null,a);if(i==="compute")return Ue.bind(null,a);if(i==="vertex")return Le.bind(null,a);if(i===Symbol.toPrimitive)return nt.bind(null,a);if(i==="listeners")return r;if(i==="attribute")return(u=v())=>rt(a,u);if(i==="instance")return(u=v())=>ot(a,u);if(i==="constant")return(u=v())=>st(a,u);if(i==="uniform")return(u=v())=>Y(a,u);if(i==="variable")return(u=v())=>it(u);if(i==="builtin")return(u=v())=>b(u);if(i==="vertexStage")return(u=v())=>at(a,u);if(i==="element")return u=>e==="storage"?ut(a,u):we(a,u);if(i==="member")return u=>k(a,u);if(i==="assign")return Ne.bind(null,a,a.type==="gather");if(i==="select")return pt.bind(null,a);if(oe(i))return i.endsWith("Assign")?(...u)=>_(Ge(i,a,...u)):(...u)=>Ge(i,a,...u);if(se(i))return(...u)=>f(i,a,...u);if(ae(i))return()=>T(fe(i),a);if(l.str(i))return le(i)?we(a,i):k(a,i)},o=(c,i,u)=>(i==="value"&&r.forEach(m=>m(u)),l.str(i)&&k(a,i).assign(u),!0),a=new Proxy({},{get:s,set:o});return a},rt=(e,t=v())=>d("attribute",{id:t},e),ot=(e,t=v())=>d("instance",{id:t},e),st=(e,t=v())=>d("constant",{id:t},e),Y=(e,t=v())=>d("uniform",{id:t},e),tn=(e,t=v())=>d("storage",{id:t},e),it=(e=v())=>d("variable",{id:e}),b=(e=v())=>d("builtin",{id:e}),at=(e,t=v())=>d("varying",{id:t,inferFrom:[e]},e),k=(e,t)=>d("member",null,e,t),we=(e,t)=>d("element",null,e,t),ut=(e,t)=>d("gather",null,e,t),nn=(e,t)=>d("scatter",null,e,t),pt=(e,t,n)=>d("ternary",null,e,t,n),Ge=(e,...t)=>d("operator",null,e,...t),f=(e,...t)=>d("function",null,e,...t),T=(e,...t)=>d("conversion",null,e,...t);var ft=b("position"),un=b("vertex_index"),pn=b("instance_index"),fn=b("front_facing"),cn=b("frag_depth"),ln=b("sample_index"),dn=b("sample_mask"),xn=b("point_coord"),Tn=b("global_invocation_id"),mn=b("position"),gn=b("positionWorld"),vn=b("positionView"),bn=b("normalLocal"),$n=b("normalWorld"),hn=b("normalView"),Cn=b("screenCoordinate"),En=b("screenUV"),ct=e=>T("float",e),_n=e=>T("int",e),yn=e=>T("uint",e),Xn=e=>T("bool",e),De=(e,t)=>T("vec2",e,t),Pe=(e,t,n)=>T("vec3",e,t,n),Sn=(e,t,n,r)=>T("vec4",e,t,n,r),Rn=(...e)=>T("mat2",...e),Fn=(...e)=>T("mat3",...e),Yn=(...e)=>T("mat4",...e),An=(e,t)=>T("ivec2",e,t),Ln=(e,t,n)=>T("ivec3",e,t,n),Un=(e,t,n,r)=>T("ivec4",e,t,n,r),In=(e,t)=>T("uvec2",e,t),Nn=(e,t,n)=>T("uvec3",e,t,n),On=(e,t,n,r)=>T("uvec4",e,t,n,r),wn=(e,t)=>T("bvec2",e,t),Gn=(e,t,n)=>T("bvec3",e,t,n),Pn=(e,t,n,r)=>T("bvec4",e,t,n,r),Dn=e=>T("texture",e),Mn=()=>T("sampler2D"),Wn=(e,t,n)=>l.num(e)&&l.und(t)&&l.und(n)?Pe(...ue(e)):Pe(e,t,n),lt=Y(De(),"iResolution"),Vn=Y(De(),"iMouse"),Bn=Y(ct(),"iTime"),zn=ft.xy.div(lt),Hn=e=>f("all",e),kn=e=>f("any",e),qn=e=>f("determinant",e),jn=(e,t)=>f("distance",e,t),Kn=(e,t)=>f("dot",e,t),Zn=e=>f("length",e),Jn=e=>f("lengthSq",e),Qn=e=>f("luminance",e),er=(e,t)=>f("cross",e,t),tr=(e,t,n)=>f("cubeTexture",e,t,n),nr=(e,t,n)=>f("texture",e,t,n),rr=(e,t,n)=>f("texelFetch",e,t,n),or=(e,t,n)=>f("textureLod",e,t,n),sr=e=>f("abs",e),ir=e=>f("acos",e),ar=e=>f("acosh",e),ur=e=>f("asin",e),pr=e=>f("asinh",e),fr=e=>f("atan",e),cr=e=>f("atanh",e),lr=e=>f("ceil",e),dr=e=>f("cos",e),xr=e=>f("cosh",e),Tr=e=>f("dFdx",e),mr=e=>f("dFdy",e),gr=e=>f("degrees",e),vr=e=>f("exp",e),br=e=>f("exp2",e),$r=e=>f("floor",e),hr=e=>f("fract",e),Cr=e=>f("fwidth",e),Er=e=>f("inverseSqrt",e),_r=e=>f("log",e),yr=e=>f("log2",e),Xr=e=>f("negate",e),Sr=e=>f("normalize",e),Rr=e=>f("oneMinus",e),Fr=e=>f("radians",e),Yr=e=>f("reciprocal",e),Ar=e=>f("round",e),Lr=e=>f("sign",e),Ur=e=>f("sin",e),Ir=e=>f("sinh",e),Nr=e=>f("sqrt",e),Or=e=>f("tan",e),wr=e=>f("tanh",e),Gr=e=>f("trunc",e),Pr=(e,t)=>f("atan2",e,t),Dr=(e,t,n)=>f("clamp",e,t,n),Mr=(e,t)=>f("max",e,t),Wr=(e,t)=>f("min",e,t),Vr=(e,t,n)=>f("mix",e,t,n),Br=(e,t)=>f("pow",e,t),zr=(e,t)=>f("reflect",e,t),Hr=(e,t,n)=>f("refract",e,t,n),kr=(e,t,n)=>f("smoothstep",e,t,n),qr=(e,t)=>f("step",e,t),Fe=(e,t)=>e.sub(e.div(t).floor().mul(t));export{Vt as Break,Bt as Continue,jt as Fn,Ht as If,kt as Loop,tt as Return,F as Scope,qt as Switch,sr as abs,ir as acos,ar as acosh,_ as addToScope,Hn as all,kn as any,ur as asin,pr as asinh,Ne as assign,fr as atan,Pr as atan2,cr as atanh,rt as attribute,Xn as bool,b as builtin,wn as bvec2,Gn as bvec3,Pn as bvec4,lr as ceil,Dr as clamp,Wn as color,Ue as compute,st as constant,T as conversion,dr as cos,xr as cosh,d as create,er as cross,tr as cubeTexture,Tr as dFdx,mr as dFdy,gr as degrees,qn as determinant,jn as distance,Kn as dot,we as element,vr as exp,br as exp2,ct as float,$r as floor,hr as fract,cn as fragDepth,Ae as fragment,fn as frontFacing,f as function_,Cr as fwidth,ut as gather,Vn as iMouse,lt as iResolution,Bn as iTime,Tn as id,ot as instance,pn as instanceIndex,_n as int,Er as inverseSqrt,An as ivec2,Ln as ivec3,Un as ivec4,Zn as length,Jn as lengthSq,_r as log,yr as log2,Qn as luminance,Rn as mat2,Fn as mat3,Yn as mat4,Mr as max,k as member,Wr as min,Vr as mix,Fe as mod,Xr as negate,bn as normalLocal,hn as normalView,$n as normalWorld,Sr as normalize,Rr as oneMinus,Ge as operator,xn as pointCoord,ft as position,mn as positionLocal,vn as positionView,gn as positionWorld,Br as pow,Fr as radians,Yr as reciprocal,zr as reflect,Hr as refract,Ar as round,ln as sampleIndex,dn as sampleMask,Mn as sampler2D,nn as scatter,Oe as scoped,Cn as screenCoordinate,En as screenUV,pt as select,Lr as sign,Ur as sin,Ir as sinh,kr as smoothstep,Nr as sqrt,qr as step,tn as storage,zt as struct,Or as tan,wr as tanh,rr as texelFetch,nr as texture,Dn as texture2D,or as textureLod,Ie as toVar,Gr as trunc,yn as uint,Y as uniform,zn as uv,In as uvec2,Nn as uvec3,On as uvec4,it as variable,De as vec2,Pe as vec3,Sn as vec4,Le as vertex,un as vertexIndex,at as vertexStage};
64
+ ${a}`),a};var X=null,R=null,_=e=>{if(!X)return;if(X.props.children||(X.props.children=[]),X.props.children.push(e),e.type!=="return"||!R)return e;let{props:t}=R;return t.inferFrom||(t.inferFrom=[]),t.inferFrom.push(e),e};function Ie(e,t){t||(t=v());let n=d("variable",{id:t,inferFrom:[e]}),r=d("declare",null,e,n);return _(r),n}var Oe=(e,t=!1,n)=>{let r=d(t?"scatter":"assign",null,e,n);return _(r),e},rt=e=>_(d("return",{inferFrom:[e]},e)),zt=()=>_(d("break")),Ht=()=>_(d("continue")),kt=(e,t=v())=>(n={},r=v())=>{let s=d("variable",{id:r,inferFrom:[t]}),o=d("struct",{id:t,fields:e,initialValues:n},s);return _(o),s},Ge=(e,t,n=R)=>{let[r,s]=[X,R];[X,R]=[e,n];let o=t();o&&rt(o),[X,R]=[r,s]},L=e=>{let t=d("scope");return Ge(t,e),t},qt=(e,t)=>{let n=L(t),r=d("if",null,e,n);_(r);let s=()=>({ElseIf:(o,a)=>{let l=L(a);return r.props.children.push(o,l),s()},Else:o=>{let a=L(o);r.props.children.push(a)}});return s()},jt=(e,t)=>{let n=v(),r=L(()=>t({i:d("variable",{id:n,inferFrom:[T("int",0)]})})),s=d("loop",{id:n},e,r);return _(s)},Kt=e=>{let t=d("switch",null,e);_(t);let n=()=>({Case:(...r)=>s=>{let o=L(s);for(let a of r)t.props.children.push(a,o);return n()},Default:r=>{let s=L(r);t.props.children.push(s)}});return n()};function Zt(e,t){let n=v(),r=(...s)=>{let o=t?.name||n,a=[],l=[];for(let m=0;m<s.length;m++){let $=t?.inputs?.[m];$?l.push({id:$.name,inferFrom:$.type==="auto"?[s[m]]:[T($.type,s[m])]}):l.push({id:`p${m}`,inferFrom:[s[m]]})}for(let m of l)a.push(d("variable",m));let i=d("scope"),u=d("define",{id:o,layout:t},i,...s);return Ge(i,()=>e(a),u),u};return r.getLayout=()=>t,r.setLayout=s=>(t=s,r),r}var ot=(e,t)=>{if(t==="string")return p(e,null)},d=(e,t,...n)=>{t||(t={}),n.length&&(t.children=n);let r=new Set,s=(l,i)=>{if(i==="type")return e;if(i==="props")return t;if(i==="toVar")return Ie.bind(null,a);if(i==="isProxy")return!0;if(i==="toString")return p.bind(null,a);if(i==="fragment")return Ye.bind(null,a);if(i==="compute")return Ne.bind(null,a);if(i==="vertex")return Ue.bind(null,a);if(i===Symbol.toPrimitive)return ot.bind(null,a);if(i==="listeners")return r;if(i==="attribute")return(u=v())=>st(a,u);if(i==="instance")return(u=v())=>it(a,u);if(i==="constant")return(u=v())=>at(a,u);if(i==="uniform")return(u=v())=>F(a,u);if(i==="variable")return(u=v())=>ut(u);if(i==="builtin")return(u=v())=>b(u);if(i==="vertexStage")return(u=v())=>pt(a,u);if(i==="element")return u=>e==="storage"?ft(a,u):De(a,u);if(i==="member")return u=>q(a,u);if(i==="assign")return Oe.bind(null,a,a.type==="gather");if(i==="select")return lt.bind(null,a);if(se(i))return i.endsWith("Assign")?(...u)=>_(Pe(i,a,...u)):(...u)=>Pe(i,a,...u);if(ie(i))return(...u)=>f(i,a,...u);if(ue(i))return()=>T(le(i),a);if(c.str(i))return de(i)?De(a,i):q(a,i)},o=(l,i,u)=>(i==="value"&&r.forEach(m=>m(u)),c.str(i)&&q(a,i).assign(u),!0),a=new Proxy({},{get:s,set:o});return a},st=(e,t=v())=>d("attribute",{id:t},e),it=(e,t=v())=>d("instance",{id:t},e),at=(e,t=v())=>d("constant",{id:t},e),F=(e,t=v())=>d("uniform",{id:t},e),rn=(e,t=v())=>d("storage",{id:t},e),ut=(e=v())=>d("variable",{id:e}),b=(e=v())=>d("builtin",{id:e}),pt=(e,t=v())=>d("varying",{id:t,inferFrom:[e]},e),q=(e,t)=>d("member",null,e,t),De=(e,t)=>d("element",null,e,t),ft=(e,t)=>d("gather",null,e,t),on=(e,t)=>d("scatter",null,e,t),lt=(e,t,n)=>d("ternary",null,e,t,n),Pe=(e,...t)=>d("operator",null,e,...t),f=(e,...t)=>d("function",null,e,...t),T=(e,...t)=>d("conversion",null,e,...t);var ct=b("position"),fn=b("vertex_index"),ln=b("instance_index"),cn=b("front_facing"),dn=b("frag_depth"),xn=b("sample_index"),Tn=b("sample_mask"),mn=b("point_coord"),gn=b("global_invocation_id"),vn=b("position"),bn=b("positionWorld"),$n=b("positionView"),hn=b("normalLocal"),Cn=b("normalWorld"),En=b("normalView"),_n=b("screenCoordinate"),yn=b("screenUV"),dt=e=>T("float",e),Xn=e=>T("int",e),Sn=e=>T("uint",e),Rn=e=>T("bool",e),We=(e,t)=>T("vec2",e,t),we=(e,t,n)=>T("vec3",e,t,n),Ln=(e,t,n,r)=>T("vec4",e,t,n,r),Fn=(...e)=>T("mat2",...e),An=(...e)=>T("mat3",...e),Yn=(...e)=>T("mat4",...e),Un=(e,t)=>T("ivec2",e,t),Nn=(e,t,n)=>T("ivec3",e,t,n),In=(e,t,n,r)=>T("ivec4",e,t,n,r),On=(e,t)=>T("uvec2",e,t),Gn=(e,t,n)=>T("uvec3",e,t,n),Dn=(e,t,n,r)=>T("uvec4",e,t,n,r),Pn=(e,t)=>T("bvec2",e,t),wn=(e,t,n)=>T("bvec3",e,t,n),Wn=(e,t,n,r)=>T("bvec4",e,t,n,r),Mn=e=>T("texture",e),Vn=()=>T("sampler2D"),Bn=(e,t,n)=>c.num(e)&&c.und(t)&&c.und(n)?we(...pe(e)):we(e,t,n),xt=F(We(),"iResolution"),zn=F(We(),"iMouse"),Hn=F(dt(),"iTime"),kn=ct.xy.div(xt),qn=e=>f("all",e),jn=e=>f("any",e),Kn=e=>f("determinant",e),Zn=(e,t)=>f("distance",e,t),Qn=(e,t)=>f("dot",e,t),Jn=e=>f("length",e),er=e=>f("lengthSq",e),tr=e=>f("luminance",e),nr=(e,t)=>f("cross",e,t),rr=(e,t,n)=>f("cubeTexture",e,t,n),or=(e,t,n)=>f("texture",e,t,n),sr=(e,t,n)=>f("texelFetch",e,t,n),ir=(e,t,n)=>f("textureLod",e,t,n),ar=e=>f("abs",e),ur=e=>f("acos",e),pr=e=>f("acosh",e),fr=e=>f("asin",e),lr=e=>f("asinh",e),cr=e=>f("atan",e),dr=e=>f("atanh",e),xr=e=>f("ceil",e),Tr=e=>f("cos",e),mr=e=>f("cosh",e),gr=e=>f("dFdx",e),vr=e=>f("dFdy",e),br=e=>f("degrees",e),$r=e=>f("exp",e),hr=e=>f("exp2",e),Cr=e=>f("floor",e),Er=e=>f("fract",e),_r=e=>f("fwidth",e),yr=e=>f("inverseSqrt",e),Xr=e=>f("log",e),Sr=e=>f("log2",e),Rr=e=>f("negate",e),Lr=e=>f("normalize",e),Fr=e=>f("oneMinus",e),Ar=e=>f("radians",e),Yr=e=>f("reciprocal",e),Ur=e=>f("round",e),Nr=e=>f("sign",e),Ir=e=>f("sin",e),Or=e=>f("sinh",e),Gr=e=>f("sqrt",e),Dr=e=>f("tan",e),Pr=e=>f("tanh",e),wr=e=>f("trunc",e),Wr=(e,t)=>f("atan2",e,t),Mr=(e,t,n)=>f("clamp",e,t,n),Vr=(e,t)=>f("max",e,t),Br=(e,t)=>f("min",e,t),zr=(e,t,n)=>f("mix",e,t,n),Hr=(e,t)=>f("pow",e,t),kr=(e,t)=>f("reflect",e,t),qr=(e,t,n)=>f("refract",e,t,n),jr=(e,t,n)=>f("smoothstep",e,t,n),Kr=(e,t)=>f("step",e,t),Fe=(e,t)=>e.sub(e.div(t).floor().mul(t));export{zt as Break,Ht as Continue,Zt as Fn,qt as If,jt as Loop,rt as Return,L as Scope,Kt as Switch,ar as abs,ur as acos,pr as acosh,_ as addToScope,qn as all,jn as any,fr as asin,lr as asinh,Oe as assign,cr as atan,Wr as atan2,dr as atanh,st as attribute,Rn as bool,b as builtin,Pn as bvec2,wn as bvec3,Wn as bvec4,xr as ceil,Mr as clamp,Bn as color,Ne as compute,at as constant,T as conversion,Tr as cos,mr as cosh,d as create,nr as cross,rr as cubeTexture,gr as dFdx,vr as dFdy,br as degrees,Kn as determinant,Zn as distance,Qn as dot,De as element,$r as exp,hr as exp2,dt as float,Cr as floor,Er as fract,dn as fragDepth,Ye as fragment,cn as frontFacing,f as function_,_r as fwidth,ft as gather,zn as iMouse,xt as iResolution,Hn as iTime,gn as id,it as instance,ln as instanceIndex,Xn as int,yr as inverseSqrt,Un as ivec2,Nn as ivec3,In as ivec4,Jn as length,er as lengthSq,Xr as log,Sr as log2,tr as luminance,Fn as mat2,An as mat3,Yn as mat4,Vr as max,q as member,Br as min,zr as mix,Fe as mod,Rr as negate,hn as normalLocal,En as normalView,Cn as normalWorld,Lr as normalize,Fr as oneMinus,Pe as operator,mn as pointCoord,ct as position,vn as positionLocal,$n as positionView,bn as positionWorld,Hr as pow,Ar as radians,Yr as reciprocal,kr as reflect,qr as refract,Ur as round,xn as sampleIndex,Tn as sampleMask,Vn as sampler2D,on as scatter,Ge as scoped,_n as screenCoordinate,yn as screenUV,lt as select,Nr as sign,Ir as sin,Or as sinh,jr as smoothstep,Gr as sqrt,Kr as step,rn as storage,kt as struct,Dr as tan,Pr as tanh,sr as texelFetch,or as texture,Mn as texture2D,ir as textureLod,Ie as toVar,wr as trunc,Sn as uint,F as uniform,kn as uv,On as uvec2,Gn as uvec3,Dn as uvec4,ut as variable,We as vec2,we as vec3,Ln as vec4,Ue as vertex,fn as vertexIndex,pt as vertexStage};
65
65
  //# sourceMappingURL=node.js.map