glre 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,50 +1,50 @@
1
- "use strict";var J=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var rt=(e,t)=>{for(var r in t)J(e,r,{get:t[r],enumerable:!0})},ot=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!tt.call(e,o)&&o!==r&&J(e,o,{get:()=>t[o],enumerable:!(n=Je(t,o))||n.enumerable});return e};var nt=e=>ot(J({},"__esModule",{value:!0}),e);var _o={};rt(_o,{ADDITIONAL_FUNCTIONS:()=>Fe,BOOL_RETURN_FUNCTIONS:()=>M,BUILTIN_TYPES:()=>ne,COMPARISON_OPERATORS:()=>se,COMPONENT_COUNT_TO_TYPE:()=>k,CONSTANTS:()=>L,CONVERSIONS:()=>ee,FIRST_ARG_TYPE_FUNCTIONS:()=>z,FUNCTIONS:()=>re,Fn:()=>Xt,HIGHEST_TYPE_FUNCTIONS:()=>W,If:()=>bt,LOGICAL_OPERATORS:()=>ie,Loop:()=>vt,OPERATORS:()=>$,OPERATOR_KEYS:()=>te,PRESERVE_TYPE_FUNCTIONS:()=>V,SCALAR_RETURN_FUNCTIONS:()=>B,SWIZZLES:()=>ft,Switch:()=>yt,TYPE_MAPPING:()=>oe,VEC3_RETURN_FUNCTIONS:()=>D,VEC4_RETURN_FUNCTIONS:()=>q,WGSL_TO_GLSL_BUILTIN:()=>ae,abs:()=>dr,acos:()=>xr,alignTo256:()=>je,all:()=>gr,any:()=>br,asin:()=>vr,assign:()=>xe,atan:()=>yr,atan2:()=>Xr,attribute:()=>Et,bitcast:()=>Tr,bool:()=>Kt,builtin:()=>Nt,bvec2:()=>ar,bvec3:()=>ur,bvec4:()=>cr,cbrt:()=>_r,ceil:()=>hr,clamp:()=>Er,code:()=>p,color:()=>pr,conversion:()=>b,cos:()=>Pr,createAttrib:()=>_e,createBindGroup:()=>Se,createBufferLayout:()=>Oe,createDescriptor:()=>Re,createDevice:()=>Pe,createGL:()=>Ze,createIbo:()=>Xe,createPipeline:()=>Ne,createProgram:()=>ve,createTexture:()=>he,createTextureSampler:()=>Le,createUniformBuffer:()=>Ce,createVbo:()=>ye,createVertexBuffer:()=>we,cross:()=>Nr,cubeTexture:()=>lr,dFdx:()=>Sr,dFdy:()=>Rr,default:()=>To,defaultFragmentGLSL:()=>Ye,defaultVertexGLSL:()=>ke,degrees:()=>wr,difference:()=>Cr,dig:()=>ct,distance:()=>Lr,dot:()=>Or,each:()=>Ge,equals:()=>Ir,exp:()=>Ur,exp2:()=>Gr,ext:()=>at,faceforward:()=>Fr,fig:()=>ut,float:()=>kt,floor:()=>Ar,flush:()=>st,formatConversions:()=>R,fract:()=>$r,fragCoord:()=>Wt,fragDepth:()=>Ot,fragment:()=>G,frontFacing:()=>Lt,function_:()=>i,fwidth:()=>Br,generateDefine:()=>me,getId:()=>I,getOperator:()=>le,getStride:()=>Te,hex2rgb:()=>fe,iMouse:()=>Rt,iResolution:()=>St,iTime:()=>wt,infer:()=>_,inferImpl:()=>Ve,instanceIndex:()=>Ct,int:()=>Yt,inverseSqrt:()=>Mr,is:()=>g,isConversion:()=>pe,isFunction:()=>ce,isGL:()=>Xo,isNodeProxy:()=>S,isOperator:()=>ue,isServer:()=>Ke,isSwizzle:()=>Y,isWebGPUSupported:()=>He,ivec2:()=>tr,ivec3:()=>rr,ivec4:()=>or,joins:()=>U,length:()=>Vr,lengthSq:()=>Dr,log:()=>zr,log2:()=>Wr,mat2:()=>Qt,mat3:()=>Jt,mat4:()=>er,max:()=>qr,min:()=>kr,mix:()=>Yr,negate:()=>jr,node:()=>c,normalLocal:()=>Bt,normalView:()=>Vt,normalWorld:()=>Mt,normalize:()=>Kr,oneMinus:()=>Hr,operator:()=>De,pointCoord:()=>Gt,position:()=>ze,positionLocal:()=>Ft,positionView:()=>$t,positionWorld:()=>At,pow:()=>Zr,pow2:()=>Qr,pow3:()=>Jr,pow4:()=>eo,radians:()=>to,reciprocal:()=>ro,reflect:()=>oo,refract:()=>no,replace:()=>it,round:()=>so,sampleIndex:()=>It,sampleMask:()=>Ut,saturate:()=>io,screenCoordinate:()=>Dt,screenUV:()=>zt,select:()=>_t,sig:()=>pt,sign:()=>ao,sin:()=>uo,smoothstep:()=>co,sqrt:()=>po,step:()=>fo,swizzle:()=>ge,tan:()=>lo,texture:()=>fr,textureSize:()=>mr,toVar:()=>de,transformDirection:()=>mo,trunc:()=>xo,uint:()=>jt,uniform:()=>j,uvec2:()=>nr,uvec3:()=>sr,uvec4:()=>ir,variable:()=>Pt,varying:()=>ht,vec2:()=>Ht,vec3:()=>be,vec4:()=>Zt,vertex:()=>F,vertexId:()=>qt,vertexIndex:()=>We,webgl:()=>Ee,webgpu:()=>Ie});module.exports=nt(_o);var O=require("reev"),Z=require("refr");var K=require("reev");var g={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)},Ge=(e,t)=>e.forEach(t),st=(e,...t)=>{Ge(e,r=>r(...t))},it=(e="",t="_",r="/")=>e.split(t).join(r),at=(e=".pdf")=>e.split(".").pop()?.toLowerCase()??"",ut=(e=0)=>`${e}`.split(".")[1]?.length??0,ct=(e=0)=>`${e}`.split(".")[0]?.length-(e<0?1:0),pt=(e=0,t=-2)=>(t*=-1,t=Math.pow(10,t),e*=t,e=Math.round(e),e/=t,e);var ft=["x","y","z","w","r","g","b","a","s","t","p","q"],L=["bool","uint","int","float","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","vec2","vec3","vec4","color","mat2","mat3","mat4"],ee=["toFloat","toInt","toUint","toBool","toVec2","toVec3","toVec4","toIvec2","toIvec3","toIvec4","toUvec2","toUvec3","toUvec4","toBvec2","toBvec3","toBvec4","toMat2","toMat3","toMat4","toColor"],$={add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>"},te=Object.keys($),B=["dot","distance","length","lengthSq","determinant","luminance"],M=["all","any"],V=["abs","sign","floor","ceil","round","fract","trunc","sin","cos","tan","asin","acos","atan","exp","exp2","log","log2","sqrt","inverseSqrt","normalize","oneMinus","saturate","negate","reciprocal","dFdx","dFdy","fwidth"],D=["cross"],z=["reflect","refract"],W=["min","max","mix","clamp","step","smoothstep"],q=["texture","textureLod","textureSize","cubeTexture"],Fe=["atan2","degrees","faceforward","bitcast","cbrt","difference","equals","pow","pow2","pow3","pow4","radians","transformDirection"],re=[...B,...M,...V,...D,...z,...W,...q,...Fe],oe={float:"f32",int:"i32",uint:"u32",bool:"bool",vec2:"vec2f",vec3:"vec3f",vec4:"vec4f",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",ivec2:"vec2i",ivec3:"vec3i",ivec4:"vec4i",uvec2:"vec2u",uvec3:"vec3u",uvec4:"vec4u",bvec2:"vec2<bool>",bvec3:"vec3<bool>",bvec4:"vec4<bool>"},k={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},ne={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",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"},se=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],ie=["and","or"],ae={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"};var Y=e=>g.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),ue=e=>te.includes(e),ce=e=>re.includes(e),pe=e=>ee.includes(e),S=e=>!e||typeof e!="object"?!1:e.isProxy,lt=0,fe=e=>{let t=(e>>16&255)/255,r=(e>>8&255)/255,n=(e&255)/255;return[t,r,n]},I=()=>`i${lt++}`,U=(e,t)=>e.filter(r=>!g.und(r)&&!g.nul(r)).map(r=>p(r,t)).join(", "),R=(e,t)=>g.str(e)?t?.isWebGL?e:oe[e]:"",le=e=>$[e]||e,Ae=e=>Array.from(e.headers).map(([,t])=>t).join(`
2
- `),me=(e,t)=>{let{id:r,children:n=[]}=e,[o,s,...u]=n,a=s?_(s,t):"void",m=u.map((h,T)=>[`p${T}`,_(h,t)]),y=[p(o,t)];if(s&&y.push(`return ${p(s,t)};`),t?.isWebGL){let h=m.map(([T,E])=>`${E} ${T}`);return`${a} ${r}(${h}) {
3
- ${y.join(`
4
- `)}
5
- }`}let f=R(a,t),d=m.map(([h,T])=>`${h}: ${R(T,t)}`);return`fn ${r}(${d}) -> ${f} {
6
- ${y.join(`
7
- `)}
8
- }`},$e=(e,t,r=!0)=>r?`
1
+ "use strict";var te=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var nt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rt(t))!ot.call(e,o)&&o!==r&&te(e,o,{get:()=>t[o],enumerable:!(n=tt(t,o))||n.enumerable});return e};var it=e=>st(te({},"__esModule",{value:!0}),e);var Po={};nt(Po,{ADDITIONAL_FUNCTIONS:()=>Me,BOOL_RETURN_FUNCTIONS:()=>V,BUILTIN_TYPES:()=>se,COMPARISON_OPERATORS:()=>ie,COMPONENT_COUNT_TO_TYPE:()=>j,CONSTANTS:()=>C,CONVERSIONS:()=>B,FIRST_ARG_TYPE_FUNCTIONS:()=>q,FUNCTIONS:()=>oe,Fn:()=>St,HIGHEST_TYPE_FUNCTIONS:()=>k,If:()=>Et,LOGICAL_OPERATORS:()=>ae,Loop:()=>Nt,OPERATORS:()=>D,OPERATOR_KEYS:()=>re,PRESERVE_TYPE_FUNCTIONS:()=>z,SCALAR_RETURN_FUNCTIONS:()=>M,SWIZZLES:()=>mt,Switch:()=>Pt,TYPE_MAPPING:()=>ne,VEC3_RETURN_FUNCTIONS:()=>W,VEC4_RETURN_FUNCTIONS:()=>Y,WGSL_TO_GLSL_BUILTIN:()=>ue,abs:()=>vr,acos:()=>yr,alignTo256:()=>Ke,all:()=>Xr,any:()=>_r,asin:()=>Tr,assign:()=>ve,atan:()=>hr,atan2:()=>Er,attribute:()=>Ct,bitcast:()=>Nr,bool:()=>Zt,builtin:()=>h,bvec2:()=>ur,bvec3:()=>cr,bvec4:()=>pr,cbrt:()=>Pr,ceil:()=>Sr,clamp:()=>Rr,code:()=>c,color:()=>fr,constant:()=>wt,conversion:()=>v,conversionToConstant:()=>xe,cos:()=>Cr,createAttrib:()=>Se,createBindGroup:()=>Oe,createBufferLayout:()=>Ae,createDescriptor:()=>Ge,createDevice:()=>Le,createGL:()=>Je,createIbo:()=>Ne,createPipeline:()=>we,createProgram:()=>he,createTexture:()=>Re,createTextureSampler:()=>Ue,createUniformBuffer:()=>Fe,createVbo:()=>Ee,createVertexBuffer:()=>Ie,cross:()=>Lr,cubeTexture:()=>gr,dFdx:()=>wr,dFdy:()=>Or,default:()=>No,defaultFragmentGLSL:()=>He,defaultVertexGLSL:()=>je,degrees:()=>Gr,difference:()=>Ir,dig:()=>ft,distance:()=>Fr,dot:()=>Ur,each:()=>De,equals:()=>Ar,exp:()=>$r,exp2:()=>Br,ext:()=>ct,faceforward:()=>Dr,fig:()=>pt,float:()=>ke,floor:()=>Mr,flush:()=>at,formatConversions:()=>L,fract:()=>Vr,fragDepth:()=>$t,fragment:()=>F,frontFacing:()=>At,function_:()=>i,fwidth:()=>zr,generateDefine:()=>ge,getBluiltin:()=>de,getId:()=>K,getOperator:()=>me,getStride:()=>Pe,hex2rgb:()=>le,iMouse:()=>mr,iResolution:()=>lr,iTime:()=>dr,infer:()=>_,inferImpl:()=>We,instanceIndex:()=>Ut,int:()=>ye,inverseSqrt:()=>Wr,is:()=>b,isConversion:()=>fe,isFunction:()=>pe,isGL:()=>Eo,isNodeProxy:()=>R,isOperator:()=>ce,isServer:()=>Ze,isSwizzle:()=>H,isWebGPUSupported:()=>Qe,ivec2:()=>rr,ivec3:()=>or,ivec4:()=>nr,joins:()=>I,length:()=>qr,lengthSq:()=>kr,log:()=>Yr,log2:()=>jr,mat2:()=>Jt,mat3:()=>er,mat4:()=>tr,max:()=>Hr,min:()=>Kr,mix:()=>Zr,negate:()=>Qr,node:()=>m,normalLocal:()=>Vt,normalView:()=>Wt,normalWorld:()=>zt,normalize:()=>Jr,oneMinus:()=>eo,operator:()=>qe,pointCoord:()=>Mt,position:()=>It,positionLocal:()=>qt,positionView:()=>Yt,positionWorld:()=>kt,pow:()=>to,pow2:()=>ro,pow3:()=>oo,pow4:()=>no,radians:()=>so,reciprocal:()=>io,reflect:()=>ao,refract:()=>uo,replace:()=>ut,round:()=>co,sampleIndex:()=>Bt,sampleMask:()=>Dt,saturate:()=>po,screenCoordinate:()=>jt,screenUV:()=>Ht,select:()=>Gt,sig:()=>lt,sign:()=>fo,sin:()=>lo,smoothstep:()=>mo,sqrt:()=>xo,step:()=>go,swizzle:()=>Xe,tan:()=>bo,texture:()=>xr,textureSize:()=>br,toVar:()=>be,transformDirection:()=>vo,trunc:()=>yo,uint:()=>Kt,uniform:()=>$,uvec2:()=>sr,uvec3:()=>ir,uvec4:()=>ar,variable:()=>Ot,varying:()=>Lt,vec2:()=>Te,vec3:()=>_e,vec4:()=>Qt,vertex:()=>U,vertexIndex:()=>Ft,webgl:()=>Ce,webgpu:()=>$e});module.exports=it(Po);var G=require("reev"),J=require("refr");var Z=require("reev");var b={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)},De=(e,t)=>e.forEach(t),at=(e,...t)=>{De(e,r=>r(...t))},ut=(e="",t="_",r="/")=>e.split(t).join(r),ct=(e=".pdf")=>e.split(".").pop()?.toLowerCase()??"",pt=(e=0)=>`${e}`.split(".")[1]?.length??0,ft=(e=0)=>`${e}`.split(".")[0]?.length-(e<0?1:0),lt=(e=0,t=-2)=>(t*=-1,t=Math.pow(10,t),e*=t,e=Math.round(e),e/=t,e);var mt=["x","y","z","w","r","g","b","a","s","t","p","q"],C=["bool","uint","int","float","bvec2","ivec2","uvec2","vec2","bvec3","ivec3","uvec3","vec3","bvec4","ivec4","uvec4","vec4","color","mat2","mat3","mat4"],B=["toBool","toUint","toInt","toFloat","toBvec2","toIvec2","toUvec2","toVec2","toBvec3","toIvec3","toUvec3","toVec3","toBvec4","toIvec4","toUvec4","toVec4","toColor","toMat2","toMat3","toMat4"],D={add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>"},re=Object.keys(D),M=["dot","distance","length","lengthSq","determinant","luminance"],V=["all","any"],z=["abs","sign","floor","ceil","round","fract","trunc","sin","cos","tan","asin","acos","atan","exp","exp2","log","log2","sqrt","inverseSqrt","normalize","oneMinus","saturate","negate","reciprocal","dFdx","dFdy","fwidth"],W=["cross"],q=["reflect","refract"],k=["min","max","mix","clamp","step","smoothstep"],Y=["texture","textureLod","textureSize","cubeTexture"],Me=["atan2","degrees","faceforward","bitcast","cbrt","difference","equals","pow","pow2","pow3","pow4","radians","transformDirection"],oe=[...M,...V,...z,...W,...q,...k,...Y,...Me],ne={float:"f32",int:"i32",uint:"u32",bool:"bool",vec2:"vec2f",vec3:"vec3f",vec4:"vec4f",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",ivec2:"vec2i",ivec3:"vec3i",ivec4:"vec4i",uvec2:"vec2u",uvec3:"vec3u",uvec4:"vec4u",bvec2:"vec2<bool>",bvec3:"vec3<bool>",bvec4:"vec4<bool>"},j={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},se={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",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"},ie=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],ae=["and","or"],ue={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"};var H=e=>b.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),ce=e=>re.includes(e),pe=e=>oe.includes(e),fe=e=>B.includes(e),R=e=>!e||typeof e!="object"?!1:e.isProxy,le=e=>{let t=(e>>16&255)/255,r=(e>>8&255)/255,n=(e&255)/255;return[t,r,n]},dt=0,K=()=>`i${dt++}`,I=(e,t)=>e.filter(r=>!b.und(r)&&!b.nul(r)).map(r=>c(r,t)).join(", "),L=(e,t)=>b.str(e)?t?.isWebGL?e:ne[e]:"",me=e=>D[e]||e,de=e=>ue[e],xe=e=>{let t=B.indexOf(e);return t!==-1?C[t]:"float"},Ve=e=>Array.from(e.headers).map(([,t])=>t).join(`
2
+ `),ge=(e,t)=>{let{id:r,children:n=[],layout:o}=e,[s,a,...u]=n,d=o?.type&&o?.type!=="auto"?o?.type:a?_(a,t):"void",l=[],p=[];if(o?.inputs)for(let y of o.inputs)l.push([y.name,y.type]);else for(let y=0;y<u.length;y++)l.push([`p${y}`,_(u[y],t)]);let f="";if(t?.isWebGL){for(let[y,E]of l)p.push(`${E} ${y}`);f+=`${d} ${r}(${p}) {
3
+ `}else{for(let[y,E]of l)p.push(`${y}: ${L(E,t)}`);f+=`fn ${r}(${p}) -> ${L(d,t)} {
4
+ `}let N=c(s,t);return N&&(f+=N+`
5
+ `),a&&(f+=`return ${c(a,t)};`),f+=`
6
+ }`,f},xt=`
9
7
  #version 300 es
10
8
  precision mediump float;
11
9
  out vec4 fragColor;
12
- ${t}
13
- void main() {
14
- fragColor = ${e};
15
- }`.trim():`
16
- ${t}
10
+ `.trim(),gt=`
17
11
  @fragment
18
12
  fn main(@builtin(position) position: vec4f) -> @location(0) vec4f {
19
- return ${e};
20
- }`.trim(),G=(e,t={})=>{let r=p(e,t),n=Ae(t),o=$e(r,n,t.isWebGL);return console.log(`// \u2193\u2193\u2193 generated \u2193\u2193\u2193
13
+ `.trim(),bt=(e,t,r=!0)=>{let n="";return r&&(n+=xt),t&&(n+=`
14
+ `+t+`
15
+ `),r?n+=`void main() {
16
+ fragColor = ${e};`:(n+=gt+`
17
+ `,n+=` return ${e};`),n+=`
18
+ }`,n},vt=(e,t,r=!0)=>"",F=(e,t={})=>{let r=c(e,t),n=Ve(t),o=bt(r,n,t.isWebGL);return console.log(`// \u2193\u2193\u2193 generated \u2193\u2193\u2193
21
19
 
22
20
  ${o}
23
21
 
24
- `),o},F=(e,t)=>{let r=p(e,t),n=Ae(t);return $e(r,n,t.isWebGL)};var Me=e=>g.bol(e)?"bool":g.num(e)?"float":g.arr(e)&&k[e.length]||"float",Be=(e,t,r)=>{if(se.includes(r)||ie.includes(r))return"bool";if(e===t||e.includes("vec")&&!t.includes("vec"))return e;if(t.includes("vec")&&!e.includes("vec"))return t;let n=L.indexOf(e),o=L.indexOf(t);return n>=o?e:t},mt=(e,t)=>e.reduce((r,n)=>{let o=_(n,t),s=L.indexOf(r);return L.indexOf(o)>s?o:r},"float"),dt=e=>k[e],xt=e=>ne[e],gt=(e,t,r)=>{let n=t.length>0?_(t[0],r):"float";return z.includes(e)?n:B.includes(e)?"float":M.includes(e)?"bool":V.includes(e)?n:D.includes(e)?"vec3":q.includes(e)?"vec4":W.includes(e)?mt(t,r):n},Ve=(e,t)=>{let{type:r,props:n}=e,{id:o,children:s=[],value:u}=n,[a,m,y]=s;return r==="uniform"||r==="variable"||r==="constant"||r==="attribute"||r==="varying"?Me(u):r==="conversion"?a:r==="operator"?Be(_(m,t),_(y,t),a):r==="function"?gt(a,s.slice(1),t):r==="swizzle"?dt(a.length):r==="ternary"?Be(_(m,t),_(y,t),"add"):r==="define"?m?_(m,t):"void":r==="builtin"?xt(o):"float"},_=(e,t)=>{if(t||(t={}),!S(e))return Me(e);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let r=Ve(e,t);return t.infers.set(e,r),r};var p=(e,t)=>{if(t||(t={}),t.headers||(t.headers=new Map),g.str(e))return e;if(g.num(e))return e.toFixed(1);if(g.bol(e))return e?"true":"false";if(!e)return"";let{type:r,props:n}=e,{id:o="",children:s=[]}=n,[u,a,m]=s,y="";if(r==="uniform"){if(t.headers.has(o))return o;t.binding||(t.binding=0);let f=_(e,t);y=t.isWebGL?`uniform ${f} ${o};`:`@group(0) @binding(${t.binding++}) var<uniform> ${o}: ${R(f,t)};`}if(r==="attribute"){if(t.headers.has(o))return o;y=`${_(e,t)} ${o}`}if(r==="constant"){if(t.headers.has(o))return o;y=`${_(e,t)} ${o}`}if(r==="varying"){if(t.headers.has(o))return o;y=`${_(e,t)} ${o}`}if(y)return t.headers.set(o,y),t.onMount?.(o,n.value),o;if(r==="variable")return o;if(r==="swizzle")return`${p(a,t)}.${p(u,t)}`;if(r==="operator")return u==="not"||u==="bitNot"?`!${p(a,t)}`:`(${p(a,t)} ${le(u)} ${p(m,t)})`;if(r==="function")return u==="negate"?`(-${U(s.slice(1),t)})`:`${u}(${U(s.slice(1),t)})`;if(r==="conversion")return`${R(u,t)}(${U(s.slice(1),t)})`;if(r==="scope")return s.map(f=>p(f,t)).join(`
25
- `);if(r==="assign")return`${p(u,t)} = ${p(a,t)};`;if(r==="define"){let f=s.slice(2),d=`${o}(${f.map(h=>p(h,t))})`;return t.headers.has(o)||t.headers.set(o,me(n,t)),d}if(r==="loop")return`for (int i = 0; i < ${u}; i++) {
26
- ${p(a,t)}
27
- }`;if(r==="if"){let f=`if (${p(u,t)}) {
28
- ${p(a,t)}
29
- }`;for(let d=2;d<s.length;d+=2){let h=d>=s.length-1;f+=h?` else {
30
- ${p(s[d],t)}
31
- }`:` else if (${p(s[d],t)}) {
32
- ${p(s[d+1],t)}
33
- }`}return f}if(r==="switch"){let f=`switch (${p(u,t)}) {
34
- `;for(let d=1;d<s.length;d+=2)d>=s.length-1&&s.length%2===0?f+=`default:
35
- ${p(s[d],t)}
22
+ `),o},U=(e,t)=>{let r=c(e,t),n=Ve(t);return vt(r,n,t.isWebGL)};var yt=(e,t)=>e.reduce((r,n)=>{let o=_(n,t),s=C.indexOf(r);return C.indexOf(o)>s?o:r},"float"),Xt=e=>se[e],_t=(e,t,r)=>{let n=t.length>0?_(t[0],r):"float";return q.includes(e)?n:M.includes(e)?"float":V.includes(e)?"bool":z.includes(e)?n:W.includes(e)?"vec3":Y.includes(e)?"vec4":k.includes(e)?yt(t,r):n},ze=(e,t,r)=>{if(ie.includes(r)||ae.includes(r))return"bool";if(e===t||e.includes("vec")&&!t.includes("vec"))return e;if(t.includes("vec")&&!e.includes("vec"))return t;let n=C.indexOf(e),o=C.indexOf(t);return n>=o?e:t},Tt=e=>b.bol(e)?"bool":b.num(e)?"float":b.arr(e)&&j[e.length]||"float",ht=e=>j[e],We=(e,t)=>{let{type:r,props:n}=e,{id:o,children:s=[],inferFrom:a}=n,[u,d,l]=s;return a?_(a,t):r==="conversion"?u:r==="operator"?ze(_(d,t),_(l,t),u):r==="function"?_t(u,s.slice(1),t):r==="swizzle"?ht(u.length):r==="ternary"?ze(_(d,t),_(l,t),"add"):r==="builtin"?Xt(o):r==="define"?n.layout?.type&&n.layout?.type!=="auto"?n.layout.type:d?_(d,t):"void":_(u,t)},_=(e,t)=>{if(t||(t={}),!R(e))return Tt(e);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let r=We(e,t);return t.infers.set(e,r),r};var c=(e,t)=>{if(t||(t={}),t.headers||(t.headers=new Map),b.str(e))return e;if(b.num(e)){let p=`${e}`;return p.includes(".")?p:p+".0"}if(b.bol(e))return e?"true":"false";if(!e)return"";let{type:r,props:n}=e,{id:o="",children:s=[]}=n,[a,u,d]=s,l="";if(r==="attribute"){if(t.headers.has(o))return o;l=`${_(e,t)} ${o}`}if(r==="uniform"){if(t.headers.has(o))return o;t.binding||(t.binding=0);let p=_(e,t);l=t.isWebGL?`uniform ${p} ${o};`:`@group(0) @binding(${t.binding++}) var<uniform> ${o}: ${L(p,t)};`}if(r==="constant"){if(t.headers.has(o))return o;let p=_(e,t),f=c(a,t);l=t.isWebGL?`const ${p} ${o} = ${f};`:`const ${o}: ${L(p,t)} = ${f};`}if(r==="varying"){if(t.headers.has(o))return o;l=`${_(e,t)} ${o}`}if(l)return t.headers.set(o,l),t.onMount?.(o),o;if(r==="variable")return o;if(r==="swizzle")return`${c(u,t)}.${c(a,t)}`;if(r==="ternary")return`(${c(a,t)} ? ${c(u,t)} : ${c(d,t)})`;if(r==="builtin")return t?.isWebGL?de(o):o;if(r==="conversion")return`${L(a,t)}(${I(s.slice(1),t)})`;if(r==="operator")return a==="not"||a==="bitNot"?`!${c(u,t)}`:`(${c(u,t)} ${me(a)} ${c(d,t)})`;if(r==="function")return a==="negate"?`(-${I(s.slice(1),t)})`:`${a}(${I(s.slice(1),t)})`;if(r==="scope")return s.map(p=>c(p,t)).join(`
23
+ `);if(r==="assign")return`${c(a,t)} = ${c(u,t)};`;if(r==="loop")return t.isWebGL?`for (int i = 0; i < ${a}; i += 1) {
24
+ ${c(u,t)}
25
+ }`:`for (var i: i32 = 0; i < ${a}; i++) {
26
+ ${c(u,t)}
27
+ }`;if(r==="define"){let p=s.slice(2),f=`${o}(${p.map(N=>c(N,t))})`;return t.headers.has(o)||t.headers.set(o,ge(n,t)),f}if(r==="if"){let p=`if (${c(a,t)}) {
28
+ ${c(u,t)}
29
+ }`;for(let f=2;f<s.length;f+=2){let N=f>=s.length-1;p+=N?` else {
30
+ ${c(s[f],t)}
31
+ }`:` else if (${c(s[f],t)}) {
32
+ ${c(s[f+1],t)}
33
+ }`}return p}if(r==="switch"){let p=`switch (${c(a,t)}) {
34
+ `;for(let f=1;f<s.length;f+=2)f>=s.length-1&&s.length%2===0?p+=`default:
35
+ ${c(s[f],t)}
36
36
  break;
37
- `:d+1<s.length&&(f+=`case ${p(s[d],t)}:
38
- ${p(s[d+1],t)}
37
+ `:f+1<s.length&&(p+=`case ${c(s[f],t)}:
38
+ ${c(s[f+1],t)}
39
39
  break;
40
- `);return f+="}",f}if(r==="ternary")return`(${p(u,t)} ? ${p(a,t)} : ${p(m,t)})`;if(r==="declare"){let f=_(a,t),d=u?.props?.id;if(t.isWebGL)return`${f} ${d} = ${p(a,t)};`;let h=R(f);return`var ${d}: ${h} = ${p(a,t)};`}if(r==="builtin"){if(t?.isWebGL){let f=ae[o];if(f)return f;if(o==="uv")return"gl_FragCoord.xy"}return o}return p(u,t)};var w=null,C=(e,t=()=>{})=>{let r=w;w=e,t(),w=r},A=e=>{w&&(w.props.children||(w.props.children=[]),w.props.children.push(e))},de=(e,t)=>{t||(t=I());let r=c("variable",{id:t}),n=c("declare",null,r,e);return A(n),r},xe=(e,t)=>{let r=c("assign",null,e,t);return A(r),e},bt=(e,t)=>{let r=c("scope");C(r,t);let n=c("if",null,e,r);A(n);let o=()=>({ElseIf:(s,u)=>{let a=c("scope");return C(a,u),n.props.children.push(s,a),o()},Else:s=>{let u=c("scope");C(u,s),n.props.children.push(u)}});return o()},vt=(e,t)=>{let r=c("scope");C(r,()=>t({i:c("variable",{id:"i"})}));let n=c("loop",null,e,r);return A(n),n},yt=e=>{let t=c("switch",null,e);A(t);let r=()=>({Case:(...n)=>o=>{let s=c("scope");C(s,o);for(let u of n)t.props.children.push(u,s);return r()},Default:n=>{let o=c("scope");C(o,n),t.props.children.push(o)}});return r()},Xt=e=>{let t=I();return(...r)=>{let n=c("scope"),o,s=[];for(let u=0;u<r.length;u++){let a=`p${u}`,m=c("variable",{id:a});s.push(m)}return C(n,()=>o=e(s)),c("define",{id:t},n,o,...r)}};var Tt=(e,t)=>{if(t==="string")return p(e)},c=(e,t,...r)=>{t||(t={}),r.length&&(t.children=r);let n=(u,a)=>{if(a==="type")return e;if(a==="props")return t;if(a==="toVar")return de.bind(null,s);if(a==="assign")return xe.bind(null,s);if(a==="isProxy")return!0;if(a==="toString")return p.bind(null,s);if(a===Symbol.toPrimitive)return Tt.bind(null,s);if(Y(a))return ge(a,s);if(ue(a))return(...m)=>De(a,s,...m);if(ce(a))return(...m)=>i(a,s,...m);if(pe(a))return b(a,s)},o=(u,a,m)=>Y(a)?(ge(a,s).assign(m),!0):!1,s=new Proxy({},{get:n,set:o});return s};var ge=(e,t)=>c("swizzle",null,e,t),De=(e,...t)=>c("operator",null,e,...t),i=(e,...t)=>c("function",null,e,...t),b=(e,...t)=>c("conversion",null,e,...t);var _t=(e,t,r)=>c("ternary",null,e,t,r),j=(e,t)=>c("uniform",{id:t,value:e}),ht=(e,t)=>c("varying",{id:t,value:e}),Et=(e,t)=>c("varying",{id:t,value:e}),Pt=e=>c("variable",{id:e}),Nt=e=>c("builtin",{id:e}),St=j([1280,800],"iResolution"),Rt=j([0,0],"iMouse"),wt=j(0,"iTime"),ze=c("builtin",{id:"position"}),We=c("builtin",{id:"vertex_index"}),Ct=c("builtin",{id:"instance_index"}),Lt=c("builtin",{id:"front_facing"}),Ot=c("builtin",{id:"frag_depth"}),It=c("builtin",{id:"sample_index"}),Ut=c("builtin",{id:"sample_mask"}),Gt=c("builtin",{id:"point_coord"}),Ft=c("builtin",{id:"position"}),At=c("builtin",{id:"positionWorld"}),$t=c("builtin",{id:"positionView"}),Bt=c("builtin",{id:"normalLocal"}),Mt=c("builtin",{id:"normalWorld"}),Vt=c("builtin",{id:"normalView"}),Dt=c("builtin",{id:"screenCoordinate"}),zt=c("builtin",{id:"screenUV"}),Wt=ze,qt=We,kt=e=>b("float",e),Yt=e=>b("int",e),jt=e=>b("uint",e),Kt=e=>b("bool",e),Ht=(e,t)=>b("vec2",e,t),be=(e,t,r)=>b("vec3",e,t,r),Zt=(e,t,r,n)=>b("vec4",e,t,r,n),Qt=(...e)=>b("mat2",...e),Jt=(...e)=>b("mat3",...e),er=(...e)=>b("mat4",...e),tr=(e,t)=>b("ivec2",e,t),rr=(e,t,r)=>b("ivec3",e,t,r),or=(e,t,r,n)=>b("ivec4",e,t,r,n),nr=(e,t)=>b("uvec2",e,t),sr=(e,t,r)=>b("uvec3",e,t,r),ir=(e,t,r,n)=>b("uvec4",e,t,r,n),ar=(e,t)=>b("bvec2",e,t),ur=(e,t,r)=>b("bvec3",e,t,r),cr=(e,t,r,n)=>b("bvec4",e,t,r,n),pr=(e,t,r)=>g.num(e)&&g.und(t)&&g.und(r)?be(...fe(e)):be(e,t,r),fr=(e,t,r)=>i("texture",e,t,r),lr=(e,t,r)=>i("cubeTexture",e,t,r),mr=(e,t)=>i("textureSize",e,t),dr=e=>i("abs",e),xr=e=>i("acos",e),gr=e=>i("all",e),br=e=>i("any",e),vr=e=>i("asin",e),yr=(e,t)=>t!==void 0?i("atan",e,t):i("atan",e),Xr=(e,t)=>i("atan",e,t),Tr=(e,t)=>i("bitcast",e,t),_r=e=>i("cbrt",e),hr=e=>i("ceil",e),Er=(e,t,r)=>i("clamp",e,t,r),Pr=e=>i("cos",e),Nr=(e,t)=>i("cross",e,t),Sr=e=>i("dFdx",e),Rr=e=>i("dFdy",e),wr=e=>i("degrees",e),Cr=(e,t)=>i("difference",e,t),Lr=(e,t)=>i("distance",e,t),Or=(e,t)=>i("dot",e,t),Ir=(e,t)=>i("equals",e,t),Ur=e=>i("exp",e),Gr=e=>i("exp2",e),Fr=(e,t,r)=>i("faceforward",e,t,r),Ar=e=>i("floor",e),$r=e=>i("fract",e),Br=e=>i("fwidth",e),Mr=e=>i("inverseSqrt",e),Vr=e=>i("length",e),Dr=e=>i("lengthSq",e),zr=e=>i("log",e),Wr=e=>i("log2",e),qr=(e,t)=>i("max",e,t),kr=(e,t)=>i("min",e,t),Yr=(e,t,r)=>i("mix",e,t,r),jr=e=>i("negate",e),Kr=e=>i("normalize",e),Hr=e=>i("oneMinus",e),Zr=(e,t)=>i("pow",e,t),Qr=e=>i("pow2",e),Jr=e=>i("pow3",e),eo=e=>i("pow4",e),to=e=>i("radians",e),ro=e=>i("reciprocal",e),oo=(e,t)=>i("reflect",e,t),no=(e,t,r)=>i("refract",e,t,r),so=e=>i("round",e),io=e=>i("saturate",e),ao=e=>i("sign",e),uo=e=>i("sin",e),co=(e,t,r)=>i("smoothstep",e,t,r),po=e=>i("sqrt",e),fo=(e,t)=>i("step",e,t),lo=e=>i("tan",e),mo=(e,t)=>i("transformDirection",e,t),xo=e=>i("trunc",e);var ke=`
40
+ `);return p+="}",p}if(r==="declare"){let p=_(a,t),f=u?.props?.id;if(t.isWebGL)return`${p} ${f} = ${c(a,t)};`;let N=L(p);return`var ${f}: ${N} = ${c(a,t)};`}return c(a,t)};var w=null,O=(e,t=()=>{})=>{let r=w;w=e,t(),w=r},A=e=>{w&&(w.props.children||(w.props.children=[]),w.props.children.push(e))},be=(e,t)=>{t||(t=K());let r=m("variable",{id:t,inferFrom:e}),n=m("declare",null,e,r);return A(n),r},ve=(e,t)=>{let r=m("assign",null,e,t);return A(r),e},Et=(e,t)=>{let r=m("scope");O(r,t);let n=m("if",null,e,r);A(n);let o=()=>({ElseIf:(s,a)=>{let u=m("scope");return O(u,a),n.props.children.push(s,u),o()},Else:s=>{let a=m("scope");O(a,s),n.props.children.push(a)}});return o()},Nt=(e,t)=>{let r=m("scope");O(r,()=>t({i:m("variable",{id:"i",inferFrom:ye(0)})}));let n=m("loop",null,e,r);return A(n),n},Pt=e=>{let t=m("switch",null,e);A(t);let r=()=>({Case:(...n)=>o=>{let s=m("scope");O(s,o);for(let a of n)t.props.children.push(a,s);return r()},Default:n=>{let o=m("scope");O(o,n),t.props.children.push(o)}});return r()},St=e=>{let t,r=(...n)=>{let o=t?.name||K(),s=m("scope"),a,u=[],d=[];if(t?.inputs)for(let l of t.inputs)d.push({id:l.name,inferFrom:v(l.type)});else for(let l=0;l<n.length;l++)d.push({id:`p${l}`,inferFrom:n[l]});for(let l of d)u.push(m("variable",l));return O(s,()=>a=e(u)),m("define",{id:o,layout:t},s,a,...n)};return r.setLayout=n=>(t=n,r),r};var Rt=(e,t)=>{if(t==="string")return c(e)},m=(e,t,...r)=>{t||(t={}),r.length&&(t.children=r);let n=(a,u)=>{if(u==="type")return e;if(u==="props")return t;if(u==="toVar")return be.bind(null,s);if(u==="assign")return ve.bind(null,s);if(u==="isProxy")return!0;if(u==="toString")return c.bind(null,s);if(u===Symbol.toPrimitive)return Rt.bind(null,s);if(H(u))return Xe(u,s);if(ce(u))return(...d)=>qe(u,s,...d);if(pe(u))return(...d)=>i(u,s,...d);if(fe(u))return()=>v(xe(u),s)},o=(a,u,d)=>H(u)?(Xe(u,s).assign(d),!0):!1,s=new Proxy({},{get:n,set:o});return s},Ct=(e,t)=>m("varying",{id:t},e),$=(e,t)=>m("uniform",{id:t},e),Lt=(e,t)=>m("varying",{id:t},e),wt=(e,t)=>m("constant",{id:t},e),Ot=e=>m("variable",{id:e}),h=e=>m("builtin",{id:e}),Xe=(e,t)=>m("swizzle",null,e,t),qe=(e,...t)=>m("operator",null,e,...t),i=(e,...t)=>m("function",null,e,...t),v=(e,...t)=>m("conversion",null,e,...t),Gt=(e,t,r)=>m("ternary",null,e,t,r);var It=h("position"),Ft=h("vertex_index"),Ut=h("instance_index"),At=h("front_facing"),$t=h("frag_depth"),Bt=h("sample_index"),Dt=h("sample_mask"),Mt=h("point_coord"),Vt=h("normalLocal"),zt=h("normalWorld"),Wt=h("normalView"),qt=h("position"),kt=h("positionWorld"),Yt=h("positionView"),jt=h("screenCoordinate"),Ht=h("screenUV"),ke=e=>v("float",e),ye=e=>v("int",e),Kt=e=>v("uint",e),Zt=e=>v("bool",e),Te=(e,t)=>v("vec2",e,t),_e=(e,t,r)=>v("vec3",e,t,r),Qt=(e,t,r,n)=>v("vec4",e,t,r,n),Jt=(...e)=>v("mat2",...e),er=(...e)=>v("mat3",...e),tr=(...e)=>v("mat4",...e),rr=(e,t)=>v("ivec2",e,t),or=(e,t,r)=>v("ivec3",e,t,r),nr=(e,t,r,n)=>v("ivec4",e,t,r,n),sr=(e,t)=>v("uvec2",e,t),ir=(e,t,r)=>v("uvec3",e,t,r),ar=(e,t,r,n)=>v("uvec4",e,t,r,n),ur=(e,t)=>v("bvec2",e,t),cr=(e,t,r)=>v("bvec3",e,t,r),pr=(e,t,r,n)=>v("bvec4",e,t,r,n),fr=(e,t,r)=>b.num(e)&&b.und(t)&&b.und(r)?_e(...le(e)):_e(e,t,r),lr=$(Te(1280,800),"iResolution"),mr=$(Te(0,0),"iMouse"),dr=$(ke(0),"iTime"),xr=(e,t,r)=>i("texture",e,t,r),gr=(e,t,r)=>i("cubeTexture",e,t,r),br=(e,t)=>i("textureSize",e,t),vr=e=>i("abs",e),yr=e=>i("acos",e),Xr=e=>i("all",e),_r=e=>i("any",e),Tr=e=>i("asin",e),hr=(e,t)=>t!==void 0?i("atan",e,t):i("atan",e),Er=(e,t)=>i("atan",e,t),Nr=(e,t)=>i("bitcast",e,t),Pr=e=>i("cbrt",e),Sr=e=>i("ceil",e),Rr=(e,t,r)=>i("clamp",e,t,r),Cr=e=>i("cos",e),Lr=(e,t)=>i("cross",e,t),wr=e=>i("dFdx",e),Or=e=>i("dFdy",e),Gr=e=>i("degrees",e),Ir=(e,t)=>i("difference",e,t),Fr=(e,t)=>i("distance",e,t),Ur=(e,t)=>i("dot",e,t),Ar=(e,t)=>i("equals",e,t),$r=e=>i("exp",e),Br=e=>i("exp2",e),Dr=(e,t,r)=>i("faceforward",e,t,r),Mr=e=>i("floor",e),Vr=e=>i("fract",e),zr=e=>i("fwidth",e),Wr=e=>i("inverseSqrt",e),qr=e=>i("length",e),kr=e=>i("lengthSq",e),Yr=e=>i("log",e),jr=e=>i("log2",e),Hr=(e,t)=>i("max",e,t),Kr=(e,t)=>i("min",e,t),Zr=(e,t,r)=>i("mix",e,t,r),Qr=e=>i("negate",e),Jr=e=>i("normalize",e),eo=e=>i("oneMinus",e),to=(e,t)=>i("pow",e,t),ro=e=>i("pow2",e),oo=e=>i("pow3",e),no=e=>i("pow4",e),so=e=>i("radians",e),io=e=>i("reciprocal",e),ao=(e,t)=>i("reflect",e,t),uo=(e,t,r)=>i("refract",e,t,r),co=e=>i("round",e),po=e=>i("saturate",e),fo=e=>i("sign",e),lo=e=>i("sin",e),mo=(e,t,r)=>i("smoothstep",e,t,r),xo=e=>i("sqrt",e),go=(e,t)=>i("step",e,t),bo=e=>i("tan",e),vo=(e,t)=>i("transformDirection",e,t),yo=e=>i("trunc",e);var je=`
41
41
  #version 300 es
42
42
  void main() {
43
43
  float x = float(gl_VertexID % 2) * 4.0 - 1.0;
44
44
  float y = float(gl_VertexID / 2) * 4.0 - 1.0;
45
45
  gl_Position = vec4(x, y, 0.0, 1.0);
46
46
  }
47
- `,Ye=`
47
+ `,He=`
48
48
  #version 300 es
49
49
  precision mediump float;
50
50
  uniform vec2 iResolution;
@@ -52,19 +52,19 @@ out vec4 fragColor;
52
52
  void main() {
53
53
  fragColor = vec4(fract(gl_FragCoord.xy / iResolution), 0, 1);
54
54
  }
55
- `,qe=(e,t,r)=>{let n=e.createShader(r);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,t.trim()),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS))return n;let o=e.getShaderInfoLog(n);e.deleteShader(n),console.warn(`Could not compile shader: ${o}`)},ve=(e,t=ke,r=Ye,n=()=>{})=>{S(r)&&(r=G(r,{isWebGL:!0})),S(t)&&(t=F(r,{isWebGL:!0}));let o=e.createProgram(),s=qe(e,t,e.VERTEX_SHADER),u=qe(e,r,e.FRAGMENT_SHADER);if(!s||!u)return n();if(e.attachShader(o,s),e.attachShader(o,u),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS))return o;let a=e.getProgramInfoLog(o);e.deleteProgram(o),n(),console.warn(`Could not link pg: ${a}`)},ye=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(t),e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null),r},Xe=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Int16Array(t),e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),r},Te=(e,t,r)=>{r&&(e=Math.max(...r)+1);let n=t.length/e;return Math.floor(n)},_e=(e,t,r,n,o)=>{e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,t,e.FLOAT,!1,0,0),o&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o)},he=(e,t,r,n)=>{let o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),e.uniform1i(r,n),e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,o)};var Ee=async e=>{let t=e.el.getContext("webgl2"),r=ve(t,e.vs,e.fs,()=>void(e.isLoop=!1));t.useProgram(r);let n=0,o=(0,K.nested)(T=>t.getUniformLocation(r,T)),s=(0,K.nested)(T=>t.getAttribLocation(r,T)),u=(0,K.nested)(()=>n++);return{webgl:{context:t,program:r},render:()=>{t.clear(t.COLOR_BUFFER_BIT),t.viewport(0,0,...e.size),t.drawArrays(t.TRIANGLES,0,3)},clean:()=>t.deleteProgram(r),_attribute:(T="",E,P)=>{let N=s(T,!0),X=ye(t,E),l=Xe(t,P),x=Te(e.count,E,P);_e(t,x,N,X,l)},_uniform:(T,E)=>{let P=o(T);if(g.num(E))return t.uniform1f(P,E);let N=E.length;if(N<=4)return t[`uniform${N}fv`](P,E);N=Math.sqrt(N)<<0,t[`uniformMatrix${N}fv`](P,!1,E)},_texture:(T,E)=>{let P=new Image;Object.assign(P,{src:E,crossOrigin:"anonymous"}),P.decode().then(()=>{let N=o(T),X=u(T);he(t,P,N,X)})}}};var H=require("reev");var go=`
55
+ `,Ye=(e,t,r)=>{let n=e.createShader(r);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,t.trim()),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS))return n;let o=e.getShaderInfoLog(n);e.deleteShader(n),console.warn(`Could not compile shader: ${o}`)},he=(e,t=je,r=He,n=()=>{})=>{R(r)&&(r=F(r,{isWebGL:!0})),R(t)&&(t=U(r,{isWebGL:!0}));let o=e.createProgram(),s=Ye(e,t,e.VERTEX_SHADER),a=Ye(e,r,e.FRAGMENT_SHADER);if(!s||!a)return n();if(e.attachShader(o,s),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS))return o;let u=e.getProgramInfoLog(o);e.deleteProgram(o),n(),console.warn(`Could not link pg: ${u}`)},Ee=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(t),e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null),r},Ne=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Int16Array(t),e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),r},Pe=(e,t,r)=>{r&&(e=Math.max(...r)+1);let n=t.length/e;return Math.floor(n)},Se=(e,t,r,n,o)=>{e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,t,e.FLOAT,!1,0,0),o&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o)},Re=(e,t,r,n)=>{let o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),e.uniform1i(r,n),e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,o)};var Ce=async e=>{let t=e.el.getContext("webgl2"),r=he(t,e.vs,e.fs,()=>void(e.isLoop=!1));t.useProgram(r);let n=0,o=(0,Z.nested)(y=>t.getUniformLocation(r,y)),s=(0,Z.nested)(y=>t.getAttribLocation(r,y)),a=(0,Z.nested)(()=>n++);return{webgl:{context:t,program:r},render:()=>{t.clear(t.COLOR_BUFFER_BIT),t.viewport(0,0,...e.size),t.drawArrays(t.TRIANGLES,0,3)},clean:()=>t.deleteProgram(r),_attribute:(y="",E,P)=>{let S=s(y,!0),T=Ee(t,E),x=Ne(t,P),g=Pe(e.count,E,P);Se(t,g,S,T,x)},_uniform:(y,E)=>{let P=o(y);if(b.num(E))return t.uniform1f(P,E);let S=E.length;if(S<=4)return t[`uniform${S}fv`](P,E);S=Math.sqrt(S)<<0,t[`uniformMatrix${S}fv`](P,!1,E)},_texture:(y,E)=>{let P=new Image;Object.assign(P,{src:E,crossOrigin:"anonymous"}),P.decode().then(()=>{let S=o(y),T=a(y);Re(t,P,S,T)})}}};var Q=require("reev");var Xo=`
56
56
  @vertex
57
57
  fn main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f {
58
58
  let x = f32(vertex_index % 2u) * 4.0 - 1.0;
59
59
  let y = f32(vertex_index / 2u) * 4.0 - 1.0;
60
60
  return vec4f(x, y, 0.0, 1.0);
61
61
  }
62
- `,bo=`
62
+ `,_o=`
63
63
  @group(0) @binding(0) var<uniform> iResolution: vec2f;
64
64
 
65
65
  @fragment
66
66
  fn main(@builtin(position) position: vec4f) -> @location(0) vec4f {
67
67
  return vec4f(position.xy / iResolution, 0.0, 1.0);
68
68
  }
69
- `,Pe=async e=>{let t=navigator.gpu,r=t.getPreferredCanvasFormat(),o=await(await t.requestAdapter()).requestDevice();return e.configure({device:o,format:r,alphaMode:"opaque"}),{device:o,format:r}},Ne=(e,t,r,n,o=go,s=bo)=>{S(o)&&(o=F(o,{isWebGL:!1})),S(s)&&(s=G(s,{isWebGL:!1}));let u=e.createPipelineLayout({bindGroupLayouts:n});return e.createRenderPipeline({vertex:{module:e.createShaderModule({code:o.trim()}),entryPoint:"main",buffers:r},fragment:{module:e.createShaderModule({code:s.trim()}),entryPoint:"main",targets:[{format:t}]},layout:u,primitive:{topology:"triangle-list"}})},Se=(e,t)=>{let r=[],n=[];t.forEach((u,a)=>{if(!u)return;let m="buffer"in u,y=u instanceof GPUTextureView,f=u instanceof GPUSampler;if(m)r.push({binding:a,visibility:3,buffer:{type:"uniform"}});else if(y)r.push({binding:a,visibility:2,texture:{}});else if(f)r.push({binding:a,visibility:2,sampler:{}});else return;n.push({binding:a,resource:u})});let o=e.createBindGroupLayout({entries:r}),s=e.createBindGroup({layout:o,entries:n});return{layout:o,bindGroup:s}},Re=e=>({colorAttachments:[{view:e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]}),je=e=>Math.ceil(e/256)*256,we=(e,t)=>{let r=new Float32Array(t),n=e.createBuffer({size:r.byteLength,usage:40});return{array:r,buffer:n}},Ce=(e,t)=>{let r=new Float32Array(t),n=je(r.byteLength),o=e.createBuffer({size:n,usage:72});return{array:r,buffer:o}},Le=(e,t=1280,r=800)=>{let n=e.createTexture({size:[t,r],format:"rgba8unorm",usage:22}),o=e.createSampler({magFilter:"linear",minFilter:"linear"});return{texture:n,sampler:o}},vo=(e,t)=>e/t,yo=e=>e===2?"float32x2":e===3?"float32x3":e===4?"float32x4":"float32",Oe=(e,t,r=6)=>{let n=vo(t,r);return{arrayStride:n*4,attributes:[{shaderLocation:e,offset:0,format:yo(n)}]}};var Ie=async e=>{let t=e.el.getContext("webgpu"),{device:r,format:n}=await Pe(t),o={device:r,context:t,resources:[[],[]],loadingImg:0,needsUpdate:!0},s=[],u=[],a=[],m=(0,H.nested)((X,l)=>{let{array:x,buffer:v}=we(r,l);return u.push(v),a.push(Oe(a.length,x.length,e.count)),o.needsUpdate=!0,{array:x,buffer:v}}),y=(0,H.nested)((X,l)=>{let{array:x,buffer:v}=Ce(r,l);return o.resources[0].push({buffer:v}),o.needsUpdate=!0,{array:x,buffer:v}}),f=(0,H.nested)((X,{width:l,height:x})=>{let{texture:v,sampler:Q}=Le(r,l,x);return o.resources[1].push(Q,v.createView()),o.needsUpdate=!0,{texture:v,width:l,height:x}}),d=()=>{let X=[];s.length=0,o.resources.forEach(l=>{if(!l.length)return;let{layout:x,bindGroup:v}=Se(r,l);X.push(x),s.push(v)}),o.pipeline=Ne(r,n,a,X,e.vs,e.fs)};return{webgpu:o,render:()=>{if(o.loadingImg)return;o.needsUpdate&&d(),o.needsUpdate=!1;let X=r.createCommandEncoder(),l=X.beginRenderPass(Re(t));l.setPipeline(o.pipeline),s.forEach((x,v)=>l.setBindGroup(v,x)),u.forEach((x,v)=>l.setVertexBuffer(v,x)),l.draw(e.count,1,0,0),l.end(),r.queue.submit([X.finish()])},clean:()=>{},_attribute:(X="",l)=>{let{array:x,buffer:v}=m(X,l);r.queue.writeBuffer(v,0,x)},_uniform:(X,l)=>{g.num(l)&&(l=[l]);let{array:x,buffer:v}=y(X,l);x.set(l),r.queue.writeBuffer(v,0,x)},_texture:(X,l)=>{o.loadingImg++;let x=Object.assign(new Image,{src:l,crossOrigin:"anonymous"});x.decode().then(()=>{let{texture:v,width:Q,height:Qe}=f(X,x);r.queue.copyExternalImageToTexture({source:x},{texture:v},{width:Q,height:Qe}),o.loadingImg--})}}};var Xo=e=>g.obj(e)?"isGL"in e:!1,Ke=()=>typeof window>"u",He=()=>Ke()?!1:"gpu"in navigator,Ue=performance.now(),Ze=e=>{let t=(0,O.event)({isNative:!1,isWebGL:!0,isLoop:!0,isGL:!0,size:[0,0],mouse:[0,0],count:6,webgl:{},webgpu:{}});return t.queue=(0,Z.createQueue)(),t.frame=(0,Z.createFrame)(),t.attribute=(0,O.durable)((r,n,o)=>t.queue(()=>t._attribute?.(r,n,o))),t.texture=(0,O.durable)((r,n)=>t.queue(()=>t._texture?.(r,n))),t.uniform=(0,O.durable)((r,n,o)=>t.queue(()=>t._uniform?.(r,n,o))),t.uniform({iResolution:t.size,iMouse:[0,0],iTime:Ue}),t("mount",async()=>{t.vs=t.vs||t.vert||t.vertex,t.fs=t.fs||t.frag||t.fragment,He()||(t.isWebGL=!0),t.isWebGL?t(await Ee(t)):t(await Ie(t)),t.resize(),t.frame(()=>(t.loop(),t.queue.flush(),t.render(),t.isLoop)),!t.isNative&&(window.addEventListener("resize",t.resize),t.el.addEventListener("mousemove",t.mousemove))}),t("clean",()=>{t.frame.stop(),t.frame.clean(t.render),!t.isNative&&(window.removeEventListener("resize",t.resize),t.el.removeEventListener("mousemove",t.mousemove))}),t("resize",()=>{let r=t.width||window.innerWidth,n=t.height||window.innerHeight;t.size[0]=t.el.width=r,t.size[1]=t.el.height=n,t.uniform("iResolution",t.size)}),t("mousemove",(r,n=r.clientX,o=r.clientY)=>{let[s,u]=t.size,{top:a,left:m}=t.el.getBoundingClientRect();t.mouse[0]=(n-a-s/2)/(s/2),t.mouse[1]=-(o-m-u/2)/(u/2),t.uniform("iMouse",t.mouse)}),t("loop",()=>{Ue=performance.now()/1e3,t.uniform("iTime",Ue)}),t(e)},To=Ze;0&&(module.exports={ADDITIONAL_FUNCTIONS,BOOL_RETURN_FUNCTIONS,BUILTIN_TYPES,COMPARISON_OPERATORS,COMPONENT_COUNT_TO_TYPE,CONSTANTS,CONVERSIONS,FIRST_ARG_TYPE_FUNCTIONS,FUNCTIONS,Fn,HIGHEST_TYPE_FUNCTIONS,If,LOGICAL_OPERATORS,Loop,OPERATORS,OPERATOR_KEYS,PRESERVE_TYPE_FUNCTIONS,SCALAR_RETURN_FUNCTIONS,SWIZZLES,Switch,TYPE_MAPPING,VEC3_RETURN_FUNCTIONS,VEC4_RETURN_FUNCTIONS,WGSL_TO_GLSL_BUILTIN,abs,acos,alignTo256,all,any,asin,assign,atan,atan2,attribute,bitcast,bool,builtin,bvec2,bvec3,bvec4,cbrt,ceil,clamp,code,color,conversion,cos,createAttrib,createBindGroup,createBufferLayout,createDescriptor,createDevice,createGL,createIbo,createPipeline,createProgram,createTexture,createTextureSampler,createUniformBuffer,createVbo,createVertexBuffer,cross,cubeTexture,dFdx,dFdy,defaultFragmentGLSL,defaultVertexGLSL,degrees,difference,dig,distance,dot,each,equals,exp,exp2,ext,faceforward,fig,float,floor,flush,formatConversions,fract,fragCoord,fragDepth,fragment,frontFacing,function_,fwidth,generateDefine,getId,getOperator,getStride,hex2rgb,iMouse,iResolution,iTime,infer,inferImpl,instanceIndex,int,inverseSqrt,is,isConversion,isFunction,isGL,isNodeProxy,isOperator,isServer,isSwizzle,isWebGPUSupported,ivec2,ivec3,ivec4,joins,length,lengthSq,log,log2,mat2,mat3,mat4,max,min,mix,negate,node,normalLocal,normalView,normalWorld,normalize,oneMinus,operator,pointCoord,position,positionLocal,positionView,positionWorld,pow,pow2,pow3,pow4,radians,reciprocal,reflect,refract,replace,round,sampleIndex,sampleMask,saturate,screenCoordinate,screenUV,select,sig,sign,sin,smoothstep,sqrt,step,swizzle,tan,texture,textureSize,toVar,transformDirection,trunc,uint,uniform,uvec2,uvec3,uvec4,variable,varying,vec2,vec3,vec4,vertex,vertexId,vertexIndex,webgl,webgpu});
69
+ `,Le=async e=>{let t=navigator.gpu,r=t.getPreferredCanvasFormat(),o=await(await t.requestAdapter()).requestDevice();return e.configure({device:o,format:r,alphaMode:"opaque"}),{device:o,format:r}},we=(e,t,r,n,o=Xo,s=_o)=>{R(o)&&(o=U(o,{isWebGL:!1})),R(s)&&(s=F(s,{isWebGL:!1}));let a=e.createPipelineLayout({bindGroupLayouts:n});return e.createRenderPipeline({vertex:{module:e.createShaderModule({code:o.trim()}),entryPoint:"main",buffers:r},fragment:{module:e.createShaderModule({code:s.trim()}),entryPoint:"main",targets:[{format:t}]},layout:a,primitive:{topology:"triangle-list"}})},Oe=(e,t)=>{let r=[],n=[];t.forEach((a,u)=>{if(!a)return;let d="buffer"in a,l=a instanceof GPUTextureView,p=a instanceof GPUSampler;if(d)r.push({binding:u,visibility:3,buffer:{type:"uniform"}});else if(l)r.push({binding:u,visibility:2,texture:{}});else if(p)r.push({binding:u,visibility:2,sampler:{}});else return;n.push({binding:u,resource:a})});let o=e.createBindGroupLayout({entries:r}),s=e.createBindGroup({layout:o,entries:n});return{layout:o,bindGroup:s}},Ge=e=>({colorAttachments:[{view:e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]}),Ke=e=>Math.ceil(e/256)*256,Ie=(e,t)=>{let r=new Float32Array(t),n=e.createBuffer({size:r.byteLength,usage:40});return{array:r,buffer:n}},Fe=(e,t)=>{let r=new Float32Array(t),n=Ke(r.byteLength),o=e.createBuffer({size:n,usage:72});return{array:r,buffer:o}},Ue=(e,t=1280,r=800)=>{let n=e.createTexture({size:[t,r],format:"rgba8unorm",usage:22}),o=e.createSampler({magFilter:"linear",minFilter:"linear"});return{texture:n,sampler:o}},To=(e,t)=>e/t,ho=e=>e===2?"float32x2":e===3?"float32x3":e===4?"float32x4":"float32",Ae=(e,t,r=6)=>{let n=To(t,r);return{arrayStride:n*4,attributes:[{shaderLocation:e,offset:0,format:ho(n)}]}};var $e=async e=>{let t=e.el.getContext("webgpu"),{device:r,format:n}=await Le(t),o={device:r,context:t,resources:[[],[]],loadingImg:0,needsUpdate:!0},s=[],a=[],u=[],d=(0,Q.nested)((T,x)=>{let{array:g,buffer:X}=Ie(r,x);return a.push(X),u.push(Ae(u.length,g.length,e.count)),o.needsUpdate=!0,{array:g,buffer:X}}),l=(0,Q.nested)((T,x)=>{let{array:g,buffer:X}=Fe(r,x);return o.resources[0].push({buffer:X}),o.needsUpdate=!0,{array:g,buffer:X}}),p=(0,Q.nested)((T,{width:x,height:g})=>{let{texture:X,sampler:ee}=Ue(r,x,g);return o.resources[1].push(ee,X.createView()),o.needsUpdate=!0,{texture:X,width:x,height:g}}),f=()=>{let T=[];s.length=0,o.resources.forEach(x=>{if(!x.length)return;let{layout:g,bindGroup:X}=Oe(r,x);T.push(g),s.push(X)}),o.pipeline=we(r,n,u,T,e.vs,e.fs)};return{webgpu:o,render:()=>{if(o.loadingImg)return;o.needsUpdate&&f(),o.needsUpdate=!1;let T=r.createCommandEncoder(),x=T.beginRenderPass(Ge(t));x.setPipeline(o.pipeline),s.forEach((g,X)=>x.setBindGroup(X,g)),a.forEach((g,X)=>x.setVertexBuffer(X,g)),x.draw(e.count,1,0,0),x.end(),r.queue.submit([T.finish()])},clean:()=>{},_attribute:(T="",x)=>{let{array:g,buffer:X}=d(T,x);r.queue.writeBuffer(X,0,g)},_uniform:(T,x)=>{b.num(x)&&(x=[x]);let{array:g,buffer:X}=l(T,x);g.set(x),r.queue.writeBuffer(X,0,g)},_texture:(T,x)=>{o.loadingImg++;let g=Object.assign(new Image,{src:x,crossOrigin:"anonymous"});g.decode().then(()=>{let{texture:X,width:ee,height:et}=p(T,g);r.queue.copyExternalImageToTexture({source:g},{texture:X},{width:ee,height:et}),o.loadingImg--})}}};var Eo=e=>b.obj(e)?"isGL"in e:!1,Ze=()=>typeof window>"u",Qe=()=>Ze()?!1:"gpu"in navigator,Be=performance.now(),Je=e=>{let t=(0,G.event)({isNative:!1,isWebGL:!0,isLoop:!0,isGL:!0,size:[0,0],mouse:[0,0],count:6,webgl:{},webgpu:{}});return t.queue=(0,J.createQueue)(),t.frame=(0,J.createFrame)(),t.attribute=(0,G.durable)((r,n,o)=>t.queue(()=>t._attribute?.(r,n,o))),t.texture=(0,G.durable)((r,n)=>t.queue(()=>t._texture?.(r,n))),t.uniform=(0,G.durable)((r,n,o)=>t.queue(()=>t._uniform?.(r,n,o))),t.uniform({iResolution:t.size,iMouse:[0,0],iTime:Be}),t("mount",async()=>{t.vs=t.vs||t.vert||t.vertex,t.fs=t.fs||t.frag||t.fragment,Qe()||(t.isWebGL=!0),t.isWebGL?t(await Ce(t)):t(await $e(t)),t.resize(),t.frame(()=>(t.loop(),t.queue.flush(),t.render(),t.isLoop)),!t.isNative&&(window.addEventListener("resize",t.resize),t.el.addEventListener("mousemove",t.mousemove))}),t("clean",()=>{t.frame.stop(),t.frame.clean(t.render),!t.isNative&&(window.removeEventListener("resize",t.resize),t.el.removeEventListener("mousemove",t.mousemove))}),t("resize",()=>{let r=t.width||window.innerWidth,n=t.height||window.innerHeight;t.size[0]=t.el.width=r,t.size[1]=t.el.height=n,t.uniform("iResolution",t.size)}),t("mousemove",(r,n=r.clientX,o=r.clientY)=>{let[s,a]=t.size,{top:u,left:d}=t.el.getBoundingClientRect();t.mouse[0]=(n-u-s/2)/(s/2),t.mouse[1]=-(o-d-a/2)/(a/2),t.uniform("iMouse",t.mouse)}),t("loop",()=>{Be=performance.now()/1e3,t.uniform("iTime",Be)}),t(e)},No=Je;0&&(module.exports={ADDITIONAL_FUNCTIONS,BOOL_RETURN_FUNCTIONS,BUILTIN_TYPES,COMPARISON_OPERATORS,COMPONENT_COUNT_TO_TYPE,CONSTANTS,CONVERSIONS,FIRST_ARG_TYPE_FUNCTIONS,FUNCTIONS,Fn,HIGHEST_TYPE_FUNCTIONS,If,LOGICAL_OPERATORS,Loop,OPERATORS,OPERATOR_KEYS,PRESERVE_TYPE_FUNCTIONS,SCALAR_RETURN_FUNCTIONS,SWIZZLES,Switch,TYPE_MAPPING,VEC3_RETURN_FUNCTIONS,VEC4_RETURN_FUNCTIONS,WGSL_TO_GLSL_BUILTIN,abs,acos,alignTo256,all,any,asin,assign,atan,atan2,attribute,bitcast,bool,builtin,bvec2,bvec3,bvec4,cbrt,ceil,clamp,code,color,constant,conversion,conversionToConstant,cos,createAttrib,createBindGroup,createBufferLayout,createDescriptor,createDevice,createGL,createIbo,createPipeline,createProgram,createTexture,createTextureSampler,createUniformBuffer,createVbo,createVertexBuffer,cross,cubeTexture,dFdx,dFdy,defaultFragmentGLSL,defaultVertexGLSL,degrees,difference,dig,distance,dot,each,equals,exp,exp2,ext,faceforward,fig,float,floor,flush,formatConversions,fract,fragDepth,fragment,frontFacing,function_,fwidth,generateDefine,getBluiltin,getId,getOperator,getStride,hex2rgb,iMouse,iResolution,iTime,infer,inferImpl,instanceIndex,int,inverseSqrt,is,isConversion,isFunction,isGL,isNodeProxy,isOperator,isServer,isSwizzle,isWebGPUSupported,ivec2,ivec3,ivec4,joins,length,lengthSq,log,log2,mat2,mat3,mat4,max,min,mix,negate,node,normalLocal,normalView,normalWorld,normalize,oneMinus,operator,pointCoord,position,positionLocal,positionView,positionWorld,pow,pow2,pow3,pow4,radians,reciprocal,reflect,refract,replace,round,sampleIndex,sampleMask,saturate,screenCoordinate,screenUV,select,sig,sign,sin,smoothstep,sqrt,step,swizzle,tan,texture,textureSize,toVar,transformDirection,trunc,uint,uniform,uvec2,uvec3,uvec4,variable,varying,vec2,vec3,vec4,vertex,vertexIndex,webgl,webgpu});
70
70
  //# sourceMappingURL=index.cjs.map