@luma.gl/shadertools 9.0.21 → 9.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/dist.dev.js +102 -90
  2. package/dist/dist.min.js +127 -130
  3. package/dist/index.cjs +94 -79
  4. package/dist/index.cjs.map +3 -3
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -1
  8. package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
  9. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  10. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +49 -52
  11. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +10 -29
  12. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  13. package/dist/modules/lighting/pbr-material/pbr-material.js +14 -11
  14. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
  15. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
  16. package/dist/modules/lighting/pbr-material/pbr-projection.js +25 -0
  17. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  18. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +8 -14
  19. package/dist/modules/lighting/phong-material/phong-material.js +1 -1
  20. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  21. package/package.json +2 -2
  22. package/src/index.ts +7 -1
  23. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  24. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
  25. package/src/modules/lighting/pbr-material/pbr-material.ts +25 -52
  26. package/src/modules/lighting/pbr-material/pbr-projection.ts +41 -0
  27. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
  28. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  29. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +0 -1
  30. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +0 -2
  31. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +0 -1
  32. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +0 -48
  33. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +0 -69
package/dist/dist.min.js CHANGED
@@ -4,10 +4,10 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var to=Object.create;var he=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var ro=Object.getOwnPropertyNames;var oo=Object.getPrototypeOf,io=Object.prototype.hasOwnProperty;var so=(n,e,t)=>e in n?he(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ao=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),co=(n,e)=>{for(var t in e)he(n,t,{get:e[t],enumerable:!0})},we=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ro(e))!io.call(n,o)&&o!==t&&he(n,o,{get:()=>e[o],enumerable:!(r=no(e,o))||r.enumerable});return n},Le=(n,e,t)=>(we(n,e,"default"),t&&we(t,e,"default")),rt=(n,e,t)=>(t=n!=null?to(oo(n)):{},we(e||!n||!n.__esModule?he(t,"default",{value:n,enumerable:!0}):t,n)),lo=n=>we(he({},"__esModule",{value:!0}),n);var pn=(n,e,t)=>(so(n,typeof e!="symbol"?e+"":e,t),t);var ke=ao((Yi,dn)=>{dn.exports=globalThis.luma});var Pe={};co(Pe,{ShaderAssembler:()=>me,ShaderModuleInstance:()=>C,_ShaderModuleInstance:()=>C,_getDependencyGraph:()=>Se,_resolveModules:()=>ne,_warp:()=>fe,assembleShaderPairGLSL:()=>Te,brightnessContrast:()=>Jn,bulgePinch:()=>dr,capitalize:()=>Z,colorHalftone:()=>lr,combineInjects:()=>Ln,convertToVec4:()=>_t,denoise:()=>er,dirlight:()=>Kt,dirlight1:()=>Wr,dotScreen:()=>fr,edgeWork:()=>ur,fp32:()=>Hn,fp64:()=>Ar,fp64arithmetic:()=>nn,fxaa:()=>gr,generateShaderForModule:()=>Bn,geometry1:()=>yr,getPassthroughFS:()=>Un,getQualifierDetails:()=>On,getShaderInfo:()=>Ne,getShaderLayoutFromWGSL:()=>Vn,glsl:()=>mn,gouraudLighting:()=>$r,gouraudMaterial:()=>Zt,hexagonalPixelate:()=>_r,hueSaturation:()=>tr,ink:()=>hr,lighting:()=>Q,lights1:()=>te,magnify:()=>pr,noise:()=>nr,normalizeShaderModule:()=>Rn,pbr:()=>eo,pbrMaterial:()=>Zn,phongLighting:()=>Kr,phongMaterial:()=>Jt,picking:()=>Gn,project1:()=>nt,random:()=>q,sepia:()=>rr,swirl:()=>mr,tiltShift:()=>sr,triangleBlur:()=>ar,typeToChannelCount:()=>Dn,typeToChannelSuffix:()=>zn,vibrance:()=>or,vignette:()=>ir,zoomBlur:()=>cr});Le(Pe,rt(ke(),1));var mn=n=>`${n}`;function D(n,e){if(!n)throw new Error(e||"shadertools: assertion failed.")}var ot={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}};function xn(n){let e={};for(let[t,r]of Object.entries(n))e[t]=fo(r);return e}function vn(n,e,t){let r={};for(let[o,i]of Object.entries(e))n&&o in n&&!i.private?(i.validate&&D(i.validate(n[o],i),`${t}: invalid ${o}`),r[o]=n[o]):r[o]=i.value;return r}function fo(n){let e=gn(n);if(e!=="object")return{value:n,...ot[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...ot[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=gn(n.value),{...n,...ot[e],type:e}):{type:"object",value:null};throw new Error("props")}function gn(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var An=`#ifdef MODULE_LOGDEPTH
7
+ "use strict";var __exports__=(()=>{var ro=Object.create;var he=Object.defineProperty;var oo=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var so=Object.getPrototypeOf,ao=Object.prototype.hasOwnProperty;var co=(n,e,t)=>e in n?he(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var lo=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),fo=(n,e)=>{for(var t in e)he(n,t,{get:e[t],enumerable:!0})},we=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of io(e))!ao.call(n,o)&&o!==t&&he(n,o,{get:()=>e[o],enumerable:!(r=oo(e,o))||r.enumerable});return n},Le=(n,e,t)=>(we(n,e,"default"),t&&we(t,e,"default")),rt=(n,e,t)=>(t=n!=null?ro(so(n)):{},we(e||!n||!n.__esModule?he(t,"default",{value:n,enumerable:!0}):t,n)),uo=n=>we(he({},"__esModule",{value:!0}),n);var pn=(n,e,t)=>(co(n,typeof e!="symbol"?e+"":e,t),t);var ke=lo((Bi,dn)=>{dn.exports=globalThis.luma});var Pe={};fo(Pe,{ShaderAssembler:()=>me,ShaderModuleInstance:()=>C,_ShaderModuleInstance:()=>C,_getDependencyGraph:()=>Se,_resolveModules:()=>ne,_warp:()=>fe,assembleShaderPairGLSL:()=>Te,brightnessContrast:()=>tr,bulgePinch:()=>gr,capitalize:()=>Z,colorHalftone:()=>ur,combineInjects:()=>Ln,convertToVec4:()=>_t,denoise:()=>nr,dirlight:()=>Kt,dirlight1:()=>$r,dotScreen:()=>_r,edgeWork:()=>hr,fp32:()=>Wn,fp64:()=>yr,fp64arithmetic:()=>nn,fxaa:()=>vr,generateShaderForModule:()=>Bn,geometry1:()=>Pr,getPassthroughFS:()=>Un,getQualifierDetails:()=>On,getShaderInfo:()=>Ne,getShaderLayoutFromWGSL:()=>Vn,glsl:()=>mn,gouraudLighting:()=>Zr,gouraudMaterial:()=>Zt,hexagonalPixelate:()=>pr,hueSaturation:()=>rr,ink:()=>dr,lighting:()=>Q,lights1:()=>te,magnify:()=>mr,noise:()=>or,normalizeShaderModule:()=>Rn,pbr:()=>no,pbrMaterial:()=>er,phongLighting:()=>Jr,phongMaterial:()=>Jt,picking:()=>Gn,project1:()=>nt,random:()=>q,sepia:()=>ir,swirl:()=>xr,tiltShift:()=>cr,triangleBlur:()=>lr,typeToChannelCount:()=>Yn,typeToChannelSuffix:()=>zn,vibrance:()=>sr,vignette:()=>ar,zoomBlur:()=>fr});Le(Pe,rt(ke(),1));var mn=n=>`${n}`;function Y(n,e){if(!n)throw new Error(e||"shadertools: assertion failed.")}var ot={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}};function xn(n){let e={};for(let[t,r]of Object.entries(n))e[t]=_o(r);return e}function vn(n,e,t){let r={};for(let[o,i]of Object.entries(e))n&&o in n&&!i.private?(i.validate&&Y(i.validate(n[o],i),`${t}: invalid ${o}`),r[o]=n[o]):r[o]=i.value;return r}function _o(n){let e=gn(n);if(e!=="object")return{value:n,...ot[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...ot[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=gn(n.value),{...n,...ot[e],type:e}):{type:"object",value:null};throw new Error("props")}function gn(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var An=`#ifdef MODULE_LOGDEPTH
8
8
  logdepth_adjustPosition(gl_Position);
9
9
  #endif
10
- `,yn=`#ifdef MODULE_MATERIAL
10
+ `,bn=`#ifdef MODULE_MATERIAL
11
11
  gl_FragColor = material_filterColor(gl_FragColor);
12
12
  #endif
13
13
  #ifdef MODULE_LIGHTING
@@ -23,15 +23,15 @@ gl_FragColor = picking_filterPickingColor(gl_FragColor);
23
23
  #ifdef MODULE_LOGDEPTH
24
24
  logdepth_setFragDepth();
25
25
  #endif
26
- `;var uo={vertex:An,fragment:yn},bn=/void\s+main\s*\([^)]*\)\s*\{\n?/,Pn=/}\n?[^{}]*$/,it=[],pe="__LUMA_INJECT_DECLARATIONS__";function wn(n){let e={vertex:{},fragment:{}};for(let t in n){let r=n[t],o=_o(t);typeof r=="string"&&(r={order:0,injection:r}),e[o][t]=r}return e}function _o(n){let e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function de(n,e,t,r=!1){let o=e==="vertex";for(let i in t){let a=t[i];a.sort((u,h)=>u.order-h.order),it.length=a.length;for(let u=0,h=a.length;u<h;++u)it[u]=a[u].injection;let c=`${it.join(`
26
+ `;var ho={vertex:An,fragment:bn},yn=/void\s+main\s*\([^)]*\)\s*\{\n?/,Pn=/}\n?[^{}]*$/,it=[],pe="__LUMA_INJECT_DECLARATIONS__";function wn(n){let e={vertex:{},fragment:{}};for(let t in n){let r=n[t],o=po(t);typeof r=="string"&&(r={order:0,injection:r}),e[o][t]=r}return e}function po(n){let e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function de(n,e,t,r=!1){let o=e==="vertex";for(let i in t){let a=t[i];a.sort((u,h)=>u.order-h.order),it.length=a.length;for(let u=0,h=a.length;u<h;++u)it[u]=a[u].injection;let c=`${it.join(`
27
27
  `)}
28
- `;switch(i){case"vs:#decl":o&&(n=n.replace(pe,c));break;case"vs:#main-start":o&&(n=n.replace(bn,u=>u+c));break;case"vs:#main-end":o&&(n=n.replace(Pn,u=>c+u));break;case"fs:#decl":o||(n=n.replace(pe,c));break;case"fs:#main-start":o||(n=n.replace(bn,u=>u+c));break;case"fs:#main-end":o||(n=n.replace(Pn,u=>c+u));break;default:n=n.replace(i,u=>u+c)}}return n=n.replace(pe,""),r&&(n=n.replace(/\}\s*$/,i=>i+uo[e])),n}function Ln(n){let e={};return D(Array.isArray(n)&&n.length>1),n.forEach(t=>{for(let r in t)e[r]=e[r]?`${e[r]}
29
- ${t[r]}`:t[r]}),e}var ho=1,C=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(t=>{if(t instanceof C)return t;D(typeof t!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(t)}' and use it directly.`),t.name||(console.warn("shader module has no name"),t.name=`shader-module-${ho++}`);let r=new C(t);return r.dependencies=C.instantiateModules(t.dependencies||[]),r})}constructor(e){let{name:t,vs:r,fs:o,dependencies:i=[],uniformTypes:a={},uniformPropTypes:c={},getUniforms:u,deprecations:h=[],defines:p={},inject:d={}}=e;D(typeof t=="string"),this.name=t,this.vs=r,this.fs=o,this.getModuleUniforms=u,this.dependencies=C.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(h),this.defines=p,this.injections=wn(d),this.uniformTypes=a,c&&(this.uniforms=xn(c))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:D(!1)}let r=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
28
+ `;switch(i){case"vs:#decl":o&&(n=n.replace(pe,c));break;case"vs:#main-start":o&&(n=n.replace(yn,u=>u+c));break;case"vs:#main-end":o&&(n=n.replace(Pn,u=>c+u));break;case"fs:#decl":o||(n=n.replace(pe,c));break;case"fs:#main-start":o||(n=n.replace(yn,u=>u+c));break;case"fs:#main-end":o||(n=n.replace(Pn,u=>c+u));break;default:n=n.replace(i,u=>u+c)}}return n=n.replace(pe,""),r&&(n=n.replace(/\}\s*$/,i=>i+ho[e])),n}function Ln(n){let e={};return Y(Array.isArray(n)&&n.length>1),n.forEach(t=>{for(let r in t)e[r]=e[r]?`${e[r]}
29
+ ${t[r]}`:t[r]}),e}var mo=1,C=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(t=>{if(t instanceof C)return t;Y(typeof t!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(t)}' and use it directly.`),t.name||(console.warn("shader module has no name"),t.name=`shader-module-${mo++}`);let r=new C(t);return r.dependencies=C.instantiateModules(t.dependencies||[]),r})}constructor(e){let{name:t,vs:r,fs:o,dependencies:i=[],uniformTypes:a={},uniformPropTypes:c={},getUniforms:u,deprecations:h=[],defines:p={},inject:d={}}=e;Y(typeof t=="string"),this.name=t,this.vs=r,this.fs=o,this.getModuleUniforms=u,this.dependencies=C.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(h),this.defines=p,this.injections=wn(d),this.uniformTypes=a,c&&(this.uniforms=xn(c))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:Y(!1)}let r=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
30
30
 
31
31
  #define MODULE_${r}
32
32
  ${t}
33
33
 
34
- `}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):vn(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(r=>{r.regex?.test(e)&&(r.deprecated?t.deprecated(r.old,r.new)():t.removed(r.old,r.new)())})}_parseDeprecationDefinitions(e){return e.forEach(t=>{switch(t.type){case"function":t.regex=new RegExp(`\\b${t.old}\\(`);break;default:t.regex=new RegExp(`${t.type} ${t.old};`)}}),e}_defaultGetUniforms(e={}){let t={},r=this.uniforms;for(let o in r){let i=r[o];o in e&&!i.private?(i.validate&&D(i.validate(e[o],i),`${this.name}: invalid ${o}`),t[o]=e[o]):t[o]=i.value}return t}};function st(n){if(n.source&&n.platformInfo.type==="webgpu")return{...n,vs:void 0,fs:void 0};if(!n.vs)throw new Error("no vertex shader");let e=kn(n.platformInfo,n.vs),t;return n.fs&&(t=kn(n.platformInfo,n.fs)),{...n,vs:e,fs:t}}function kn(n,e){if(typeof e=="string")return e;switch(n.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function ne(n){let e=C.instantiateModules(n);return po(e)}function po(n){let e={},t={};return Se({modules:n,level:0,moduleMap:e,moduleDepth:t}),Object.keys(t).sort((r,o)=>t[o]-t[r]).map(r=>e[r])}function Se(n){let{modules:e,level:t,moduleMap:r,moduleDepth:o}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)r[i.name]=i,(o[i.name]===void 0||o[i.name]<t)&&(o[i.name]=t);for(let i of e)i.dependencies&&Se({modules:i.dependencies,level:t+1,moduleMap:r,moduleDepth:o})}function Sn(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
34
+ `}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):vn(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(r=>{r.regex?.test(e)&&(r.deprecated?t.deprecated(r.old,r.new)():t.removed(r.old,r.new)())})}_parseDeprecationDefinitions(e){return e.forEach(t=>{switch(t.type){case"function":t.regex=new RegExp(`\\b${t.old}\\(`);break;default:t.regex=new RegExp(`${t.type} ${t.old};`)}}),e}_defaultGetUniforms(e={}){let t={},r=this.uniforms;for(let o in r){let i=r[o];o in e&&!i.private?(i.validate&&Y(i.validate(e[o],i),`${this.name}: invalid ${o}`),t[o]=e[o]):t[o]=i.value}return t}};function st(n){if(n.source&&n.platformInfo.type==="webgpu")return{...n,vs:void 0,fs:void 0};if(!n.vs)throw new Error("no vertex shader");let e=kn(n.platformInfo,n.vs),t;return n.fs&&(t=kn(n.platformInfo,n.fs)),{...n,vs:e,fs:t}}function kn(n,e){if(typeof e=="string")return e;switch(n.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function ne(n){let e=C.instantiateModules(n);return go(e)}function go(n){let e={},t={};return Se({modules:n,level:0,moduleMap:e,moduleDepth:t}),Object.keys(t).sort((r,o)=>t[o]-t[r]).map(r=>e[r])}function Se(n){let{modules:e,level:t,moduleMap:r,moduleDepth:o}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)r[i.name]=i,(o[i.name]===void 0||o[i.name]<t)&&(o[i.name]=t);for(let i of e)i.dependencies&&Se({modules:i.dependencies,level:t+1,moduleMap:r,moduleDepth:o})}function Sn(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
35
35
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
36
36
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
37
37
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
@@ -46,51 +46,51 @@ ${t}
46
46
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
47
47
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
48
48
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
49
- `}}function Tn(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=Nn(n,mo),n;case"fragment":return n=Nn(n,go),n;default:throw new Error(e)}}var En=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
50
- `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],mo=[...En,[at("attribute"),"in $1"],[at("varying"),"out $1"]],go=[...En,[at("varying"),"in $1"]];function Nn(n,e){for(let[t,r]of e)n=n.replace(t,r);return n}function at(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function ct(n,e){let t="";for(let r in n){let o=n[r];if(t+=`void ${o.signature} {
49
+ `}}function Tn(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=Nn(n,xo),n;case"fragment":return n=Nn(n,vo),n;default:throw new Error(e)}}var En=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
50
+ `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],xo=[...En,[at("attribute"),"in $1"],[at("varying"),"out $1"]],vo=[...En,[at("varying"),"in $1"]];function Nn(n,e){for(let[t,r]of e)n=n.replace(t,r);return n}function at(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function ct(n,e){let t="";for(let r in n){let o=n[r];if(t+=`void ${o.signature} {
51
51
  `,o.header&&(t+=` ${o.header}`),e[r]){let i=e[r];i.sort((a,c)=>a.order-c.order);for(let a of i)t+=` ${a.injection}
52
52
  `}o.footer&&(t+=` ${o.footer}`),t+=`}
53
- `}return t}function lt(n){let e={vertex:{},fragment:{}};for(let t of n){let r,o;typeof t!="string"?(r=t,o=r.hook):(r={},o=t),o=o.trim();let[i,a]=o.split(":"),c=o.replace(/\(.+/,""),u=Object.assign(r,{signature:a});switch(i){case"vs":e.vertex[c]=u;break;case"fs":e.fragment[c]=u;break;default:throw new Error(i)}}return e}function Ne(n,e){return{name:xo(n,e),language:"glsl",version:vo(n)}}function xo(n,e="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return r?r[1]:e}function vo(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let r=parseInt(t[1],10);Number.isFinite(r)&&(e=r)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var In=`
53
+ `}return t}function lt(n){let e={vertex:{},fragment:{}};for(let t of n){let r,o;typeof t!="string"?(r=t,o=r.hook):(r={},o=t),o=o.trim();let[i,a]=o.split(":"),c=o.replace(/\(.+/,""),u=Object.assign(r,{signature:a});switch(i){case"vs":e.vertex[c]=u;break;case"fs":e.fragment[c]=u;break;default:throw new Error(i)}}return e}function Ne(n,e){return{name:Ao(n,e),language:"glsl",version:bo(n)}}function Ao(n,e="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return r?r[1]:e}function bo(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let r=parseInt(t[1],10);Number.isFinite(r)&&(e=r)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var In=`
54
54
 
55
55
  ${pe}
56
- `,Ao=`precision highp float;
57
- `;function Fn(n){let e=ne(n.modules||[]);return{source:ft(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e}),getUniforms:ut(e)}}function Cn(n){let e=ne(n.modules||[]);return{vs:ft(n.platformInfo,{...n,source:n.vs,stage:"vertex",modules:e}),fs:ft(n.platformInfo,{...n,source:n.fs,stage:"fragment",modules:e}),getUniforms:ut(e)}}function Te(n){let{vs:e,fs:t}=n,r=ne(n.modules||[]);return{vs:Mn(n.platformInfo,{...n,source:e,stage:"vertex",modules:r}),fs:Mn(n.platformInfo,{...n,source:t,stage:"fragment",modules:r}),getUniforms:ut(r)}}function ft(n,e){let{source:t,stage:r,modules:o,hookFunctions:i=[],inject:a={},log:c}=e;D(typeof t=="string","shader source must be a string");let u=t,h="",p=lt(i),d={},m={},x={};for(let g in a){let A=typeof a[g]=="string"?{injection:a[g],order:0}:a[g],L=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(L){let v=L[2],b=L[3];v?b==="decl"?m[g]=[A]:x[g]=[A]:d[g]=[A]}else x[g]=[A]}let w=n.type!=="webgpu"?o:[];for(let g of w){c&&g.checkDeprecations(u,c);let A=g.getModuleSource(r,"wgsl");h+=A;let L=g.injections[r];for(let v in L){let b=/^(v|f)s:#([\w-]+)$/.exec(v);if(b){let y=b[2]==="decl"?m:x;y[v]=y[v]||[],y[v].push(L[v])}else d[v]=d[v]||[],d[v].push(L[v])}}return h+=In,h=de(h,r,m),h+=ct(p[r],d),h+=u,h=de(h,r,x),h}function Mn(n,e){let{id:t,source:r,stage:o,language:i="glsl",modules:a,defines:c={},hookFunctions:u=[],inject:h={},prologue:p=!0,log:d}=e;D(typeof r=="string","shader source must be a string");let m=i==="glsl"?Ne(r).version:-1,x=n.shaderLanguageVersion,w=m===100?"#version 100":"#version 300 es",A=r.split(`
56
+ `,yo=`precision highp float;
57
+ `;function Fn(n){let e=ne(n.modules||[]);return{source:ft(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e}),getUniforms:ut(e)}}function Cn(n){let e=ne(n.modules||[]);return{vs:ft(n.platformInfo,{...n,source:n.vs,stage:"vertex",modules:e}),fs:ft(n.platformInfo,{...n,source:n.fs,stage:"fragment",modules:e}),getUniforms:ut(e)}}function Te(n){let{vs:e,fs:t}=n,r=ne(n.modules||[]);return{vs:Mn(n.platformInfo,{...n,source:e,stage:"vertex",modules:r}),fs:Mn(n.platformInfo,{...n,source:t,stage:"fragment",modules:r}),getUniforms:ut(r)}}function ft(n,e){let{source:t,stage:r,modules:o,hookFunctions:i=[],inject:a={},log:c}=e;Y(typeof t=="string","shader source must be a string");let u=t,h="",p=lt(i),d={},m={},x={};for(let g in a){let A=typeof a[g]=="string"?{injection:a[g],order:0}:a[g],L=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(L){let v=L[2],y=L[3];v?y==="decl"?m[g]=[A]:x[g]=[A]:d[g]=[A]}else x[g]=[A]}let w=n.type!=="webgpu"?o:[];for(let g of w){c&&g.checkDeprecations(u,c);let A=g.getModuleSource(r,"wgsl");h+=A;let L=g.injections[r];for(let v in L){let y=/^(v|f)s:#([\w-]+)$/.exec(v);if(y){let b=y[2]==="decl"?m:x;b[v]=b[v]||[],b[v].push(L[v])}else d[v]=d[v]||[],d[v].push(L[v])}}return h+=In,h=de(h,r,m),h+=ct(p[r],d),h+=u,h=de(h,r,x),h}function Mn(n,e){let{id:t,source:r,stage:o,language:i="glsl",modules:a,defines:c={},hookFunctions:u=[],inject:h={},prologue:p=!0,log:d}=e;Y(typeof r=="string","shader source must be a string");let m=i==="glsl"?Ne(r).version:-1,x=n.shaderLanguageVersion,w=m===100?"#version 100":"#version 300 es",A=r.split(`
58
58
  `).slice(1).join(`
59
59
  `),L={};a.forEach(S=>{Object.assign(L,S.getDefines())}),Object.assign(L,c);let v="";switch(i){case"wgsl":break;case"glsl":v=p?`${w}
60
60
 
61
61
  // ----- PROLOGUE -------------------------
62
- ${yo({id:t,source:r,stage:o})}
62
+ ${Po({id:t,source:r,stage:o})}
63
63
  ${`#define SHADER_TYPE_${o.toUpperCase()}`}
64
64
  ${Sn(n)}
65
- ${o==="fragment"?Ao:""}
65
+ ${o==="fragment"?yo:""}
66
66
 
67
67
  // ----- APPLICATION DEFINES -------------------------
68
68
 
69
- ${bo(L)}
69
+ ${wo(L)}
70
70
 
71
71
  `:`${w}
72
- `;break}let b=lt(u),P={},y={},k={};for(let S in h){let I=typeof h[S]=="string"?{injection:h[S],order:0}:h[S],M=/^(v|f)s:(#)?([\w-]+)$/.exec(S);if(M){let T=M[2],F=M[3];T?F==="decl"?y[S]=[I]:k[S]=[I]:P[S]=[I]}else k[S]=[I]}for(let S of a){d&&S.checkDeprecations(A,d);let I=S.getModuleSource(o);v+=I;let M=S.injections[o];for(let T in M){let F=/^(v|f)s:#([\w-]+)$/.exec(T);if(F){let R=F[2]==="decl"?y:k;R[T]=R[T]||[],R[T].push(M[T])}else P[T]=P[T]||[],P[T].push(M[T])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=In,v=de(v,o,y),v+=ct(b[o],P),v+=A,v=de(v,o,k),i==="glsl"&&m!==x&&(v=Tn(v,o)),v.trim()}function ut(n){return function(t){let r={};for(let o of n){let i=o.getUniforms(t,r);Object.assign(r,i)}return r}}function yo(n){let{id:e,source:t,stage:r}=n;return e&&t.indexOf("SHADER_NAME")===-1?`
72
+ `;break}let y=lt(u),P={},b={},k={};for(let S in h){let I=typeof h[S]=="string"?{injection:h[S],order:0}:h[S],M=/^(v|f)s:(#)?([\w-]+)$/.exec(S);if(M){let T=M[2],F=M[3];T?F==="decl"?b[S]=[I]:k[S]=[I]:P[S]=[I]}else k[S]=[I]}for(let S of a){d&&S.checkDeprecations(A,d);let I=S.getModuleSource(o);v+=I;let M=S.injections[o];for(let T in M){let F=/^(v|f)s:#([\w-]+)$/.exec(T);if(F){let R=F[2]==="decl"?b:k;R[T]=R[T]||[],R[T].push(M[T])}else P[T]=P[T]||[],P[T].push(M[T])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=In,v=de(v,o,b),v+=ct(y[o],P),v+=A,v=de(v,o,k),i==="glsl"&&m!==x&&(v=Tn(v,o)),v.trim()}function ut(n){return function(t){let r={};for(let o of n){let i=o.getUniforms(t,r);Object.assign(r,i)}return r}}function Po(n){let{id:e,source:t,stage:r}=n;return e&&t.indexOf("SHADER_NAME")===-1?`
73
73
  #define SHADER_NAME ${e}_${r}
74
74
 
75
- `:""}function bo(n={}){let e="";for(let t in n){let r=n[t];(r||Number.isFinite(r))&&(e+=`#define ${t.toUpperCase()} ${n[t]}
76
- `)}return e}var re=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return re.defaultShaderAssembler=re.defaultShaderAssembler||new re,re.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let t=this._getModuleList(e.modules),r=this._hookFunctions,o=st(e);return{...Fn({platformInfo:e.platformInfo,...o,modules:t,hookFunctions:r}),modules:t}}assembleShaderPair(e){let t=st(e),r=this._getModuleList(e.modules),o=this._hookFunctions,{platformInfo:i}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?Cn({platformInfo:i,...t,modules:r,hookFunctions:o}):Te({platformInfo:i,...t,modules:r,hookFunctions:o}),modules:r}}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),r={},o=0;for(let i=0,a=this._defaultModules.length;i<a;++i){let c=this._defaultModules[i],u=c.name;t[o++]=c,r[u]=!0}for(let i=0,a=e.length;i<a;++i){let c=e[i],u=c.name;r[u]||(t[o++]=c,r[u]=!0)}return t.length=o,C.instantiateModules(t)}},me=re;pn(me,"defaultShaderAssembler");function Rn(n){if(!n.normalized&&(n.normalized=!0,n.uniformPropTypes&&!n.getUniforms)){let e=new C(n);n.getUniforms=e.getUniforms.bind(e)}return n}var Po=`out vec4 transform_output;
75
+ `:""}function wo(n={}){let e="";for(let t in n){let r=n[t];(r||Number.isFinite(r))&&(e+=`#define ${t.toUpperCase()} ${n[t]}
76
+ `)}return e}var re=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return re.defaultShaderAssembler=re.defaultShaderAssembler||new re,re.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let t=this._getModuleList(e.modules),r=this._hookFunctions,o=st(e);return{...Fn({platformInfo:e.platformInfo,...o,modules:t,hookFunctions:r}),modules:t}}assembleShaderPair(e){let t=st(e),r=this._getModuleList(e.modules),o=this._hookFunctions,{platformInfo:i}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?Cn({platformInfo:i,...t,modules:r,hookFunctions:o}):Te({platformInfo:i,...t,modules:r,hookFunctions:o}),modules:r}}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),r={},o=0;for(let i=0,a=this._defaultModules.length;i<a;++i){let c=this._defaultModules[i],u=c.name;t[o++]=c,r[u]=!0}for(let i=0,a=e.length;i<a;++i){let c=e[i],u=c.name;r[u]||(t[o++]=c,r[u]=!0)}return t.length=o,C.instantiateModules(t)}},me=re;pn(me,"defaultShaderAssembler");function Rn(n){if(!n.normalized&&(n.normalized=!0,n.uniformPropTypes&&!n.getUniforms)){let e=new C(n);n.getUniforms=e.getUniforms.bind(e)}return n}var Lo=`out vec4 transform_output;
77
77
  void main() {
78
78
  transform_output = vec4(0);
79
- }`,wo=`#version 300 es
80
- ${Po}`;function On(n,e){e=Array.isArray(e)?e:[e];let t=n.replace(/^\s+/,"").split(/\s+/),[r,o,i]=t;if(!e.includes(r)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:r,type:o,name:a}}function Un(n){let{input:e,inputChannels:t,output:r}=n||{};if(!e)return wo;if(!t)throw new Error("inputChannels");let o=Lo(t),i=_t(e,t);return`#version 300 es
79
+ }`,ko=`#version 300 es
80
+ ${Lo}`;function On(n,e){e=Array.isArray(e)?e:[e];let t=n.replace(/^\s+/,"").split(/\s+/),[r,o,i]=t;if(!e.includes(r)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:r,type:o,name:a}}function Un(n){let{input:e,inputChannels:t,output:r}=n||{};if(!e)return ko;if(!t)throw new Error("inputChannels");let o=So(t),i=_t(e,t);return`#version 300 es
81
81
  in ${o} ${e};
82
82
  out vec4 ${r};
83
83
  void main() {
84
84
  ${r} = ${i};
85
- }`}function zn(n){switch(n){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(n)}}function Dn(n){switch(n){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(n)}}function Lo(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function _t(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}function Z(n){return typeof n=="string"?n.charAt(0).toUpperCase()+n.slice(1):n}function Yn(n,e){return ko(n,e)}function ko(n,e){let t=[];switch(e.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":t.push(`uniform ${Z(n.name)} {`);break;case"uniforms":}for(let[r,o]of Object.entries(n.uniformTypes||{})){let i=So(o);switch(e.uniforms){case"scoped-interface-blocks":t.push(` ${i} ${r};`);break;case"unscoped-interface-blocks":t.push(` ${i} ${n.name}_${r};`);break;case"uniforms":t.push(`uniform ${i} ${n.name}_${r};`)}}switch(e.uniforms){case"scoped-interface-blocks":t.push(`} ${n.name};`);break;case"unscoped-interface-blocks":t.push("};");break;case"uniforms":}return t.push(""),t.join(`
86
- `)}function So(n){return{f32:"float",i32:"int",u32:"uint","vec2<f32>":"vec2","vec3<f32>":"vec3","vec4<f32>":"vec4","vec2<i32>":"ivec2","vec3<i32>":"ivec3","vec4<i32>":"ivec4","vec2<u32>":"uvec2","vec3<u32>":"uvec3","vec4<u32>":"uvec4","mat2x2<f32>":"mat2","mat2x3<f32>":"mat2x3","mat2x4<f32>":"mat2x4","mat3x2<f32>":"mat3x2","mat3x3<f32>":"mat3","mat3x4<f32>":"mat3x4","mat4x2<f32>":"mat4x2","mat4x3<f32>":"mat4x3","mat4x4<f32>":"mat4"}[n]}function Xn(n,e){return No(n,e)}function No(n,e){let t=[];t.push(`struct ${Z(n.name)} {`);for(let[r,o]of Object.entries(n?.uniformTypes||{})){let i=o;t.push(` ${r} : ${i};`)}return t.push("};"),t.push(`var<uniform> ${n.name} : ${Z(n.name)};`),t.join(`
87
- `)}function Bn(n,e){switch(e.shaderLanguage){case"glsl":return Yn(n,e);case"wgsl":return Xn(n,e)}}var qn=rt(ke(),1);var ht=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},B=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(e){throw new Error("Cannot evaluate node")}evaluateString(e){return this.evaluate(e).toString()}search(e){}searchBlock(e,t){if(e){t(ae.instance);for(let r of e)r instanceof Array?this.searchBlock(r,t):r.search(t);t(ce.instance)}}},ae=class extends B{};ae.instance=new ae;var ce=class extends B{};ce.instance=new ce;var N=class extends B{constructor(){super()}},xe=class extends N{constructor(e,t,r,o,i,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=r,this.body=o,this.startLine=i,this.endLine=a}get astNodeType(){return"function"}search(e){this.searchBlock(this.body,e)}},pt=class extends N{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},dt=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},mt=class extends N{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},gt=class extends N{constructor(e,t,r,o){super(),this.init=e,this.condition=t,this.increment=r,this.body=o}get astNodeType(){return"for"}search(e){var t,r,o;(t=this.init)===null||t===void 0||t.search(e),(r=this.condition)===null||r===void 0||r.search(e),(o=this.increment)===null||o===void 0||o.search(e),this.searchBlock(this.body,e)}},H=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Ee=class extends N{constructor(e,t,r){super(),this.name=e,this.type=t,this.value=r}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},ve=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Me=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},le;(function(n){n.increment="++",n.decrement="--"})(le||(le={}));(function(n){function e(t){let r=t;if(r=="parse")throw new Error("Invalid value for IncrementOperator");return n[r]}n.parse=e})(le||(le={}));var xt=class extends N{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}},Ae;(function(n){n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(Ae||(Ae={}));(function(n){function e(t){let r=t;if(r=="parse")throw new Error("Invalid value for AssignOperator");return r}n.parse=e})(Ae||(Ae={}));var vt=class extends N{constructor(e,t,r){super(),this.operator=e,this.variable=t,this.value=r}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Ie=class extends N{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}search(e){for(let t of this.args)t.search(e);e(this)}},At=class extends N{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}},yt=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"body"}},bt=class extends N{constructor(e,t,r,o){super(),this.condition=e,this.body=t,this.elseif=r,this.else=o}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}},Pt=class extends N{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},wt=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Lt=class extends N{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},kt=class extends N{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}},Fe=class extends N{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}},St=class extends N{constructor(){super()}get astNodeType(){return"discard"}},Nt=class extends N{constructor(){super()}get astNodeType(){return"break"}},Tt=class extends N{constructor(){super()}get astNodeType(){return"continue"}},G=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},V=class extends G{constructor(e,t,r,o){super(e),this.members=t,this.startLine=r,this.endLine=o}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}},Ce=class extends G{constructor(e,t,r){super(e),this.format=t,this.access=r}get astNodeType(){return"template"}},Et=class extends G{constructor(e,t,r,o){super(e),this.storage=t,this.type=r,this.access=o}get astNodeType(){return"pointer"}},Re=class extends G{constructor(e,t,r,o){super(e),this.attributes=t,this.format=r,this.count=o}get astNodeType(){return"array"}get isArray(){return!0}},J=class extends G{constructor(e,t,r){super(e),this.format=t,this.access=r}get astNodeType(){return"sampler"}},U=class extends B{constructor(){super()}},Oe=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},$=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){e(this);for(let t of this.args)t.search(e)}},Ue=class extends U{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"callExpr"}evaluate(e){switch(this.name){case"abs":return Math.abs(this.args[0].evaluate(e));case"acos":return Math.acos(this.args[0].evaluate(e));case"acosh":return Math.acosh(this.args[0].evaluate(e));case"asin":return Math.asin(this.args[0].evaluate(e));case"asinh":return Math.asinh(this.args[0].evaluate(e));case"atan":return Math.atan(this.args[0].evaluate(e));case"atan2":return Math.atan2(this.args[0].evaluate(e),this.args[1].evaluate(e));case"atanh":return Math.atanh(this.args[0].evaluate(e));case"ceil":return Math.ceil(this.args[0].evaluate(e));case"clamp":return Math.min(Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e)),this.args[2].evaluate(e));case"cos":return Math.cos(this.args[0].evaluate(e));case"degrees":return this.args[0].evaluate(e)*180/Math.PI;case"distance":return Math.sqrt(Math.pow(this.args[0].evaluate(e)-this.args[1].evaluate(e),2));case"dot":case"exp":return Math.exp(this.args[0].evaluate(e));case"exp2":return Math.pow(2,this.args[0].evaluate(e));case"floor":return Math.floor(this.args[0].evaluate(e));case"fma":return this.args[0].evaluate(e)*this.args[1].evaluate(e)+this.args[2].evaluate(e);case"fract":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"inverseSqrt":return 1/Math.sqrt(this.args[0].evaluate(e));case"log":return Math.log(this.args[0].evaluate(e));case"log2":return Math.log2(this.args[0].evaluate(e));case"max":return Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e));case"min":return Math.min(this.args[0].evaluate(e),this.args[1].evaluate(e));case"mix":return this.args[0].evaluate(e)*(1-this.args[2].evaluate(e))+this.args[1].evaluate(e)*this.args[2].evaluate(e);case"modf":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"pow":return Math.pow(this.args[0].evaluate(e),this.args[1].evaluate(e));case"radians":return this.args[0].evaluate(e)*Math.PI/180;case"round":return Math.round(this.args[0].evaluate(e));case"sign":return Math.sign(this.args[0].evaluate(e));case"sin":return Math.sin(this.args[0].evaluate(e));case"sinh":return Math.sinh(this.args[0].evaluate(e));case"saturate":return Math.min(Math.max(this.args[0].evaluate(e),0),1);case"smoothstep":return this.args[0].evaluate(e)*this.args[0].evaluate(e)*(3-2*this.args[0].evaluate(e));case"sqrt":return Math.sqrt(this.args[0].evaluate(e));case"step":return this.args[0].evaluate(e)<this.args[1].evaluate(e)?0:1;case"tan":return Math.tan(this.args[0].evaluate(e));case"tanh":return Math.tanh(this.args[0].evaluate(e));case"trunc":return Math.trunc(this.args[0].evaluate(e));default:throw new Error("Non const function: "+this.name)}}search(e){for(let t of this.args)t.search(e);e(this)}},ye=class extends U{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}evaluate(e){let t=e.constants.get(this.name);if(!t)throw new Error("Cannot evaluate node");return t.evaluate(e)}},ze=class extends U{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}evaluate(e){var t,r;if(this.initializer instanceof $){let o=(t=this.postfix)===null||t===void 0?void 0:t.evaluateString(e),i=(r=this.initializer.type)===null||r===void 0?void 0:r.name,a=e.structs.get(i),c=a?.getMemberIndex(o);if(c!=-1)return this.initializer.args[c].evaluate(e);console.log(c)}return this.initializer.evaluate(e)}search(e){this.initializer.search(e)}},De=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Mt=class extends U{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},It=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}search(e){this.searchBlock(this.args,e)}},Ye=class extends U{constructor(e){super(),this.contents=e}get astNodeType(){return"groupExpr"}evaluate(e){return this.contents[0].evaluate(e)}search(e){this.searchBlock(this.contents,e)}},Ft=class extends U{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},Xe=class extends U{constructor(){super()}},Ct=class extends Xe{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}evaluate(e){switch(this.operator){case"+":return this.right.evaluate(e);case"-":return-this.right.evaluate(e);case"!":return this.right.evaluate(e)?0:1;case"~":return~this.right.evaluate(e);default:throw new Error("Unknown unary operator: "+this.operator)}}search(e){this.right.search(e)}},Y=class extends Xe{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}get astNodeType(){return"binaryOp"}evaluate(e){switch(this.operator){case"+":return this.left.evaluate(e)+this.right.evaluate(e);case"-":return this.left.evaluate(e)-this.right.evaluate(e);case"*":return this.left.evaluate(e)*this.right.evaluate(e);case"/":return this.left.evaluate(e)/this.right.evaluate(e);case"%":return this.left.evaluate(e)%this.right.evaluate(e);case"==":return this.left.evaluate(e)==this.right.evaluate(e)?1:0;case"!=":return this.left.evaluate(e)!=this.right.evaluate(e)?1:0;case"<":return this.left.evaluate(e)<this.right.evaluate(e)?1:0;case">":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(e){this.left.search(e),this.right.search(e)}},Be=class extends B{constructor(){super()}},Rt=class extends Be{constructor(e,t){super(),this.selector=e,this.body=t}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},Ot=class extends Be{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Ut=class extends B{constructor(e,t,r){super(),this.name=e,this.type=t,this.attributes=r}get astNodeType(){return"argument"}},zt=class extends B{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Dt=class extends B{constructor(e,t,r){super(),this.name=e,this.type=t,this.attributes=r}get astNodeType(){return"member"}},Yt=class extends B{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}},_,f;(function(n){n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(f||(f={}));var l=class{constructor(e,t,r){this.name=e,this.type=t,this.rule=r}toString(){return this.name}},s=class{};_=s;s.none=new l("",f.reserved,"");s.eof=new l("EOF",f.token,"");s.reserved={asm:new l("asm",f.reserved,"asm"),bf16:new l("bf16",f.reserved,"bf16"),do:new l("do",f.reserved,"do"),enum:new l("enum",f.reserved,"enum"),f16:new l("f16",f.reserved,"f16"),f64:new l("f64",f.reserved,"f64"),handle:new l("handle",f.reserved,"handle"),i8:new l("i8",f.reserved,"i8"),i16:new l("i16",f.reserved,"i16"),i64:new l("i64",f.reserved,"i64"),mat:new l("mat",f.reserved,"mat"),premerge:new l("premerge",f.reserved,"premerge"),regardless:new l("regardless",f.reserved,"regardless"),typedef:new l("typedef",f.reserved,"typedef"),u8:new l("u8",f.reserved,"u8"),u16:new l("u16",f.reserved,"u16"),u64:new l("u64",f.reserved,"u64"),unless:new l("unless",f.reserved,"unless"),using:new l("using",f.reserved,"using"),vec:new l("vec",f.reserved,"vec"),void:new l("void",f.reserved,"void")};s.keywords={array:new l("array",f.keyword,"array"),atomic:new l("atomic",f.keyword,"atomic"),bool:new l("bool",f.keyword,"bool"),f32:new l("f32",f.keyword,"f32"),i32:new l("i32",f.keyword,"i32"),mat2x2:new l("mat2x2",f.keyword,"mat2x2"),mat2x3:new l("mat2x3",f.keyword,"mat2x3"),mat2x4:new l("mat2x4",f.keyword,"mat2x4"),mat3x2:new l("mat3x2",f.keyword,"mat3x2"),mat3x3:new l("mat3x3",f.keyword,"mat3x3"),mat3x4:new l("mat3x4",f.keyword,"mat3x4"),mat4x2:new l("mat4x2",f.keyword,"mat4x2"),mat4x3:new l("mat4x3",f.keyword,"mat4x3"),mat4x4:new l("mat4x4",f.keyword,"mat4x4"),ptr:new l("ptr",f.keyword,"ptr"),sampler:new l("sampler",f.keyword,"sampler"),sampler_comparison:new l("sampler_comparison",f.keyword,"sampler_comparison"),struct:new l("struct",f.keyword,"struct"),texture_1d:new l("texture_1d",f.keyword,"texture_1d"),texture_2d:new l("texture_2d",f.keyword,"texture_2d"),texture_2d_array:new l("texture_2d_array",f.keyword,"texture_2d_array"),texture_3d:new l("texture_3d",f.keyword,"texture_3d"),texture_cube:new l("texture_cube",f.keyword,"texture_cube"),texture_cube_array:new l("texture_cube_array",f.keyword,"texture_cube_array"),texture_multisampled_2d:new l("texture_multisampled_2d",f.keyword,"texture_multisampled_2d"),texture_storage_1d:new l("texture_storage_1d",f.keyword,"texture_storage_1d"),texture_storage_2d:new l("texture_storage_2d",f.keyword,"texture_storage_2d"),texture_storage_2d_array:new l("texture_storage_2d_array",f.keyword,"texture_storage_2d_array"),texture_storage_3d:new l("texture_storage_3d",f.keyword,"texture_storage_3d"),texture_depth_2d:new l("texture_depth_2d",f.keyword,"texture_depth_2d"),texture_depth_2d_array:new l("texture_depth_2d_array",f.keyword,"texture_depth_2d_array"),texture_depth_cube:new l("texture_depth_cube",f.keyword,"texture_depth_cube"),texture_depth_cube_array:new l("texture_depth_cube_array",f.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new l("texture_depth_multisampled_2d",f.keyword,"texture_depth_multisampled_2d"),texture_external:new l("texture_external",f.keyword,"texture_external"),u32:new l("u32",f.keyword,"u32"),vec2:new l("vec2",f.keyword,"vec2"),vec3:new l("vec3",f.keyword,"vec3"),vec4:new l("vec4",f.keyword,"vec4"),bitcast:new l("bitcast",f.keyword,"bitcast"),block:new l("block",f.keyword,"block"),break:new l("break",f.keyword,"break"),case:new l("case",f.keyword,"case"),continue:new l("continue",f.keyword,"continue"),continuing:new l("continuing",f.keyword,"continuing"),default:new l("default",f.keyword,"default"),diagnostic:new l("diagnostic",f.keyword,"diagnostic"),discard:new l("discard",f.keyword,"discard"),else:new l("else",f.keyword,"else"),enable:new l("enable",f.keyword,"enable"),fallthrough:new l("fallthrough",f.keyword,"fallthrough"),false:new l("false",f.keyword,"false"),fn:new l("fn",f.keyword,"fn"),for:new l("for",f.keyword,"for"),function:new l("function",f.keyword,"function"),if:new l("if",f.keyword,"if"),let:new l("let",f.keyword,"let"),const:new l("const",f.keyword,"const"),loop:new l("loop",f.keyword,"loop"),while:new l("while",f.keyword,"while"),private:new l("private",f.keyword,"private"),read:new l("read",f.keyword,"read"),read_write:new l("read_write",f.keyword,"read_write"),return:new l("return",f.keyword,"return"),requires:new l("requires",f.keyword,"requires"),storage:new l("storage",f.keyword,"storage"),switch:new l("switch",f.keyword,"switch"),true:new l("true",f.keyword,"true"),alias:new l("alias",f.keyword,"alias"),type:new l("type",f.keyword,"type"),uniform:new l("uniform",f.keyword,"uniform"),var:new l("var",f.keyword,"var"),override:new l("override",f.keyword,"override"),workgroup:new l("workgroup",f.keyword,"workgroup"),write:new l("write",f.keyword,"write"),r8unorm:new l("r8unorm",f.keyword,"r8unorm"),r8snorm:new l("r8snorm",f.keyword,"r8snorm"),r8uint:new l("r8uint",f.keyword,"r8uint"),r8sint:new l("r8sint",f.keyword,"r8sint"),r16uint:new l("r16uint",f.keyword,"r16uint"),r16sint:new l("r16sint",f.keyword,"r16sint"),r16float:new l("r16float",f.keyword,"r16float"),rg8unorm:new l("rg8unorm",f.keyword,"rg8unorm"),rg8snorm:new l("rg8snorm",f.keyword,"rg8snorm"),rg8uint:new l("rg8uint",f.keyword,"rg8uint"),rg8sint:new l("rg8sint",f.keyword,"rg8sint"),r32uint:new l("r32uint",f.keyword,"r32uint"),r32sint:new l("r32sint",f.keyword,"r32sint"),r32float:new l("r32float",f.keyword,"r32float"),rg16uint:new l("rg16uint",f.keyword,"rg16uint"),rg16sint:new l("rg16sint",f.keyword,"rg16sint"),rg16float:new l("rg16float",f.keyword,"rg16float"),rgba8unorm:new l("rgba8unorm",f.keyword,"rgba8unorm"),rgba8unorm_srgb:new l("rgba8unorm_srgb",f.keyword,"rgba8unorm_srgb"),rgba8snorm:new l("rgba8snorm",f.keyword,"rgba8snorm"),rgba8uint:new l("rgba8uint",f.keyword,"rgba8uint"),rgba8sint:new l("rgba8sint",f.keyword,"rgba8sint"),bgra8unorm:new l("bgra8unorm",f.keyword,"bgra8unorm"),bgra8unorm_srgb:new l("bgra8unorm_srgb",f.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new l("rgb10a2unorm",f.keyword,"rgb10a2unorm"),rg11b10float:new l("rg11b10float",f.keyword,"rg11b10float"),rg32uint:new l("rg32uint",f.keyword,"rg32uint"),rg32sint:new l("rg32sint",f.keyword,"rg32sint"),rg32float:new l("rg32float",f.keyword,"rg32float"),rgba16uint:new l("rgba16uint",f.keyword,"rgba16uint"),rgba16sint:new l("rgba16sint",f.keyword,"rgba16sint"),rgba16float:new l("rgba16float",f.keyword,"rgba16float"),rgba32uint:new l("rgba32uint",f.keyword,"rgba32uint"),rgba32sint:new l("rgba32sint",f.keyword,"rgba32sint"),rgba32float:new l("rgba32float",f.keyword,"rgba32float"),static_assert:new l("static_assert",f.keyword,"static_assert")};s.tokens={decimal_float_literal:new l("decimal_float_literal",f.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new l("hex_float_literal",f.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new l("int_literal",f.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new l("uint_literal",f.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new l("ident",f.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new l("and",f.token,"&"),and_and:new l("and_and",f.token,"&&"),arrow:new l("arrow ",f.token,"->"),attr:new l("attr",f.token,"@"),forward_slash:new l("forward_slash",f.token,"/"),bang:new l("bang",f.token,"!"),bracket_left:new l("bracket_left",f.token,"["),bracket_right:new l("bracket_right",f.token,"]"),brace_left:new l("brace_left",f.token,"{"),brace_right:new l("brace_right",f.token,"}"),colon:new l("colon",f.token,":"),comma:new l("comma",f.token,","),equal:new l("equal",f.token,"="),equal_equal:new l("equal_equal",f.token,"=="),not_equal:new l("not_equal",f.token,"!="),greater_than:new l("greater_than",f.token,">"),greater_than_equal:new l("greater_than_equal",f.token,">="),shift_right:new l("shift_right",f.token,">>"),less_than:new l("less_than",f.token,"<"),less_than_equal:new l("less_than_equal",f.token,"<="),shift_left:new l("shift_left",f.token,"<<"),modulo:new l("modulo",f.token,"%"),minus:new l("minus",f.token,"-"),minus_minus:new l("minus_minus",f.token,"--"),period:new l("period",f.token,"."),plus:new l("plus",f.token,"+"),plus_plus:new l("plus_plus",f.token,"++"),or:new l("or",f.token,"|"),or_or:new l("or_or",f.token,"||"),paren_left:new l("paren_left",f.token,"("),paren_right:new l("paren_right",f.token,")"),semicolon:new l("semicolon",f.token,";"),star:new l("star",f.token,"*"),tilde:new l("tilde",f.token,"~"),underscore:new l("underscore",f.token,"_"),xor:new l("xor",f.token,"^"),plus_equal:new l("plus_equal",f.token,"+="),minus_equal:new l("minus_equal",f.token,"-="),times_equal:new l("times_equal",f.token,"*="),division_equal:new l("division_equal",f.token,"/="),modulo_equal:new l("modulo_equal",f.token,"%="),and_equal:new l("and_equal",f.token,"&="),or_equal:new l("or_equal",f.token,"|="),xor_equal:new l("xor_equal",f.token,"^="),shift_right_equal:new l("shift_right_equal",f.token,">>="),shift_left_equal:new l("shift_left_equal",f.token,"<<=")};s.simpleTokens={"@":_.tokens.attr,"{":_.tokens.brace_left,"}":_.tokens.brace_right,":":_.tokens.colon,",":_.tokens.comma,"(":_.tokens.paren_left,")":_.tokens.paren_right,";":_.tokens.semicolon};s.literalTokens={"&":_.tokens.and,"&&":_.tokens.and_and,"->":_.tokens.arrow,"/":_.tokens.forward_slash,"!":_.tokens.bang,"[":_.tokens.bracket_left,"]":_.tokens.bracket_right,"=":_.tokens.equal,"==":_.tokens.equal_equal,"!=":_.tokens.not_equal,">":_.tokens.greater_than,">=":_.tokens.greater_than_equal,">>":_.tokens.shift_right,"<":_.tokens.less_than,"<=":_.tokens.less_than_equal,"<<":_.tokens.shift_left,"%":_.tokens.modulo,"-":_.tokens.minus,"--":_.tokens.minus_minus,".":_.tokens.period,"+":_.tokens.plus,"++":_.tokens.plus_plus,"|":_.tokens.or,"||":_.tokens.or_or,"*":_.tokens.star,"~":_.tokens.tilde,_:_.tokens.underscore,"^":_.tokens.xor,"+=":_.tokens.plus_equal,"-=":_.tokens.minus_equal,"*=":_.tokens.times_equal,"/=":_.tokens.division_equal,"%=":_.tokens.modulo_equal,"&=":_.tokens.and_equal,"|=":_.tokens.or_equal,"^=":_.tokens.xor_equal,">>=":_.tokens.shift_right_equal,"<<=":_.tokens.shift_left_equal};s.regexTokens={decimal_float_literal:_.tokens.decimal_float_literal,hex_float_literal:_.tokens.hex_float_literal,int_literal:_.tokens.int_literal,uint_literal:_.tokens.uint_literal,ident:_.tokens.ident};s.storage_class=[_.keywords.function,_.keywords.private,_.keywords.workgroup,_.keywords.uniform,_.keywords.storage];s.access_mode=[_.keywords.read,_.keywords.write,_.keywords.read_write];s.sampler_type=[_.keywords.sampler,_.keywords.sampler_comparison];s.sampled_texture_type=[_.keywords.texture_1d,_.keywords.texture_2d,_.keywords.texture_2d_array,_.keywords.texture_3d,_.keywords.texture_cube,_.keywords.texture_cube_array];s.multisampled_texture_type=[_.keywords.texture_multisampled_2d];s.storage_texture_type=[_.keywords.texture_storage_1d,_.keywords.texture_storage_2d,_.keywords.texture_storage_2d_array,_.keywords.texture_storage_3d];s.depth_texture_type=[_.keywords.texture_depth_2d,_.keywords.texture_depth_2d_array,_.keywords.texture_depth_cube,_.keywords.texture_depth_cube_array,_.keywords.texture_depth_multisampled_2d];s.texture_external_type=[_.keywords.texture_external];s.any_texture_type=[..._.sampled_texture_type,..._.multisampled_texture_type,..._.storage_texture_type,..._.depth_texture_type,..._.texture_external_type];s.texel_format=[_.keywords.r8unorm,_.keywords.r8snorm,_.keywords.r8uint,_.keywords.r8sint,_.keywords.r16uint,_.keywords.r16sint,_.keywords.r16float,_.keywords.rg8unorm,_.keywords.rg8snorm,_.keywords.rg8uint,_.keywords.rg8sint,_.keywords.r32uint,_.keywords.r32sint,_.keywords.r32float,_.keywords.rg16uint,_.keywords.rg16sint,_.keywords.rg16float,_.keywords.rgba8unorm,_.keywords.rgba8unorm_srgb,_.keywords.rgba8snorm,_.keywords.rgba8uint,_.keywords.rgba8sint,_.keywords.bgra8unorm,_.keywords.bgra8unorm_srgb,_.keywords.rgb10a2unorm,_.keywords.rg11b10float,_.keywords.rg32uint,_.keywords.rg32sint,_.keywords.rg32float,_.keywords.rgba16uint,_.keywords.rgba16sint,_.keywords.rgba16float,_.keywords.rgba32uint,_.keywords.rgba32sint,_.keywords.rgba32float];s.const_literal=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal,_.keywords.true,_.keywords.false];s.literal_or_ident=[_.tokens.ident,_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal];s.element_count_expression=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.ident];s.template_types=[_.keywords.vec2,_.keywords.vec3,_.keywords.vec4,_.keywords.mat2x2,_.keywords.mat2x3,_.keywords.mat2x4,_.keywords.mat3x2,_.keywords.mat3x3,_.keywords.mat3x4,_.keywords.mat4x2,_.keywords.mat4x3,_.keywords.mat4x4,_.keywords.atomic,_.keywords.bitcast,..._.any_texture_type];s.attribute_name=[_.tokens.ident,_.keywords.block,_.keywords.diagnostic];s.assignment_operators=[_.tokens.equal,_.tokens.plus_equal,_.tokens.minus_equal,_.tokens.times_equal,_.tokens.division_equal,_.tokens.modulo_equal,_.tokens.and_equal,_.tokens.or_equal,_.tokens.xor_equal,_.tokens.shift_right_equal,_.tokens.shift_left_equal];s.increment_operators=[_.tokens.plus_plus,_.tokens.minus_minus];var Qe=class{constructor(e,t,r){this.type=e,this.lexeme=t,this.line=r}toString(){return this.lexeme}isTemplateType(){return s.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==s.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},Xt=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Qe(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
85
+ }`}function zn(n){switch(n){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(n)}}function Yn(n){switch(n){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(n)}}function So(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function _t(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}function Z(n){return typeof n=="string"?n.charAt(0).toUpperCase()+n.slice(1):n}function Dn(n,e){return No(n,e)}function No(n,e){let t=[];switch(e.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":t.push(`uniform ${Z(n.name)} {`);break;case"uniforms":}for(let[r,o]of Object.entries(n.uniformTypes||{})){let i=To(o);switch(e.uniforms){case"scoped-interface-blocks":t.push(` ${i} ${r};`);break;case"unscoped-interface-blocks":t.push(` ${i} ${n.name}_${r};`);break;case"uniforms":t.push(`uniform ${i} ${n.name}_${r};`)}}switch(e.uniforms){case"scoped-interface-blocks":t.push(`} ${n.name};`);break;case"unscoped-interface-blocks":t.push("};");break;case"uniforms":}return t.push(""),t.join(`
86
+ `)}function To(n){return{f32:"float",i32:"int",u32:"uint","vec2<f32>":"vec2","vec3<f32>":"vec3","vec4<f32>":"vec4","vec2<i32>":"ivec2","vec3<i32>":"ivec3","vec4<i32>":"ivec4","vec2<u32>":"uvec2","vec3<u32>":"uvec3","vec4<u32>":"uvec4","mat2x2<f32>":"mat2","mat2x3<f32>":"mat2x3","mat2x4<f32>":"mat2x4","mat3x2<f32>":"mat3x2","mat3x3<f32>":"mat3","mat3x4<f32>":"mat3x4","mat4x2<f32>":"mat4x2","mat4x3<f32>":"mat4x3","mat4x4<f32>":"mat4"}[n]}function Xn(n,e){return Eo(n,e)}function Eo(n,e){let t=[];t.push(`struct ${Z(n.name)} {`);for(let[r,o]of Object.entries(n?.uniformTypes||{})){let i=o;t.push(` ${r} : ${i};`)}return t.push("};"),t.push(`var<uniform> ${n.name} : ${Z(n.name)};`),t.join(`
87
+ `)}function Bn(n,e){switch(e.shaderLanguage){case"glsl":return Dn(n,e);case"wgsl":return Xn(n,e)}}var qn=rt(ke(),1);var ht=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},B=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(e){throw new Error("Cannot evaluate node")}evaluateString(e){return this.evaluate(e).toString()}search(e){}searchBlock(e,t){if(e){t(ae.instance);for(let r of e)r instanceof Array?this.searchBlock(r,t):r.search(t);t(ce.instance)}}},ae=class extends B{};ae.instance=new ae;var ce=class extends B{};ce.instance=new ce;var N=class extends B{constructor(){super()}},xe=class extends N{constructor(e,t,r,o,i,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=r,this.body=o,this.startLine=i,this.endLine=a}get astNodeType(){return"function"}search(e){this.searchBlock(this.body,e)}},pt=class extends N{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},dt=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},mt=class extends N{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},gt=class extends N{constructor(e,t,r,o){super(),this.init=e,this.condition=t,this.increment=r,this.body=o}get astNodeType(){return"for"}search(e){var t,r,o;(t=this.init)===null||t===void 0||t.search(e),(r=this.condition)===null||r===void 0||r.search(e),(o=this.increment)===null||o===void 0||o.search(e),this.searchBlock(this.body,e)}},W=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Ee=class extends N{constructor(e,t,r){super(),this.name=e,this.type=t,this.value=r}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},ve=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Me=class extends N{constructor(e,t,r,o,i){super(),this.name=e,this.type=t,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},le;(function(n){n.increment="++",n.decrement="--"})(le||(le={}));(function(n){function e(t){let r=t;if(r=="parse")throw new Error("Invalid value for IncrementOperator");return n[r]}n.parse=e})(le||(le={}));var xt=class extends N{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}},Ae;(function(n){n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(Ae||(Ae={}));(function(n){function e(t){let r=t;if(r=="parse")throw new Error("Invalid value for AssignOperator");return r}n.parse=e})(Ae||(Ae={}));var vt=class extends N{constructor(e,t,r){super(),this.operator=e,this.variable=t,this.value=r}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Ie=class extends N{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}search(e){for(let t of this.args)t.search(e);e(this)}},At=class extends N{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}},bt=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"body"}},yt=class extends N{constructor(e,t,r,o){super(),this.condition=e,this.body=t,this.elseif=r,this.else=o}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}},Pt=class extends N{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},wt=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Lt=class extends N{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},kt=class extends N{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}},Fe=class extends N{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}},St=class extends N{constructor(){super()}get astNodeType(){return"discard"}},Nt=class extends N{constructor(){super()}get astNodeType(){return"break"}},Tt=class extends N{constructor(){super()}get astNodeType(){return"continue"}},G=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},V=class extends G{constructor(e,t,r,o){super(e),this.members=t,this.startLine=r,this.endLine=o}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}},Ce=class extends G{constructor(e,t,r){super(e),this.format=t,this.access=r}get astNodeType(){return"template"}},Et=class extends G{constructor(e,t,r,o){super(e),this.storage=t,this.type=r,this.access=o}get astNodeType(){return"pointer"}},Re=class extends G{constructor(e,t,r,o){super(e),this.attributes=t,this.format=r,this.count=o}get astNodeType(){return"array"}get isArray(){return!0}},J=class extends G{constructor(e,t,r){super(e),this.format=t,this.access=r}get astNodeType(){return"sampler"}},U=class extends B{constructor(){super()}},Oe=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},$=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){e(this);for(let t of this.args)t.search(e)}},Ue=class extends U{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"callExpr"}evaluate(e){switch(this.name){case"abs":return Math.abs(this.args[0].evaluate(e));case"acos":return Math.acos(this.args[0].evaluate(e));case"acosh":return Math.acosh(this.args[0].evaluate(e));case"asin":return Math.asin(this.args[0].evaluate(e));case"asinh":return Math.asinh(this.args[0].evaluate(e));case"atan":return Math.atan(this.args[0].evaluate(e));case"atan2":return Math.atan2(this.args[0].evaluate(e),this.args[1].evaluate(e));case"atanh":return Math.atanh(this.args[0].evaluate(e));case"ceil":return Math.ceil(this.args[0].evaluate(e));case"clamp":return Math.min(Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e)),this.args[2].evaluate(e));case"cos":return Math.cos(this.args[0].evaluate(e));case"degrees":return this.args[0].evaluate(e)*180/Math.PI;case"distance":return Math.sqrt(Math.pow(this.args[0].evaluate(e)-this.args[1].evaluate(e),2));case"dot":case"exp":return Math.exp(this.args[0].evaluate(e));case"exp2":return Math.pow(2,this.args[0].evaluate(e));case"floor":return Math.floor(this.args[0].evaluate(e));case"fma":return this.args[0].evaluate(e)*this.args[1].evaluate(e)+this.args[2].evaluate(e);case"fract":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"inverseSqrt":return 1/Math.sqrt(this.args[0].evaluate(e));case"log":return Math.log(this.args[0].evaluate(e));case"log2":return Math.log2(this.args[0].evaluate(e));case"max":return Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e));case"min":return Math.min(this.args[0].evaluate(e),this.args[1].evaluate(e));case"mix":return this.args[0].evaluate(e)*(1-this.args[2].evaluate(e))+this.args[1].evaluate(e)*this.args[2].evaluate(e);case"modf":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"pow":return Math.pow(this.args[0].evaluate(e),this.args[1].evaluate(e));case"radians":return this.args[0].evaluate(e)*Math.PI/180;case"round":return Math.round(this.args[0].evaluate(e));case"sign":return Math.sign(this.args[0].evaluate(e));case"sin":return Math.sin(this.args[0].evaluate(e));case"sinh":return Math.sinh(this.args[0].evaluate(e));case"saturate":return Math.min(Math.max(this.args[0].evaluate(e),0),1);case"smoothstep":return this.args[0].evaluate(e)*this.args[0].evaluate(e)*(3-2*this.args[0].evaluate(e));case"sqrt":return Math.sqrt(this.args[0].evaluate(e));case"step":return this.args[0].evaluate(e)<this.args[1].evaluate(e)?0:1;case"tan":return Math.tan(this.args[0].evaluate(e));case"tanh":return Math.tanh(this.args[0].evaluate(e));case"trunc":return Math.trunc(this.args[0].evaluate(e));default:throw new Error("Non const function: "+this.name)}}search(e){for(let t of this.args)t.search(e);e(this)}},be=class extends U{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}evaluate(e){let t=e.constants.get(this.name);if(!t)throw new Error("Cannot evaluate node");return t.evaluate(e)}},ze=class extends U{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}evaluate(e){var t,r;if(this.initializer instanceof $){let o=(t=this.postfix)===null||t===void 0?void 0:t.evaluateString(e),i=(r=this.initializer.type)===null||r===void 0?void 0:r.name,a=e.structs.get(i),c=a?.getMemberIndex(o);if(c!=-1)return this.initializer.args[c].evaluate(e);console.log(c)}return this.initializer.evaluate(e)}search(e){this.initializer.search(e)}},Ye=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Mt=class extends U{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},It=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}search(e){this.searchBlock(this.args,e)}},De=class extends U{constructor(e){super(),this.contents=e}get astNodeType(){return"groupExpr"}evaluate(e){return this.contents[0].evaluate(e)}search(e){this.searchBlock(this.contents,e)}},Ft=class extends U{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},Xe=class extends U{constructor(){super()}},Ct=class extends Xe{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}evaluate(e){switch(this.operator){case"+":return this.right.evaluate(e);case"-":return-this.right.evaluate(e);case"!":return this.right.evaluate(e)?0:1;case"~":return~this.right.evaluate(e);default:throw new Error("Unknown unary operator: "+this.operator)}}search(e){this.right.search(e)}},D=class extends Xe{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}get astNodeType(){return"binaryOp"}evaluate(e){switch(this.operator){case"+":return this.left.evaluate(e)+this.right.evaluate(e);case"-":return this.left.evaluate(e)-this.right.evaluate(e);case"*":return this.left.evaluate(e)*this.right.evaluate(e);case"/":return this.left.evaluate(e)/this.right.evaluate(e);case"%":return this.left.evaluate(e)%this.right.evaluate(e);case"==":return this.left.evaluate(e)==this.right.evaluate(e)?1:0;case"!=":return this.left.evaluate(e)!=this.right.evaluate(e)?1:0;case"<":return this.left.evaluate(e)<this.right.evaluate(e)?1:0;case">":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(e){this.left.search(e),this.right.search(e)}},Be=class extends B{constructor(){super()}},Rt=class extends Be{constructor(e,t){super(),this.selector=e,this.body=t}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},Ot=class extends Be{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Ut=class extends B{constructor(e,t,r){super(),this.name=e,this.type=t,this.attributes=r}get astNodeType(){return"argument"}},zt=class extends B{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Yt=class extends B{constructor(e,t,r){super(),this.name=e,this.type=t,this.attributes=r}get astNodeType(){return"member"}},Dt=class extends B{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}},_,f;(function(n){n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(f||(f={}));var l=class{constructor(e,t,r){this.name=e,this.type=t,this.rule=r}toString(){return this.name}},s=class{};_=s;s.none=new l("",f.reserved,"");s.eof=new l("EOF",f.token,"");s.reserved={asm:new l("asm",f.reserved,"asm"),bf16:new l("bf16",f.reserved,"bf16"),do:new l("do",f.reserved,"do"),enum:new l("enum",f.reserved,"enum"),f16:new l("f16",f.reserved,"f16"),f64:new l("f64",f.reserved,"f64"),handle:new l("handle",f.reserved,"handle"),i8:new l("i8",f.reserved,"i8"),i16:new l("i16",f.reserved,"i16"),i64:new l("i64",f.reserved,"i64"),mat:new l("mat",f.reserved,"mat"),premerge:new l("premerge",f.reserved,"premerge"),regardless:new l("regardless",f.reserved,"regardless"),typedef:new l("typedef",f.reserved,"typedef"),u8:new l("u8",f.reserved,"u8"),u16:new l("u16",f.reserved,"u16"),u64:new l("u64",f.reserved,"u64"),unless:new l("unless",f.reserved,"unless"),using:new l("using",f.reserved,"using"),vec:new l("vec",f.reserved,"vec"),void:new l("void",f.reserved,"void")};s.keywords={array:new l("array",f.keyword,"array"),atomic:new l("atomic",f.keyword,"atomic"),bool:new l("bool",f.keyword,"bool"),f32:new l("f32",f.keyword,"f32"),i32:new l("i32",f.keyword,"i32"),mat2x2:new l("mat2x2",f.keyword,"mat2x2"),mat2x3:new l("mat2x3",f.keyword,"mat2x3"),mat2x4:new l("mat2x4",f.keyword,"mat2x4"),mat3x2:new l("mat3x2",f.keyword,"mat3x2"),mat3x3:new l("mat3x3",f.keyword,"mat3x3"),mat3x4:new l("mat3x4",f.keyword,"mat3x4"),mat4x2:new l("mat4x2",f.keyword,"mat4x2"),mat4x3:new l("mat4x3",f.keyword,"mat4x3"),mat4x4:new l("mat4x4",f.keyword,"mat4x4"),ptr:new l("ptr",f.keyword,"ptr"),sampler:new l("sampler",f.keyword,"sampler"),sampler_comparison:new l("sampler_comparison",f.keyword,"sampler_comparison"),struct:new l("struct",f.keyword,"struct"),texture_1d:new l("texture_1d",f.keyword,"texture_1d"),texture_2d:new l("texture_2d",f.keyword,"texture_2d"),texture_2d_array:new l("texture_2d_array",f.keyword,"texture_2d_array"),texture_3d:new l("texture_3d",f.keyword,"texture_3d"),texture_cube:new l("texture_cube",f.keyword,"texture_cube"),texture_cube_array:new l("texture_cube_array",f.keyword,"texture_cube_array"),texture_multisampled_2d:new l("texture_multisampled_2d",f.keyword,"texture_multisampled_2d"),texture_storage_1d:new l("texture_storage_1d",f.keyword,"texture_storage_1d"),texture_storage_2d:new l("texture_storage_2d",f.keyword,"texture_storage_2d"),texture_storage_2d_array:new l("texture_storage_2d_array",f.keyword,"texture_storage_2d_array"),texture_storage_3d:new l("texture_storage_3d",f.keyword,"texture_storage_3d"),texture_depth_2d:new l("texture_depth_2d",f.keyword,"texture_depth_2d"),texture_depth_2d_array:new l("texture_depth_2d_array",f.keyword,"texture_depth_2d_array"),texture_depth_cube:new l("texture_depth_cube",f.keyword,"texture_depth_cube"),texture_depth_cube_array:new l("texture_depth_cube_array",f.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new l("texture_depth_multisampled_2d",f.keyword,"texture_depth_multisampled_2d"),texture_external:new l("texture_external",f.keyword,"texture_external"),u32:new l("u32",f.keyword,"u32"),vec2:new l("vec2",f.keyword,"vec2"),vec3:new l("vec3",f.keyword,"vec3"),vec4:new l("vec4",f.keyword,"vec4"),bitcast:new l("bitcast",f.keyword,"bitcast"),block:new l("block",f.keyword,"block"),break:new l("break",f.keyword,"break"),case:new l("case",f.keyword,"case"),continue:new l("continue",f.keyword,"continue"),continuing:new l("continuing",f.keyword,"continuing"),default:new l("default",f.keyword,"default"),diagnostic:new l("diagnostic",f.keyword,"diagnostic"),discard:new l("discard",f.keyword,"discard"),else:new l("else",f.keyword,"else"),enable:new l("enable",f.keyword,"enable"),fallthrough:new l("fallthrough",f.keyword,"fallthrough"),false:new l("false",f.keyword,"false"),fn:new l("fn",f.keyword,"fn"),for:new l("for",f.keyword,"for"),function:new l("function",f.keyword,"function"),if:new l("if",f.keyword,"if"),let:new l("let",f.keyword,"let"),const:new l("const",f.keyword,"const"),loop:new l("loop",f.keyword,"loop"),while:new l("while",f.keyword,"while"),private:new l("private",f.keyword,"private"),read:new l("read",f.keyword,"read"),read_write:new l("read_write",f.keyword,"read_write"),return:new l("return",f.keyword,"return"),requires:new l("requires",f.keyword,"requires"),storage:new l("storage",f.keyword,"storage"),switch:new l("switch",f.keyword,"switch"),true:new l("true",f.keyword,"true"),alias:new l("alias",f.keyword,"alias"),type:new l("type",f.keyword,"type"),uniform:new l("uniform",f.keyword,"uniform"),var:new l("var",f.keyword,"var"),override:new l("override",f.keyword,"override"),workgroup:new l("workgroup",f.keyword,"workgroup"),write:new l("write",f.keyword,"write"),r8unorm:new l("r8unorm",f.keyword,"r8unorm"),r8snorm:new l("r8snorm",f.keyword,"r8snorm"),r8uint:new l("r8uint",f.keyword,"r8uint"),r8sint:new l("r8sint",f.keyword,"r8sint"),r16uint:new l("r16uint",f.keyword,"r16uint"),r16sint:new l("r16sint",f.keyword,"r16sint"),r16float:new l("r16float",f.keyword,"r16float"),rg8unorm:new l("rg8unorm",f.keyword,"rg8unorm"),rg8snorm:new l("rg8snorm",f.keyword,"rg8snorm"),rg8uint:new l("rg8uint",f.keyword,"rg8uint"),rg8sint:new l("rg8sint",f.keyword,"rg8sint"),r32uint:new l("r32uint",f.keyword,"r32uint"),r32sint:new l("r32sint",f.keyword,"r32sint"),r32float:new l("r32float",f.keyword,"r32float"),rg16uint:new l("rg16uint",f.keyword,"rg16uint"),rg16sint:new l("rg16sint",f.keyword,"rg16sint"),rg16float:new l("rg16float",f.keyword,"rg16float"),rgba8unorm:new l("rgba8unorm",f.keyword,"rgba8unorm"),rgba8unorm_srgb:new l("rgba8unorm_srgb",f.keyword,"rgba8unorm_srgb"),rgba8snorm:new l("rgba8snorm",f.keyword,"rgba8snorm"),rgba8uint:new l("rgba8uint",f.keyword,"rgba8uint"),rgba8sint:new l("rgba8sint",f.keyword,"rgba8sint"),bgra8unorm:new l("bgra8unorm",f.keyword,"bgra8unorm"),bgra8unorm_srgb:new l("bgra8unorm_srgb",f.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new l("rgb10a2unorm",f.keyword,"rgb10a2unorm"),rg11b10float:new l("rg11b10float",f.keyword,"rg11b10float"),rg32uint:new l("rg32uint",f.keyword,"rg32uint"),rg32sint:new l("rg32sint",f.keyword,"rg32sint"),rg32float:new l("rg32float",f.keyword,"rg32float"),rgba16uint:new l("rgba16uint",f.keyword,"rgba16uint"),rgba16sint:new l("rgba16sint",f.keyword,"rgba16sint"),rgba16float:new l("rgba16float",f.keyword,"rgba16float"),rgba32uint:new l("rgba32uint",f.keyword,"rgba32uint"),rgba32sint:new l("rgba32sint",f.keyword,"rgba32sint"),rgba32float:new l("rgba32float",f.keyword,"rgba32float"),static_assert:new l("static_assert",f.keyword,"static_assert")};s.tokens={decimal_float_literal:new l("decimal_float_literal",f.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new l("hex_float_literal",f.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new l("int_literal",f.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new l("uint_literal",f.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new l("ident",f.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new l("and",f.token,"&"),and_and:new l("and_and",f.token,"&&"),arrow:new l("arrow ",f.token,"->"),attr:new l("attr",f.token,"@"),forward_slash:new l("forward_slash",f.token,"/"),bang:new l("bang",f.token,"!"),bracket_left:new l("bracket_left",f.token,"["),bracket_right:new l("bracket_right",f.token,"]"),brace_left:new l("brace_left",f.token,"{"),brace_right:new l("brace_right",f.token,"}"),colon:new l("colon",f.token,":"),comma:new l("comma",f.token,","),equal:new l("equal",f.token,"="),equal_equal:new l("equal_equal",f.token,"=="),not_equal:new l("not_equal",f.token,"!="),greater_than:new l("greater_than",f.token,">"),greater_than_equal:new l("greater_than_equal",f.token,">="),shift_right:new l("shift_right",f.token,">>"),less_than:new l("less_than",f.token,"<"),less_than_equal:new l("less_than_equal",f.token,"<="),shift_left:new l("shift_left",f.token,"<<"),modulo:new l("modulo",f.token,"%"),minus:new l("minus",f.token,"-"),minus_minus:new l("minus_minus",f.token,"--"),period:new l("period",f.token,"."),plus:new l("plus",f.token,"+"),plus_plus:new l("plus_plus",f.token,"++"),or:new l("or",f.token,"|"),or_or:new l("or_or",f.token,"||"),paren_left:new l("paren_left",f.token,"("),paren_right:new l("paren_right",f.token,")"),semicolon:new l("semicolon",f.token,";"),star:new l("star",f.token,"*"),tilde:new l("tilde",f.token,"~"),underscore:new l("underscore",f.token,"_"),xor:new l("xor",f.token,"^"),plus_equal:new l("plus_equal",f.token,"+="),minus_equal:new l("minus_equal",f.token,"-="),times_equal:new l("times_equal",f.token,"*="),division_equal:new l("division_equal",f.token,"/="),modulo_equal:new l("modulo_equal",f.token,"%="),and_equal:new l("and_equal",f.token,"&="),or_equal:new l("or_equal",f.token,"|="),xor_equal:new l("xor_equal",f.token,"^="),shift_right_equal:new l("shift_right_equal",f.token,">>="),shift_left_equal:new l("shift_left_equal",f.token,"<<=")};s.simpleTokens={"@":_.tokens.attr,"{":_.tokens.brace_left,"}":_.tokens.brace_right,":":_.tokens.colon,",":_.tokens.comma,"(":_.tokens.paren_left,")":_.tokens.paren_right,";":_.tokens.semicolon};s.literalTokens={"&":_.tokens.and,"&&":_.tokens.and_and,"->":_.tokens.arrow,"/":_.tokens.forward_slash,"!":_.tokens.bang,"[":_.tokens.bracket_left,"]":_.tokens.bracket_right,"=":_.tokens.equal,"==":_.tokens.equal_equal,"!=":_.tokens.not_equal,">":_.tokens.greater_than,">=":_.tokens.greater_than_equal,">>":_.tokens.shift_right,"<":_.tokens.less_than,"<=":_.tokens.less_than_equal,"<<":_.tokens.shift_left,"%":_.tokens.modulo,"-":_.tokens.minus,"--":_.tokens.minus_minus,".":_.tokens.period,"+":_.tokens.plus,"++":_.tokens.plus_plus,"|":_.tokens.or,"||":_.tokens.or_or,"*":_.tokens.star,"~":_.tokens.tilde,_:_.tokens.underscore,"^":_.tokens.xor,"+=":_.tokens.plus_equal,"-=":_.tokens.minus_equal,"*=":_.tokens.times_equal,"/=":_.tokens.division_equal,"%=":_.tokens.modulo_equal,"&=":_.tokens.and_equal,"|=":_.tokens.or_equal,"^=":_.tokens.xor_equal,">>=":_.tokens.shift_right_equal,"<<=":_.tokens.shift_left_equal};s.regexTokens={decimal_float_literal:_.tokens.decimal_float_literal,hex_float_literal:_.tokens.hex_float_literal,int_literal:_.tokens.int_literal,uint_literal:_.tokens.uint_literal,ident:_.tokens.ident};s.storage_class=[_.keywords.function,_.keywords.private,_.keywords.workgroup,_.keywords.uniform,_.keywords.storage];s.access_mode=[_.keywords.read,_.keywords.write,_.keywords.read_write];s.sampler_type=[_.keywords.sampler,_.keywords.sampler_comparison];s.sampled_texture_type=[_.keywords.texture_1d,_.keywords.texture_2d,_.keywords.texture_2d_array,_.keywords.texture_3d,_.keywords.texture_cube,_.keywords.texture_cube_array];s.multisampled_texture_type=[_.keywords.texture_multisampled_2d];s.storage_texture_type=[_.keywords.texture_storage_1d,_.keywords.texture_storage_2d,_.keywords.texture_storage_2d_array,_.keywords.texture_storage_3d];s.depth_texture_type=[_.keywords.texture_depth_2d,_.keywords.texture_depth_2d_array,_.keywords.texture_depth_cube,_.keywords.texture_depth_cube_array,_.keywords.texture_depth_multisampled_2d];s.texture_external_type=[_.keywords.texture_external];s.any_texture_type=[..._.sampled_texture_type,..._.multisampled_texture_type,..._.storage_texture_type,..._.depth_texture_type,..._.texture_external_type];s.texel_format=[_.keywords.r8unorm,_.keywords.r8snorm,_.keywords.r8uint,_.keywords.r8sint,_.keywords.r16uint,_.keywords.r16sint,_.keywords.r16float,_.keywords.rg8unorm,_.keywords.rg8snorm,_.keywords.rg8uint,_.keywords.rg8sint,_.keywords.r32uint,_.keywords.r32sint,_.keywords.r32float,_.keywords.rg16uint,_.keywords.rg16sint,_.keywords.rg16float,_.keywords.rgba8unorm,_.keywords.rgba8unorm_srgb,_.keywords.rgba8snorm,_.keywords.rgba8uint,_.keywords.rgba8sint,_.keywords.bgra8unorm,_.keywords.bgra8unorm_srgb,_.keywords.rgb10a2unorm,_.keywords.rg11b10float,_.keywords.rg32uint,_.keywords.rg32sint,_.keywords.rg32float,_.keywords.rgba16uint,_.keywords.rgba16sint,_.keywords.rgba16float,_.keywords.rgba32uint,_.keywords.rgba32sint,_.keywords.rgba32float];s.const_literal=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal,_.keywords.true,_.keywords.false];s.literal_or_ident=[_.tokens.ident,_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal];s.element_count_expression=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.ident];s.template_types=[_.keywords.vec2,_.keywords.vec3,_.keywords.vec4,_.keywords.mat2x2,_.keywords.mat2x3,_.keywords.mat2x4,_.keywords.mat3x2,_.keywords.mat3x3,_.keywords.mat3x4,_.keywords.mat4x2,_.keywords.mat4x3,_.keywords.mat4x4,_.keywords.atomic,_.keywords.bitcast,..._.any_texture_type];s.attribute_name=[_.tokens.ident,_.keywords.block,_.keywords.diagnostic];s.assignment_operators=[_.tokens.equal,_.tokens.plus_equal,_.tokens.minus_equal,_.tokens.times_equal,_.tokens.division_equal,_.tokens.modulo_equal,_.tokens.and_equal,_.tokens.or_equal,_.tokens.xor_equal,_.tokens.shift_right_equal,_.tokens.shift_left_equal];s.increment_operators=[_.tokens.plus_plus,_.tokens.minus_minus];var Qe=class{constructor(e,t,r){this.type=e,this.lexeme=t,this.line=r}toString(){return this.lexeme}isTemplateType(){return s.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==s.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},Xt=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Qe(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
88
88
  `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
89
89
  `;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let a=1;for(;a>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
90
- `)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),a--,a==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),a++)}return!0}}let t=s.simpleTokens[e];if(t)return this._addToken(t),!0;let r=s.none,o=this._isAlpha(e),i=e==="_";if(this._isAlphaNumeric(e)){let a=this._peekAhead();for(;this._isAlphaNumeric(a);)e+=this._advance(),a=this._peekAhead()}if(o){let a=s.keywords[e];if(a)return this._addToken(a),!0}if(o||i)return this._addToken(s.tokens.ident),!0;for(;;){let a=this._findType(e),c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let u=!1,h=this._tokens.length-1;for(let p=0;p<5&&h>=0;++p,--h)if(this._tokens[h].type===s.tokens.less_than){h>0&&this._tokens[h-1].isArrayOrTemplateType()&&(u=!0);break}if(u)return this._addToken(a),!0}if(a===s.none){let u=e,h=0,p=2;for(let d=0;d<p;++d)if(u+=this._peekAhead(d),a=this._findType(u),a!==s.none){h=d;break}if(a===s.none)return r===s.none?!1:(this._current--,this._addToken(r),!0);e=u,this._current+=h+1}if(r=a,this._isAtEnd())break;e+=this._advance()}return r===s.none?!1:(this._addToken(r),!0)}_findType(e){for(let r in s.regexTokens){let o=s.regexTokens[r];if(this._match(e,o.rule))return o}let t=s.literalTokens[e];return t||s.none}_match(e,t){let r=t.exec(e);return r&&r.index==0&&r[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new Qe(e,t,this._line))}},Bt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new ht,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let r=this._global_decl_or_directive();if(!r)break;t.push(r)}if(this._deferArrayCountEval.length>0){for(let r of this._deferArrayCountEval){let o=r.arrayType,i=r.countNode;if(i instanceof ye){let c=i.name,u=this._context.constants.get(c);if(u)try{let h=u.evaluate(this._context);o.count=h}catch{}}}this._deferArrayCountEval.length=0}return t}_initialize(e){if(e)if(typeof e=="string"){let t=new Xt(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,t){return{token:e,message:t,toString:function(){return`${t}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==s.eof}_match(e){if(e instanceof l)return this._check(e)?(this._advance(),!0):!1;for(let t=0,r=e.length;t<r;++t){let o=e[t];if(this._check(o))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),t)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let r=t.type;return e.indexOf(r)!=-1}return t.type==e}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._match(s.keywords.alias)){let t=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.diagnostic)){let t=this._diagnostic();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.requires)){let t=this._requires_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.enable)){let t=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}let e=this._attribute();if(this._check(s.keywords.var)){let t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.override)){let t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.let)){let t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.const)){let t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.struct)){let t=this._struct_decl();return t!=null&&(t.attributes=e),t}if(this._check(s.keywords.fn)){let t=this._function_decl();return t!=null&&(t.attributes=e),t}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected function name.").toString();this._consume(s.tokens.paren_left,"Expected '(' for function arguments.");let r=[];if(!this._check(s.tokens.paren_right))do{if(this._check(s.tokens.paren_right))break;let c=this._attribute(),u=this._consume(s.tokens.ident,"Expected argument name.").toString();this._consume(s.tokens.colon,"Expected ':' for argument type.");let h=this._attribute(),p=this._type_decl();p!=null&&(p.attributes=h,r.push(new Ut(u,p,c)))}while(this._match(s.tokens.comma));this._consume(s.tokens.paren_right,"Expected ')' after function arguments.");let o=null;if(this._match(s.tokens.arrow)){let c=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=c)}let i=this._compound_statement(),a=this._currentLine;return new xe(t,r,o,i,e,a)}_compound_statement(){let e=[];for(this._consume(s.tokens.brace_left,"Expected '{' for block.");!this._check(s.tokens.brace_right);){let t=this._statement();t!==null&&e.push(t)}return this._consume(s.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._check(s.tokens.attr)&&this._attribute(),this._check(s.keywords.if))return this._if_statement();if(this._check(s.keywords.switch))return this._switch_statement();if(this._check(s.keywords.loop))return this._loop_statement();if(this._check(s.keywords.for))return this._for_statement();if(this._check(s.keywords.while))return this._while_statement();if(this._check(s.keywords.continuing))return this._continuing_statement();if(this._check(s.keywords.static_assert))return this._static_assert_statement();if(this._check(s.tokens.brace_left))return this._compound_statement();let e=null;return this._check(s.keywords.return)?e=this._return_statement():this._check([s.keywords.var,s.keywords.let,s.keywords.const])?e=this._variable_statement():this._match(s.keywords.discard)?e=new St:this._match(s.keywords.break)?e=new Nt:this._match(s.keywords.continue)?e=new Tt:e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement(),e!=null&&this._consume(s.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(s.keywords.static_assert))return null;let e=this._optional_paren_expression();return new pt(e)}_while_statement(){if(!this._match(s.keywords.while))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement();return new dt(e,t)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new mt(e)}_for_statement(){if(!this._match(s.keywords.for))return null;this._consume(s.tokens.paren_left,"Expected '('.");let e=this._check(s.tokens.semicolon)?null:this._for_init();this._consume(s.tokens.semicolon,"Expected ';'.");let t=this._check(s.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(s.tokens.semicolon,"Expected ';'.");let r=this._check(s.tokens.paren_right)?null:this._for_increment();this._consume(s.tokens.paren_right,"Expected ')'."),this._check(s.tokens.attr)&&this._attribute();let o=this._compound_statement();return new gt(e,t,r,o)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(s.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(s.tokens.equal)&&(t=this._short_circuit_or_expression()),new H(e.name,e.type,e.storage,e.access,t)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for let.");let r=this._short_circuit_or_expression();return new ve(e,t,null,null,r)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for const.");let r=this._short_circuit_or_expression();return new Me(e,t,null,null,r)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(s.increment_operators))return this._current=e,null;let r=this._consume(s.increment_operators,"Expected increment operator");return new xt(r.type===s.tokens.plus_plus?le.increment:le.decrement,t)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let t=this._match(s.tokens.underscore);if(t||(e=this._unary_expression()),!t&&e==null)return null;let r=this._consume(s.assignment_operators,"Expected assignment operator."),o=this._short_circuit_or_expression();return new vt(Ae.parse(r.lexeme),e,o)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,t=this._consume(s.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=e,null):new Ie(t.lexeme,r)}_loop_statement(){if(!this._match(s.keywords.loop))return null;this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for loop.");let e=[],t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let o of t)e.push(o);else e.push(t);t=this._statement()}let r=null;return this._match(s.keywords.continuing)&&(r=this._compound_statement()),this._consume(s.tokens.brace_right,"Expected '}' for loop."),new At(e,r)}_switch_statement(){if(!this._match(s.keywords.switch))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for switch.");let t=this._switch_body();if(t==null||t.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new yt(e,t)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let t=this._case_selectors();this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch case.");let r=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch case."),e.push(new Rt(t,r))}if(this._match(s.keywords.default)){this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch default.");let t=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new Ot(t))}if(this._check([s.keywords.default,s.keywords.case])){let t=this._switch_body();e.push(t[0])}return e}_case_selectors(){let e=[this._shift_expression()];for(;this._match(s.tokens.comma);)e.push(this._shift_expression());return e}_case_body(){if(this._match(s.keywords.fallthrough))return this._consume(s.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);let t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(s.keywords.if))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement(),r=[];this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let o=null;return this._match(s.keywords.else)&&(this._check(s.tokens.attr)&&this._attribute(),o=this._compound_statement()),new bt(e,t,r,o)}_match_elseif(){return this._tokens[this._current].type===s.keywords.else&&this._tokens[this._current+1].type===s.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(e=[]){let t=this._optional_paren_expression(),r=this._compound_statement();return e.push(new zt(t,r)),this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(s.keywords.return))return null;let e=this._short_circuit_or_expression();return new Pt(e)}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(s.tokens.or_or);)e=new Y(this._previous().toString(),e,this._short_circuit_and_expr());return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(s.tokens.and_and);)e=new Y(this._previous().toString(),e,this._inclusive_or_expression());return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(s.tokens.or);)e=new Y(this._previous().toString(),e,this._exclusive_or_expression());return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(s.tokens.xor);)e=new Y(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new Y(this._previous().toString(),e,this._equality_expression());return e}_equality_expression(){let e=this._relational_expression();return this._match([s.tokens.equal_equal,s.tokens.not_equal])?new Y(this._previous().toString(),e,this._relational_expression()):e}_relational_expression(){let e=this._shift_expression();for(;this._match([s.tokens.less_than,s.tokens.greater_than,s.tokens.less_than_equal,s.tokens.greater_than_equal]);)e=new Y(this._previous().toString(),e,this._shift_expression());return e}_shift_expression(){let e=this._additive_expression();for(;this._match([s.tokens.shift_left,s.tokens.shift_right]);)e=new Y(this._previous().toString(),e,this._additive_expression());return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([s.tokens.plus,s.tokens.minus]);)e=new Y(this._previous().toString(),e,this._multiplicative_expression());return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([s.tokens.star,s.tokens.forward_slash,s.tokens.modulo]);)e=new Y(this._previous().toString(),e,this._unary_expression());return e}_unary_expression(){return this._match([s.tokens.minus,s.tokens.bang,s.tokens.tilde,s.tokens.star,s.tokens.and])?new Ct(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(s.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(s.tokens.bracket_right,"Expected ']'.");let t=new Ft(e),r=this._postfix_expression();return r&&(t.postfix=r),t}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),t=this._postfix_expression(),r=new Oe(e.lexeme);return t&&(r.postfix=t),r}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_primary_expression(){if(this._match(s.tokens.ident)){let r=this._previous().toString();if(this._check(s.tokens.paren_left)){let o=this._argument_expression_list(),i=this._getStruct(r);return i!=null?new $(i,o):new Ue(r,o)}if(this._context.constants.has(r)){let o=this._context.constants.get(r);return new ze(r,o.value)}return new ye(r)}if(this._match(s.const_literal))return new De(parseFloat(this._previous().toString()));if(this._check(s.tokens.paren_left))return this._paren_expression();if(this._match(s.keywords.bitcast)){this._consume(s.tokens.less_than,"Expected '<'.");let r=this._type_decl();this._consume(s.tokens.greater_than,"Expected '>'.");let o=this._paren_expression();return new Mt(r,o)}let e=this._type_decl(),t=this._argument_expression_list();return new It(e,t)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(s.tokens.comma));return this._consume(s.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(s.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(s.tokens.paren_right),new Ye([e])}_paren_expression(){this._consume(s.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(s.tokens.paren_right,"Expected ')'."),new Ye([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected name for struct.").toString();this._consume(s.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(s.tokens.brace_right);){let a=this._attribute(),c=this._consume(s.tokens.ident,"Expected variable name.").toString();this._consume(s.tokens.colon,"Expected ':' for struct member type.");let u=this._attribute(),h=this._type_decl();h!=null&&(h.attributes=u),this._check(s.tokens.brace_right)?this._match(s.tokens.comma):this._consume(s.tokens.comma,"Expected ',' for struct member."),r.push(new Dt(c,h,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let o=this._currentLine,i=new V(t,r,e,o);return this._context.structs.set(t,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(s.keywords.const))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}let r=null;if(this._match(s.tokens.equal)){let i=this._short_circuit_or_expression();if(i instanceof $)r=i;else if(i instanceof ze&&i.initializer instanceof $)r=i.initializer;else try{let a=i.evaluate(this._context);r=new De(a)}catch{r=i}}let o=new Me(e.toString(),t,"","",r);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(s.keywords.let))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}let r=null;return this._match(s.tokens.equal)&&(r=this._const_expression()),new ve(e.toString(),t,"","",r)}_const_expression(){if(this._match(s.const_literal))return new Oe(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let t=[];for(;!this._check(s.tokens.paren_right)&&(t.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new $(e,t)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",t="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(t=this._consume(s.access_mode,"Expected access_mode.").toString()),this._consume(s.tokens.greater_than,"Expected '>'."));let r=this._consume(s.tokens.ident,"Expected variable name"),o=null;if(this._match(s.tokens.colon)){let i=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=i)}return new H(r.toString(),o,e,t,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let r=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=r)}return new Ee(e.toString(),t,null)}_diagnostic(){this._consume(s.tokens.paren_left,"Expected '('");let e=this._consume(s.tokens.ident,"Expected severity control name.");this._consume(s.tokens.comma,"Expected ','");let t=this._consume(s.tokens.ident,"Expected diagnostic rule name.");return this._consume(s.tokens.paren_right,"Expected ')'"),new kt(e.toString(),t.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new wt(e.toString())}_requires_directive(){let e=[this._consume(s.tokens.ident,"identity expected.").toString()];for(;this._match(s.tokens.comma);){let t=this._consume(s.tokens.ident,"identity expected.");e.push(t.toString())}return new Lt(e)}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let r=new Fe(e.toString(),t);return this._context.aliases.set(r.name,r),r}_type_decl(){if(this._check([s.tokens.ident,...s.texel_format,s.keywords.bool,s.keywords.f32,s.keywords.i32,s.keywords.u32])){let r=this._advance(),o=r.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new G(r.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(s.template_types)){let r=this._advance().toString(),o=null,i=null;return this._match(s.tokens.less_than)&&(o=this._type_decl(),i=null,this._match(s.tokens.comma)&&(i=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for type.")),new Ce(r,o,i)}if(this._match(s.keywords.ptr)){let r=this._previous().toString();this._consume(s.tokens.less_than,"Expected '<' for pointer.");let o=this._consume(s.storage_class,"Expected storage_class for pointer");this._consume(s.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),a=null;return this._match(s.tokens.comma)&&(a=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for pointer."),new Et(r,o.toString(),i,a)}let t=this._attribute();if(this._match(s.keywords.array)){let r=null,o=-1,i=this._previous(),a=null;if(this._match(s.tokens.less_than)){r=this._type_decl(),this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let u="";if(this._match(s.tokens.comma)){a=this._shift_expression();try{u=a.evaluate(this._context).toString(),a=null}catch{u="1"}}this._consume(s.tokens.greater_than,"Expected '>' for array."),o=u?parseInt(u):0}let c=new Re(i.toString(),t,r,o);return a&&this._deferArrayCountEval.push({arrayType:c,countNode:a}),c}return null}_texture_sampler_types(){if(this._match(s.sampler_type))return new J(this._previous().toString(),null,null);if(this._match(s.depth_texture_type))return new J(this._previous().toString(),null,null);if(this._match(s.sampled_texture_type)||this._match(s.multisampled_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(s.texel_format,"Invalid texel format.").toString();this._consume(s.tokens.comma,"Expected ',' after texel format.");let r=this._consume(s.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,r)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let t=this._consume(s.attribute_name,"Expected attribute name"),r=new Yt(t.toString(),null);if(this._match(s.tokens.paren_left)){if(r.value=this._consume(s.literal_or_ident,"Expected attribute value").toString(),this._check(s.tokens.comma)){this._advance();do{let o=this._consume(s.literal_or_ident,"Expected attribute value").toString();r.value instanceof Array||(r.value=[r.value]),r.value.push(o)}while(this._match(s.tokens.comma))}this._consume(s.tokens.paren_right,"Expected ')'")}e.push(r)}return e.length==0?null:e}},K=class{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},qe=class{constructor(e,t,r){this.name=e,this.type=t,this.attributes=r,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},oe=class extends K{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},ge=class extends K{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}},Ve=class extends K{constructor(e,t,r,o){super(e,r),this.format=t,this.access=o}get isTemplate(){return!0}},j;(function(n){n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(j||(j={}));var ie=class{constructor(e,t,r,o,i,a,c){this.name=e,this.type=t,this.group=r,this.binding=o,this.attributes=i,this.resourceType=a,this.access=c}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Qt=class{constructor(e,t){this.name=e,this.type=t}},se=class{constructor(e,t){this.align=e,this.size=t}},qt=class{constructor(e,t,r,o){this.name=e,this.type=t,this.locationType=r,this.location=o,this.interpolation=null}},He=class{constructor(e,t,r,o){this.name=e,this.type=t,this.locationType=r,this.location=o}},Vt=class{constructor(e,t=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t}},Ht=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Gt=class{constructor(e,t,r,o){this.name=e,this.type=t,this.attributes=r,this.id=o}},Wt=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},X=class{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Ht,this.functions=[],this._types=new Map,this._functions=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let r=new Bt().parse(e);for(let o of r)o instanceof xe&&this._functions.set(o.name,new Wt(o));for(let o of r)if(o instanceof V){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i)}for(let o of r){if(o instanceof Fe){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof Ee){let i=o,a=this._getAttributeNum(i.attributes,"id",0),c=i.type!=null?this._getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Gt(i.name,c,i.attributes,a));continue}if(this._isUniformVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Uniform,i.access);this.uniforms.push(h);continue}if(this._isStorageVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Storage,i.access);this.storage.push(p);continue}if(this._isTextureVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Texture,i.access);h?this.storage.push(p):this.textures.push(p);continue}if(this._isSamplerVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Sampler,i.access);this.samplers.push(h);continue}if(o instanceof xe){let i=this._getAttribute(o,"vertex"),a=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),u=i||a||c,h=new Vt(o.name,u?.name);h.startLine=o.startLine,h.endLine=o.endLine,this.functions.push(h),this._functions.get(o.name).info=h,u&&(this._functions.get(o.name).inUse=!0,h.inUse=!0,h.resources=this._findResources(o,!!u),h.inputs=this._getInputs(o.args),h.outputs=this._getOutputs(o.returnType),this.entry[u.name].push(h));continue}}for(let o of this._functions.values())o.info&&(o.info.inUse=o.inUse,this._addCalls(o.node,o.info.calls));for(let o of this.uniforms)this._markStructsInUse(o.type);for(let o of this.storage)this._markStructsInUse(o.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var r;for(let o of e.calls){let i=(r=this._functions.get(o.name))===null||r===void 0?void 0:r.info;i&&t.add(i)}}findResource(e,t){for(let r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(let r of this.storage)if(r.group==e&&r.binding==t)return r;for(let r of this.textures)if(r.group==e&&r.binding==t)return r;for(let r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this._getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let r=[],o=this,i=[];return e.search(a=>{if(a instanceof ae)i.push({});else if(a instanceof ce)i.pop();else if(a instanceof H){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof $){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type)}else if(a instanceof ve){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof ye){let c=a;if(i.length>0&&i[i.length-1][c.name])return;let u=o._findResource(c.name);u&&r.push(u)}else if(a instanceof Ue){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),r.push(...u.resources))}else if(a instanceof Ie){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),r.push(...u.resources))}}),[...new Map(r.map(a=>[a.name,a])).values()]}getBindGroups(){let e=[];function t(r,o){r>=e.length&&(e.length=r+1),e[r]===void 0&&(e[r]=[]),o>=e[r].length&&(e[r].length=o+1)}for(let r of this.uniforms){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.storage){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.textures){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.samplers){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof V)this._getStructOutputs(e,t);else{let r=this._getOutputInfo(e);r!==null&&t.push(r)}return t}_getStructOutputs(e,t){for(let r of e.members)if(r.type instanceof V)this._getStructOutputs(r.type,t);else{let o=this._getAttribute(r,"location")||this._getAttribute(r,"builtin");if(o!==null){let i=this._getTypeInfo(r.type,r.type.attributes),a=this._parseInt(o.value),c=new He(r.name,i,o.name,a);t.push(c)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let r=this._getTypeInfo(e,e.attributes),o=this._parseInt(t.value);return new He("",r,t.name,o)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(let r of e)if(r.type instanceof V)this._getStructInputs(r.type,t);else{let o=this._getInputInfo(r);o!==null&&t.push(o)}return t}_getStructInputs(e,t){for(let r of e.members)if(r.type instanceof V)this._getStructInputs(r.type,t);else{let o=this._getInputInfo(r);o!==null&&t.push(o)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let r=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),a=new qt(e.name,o,t.name,i);return r!==null&&(a.interpolation=this._parseString(r.value)),a}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Qt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,t){if(this._types.has(e))return this._types.get(e);if(e instanceof Re){let o=e,i=this._getTypeInfo(o.format,o.attributes),a=new ge(o.name,t);return a.format=i,a.count=o.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof V){let o=e,i=new oe(o.name,t);i.startLine=o.startLine,i.endLine=o.endLine;for(let a of o.members){let c=this._getTypeInfo(a.type,a.attributes);i.members.push(new qe(a.name,c,a.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof J){let o=e,i=o.format instanceof G,a=o.format?i?this._getTypeInfo(o.format,null):new K(o.format,null):null,c=new Ve(o.name,a,t,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Ce){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new Ve(o.name,i,t,o.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let r=new K(e.name,t);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var t,r;let o=this._getTypeSize(e);if(e.size=(t=o?.size)!==null&&t!==void 0?t:0,e instanceof ge){let i=this._getTypeSize(e.format);e.stride=(r=i?.size)!==null&&r!==void 0?r:0,this._updateTypeInfo(e.format)}e instanceof oe&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let r=0,o=0,i=0,a=0;for(let c=0,u=e.members.length;c<u;++c){let h=e.members[c],p=this._getTypeSize(h);if(!p)continue;(t=this._getAlias(h.type.name))!==null&&t!==void 0||h.type;let d=p.align,m=p.size;r=this._roundUp(d,r+o),o=m,i=r,a=Math.max(a,d),h.offset=r,h.size=m,this._updateTypeInfo(h.type)}e.size=this._roundUp(a,i+o),e.align=a}_getTypeSize(e){var t;if(e==null)return null;let r=this._getAttributeNum(e.attributes,"size",0),o=this._getAttributeNum(e.attributes,"align",0);if(e instanceof qe&&(e=e.type),e instanceof K){let i=this._getAlias(e.name);i!==null&&(e=i)}{let i=X._typeInfo[e.name];if(i!==void 0){let a=e.format==="f16"?2:1;return new se(Math.max(o,i.align/a),Math.max(r,i.size/a))}}{let i=X._typeInfo[e.name.substring(0,e.name.length-1)];if(i){let a=e.name[e.name.length-1]==="h"?2:1;return new se(Math.max(o,i.align/a),Math.max(r,i.size/a))}}if(e instanceof ge){let i=e,a=8,c=8,u=this._getTypeSize(i.format);u!==null&&(c=u.size,a=u.align);let h=i.count,p=this._getAttributeNum((t=e?.attributes)!==null&&t!==void 0?t:null,"stride",this._roundUp(a,c));return c=h*p,r&&(c=r),new se(Math.max(o,a),Math.max(r,c))}if(e instanceof oe){let i=0,a=0,c=0,u=0,h=0;for(let p of e.members){let d=this._getTypeSize(p.type);d!==null&&(i=Math.max(d.align,i),c=this._roundUp(d.align,c+u),u=d.size,h=c)}return a=this._roundUp(i,h+u),new se(Math.max(o,i),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof H&&e.storage=="uniform"}_isStorageVar(e){return e instanceof H&&e.storage=="storage"}_isTextureVar(e){return e instanceof H&&e.type!==null&&X._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof H&&e.type!==null&&X._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){let r=e;if(!r||!r.attributes)return null;let o=r.attributes;for(let i of o)if(i.name==t)return i;return null}_getAttributeNum(e,t,r){if(e===null)return r;for(let o of e)if(o.name==t){let i=o!==null&&o.value!==null?o.value:r;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):r}return r}_roundUp(e,t){return Math.ceil(t/e)*e}};X._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}};X._textureTypes=s.any_texture_type.map(n=>n.name);X._samplerTypes=s.sampler_type.map(n=>n.name);function Vn(n){let e={attributes:[],bindings:[]},t;try{t=To(n)}catch(i){return qn.log.error(i.message)(),e}for(let i of t.uniforms){let a=[];for(let c of i.type?.members||[])a.push({name:c.name,type:Qn(c.type)});e.bindings.push({type:"uniform",name:i.name,location:i.binding,group:i.group,members:a})}let r=t.entry.vertex[0],o=r?.inputs.length||0;for(let i=0;i<o;i++){let a=r.inputs[i];if(a.locationType==="location"){let c=Qn(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Qn(n){return n.format?`${n.name}<${n.format.name}>`:n.name}function To(n){try{return new X(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e?.message&&(t+=`: ${e.message} `),typeof e=="object"&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}var Eo=`float random(vec3 scale, float seed) {
90
+ `)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),a--,a==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),a++)}return!0}}let t=s.simpleTokens[e];if(t)return this._addToken(t),!0;let r=s.none,o=this._isAlpha(e),i=e==="_";if(this._isAlphaNumeric(e)){let a=this._peekAhead();for(;this._isAlphaNumeric(a);)e+=this._advance(),a=this._peekAhead()}if(o){let a=s.keywords[e];if(a)return this._addToken(a),!0}if(o||i)return this._addToken(s.tokens.ident),!0;for(;;){let a=this._findType(e),c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let u=!1,h=this._tokens.length-1;for(let p=0;p<5&&h>=0;++p,--h)if(this._tokens[h].type===s.tokens.less_than){h>0&&this._tokens[h-1].isArrayOrTemplateType()&&(u=!0);break}if(u)return this._addToken(a),!0}if(a===s.none){let u=e,h=0,p=2;for(let d=0;d<p;++d)if(u+=this._peekAhead(d),a=this._findType(u),a!==s.none){h=d;break}if(a===s.none)return r===s.none?!1:(this._current--,this._addToken(r),!0);e=u,this._current+=h+1}if(r=a,this._isAtEnd())break;e+=this._advance()}return r===s.none?!1:(this._addToken(r),!0)}_findType(e){for(let r in s.regexTokens){let o=s.regexTokens[r];if(this._match(e,o.rule))return o}let t=s.literalTokens[e];return t||s.none}_match(e,t){let r=t.exec(e);return r&&r.index==0&&r[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new Qe(e,t,this._line))}},Bt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new ht,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let r=this._global_decl_or_directive();if(!r)break;t.push(r)}if(this._deferArrayCountEval.length>0){for(let r of this._deferArrayCountEval){let o=r.arrayType,i=r.countNode;if(i instanceof be){let c=i.name,u=this._context.constants.get(c);if(u)try{let h=u.evaluate(this._context);o.count=h}catch{}}}this._deferArrayCountEval.length=0}return t}_initialize(e){if(e)if(typeof e=="string"){let t=new Xt(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,t){return{token:e,message:t,toString:function(){return`${t}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==s.eof}_match(e){if(e instanceof l)return this._check(e)?(this._advance(),!0):!1;for(let t=0,r=e.length;t<r;++t){let o=e[t];if(this._check(o))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),t)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let r=t.type;return e.indexOf(r)!=-1}return t.type==e}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._match(s.keywords.alias)){let t=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.diagnostic)){let t=this._diagnostic();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.requires)){let t=this._requires_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.enable)){let t=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}let e=this._attribute();if(this._check(s.keywords.var)){let t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.override)){let t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.let)){let t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.const)){let t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.struct)){let t=this._struct_decl();return t!=null&&(t.attributes=e),t}if(this._check(s.keywords.fn)){let t=this._function_decl();return t!=null&&(t.attributes=e),t}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected function name.").toString();this._consume(s.tokens.paren_left,"Expected '(' for function arguments.");let r=[];if(!this._check(s.tokens.paren_right))do{if(this._check(s.tokens.paren_right))break;let c=this._attribute(),u=this._consume(s.tokens.ident,"Expected argument name.").toString();this._consume(s.tokens.colon,"Expected ':' for argument type.");let h=this._attribute(),p=this._type_decl();p!=null&&(p.attributes=h,r.push(new Ut(u,p,c)))}while(this._match(s.tokens.comma));this._consume(s.tokens.paren_right,"Expected ')' after function arguments.");let o=null;if(this._match(s.tokens.arrow)){let c=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=c)}let i=this._compound_statement(),a=this._currentLine;return new xe(t,r,o,i,e,a)}_compound_statement(){let e=[];for(this._consume(s.tokens.brace_left,"Expected '{' for block.");!this._check(s.tokens.brace_right);){let t=this._statement();t!==null&&e.push(t)}return this._consume(s.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._check(s.tokens.attr)&&this._attribute(),this._check(s.keywords.if))return this._if_statement();if(this._check(s.keywords.switch))return this._switch_statement();if(this._check(s.keywords.loop))return this._loop_statement();if(this._check(s.keywords.for))return this._for_statement();if(this._check(s.keywords.while))return this._while_statement();if(this._check(s.keywords.continuing))return this._continuing_statement();if(this._check(s.keywords.static_assert))return this._static_assert_statement();if(this._check(s.tokens.brace_left))return this._compound_statement();let e=null;return this._check(s.keywords.return)?e=this._return_statement():this._check([s.keywords.var,s.keywords.let,s.keywords.const])?e=this._variable_statement():this._match(s.keywords.discard)?e=new St:this._match(s.keywords.break)?e=new Nt:this._match(s.keywords.continue)?e=new Tt:e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement(),e!=null&&this._consume(s.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(s.keywords.static_assert))return null;let e=this._optional_paren_expression();return new pt(e)}_while_statement(){if(!this._match(s.keywords.while))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement();return new dt(e,t)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new mt(e)}_for_statement(){if(!this._match(s.keywords.for))return null;this._consume(s.tokens.paren_left,"Expected '('.");let e=this._check(s.tokens.semicolon)?null:this._for_init();this._consume(s.tokens.semicolon,"Expected ';'.");let t=this._check(s.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(s.tokens.semicolon,"Expected ';'.");let r=this._check(s.tokens.paren_right)?null:this._for_increment();this._consume(s.tokens.paren_right,"Expected ')'."),this._check(s.tokens.attr)&&this._attribute();let o=this._compound_statement();return new gt(e,t,r,o)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(s.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(s.tokens.equal)&&(t=this._short_circuit_or_expression()),new W(e.name,e.type,e.storage,e.access,t)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for let.");let r=this._short_circuit_or_expression();return new ve(e,t,null,null,r)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for const.");let r=this._short_circuit_or_expression();return new Me(e,t,null,null,r)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(s.increment_operators))return this._current=e,null;let r=this._consume(s.increment_operators,"Expected increment operator");return new xt(r.type===s.tokens.plus_plus?le.increment:le.decrement,t)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let t=this._match(s.tokens.underscore);if(t||(e=this._unary_expression()),!t&&e==null)return null;let r=this._consume(s.assignment_operators,"Expected assignment operator."),o=this._short_circuit_or_expression();return new vt(Ae.parse(r.lexeme),e,o)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,t=this._consume(s.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=e,null):new Ie(t.lexeme,r)}_loop_statement(){if(!this._match(s.keywords.loop))return null;this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for loop.");let e=[],t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let o of t)e.push(o);else e.push(t);t=this._statement()}let r=null;return this._match(s.keywords.continuing)&&(r=this._compound_statement()),this._consume(s.tokens.brace_right,"Expected '}' for loop."),new At(e,r)}_switch_statement(){if(!this._match(s.keywords.switch))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for switch.");let t=this._switch_body();if(t==null||t.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new bt(e,t)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let t=this._case_selectors();this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch case.");let r=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch case."),e.push(new Rt(t,r))}if(this._match(s.keywords.default)){this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch default.");let t=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new Ot(t))}if(this._check([s.keywords.default,s.keywords.case])){let t=this._switch_body();e.push(t[0])}return e}_case_selectors(){let e=[this._shift_expression()];for(;this._match(s.tokens.comma);)e.push(this._shift_expression());return e}_case_body(){if(this._match(s.keywords.fallthrough))return this._consume(s.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);let t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(s.keywords.if))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement(),r=[];this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let o=null;return this._match(s.keywords.else)&&(this._check(s.tokens.attr)&&this._attribute(),o=this._compound_statement()),new yt(e,t,r,o)}_match_elseif(){return this._tokens[this._current].type===s.keywords.else&&this._tokens[this._current+1].type===s.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(e=[]){let t=this._optional_paren_expression(),r=this._compound_statement();return e.push(new zt(t,r)),this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(s.keywords.return))return null;let e=this._short_circuit_or_expression();return new Pt(e)}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(s.tokens.or_or);)e=new D(this._previous().toString(),e,this._short_circuit_and_expr());return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(s.tokens.and_and);)e=new D(this._previous().toString(),e,this._inclusive_or_expression());return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(s.tokens.or);)e=new D(this._previous().toString(),e,this._exclusive_or_expression());return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(s.tokens.xor);)e=new D(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new D(this._previous().toString(),e,this._equality_expression());return e}_equality_expression(){let e=this._relational_expression();return this._match([s.tokens.equal_equal,s.tokens.not_equal])?new D(this._previous().toString(),e,this._relational_expression()):e}_relational_expression(){let e=this._shift_expression();for(;this._match([s.tokens.less_than,s.tokens.greater_than,s.tokens.less_than_equal,s.tokens.greater_than_equal]);)e=new D(this._previous().toString(),e,this._shift_expression());return e}_shift_expression(){let e=this._additive_expression();for(;this._match([s.tokens.shift_left,s.tokens.shift_right]);)e=new D(this._previous().toString(),e,this._additive_expression());return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([s.tokens.plus,s.tokens.minus]);)e=new D(this._previous().toString(),e,this._multiplicative_expression());return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([s.tokens.star,s.tokens.forward_slash,s.tokens.modulo]);)e=new D(this._previous().toString(),e,this._unary_expression());return e}_unary_expression(){return this._match([s.tokens.minus,s.tokens.bang,s.tokens.tilde,s.tokens.star,s.tokens.and])?new Ct(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(s.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(s.tokens.bracket_right,"Expected ']'.");let t=new Ft(e),r=this._postfix_expression();return r&&(t.postfix=r),t}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),t=this._postfix_expression(),r=new Oe(e.lexeme);return t&&(r.postfix=t),r}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_primary_expression(){if(this._match(s.tokens.ident)){let r=this._previous().toString();if(this._check(s.tokens.paren_left)){let o=this._argument_expression_list(),i=this._getStruct(r);return i!=null?new $(i,o):new Ue(r,o)}if(this._context.constants.has(r)){let o=this._context.constants.get(r);return new ze(r,o.value)}return new be(r)}if(this._match(s.const_literal))return new Ye(parseFloat(this._previous().toString()));if(this._check(s.tokens.paren_left))return this._paren_expression();if(this._match(s.keywords.bitcast)){this._consume(s.tokens.less_than,"Expected '<'.");let r=this._type_decl();this._consume(s.tokens.greater_than,"Expected '>'.");let o=this._paren_expression();return new Mt(r,o)}let e=this._type_decl(),t=this._argument_expression_list();return new It(e,t)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(s.tokens.comma));return this._consume(s.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(s.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(s.tokens.paren_right),new De([e])}_paren_expression(){this._consume(s.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(s.tokens.paren_right,"Expected ')'."),new De([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected name for struct.").toString();this._consume(s.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(s.tokens.brace_right);){let a=this._attribute(),c=this._consume(s.tokens.ident,"Expected variable name.").toString();this._consume(s.tokens.colon,"Expected ':' for struct member type.");let u=this._attribute(),h=this._type_decl();h!=null&&(h.attributes=u),this._check(s.tokens.brace_right)?this._match(s.tokens.comma):this._consume(s.tokens.comma,"Expected ',' for struct member."),r.push(new Yt(c,h,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let o=this._currentLine,i=new V(t,r,e,o);return this._context.structs.set(t,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(s.keywords.const))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}let r=null;if(this._match(s.tokens.equal)){let i=this._short_circuit_or_expression();if(i instanceof $)r=i;else if(i instanceof ze&&i.initializer instanceof $)r=i.initializer;else try{let a=i.evaluate(this._context);r=new Ye(a)}catch{r=i}}let o=new Me(e.toString(),t,"","",r);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(s.keywords.let))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}let r=null;return this._match(s.tokens.equal)&&(r=this._const_expression()),new ve(e.toString(),t,"","",r)}_const_expression(){if(this._match(s.const_literal))return new Oe(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let t=[];for(;!this._check(s.tokens.paren_right)&&(t.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new $(e,t)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",t="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(t=this._consume(s.access_mode,"Expected access_mode.").toString()),this._consume(s.tokens.greater_than,"Expected '>'."));let r=this._consume(s.tokens.ident,"Expected variable name"),o=null;if(this._match(s.tokens.colon)){let i=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=i)}return new W(r.toString(),o,e,t,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let r=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=r)}return new Ee(e.toString(),t,null)}_diagnostic(){this._consume(s.tokens.paren_left,"Expected '('");let e=this._consume(s.tokens.ident,"Expected severity control name.");this._consume(s.tokens.comma,"Expected ','");let t=this._consume(s.tokens.ident,"Expected diagnostic rule name.");return this._consume(s.tokens.paren_right,"Expected ')'"),new kt(e.toString(),t.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new wt(e.toString())}_requires_directive(){let e=[this._consume(s.tokens.ident,"identity expected.").toString()];for(;this._match(s.tokens.comma);){let t=this._consume(s.tokens.ident,"identity expected.");e.push(t.toString())}return new Lt(e)}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let r=new Fe(e.toString(),t);return this._context.aliases.set(r.name,r),r}_type_decl(){if(this._check([s.tokens.ident,...s.texel_format,s.keywords.bool,s.keywords.f32,s.keywords.i32,s.keywords.u32])){let r=this._advance(),o=r.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new G(r.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(s.template_types)){let r=this._advance().toString(),o=null,i=null;return this._match(s.tokens.less_than)&&(o=this._type_decl(),i=null,this._match(s.tokens.comma)&&(i=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for type.")),new Ce(r,o,i)}if(this._match(s.keywords.ptr)){let r=this._previous().toString();this._consume(s.tokens.less_than,"Expected '<' for pointer.");let o=this._consume(s.storage_class,"Expected storage_class for pointer");this._consume(s.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),a=null;return this._match(s.tokens.comma)&&(a=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for pointer."),new Et(r,o.toString(),i,a)}let t=this._attribute();if(this._match(s.keywords.array)){let r=null,o=-1,i=this._previous(),a=null;if(this._match(s.tokens.less_than)){r=this._type_decl(),this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let u="";if(this._match(s.tokens.comma)){a=this._shift_expression();try{u=a.evaluate(this._context).toString(),a=null}catch{u="1"}}this._consume(s.tokens.greater_than,"Expected '>' for array."),o=u?parseInt(u):0}let c=new Re(i.toString(),t,r,o);return a&&this._deferArrayCountEval.push({arrayType:c,countNode:a}),c}return null}_texture_sampler_types(){if(this._match(s.sampler_type))return new J(this._previous().toString(),null,null);if(this._match(s.depth_texture_type))return new J(this._previous().toString(),null,null);if(this._match(s.sampled_texture_type)||this._match(s.multisampled_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(s.texel_format,"Invalid texel format.").toString();this._consume(s.tokens.comma,"Expected ',' after texel format.");let r=this._consume(s.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,r)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let t=this._consume(s.attribute_name,"Expected attribute name"),r=new Dt(t.toString(),null);if(this._match(s.tokens.paren_left)){if(r.value=this._consume(s.literal_or_ident,"Expected attribute value").toString(),this._check(s.tokens.comma)){this._advance();do{let o=this._consume(s.literal_or_ident,"Expected attribute value").toString();r.value instanceof Array||(r.value=[r.value]),r.value.push(o)}while(this._match(s.tokens.comma))}this._consume(s.tokens.paren_right,"Expected ')'")}e.push(r)}return e.length==0?null:e}},K=class{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},qe=class{constructor(e,t,r){this.name=e,this.type=t,this.attributes=r,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},oe=class extends K{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},ge=class extends K{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}},Ve=class extends K{constructor(e,t,r,o){super(e,r),this.format=t,this.access=o}get isTemplate(){return!0}},j;(function(n){n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(j||(j={}));var ie=class{constructor(e,t,r,o,i,a,c){this.name=e,this.type=t,this.group=r,this.binding=o,this.attributes=i,this.resourceType=a,this.access=c}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Qt=class{constructor(e,t){this.name=e,this.type=t}},se=class{constructor(e,t){this.align=e,this.size=t}},qt=class{constructor(e,t,r,o){this.name=e,this.type=t,this.locationType=r,this.location=o,this.interpolation=null}},We=class{constructor(e,t,r,o){this.name=e,this.type=t,this.locationType=r,this.location=o}},Vt=class{constructor(e,t=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t}},Wt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Gt=class{constructor(e,t,r,o){this.name=e,this.type=t,this.attributes=r,this.id=o}},Ht=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},X=class{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Wt,this.functions=[],this._types=new Map,this._functions=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let r=new Bt().parse(e);for(let o of r)o instanceof xe&&this._functions.set(o.name,new Ht(o));for(let o of r)if(o instanceof V){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i)}for(let o of r){if(o instanceof Fe){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof Ee){let i=o,a=this._getAttributeNum(i.attributes,"id",0),c=i.type!=null?this._getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Gt(i.name,c,i.attributes,a));continue}if(this._isUniformVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Uniform,i.access);this.uniforms.push(h);continue}if(this._isStorageVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Storage,i.access);this.storage.push(p);continue}if(this._isTextureVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Texture,i.access);h?this.storage.push(p):this.textures.push(p);continue}if(this._isSamplerVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Sampler,i.access);this.samplers.push(h);continue}if(o instanceof xe){let i=this._getAttribute(o,"vertex"),a=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),u=i||a||c,h=new Vt(o.name,u?.name);h.startLine=o.startLine,h.endLine=o.endLine,this.functions.push(h),this._functions.get(o.name).info=h,u&&(this._functions.get(o.name).inUse=!0,h.inUse=!0,h.resources=this._findResources(o,!!u),h.inputs=this._getInputs(o.args),h.outputs=this._getOutputs(o.returnType),this.entry[u.name].push(h));continue}}for(let o of this._functions.values())o.info&&(o.info.inUse=o.inUse,this._addCalls(o.node,o.info.calls));for(let o of this.uniforms)this._markStructsInUse(o.type);for(let o of this.storage)this._markStructsInUse(o.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var r;for(let o of e.calls){let i=(r=this._functions.get(o.name))===null||r===void 0?void 0:r.info;i&&t.add(i)}}findResource(e,t){for(let r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(let r of this.storage)if(r.group==e&&r.binding==t)return r;for(let r of this.textures)if(r.group==e&&r.binding==t)return r;for(let r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this._getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let r=[],o=this,i=[];return e.search(a=>{if(a instanceof ae)i.push({});else if(a instanceof ce)i.pop();else if(a instanceof W){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof $){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type)}else if(a instanceof ve){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof be){let c=a;if(i.length>0&&i[i.length-1][c.name])return;let u=o._findResource(c.name);u&&r.push(u)}else if(a instanceof Ue){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),r.push(...u.resources))}else if(a instanceof Ie){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),r.push(...u.resources))}}),[...new Map(r.map(a=>[a.name,a])).values()]}getBindGroups(){let e=[];function t(r,o){r>=e.length&&(e.length=r+1),e[r]===void 0&&(e[r]=[]),o>=e[r].length&&(e[r].length=o+1)}for(let r of this.uniforms){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.storage){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.textures){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.samplers){t(r.group,r.binding);let o=e[r.group];o[r.binding]=r}return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof V)this._getStructOutputs(e,t);else{let r=this._getOutputInfo(e);r!==null&&t.push(r)}return t}_getStructOutputs(e,t){for(let r of e.members)if(r.type instanceof V)this._getStructOutputs(r.type,t);else{let o=this._getAttribute(r,"location")||this._getAttribute(r,"builtin");if(o!==null){let i=this._getTypeInfo(r.type,r.type.attributes),a=this._parseInt(o.value),c=new We(r.name,i,o.name,a);t.push(c)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let r=this._getTypeInfo(e,e.attributes),o=this._parseInt(t.value);return new We("",r,t.name,o)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(let r of e)if(r.type instanceof V)this._getStructInputs(r.type,t);else{let o=this._getInputInfo(r);o!==null&&t.push(o)}return t}_getStructInputs(e,t){for(let r of e.members)if(r.type instanceof V)this._getStructInputs(r.type,t);else{let o=this._getInputInfo(r);o!==null&&t.push(o)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let r=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),a=new qt(e.name,o,t.name,i);return r!==null&&(a.interpolation=this._parseString(r.value)),a}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Qt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,t){if(this._types.has(e))return this._types.get(e);if(e instanceof Re){let o=e,i=this._getTypeInfo(o.format,o.attributes),a=new ge(o.name,t);return a.format=i,a.count=o.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof V){let o=e,i=new oe(o.name,t);i.startLine=o.startLine,i.endLine=o.endLine;for(let a of o.members){let c=this._getTypeInfo(a.type,a.attributes);i.members.push(new qe(a.name,c,a.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof J){let o=e,i=o.format instanceof G,a=o.format?i?this._getTypeInfo(o.format,null):new K(o.format,null):null,c=new Ve(o.name,a,t,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Ce){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new Ve(o.name,i,t,o.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let r=new K(e.name,t);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var t,r;let o=this._getTypeSize(e);if(e.size=(t=o?.size)!==null&&t!==void 0?t:0,e instanceof ge){let i=this._getTypeSize(e.format);e.stride=(r=i?.size)!==null&&r!==void 0?r:0,this._updateTypeInfo(e.format)}e instanceof oe&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let r=0,o=0,i=0,a=0;for(let c=0,u=e.members.length;c<u;++c){let h=e.members[c],p=this._getTypeSize(h);if(!p)continue;(t=this._getAlias(h.type.name))!==null&&t!==void 0||h.type;let d=p.align,m=p.size;r=this._roundUp(d,r+o),o=m,i=r,a=Math.max(a,d),h.offset=r,h.size=m,this._updateTypeInfo(h.type)}e.size=this._roundUp(a,i+o),e.align=a}_getTypeSize(e){var t;if(e==null)return null;let r=this._getAttributeNum(e.attributes,"size",0),o=this._getAttributeNum(e.attributes,"align",0);if(e instanceof qe&&(e=e.type),e instanceof K){let i=this._getAlias(e.name);i!==null&&(e=i)}{let i=X._typeInfo[e.name];if(i!==void 0){let a=e.format==="f16"?2:1;return new se(Math.max(o,i.align/a),Math.max(r,i.size/a))}}{let i=X._typeInfo[e.name.substring(0,e.name.length-1)];if(i){let a=e.name[e.name.length-1]==="h"?2:1;return new se(Math.max(o,i.align/a),Math.max(r,i.size/a))}}if(e instanceof ge){let i=e,a=8,c=8,u=this._getTypeSize(i.format);u!==null&&(c=u.size,a=u.align);let h=i.count,p=this._getAttributeNum((t=e?.attributes)!==null&&t!==void 0?t:null,"stride",this._roundUp(a,c));return c=h*p,r&&(c=r),new se(Math.max(o,a),Math.max(r,c))}if(e instanceof oe){let i=0,a=0,c=0,u=0,h=0;for(let p of e.members){let d=this._getTypeSize(p.type);d!==null&&(i=Math.max(d.align,i),c=this._roundUp(d.align,c+u),u=d.size,h=c)}return a=this._roundUp(i,h+u),new se(Math.max(o,i),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof W&&e.storage=="uniform"}_isStorageVar(e){return e instanceof W&&e.storage=="storage"}_isTextureVar(e){return e instanceof W&&e.type!==null&&X._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof W&&e.type!==null&&X._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){let r=e;if(!r||!r.attributes)return null;let o=r.attributes;for(let i of o)if(i.name==t)return i;return null}_getAttributeNum(e,t,r){if(e===null)return r;for(let o of e)if(o.name==t){let i=o!==null&&o.value!==null?o.value:r;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):r}return r}_roundUp(e,t){return Math.ceil(t/e)*e}};X._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}};X._textureTypes=s.any_texture_type.map(n=>n.name);X._samplerTypes=s.sampler_type.map(n=>n.name);function Vn(n){let e={attributes:[],bindings:[]},t;try{t=Mo(n)}catch(i){return qn.log.error(i.message)(),e}for(let i of t.uniforms){let a=[];for(let c of i.type?.members||[])a.push({name:c.name,type:Qn(c.type)});e.bindings.push({type:"uniform",name:i.name,location:i.binding,group:i.group,members:a})}let r=t.entry.vertex[0],o=r?.inputs.length||0;for(let i=0;i<o;i++){let a=r.inputs[i];if(a.locationType==="location"){let c=Qn(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Qn(n){return n.format?`${n.name}<${n.format.name}>`:n.name}function Mo(n){try{return new X(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e?.message&&(t+=`: ${e.message} `),typeof e=="object"&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}var Io=`float random(vec3 scale, float seed) {
91
91
  return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
92
92
  }
93
- `,q={name:"random",fs:Eo};var Mo=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
93
+ `,q={name:"random",fs:Io};var Fo=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
94
94
  const float TWO_PI = 6.2831854820251465;
95
95
  const float PI_2 = 1.5707963705062866;
96
96
  const float PI_16 = 0.1963495463132858;
@@ -212,7 +212,7 @@ return tan_taylor_fp32(a);
212
212
  return tan(a);
213
213
  #endif
214
214
  }
215
- `,Hn={name:"fp32",vs:Mo};var Io=[0,1,1,1],Fo=`uniform pickingUniforms {
215
+ `,Wn={name:"fp32",vs:Fo};var Co=[0,1,1,1],Ro=`uniform pickingUniforms {
216
216
  float isActive;
217
217
  float isAttribute;
218
218
  float isHighlightActive;
@@ -264,7 +264,7 @@ if (bool(picking.isAttribute)) {
264
264
  picking_vRGBcolor_Avalid.rgb = value;
265
265
  }
266
266
  }
267
- `,Co=`uniform pickingUniforms {
267
+ `,Oo=`uniform pickingUniforms {
268
268
  float isActive;
269
269
  float isAttribute;
270
270
  float isHighlightActive;
@@ -301,7 +301,7 @@ vec4 picking_filterColor(vec4 color) {
301
301
  vec4 highlightColor = picking_filterHighlightColor(color);
302
302
  return picking_filterPickingColor(highlightColor);
303
303
  }
304
- `,Gn={name:"picking",vs:Fo,fs:Co,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:Io},getUniforms:Ro};function Ro(n={},e){let t={};if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}if(n.highlightColor){let r=Array.from(n.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),t.highlightColor=r}return n.isActive!==void 0&&(t.isActive=Boolean(n.isActive),t.isAttribute=Boolean(n.isAttribute)),n.useFloatColors!==void 0&&(t.useFloatColors=Boolean(n.useFloatColors)),t}var jt=`precision highp int;
304
+ `,Gn={name:"picking",vs:Ro,fs:Oo,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:Co},getUniforms:Uo};function Uo(n={},e){let t={};if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}if(n.highlightColor){let r=Array.from(n.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),t.highlightColor=r}return n.isActive!==void 0&&(t.isActive=Boolean(n.isActive),t.isAttribute=Boolean(n.isAttribute)),n.useFloatColors!==void 0&&(t.useFloatColors=Boolean(n.useFloatColors)),t}var jt=`precision highp int;
305
305
  struct AmbientLight {
306
306
  vec3 color;
307
307
  };
@@ -360,11 +360,11 @@ return pointLight.attenuation.x
360
360
  + pointLight.attenuation.y * distance
361
361
  + pointLight.attenuation.z * distance * distance;
362
362
  }
363
- `;var Wn=rt(ke(),1),jn=3,Oo=255,be;(function(n){n[n.POINT=0]="POINT",n[n.DIRECTIONAL=1]="DIRECTIONAL"})(be||(be={}));var Q={name:"lighting",vs:jt,fs:jt,getUniforms(n,e){return Uo(n)},defines:{MAX_LIGHTS:jn},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:be.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]}};function Uo(n,e={}){if(n=n&&{...n},!n)return{...Q.defaultUniforms};n.lights&&(n={...n,...Do(n.lights),lights:void 0});let{ambientLight:t,pointLights:r,directionalLights:o}=n||{};if(!(t||r&&r.length>0||o&&o.length>0))return{...Q.defaultUniforms,enabled:0};let a={...Q.defaultUniforms,...e,...zo({ambientLight:t,pointLights:r,directionalLights:o})};return n.enabled!==void 0&&(a.enabled=n.enabled?1:0),a}function zo({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};r.ambientLightColor=$t(n);let o=0;for(let i of e){r.lightType=be.POINT;let a=o;r[`lightColor${a}`]=$t(i),r[`lightPosition${a}`]=i.position,r[`lightAttenuation${a}`]=i.attenuation||[1,0,0],o++}for(let i of t){r.lightType=be.DIRECTIONAL;let a=o;r[`lightColor${a}`]=$t(i),r[`lightDirection${a}`]=i.direction,o++}return o>jn&&Wn.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=t.length,r.pointLightCount=e.length,r}function Do(n){let e={pointLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function $t(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/Oo)}var Yo=`out vec3 dirlight_vNormal;
363
+ `;var Hn=rt(ke(),1),jn=3,zo=255,ye;(function(n){n[n.POINT=0]="POINT",n[n.DIRECTIONAL=1]="DIRECTIONAL"})(ye||(ye={}));var Q={name:"lighting",vs:jt,fs:jt,getUniforms(n,e){return Yo(n)},defines:{MAX_LIGHTS:jn},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:ye.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]}};function Yo(n,e={}){if(n=n&&{...n},!n)return{...Q.defaultUniforms};n.lights&&(n={...n,...Xo(n.lights),lights:void 0});let{ambientLight:t,pointLights:r,directionalLights:o}=n||{};if(!(t||r&&r.length>0||o&&o.length>0))return{...Q.defaultUniforms,enabled:0};let a={...Q.defaultUniforms,...e,...Do({ambientLight:t,pointLights:r,directionalLights:o})};return n.enabled!==void 0&&(a.enabled=n.enabled?1:0),a}function Do({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};r.ambientLightColor=$t(n);let o=0;for(let i of e){r.lightType=ye.POINT;let a=o;r[`lightColor${a}`]=$t(i),r[`lightPosition${a}`]=i.position,r[`lightAttenuation${a}`]=i.attenuation||[1,0,0],o++}for(let i of t){r.lightType=ye.DIRECTIONAL;let a=o;r[`lightColor${a}`]=$t(i),r[`lightDirection${a}`]=i.direction,o++}return o>jn&&Hn.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=t.length,r.pointLightCount=e.length,r}function Xo(n){let e={pointLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function $t(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/zo)}var Bo=`out vec3 dirlight_vNormal;
364
364
  void dirlight_setNormal(vec3 normal) {
365
365
  dirlight_vNormal = normalize(normal);
366
366
  }
367
- `,Xo=`uniform dirlightUniforms {
367
+ `,Qo=`uniform dirlightUniforms {
368
368
  vec3 lightDirection;
369
369
  } dirlight;
370
370
  in vec3 dirlight_vNormal;
@@ -372,13 +372,13 @@ vec4 dirlight_filterColor(vec4 color) {
372
372
  float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
373
373
  return vec4(color.rgb * d, color.a);
374
374
  }
375
- `,Kt={name:"dirlight",dependencies:[],vs:Yo,fs:Xo,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:Bo};function Bo(n=Kt.defaultUniforms){let e={};return n.lightDirection&&(e.dirlight_uLightDirection=n.lightDirection),e}var Ge=`uniform phongMaterialUniforms {
375
+ `,Kt={name:"dirlight",dependencies:[],vs:Bo,fs:Qo,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:qo};function qo(n=Kt.defaultUniforms){let e={};return n.lightDirection&&(e.dirlight_uLightDirection=n.lightDirection),e}var Ge=`uniform phongMaterialUniforms {
376
376
  uniform float ambient;
377
377
  uniform float diffuse;
378
378
  uniform float shininess;
379
379
  uniform vec3 specularColor;
380
380
  } material;
381
- `,We=`uniform phongMaterialUniforms {
381
+ `,He=`uniform phongMaterialUniforms {
382
382
  uniform float ambient;
383
383
  uniform float diffuse;
384
384
  uniform float shininess;
@@ -416,33 +416,27 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
416
416
  }
417
417
  return lightColor;
418
418
  }
419
- `;var Zt={name:"gouraudMaterial",vs:We.replace("phongMaterial","gouraudMaterial"),fs:Ge.replace("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Zt.defaultUniforms,...n}}};var Jt={name:"phongMaterial",vs:Ge,fs:We,defines:{LIGHTING_FRAGMENT:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Jt.defaultUniforms,...n}}};var $n=`uniform projection {
420
- mat4 u_MVPMatrix;
421
- mat4 u_ModelMatrix;
422
- mat4 u_NormalMatrix;
423
- vec3 u_Camera;
424
- }
425
- varying vec3 pbr_vPosition;
426
- varying vec2 pbr_vUV;
419
+ `;var Zt={name:"gouraudMaterial",vs:He.replace("phongMaterial","gouraudMaterial"),fs:Ge.replace("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Zt.defaultUniforms,...e}}};var Jt={name:"phongMaterial",vs:Ge,fs:He,defines:{LIGHTING_FRAGMENT:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Jt.defaultUniforms,...e}}};var $n=`out vec3 pbr_vPosition;
420
+ out vec2 pbr_vUV;
427
421
  #ifdef HAS_NORMALS
428
422
  # ifdef HAS_TANGENTS
429
- varying mat3 pbr_vTBN;
423
+ out mat3 pbr_vTBN;
430
424
  # else
431
- varying vec3 pbr_vNormal;
425
+ out vec3 pbr_vNormal;
432
426
  # endif
433
427
  #endif
434
428
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
435
429
  {
436
- vec4 pos = u_ModelMatrix * position;
430
+ vec4 pos = pbrProjection.modelMatrix * position;
437
431
  pbr_vPosition = vec3(pos.xyz) / pos.w;
438
432
  #ifdef HAS_NORMALS
439
433
  #ifdef HAS_TANGENTS
440
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
441
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
434
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
435
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
442
436
  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
443
437
  pbr_vTBN = mat3(tangentW, bitangentW, normalW);
444
438
  #else
445
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
439
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
446
440
  #endif
447
441
  #endif
448
442
  #ifdef HAS_UV
@@ -452,10 +446,7 @@ pbr_vUV = vec2(0.,0.);
452
446
  #endif
453
447
  }
454
448
  `;var Kn=`precision highp float;
455
- uniform Projection {
456
- uniform vec3 u_Camera;
457
- };
458
- uniform pbrMaterial {
449
+ uniform pbrMaterialUniforms {
459
450
  bool unlit;
460
451
  bool baseColorMapEnabled;
461
452
  vec4 baseColorFactor;
@@ -473,34 +464,34 @@ bool IBLenabled;
473
464
  vec2 scaleIBLAmbient;
474
465
  vec4 scaleDiffBaseMR;
475
466
  vec4 scaleFGDSpec;
476
- } u_pbrMaterial;
467
+ } pbrMaterial;
477
468
  #ifdef HAS_BASECOLORMAP
478
- uniform sampler2D u_BaseColorSampler;
469
+ uniform sampler2D pbr_baseColorSampler;
479
470
  #endif
480
471
  #ifdef HAS_NORMALMAP
481
- uniform sampler2D u_NormalSampler;
472
+ uniform sampler2D pbr_normalSampler;
482
473
  #endif
483
474
  #ifdef HAS_EMISSIVEMAP
484
- uniform sampler2D u_EmissiveSampler;
475
+ uniform sampler2D pbr_emissiveSampler;
485
476
  #endif
486
477
  #ifdef HAS_METALROUGHNESSMAP
487
- uniform sampler2D u_MetallicRoughnessSampler;
478
+ uniform sampler2D pbr_metallicRoughnessSampler;
488
479
  #endif
489
480
  #ifdef HAS_OCCLUSIONMAP
490
- uniform sampler2D u_OcclusionSampler;
481
+ uniform sampler2D pbr_occlusionSampler;
491
482
  #endif
492
483
  #ifdef USE_IBL
493
- uniform samplerCube u_DiffuseEnvSampler;
494
- uniform samplerCube u_SpecularEnvSampler;
495
- uniform sampler2D u_brdfLUT;
484
+ uniform samplerCube pbr_diffuseEnvSampler;
485
+ uniform samplerCube pbr_specularEnvSampler;
486
+ uniform sampler2D pbr_brdfLUT;
496
487
  #endif
497
- varying vec3 pbr_vPosition;
498
- varying vec2 pbr_vUV;
488
+ in vec3 pbr_vPosition;
489
+ in vec2 pbr_vUV;
499
490
  #ifdef HAS_NORMALS
500
491
  #ifdef HAS_TANGENTS
501
- varying mat3 pbr_vTBN;
492
+ in mat3 pbr_vTBN;
502
493
  #else
503
- varying vec3 pbr_vNormal;
494
+ in vec3 pbr_vNormal;
504
495
  #endif
505
496
  #endif
506
497
  struct PBRInfo {
@@ -555,8 +546,8 @@ mat3 tbn = mat3(t, b, ng);
555
546
  mat3 tbn = pbr_vTBN;
556
547
  #endif
557
548
  #ifdef HAS_NORMALMAP
558
- vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;
559
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_pbrMaterial.normalScale, u_pbrMaterial.normalScale, 1.0)));
549
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
550
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
560
551
  #else
561
552
  vec3 n = normalize(tbn[2].xyz);
562
553
  #endif
@@ -567,18 +558,18 @@ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
567
558
  {
568
559
  float mipCount = 9.0;
569
560
  float lod = (pbrInfo.perceptualRoughness * mipCount);
570
- vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,
561
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
571
562
  vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
572
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
563
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
573
564
  #ifdef USE_TEX_LOD
574
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
565
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
575
566
  #else
576
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
567
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
577
568
  #endif
578
569
  vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
579
570
  vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
580
- diffuse *= u_pbrMaterial.scaleIBLAmbient.x;
581
- specular *= u_pbrMaterial.scaleIBLAmbient.y;
571
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
572
+ specular *= pbrMaterial.scaleIBLAmbient.y;
582
573
  return diffuse + specular;
583
574
  }
584
575
  #endif
@@ -638,24 +629,24 @@ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
638
629
  vec4 pbr_filterColor(vec4 colorUnused)
639
630
  {
640
631
  #ifdef HAS_BASECOLORMAP
641
- vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_pbrMaterial.baseColorFactor;
632
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
642
633
  #else
643
- vec4 baseColor = u_pbrMaterial.baseColorFactor;
634
+ vec4 baseColor = pbrMaterial.baseColorFactor;
644
635
  #endif
645
636
  #ifdef ALPHA_CUTOFF
646
- if (baseColor.a < u_pbrMaterial.alphaCutoff) {
637
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
647
638
  discard;
648
639
  }
649
640
  #endif
650
641
  vec3 color = vec3(0, 0, 0);
651
- if(u_pbrMaterial.unlit){
642
+ if(pbrMaterial.unlit){
652
643
  color.rgb = baseColor.rgb;
653
644
  }
654
645
  else{
655
- float perceptualRoughness = u_pbrMaterial.metallicRoughnessValues.y;
656
- float metallic = u_pbrMaterial.metallicRoughnessValues.x;
646
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
647
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
657
648
  #ifdef HAS_METALROUGHNESSMAP
658
- vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);
649
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
659
650
  perceptualRoughness = mrSample.g * perceptualRoughness;
660
651
  metallic = mrSample.b * metallic;
661
652
  #endif
@@ -671,7 +662,7 @@ float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
671
662
  vec3 specularEnvironmentR0 = specularColor.rgb;
672
663
  vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
673
664
  vec3 n = getNormal();
674
- vec3 v = normalize(u_Camera - pbr_vPosition);
665
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition);
675
666
  float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
676
667
  vec3 reflection = -normalize(reflect(v, n));
677
668
  PBRInfo pbrInfo = PBRInfo(
@@ -692,47 +683,53 @@ v
692
683
  );
693
684
  #ifdef USE_LIGHTS
694
685
  PBRInfo_setAmbientLight(pbrInfo);
695
- color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color);
696
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
697
- if (i < lighting_uDirectionalLightCount) {
698
- PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction);
699
- color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color);
686
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
687
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
688
+ if (i < lighting.directionalLightCount) {
689
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
690
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
700
691
  }
701
692
  }
702
- for(int i = 0; i < lighting_uPointLightCount; i++) {
703
- if (i < lighting_uPointLightCount) {
704
- PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]);
705
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
706
- color += calculateFinalColor(pbrInfo, lighting_uPointLight[i].color / attenuation);
693
+ for(int i = 0; i < lighting.pointLightCount; i++) {
694
+ if (i < lighting.pointLightCount) {
695
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
696
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
697
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
707
698
  }
708
699
  }
709
700
  #endif
710
701
  #ifdef USE_IBL
711
- if (u_pbrMateral.IBLEnabled) {
702
+ if (pbrMaterial.IBLenabled) {
712
703
  color += getIBLContribution(pbrInfo, n, reflection);
713
704
  }
714
705
  #endif
715
706
  #ifdef HAS_OCCLUSIONMAP
716
- if (u_pbrMaterial.occlusionMapEnabled) {
717
- float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;
718
- color = mix(color, color * ao, u_pbrMaterial.occlusionStrength);
707
+ if (pbrMaterial.occlusionMapEnabled) {
708
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
709
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
719
710
  }
720
711
  #endif
721
712
  #ifdef HAS_EMISSIVEMAP
722
- if (u_pbrMaterial.emmissiveMapEnabled) {
723
- vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_pbrMaterial.emissiveFactor;
713
+ if (pbrMaterial.emissiveMapEnabled) {
714
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
724
715
  color += emissive;
725
716
  }
726
717
  #endif
727
718
  #ifdef PBR_DEBUG
728
- color = mix(color, baseColor.rgb, u_pbrMaterial.scaleDiffBaseMR.y);
729
- color = mix(color, vec3(metallic), u_pbrMaterial.scaleDiffBaseMR.z);
730
- color = mix(color, vec3(perceptualRoughness), u_pbrMaterial.scaleDiffBaseMR.w);
719
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
720
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
721
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
731
722
  #endif
732
723
  }
733
724
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
734
725
  }
735
- `;var Zn={name:"pbr",vs:$n,fs:Kn,defines:{LIGHTING_FRAGMENT:1,HAS_NORMALMAP:0,HAS_EMISSIVEMAP:0,HAS_OCCLUSIONMAP:0,HAS_BASECOLORMAP:0,HAS_METALROUGHNESSMAP:0,ALPHA_CUTOFF:0,USE_IBL:0,PBR_DEBUG:0},uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"},dependencies:[Q]};var Qo=`uniform brightnessContrastUniforms {
726
+ `;var Zn=`uniform pbrProjectionUniforms {
727
+ mat4 modelViewProjectionMatrix;
728
+ mat4 modelMatrix;
729
+ mat4 normalMatrix;
730
+ vec3 camera;
731
+ } pbrProjection;
732
+ `,Jn={name:"pbrProjection",vs:Zn,fs:Zn,getUniforms:n=>n,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<i32>"}};var er={name:"pbrMaterial",vs:$n,fs:Kn,defines:{LIGHTING_FRAGMENT:1},getUniforms:n=>n,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"},dependencies:[Q,Jn]};var Vo=`uniform brightnessContrastUniforms {
736
733
  float brightness;
737
734
  float contrast;
738
735
  } brightnessContrast;
@@ -748,7 +745,7 @@ return color;
748
745
  vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
749
746
  return brightnessContrast_filterColor(color);
750
747
  }
751
- `,Jn={name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},uniformPropTypes:{brightness:{format:"f32",value:0,min:-1,max:1},contrast:{format:"f32",value:0,min:-1,max:1}},fs:Qo,passes:[{filter:!0}]};var qo=`uniform denoiseUniforms {
748
+ `,tr={name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},uniformPropTypes:{brightness:{format:"f32",value:0,min:-1,max:1},contrast:{format:"f32",value:0,min:-1,max:1}},fs:Vo,passes:[{filter:!0}]};var Wo=`uniform denoiseUniforms {
752
749
  float strength;
753
750
  } noise;
754
751
  vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
@@ -767,7 +764,7 @@ total += weight;
767
764
  }
768
765
  return color / total;
769
766
  }
770
- `,er={name:"denoise",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:qo,passes:[{sampler:!0},{sampler:!0}]};var Vo=`uniform hueSaturationUniforms {
767
+ `,nr={name:"denoise",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:Wo,passes:[{sampler:!0},{sampler:!0}]};var Go=`uniform hueSaturationUniforms {
771
768
  float hue;
772
769
  float saturation;
773
770
  } hueSaturation;
@@ -792,7 +789,7 @@ return color;
792
789
  vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
793
790
  return hueSaturation_filterColor(color);
794
791
  }
795
- `,tr={name:"hueSaturation",uniformTypes:{hue:"f32",saturation:"f32"},uniformPropTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},fs:Vo,passes:[{filter:!0}]};var Ho=`uniform noiseUniforms {
792
+ `,rr={name:"hueSaturation",uniformTypes:{hue:"f32",saturation:"f32"},uniformPropTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},fs:Go,passes:[{filter:!0}]};var Ho=`uniform noiseUniforms {
796
793
  float amount;
797
794
  } noise;
798
795
  float rand(vec2 co) {
@@ -808,7 +805,7 @@ return color;
808
805
  vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
809
806
  return noise_filterColor(color, texCoord);
810
807
  }
811
- `,nr={name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Ho,passes:[{filter:!0}]};var Go=`uniform sepiaUniforms {
808
+ `,or={name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Ho,passes:[{filter:!0}]};var jo=`uniform sepiaUniforms {
812
809
  float amount;
813
810
  } sepia;
814
811
  vec4 sepia_filterColor(vec4 color) {
@@ -824,7 +821,7 @@ return color;
824
821
  vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
825
822
  return sepia_filterColor(color);
826
823
  }
827
- `,rr={name:"sepia",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Go,passes:[{filter:!0}]};var Wo=`uniform vibranceUniforms {
824
+ `,ir={name:"sepia",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:jo,passes:[{filter:!0}]};var $o=`uniform vibranceUniforms {
828
825
  float amount;
829
826
  } vibrance;
830
827
  vec4 vibrance_filterColor(vec4 color) {
@@ -837,7 +834,7 @@ return color;
837
834
  vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
838
835
  return vibrance_filterColor(color);
839
836
  }
840
- `,or={name:"vibrance",uniformPropTypes:{amount:{value:0,min:-1,max:1}},fs:Wo,passes:[{filter:!0}]};var jo=`uniform vignetteUniforms {
837
+ `,sr={name:"vibrance",uniformPropTypes:{amount:{value:0,min:-1,max:1}},fs:$o,passes:[{filter:!0}]};var Ko=`uniform vignetteUniforms {
841
838
  float radius;
842
839
  float amount;
843
840
  } vignette;
@@ -849,7 +846,7 @@ return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
849
846
  vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
850
847
  return vignette_filterColor(color, texCoord);
851
848
  }
852
- `,ir={name:"vignette",fs:jo,uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}]};var $o=`uniform tiltShiftUniforms {
849
+ `,ar={name:"vignette",fs:Ko,uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}]};var Zo=`uniform tiltShiftUniforms {
853
850
  float blurRadius;
854
851
  float gradientRadius;
855
852
  vec2 start;
@@ -879,7 +876,7 @@ color = color / total;
879
876
  color.rgb /= color.a + 0.00001;
880
877
  return color;
881
878
  }
882
- `,sr={name:"tiltShift",uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},uniformPropTypes:{blurRadius:{value:15,min:0,max:50},gradientRadius:{value:200,min:0,max:400},start:{value:[0,0]},end:{value:[1,1]},invert:{value:!1,private:!0}},passes:[{sampler:!0,uniforms:{invert:!1}},{sampler:!0,uniforms:{invert:!0}}],dependencies:[q],fs:$o};var Ko=`uniform triangleBlurUniforms {
879
+ `,cr={name:"tiltShift",uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},uniformPropTypes:{blurRadius:{value:15,min:0,max:50},gradientRadius:{value:200,min:0,max:400},start:{value:[0,0]},end:{value:[1,1]},invert:{value:!1,private:!0}},passes:[{sampler:!0,uniforms:{invert:!1}},{sampler:!0,uniforms:{invert:!0}}],dependencies:[q],fs:Zo};var Jo=`uniform triangleBlurUniforms {
883
880
  float radius;
884
881
  vec2 delta;
885
882
  } triangleBlur;
@@ -900,7 +897,7 @@ color = color / total;
900
897
  color.rgb /= color.a + 0.00001;
901
898
  return color;
902
899
  }
903
- `,ar={name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},uniformPropTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Ko,dependencies:[q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var Zo=`
900
+ `,lr={name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},uniformPropTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Jo,dependencies:[q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var ei=`
904
901
  uniform zoomBlurUniforms {
905
902
  vec2 center;
906
903
  float strength;
@@ -933,7 +930,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
933
930
 
934
931
  return color;
935
932
  }
936
- `,cr={name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:Zo,dependencies:[q],passes:[{sampler:!0}]};var Jo=`uniform colorHalftoneUniforms {
933
+ `,fr={name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:ei,dependencies:[q],passes:[{sampler:!0}]};var ti=`uniform colorHalftoneUniforms {
937
934
  vec2 center;
938
935
  float angle;
939
936
  float size;
@@ -964,7 +961,7 @@ pattern(colorHalftone.angle, scale, texSize, texCoord)
964
961
  k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
965
962
  return vec4(1.0 - cmy - k, color.a);
966
963
  }
967
- `,lr={name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:4,min:1,softMin:3,softMax:20}},fs:Jo,passes:[{filter:!0}]};var ei=`uniform dotScreenUniforms {
964
+ `,ur={name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:4,min:1,softMin:3,softMax:20}},fs:ti,passes:[{filter:!0}]};var ni=`uniform dotScreenUniforms {
968
965
  vec2 center;
969
966
  float angle;
970
967
  float size;
@@ -983,7 +980,7 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
983
980
  float average = (color.r + color.g + color.b) / 3.0;
984
981
  return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
985
982
  }
986
- `,fr={name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:3,min:1,softMin:3,softMax:20}},fs:ei,passes:[{filter:!0}]};var ti=`uniform edgeWorkUniforms {
983
+ `,_r={name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:3,min:1,softMin:3,softMax:20}},fs:ni,passes:[{filter:!0}]};var ri=`uniform edgeWorkUniforms {
987
984
  float radius;
988
985
  vec2 delta;
989
986
  } edgeWork;
@@ -1027,7 +1024,7 @@ total.y += weight;
1027
1024
  float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
1028
1025
  return vec4(c, c, c, 1.0);
1029
1026
  }
1030
- `,ur={name:"edgeWork",uniformPropTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},fs:ti,dependencies:[q],passes:[{sampler:"edgeWork_sampleColor1",uniformPropTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",uniformPropTypes:{delta:[0,1]}}]};var ni=`uniform hexagonalPixelateUniforms {
1027
+ `,hr={name:"edgeWork",uniformPropTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},fs:ri,dependencies:[q],passes:[{sampler:"edgeWork_sampleColor1",uniformPropTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",uniformPropTypes:{delta:[0,1]}}]};var oi=`uniform hexagonalPixelateUniforms {
1031
1028
  vec2 center;
1032
1029
  float scale;
1033
1030
  } hexagonalPixelate;
@@ -1062,7 +1059,7 @@ choice.y *= 0.866025404;
1062
1059
  choice *= hexagonalPixelate.scale / texSize;
1063
1060
  return texture(source, choice + hexagonalPixelate.center);
1064
1061
  }
1065
- `,_r={name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},uniformPropTypes:{center:{value:[.5,.5],hint:"screenspace"},scale:{value:10,min:1,softMin:5,softMax:50}},fs:ni,passes:[{sampler:!0}]};var ri=`uniform inkUniforms {
1062
+ `,pr={name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},uniformPropTypes:{center:{value:[.5,.5],hint:"screenspace"},scale:{value:10,min:1,softMin:5,softMax:50}},fs:oi,passes:[{sampler:!0}]};var ii=`uniform inkUniforms {
1066
1063
  float strength;
1067
1064
  } ink;
1068
1065
  vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
@@ -1088,7 +1085,7 @@ vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
1088
1085
  float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
1089
1086
  return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
1090
1087
  }
1091
- `,hr={name:"ink",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{value:.25,min:0,softMax:1}},fs:ri,passes:[{sampler:!0}]};var oi=`uniform magnifyUniforms {
1088
+ `,dr={name:"ink",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{value:.25,min:0,softMax:1}},fs:ii,passes:[{sampler:!0}]};var si=`uniform magnifyUniforms {
1092
1089
  vec2 screenXY;
1093
1090
  float radiusPixels;
1094
1091
  float zoom;
@@ -1106,7 +1103,7 @@ return magnify.borderColor;
1106
1103
  }
1107
1104
  return texture(source, texCoord);
1108
1105
  }
1109
- `,pr={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},uniformPropTypes:{screenXY:{value:[0,0]},radiusPixels:200,zoom:2,borderWidthPixels:0,borderColor:{value:[255,255,255,255]}},fs:oi,passes:[{sampler:!0}]};var ii=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1106
+ `,mr={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},uniformPropTypes:{screenXY:{value:[0,0]},radiusPixels:200,zoom:2,borderWidthPixels:0,borderColor:{value:[255,255,255,255]}},fs:si,passes:[{sampler:!0}]};var ai=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1110
1107
  vec4 color = texture(source, coord / texSize);
1111
1108
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
1112
1109
  if (coord != clampedCoord) {
@@ -1114,7 +1111,7 @@ color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
1114
1111
  }
1115
1112
  return color;
1116
1113
  }
1117
- `,fe={name:"warp",passes:[],fs:ii};var si=`uniform bulgePinchUniforms {
1114
+ `,fe={name:"warp",passes:[],fs:ai};var ci=`uniform bulgePinchUniforms {
1118
1115
  float radius;
1119
1116
  float strength;
1120
1117
  vec2 center;
@@ -1138,7 +1135,7 @@ vec2 coord = texCoord * texSize;
1138
1135
  coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
1139
1136
  return warp_sampleColor(source, texSize, coord);
1140
1137
  }
1141
- `,dr={name:"bulgePinch",fs:si,uniformTypes:{center:"vec2<f32>",radius:"f32",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},strength:{value:.5,min:-1,max:1}},dependencies:[fe],passes:[{sampler:!0}]};var ai=`uniform swirlUniforms {
1138
+ `,gr={name:"bulgePinch",fs:ci,uniformTypes:{center:"vec2<f32>",radius:"f32",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},strength:{value:.5,min:-1,max:1}},dependencies:[fe],passes:[{sampler:!0}]};var li=`uniform swirlUniforms {
1142
1139
  float radius;
1143
1140
  float angle;
1144
1141
  vec2 center;
@@ -1164,7 +1161,7 @@ vec2 coord = texCoord * texSize;
1164
1161
  coord = swirl_warp(coord, swirl.center * texSize);
1165
1162
  return warp_sampleColor(source, texSize, coord);
1166
1163
  }
1167
- `,mr={name:"swirl",fs:ai,uniformTypes:{center:"vec2<f32>",radius:"f32",angle:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},angle:{value:3,softMin:-25,softMax:25}},dependencies:[fe],passes:[{sampler:!0}]};var ci=`
1164
+ `,xr={name:"swirl",fs:li,uniformTypes:{center:"vec2<f32>",radius:"f32",angle:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},angle:{value:3,softMin:-25,softMax:25}},dependencies:[fe],passes:[{sampler:!0}]};var fi=`
1168
1165
  #define FXAA_QUALITY_PRESET 29
1169
1166
 
1170
1167
  #if (FXAA_QUALITY_PRESET == 10)
@@ -1744,7 +1741,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1744
1741
  fxaa_QualityEdgeThresholdMin
1745
1742
  );
1746
1743
  }
1747
- `,gr={name:"fxaa",uniformPropTypes:{},fs:ci,passes:[{sampler:!0}]};function je(n,e=[],t=0){let r=Math.fround(n),o=n-r;return e[t]=r,e[t+1]=o,e}function en(n){return n-Math.fround(n)}function tn(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let r=0;r<4;++r){let o=t*4+r;je(n[r*4+t],e,o*2)}return e}var xr=`uniform float ONE;
1744
+ `,vr={name:"fxaa",uniformPropTypes:{},fs:fi,passes:[{sampler:!0}]};function je(n,e=[],t=0){let r=Math.fround(n),o=n-r;return e[t]=r,e[t+1]=o,e}function en(n){return n-Math.fround(n)}function tn(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let r=0;r<4;++r){let o=t*4+r;je(n[r*4+t],e,o*2)}return e}var Ar=`uniform float ONE;
1748
1745
  vec2 split(float a) {
1749
1746
  const float SPLIT = 4097.0;
1750
1747
  float t = a * SPLIT;
@@ -1876,7 +1873,7 @@ return sum_fp64(split(yn), prod);
1876
1873
  return sum_fp64(vec2(yn, 0.0), prod);
1877
1874
  #endif
1878
1875
  }
1879
- `;var vr=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
1876
+ `;var br=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
1880
1877
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
1881
1878
  const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
1882
1879
  const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
@@ -2389,7 +2386,7 @@ tmp[j] = b[j + i * 4];
2389
2386
  vec4_dot_fp64(a, tmp, out_val[i]);
2390
2387
  }
2391
2388
  }
2392
- `;var li={ONE:1};function fi(){return li}var nn={name:"fp64-arithmetic",vs:xr,getUniforms:fi,fp64ify:je,fp64LowPart:en,fp64ifyMatrix4:tn},Ar={name:"fp64",vs:vr,dependencies:[nn],fp64ify:je,fp64LowPart:en,fp64ifyMatrix4:tn};var ui=`varying vec4 geometry_vPosition;
2389
+ `;var ui={ONE:1};function _i(){return ui}var nn={name:"fp64-arithmetic",vs:Ar,getUniforms:_i,fp64ify:je,fp64LowPart:en,fp64ifyMatrix4:tn},yr={name:"fp64",vs:br,dependencies:[nn],fp64ify:je,fp64LowPart:en,fp64ifyMatrix4:tn};var hi=`varying vec4 geometry_vPosition;
2393
2390
  varying vec3 geometry_vNormal;
2394
2391
  void geometry_setNormal(vec3 normal) {
2395
2392
  geometry_vNormal = normal;
@@ -2400,7 +2397,7 @@ geometry_vPosition = position;
2400
2397
  void geometry_setPosition(vec3 position) {
2401
2398
  geometry_vPosition = vec4(position, 1.);
2402
2399
  }
2403
- `,_i=`varying vec4 geometry_vPosition;
2400
+ `,pi=`varying vec4 geometry_vPosition;
2404
2401
  varying vec3 geometry_vNormal;
2405
2402
  vec4 geometry_getPosition() {
2406
2403
  return geometry_vPosition;
@@ -2408,7 +2405,7 @@ return geometry_vPosition;
2408
2405
  vec3 geometry_getNormal() {
2409
2406
  return geometry_vNormal;
2410
2407
  }
2411
- `,yr={name:"geometry",vs:ui,fs:_i};var Fa=1/Math.PI*180,Ca=1/180*Math.PI,hi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...hi}};var O=globalThis.mathgl.config;function br(n,{precision:e=O.precision}={}){return n=pi(n),`${parseFloat(n.toPrecision(e))}`}function $e(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function rn(n,e,t){let r=O.EPSILON;t&&(O.EPSILON=t);try{if(n===e)return!0;if($e(n)&&$e(e)){if(n.length!==e.length)return!1;for(let o=0;o<n.length;++o)if(!rn(n[o],e[o]))return!1;return!0}return n&&n.equals?n.equals(e):e&&e.equals?e.equals(n):typeof n=="number"&&typeof e=="number"?Math.abs(n-e)<=O.EPSILON*Math.max(1,Math.abs(n),Math.abs(e)):!1}finally{O.EPSILON=r}}function pi(n){return Math.round(n/O.EPSILON)*O.EPSILON}var Ke=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:$e(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+br(this[r],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!rn(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(r===void 0)return this.lerp(this,e,t);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof t=="number"?t:t[o];this[o]=i+r*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=t[r];return this.check()}subtract(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=t[r];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}};function di(n,e){if(n.length!==e)return!1;for(let t=0;t<n.length;++t)if(!Number.isFinite(n[t]))return!1;return!0}function Pr(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function Ze(n,e,t=""){if(O.debug&&!di(n,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return n}var W=typeof Float32Array<"u"?Float32Array:Array;var Ya=Math.PI/180;function mi(){let n=new W(2);return W!=Float32Array&&(n[0]=0,n[1]=0),n}function kr(n,e,t){let r=e[0],o=e[1];return n[0]=t[0]*r+t[4]*o+t[12],n[1]=t[1]*r+t[5]*o+t[13],n}var Xa=function(){let n=mi();return function(e,t,r,o,i,a){let c,u;for(t||(t=2),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],i(n,n,a),e[c]=n[0],e[c+1]=n[1];return e}}();function Sr(n,e,t){let r=e[0],o=e[1],i=t[3]*r+t[7]*o||1;return n[0]=(t[0]*r+t[4]*o)/i,n[1]=(t[1]*r+t[5]*o)/i,n}function Nr(n,e,t){let r=e[0],o=e[1],i=e[2],a=t[3]*r+t[7]*o+t[11]*i||1;return n[0]=(t[0]*r+t[4]*o+t[8]*i)/a,n[1]=(t[1]*r+t[5]*o+t[9]*i)/a,n[2]=(t[2]*r+t[6]*o+t[10]*i)/a,n}function gi(){let n=new W(3);return W!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Tr(n,e,t){let r=e[0],o=e[1],i=e[2],a=t[3]*r+t[7]*o+t[11]*i+t[15];return a=a||1,n[0]=(t[0]*r+t[4]*o+t[8]*i+t[12])/a,n[1]=(t[1]*r+t[5]*o+t[9]*i+t[13])/a,n[2]=(t[2]*r+t[6]*o+t[10]*i+t[14])/a,n}var qa=function(){let n=gi();return function(e,t,r,o,i,a){let c,u;for(t||(t=3),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],n[2]=e[c+2],i(n,n,a),e[c]=n[0],e[c+1]=n[1],e[c+2]=n[2];return e}}();var Je=class extends Ke{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=Pr(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)t[o]=this[r+o];return t}setColumn(e,t){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)this[r+o]=t[o];return this}};function xi(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Er(n,e){if(n===e){let t=e[1],r=e[2],o=e[3],i=e[6],a=e[7],c=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=i,n[11]=e[14],n[12]=o,n[13]=a,n[14]=c}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function Mr(n,e){let t=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=t*c-r*a,b=t*u-o*a,P=t*h-i*a,y=r*u-o*c,k=r*h-i*c,S=o*h-i*u,I=p*g-d*w,M=p*A-m*w,T=p*L-x*w,F=d*A-m*g,z=d*L-x*g,R=m*L-x*A,E=v*R-b*z+P*F+y*T-k*M+S*I;return E?(E=1/E,n[0]=(c*R-u*z+h*F)*E,n[1]=(o*z-r*R-i*F)*E,n[2]=(g*S-A*k+L*y)*E,n[3]=(m*k-d*S-x*y)*E,n[4]=(u*T-a*R-h*M)*E,n[5]=(t*R-o*T+i*M)*E,n[6]=(A*P-w*S-L*b)*E,n[7]=(p*S-m*P+x*b)*E,n[8]=(a*z-c*T+h*I)*E,n[9]=(r*T-t*z-i*I)*E,n[10]=(w*k-g*P+L*v)*E,n[11]=(d*P-p*k-x*v)*E,n[12]=(c*M-a*F-u*I)*E,n[13]=(t*F-r*M+o*I)*E,n[14]=(g*b-w*y-A*v)*E,n[15]=(p*y-d*b+m*v)*E,n):null}function Ir(n){let e=n[0],t=n[1],r=n[2],o=n[3],i=n[4],a=n[5],c=n[6],u=n[7],h=n[8],p=n[9],d=n[10],m=n[11],x=n[12],w=n[13],g=n[14],A=n[15],L=e*a-t*i,v=e*c-r*i,b=t*c-r*a,P=h*w-p*x,y=h*g-d*x,k=p*g-d*w,S=e*k-t*y+r*P,I=i*k-a*y+c*P,M=h*b-p*v+d*L,T=x*b-w*v+g*L;return u*S-o*I+A*M-m*T}function sn(n,e,t){let r=e[0],o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],b=t[0],P=t[1],y=t[2],k=t[3];return n[0]=b*r+P*c+y*d+k*g,n[1]=b*o+P*u+y*m+k*A,n[2]=b*i+P*h+y*x+k*L,n[3]=b*a+P*p+y*w+k*v,b=t[4],P=t[5],y=t[6],k=t[7],n[4]=b*r+P*c+y*d+k*g,n[5]=b*o+P*u+y*m+k*A,n[6]=b*i+P*h+y*x+k*L,n[7]=b*a+P*p+y*w+k*v,b=t[8],P=t[9],y=t[10],k=t[11],n[8]=b*r+P*c+y*d+k*g,n[9]=b*o+P*u+y*m+k*A,n[10]=b*i+P*h+y*x+k*L,n[11]=b*a+P*p+y*w+k*v,b=t[12],P=t[13],y=t[14],k=t[15],n[12]=b*r+P*c+y*d+k*g,n[13]=b*o+P*u+y*m+k*A,n[14]=b*i+P*h+y*x+k*L,n[15]=b*a+P*p+y*w+k*v,n}function Fr(n,e,t){let r=t[0],o=t[1],i=t[2],a,c,u,h,p,d,m,x,w,g,A,L;return e===n?(n[12]=e[0]*r+e[4]*o+e[8]*i+e[12],n[13]=e[1]*r+e[5]*o+e[9]*i+e[13],n[14]=e[2]*r+e[6]*o+e[10]*i+e[14],n[15]=e[3]*r+e[7]*o+e[11]*i+e[15]):(a=e[0],c=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],n[0]=a,n[1]=c,n[2]=u,n[3]=h,n[4]=p,n[5]=d,n[6]=m,n[7]=x,n[8]=w,n[9]=g,n[10]=A,n[11]=L,n[12]=a*r+p*o+w*i+e[12],n[13]=c*r+d*o+g*i+e[13],n[14]=u*r+m*o+A*i+e[14],n[15]=h*r+x*o+L*i+e[15]),n}function Cr(n,e,t){let r=t[0],o=t[1],i=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*o,n[5]=e[5]*o,n[6]=e[6]*o,n[7]=e[7]*o,n[8]=e[8]*i,n[9]=e[9]*i,n[10]=e[10]*i,n[11]=e[11]*i,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Rr(n,e,t,r){let o=r[0],i=r[1],a=r[2],c=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,b,P,y,k,S,I,M,T,F,z,R,E,_e;return c<1e-6?null:(c=1/c,o*=c,i*=c,a*=c,h=Math.sin(t),u=Math.cos(t),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],b=e[8],P=e[9],y=e[10],k=e[11],S=o*o*p+u,I=i*o*p+a*h,M=a*o*p-i*h,T=o*i*p-a*h,F=i*i*p+u,z=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,_e=a*a*p+u,n[0]=d*S+g*I+b*M,n[1]=m*S+A*I+P*M,n[2]=x*S+L*I+y*M,n[3]=w*S+v*I+k*M,n[4]=d*T+g*F+b*z,n[5]=m*T+A*F+P*z,n[6]=x*T+L*F+y*z,n[7]=w*T+v*F+k*z,n[8]=d*R+g*E+b*_e,n[9]=m*R+A*E+P*_e,n[10]=x*R+L*E+y*_e,n[11]=w*R+v*E+k*_e,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Or(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[4],a=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=i*o+h*r,n[5]=a*o+p*r,n[6]=c*o+d*r,n[7]=u*o+m*r,n[8]=h*o-i*r,n[9]=p*o-a*r,n[10]=d*o-c*r,n[11]=m*o-u*r,n}function Ur(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*o-h*r,n[1]=a*o-p*r,n[2]=c*o-d*r,n[3]=u*o-m*r,n[8]=i*r+h*o,n[9]=a*r+p*o,n[10]=c*r+d*o,n[11]=u*r+m*o,n}function zr(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*o+h*r,n[1]=a*o+p*r,n[2]=c*o+d*r,n[3]=u*o+m*r,n[4]=h*o-i*r,n[5]=p*o-a*r,n[6]=d*o-c*r,n[7]=m*o-u*r,n}function Dr(n,e){let t=e[0],r=e[1],o=e[2],i=e[3],a=t+t,c=r+r,u=o+o,h=t*a,p=r*a,d=r*c,m=o*a,x=o*c,w=o*u,g=i*a,A=i*c,L=i*u;return n[0]=1-d-w,n[1]=p+L,n[2]=m-A,n[3]=0,n[4]=p-L,n[5]=1-h-w,n[6]=x+g,n[7]=0,n[8]=m+A,n[9]=x-g,n[10]=1-h-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Yr(n,e,t,r,o,i,a){let c=1/(t-e),u=1/(o-r),h=1/(i-a);return n[0]=i*2*c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*u,n[6]=0,n[7]=0,n[8]=(t+e)*c,n[9]=(o+r)*u,n[10]=(a+i)*h,n[11]=-1,n[12]=0,n[13]=0,n[14]=a*i*2*h,n[15]=0,n}function vi(n,e,t,r,o){let i=1/Math.tan(e/2);if(n[0]=i/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,o!=null&&o!==1/0){let a=1/(r-o);n[10]=(o+r)*a,n[14]=2*o*r*a}else n[10]=-1,n[14]=-2*r;return n}var Xr=vi;function Ai(n,e,t,r,o,i,a){let c=1/(e-t),u=1/(r-o),h=1/(i-a);return n[0]=-2*c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*u,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*h,n[11]=0,n[12]=(e+t)*c,n[13]=(o+r)*u,n[14]=(a+i)*h,n[15]=1,n}var Br=Ai;function Qr(n,e,t,r){let o,i,a,c,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=r[0],v=r[1],b=r[2],P=t[0],y=t[1],k=t[2];return Math.abs(w-P)<1e-6&&Math.abs(g-y)<1e-6&&Math.abs(A-k)<1e-6?xi(n):(d=w-P,m=g-y,x=A-k,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-b*m,a=b*d-L*x,c=L*m-v*d,o=Math.sqrt(i*i+a*a+c*c),o?(o=1/o,i*=o,a*=o,c*=o):(i=0,a=0,c=0),u=m*c-x*a,h=x*i-d*c,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),n[0]=i,n[1]=u,n[2]=d,n[3]=0,n[4]=a,n[5]=h,n[6]=m,n[7]=0,n[8]=c,n[9]=p,n[10]=x,n[11]=0,n[12]=-(i*w+a*g+c*A),n[13]=-(u*w+h*g+p*A),n[14]=-(d*w+m*g+x*A),n[15]=1,n)}function yi(){let n=new W(4);return W!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function qr(n,e,t){let r=e[0],o=e[1],i=e[2],a=e[3];return n[0]=t[0]*r+t[4]*o+t[8]*i+t[12]*a,n[1]=t[1]*r+t[5]*o+t[9]*i+t[13]*a,n[2]=t[2]*r+t[6]*o+t[10]*i+t[14]*a,n[3]=t[3]*r+t[7]*o+t[11]*i+t[15]*a,n}var Ka=function(){let n=yi();return function(e,t,r,o,i,a){let c,u;for(t||(t=4),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],n[2]=e[c+2],n[3]=e[c+3],i(n,n,a),e[c]=n[0],e[c+1]=n[1],e[c+2]=n[2],e[c+3]=n[3];return e}}();var ln;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(ln||(ln={}));var bi=45*Math.PI/180,Pi=1,an=.1,cn=500,wi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Je{static get IDENTITY(){return ki()}static get ZERO(){return Li()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ln}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=t,this[2]=r,this[3]=o,this[4]=i,this[5]=a,this[6]=c,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,t,r,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=t,this[5]=a,this[6]=p,this[7]=w,this[8]=r,this[9]=c,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(wi)}fromObject(e){return this.check()}fromQuaternion(e){return Dr(this,e),this.check()}frustum(e){let{left:t,right:r,bottom:o,top:i,near:a=an,far:c=cn}=e;return c===1/0?Si(this,t,r,o,i,a):Yr(this,t,r,o,i,a,c),this.check()}lookAt(e){let{eye:t,center:r=[0,0,0],up:o=[0,1,0]}=e;return Qr(this,t,r,o),this.check()}ortho(e){let{left:t,right:r,bottom:o,top:i,near:a=an,far:c=cn}=e;return Br(this,t,r,o,i,a,c),this.check()}orthographic(e){let{fovy:t=bi,aspect:r=Pi,focalDistance:o=1,near:i=an,far:a=cn}=e;Vr(t);let c=t/2,u=o*Math.tan(c),h=u*r;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:r=1,near:o=.1,far:i=500}=e;return Vr(t),Xr(this,t,r,o,i),this.check()}determinant(){return Ir(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),o=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),o=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return Er(this,this),this.check()}invert(){return Mr(this,this),this.check()}multiplyLeft(e){return sn(this,e,this),this.check()}multiplyRight(e){return sn(this,this,e),this.check()}rotateX(e){return Or(this,this,e),this.check()}rotateY(e){return Ur(this,this,e),this.check()}rotateZ(e){return zr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Rr(this,this,e,t),this.check()}scale(e){return Cr(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Fr(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qr(t||[-0,-0,-0,-0],e,this),Ze(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:r}=e,o;switch(r){case 2:o=kr(t||[-0,-0],e,this);break;case 3:o=Tr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ze(o,e.length),o}transformAsVector(e,t){let r;switch(e.length){case 2:r=Sr(t||[-0,-0],e,this);break;case 3:r=Nr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ze(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}},et,tt;function Li(){return et||(et=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(et)),et}function ki(){return tt||(tt=new ee,Object.freeze(tt)),tt}function Vr(n){if(n>Math.PI*2)throw Error("expected radians")}function Si(n,e,t,r,o,i){let a=2*i/(t-e),c=2*i/(o-r),u=(t+e)/(t-e),h=(o+r)/(o-r),p=-1,d=-1,m=-2*i;return n[0]=a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=c,n[6]=0,n[7]=0,n[8]=u,n[9]=h,n[10]=p,n[11]=d,n[12]=0,n[13]=0,n[14]=m,n[15]=0,n}var fn=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ni={modelMatrix:fn,viewMatrix:fn,projectionMatrix:fn,cameraPositionWorld:[0,0,0]};function Ti(n=Ni,e={}){let t={};return n.modelMatrix!==void 0&&(t.modelMatrix=n.modelMatrix),n.viewMatrix!==void 0&&(t.viewMatrix=n.viewMatrix),n.projectionMatrix!==void 0&&(t.projectionMatrix=n.projectionMatrix),n.cameraPositionWorld!==void 0&&(t.cameraPositionWorld=n.cameraPositionWorld),(n.projectionMatrix!==void 0||n.viewMatrix!==void 0)&&(t.viewProjectionMatrix=new ee(n.projectionMatrix).multiplyRight(n.viewMatrix)),t}var Hr=`varying vec4 project_vPositionWorld;
2408
+ `,Pr={name:"geometry",vs:hi,fs:pi};var Ua=1/Math.PI*180,za=1/180*Math.PI,di={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...di}};var O=globalThis.mathgl.config;function wr(n,{precision:e=O.precision}={}){return n=mi(n),`${parseFloat(n.toPrecision(e))}`}function $e(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function rn(n,e,t){let r=O.EPSILON;t&&(O.EPSILON=t);try{if(n===e)return!0;if($e(n)&&$e(e)){if(n.length!==e.length)return!1;for(let o=0;o<n.length;++o)if(!rn(n[o],e[o]))return!1;return!0}return n&&n.equals?n.equals(e):e&&e.equals?e.equals(n):typeof n=="number"&&typeof e=="number"?Math.abs(n-e)<=O.EPSILON*Math.max(1,Math.abs(n),Math.abs(e)):!1}finally{O.EPSILON=r}}function mi(n){return Math.round(n/O.EPSILON)*O.EPSILON}var Ke=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:$e(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+wr(this[r],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!rn(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(r===void 0)return this.lerp(this,e,t);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof t=="number"?t:t[o];this[o]=i+r*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=t[r];return this.check()}subtract(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=t[r];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}};function gi(n,e){if(n.length!==e)return!1;for(let t=0;t<n.length;++t)if(!Number.isFinite(n[t]))return!1;return!0}function Lr(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function Ze(n,e,t=""){if(O.debug&&!gi(n,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return n}var H=typeof Float32Array<"u"?Float32Array:Array;var qa=Math.PI/180;function xi(){let n=new H(2);return H!=Float32Array&&(n[0]=0,n[1]=0),n}function Nr(n,e,t){let r=e[0],o=e[1];return n[0]=t[0]*r+t[4]*o+t[12],n[1]=t[1]*r+t[5]*o+t[13],n}var Va=function(){let n=xi();return function(e,t,r,o,i,a){let c,u;for(t||(t=2),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],i(n,n,a),e[c]=n[0],e[c+1]=n[1];return e}}();function Tr(n,e,t){let r=e[0],o=e[1],i=t[3]*r+t[7]*o||1;return n[0]=(t[0]*r+t[4]*o)/i,n[1]=(t[1]*r+t[5]*o)/i,n}function Er(n,e,t){let r=e[0],o=e[1],i=e[2],a=t[3]*r+t[7]*o+t[11]*i||1;return n[0]=(t[0]*r+t[4]*o+t[8]*i)/a,n[1]=(t[1]*r+t[5]*o+t[9]*i)/a,n[2]=(t[2]*r+t[6]*o+t[10]*i)/a,n}function vi(){let n=new H(3);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Mr(n,e,t){let r=e[0],o=e[1],i=e[2],a=t[3]*r+t[7]*o+t[11]*i+t[15];return a=a||1,n[0]=(t[0]*r+t[4]*o+t[8]*i+t[12])/a,n[1]=(t[1]*r+t[5]*o+t[9]*i+t[13])/a,n[2]=(t[2]*r+t[6]*o+t[10]*i+t[14])/a,n}var Ha=function(){let n=vi();return function(e,t,r,o,i,a){let c,u;for(t||(t=3),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],n[2]=e[c+2],i(n,n,a),e[c]=n[0],e[c+1]=n[1],e[c+2]=n[2];return e}}();var Je=class extends Ke{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=Lr(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)t[o]=this[r+o];return t}setColumn(e,t){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)this[r+o]=t[o];return this}};function Ai(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ir(n,e){if(n===e){let t=e[1],r=e[2],o=e[3],i=e[6],a=e[7],c=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=i,n[11]=e[14],n[12]=o,n[13]=a,n[14]=c}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function Fr(n,e){let t=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=t*c-r*a,y=t*u-o*a,P=t*h-i*a,b=r*u-o*c,k=r*h-i*c,S=o*h-i*u,I=p*g-d*w,M=p*A-m*w,T=p*L-x*w,F=d*A-m*g,z=d*L-x*g,R=m*L-x*A,E=v*R-y*z+P*F+b*T-k*M+S*I;return E?(E=1/E,n[0]=(c*R-u*z+h*F)*E,n[1]=(o*z-r*R-i*F)*E,n[2]=(g*S-A*k+L*b)*E,n[3]=(m*k-d*S-x*b)*E,n[4]=(u*T-a*R-h*M)*E,n[5]=(t*R-o*T+i*M)*E,n[6]=(A*P-w*S-L*y)*E,n[7]=(p*S-m*P+x*y)*E,n[8]=(a*z-c*T+h*I)*E,n[9]=(r*T-t*z-i*I)*E,n[10]=(w*k-g*P+L*v)*E,n[11]=(d*P-p*k-x*v)*E,n[12]=(c*M-a*F-u*I)*E,n[13]=(t*F-r*M+o*I)*E,n[14]=(g*y-w*b-A*v)*E,n[15]=(p*b-d*y+m*v)*E,n):null}function Cr(n){let e=n[0],t=n[1],r=n[2],o=n[3],i=n[4],a=n[5],c=n[6],u=n[7],h=n[8],p=n[9],d=n[10],m=n[11],x=n[12],w=n[13],g=n[14],A=n[15],L=e*a-t*i,v=e*c-r*i,y=t*c-r*a,P=h*w-p*x,b=h*g-d*x,k=p*g-d*w,S=e*k-t*b+r*P,I=i*k-a*b+c*P,M=h*y-p*v+d*L,T=x*y-w*v+g*L;return u*S-o*I+A*M-m*T}function sn(n,e,t){let r=e[0],o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=t[0],P=t[1],b=t[2],k=t[3];return n[0]=y*r+P*c+b*d+k*g,n[1]=y*o+P*u+b*m+k*A,n[2]=y*i+P*h+b*x+k*L,n[3]=y*a+P*p+b*w+k*v,y=t[4],P=t[5],b=t[6],k=t[7],n[4]=y*r+P*c+b*d+k*g,n[5]=y*o+P*u+b*m+k*A,n[6]=y*i+P*h+b*x+k*L,n[7]=y*a+P*p+b*w+k*v,y=t[8],P=t[9],b=t[10],k=t[11],n[8]=y*r+P*c+b*d+k*g,n[9]=y*o+P*u+b*m+k*A,n[10]=y*i+P*h+b*x+k*L,n[11]=y*a+P*p+b*w+k*v,y=t[12],P=t[13],b=t[14],k=t[15],n[12]=y*r+P*c+b*d+k*g,n[13]=y*o+P*u+b*m+k*A,n[14]=y*i+P*h+b*x+k*L,n[15]=y*a+P*p+b*w+k*v,n}function Rr(n,e,t){let r=t[0],o=t[1],i=t[2],a,c,u,h,p,d,m,x,w,g,A,L;return e===n?(n[12]=e[0]*r+e[4]*o+e[8]*i+e[12],n[13]=e[1]*r+e[5]*o+e[9]*i+e[13],n[14]=e[2]*r+e[6]*o+e[10]*i+e[14],n[15]=e[3]*r+e[7]*o+e[11]*i+e[15]):(a=e[0],c=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],n[0]=a,n[1]=c,n[2]=u,n[3]=h,n[4]=p,n[5]=d,n[6]=m,n[7]=x,n[8]=w,n[9]=g,n[10]=A,n[11]=L,n[12]=a*r+p*o+w*i+e[12],n[13]=c*r+d*o+g*i+e[13],n[14]=u*r+m*o+A*i+e[14],n[15]=h*r+x*o+L*i+e[15]),n}function Or(n,e,t){let r=t[0],o=t[1],i=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*o,n[5]=e[5]*o,n[6]=e[6]*o,n[7]=e[7]*o,n[8]=e[8]*i,n[9]=e[9]*i,n[10]=e[10]*i,n[11]=e[11]*i,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Ur(n,e,t,r){let o=r[0],i=r[1],a=r[2],c=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,k,S,I,M,T,F,z,R,E,_e;return c<1e-6?null:(c=1/c,o*=c,i*=c,a*=c,h=Math.sin(t),u=Math.cos(t),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],k=e[11],S=o*o*p+u,I=i*o*p+a*h,M=a*o*p-i*h,T=o*i*p-a*h,F=i*i*p+u,z=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,_e=a*a*p+u,n[0]=d*S+g*I+y*M,n[1]=m*S+A*I+P*M,n[2]=x*S+L*I+b*M,n[3]=w*S+v*I+k*M,n[4]=d*T+g*F+y*z,n[5]=m*T+A*F+P*z,n[6]=x*T+L*F+b*z,n[7]=w*T+v*F+k*z,n[8]=d*R+g*E+y*_e,n[9]=m*R+A*E+P*_e,n[10]=x*R+L*E+b*_e,n[11]=w*R+v*E+k*_e,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function zr(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[4],a=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=i*o+h*r,n[5]=a*o+p*r,n[6]=c*o+d*r,n[7]=u*o+m*r,n[8]=h*o-i*r,n[9]=p*o-a*r,n[10]=d*o-c*r,n[11]=m*o-u*r,n}function Yr(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*o-h*r,n[1]=a*o-p*r,n[2]=c*o-d*r,n[3]=u*o-m*r,n[8]=i*r+h*o,n[9]=a*r+p*o,n[10]=c*r+d*o,n[11]=u*r+m*o,n}function Dr(n,e,t){let r=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*o+h*r,n[1]=a*o+p*r,n[2]=c*o+d*r,n[3]=u*o+m*r,n[4]=h*o-i*r,n[5]=p*o-a*r,n[6]=d*o-c*r,n[7]=m*o-u*r,n}function Xr(n,e){let t=e[0],r=e[1],o=e[2],i=e[3],a=t+t,c=r+r,u=o+o,h=t*a,p=r*a,d=r*c,m=o*a,x=o*c,w=o*u,g=i*a,A=i*c,L=i*u;return n[0]=1-d-w,n[1]=p+L,n[2]=m-A,n[3]=0,n[4]=p-L,n[5]=1-h-w,n[6]=x+g,n[7]=0,n[8]=m+A,n[9]=x-g,n[10]=1-h-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Br(n,e,t,r,o,i,a){let c=1/(t-e),u=1/(o-r),h=1/(i-a);return n[0]=i*2*c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*u,n[6]=0,n[7]=0,n[8]=(t+e)*c,n[9]=(o+r)*u,n[10]=(a+i)*h,n[11]=-1,n[12]=0,n[13]=0,n[14]=a*i*2*h,n[15]=0,n}function bi(n,e,t,r,o){let i=1/Math.tan(e/2);if(n[0]=i/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,o!=null&&o!==1/0){let a=1/(r-o);n[10]=(o+r)*a,n[14]=2*o*r*a}else n[10]=-1,n[14]=-2*r;return n}var Qr=bi;function yi(n,e,t,r,o,i,a){let c=1/(e-t),u=1/(r-o),h=1/(i-a);return n[0]=-2*c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*u,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*h,n[11]=0,n[12]=(e+t)*c,n[13]=(o+r)*u,n[14]=(a+i)*h,n[15]=1,n}var qr=yi;function Vr(n,e,t,r){let o,i,a,c,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=r[0],v=r[1],y=r[2],P=t[0],b=t[1],k=t[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-k)<1e-6?Ai(n):(d=w-P,m=g-b,x=A-k,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,c=L*m-v*d,o=Math.sqrt(i*i+a*a+c*c),o?(o=1/o,i*=o,a*=o,c*=o):(i=0,a=0,c=0),u=m*c-x*a,h=x*i-d*c,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),n[0]=i,n[1]=u,n[2]=d,n[3]=0,n[4]=a,n[5]=h,n[6]=m,n[7]=0,n[8]=c,n[9]=p,n[10]=x,n[11]=0,n[12]=-(i*w+a*g+c*A),n[13]=-(u*w+h*g+p*A),n[14]=-(d*w+m*g+x*A),n[15]=1,n)}function Pi(){let n=new H(4);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Wr(n,e,t){let r=e[0],o=e[1],i=e[2],a=e[3];return n[0]=t[0]*r+t[4]*o+t[8]*i+t[12]*a,n[1]=t[1]*r+t[5]*o+t[9]*i+t[13]*a,n[2]=t[2]*r+t[6]*o+t[10]*i+t[14]*a,n[3]=t[3]*r+t[7]*o+t[11]*i+t[15]*a,n}var tc=function(){let n=Pi();return function(e,t,r,o,i,a){let c,u;for(t||(t=4),r||(r=0),o?u=Math.min(o*t+r,e.length):u=e.length,c=r;c<u;c+=t)n[0]=e[c],n[1]=e[c+1],n[2]=e[c+2],n[3]=e[c+3],i(n,n,a),e[c]=n[0],e[c+1]=n[1],e[c+2]=n[2],e[c+3]=n[3];return e}}();var ln;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(ln||(ln={}));var wi=45*Math.PI/180,Li=1,an=.1,cn=500,ki=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Je{static get IDENTITY(){return Ni()}static get ZERO(){return Si()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ln}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=t,this[2]=r,this[3]=o,this[4]=i,this[5]=a,this[6]=c,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,t,r,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=t,this[5]=a,this[6]=p,this[7]=w,this[8]=r,this[9]=c,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(ki)}fromObject(e){return this.check()}fromQuaternion(e){return Xr(this,e),this.check()}frustum(e){let{left:t,right:r,bottom:o,top:i,near:a=an,far:c=cn}=e;return c===1/0?Ti(this,t,r,o,i,a):Br(this,t,r,o,i,a,c),this.check()}lookAt(e){let{eye:t,center:r=[0,0,0],up:o=[0,1,0]}=e;return Vr(this,t,r,o),this.check()}ortho(e){let{left:t,right:r,bottom:o,top:i,near:a=an,far:c=cn}=e;return qr(this,t,r,o,i,a,c),this.check()}orthographic(e){let{fovy:t=wi,aspect:r=Li,focalDistance:o=1,near:i=an,far:a=cn}=e;Gr(t);let c=t/2,u=o*Math.tan(c),h=u*r;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:r=1,near:o=.1,far:i=500}=e;return Gr(t),Qr(this,t,r,o,i),this.check()}determinant(){return Cr(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),o=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),o=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return Ir(this,this),this.check()}invert(){return Fr(this,this),this.check()}multiplyLeft(e){return sn(this,e,this),this.check()}multiplyRight(e){return sn(this,this,e),this.check()}rotateX(e){return zr(this,this,e),this.check()}rotateY(e){return Yr(this,this,e),this.check()}rotateZ(e){return Dr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Ur(this,this,e,t),this.check()}scale(e){return Or(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Rr(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Wr(t||[-0,-0,-0,-0],e,this),Ze(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:r}=e,o;switch(r){case 2:o=Nr(t||[-0,-0],e,this);break;case 3:o=Mr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ze(o,e.length),o}transformAsVector(e,t){let r;switch(e.length){case 2:r=Tr(t||[-0,-0],e,this);break;case 3:r=Er(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ze(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}},et,tt;function Si(){return et||(et=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(et)),et}function Ni(){return tt||(tt=new ee,Object.freeze(tt)),tt}function Gr(n){if(n>Math.PI*2)throw Error("expected radians")}function Ti(n,e,t,r,o,i){let a=2*i/(t-e),c=2*i/(o-r),u=(t+e)/(t-e),h=(o+r)/(o-r),p=-1,d=-1,m=-2*i;return n[0]=a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=c,n[6]=0,n[7]=0,n[8]=u,n[9]=h,n[10]=p,n[11]=d,n[12]=0,n[13]=0,n[14]=m,n[15]=0,n}var fn=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ei={modelMatrix:fn,viewMatrix:fn,projectionMatrix:fn,cameraPositionWorld:[0,0,0]};function Mi(n=Ei,e={}){let t={};return n.modelMatrix!==void 0&&(t.modelMatrix=n.modelMatrix),n.viewMatrix!==void 0&&(t.viewMatrix=n.viewMatrix),n.projectionMatrix!==void 0&&(t.projectionMatrix=n.projectionMatrix),n.cameraPositionWorld!==void 0&&(t.cameraPositionWorld=n.cameraPositionWorld),(n.projectionMatrix!==void 0||n.viewMatrix!==void 0)&&(t.viewProjectionMatrix=new ee(n.projectionMatrix).multiplyRight(n.viewMatrix)),t}var Hr=`varying vec4 project_vPositionWorld;
2412
2409
  varying vec3 project_vNormalWorld;
2413
2410
  vec4 project_getPosition_World() {
2414
2411
  return project_vPositionWorld;
@@ -2416,7 +2413,7 @@ return project_vPositionWorld;
2416
2413
  vec3 project_getNormal_World() {
2417
2414
  return project_vNormalWorld;
2418
2415
  }
2419
- `,Ei=`${Hr}
2416
+ `,Ii=`${Hr}
2420
2417
 
2421
2418
  // Unprefixed uniforms
2422
2419
  uniform mat4 modelMatrix;
@@ -2469,8 +2466,8 @@ vec4 project_view_to_clipspace(vec3 position) {
2469
2466
  vec4 project_to_clipspace(vec3 position) {
2470
2467
  return viewProjectionMatrix * vec4(position, 1.);
2471
2468
  }
2472
- `,Mi=`
2473
- ${Hr}`,nt={name:"project",getUniforms:Ti,vs:Ei,fs:Mi};var un=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
2469
+ `,Fi=`
2470
+ ${Hr}`,nt={name:"project",getUniforms:Mi,vs:Ii,fs:Fi};var un=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
2474
2471
  struct AmbientLight {
2475
2472
  vec3 color;
2476
2473
  };
@@ -2495,13 +2492,13 @@ return pointLight.attenuation.x
2495
2492
  + pointLight.attenuation.z * distance * distance;
2496
2493
  }
2497
2494
  #endif
2498
- `;var Ii={lightSources:{}};function _n(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/255)}function Fi({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};return n?r["lighting_uAmbientLight.color"]=_n(n):r["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{r[`lighting_uPointLight[${i}].color`]=_n(o),r[`lighting_uPointLight[${i}].position`]=o.position,r[`lighting_uPointLight[${i}].attenuation`]=o.attenuation||[1,0,0]}),r.lighting_uPointLightCount=e.length,t.forEach((o,i)=>{r[`lighting_uDirectionalLight[${i}].color`]=_n(o),r[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),r.lighting_uDirectionalLightCount=t.length,r}function Gr(n=Ii){if("lightSources"in n){let{ambientLight:e,pointLights:t,directionalLights:r}=n.lightSources||{};return e||t&&t.length>0||r&&r.length>0?Object.assign({},Fi({ambientLight:e,pointLights:t,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in n){let e={pointLights:[],directionalLights:[]};for(let t of n.lights||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return Gr({lightSources:e})}return{}}var te={name:"lights",vs:un,fs:un,getUniforms:Gr,defines:{MAX_LIGHTS:3}};var Ci={lightDirection:new Float32Array([1,1,2])};function Ri(n=Ci){let e={};return n.lightDirection&&(e.dirlight_uLightDirection=n.lightDirection),e}var Oi=`uniform vec3 dirlight_uLightDirection;
2495
+ `;var Ci={lightSources:{}};function _n(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/255)}function Ri({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};return n?r["lighting_uAmbientLight.color"]=_n(n):r["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{r[`lighting_uPointLight[${i}].color`]=_n(o),r[`lighting_uPointLight[${i}].position`]=o.position,r[`lighting_uPointLight[${i}].attenuation`]=o.attenuation||[1,0,0]}),r.lighting_uPointLightCount=e.length,t.forEach((o,i)=>{r[`lighting_uDirectionalLight[${i}].color`]=_n(o),r[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),r.lighting_uDirectionalLightCount=t.length,r}function jr(n=Ci){if("lightSources"in n){let{ambientLight:e,pointLights:t,directionalLights:r}=n.lightSources||{};return e||t&&t.length>0||r&&r.length>0?Object.assign({},Ri({ambientLight:e,pointLights:t,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in n){let e={pointLights:[],directionalLights:[]};for(let t of n.lights||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return jr({lightSources:e})}return{}}var te={name:"lights",vs:un,fs:un,getUniforms:jr,defines:{MAX_LIGHTS:3}};var Oi={lightDirection:new Float32Array([1,1,2])};function Ui(n=Oi){let e={};return n.lightDirection&&(e.dirlight_uLightDirection=n.lightDirection),e}var zi=`uniform vec3 dirlight_uLightDirection;
2499
2496
  vec4 dirlight_filterColor(vec4 color) {
2500
2497
  vec3 normal = project_getNormal_World();
2501
2498
  float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
2502
2499
  return vec4(color.rgb * d, color.a);
2503
2500
  }
2504
- `,Wr={name:"dirlight",fs:Oi,getUniforms:Ri,dependencies:[nt]};var hn=`uniform float lighting_uAmbient;
2501
+ `,$r={name:"dirlight",fs:zi,getUniforms:Ui,dependencies:[nt]};var hn=`uniform float lighting_uAmbient;
2505
2502
  uniform float lighting_uDiffuse;
2506
2503
  uniform float lighting_uShininess;
2507
2504
  uniform vec3 lighting_uSpecularColor;
@@ -2564,7 +2561,7 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
2564
2561
  }
2565
2562
  return lightColor;
2566
2563
  }
2567
- `;var Ui={};function zi(n){let{ambient:e=.35,diffuse:t=.6,shininess:r=32,specularColor:o=[30,30,30]}=n;return{lighting_uAmbient:e,lighting_uDiffuse:t,lighting_uShininess:r,lighting_uSpecularColor:o.map(i=>i/255)}}function jr(n=Ui){if(!("material"in n))return{};let{material:e}=n;return e?zi(e):{lighting_uEnabled:!1}}var $r={name:"gouraud-lighting",dependencies:[te],vs:hn,defines:{LIGHTING_VERTEX:1},getUniforms:jr},Kr={name:"phong-lighting",dependencies:[te],fs:hn,defines:{LIGHTING_FRAGMENT:1},getUniforms:jr};var Zr=`uniform mat4 u_MVPMatrix;
2564
+ `;var Yi={};function Di(n){let{ambient:e=.35,diffuse:t=.6,shininess:r=32,specularColor:o=[30,30,30]}=n;return{lighting_uAmbient:e,lighting_uDiffuse:t,lighting_uShininess:r,lighting_uSpecularColor:o.map(i=>i/255)}}function Kr(n=Yi){if(!("material"in n))return{};let{material:e}=n;return e?Di(e):{lighting_uEnabled:!1}}var Zr={name:"gouraud-lighting",dependencies:[te],vs:hn,defines:{LIGHTING_VERTEX:1},getUniforms:Kr},Jr={name:"phong-lighting",dependencies:[te],fs:hn,defines:{LIGHTING_FRAGMENT:1},getUniforms:Kr};var eo=`uniform mat4 u_MVPMatrix;
2568
2565
  uniform mat4 u_ModelMatrix;
2569
2566
  uniform mat4 u_NormalMatrix;
2570
2567
  out vec3 pbr_vPosition;
@@ -2596,7 +2593,7 @@ pbr_vUV = uv;
2596
2593
  pbr_vUV = vec2(0.,0.);
2597
2594
  #endif
2598
2595
  }
2599
- `;var Jr=`precision highp float;
2596
+ `;var to=`precision highp float;
2600
2597
  uniform bool pbr_uUnlit;
2601
2598
  #ifdef USE_IBL
2602
2599
  uniform samplerCube u_DiffuseEnvSampler;
@@ -2865,7 +2862,7 @@ color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
2865
2862
  }
2866
2863
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
2867
2864
  }
2868
- `;var eo={name:"pbr",vs:Zr,fs:Jr,defines:{LIGHTING_FRAGMENT:1},dependencies:[te]};return lo(Pe);})();
2865
+ `;var no={name:"pbr",vs:eo,fs:to,defines:{LIGHTING_FRAGMENT:1},dependencies:[te]};return uo(Pe);})();
2869
2866
  /**
2870
2867
  * ORIGINAL LICENCE
2871
2868
  * @license