glre 0.44.0 → 0.45.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/dist/addons.d.ts CHANGED
@@ -245,7 +245,7 @@ interface NodeContext {
245
245
  fragInputs: Map<string, string>;
246
246
  vertInputs: Map<string, string>;
247
247
  vertOutputs: Map<string, string>;
248
- vertVaryings: Map<string, string>;
248
+ vertVaryings: Map<string, VaryingInfo>;
249
249
  computeInputs: Map<string, string>;
250
250
  dependencies: Map<string, Set<string>>;
251
251
  structStructFields: Map<string, StructFields>;
@@ -341,6 +341,10 @@ type Mat4 = XImpl<'mat4'>;
341
341
  type Texture = XImpl<'texture'>;
342
342
  type Sampler2D = XImpl<'sampler2D'>;
343
343
  type StructBase = XImpl<'struct'>;
344
+ interface VaryingInfo {
345
+ node: Y;
346
+ code?: string;
347
+ }
344
348
  type Struct<T extends StructFields = any> = Omit<StructBase, keyof T> & {
345
349
  [K in keyof T]: T[K] extends X<infer U> ? X<U> : never;
346
350
  } & {
@@ -382,6 +386,7 @@ type XImpl<T extends C> = _X<T> & {
382
386
  };
383
387
  type C = Constants;
384
388
  type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
389
+ type Y<T extends C = C> = number | number[] | string | boolean | undefined | HTMLElement | X<T>;
385
390
  type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
386
391
  interface _X<T extends C> {
387
392
  readonly __nodeType?: T;
package/dist/index.d.ts CHANGED
@@ -111,7 +111,7 @@ interface NodeContext {
111
111
  fragInputs: Map<string, string>;
112
112
  vertInputs: Map<string, string>;
113
113
  vertOutputs: Map<string, string>;
114
- vertVaryings: Map<string, string>;
114
+ vertVaryings: Map<string, VaryingInfo>;
115
115
  computeInputs: Map<string, string>;
116
116
  dependencies: Map<string, Set<string>>;
117
117
  structStructFields: Map<string, StructFields>;
@@ -207,6 +207,10 @@ type Mat4 = XImpl<'mat4'>;
207
207
  type Texture$1 = XImpl<'texture'>;
208
208
  type Sampler2D = XImpl<'sampler2D'>;
209
209
  type StructBase = XImpl<'struct'>;
210
+ interface VaryingInfo {
211
+ node: Y;
212
+ code?: string;
213
+ }
210
214
  interface ConstantsToType {
211
215
  void: Void;
212
216
  bool: Bool;
@@ -243,6 +247,7 @@ type XImpl<T extends C> = _X<T> & {
243
247
  };
244
248
  type C = Constants;
245
249
  type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
250
+ type Y<T extends C = C> = number | number[] | string | boolean | undefined | HTMLElement | X<T>;
246
251
  type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
247
252
  interface _X<T extends C> {
248
253
  readonly __nodeType?: T;
package/dist/native.d.ts CHANGED
@@ -112,7 +112,7 @@ interface NodeContext {
112
112
  fragInputs: Map<string, string>;
113
113
  vertInputs: Map<string, string>;
114
114
  vertOutputs: Map<string, string>;
115
- vertVaryings: Map<string, string>;
115
+ vertVaryings: Map<string, VaryingInfo>;
116
116
  computeInputs: Map<string, string>;
117
117
  dependencies: Map<string, Set<string>>;
118
118
  structStructFields: Map<string, StructFields>;
@@ -208,6 +208,10 @@ type Mat4 = XImpl<'mat4'>;
208
208
  type Texture$1 = XImpl<'texture'>;
209
209
  type Sampler2D = XImpl<'sampler2D'>;
210
210
  type StructBase = XImpl<'struct'>;
211
+ interface VaryingInfo {
212
+ node: Y;
213
+ code?: string;
214
+ }
211
215
  interface ConstantsToType {
212
216
  void: Void;
213
217
  bool: Bool;
@@ -244,6 +248,7 @@ type XImpl<T extends C> = _X<T> & {
244
248
  };
245
249
  type C = Constants;
246
250
  type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
251
+ type Y<T extends C = C> = number | number[] | string | boolean | undefined | HTMLElement | X<T>;
247
252
  type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
248
253
  interface _X<T extends C> {
249
254
  readonly __nodeType?: T;
package/dist/node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var O=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},ot=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tt(t))!nt.call(e,s)&&s!==n&&O(e,s,{get:()=>t[s],enumerable:!(r=et(t,s))||r.enumerable});return e};var st=e=>ot(O({},"__esModule",{value:!0}),e);var gr={};rt(gr,{Break:()=>bt,Continue:()=>$t,Fn:()=>yt,If:()=>Ct,Loop:()=>Et,Return:()=>We,Scope:()=>S,Switch:()=>_t,abs:()=>Sn,acos:()=>Rn,acosh:()=>Fn,addToScope:()=>E,all:()=>xn,any:()=>Tn,asin:()=>Yn,asinh:()=>An,assign:()=>ee,atan:()=>Ln,atan2:()=>ar,atanh:()=>Un,attribute:()=>Ve,bool:()=>kt,builtin:()=>b,bvec2:()=>on,bvec3:()=>sn,bvec4:()=>an,ceil:()=>In,clamp:()=>ur,color:()=>cn,compute:()=>J,constant:()=>ze,conversion:()=>T,cos:()=>Nn,cosh:()=>On,create:()=>d,cross:()=>Cn,cubeTexture:()=>En,dFdx:()=>wn,dFdy:()=>Gn,degrees:()=>Pn,determinant:()=>mn,distance:()=>gn,dot:()=>vn,element:()=>ne,exp:()=>Dn,exp2:()=>Mn,float:()=>Ze,floor:()=>Wn,fract:()=>Vn,fragDepth:()=>Lt,fragment:()=>K,frontFacing:()=>At,function_:()=>c,fwidth:()=>Bn,gather:()=>qe,iMouse:()=>fn,iResolution:()=>Je,iTime:()=>ln,id:()=>Ot,instance:()=>Be,instanceIndex:()=>Yt,int:()=>zt,inverseSqrt:()=>zn,ivec2:()=>Jt,ivec3:()=>Qt,ivec4:()=>en,length:()=>bn,lengthSq:()=>$n,log:()=>Hn,log2:()=>kn,luminance:()=>hn,mat2:()=>jt,mat3:()=>Kt,mat4:()=>Zt,max:()=>pr,member:()=>N,min:()=>cr,mix:()=>fr,mod:()=>q,negate:()=>qn,normalLocal:()=>Dt,normalView:()=>Wt,normalWorld:()=>Mt,normalize:()=>jn,oneMinus:()=>Kn,operator:()=>re,pointCoord:()=>Nt,position:()=>Ke,positionLocal:()=>wt,positionView:()=>Pt,positionWorld:()=>Gt,pow:()=>lr,radians:()=>Zn,reciprocal:()=>Jn,reflect:()=>dr,refract:()=>xr,round:()=>Qn,sampleIndex:()=>Ut,sampleMask:()=>It,sampler2D:()=>pn,scatter:()=>Rt,scoped:()=>te,screenCoordinate:()=>Vt,screenUV:()=>Bt,select:()=>je,sign:()=>er,sin:()=>tr,sinh:()=>nr,smoothstep:()=>Tr,sqrt:()=>rr,step:()=>mr,storage:()=>St,struct:()=>ht,tan:()=>or,tanh:()=>sr,texelFetch:()=>yn,texture:()=>_n,texture2D:()=>un,textureLod:()=>Xn,toVar:()=>Q,trunc:()=>ir,uint:()=>Ht,uniform:()=>Y,uv:()=>dn,uvec2:()=>tn,uvec3:()=>nn,uvec4:()=>rn,variable:()=>He,vec2:()=>se,vec3:()=>oe,vec4:()=>qt,vertex:()=>Z,vertexIndex:()=>Ft,vertexStage:()=>ke});module.exports=st(gr);var G=["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"},D=Object.keys(P),M={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:">>="},ie=Object.keys(M),W={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},ae={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"},ue=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],pe=["and","or"],ce=[["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"]],fe={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"},le=[...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"],w=(e,t)=>e===t,it=(e,t)=>ce.some(([n,r,s])=>n===e&&r===t||n===t&&r===e),de=(e,t,n)=>ue.includes(n)||pe.includes(n)?w(e,t):w(e,t)?!0:it(e,t),xe=(e,t,n)=>{if(ue.includes(n)||pe.includes(n))return"bool";if(w(e,t))return e;let r=ce.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 at=e=>[1,2,3,4,9,16].includes(e),ut=(e,t=3)=>e%t===0?Math.floor(e/t):-1,B=(e,t=1,n=console.warn)=>{let r=ut(e,t);return at(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 $r=`
1
+ "use strict";var O=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},ot=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tt(t))!nt.call(e,s)&&s!==n&&O(e,s,{get:()=>t[s],enumerable:!(r=et(t,s))||r.enumerable});return e};var st=e=>ot(O({},"__esModule",{value:!0}),e);var gr={};rt(gr,{Break:()=>bt,Continue:()=>$t,Fn:()=>yt,If:()=>Ct,Loop:()=>Et,Return:()=>We,Scope:()=>S,Switch:()=>_t,abs:()=>Sn,acos:()=>Rn,acosh:()=>Fn,addToScope:()=>E,all:()=>xn,any:()=>Tn,asin:()=>Yn,asinh:()=>An,assign:()=>ee,atan:()=>Ln,atan2:()=>ar,atanh:()=>Un,attribute:()=>Ve,bool:()=>kt,builtin:()=>b,bvec2:()=>on,bvec3:()=>sn,bvec4:()=>an,ceil:()=>In,clamp:()=>ur,color:()=>fn,compute:()=>J,constant:()=>ze,conversion:()=>T,cos:()=>Nn,cosh:()=>On,create:()=>d,cross:()=>Cn,cubeTexture:()=>En,dFdx:()=>wn,dFdy:()=>Gn,degrees:()=>Pn,determinant:()=>mn,distance:()=>gn,dot:()=>vn,element:()=>ne,exp:()=>Dn,exp2:()=>Mn,float:()=>Ze,floor:()=>Wn,fract:()=>Vn,fragDepth:()=>Lt,fragment:()=>K,frontFacing:()=>At,function_:()=>f,fwidth:()=>Bn,gather:()=>qe,iMouse:()=>cn,iResolution:()=>Je,iTime:()=>ln,id:()=>Ot,instance:()=>Be,instanceIndex:()=>Yt,int:()=>zt,inverseSqrt:()=>zn,ivec2:()=>Jt,ivec3:()=>Qt,ivec4:()=>en,length:()=>bn,lengthSq:()=>$n,log:()=>Hn,log2:()=>kn,luminance:()=>hn,mat2:()=>jt,mat3:()=>Kt,mat4:()=>Zt,max:()=>pr,member:()=>N,min:()=>fr,mix:()=>cr,mod:()=>q,negate:()=>qn,normalLocal:()=>Dt,normalView:()=>Wt,normalWorld:()=>Mt,normalize:()=>jn,oneMinus:()=>Kn,operator:()=>re,pointCoord:()=>Nt,position:()=>Ke,positionLocal:()=>wt,positionView:()=>Pt,positionWorld:()=>Gt,pow:()=>lr,radians:()=>Zn,reciprocal:()=>Jn,reflect:()=>dr,refract:()=>xr,round:()=>Qn,sampleIndex:()=>Ut,sampleMask:()=>It,sampler2D:()=>pn,scatter:()=>Rt,scoped:()=>te,screenCoordinate:()=>Vt,screenUV:()=>Bt,select:()=>je,sign:()=>er,sin:()=>tr,sinh:()=>nr,smoothstep:()=>Tr,sqrt:()=>rr,step:()=>mr,storage:()=>St,struct:()=>ht,tan:()=>or,tanh:()=>sr,texelFetch:()=>yn,texture:()=>_n,texture2D:()=>un,textureLod:()=>Xn,toVar:()=>Q,trunc:()=>ir,uint:()=>Ht,uniform:()=>Y,uv:()=>dn,uvec2:()=>tn,uvec3:()=>nn,uvec4:()=>rn,variable:()=>He,vec2:()=>se,vec3:()=>oe,vec4:()=>qt,vertex:()=>Z,vertexIndex:()=>Ft,vertexStage:()=>ke});module.exports=st(gr);var G=["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"},D=Object.keys(P),M={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:">>="},ie=Object.keys(M),W={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},ae={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"},ue=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],pe=["and","or"],fe=[["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"]],ce={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"},le=[...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"],w=(e,t)=>e===t,it=(e,t)=>fe.some(([n,r,s])=>n===e&&r===t||n===t&&r===e),de=(e,t,n)=>ue.includes(n)||pe.includes(n)?w(e,t):w(e,t)?!0:it(e,t),xe=(e,t,n)=>{if(ue.includes(n)||pe.includes(n))return"bool";if(w(e,t))return e;let r=fe.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 at=e=>[1,2,3,4,9,16].includes(e),ut=(e,t=3)=>e%t===0?Math.floor(e/t):-1,B=(e,t=1,n=console.warn)=>{let r=ut(e,t);return at(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 $r=`
2
2
  struct In { @builtin(vertex_index) vertex_index: u32 }
3
3
  struct Out { @builtin(position) position: vec4f }
4
4
  @vertex
@@ -9,7 +9,7 @@ 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 Te=e=>l.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),me=e=>ie.includes(e),ge=e=>le.includes(e),ve=e=>l.obj(e)?!1:e instanceof Element,be=e=>G.includes(e),R=e=>!e||typeof e!="object"?!1:e.isProxy,z=e=>l.str(e)?D.includes(e):!1,$e=e=>{let t=(e>>16&255)/255,n=(e>>8&255)/255,r=(e&255)/255;return[t,n,r]},pt=0,v=()=>`x${pt++}`,he=(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=fe[t];if(!n)throw new Error(`Error: unknown builtin variable ${t}`);return n},C=(e,t)=>l.str(e)?t?.isWebGL?e:P[e]||e:"",H=e=>M[e]||e,Ce=e=>{let t=G.indexOf(e);return t!==-1?D[t]:"float"},Ee=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),_e=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),z(n)||e.code.dependencies.get(t).add(n)},ct=(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),ft=(e,t)=>{if(l.und(e))return;if(!R(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]))},k=(e,t,n,r,s)=>{let o=ct(e,t,n);return ft(s,o),r.listeners.add(o),o};var lt=e=>ae[e],dt=(e,t,n)=>(de(e,t,n)||console.warn(`GLRE Type Warning: Invalid operator '${n}' between types '${e}' and '${t}'`),xe(e,t,n)),xt=e=>l.bol(e)?"bool":l.str(e)?"texture":l.num(e)?"float":l.arr(e)?W[e.length]:ve(e)?"texture":"void",U=e=>{let t=W[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},ye=(e,t)=>{if(e.length===0)return"void";let[n]=e;return l.str(n)?n:g(n,t)},Tt=e=>V[e],mt=(e,t)=>{let{type:n,props:r}=e,{id:s,children:o=[],inferFrom:a,layout:f}=r,[i,u,m]=o;if(n==="conversion")return i;if(n==="operator")return dt(g(u,t),g(m,t),i);if(n==="builtin")return lt(s);if(n==="function")return Tt(i)||g(u,t);if(n==="define")return z(f?.type)?f?.type:!a||a.length===0?"void":ye(a,t);if(n==="attribute"&&l.arr(i)){let $=B(i.length,t.gl?.count,t.gl?.error);return U($)}if(n==="instance"&&l.arr(i)){let $=B(i.length,t.gl?.instanceCount,t.gl?.error);return U($)}if(n==="member"){if(Te(u))return U(u.length);if(R(i)){let $=g(i,t),h=t.code?.structStructFields?.get($);if(h&&h[u])return g(h[u],t)}return"float"}return a?ye(a,t):i?g(i,t):"void"},g=(e,t)=>{if(t||(t={}),!R(e))return xt(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=mt(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),f=`int(${o}) % ${a.x}`,i=`int(${o}) / ${a.x}`;return`texelFetch(${p(t,e)}, ivec2(${f}, ${i}), 0)${s()}`},Se=(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}`)},Re=(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})`},Fe=(e,t,n,r)=>{let s=`if (${p(t,e)}) {
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 Te=e=>l.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),me=e=>ie.includes(e),ge=e=>le.includes(e),ve=e=>l.obj(e)?!1:e instanceof Element,be=e=>G.includes(e),R=e=>!e||typeof e!="object"?!1:e.isProxy,z=e=>l.str(e)?D.includes(e):!1,$e=e=>{let t=(e>>16&255)/255,n=(e>>8&255)/255,r=(e&255)/255;return[t,n,r]},pt=0,v=()=>`x${pt++}`,he=(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=ce[t];if(!n)throw new Error(`Error: unknown builtin variable ${t}`);return n},C=(e,t)=>l.str(e)?t?.isWebGL?e:P[e]||e:"",H=e=>M[e]||e,Ce=e=>{let t=G.indexOf(e);return t!==-1?D[t]:"float"},Ee=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),_e=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),z(n)||e.code.dependencies.get(t).add(n)},ft=(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),ct=(e,t)=>{if(l.und(e))return;if(!R(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]))},k=(e,t,n,r,s)=>{let o=ft(e,t,n);return ct(s,o),r.listeners.add(o),o};var lt=e=>ae[e],dt=(e,t,n)=>(de(e,t,n)||console.warn(`GLRE Type Warning: Invalid operator '${n}' between types '${e}' and '${t}'`),xe(e,t,n)),xt=e=>l.bol(e)?"bool":l.str(e)?"texture":l.num(e)?"float":l.arr(e)?W[e.length]:ve(e)?"texture":"void",U=e=>{let t=W[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},ye=(e,t)=>{if(e.length===0)return"void";let[n]=e;return l.str(n)?n:g(n,t)},Tt=e=>V[e],mt=(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 dt(g(u,t),g(m,t),i);if(n==="builtin")return lt(s);if(n==="function")return Tt(i)||g(u,t);if(n==="define")return z(c?.type)?c?.type:!a||a.length===0?"void":ye(a,t);if(n==="attribute"&&l.arr(i)){let $=B(i.length,t.gl?.count,t.gl?.error);return U($)}if(n==="instance"&&l.arr(i)){let $=B(i.length,t.gl?.instanceCount,t.gl?.error);return U($)}if(n==="member"){if(Te(u))return U(u.length);if(R(i)){let $=g(i,t),h=t.code?.structStructFields?.get($);if(h&&h[u])return g(h[u],t)}return"float"}return a?ye(a,t):i?g(i,t):"void"},g=(e,t)=>{if(t||(t={}),!R(e))return xt(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=mt(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()}`},Se=(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}`)},Re=(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})`},Fe=(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)}
@@ -22,13 +22,13 @@ 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},Ae=(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)};`},Le=(e,t,n={})=>{e.code?.structStructFields?.set(t,n);let r=[];for(let o in n){let a=n[o],f=g(a,e);e.isWebGL&&L(e,t,f),r.push(e.isWebGL?`${f} ${o};`:`${o}: ${C(f,e)},`)}let s=r.join(`
25
+ `);return r+="}",r},Ae=(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)};`},Le=(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(`
26
26
  `);return`struct ${t} {
27
27
  ${s}
28
- };`},Ue=(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};`},Ie=(e,t,n)=>{let{id:r,children:s=[],layout:o}=t,[a,...f]=s,i=[],u=[];for(let x=0;x<f.length;x++){let _=o?.inputs?.[x];_?i.push([_.name,_.type==="auto"?g(f[x],e):_.type]):i.push([`p${x}`,g(f[x],e)])}let m=p(a,e),$=g(n,e),h=[];if(e?.isWebGL){for(let[x,_]of i)L(e,r,_),u.push(`${_} ${x}`);L(e,r,$),h.push(`${$} ${r}(${u}) {`)}else{for(let[_,Qe]of i)u.push(`${_}: ${C(Qe,e)}`);$==="void"?h.push(`fn ${r}(${u}) {`):h.push(`fn ${r}(${u}) -> ${C($,e)} {`)}return m&&h.push(m),h.push("}"),h.join(`
29
- `)},Ne=(e,t,n)=>e.isWebGL?`${n} ${t};`:`@location(${e.code?.vertVaryings?.size||0}) ${t}: ${C(n,e)}`,Oe=(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}`},we=(e,t,n)=>{let r=n==="sampler2D"||n==="texture";if(e.isWebGL)return r?`uniform sampler2D ${t};`:`uniform ${n} ${t};`;if(r){let{group:f=1,binding:i=0}=e.gl?.webgpu?.textures.map.get(t)||{};return`@group(${f}) @binding(${i}) var ${t}Sampler: sampler;
30
- @group(${f}) @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};`},Ge=(e,t,n)=>{if(e.isWebGL){let a=`uniform sampler2D ${t};`;if(e.label!=="compute")return a;let f=e.units?.(t);return`${a}
31
- layout(location = ${f}) 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}>;`},Pe=(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
+ };`},Ue=(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};`},Ie=(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 _=o?.inputs?.[x];_?i.push([_.name,_.type==="auto"?g(c[x],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,_]of i)L(e,r,_),u.push(`${_} ${x}`);L(e,r,$),h.push(`${$} ${r}(${u}) {`)}else{for(let[_,Qe]of i)u.push(`${_}: ${C(Qe,e)}`);$==="void"?h.push(`fn ${r}(${u}) {`):h.push(`fn ${r}(${u}) -> ${C($,e)} {`)}return m&&h.push(m),h.push("}"),h.join(`
29
+ `)},Ne=(e,t,n)=>e.isWebGL?`${n} ${t};`:`@location(${e.code?.vertVaryings?.size||0}) ${t}: ${C(n,e)}`,Oe=(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}`},we=(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};`},Ge=(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}>;`},Pe=(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
- }`},De=(e,t,n,r)=>e.isWebGL?`const ${n} ${t} = ${r};`:`const ${t}: ${C(n,e)} = ${r};`;var p=(e,t)=>{if(t||(t={}),Ee(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||!R(e))return"";let{type:n,props:r={}}=e,{id:s="i",children:o=[],fields:a,initialValues:f}=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,_]=i.props.children??[];return t.isWebGL?Se(t,x,u):`${p(x,t)}[${p(_,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(q(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 Re(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 Pe(t,i,u,s);if(n==="if")return Fe(t,i,u,o);if(n==="switch")return Ye(t,i,o);if(n==="declare")return Ae(t,i,u);if(n==="define")return t.code?.headers.has(s)||t.code?.headers.set(s,Ie(t,r,e)),`${s}(${y(o.slice(1),t)})`;if(n==="struct")return t.code?.headers.has(s)||t.code?.headers.set(s,Le(t,s,a)),Ue(t,s,i.props.id,f);if(n==="varying"){if(t.code?.vertOutputs.has(s))return t.isWebGL?`${s}`:`out.${s}`;let x=Ne(t,s,g(e,t));return t.code?.fragInputs.set(s,x),t.code?.vertOutputs.set(s,x),t.code?.vertVaryings.set(s,p(i,t)),t.isWebGL?`${s}`:`out.${s}`}if(n==="builtin"){if(t.isWebGL)return he(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 k(t,s,n,e,i),t.code?.vertInputs.set(s,Oe(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);k(t,s,x,e,i),h=we(t,s,x)}return n==="storage"&&(h=Ge(t,s,g(e,t))),n==="constant"&&(h=De(t,s,g(e,t),p(i,t))),h?(t.code?.headers.set(s,h),s):p(i,t)};var gt=(e,t)=>{let n=[],r=new Set,s=new Set,o=a=>{if(s.has(a)||r.has(a))return;s.add(a);let f=t.get(a)||new Set;for(let i of f)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},j=(e,t)=>{let n=p(e,t),r="";t.isWebGL&&t.code?.dependencies?r=gt(t.code.headers,t.code.dependencies).map(([,f])=>f).join(`
51
+ }`},De=(e,t,n,r)=>e.isWebGL?`const ${n} ${t} = ${r};`:`const ${t}: ${C(n,e)} = ${r};`;var p=(e,t)=>{if(t||(t={}),Ee(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||!R(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,_]=i.props.children??[];return t.isWebGL?Se(t,x,u):`${p(x,t)}[${p(_,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(q(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 Re(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 Pe(t,i,u,s);if(n==="if")return Fe(t,i,u,o);if(n==="switch")return Ye(t,i,o);if(n==="declare")return Ae(t,i,u);if(n==="define")return t.code?.headers.has(s)||t.code?.headers.set(s,Ie(t,r,e)),`${s}(${y(o.slice(1),t)})`;if(n==="struct")return t.code?.headers.has(s)||t.code?.headers.set(s,Le(t,s,a)),Ue(t,s,i.props.id,c);if(n==="varying"){if(t.code?.vertOutputs.has(s))return t.isWebGL?`${s}`:`out.${s}`;let x=Ne(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 he(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 k(t,s,n,e,i),t.code?.vertInputs.set(s,Oe(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);k(t,s,x,e,i),h=we(t,s,x)}return n==="storage"&&(h=Ge(t,s,g(e,t))),n==="constant"&&(h=De(t,s,g(e,t),p(i,t))),h?(t.code?.headers.set(s,h),s):p(i,t)};var gt=(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},j=(e,t)=>{let n=p(e,t),r="";t.isWebGL&&t.code?.dependencies?r=gt(t.code.headers,t.code.dependencies).map(([,c])=>c).join(`
53
53
  `):r=Array.from(t.code?.headers?.values()||[]).join(`
54
54
  `);let[s,o]=n.split("return ");return o?o=o.replace(";",""):[s,o]=["",n],[r,s.trim(),o]},I=(e,t)=>`struct ${e} {
55
55
  ${Array.from(t.values()).join(`,
56
56
  `)}
57
- }`,Me=(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;`)},vt=(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"},K=(e,t={})=>{t.code?.headers?.clear(),t.label="frag";let[n,r,s]=j(e,t),o=[];if(t.isWebGL){o.push("#version 300 es"),Me(o,vt(t.gl?.webgl?.context,t.gl?.precision)),o.push("out vec4 fragColor;");for(let f of t.code?.fragInputs?.values()||[])o.push(`in ${f}`);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
+ }`,Me=(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;`)},vt=(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"},K=(e,t={})=>{t.code?.headers?.clear(),t.label="frag";let[n,r,s]=j(e,t),o=[];if(t.isWebGL){o.push("#version 300 es"),Me(o,vt(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
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},Z=(e,t={})=>{t.code?.headers?.clear(),t.label="vert";let[n,r,s]=j(e,t),o=[];if(t.isWebGL){o.push("#version 300 es");for(let f of t.code?.vertInputs?.values()||[])o.push(`in ${f}`);for(let f of t.code?.vertOutputs?.values()||[])o.push(`out ${f}`);o.push(n),o.push("void main() {"),o.push(` ${r}`),o.push(` gl_Position = ${s};`);for(let[f,i]of t.code?.vertVaryings?.entries()||[])o.push(` ${f} = ${i};`)}else{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};`);for(let[f,i]of t.code?.vertVaryings?.entries()||[])o.push(` out.${f} = ${i};`);o.push(" return out;")}o.push("}");let a=o.filter(Boolean).join(`
60
+ ${a}`),a},Z=(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]=j(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(`
61
61
  `).trim();return t.gl?.isDebug&&console.log(`\u2193\u2193\u2193generated\u2193\u2193\u2193
62
62
  ${a}`),a},J=(e,t={})=>{t.code?.headers?.clear(),t.label="compute";let[n,r,s]=j(e,t),o=[];t.isWebGL?(o.push("#version 300 es"),Me(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(`
63
63
  `).trim();return t.gl?.isDebug&&console.log(`\u2193\u2193\u2193generated\u2193\u2193\u2193
64
- ${a}`),a};var X=null,F=null,E=e=>{if(!X)return;if(X.props.children||(X.props.children=[]),X.props.children.push(e),e.type!=="return"||!F)return e;let{props:t}=F;return t.inferFrom||(t.inferFrom=[]),t.inferFrom.push(e),e};function Q(e,t){t||(t=v());let n=d("variable",{id:t,inferFrom:[e]}),r=d("declare",null,e,n);return E(r),n}var ee=(e,t=!1,n)=>{let r=d(t?"scatter":"assign",null,e,n);return E(r),e},We=e=>E(d("return",{inferFrom:[e]},e)),bt=()=>E(d("break")),$t=()=>E(d("continue")),ht=(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 E(o),s},te=(e,t,n=F)=>{let[r,s]=[X,F];[X,F]=[e,n];let o=t();o&&We(o),[X,F]=[r,s]},S=e=>{let t=d("scope");return te(t,e),t},Ct=(e,t)=>{let n=S(t),r=d("if",null,e,n);E(r);let s=()=>({ElseIf:(o,a)=>{let f=S(a);return r.props.children.push(o,f),s()},Else:o=>{let a=S(o);r.props.children.push(a)}});return s()},Et=(e,t)=>{let n=v(),r=S(()=>t({i:d("variable",{id:n,inferFrom:[T("int",0)]})})),s=d("loop",{id:n},e,r);return E(s)},_t=e=>{let t=d("switch",null,e);E(t);let n=()=>({Case:(...r)=>s=>{let o=S(s);for(let a of r)t.props.children.push(a,o);return n()},Default:r=>{let s=S(r);t.props.children.push(s)}});return n()};function yt(e,t){let n=v(),r=(...s)=>{let o=t?.name||n,a=[],f=[];for(let m=0;m<s.length;m++){let $=t?.inputs?.[m];$?f.push({id:$.name,inferFrom:$.type==="auto"?[s[m]]:[T($.type,s[m])]}):f.push({id:`p${m}`,inferFrom:[s[m]]})}for(let m of f)a.push(d("variable",m));let i=d("scope"),u=d("define",{id:o,layout:t},i,...s);return te(i,()=>e(a),u),u};return r.getLayout=()=>t,r.setLayout=s=>(t=s,r),r}var Xt=(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=(f,i)=>{if(i==="type")return e;if(i==="props")return t;if(i==="toVar")return Q.bind(null,a);if(i==="isProxy")return!0;if(i==="toString")return p.bind(null,a);if(i==="fragment")return K.bind(null,a);if(i==="compute")return J.bind(null,a);if(i==="vertex")return Z.bind(null,a);if(i===Symbol.toPrimitive)return Xt.bind(null,a);if(i==="listeners")return r;if(i==="attribute")return(u=v())=>Ve(a,u);if(i==="instance")return(u=v())=>Be(a,u);if(i==="constant")return(u=v())=>ze(a,u);if(i==="uniform")return(u=v())=>Y(a,u);if(i==="variable")return(u=v())=>He(u);if(i==="builtin")return(u=v())=>b(u);if(i==="vertexStage")return(u=v())=>ke(a,u);if(i==="element")return u=>e==="storage"?qe(a,u):ne(a,u);if(i==="member")return u=>N(a,u);if(i==="assign")return ee.bind(null,a,a.type==="gather");if(i==="select")return je.bind(null,a);if(me(i))return i.endsWith("Assign")?(...u)=>E(re(i,a,...u)):(...u)=>re(i,a,...u);if(ge(i))return(...u)=>c(i,a,...u);if(be(i))return()=>T(Ce(i),a);if(l.str(i))return _e(i)?ne(a,i):N(a,i)},o=(f,i,u)=>(i==="value"&&r.forEach(m=>m(u)),l.str(i)&&N(a,i).assign(u),!0),a=new Proxy({},{get:s,set:o});return a},Ve=(e,t=v())=>d("attribute",{id:t},e),Be=(e,t=v())=>d("instance",{id:t},e),ze=(e,t=v())=>d("constant",{id:t},e),Y=(e,t=v())=>d("uniform",{id:t},e),St=(e,t=v())=>d("storage",{id:t},e),He=(e=v())=>d("variable",{id:e}),b=(e=v())=>d("builtin",{id:e}),ke=(e,t=v())=>d("varying",{id:t,inferFrom:[e]},e),N=(e,t)=>d("member",null,e,t),ne=(e,t)=>d("element",null,e,t),qe=(e,t)=>d("gather",null,e,t),Rt=(e,t)=>d("scatter",null,e,t),je=(e,t,n)=>d("ternary",null,e,t,n),re=(e,...t)=>d("operator",null,e,...t),c=(e,...t)=>d("function",null,e,...t),T=(e,...t)=>d("conversion",null,e,...t);var Ke=b("position"),Ft=b("vertex_index"),Yt=b("instance_index"),At=b("front_facing"),Lt=b("frag_depth"),Ut=b("sample_index"),It=b("sample_mask"),Nt=b("point_coord"),Ot=b("global_invocation_id"),wt=b("position"),Gt=b("positionWorld"),Pt=b("positionView"),Dt=b("normalLocal"),Mt=b("normalWorld"),Wt=b("normalView"),Vt=b("screenCoordinate"),Bt=b("screenUV"),Ze=e=>T("float",e),zt=e=>T("int",e),Ht=e=>T("uint",e),kt=e=>T("bool",e),se=(e,t)=>T("vec2",e,t),oe=(e,t,n)=>T("vec3",e,t,n),qt=(e,t,n,r)=>T("vec4",e,t,n,r),jt=(...e)=>T("mat2",...e),Kt=(...e)=>T("mat3",...e),Zt=(...e)=>T("mat4",...e),Jt=(e,t)=>T("ivec2",e,t),Qt=(e,t,n)=>T("ivec3",e,t,n),en=(e,t,n,r)=>T("ivec4",e,t,n,r),tn=(e,t)=>T("uvec2",e,t),nn=(e,t,n)=>T("uvec3",e,t,n),rn=(e,t,n,r)=>T("uvec4",e,t,n,r),on=(e,t)=>T("bvec2",e,t),sn=(e,t,n)=>T("bvec3",e,t,n),an=(e,t,n,r)=>T("bvec4",e,t,n,r),un=e=>T("texture",e),pn=()=>T("sampler2D"),cn=(e,t,n)=>l.num(e)&&l.und(t)&&l.und(n)?oe(...$e(e)):oe(e,t,n),Je=Y(se(),"iResolution"),fn=Y(se(),"iMouse"),ln=Y(Ze(),"iTime"),dn=Ke.xy.div(Je),xn=e=>c("all",e),Tn=e=>c("any",e),mn=e=>c("determinant",e),gn=(e,t)=>c("distance",e,t),vn=(e,t)=>c("dot",e,t),bn=e=>c("length",e),$n=e=>c("lengthSq",e),hn=e=>c("luminance",e),Cn=(e,t)=>c("cross",e,t),En=(e,t,n)=>c("cubeTexture",e,t,n),_n=(e,t,n)=>c("texture",e,t,n),yn=(e,t,n)=>c("texelFetch",e,t,n),Xn=(e,t,n)=>c("textureLod",e,t,n),Sn=e=>c("abs",e),Rn=e=>c("acos",e),Fn=e=>c("acosh",e),Yn=e=>c("asin",e),An=e=>c("asinh",e),Ln=e=>c("atan",e),Un=e=>c("atanh",e),In=e=>c("ceil",e),Nn=e=>c("cos",e),On=e=>c("cosh",e),wn=e=>c("dFdx",e),Gn=e=>c("dFdy",e),Pn=e=>c("degrees",e),Dn=e=>c("exp",e),Mn=e=>c("exp2",e),Wn=e=>c("floor",e),Vn=e=>c("fract",e),Bn=e=>c("fwidth",e),zn=e=>c("inverseSqrt",e),Hn=e=>c("log",e),kn=e=>c("log2",e),qn=e=>c("negate",e),jn=e=>c("normalize",e),Kn=e=>c("oneMinus",e),Zn=e=>c("radians",e),Jn=e=>c("reciprocal",e),Qn=e=>c("round",e),er=e=>c("sign",e),tr=e=>c("sin",e),nr=e=>c("sinh",e),rr=e=>c("sqrt",e),or=e=>c("tan",e),sr=e=>c("tanh",e),ir=e=>c("trunc",e),ar=(e,t)=>c("atan2",e,t),ur=(e,t,n)=>c("clamp",e,t,n),pr=(e,t)=>c("max",e,t),cr=(e,t)=>c("min",e,t),fr=(e,t,n)=>c("mix",e,t,n),lr=(e,t)=>c("pow",e,t),dr=(e,t)=>c("reflect",e,t),xr=(e,t,n)=>c("refract",e,t,n),Tr=(e,t,n)=>c("smoothstep",e,t,n),mr=(e,t)=>c("step",e,t),q=(e,t)=>e.sub(e.div(t).floor().mul(t));0&&(module.exports={Break,Continue,Fn,If,Loop,Return,Scope,Switch,abs,acos,acosh,addToScope,all,any,asin,asinh,assign,atan,atan2,atanh,attribute,bool,builtin,bvec2,bvec3,bvec4,ceil,clamp,color,compute,constant,conversion,cos,cosh,create,cross,cubeTexture,dFdx,dFdy,degrees,determinant,distance,dot,element,exp,exp2,float,floor,fract,fragDepth,fragment,frontFacing,function_,fwidth,gather,iMouse,iResolution,iTime,id,instance,instanceIndex,int,inverseSqrt,ivec2,ivec3,ivec4,length,lengthSq,log,log2,luminance,mat2,mat3,mat4,max,member,min,mix,mod,negate,normalLocal,normalView,normalWorld,normalize,oneMinus,operator,pointCoord,position,positionLocal,positionView,positionWorld,pow,radians,reciprocal,reflect,refract,round,sampleIndex,sampleMask,sampler2D,scatter,scoped,screenCoordinate,screenUV,select,sign,sin,sinh,smoothstep,sqrt,step,storage,struct,tan,tanh,texelFetch,texture,texture2D,textureLod,toVar,trunc,uint,uniform,uv,uvec2,uvec3,uvec4,variable,vec2,vec3,vec4,vertex,vertexIndex,vertexStage});
64
+ ${a}`),a};var X=null,F=null,E=e=>{if(!X)return;if(X.props.children||(X.props.children=[]),X.props.children.push(e),e.type!=="return"||!F)return e;let{props:t}=F;return t.inferFrom||(t.inferFrom=[]),t.inferFrom.push(e),e};function Q(e,t){t||(t=v());let n=d("variable",{id:t,inferFrom:[e]}),r=d("declare",null,e,n);return E(r),n}var ee=(e,t=!1,n)=>{let r=d(t?"scatter":"assign",null,e,n);return E(r),e},We=e=>E(d("return",{inferFrom:[e]},e)),bt=()=>E(d("break")),$t=()=>E(d("continue")),ht=(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 E(o),s},te=(e,t,n=F)=>{let[r,s]=[X,F];[X,F]=[e,n];let o=t();o&&We(o),[X,F]=[r,s]},S=e=>{let t=d("scope");return te(t,e),t},Ct=(e,t)=>{let n=S(t),r=d("if",null,e,n);E(r);let s=()=>({ElseIf:(o,a)=>{let c=S(a);return r.props.children.push(o,c),s()},Else:o=>{let a=S(o);r.props.children.push(a)}});return s()},Et=(e,t)=>{let n=v(),r=S(()=>t({i:d("variable",{id:n,inferFrom:[T("int",0)]})})),s=d("loop",{id:n},e,r);return E(s)},_t=e=>{let t=d("switch",null,e);E(t);let n=()=>({Case:(...r)=>s=>{let o=S(s);for(let a of r)t.props.children.push(a,o);return n()},Default:r=>{let s=S(r);t.props.children.push(s)}});return n()};function yt(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 te(i,()=>e(a),u),u};return r.getLayout=()=>t,r.setLayout=s=>(t=s,r),r}var Xt=(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 Q.bind(null,a);if(i==="isProxy")return!0;if(i==="toString")return p.bind(null,a);if(i==="fragment")return K.bind(null,a);if(i==="compute")return J.bind(null,a);if(i==="vertex")return Z.bind(null,a);if(i===Symbol.toPrimitive)return Xt.bind(null,a);if(i==="listeners")return r;if(i==="attribute")return(u=v())=>Ve(a,u);if(i==="instance")return(u=v())=>Be(a,u);if(i==="constant")return(u=v())=>ze(a,u);if(i==="uniform")return(u=v())=>Y(a,u);if(i==="variable")return(u=v())=>He(u);if(i==="builtin")return(u=v())=>b(u);if(i==="vertexStage")return(u=v())=>ke(a,u);if(i==="element")return u=>e==="storage"?qe(a,u):ne(a,u);if(i==="member")return u=>N(a,u);if(i==="assign")return ee.bind(null,a,a.type==="gather");if(i==="select")return je.bind(null,a);if(me(i))return i.endsWith("Assign")?(...u)=>E(re(i,a,...u)):(...u)=>re(i,a,...u);if(ge(i))return(...u)=>f(i,a,...u);if(be(i))return()=>T(Ce(i),a);if(l.str(i))return _e(i)?ne(a,i):N(a,i)},o=(c,i,u)=>(i==="value"&&r.forEach(m=>m(u)),l.str(i)&&N(a,i).assign(u),!0),a=new Proxy({},{get:s,set:o});return a},Ve=(e,t=v())=>d("attribute",{id:t},e),Be=(e,t=v())=>d("instance",{id:t},e),ze=(e,t=v())=>d("constant",{id:t},e),Y=(e,t=v())=>d("uniform",{id:t},e),St=(e,t=v())=>d("storage",{id:t},e),He=(e=v())=>d("variable",{id:e}),b=(e=v())=>d("builtin",{id:e}),ke=(e,t=v())=>d("varying",{id:t,inferFrom:[e]},e),N=(e,t)=>d("member",null,e,t),ne=(e,t)=>d("element",null,e,t),qe=(e,t)=>d("gather",null,e,t),Rt=(e,t)=>d("scatter",null,e,t),je=(e,t,n)=>d("ternary",null,e,t,n),re=(e,...t)=>d("operator",null,e,...t),f=(e,...t)=>d("function",null,e,...t),T=(e,...t)=>d("conversion",null,e,...t);var Ke=b("position"),Ft=b("vertex_index"),Yt=b("instance_index"),At=b("front_facing"),Lt=b("frag_depth"),Ut=b("sample_index"),It=b("sample_mask"),Nt=b("point_coord"),Ot=b("global_invocation_id"),wt=b("position"),Gt=b("positionWorld"),Pt=b("positionView"),Dt=b("normalLocal"),Mt=b("normalWorld"),Wt=b("normalView"),Vt=b("screenCoordinate"),Bt=b("screenUV"),Ze=e=>T("float",e),zt=e=>T("int",e),Ht=e=>T("uint",e),kt=e=>T("bool",e),se=(e,t)=>T("vec2",e,t),oe=(e,t,n)=>T("vec3",e,t,n),qt=(e,t,n,r)=>T("vec4",e,t,n,r),jt=(...e)=>T("mat2",...e),Kt=(...e)=>T("mat3",...e),Zt=(...e)=>T("mat4",...e),Jt=(e,t)=>T("ivec2",e,t),Qt=(e,t,n)=>T("ivec3",e,t,n),en=(e,t,n,r)=>T("ivec4",e,t,n,r),tn=(e,t)=>T("uvec2",e,t),nn=(e,t,n)=>T("uvec3",e,t,n),rn=(e,t,n,r)=>T("uvec4",e,t,n,r),on=(e,t)=>T("bvec2",e,t),sn=(e,t,n)=>T("bvec3",e,t,n),an=(e,t,n,r)=>T("bvec4",e,t,n,r),un=e=>T("texture",e),pn=()=>T("sampler2D"),fn=(e,t,n)=>l.num(e)&&l.und(t)&&l.und(n)?oe(...$e(e)):oe(e,t,n),Je=Y(se(),"iResolution"),cn=Y(se(),"iMouse"),ln=Y(Ze(),"iTime"),dn=Ke.xy.div(Je),xn=e=>f("all",e),Tn=e=>f("any",e),mn=e=>f("determinant",e),gn=(e,t)=>f("distance",e,t),vn=(e,t)=>f("dot",e,t),bn=e=>f("length",e),$n=e=>f("lengthSq",e),hn=e=>f("luminance",e),Cn=(e,t)=>f("cross",e,t),En=(e,t,n)=>f("cubeTexture",e,t,n),_n=(e,t,n)=>f("texture",e,t,n),yn=(e,t,n)=>f("texelFetch",e,t,n),Xn=(e,t,n)=>f("textureLod",e,t,n),Sn=e=>f("abs",e),Rn=e=>f("acos",e),Fn=e=>f("acosh",e),Yn=e=>f("asin",e),An=e=>f("asinh",e),Ln=e=>f("atan",e),Un=e=>f("atanh",e),In=e=>f("ceil",e),Nn=e=>f("cos",e),On=e=>f("cosh",e),wn=e=>f("dFdx",e),Gn=e=>f("dFdy",e),Pn=e=>f("degrees",e),Dn=e=>f("exp",e),Mn=e=>f("exp2",e),Wn=e=>f("floor",e),Vn=e=>f("fract",e),Bn=e=>f("fwidth",e),zn=e=>f("inverseSqrt",e),Hn=e=>f("log",e),kn=e=>f("log2",e),qn=e=>f("negate",e),jn=e=>f("normalize",e),Kn=e=>f("oneMinus",e),Zn=e=>f("radians",e),Jn=e=>f("reciprocal",e),Qn=e=>f("round",e),er=e=>f("sign",e),tr=e=>f("sin",e),nr=e=>f("sinh",e),rr=e=>f("sqrt",e),or=e=>f("tan",e),sr=e=>f("tanh",e),ir=e=>f("trunc",e),ar=(e,t)=>f("atan2",e,t),ur=(e,t,n)=>f("clamp",e,t,n),pr=(e,t)=>f("max",e,t),fr=(e,t)=>f("min",e,t),cr=(e,t,n)=>f("mix",e,t,n),lr=(e,t)=>f("pow",e,t),dr=(e,t)=>f("reflect",e,t),xr=(e,t,n)=>f("refract",e,t,n),Tr=(e,t,n)=>f("smoothstep",e,t,n),mr=(e,t)=>f("step",e,t),q=(e,t)=>e.sub(e.div(t).floor().mul(t));0&&(module.exports={Break,Continue,Fn,If,Loop,Return,Scope,Switch,abs,acos,acosh,addToScope,all,any,asin,asinh,assign,atan,atan2,atanh,attribute,bool,builtin,bvec2,bvec3,bvec4,ceil,clamp,color,compute,constant,conversion,cos,cosh,create,cross,cubeTexture,dFdx,dFdy,degrees,determinant,distance,dot,element,exp,exp2,float,floor,fract,fragDepth,fragment,frontFacing,function_,fwidth,gather,iMouse,iResolution,iTime,id,instance,instanceIndex,int,inverseSqrt,ivec2,ivec3,ivec4,length,lengthSq,log,log2,luminance,mat2,mat3,mat4,max,member,min,mix,mod,negate,normalLocal,normalView,normalWorld,normalize,oneMinus,operator,pointCoord,position,positionLocal,positionView,positionWorld,pow,radians,reciprocal,reflect,refract,round,sampleIndex,sampleMask,sampler2D,scatter,scoped,screenCoordinate,screenUV,select,sign,sin,sinh,smoothstep,sqrt,step,storage,struct,tan,tanh,texelFetch,texture,texture2D,textureLod,toVar,trunc,uint,uniform,uv,uvec2,uvec3,uvec4,variable,vec2,vec3,vec4,vertex,vertexIndex,vertexStage});
65
65
  //# sourceMappingURL=node.cjs.map