@luma.gl/shadertools 9.1.0-alpha.10 → 9.1.0-alpha.13

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 (51) hide show
  1. package/dist/dist.dev.js +195 -10
  2. package/dist/dist.min.js +241 -80
  3. package/dist/index.cjs +196 -10
  4. package/dist/index.cjs.map +3 -3
  5. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  6. package/dist/lib/shader-assembly/assemble-shaders.js +9 -8
  7. package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -1
  8. package/dist/lib/shader-module/shader-module-dependencies.js +1 -1
  9. package/dist/lib/shader-module/shader-module.d.ts +2 -2
  10. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  11. package/dist/modules/engine/picking/picking.d.ts +5 -5
  12. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  13. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  14. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  15. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  16. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  17. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +1 -1
  18. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts +2 -0
  19. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +1 -0
  20. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js +56 -0
  21. package/dist/modules/lighting/lights/lighting.d.ts +1 -0
  22. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  23. package/dist/modules/lighting/lights/lighting.js +5 -3
  24. package/dist/modules/lighting/no-material/dirlight.d.ts +4 -4
  25. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  26. package/dist/modules/lighting/no-material/dirlight.js +22 -11
  27. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +1 -0
  28. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  29. package/dist/modules/lighting/phong-material/phong-material.d.ts +2 -0
  30. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  31. package/dist/modules/lighting/phong-material/phong-material.js +2 -0
  32. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +41 -0
  33. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -0
  34. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +130 -0
  35. package/dist/modules/math/fp64/fp64-utils.d.ts +3 -3
  36. package/dist/modules/math/fp64/fp64-utils.d.ts.map +1 -1
  37. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +2 -2
  38. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
  39. package/package.json +5 -5
  40. package/src/lib/shader-assembly/assemble-shaders.ts +9 -8
  41. package/src/lib/shader-module/shader-module-dependencies.ts +1 -2
  42. package/src/lib/shader-module/shader-module.ts +10 -6
  43. package/src/modules/engine/picking/picking.ts +5 -5
  44. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -1
  45. package/src/modules/lighting/lights/lighting-uniforms-wgsl.ts +57 -0
  46. package/src/modules/lighting/lights/lighting.ts +5 -3
  47. package/src/modules/lighting/no-material/dirlight.ts +24 -14
  48. package/src/modules/lighting/phong-material/phong-material.ts +2 -0
  49. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +132 -0
  50. package/src/modules/math/fp64/fp64-utils.ts +3 -3
  51. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +2 -2
package/dist/dist.min.js CHANGED
@@ -4,7 +4,7 @@
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 lo=Object.create;var de=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var uo=Object.getOwnPropertyNames;var ho=Object.getPrototypeOf,_o=Object.prototype.hasOwnProperty;var po=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var mo=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),go=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},Fe=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of uo(e))!_o.call(t,o)&&o!==n&&de(t,o,{get:()=>e[o],enumerable:!(r=fo(e,o))||r.enumerable});return t},Ie=(t,e,n)=>(Fe(t,e,"default"),n&&Fe(n,e,"default")),dn=(t,e,n)=>(n=t!=null?lo(ho(t)):{},Fe(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),xo=t=>Fe(de({},"__esModule",{value:!0}),t);var mn=(t,e,n)=>(po(t,typeof e!="symbol"?e+"":e,n),n);var ct=mo((es,gn)=>{gn.exports=globalThis.luma});var Ee={};go(Ee,{ShaderAssembler:()=>be,_getDependencyGraph:()=>Ae,_resolveModules:()=>Tn,_warp:()=>_e,assembleGLSLShaderPair:()=>Re,brightnessContrast:()=>Fr,bulgePinch:()=>Vr,capitalize:()=>Z,checkShaderModuleDeprecations:()=>xe,colorHalftone:()=>Xr,combineInjects:()=>Sn,convertToVec4:()=>pt,denoise:()=>Ir,dirlight:()=>an,dirlight1:()=>no,dotScreen:()=>Yr,edgeWork:()=>Qr,fp32:()=>yr,fp64:()=>Zr,fp64LowPart:()=>ke,fp64arithmetic:()=>fn,fp64ify:()=>he,fp64ifyMatrix4:()=>Te,fromHalfFloat:()=>Ar,fxaa:()=>jr,generateShaderForModule:()=>Qn,geometry1:()=>Jr,getPassthroughFS:()=>zn,getQualifierDetails:()=>Un,getShaderInfo:()=>Ce,getShaderLayoutFromWGSL:()=>Hn,getShaderModuleDependencies:()=>ve,getShaderModuleSource:()=>Oe,getShaderModuleUniforms:()=>kn,gouraudLighting:()=>oo,gouraudMaterial:()=>cn,hexagonalPixelate:()=>qr,hueSaturation:()=>Mr,initializeShaderModule:()=>Me,initializeShaderModules:()=>Y,ink:()=>Gr,lighting:()=>X,lights1:()=>ne,magnify:()=>Hr,noise:()=>Cr,pbr:()=>co,pbrMaterial:()=>Er,phongLighting:()=>io,phongMaterial:()=>ln,picking:()=>wr,preprocess:()=>Ue,project1:()=>at,random:()=>Q,sepia:()=>Rr,swirl:()=>Wr,tiltShift:()=>zr,toHalfFloat:()=>vr,triangleBlur:()=>Dr,typeToChannelCount:()=>Bn,typeToChannelSuffix:()=>Dn,vibrance:()=>Or,vignette:()=>Ur,zoomBlur:()=>Br});Ie(Ee,dn(ct(),1));function W(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var lt={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function vn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=vo(r);return e}function An(t,e,n){let r={};for(let[o,i]of Object.entries(e))t&&o in t&&!i.private?(i.validate&&W(i.validate(t[o],i),`${n}: invalid ${o}`),r[o]=t[o]):r[o]=i.value;return r}function vo(t){let e=xn(t);if(e!=="object")return{value:t,...lt[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...lt[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=xn(t.value),{...t,...lt[e],type:e}):{type:"object",value:null};throw new Error("props")}function xn(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var bn=`#ifdef MODULE_LOGDEPTH
7
+ "use strict";var __exports__=(()=>{var ui=Object.create;var de=Object.defineProperty;var hi=Object.getOwnPropertyDescriptor;var _i=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,di=Object.prototype.hasOwnProperty;var mi=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var gi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xi=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},Ie=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _i(e))!di.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(r=hi(e,i))||r.enumerable});return t},Fe=(t,e,n)=>(Ie(t,e,"default"),n&&Ie(n,e,"default")),dn=(t,e,n)=>(n=t!=null?ui(pi(t)):{},Ie(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),vi=t=>Ie(de({},"__esModule",{value:!0}),t);var mn=(t,e,n)=>(mi(t,typeof e!="symbol"?e+"":e,n),n);var ct=gi((rs,gn)=>{gn.exports=globalThis.luma});var Ne={};xi(Ne,{ShaderAssembler:()=>be,_getDependencyGraph:()=>Ae,_resolveModules:()=>Tn,_warp:()=>_e,assembleGLSLShaderPair:()=>Re,brightnessContrast:()=>Mr,bulgePinch:()=>jr,capitalize:()=>Z,checkShaderModuleDeprecations:()=>xe,colorHalftone:()=>Qr,combineInjects:()=>Sn,convertToVec4:()=>pt,denoise:()=>Cr,dirlight:()=>an,dirlight1:()=>ii,dotScreen:()=>Gr,edgeWork:()=>qr,fp32:()=>yr,fp64:()=>ei,fp64LowPart:()=>ke,fp64arithmetic:()=>fn,fp64ify:()=>he,fp64ifyMatrix4:()=>Te,fromHalfFloat:()=>Ar,fxaa:()=>Kr,generateShaderForModule:()=>Qn,geometry1:()=>ti,getPassthroughFS:()=>zn,getQualifierDetails:()=>Un,getShaderInfo:()=>Ce,getShaderLayoutFromWGSL:()=>Hn,getShaderModuleDependencies:()=>ve,getShaderModuleSource:()=>Oe,getShaderModuleUniforms:()=>kn,gouraudLighting:()=>si,gouraudMaterial:()=>cn,hexagonalPixelate:()=>Hr,hueSaturation:()=>Rr,initializeShaderModule:()=>Me,initializeShaderModules:()=>Y,ink:()=>Vr,lighting:()=>X,lights1:()=>ne,magnify:()=>Wr,noise:()=>Or,pbr:()=>fi,pbrMaterial:()=>Fr,phongLighting:()=>ai,phongMaterial:()=>ln,picking:()=>wr,preprocess:()=>Ue,project1:()=>at,random:()=>Q,sepia:()=>Ur,swirl:()=>$r,tiltShift:()=>Br,toHalfFloat:()=>vr,triangleBlur:()=>Xr,typeToChannelCount:()=>Bn,typeToChannelSuffix:()=>Dn,vibrance:()=>zr,vignette:()=>Dr,zoomBlur:()=>Yr});Fe(Ne,dn(ct(),1));function W(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var lt={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function vn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=Ai(r);return e}function An(t,e,n){let r={};for(let[i,o]of Object.entries(e))t&&i in t&&!o.private?(o.validate&&W(o.validate(t[i],o),`${n}: invalid ${i}`),r[i]=t[i]):r[i]=o.value;return r}function Ai(t){let e=xn(t);if(e!=="object")return{value:t,...lt[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...lt[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=xn(t.value),{...t,...lt[e],type:e}):{type:"object",value:null};throw new Error("props")}function xn(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var bn=`#ifdef MODULE_LOGDEPTH
8
8
  logdepth_adjustPosition(gl_Position);
9
9
  #endif
10
10
  `,yn=`#ifdef MODULE_MATERIAL
@@ -27,10 +27,10 @@
27
27
  #ifdef MODULE_LOGDEPTH
28
28
  logdepth_setFragDepth();
29
29
  #endif
30
- `;var Ao={vertex:bn,fragment:yn},wn=/void\s+main\s*\([^)]*\)\s*\{\n?/,Pn=/}\n?[^{}]*$/,ft=[],me="__LUMA_INJECT_DECLARATIONS__";function Ln(t){let e={vertex:{},fragment:{}};for(let n in t){let r=t[n],o=bo(n);typeof r=="string"&&(r={order:0,injection:r}),e[o][n]=r}return e}function bo(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function ge(t,e,n,r=!1){let o=e==="vertex";for(let i in n){let a=n[i];a.sort((u,_)=>u.order-_.order),ft.length=a.length;for(let u=0,_=a.length;u<_;++u)ft[u]=a[u].injection;let c=`${ft.join(`
30
+ `;var bi={vertex:bn,fragment:yn},wn=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ln=/}\n?[^{}]*$/,ft=[],me="__LUMA_INJECT_DECLARATIONS__";function Pn(t){let e={vertex:{},fragment:{}};for(let n in t){let r=t[n],i=yi(n);typeof r=="string"&&(r={order:0,injection:r}),e[i][n]=r}return e}function yi(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function ge(t,e,n,r=!1){let i=e==="vertex";for(let o in n){let a=n[o];a.sort((u,_)=>u.order-_.order),ft.length=a.length;for(let u=0,_=a.length;u<_;++u)ft[u]=a[u].injection;let c=`${ft.join(`
31
31
  `)}
32
- `;switch(i){case"vs:#decl":o&&(t=t.replace(me,c));break;case"vs:#main-start":o&&(t=t.replace(wn,u=>u+c));break;case"vs:#main-end":o&&(t=t.replace(Pn,u=>c+u));break;case"fs:#decl":o||(t=t.replace(me,c));break;case"fs:#main-start":o||(t=t.replace(wn,u=>u+c));break;case"fs:#main-end":o||(t=t.replace(Pn,u=>c+u));break;default:t=t.replace(i,u=>u+c)}}return t=t.replace(me,""),r&&(t=t.replace(/\}\s*$/,i=>i+Ao[e])),t}function Sn(t){let e={};return W(Array.isArray(t)&&t.length>1),t.forEach(n=>{for(let r in n)e[r]=e[r]?`${e[r]}
33
- ${n[r]}`:n[r]}),e}function Y(t){t.map(e=>Me(e))}function Me(t){if(t.instance)return;Y(t.dependencies||[]);let{uniformPropTypes:e={},deprecations:n=[],inject:r={}}=t,o={normalizedInjections:Ln(r),parsedDeprecations:yo(n)};e&&(o.propValidators=vn(e)),t.instance=o}function kn(t,e,n){Me(t);let r=n||{...t.defaultUniforms};return t.getUniforms?t.getUniforms(e,r):An(e,t.instance?.propValidators,t.name)}function xe(t,e,n){t.deprecations?.forEach(r=>{r.regex?.test(e)&&(r.deprecated?n.deprecated(r.old,r.new)():n.removed(r.old,r.new)())})}function yo(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function ve(t){Y(t);let e={},n={};Ae({modules:t,level:0,moduleMap:e,moduleDepth:n});let r=Object.keys(n).sort((o,i)=>n[i]-n[o]).map(o=>e[o]);return Y(r),r}function Ae(t){let{modules:e,level:n,moduleMap:r,moduleDepth:o}=t;if(n>=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]<n)&&(o[i.name]=n);for(let i of e)i.dependencies&&Ae({modules:i.dependencies,level:n+1,moduleMap:r,moduleDepth:o})}function wo(t){Y(t);let e={},n={};return Ae({modules:t,level:0,moduleMap:e,moduleDepth:n}),t=Object.keys(n).sort((r,o)=>n[o]-n[r]).map(r=>e[r]),Y(t),t}function Tn(t){return wo(t)}function Nn(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
32
+ `;switch(o){case"vs:#decl":i&&(t=t.replace(me,c));break;case"vs:#main-start":i&&(t=t.replace(wn,u=>u+c));break;case"vs:#main-end":i&&(t=t.replace(Ln,u=>c+u));break;case"fs:#decl":i||(t=t.replace(me,c));break;case"fs:#main-start":i||(t=t.replace(wn,u=>u+c));break;case"fs:#main-end":i||(t=t.replace(Ln,u=>c+u));break;default:t=t.replace(o,u=>u+c)}}return t=t.replace(me,""),r&&(t=t.replace(/\}\s*$/,o=>o+bi[e])),t}function Sn(t){let e={};return W(Array.isArray(t)&&t.length>1),t.forEach(n=>{for(let r in n)e[r]=e[r]?`${e[r]}
33
+ ${n[r]}`:n[r]}),e}function Y(t){t.map(e=>Me(e))}function Me(t){if(t.instance)return;Y(t.dependencies||[]);let{uniformPropTypes:e={},deprecations:n=[],inject:r={}}=t,i={normalizedInjections:Pn(r),parsedDeprecations:wi(n)};e&&(i.propValidators=vn(e)),t.instance=i}function kn(t,e,n){Me(t);let r=n||{...t.defaultUniforms};return t.getUniforms?t.getUniforms(e,r):An(e,t.instance?.propValidators,t.name)}function xe(t,e,n){t.deprecations?.forEach(r=>{r.regex?.test(e)&&(r.deprecated?n.deprecated(r.old,r.new)():n.removed(r.old,r.new)())})}function wi(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function ve(t){Y(t);let e={},n={};Ae({modules:t,level:0,moduleMap:e,moduleDepth:n});let r=Object.keys(n).sort((i,o)=>n[o]-n[i]).map(i=>e[i]);return Y(r),r}function Ae(t){let{modules:e,level:n,moduleMap:r,moduleDepth:i}=t;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(let o of e)r[o.name]=o,(i[o.name]===void 0||i[o.name]<n)&&(i[o.name]=n);for(let o of e)o.dependencies&&Ae({modules:o.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}function Li(t){Y(t);let e={},n={};return Ae({modules:t,level:0,moduleMap:e,moduleDepth:n}),t=Object.keys(n).sort((r,i)=>n[i]-n[r]).map(r=>e[r]),Y(t),t}function Tn(t){return Li(t)}function En(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
34
34
  // Apple optimizes away the calculation necessary for emulated fp64
35
35
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
36
36
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
@@ -54,58 +54,57 @@ ${n[r]}`:n[r]}),e}function Y(t){t.map(e=>Me(e))}function Me(t){if(t.instance)ret
54
54
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
55
55
  // If the GPU doesn't have full 32 bits precision, will causes overflow
56
56
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
57
- `}}function Fn(t,e){if(Number(t.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 t=En(t,Po),t;case"fragment":return t=En(t,Lo),t;default:throw new Error(e)}}var In=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
58
- `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Po=[...In,[ut("attribute"),"in $1"],[ut("varying"),"out $1"]],Lo=[...In,[ut("varying"),"in $1"]];function En(t,e){for(let[n,r]of e)t=t.replace(n,r);return t}function ut(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function ht(t,e){let n="";for(let r in t){let o=t[r];if(n+=`void ${o.signature} {
59
- `,o.header&&(n+=` ${o.header}`),e[r]){let i=e[r];i.sort((a,c)=>a.order-c.order);for(let a of i)n+=` ${a.injection}
60
- `}o.footer&&(n+=` ${o.footer}`),n+=`}
61
- `}return n}function _t(t){let e={vertex:{},fragment:{}};for(let n of t){let r,o;typeof n!="string"?(r=n,o=r.hook):(r={},o=n),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 Ce(t,e){return{name:So(t,e),language:"glsl",version:ko(t)}}function So(t,e="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return r?r[1]:e}function ko(t){let e=100,n=t.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]==="#version"){let r=parseInt(n[1],10);Number.isFinite(r)&&(e=r)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Cn=`
57
+ `}}function In(t,e){if(Number(t.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 t=Nn(t,Pi),t;case"fragment":return t=Nn(t,Si),t;default:throw new Error(e)}}var Fn=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
58
+ `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Pi=[...Fn,[ut("attribute"),"in $1"],[ut("varying"),"out $1"]],Si=[...Fn,[ut("varying"),"in $1"]];function Nn(t,e){for(let[n,r]of e)t=t.replace(n,r);return t}function ut(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function ht(t,e){let n="";for(let r in t){let i=t[r];if(n+=`void ${i.signature} {
59
+ `,i.header&&(n+=` ${i.header}`),e[r]){let o=e[r];o.sort((a,c)=>a.order-c.order);for(let a of o)n+=` ${a.injection}
60
+ `}i.footer&&(n+=` ${i.footer}`),n+=`}
61
+ `}return n}function _t(t){let e={vertex:{},fragment:{}};for(let n of t){let r,i;typeof n!="string"?(r=n,i=r.hook):(r={},i=n),i=i.trim();let[o,a]=i.split(":"),c=i.replace(/\(.+/,""),u=Object.assign(r,{signature:a});switch(o){case"vs":e.vertex[c]=u;break;case"fs":e.fragment[c]=u;break;default:throw new Error(o)}}return e}function Ce(t,e){return{name:ki(t,e),language:"glsl",version:Ti(t)}}function ki(t,e="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return r?r[1]:e}function Ti(t){let e=100,n=t.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]==="#version"){let r=parseInt(n[1],10);Number.isFinite(r)&&(e=r)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Cn=`
62
62
 
63
63
  ${me}
64
- `,To=`precision highp float;
65
- `;function Rn(t){let e=ve(t.modules||[]);return{source:No(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:On(e)}}function Re(t){let{vs:e,fs:n}=t,r=ve(t.modules||[]);return{vs:Mn(t.platformInfo,{...t,source:e,stage:"vertex",modules:r}),fs:Mn(t.platformInfo,{...t,source:n,stage:"fragment",modules:r}),getUniforms:On(r)}}function No(t,e){let{source:n,stage:r,modules:o,hookFunctions:i=[],inject:a={},log:c}=e;W(typeof n=="string","shader source must be a string");let u=n,_="",p=_t(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 P=t.type!=="webgpu"?o:[];for(let g of P){c&&xe(g,u,c);let A=Oe(g,r);_+=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 _+=Cn,_=ge(_,r,m),_+=ht(p[r],d),_+=u,_=ge(_,r,x),_}function Mn(t,e){let{id:n,source:r,stage:o,language:i="glsl",modules:a,defines:c={},hookFunctions:u=[],inject:_={},prologue:p=!0,log:d}=e;W(typeof r=="string","shader source must be a string");let m=i==="glsl"?Ce(r).version:-1,x=t.shaderLanguageVersion,P=m===100?"#version 100":"#version 300 es",A=r.split(`
64
+ `,Ei=`precision highp float;
65
+ `;function Rn(t){let e=ve(t.modules||[]);return{source:Ni(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:On(e)}}function Re(t){let{vs:e,fs:n}=t,r=ve(t.modules||[]);return{vs:Mn(t.platformInfo,{...t,source:e,stage:"vertex",modules:r}),fs:Mn(t.platformInfo,{...t,source:n,stage:"fragment",modules:r}),getUniforms:On(r)}}function Ni(t,e){let{source:n,stage:r,modules:i,hookFunctions:o=[],inject:a={},log:c}=e;W(typeof n=="string","shader source must be a string");let u=n,_="",p=_t(o),d={},m={},x={};for(let g in a){let A=typeof a[g]=="string"?{injection:a[g],order:0}:a[g],P=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(P){let v=P[2],y=P[3];v?y==="decl"?m[g]=[A]:x[g]=[A]:d[g]=[A]}else x[g]=[A]}let L=i;for(let g of L){c&&xe(g,u,c);let A=Oe(g,"wgsl");_+=A;let P=g.injections?.[r]||{};for(let v in P){let y=/^(v|f)s:#([\w-]+)$/.exec(v);if(y){let b=y[2]==="decl"?m:x;b[v]=b[v]||[],b[v].push(P[v])}else d[v]=d[v]||[],d[v].push(P[v])}}return _+=Cn,_=ge(_,r,m),_+=ht(p[r],d),_+=u,_=ge(_,r,x),_}function Mn(t,e){let{id:n,source:r,stage:i,language:o="glsl",modules:a,defines:c={},hookFunctions:u=[],inject:_={},prologue:p=!0,log:d}=e;W(typeof r=="string","shader source must be a string");let m=o==="glsl"?Ce(r).version:-1,x=t.shaderLanguageVersion,L=m===100?"#version 100":"#version 300 es",A=r.split(`
66
66
  `).slice(1).join(`
67
- `),L={};a.forEach(k=>{Object.assign(L,k.defines)}),Object.assign(L,c);let v="";switch(i){case"wgsl":break;case"glsl":v=p?`${P}
67
+ `),P={};a.forEach(k=>{Object.assign(P,k.defines)}),Object.assign(P,c);let v="";switch(o){case"wgsl":break;case"glsl":v=p?`${L}
68
68
 
69
69
  // ----- PROLOGUE -------------------------
70
- ${Eo({id:n,source:r,stage:o})}
71
- ${`#define SHADER_TYPE_${o.toUpperCase()}`}
70
+ ${Ii({id:n,source:r,stage:i})}
71
+ ${`#define SHADER_TYPE_${i.toUpperCase()}`}
72
72
 
73
- ${Nn(t)}
74
- ${o==="fragment"?To:""}
73
+ ${En(t)}
74
+ ${i==="fragment"?Ei:""}
75
75
 
76
76
  // ----- APPLICATION DEFINES -------------------------
77
77
 
78
- ${Fo(L)}
78
+ ${Fi(P)}
79
79
 
80
- `:`${P}
81
- `;break}let y=_t(u),w={},b={},S={};for(let k in _){let I=typeof _[k]=="string"?{injection:_[k],order:0}:_[k],F=/^(v|f)s:(#)?([\w-]+)$/.exec(k);if(F){let N=F[2],M=F[3];N?M==="decl"?b[k]=[I]:S[k]=[I]:w[k]=[I]}else S[k]=[I]}for(let k of a){d&&xe(k,A,d);let I=Oe(k,o);v+=I;let F=k.instance?.normalizedInjections[o]||{};for(let N in F){let M=/^(v|f)s:#([\w-]+)$/.exec(N);if(M){let C=M[2]==="decl"?b:S;C[N]=C[N]||[],C[N].push(F[N])}else w[N]=w[N]||[],w[N].push(F[N])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=Cn,v=ge(v,o,b),v+=ht(y[o],w),v+=A,v=ge(v,o,S),i==="glsl"&&m!==x&&(v=Fn(v,o)),v.trim()}function On(t){return function(n){let r={};for(let o of t){let i=o.getUniforms?.(n,r);Object.assign(r,i)}return r}}function Eo(t){let{id:e,source:n,stage:r}=t;return e&&n.indexOf("SHADER_NAME")===-1?`
82
- #define SHADER_NAME ${e}_${r}`:""}function Fo(t={}){let e="";for(let n in t){let r=t[n];(r||Number.isFinite(r))&&(e+=`#define ${n.toUpperCase()} ${t[n]}
83
- `)}return e}function Oe(t,e){let n;switch(e){case"vertex":n=t.vs||"";break;case"fragment":n=t.fs||"";break;case"wgsl":n=t.source||"";break;default:W(!1)}if(!t.name)throw new Error("Shader module must have a name");let r=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${t.name} ---------------
80
+ `:`${L}
81
+ `;break}let y=_t(u),w={},b={},S={};for(let k in _){let F=typeof _[k]=="string"?{injection:_[k],order:0}:_[k],I=/^(v|f)s:(#)?([\w-]+)$/.exec(k);if(I){let E=I[2],M=I[3];E?M==="decl"?b[k]=[F]:S[k]=[F]:w[k]=[F]}else S[k]=[F]}for(let k of a){d&&xe(k,A,d);let F=Oe(k,i);v+=F;let I=k.instance?.normalizedInjections[i]||{};for(let E in I){let M=/^(v|f)s:#([\w-]+)$/.exec(E);if(M){let C=M[2]==="decl"?b:S;C[E]=C[E]||[],C[E].push(I[E])}else w[E]=w[E]||[],w[E].push(I[E])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=Cn,v=ge(v,i,b),v+=ht(y[i],w),v+=A,v=ge(v,i,S),o==="glsl"&&m!==x&&(v=In(v,i)),v.trim()}function On(t){return function(n){let r={};for(let i of t){let o=i.getUniforms?.(n,r);Object.assign(r,o)}return r}}function Ii(t){let{id:e,source:n,stage:r}=t;return e&&n.indexOf("SHADER_NAME")===-1?`
82
+ #define SHADER_NAME ${e}_${r}`:""}function Fi(t={}){let e="";for(let n in t){let r=t[n];(r||Number.isFinite(r))&&(e+=`#define ${n.toUpperCase()} ${t[n]}
83
+ `)}return e}function Oe(t,e){let n;switch(e){case"vertex":n=t.vs||"";break;case"fragment":n=t.fs||"";break;case"wgsl":n=t.source||"";break;default:W(!1)}if(!t.name)throw new Error("Shader module must have a name");let r=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),i=`// ----- MODULE ${t.name} ---------------
84
84
 
85
- #define MODULE_${r}
86
- ${n}
87
-
88
- `}var Io=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Mo=/^\s*\#\s*endif\s*$/;function Ue(t,e){let n=t.split(`
89
- `),r=[],o=!0,i=null;for(let a of n){let c=a.match(Io),u=a.match(Mo);c?(i=c[1],o=Boolean(e?.defines?.[i])):u?o=!0:o&&r.push(a)}return r.join(`
90
- `)}var re=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return re.defaultShaderAssembler=re.defaultShaderAssembler||new re,re.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(n=>n.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let n=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==n)}addShaderHook(e,n){n&&(e=Object.assign(n,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let n=this._getModuleList(e.modules),r=this._hookFunctions,{source:o,getUniforms:i}=Rn({...e,source:e.source,modules:n,hookFunctions:r});return{source:e.platformInfo.shaderLanguage==="wgsl"?Ue(o):o,getUniforms:i,modules:n}}assembleGLSLShaderPair(e){let n=this._getModuleList(e.modules),r=this._hookFunctions;return{...Re({...e,vs:e.vs,fs:e.fs,modules:n,hookFunctions:r}),modules:n}}_getModuleList(e=[]){let n=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;n[o++]=c,r[u]=!0}for(let i=0,a=e.length;i<a;++i){let c=e[i],u=c.name;r[u]||(n[o++]=c,r[u]=!0)}return n.length=o,Y(n),n}},be=re;mn(be,"defaultShaderAssembler");var Co=`out vec4 transform_output;
85
+ `;return e!=="wgsl"&&(i+=`#define MODULE_${r}
86
+ `),i+=`${n}
87
+ `,i}var Mi=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Ci=/^\s*\#\s*endif\s*$/;function Ue(t,e){let n=t.split(`
88
+ `),r=[],i=!0,o=null;for(let a of n){let c=a.match(Mi),u=a.match(Ci);c?(o=c[1],i=Boolean(e?.defines?.[o])):u?i=!0:i&&r.push(a)}return r.join(`
89
+ `)}var re=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return re.defaultShaderAssembler=re.defaultShaderAssembler||new re,re.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(n=>n.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let n=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==n)}addShaderHook(e,n){n&&(e=Object.assign(n,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let n=this._getModuleList(e.modules),r=this._hookFunctions,{source:i,getUniforms:o}=Rn({...e,source:e.source,modules:n,hookFunctions:r});return{source:e.platformInfo.shaderLanguage==="wgsl"?Ue(i):i,getUniforms:o,modules:n}}assembleGLSLShaderPair(e){let n=this._getModuleList(e.modules),r=this._hookFunctions;return{...Re({...e,vs:e.vs,fs:e.fs,modules:n,hookFunctions:r}),modules:n}}_getModuleList(e=[]){let n=new Array(this._defaultModules.length+e.length),r={},i=0;for(let o=0,a=this._defaultModules.length;o<a;++o){let c=this._defaultModules[o],u=c.name;n[i++]=c,r[u]=!0}for(let o=0,a=e.length;o<a;++o){let c=e[o],u=c.name;r[u]||(n[i++]=c,r[u]=!0)}return n.length=i,Y(n),n}},be=re;mn(be,"defaultShaderAssembler");var Ri=`out vec4 transform_output;
91
90
  void main() {
92
91
  transform_output = vec4(0);
93
- }`,Ro=`#version 300 es
94
- ${Co}`;function Un(t,e){e=Array.isArray(e)?e:[e];let n=t.replace(/^\s+/,"").split(/\s+/),[r,o,i]=n;if(!e.includes(r)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:r,type:o,name:a}}function zn(t){let{input:e,inputChannels:n,output:r}=t||{};if(!e)return Ro;if(!n)throw new Error("inputChannels");let o=Oo(n),i=pt(e,n);return`#version 300 es
95
- in ${o} ${e};
92
+ }`,Oi=`#version 300 es
93
+ ${Ri}`;function Un(t,e){e=Array.isArray(e)?e:[e];let n=t.replace(/^\s+/,"").split(/\s+/),[r,i,o]=n;if(!e.includes(r)||!i||!o)return null;let a=o.split(";")[0];return{qualifier:r,type:i,name:a}}function zn(t){let{input:e,inputChannels:n,output:r}=t||{};if(!e)return Oi;if(!n)throw new Error("inputChannels");let i=Ui(n),o=pt(e,n);return`#version 300 es
94
+ in ${i} ${e};
96
95
  out vec4 ${r};
97
96
  void main() {
98
- ${r} = ${i};
99
- }`}function Dn(t){switch(t){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(t)}}function Bn(t){switch(t){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(t)}}function Oo(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function pt(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}function Z(t){return typeof t=="string"?t.charAt(0).toUpperCase()+t.slice(1):t}function Xn(t,e){return Uo(t,e)}function Uo(t,e){let n=[];switch(e.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":n.push(`uniform ${Z(t.name)} {`);break;case"uniforms":}for(let[r,o]of Object.entries(t.uniformTypes||{})){let i=zo(o);switch(e.uniforms){case"scoped-interface-blocks":n.push(` ${i} ${r};`);break;case"unscoped-interface-blocks":n.push(` ${i} ${t.name}_${r};`);break;case"uniforms":n.push(`uniform ${i} ${t.name}_${r};`)}}switch(e.uniforms){case"scoped-interface-blocks":n.push(`} ${t.name};`);break;case"unscoped-interface-blocks":n.push("};");break;case"uniforms":}return n.push(""),n.join(`
100
- `)}function zo(t){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"}[t]}function Yn(t,e){return Do(t,e)}function Do(t,e){let n=[];n.push(`struct ${Z(t.name)} {`);for(let[r,o]of Object.entries(t?.uniformTypes||{})){let i=o;n.push(` ${r} : ${i};`)}return n.push("};"),n.push(`var<uniform> ${t.name} : ${Z(t.name)};`),n.join(`
101
- `)}function Qn(t,e){switch(e.shaderLanguage){case"glsl":return Xn(t,e);case"wgsl":return Yn(t,e)}}var Gn=dn(ct(),1);var dt=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,n){if(e){n(ae.instance);for(let r of e)r instanceof Array?this.searchBlock(r,n):r.search(n);n(ce.instance)}}},ae=class extends B{};ae.instance=new ae;var ce=class extends B{};ce.instance=new ce;var T=class extends B{constructor(){super()}},we=class extends T{constructor(e,n,r,o,i,a){super(),this.calls=new Set,this.name=e,this.args=n,this.returnType=r,this.body=o,this.startLine=i,this.endLine=a}get astNodeType(){return"function"}search(e){this.searchBlock(this.body,e)}},mt=class extends T{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},gt=class extends T{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},xt=class extends T{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},vt=class extends T{constructor(e,n,r,o){super(),this.init=e,this.condition=n,this.increment=r,this.body=o}get astNodeType(){return"for"}search(e){var n,r,o;(n=this.init)===null||n===void 0||n.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)}},G=class extends T{constructor(e,n,r,o,i){super(),this.name=e,this.type=n,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"var"}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},ze=class extends T{constructor(e,n,r){super(),this.name=e,this.type=n,this.value=r}get astNodeType(){return"override"}search(e){var n;(n=this.value)===null||n===void 0||n.search(e)}},Pe=class extends T{constructor(e,n,r,o,i){super(),this.name=e,this.type=n,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"let"}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},De=class extends T{constructor(e,n,r,o,i){super(),this.name=e,this.type=n,this.storage=r,this.access=o,this.value=i}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},le;(function(t){t.increment="++",t.decrement="--"})(le||(le={}));(function(t){function e(n){let r=n;if(r=="parse")throw new Error("Invalid value for IncrementOperator");return t[r]}t.parse=e})(le||(le={}));var At=class extends T{constructor(e,n){super(),this.operator=e,this.variable=n}get astNodeType(){return"increment"}search(e){this.variable.search(e)}},Le;(function(t){t.assign="=",t.addAssign="+=",t.subtractAssin="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="})(Le||(Le={}));(function(t){function e(n){let r=n;if(r=="parse")throw new Error("Invalid value for AssignOperator");return r}t.parse=e})(Le||(Le={}));var bt=class extends T{constructor(e,n,r){super(),this.operator=e,this.variable=n,this.value=r}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Be=class extends T{constructor(e,n){super(),this.name=e,this.args=n}get astNodeType(){return"call"}search(e){for(let n of this.args)n.search(e);e(this)}},yt=class extends T{constructor(e,n){super(),this.body=e,this.continuing=n}get astNodeType(){return"loop"}},wt=class extends T{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"body"}},Pt=class extends T{constructor(e,n,r,o){super(),this.condition=e,this.body=n,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)}},Lt=class extends T{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var n;(n=this.value)===null||n===void 0||n.search(e)}},St=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},kt=class extends T{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},Tt=class extends T{constructor(e,n){super(),this.severity=e,this.rule=n}get astNodeType(){return"diagnostic"}},Xe=class extends T{constructor(e,n){super(),this.name=e,this.type=n}get astNodeType(){return"alias"}},Nt=class extends T{constructor(){super()}get astNodeType(){return"discard"}},Et=class extends T{constructor(){super()}get astNodeType(){return"break"}},Ft=class extends T{constructor(){super()}get astNodeType(){return"continue"}},H=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},q=class extends H{constructor(e,n,r,o){super(e),this.members=n,this.startLine=r,this.endLine=o}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let n=0;n<this.members.length;n++)if(this.members[n].name==e)return n;return-1}},Ye=class extends H{constructor(e,n,r){super(e),this.format=n,this.access=r}get astNodeType(){return"template"}},It=class extends H{constructor(e,n,r,o){super(e),this.storage=n,this.type=r,this.access=o}get astNodeType(){return"pointer"}},Qe=class extends H{constructor(e,n,r,o){super(e),this.attributes=n,this.format=r,this.count=o}get astNodeType(){return"array"}get isArray(){return!0}},J=class extends H{constructor(e,n,r){super(e),this.format=n,this.access=r}get astNodeType(){return"sampler"}},O=class extends B{constructor(){super()}},qe=class extends O{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},$=class extends O{constructor(e,n){super(),this.type=e,this.args=n}get astNodeType(){return"createExpr"}search(e){e(this);for(let n of this.args)n.search(e)}},Ge=class extends O{constructor(e,n){super(),this.name=e,this.args=n}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 n of this.args)n.search(e);e(this)}},Se=class extends O{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}evaluate(e){let n=e.constants.get(this.name);if(!n)throw new Error("Cannot evaluate node");return n.evaluate(e)}},He=class extends O{constructor(e,n){super(),this.name=e,this.initializer=n}get astNodeType(){return"constExpr"}evaluate(e){var n,r;if(this.initializer instanceof $){let o=(n=this.postfix)===null||n===void 0?void 0:n.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)}},Ve=class extends O{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Mt=class extends O{constructor(e,n){super(),this.type=e,this.value=n}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},Ct=class extends O{constructor(e,n){super(),this.type=e,this.args=n}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}search(e){this.searchBlock(this.args,e)}},We=class extends O{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)}},Rt=class extends O{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},je=class extends O{constructor(){super()}},Ot=class extends je{constructor(e,n){super(),this.operator=e,this.right=n}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)}},z=class extends je{constructor(e,n,r){super(),this.operator=e,this.left=n,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)}},$e=class extends B{constructor(){super()}},Ut=class extends $e{constructor(e,n){super(),this.selector=e,this.body=n}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},zt=class extends $e{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Dt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"argument"}},Bt=class extends B{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Xt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"member"}},Yt=class extends B{constructor(e,n){super(),this.name=e,this.value=n}get astNodeType(){return"attribute"}},h,f;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(f||(f={}));var l=class{constructor(e,n,r){this.name=e,this.type=n,this.rule=r}toString(){return this.name}},s=class{};h=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={"@":h.tokens.attr,"{":h.tokens.brace_left,"}":h.tokens.brace_right,":":h.tokens.colon,",":h.tokens.comma,"(":h.tokens.paren_left,")":h.tokens.paren_right,";":h.tokens.semicolon};s.literalTokens={"&":h.tokens.and,"&&":h.tokens.and_and,"->":h.tokens.arrow,"/":h.tokens.forward_slash,"!":h.tokens.bang,"[":h.tokens.bracket_left,"]":h.tokens.bracket_right,"=":h.tokens.equal,"==":h.tokens.equal_equal,"!=":h.tokens.not_equal,">":h.tokens.greater_than,">=":h.tokens.greater_than_equal,">>":h.tokens.shift_right,"<":h.tokens.less_than,"<=":h.tokens.less_than_equal,"<<":h.tokens.shift_left,"%":h.tokens.modulo,"-":h.tokens.minus,"--":h.tokens.minus_minus,".":h.tokens.period,"+":h.tokens.plus,"++":h.tokens.plus_plus,"|":h.tokens.or,"||":h.tokens.or_or,"*":h.tokens.star,"~":h.tokens.tilde,_:h.tokens.underscore,"^":h.tokens.xor,"+=":h.tokens.plus_equal,"-=":h.tokens.minus_equal,"*=":h.tokens.times_equal,"/=":h.tokens.division_equal,"%=":h.tokens.modulo_equal,"&=":h.tokens.and_equal,"|=":h.tokens.or_equal,"^=":h.tokens.xor_equal,">>=":h.tokens.shift_right_equal,"<<=":h.tokens.shift_left_equal};s.regexTokens={decimal_float_literal:h.tokens.decimal_float_literal,hex_float_literal:h.tokens.hex_float_literal,int_literal:h.tokens.int_literal,uint_literal:h.tokens.uint_literal,ident:h.tokens.ident};s.storage_class=[h.keywords.function,h.keywords.private,h.keywords.workgroup,h.keywords.uniform,h.keywords.storage];s.access_mode=[h.keywords.read,h.keywords.write,h.keywords.read_write];s.sampler_type=[h.keywords.sampler,h.keywords.sampler_comparison];s.sampled_texture_type=[h.keywords.texture_1d,h.keywords.texture_2d,h.keywords.texture_2d_array,h.keywords.texture_3d,h.keywords.texture_cube,h.keywords.texture_cube_array];s.multisampled_texture_type=[h.keywords.texture_multisampled_2d];s.storage_texture_type=[h.keywords.texture_storage_1d,h.keywords.texture_storage_2d,h.keywords.texture_storage_2d_array,h.keywords.texture_storage_3d];s.depth_texture_type=[h.keywords.texture_depth_2d,h.keywords.texture_depth_2d_array,h.keywords.texture_depth_cube,h.keywords.texture_depth_cube_array,h.keywords.texture_depth_multisampled_2d];s.texture_external_type=[h.keywords.texture_external];s.any_texture_type=[...h.sampled_texture_type,...h.multisampled_texture_type,...h.storage_texture_type,...h.depth_texture_type,...h.texture_external_type];s.texel_format=[h.keywords.r8unorm,h.keywords.r8snorm,h.keywords.r8uint,h.keywords.r8sint,h.keywords.r16uint,h.keywords.r16sint,h.keywords.r16float,h.keywords.rg8unorm,h.keywords.rg8snorm,h.keywords.rg8uint,h.keywords.rg8sint,h.keywords.r32uint,h.keywords.r32sint,h.keywords.r32float,h.keywords.rg16uint,h.keywords.rg16sint,h.keywords.rg16float,h.keywords.rgba8unorm,h.keywords.rgba8unorm_srgb,h.keywords.rgba8snorm,h.keywords.rgba8uint,h.keywords.rgba8sint,h.keywords.bgra8unorm,h.keywords.bgra8unorm_srgb,h.keywords.rgb10a2unorm,h.keywords.rg11b10float,h.keywords.rg32uint,h.keywords.rg32sint,h.keywords.rg32float,h.keywords.rgba16uint,h.keywords.rgba16sint,h.keywords.rgba16float,h.keywords.rgba32uint,h.keywords.rgba32sint,h.keywords.rgba32float];s.const_literal=[h.tokens.int_literal,h.tokens.uint_literal,h.tokens.decimal_float_literal,h.tokens.hex_float_literal,h.keywords.true,h.keywords.false];s.literal_or_ident=[h.tokens.ident,h.tokens.int_literal,h.tokens.uint_literal,h.tokens.decimal_float_literal,h.tokens.hex_float_literal];s.element_count_expression=[h.tokens.int_literal,h.tokens.uint_literal,h.tokens.ident];s.template_types=[h.keywords.vec2,h.keywords.vec3,h.keywords.vec4,h.keywords.mat2x2,h.keywords.mat2x3,h.keywords.mat2x4,h.keywords.mat3x2,h.keywords.mat3x3,h.keywords.mat3x4,h.keywords.mat4x2,h.keywords.mat4x3,h.keywords.mat4x4,h.keywords.atomic,h.keywords.bitcast,...h.any_texture_type];s.attribute_name=[h.tokens.ident,h.keywords.block,h.keywords.diagnostic];s.assignment_operators=[h.tokens.equal,h.tokens.plus_equal,h.tokens.minus_equal,h.tokens.times_equal,h.tokens.division_equal,h.tokens.modulo_equal,h.tokens.and_equal,h.tokens.or_equal,h.tokens.xor_equal,h.tokens.shift_right_equal,h.tokens.shift_left_equal];s.increment_operators=[h.tokens.plus_plus,h.tokens.minus_minus];var Ke=class{constructor(e,n,r){this.type=e,this.lexeme=n,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()}},Qt=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 Ke(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
97
+ ${r} = ${o};
98
+ }`}function Dn(t){switch(t){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(t)}}function Bn(t){switch(t){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(t)}}function Ui(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function pt(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}function Z(t){return typeof t=="string"?t.charAt(0).toUpperCase()+t.slice(1):t}function Xn(t,e){return zi(t,e)}function zi(t,e){let n=[];switch(e.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":n.push(`uniform ${Z(t.name)} {`);break;case"uniforms":}for(let[r,i]of Object.entries(t.uniformTypes||{})){let o=Di(i);switch(e.uniforms){case"scoped-interface-blocks":n.push(` ${o} ${r};`);break;case"unscoped-interface-blocks":n.push(` ${o} ${t.name}_${r};`);break;case"uniforms":n.push(`uniform ${o} ${t.name}_${r};`)}}switch(e.uniforms){case"scoped-interface-blocks":n.push(`} ${t.name};`);break;case"unscoped-interface-blocks":n.push("};");break;case"uniforms":}return n.push(""),n.join(`
99
+ `)}function Di(t){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"}[t]}function Yn(t,e){return Bi(t,e)}function Bi(t,e){let n=[];n.push(`struct ${Z(t.name)} {`);for(let[r,i]of Object.entries(t?.uniformTypes||{})){let o=i;n.push(` ${r} : ${o};`)}return n.push("};"),n.push(`var<uniform> ${t.name} : ${Z(t.name)};`),n.join(`
100
+ `)}function Qn(t,e){switch(e.shaderLanguage){case"glsl":return Xn(t,e);case"wgsl":return Yn(t,e)}}var qn=dn(ct(),1);var dt=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,n){if(e){n(ae.instance);for(let r of e)r instanceof Array?this.searchBlock(r,n):r.search(n);n(ce.instance)}}},ae=class extends B{};ae.instance=new ae;var ce=class extends B{};ce.instance=new ce;var T=class extends B{constructor(){super()}},we=class extends T{constructor(e,n,r,i,o,a){super(),this.calls=new Set,this.name=e,this.args=n,this.returnType=r,this.body=i,this.startLine=o,this.endLine=a}get astNodeType(){return"function"}search(e){this.searchBlock(this.body,e)}},mt=class extends T{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},gt=class extends T{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},xt=class extends T{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},vt=class extends T{constructor(e,n,r,i){super(),this.init=e,this.condition=n,this.increment=r,this.body=i}get astNodeType(){return"for"}search(e){var n,r,i;(n=this.init)===null||n===void 0||n.search(e),(r=this.condition)===null||r===void 0||r.search(e),(i=this.increment)===null||i===void 0||i.search(e),this.searchBlock(this.body,e)}},q=class extends T{constructor(e,n,r,i,o){super(),this.name=e,this.type=n,this.storage=r,this.access=i,this.value=o}get astNodeType(){return"var"}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},ze=class extends T{constructor(e,n,r){super(),this.name=e,this.type=n,this.value=r}get astNodeType(){return"override"}search(e){var n;(n=this.value)===null||n===void 0||n.search(e)}},Le=class extends T{constructor(e,n,r,i,o){super(),this.name=e,this.type=n,this.storage=r,this.access=i,this.value=o}get astNodeType(){return"let"}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},De=class extends T{constructor(e,n,r,i,o){super(),this.name=e,this.type=n,this.storage=r,this.access=i,this.value=o}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}search(e){var n;e(this),(n=this.value)===null||n===void 0||n.search(e)}},le;(function(t){t.increment="++",t.decrement="--"})(le||(le={}));(function(t){function e(n){let r=n;if(r=="parse")throw new Error("Invalid value for IncrementOperator");return t[r]}t.parse=e})(le||(le={}));var At=class extends T{constructor(e,n){super(),this.operator=e,this.variable=n}get astNodeType(){return"increment"}search(e){this.variable.search(e)}},Pe;(function(t){t.assign="=",t.addAssign="+=",t.subtractAssin="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="})(Pe||(Pe={}));(function(t){function e(n){let r=n;if(r=="parse")throw new Error("Invalid value for AssignOperator");return r}t.parse=e})(Pe||(Pe={}));var bt=class extends T{constructor(e,n,r){super(),this.operator=e,this.variable=n,this.value=r}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Be=class extends T{constructor(e,n){super(),this.name=e,this.args=n}get astNodeType(){return"call"}search(e){for(let n of this.args)n.search(e);e(this)}},yt=class extends T{constructor(e,n){super(),this.body=e,this.continuing=n}get astNodeType(){return"loop"}},wt=class extends T{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"body"}},Lt=class extends T{constructor(e,n,r,i){super(),this.condition=e,this.body=n,this.elseif=r,this.else=i}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 T{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var n;(n=this.value)===null||n===void 0||n.search(e)}},St=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},kt=class extends T{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},Tt=class extends T{constructor(e,n){super(),this.severity=e,this.rule=n}get astNodeType(){return"diagnostic"}},Xe=class extends T{constructor(e,n){super(),this.name=e,this.type=n}get astNodeType(){return"alias"}},Et=class extends T{constructor(){super()}get astNodeType(){return"discard"}},Nt=class extends T{constructor(){super()}get astNodeType(){return"break"}},It=class extends T{constructor(){super()}get astNodeType(){return"continue"}},H=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},G=class extends H{constructor(e,n,r,i){super(e),this.members=n,this.startLine=r,this.endLine=i}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let n=0;n<this.members.length;n++)if(this.members[n].name==e)return n;return-1}},Ye=class extends H{constructor(e,n,r){super(e),this.format=n,this.access=r}get astNodeType(){return"template"}},Ft=class extends H{constructor(e,n,r,i){super(e),this.storage=n,this.type=r,this.access=i}get astNodeType(){return"pointer"}},Qe=class extends H{constructor(e,n,r,i){super(e),this.attributes=n,this.format=r,this.count=i}get astNodeType(){return"array"}get isArray(){return!0}},J=class extends H{constructor(e,n,r){super(e),this.format=n,this.access=r}get astNodeType(){return"sampler"}},O=class extends B{constructor(){super()}},Ge=class extends O{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},$=class extends O{constructor(e,n){super(),this.type=e,this.args=n}get astNodeType(){return"createExpr"}search(e){e(this);for(let n of this.args)n.search(e)}},qe=class extends O{constructor(e,n){super(),this.name=e,this.args=n}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 n of this.args)n.search(e);e(this)}},Se=class extends O{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}evaluate(e){let n=e.constants.get(this.name);if(!n)throw new Error("Cannot evaluate node");return n.evaluate(e)}},He=class extends O{constructor(e,n){super(),this.name=e,this.initializer=n}get astNodeType(){return"constExpr"}evaluate(e){var n,r;if(this.initializer instanceof $){let i=(n=this.postfix)===null||n===void 0?void 0:n.evaluateString(e),o=(r=this.initializer.type)===null||r===void 0?void 0:r.name,a=e.structs.get(o),c=a?.getMemberIndex(i);if(c!=-1)return this.initializer.args[c].evaluate(e);console.log(c)}return this.initializer.evaluate(e)}search(e){this.initializer.search(e)}},Ve=class extends O{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Mt=class extends O{constructor(e,n){super(),this.type=e,this.value=n}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},Ct=class extends O{constructor(e,n){super(),this.type=e,this.args=n}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}search(e){this.searchBlock(this.args,e)}},We=class extends O{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)}},Rt=class extends O{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},je=class extends O{constructor(){super()}},Ot=class extends je{constructor(e,n){super(),this.operator=e,this.right=n}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)}},z=class extends je{constructor(e,n,r){super(),this.operator=e,this.left=n,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)}},$e=class extends B{constructor(){super()}},Ut=class extends $e{constructor(e,n){super(),this.selector=e,this.body=n}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},zt=class extends $e{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Dt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"argument"}},Bt=class extends B{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Xt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"member"}},Yt=class extends B{constructor(e,n){super(),this.name=e,this.value=n}get astNodeType(){return"attribute"}},h,f;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(f||(f={}));var l=class{constructor(e,n,r){this.name=e,this.type=n,this.rule=r}toString(){return this.name}},s=class{};h=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={"@":h.tokens.attr,"{":h.tokens.brace_left,"}":h.tokens.brace_right,":":h.tokens.colon,",":h.tokens.comma,"(":h.tokens.paren_left,")":h.tokens.paren_right,";":h.tokens.semicolon};s.literalTokens={"&":h.tokens.and,"&&":h.tokens.and_and,"->":h.tokens.arrow,"/":h.tokens.forward_slash,"!":h.tokens.bang,"[":h.tokens.bracket_left,"]":h.tokens.bracket_right,"=":h.tokens.equal,"==":h.tokens.equal_equal,"!=":h.tokens.not_equal,">":h.tokens.greater_than,">=":h.tokens.greater_than_equal,">>":h.tokens.shift_right,"<":h.tokens.less_than,"<=":h.tokens.less_than_equal,"<<":h.tokens.shift_left,"%":h.tokens.modulo,"-":h.tokens.minus,"--":h.tokens.minus_minus,".":h.tokens.period,"+":h.tokens.plus,"++":h.tokens.plus_plus,"|":h.tokens.or,"||":h.tokens.or_or,"*":h.tokens.star,"~":h.tokens.tilde,_:h.tokens.underscore,"^":h.tokens.xor,"+=":h.tokens.plus_equal,"-=":h.tokens.minus_equal,"*=":h.tokens.times_equal,"/=":h.tokens.division_equal,"%=":h.tokens.modulo_equal,"&=":h.tokens.and_equal,"|=":h.tokens.or_equal,"^=":h.tokens.xor_equal,">>=":h.tokens.shift_right_equal,"<<=":h.tokens.shift_left_equal};s.regexTokens={decimal_float_literal:h.tokens.decimal_float_literal,hex_float_literal:h.tokens.hex_float_literal,int_literal:h.tokens.int_literal,uint_literal:h.tokens.uint_literal,ident:h.tokens.ident};s.storage_class=[h.keywords.function,h.keywords.private,h.keywords.workgroup,h.keywords.uniform,h.keywords.storage];s.access_mode=[h.keywords.read,h.keywords.write,h.keywords.read_write];s.sampler_type=[h.keywords.sampler,h.keywords.sampler_comparison];s.sampled_texture_type=[h.keywords.texture_1d,h.keywords.texture_2d,h.keywords.texture_2d_array,h.keywords.texture_3d,h.keywords.texture_cube,h.keywords.texture_cube_array];s.multisampled_texture_type=[h.keywords.texture_multisampled_2d];s.storage_texture_type=[h.keywords.texture_storage_1d,h.keywords.texture_storage_2d,h.keywords.texture_storage_2d_array,h.keywords.texture_storage_3d];s.depth_texture_type=[h.keywords.texture_depth_2d,h.keywords.texture_depth_2d_array,h.keywords.texture_depth_cube,h.keywords.texture_depth_cube_array,h.keywords.texture_depth_multisampled_2d];s.texture_external_type=[h.keywords.texture_external];s.any_texture_type=[...h.sampled_texture_type,...h.multisampled_texture_type,...h.storage_texture_type,...h.depth_texture_type,...h.texture_external_type];s.texel_format=[h.keywords.r8unorm,h.keywords.r8snorm,h.keywords.r8uint,h.keywords.r8sint,h.keywords.r16uint,h.keywords.r16sint,h.keywords.r16float,h.keywords.rg8unorm,h.keywords.rg8snorm,h.keywords.rg8uint,h.keywords.rg8sint,h.keywords.r32uint,h.keywords.r32sint,h.keywords.r32float,h.keywords.rg16uint,h.keywords.rg16sint,h.keywords.rg16float,h.keywords.rgba8unorm,h.keywords.rgba8unorm_srgb,h.keywords.rgba8snorm,h.keywords.rgba8uint,h.keywords.rgba8sint,h.keywords.bgra8unorm,h.keywords.bgra8unorm_srgb,h.keywords.rgb10a2unorm,h.keywords.rg11b10float,h.keywords.rg32uint,h.keywords.rg32sint,h.keywords.rg32float,h.keywords.rgba16uint,h.keywords.rgba16sint,h.keywords.rgba16float,h.keywords.rgba32uint,h.keywords.rgba32sint,h.keywords.rgba32float];s.const_literal=[h.tokens.int_literal,h.tokens.uint_literal,h.tokens.decimal_float_literal,h.tokens.hex_float_literal,h.keywords.true,h.keywords.false];s.literal_or_ident=[h.tokens.ident,h.tokens.int_literal,h.tokens.uint_literal,h.tokens.decimal_float_literal,h.tokens.hex_float_literal];s.element_count_expression=[h.tokens.int_literal,h.tokens.uint_literal,h.tokens.ident];s.template_types=[h.keywords.vec2,h.keywords.vec3,h.keywords.vec4,h.keywords.mat2x2,h.keywords.mat2x3,h.keywords.mat2x4,h.keywords.mat3x2,h.keywords.mat3x3,h.keywords.mat3x4,h.keywords.mat4x2,h.keywords.mat4x3,h.keywords.mat4x4,h.keywords.atomic,h.keywords.bitcast,...h.any_texture_type];s.attribute_name=[h.tokens.ident,h.keywords.block,h.keywords.diagnostic];s.assignment_operators=[h.tokens.equal,h.tokens.plus_equal,h.tokens.minus_equal,h.tokens.times_equal,h.tokens.division_equal,h.tokens.modulo_equal,h.tokens.and_equal,h.tokens.or_equal,h.tokens.xor_equal,h.tokens.shift_right_equal,h.tokens.shift_left_equal];s.increment_operators=[h.tokens.plus_plus,h.tokens.minus_minus];var Ke=class{constructor(e,n,r){this.type=e,this.lexeme=n,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()}},Qt=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 Ke(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
102
101
  `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
103
102
  `;){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==`
104
- `)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 n=s.simpleTokens[e];if(n)return this._addToken(n),!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,_=this._tokens.length-1;for(let p=0;p<5&&_>=0;++p,--_)if(this._tokens[_].type===s.tokens.less_than){_>0&&this._tokens[_-1].isArrayOrTemplateType()&&(u=!0);break}if(u)return this._addToken(a),!0}if(a===s.none){let u=e,_=0,p=2;for(let d=0;d<p;++d)if(u+=this._peekAhead(d),a=this._findType(u),a!==s.none){_=d;break}if(a===s.none)return r===s.none?!1:(this._current--,this._addToken(r),!0);e=u,this._current+=_+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 n=s.literalTokens[e];return n||s.none}_match(e,n){let r=n.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 n=this._source[this._current];return e=e||0,e++,this._current+=e,n}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let n=this._source.substring(this._start,this._current);this._tokens.push(new Ke(e,n,this._line))}},qt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new dt,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let n=[];for(;!this._isAtEnd();){let r=this._global_decl_or_directive();if(!r)break;n.push(r)}if(this._deferArrayCountEval.length>0){for(let r of this._deferArrayCountEval){let o=r.arrayType,i=r.countNode;if(i instanceof Se){let c=i.name,u=this._context.constants.get(c);if(u)try{let _=u.evaluate(this._context);o.count=_}catch{}}}this._deferArrayCountEval.length=0}return n}_initialize(e){if(e)if(typeof e=="string"){let n=new Qt(e);this._tokens=n.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,n){return{token:e,message:n,toString:function(){return`${n}`}}}_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 n=0,r=e.length;n<r;++n){let o=e[n];if(this._check(o))return this._advance(),!0}return!1}_consume(e,n){if(this._check(e))return this._advance();throw this._error(this._peek(),n)}_check(e){if(this._isAtEnd())return!1;let n=this._peek();if(e instanceof Array){let r=n.type;return e.indexOf(r)!=-1}return n.type==e}_advance(){var e,n;return this._currentLine=(n=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&n!==void 0?n:-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 n=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.diagnostic)){let n=this._diagnostic();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.requires)){let n=this._requires_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.enable)){let n=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),n}let e=this._attribute();if(this._check(s.keywords.var)){let n=this._global_variable_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.override)){let n=this._override_variable_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.let)){let n=this._global_let_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.const)){let n=this._global_const_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.struct)){let n=this._struct_decl();return n!=null&&(n.attributes=e),n}if(this._check(s.keywords.fn)){let n=this._function_decl();return n!=null&&(n.attributes=e),n}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=this._currentLine,n=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 _=this._attribute(),p=this._type_decl();p!=null&&(p.attributes=_,r.push(new Dt(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 we(n,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 n=this._statement();n!==null&&e.push(n)}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 Nt:this._match(s.keywords.break)?e=new Et:this._match(s.keywords.continue)?e=new Ft: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 mt(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 n=this._compound_statement();return new gt(e,n)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new xt(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 n=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 vt(e,n,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 n=null;return this._match(s.tokens.equal)&&(n=this._short_circuit_or_expression()),new G(e.name,e.type,e.storage,e.access,n)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),n=null;if(this._match(s.tokens.colon)){let o=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for let.");let r=this._short_circuit_or_expression();return new Pe(e,n,null,null,r)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),n=null;if(this._match(s.tokens.colon)){let o=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for const.");let r=this._short_circuit_or_expression();return new De(e,n,null,null,r)}return null}_increment_decrement_statement(){let e=this._current,n=this._unary_expression();if(n==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 At(r.type===s.tokens.plus_plus?le.increment:le.decrement,n)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let n=this._match(s.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e==null)return null;let r=this._consume(s.assignment_operators,"Expected assignment operator."),o=this._short_circuit_or_expression();return new bt(Le.parse(r.lexeme),e,o)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,n=this._consume(s.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=e,null):new Be(n.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=[],n=this._statement();for(;n!==null;){if(Array.isArray(n))for(let o of n)e.push(o);else e.push(n);n=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 yt(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 n=this._switch_body();if(n==null||n.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new wt(e,n)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let n=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 Ut(n,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 n=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new zt(n))}if(this._check([s.keywords.default,s.keywords.case])){let n=this._switch_body();e.push(n[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 n=this._case_body();return n.length==0?e:[...e,n[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 n=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 Pt(e,n,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 n=this._optional_paren_expression(),r=this._compound_statement();return e.push(new Bt(n,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 Lt(e)}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(s.tokens.or_or);)e=new z(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 z(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 z(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 z(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new z(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 z(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 z(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 z(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 z(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 z(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 Ot(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),n=this._postfix_expression();return n&&(e.postfix=n),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 n=new Rt(e),r=this._postfix_expression();return r&&(n.postfix=r),n}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),n=this._postfix_expression(),r=new qe(e.lexeme);return n&&(r.postfix=n),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 Ge(r,o)}if(this._context.constants.has(r)){let o=this._context.constants.get(r);return new He(r,o.value)}return new Se(r)}if(this._match(s.const_literal))return new Ve(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(),n=this._argument_expression_list();return new Ct(e,n)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let n=this._short_circuit_or_expression();e.push(n)}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 We([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 We([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=this._currentLine,n=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(),_=this._type_decl();_!=null&&(_.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 Xt(c,_,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let o=this._currentLine,i=new q(n,r,e,o);return this._context.structs.set(n,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"),n=null;if(this._match(s.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.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 He&&i.initializer instanceof $)r=i.initializer;else try{let a=i.evaluate(this._context);r=new Ve(a)}catch{r=i}}let o=new De(e.toString(),n,"","",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"),n=null;if(this._match(s.tokens.colon)){let o=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=o)}let r=null;return this._match(s.tokens.equal)&&(r=this._const_expression()),new Pe(e.toString(),n,"","",r)}_const_expression(){if(this._match(s.const_literal))return new qe(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let n=[];for(;!this._check(s.tokens.paren_right)&&(n.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new $(e,n)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",n="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(n=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 G(r.toString(),o,e,n,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),n=null;if(this._match(s.tokens.colon)){let r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}return new ze(e.toString(),n,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 n=this._consume(s.tokens.ident,"Expected diagnostic rule name.");return this._consume(s.tokens.paren_right,"Expected ')'"),new Tt(e.toString(),n.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new St(e.toString())}_requires_directive(){let e=[this._consume(s.tokens.ident,"identity expected.").toString()];for(;this._match(s.tokens.comma);){let n=this._consume(s.tokens.ident,"identity expected.");e.push(n.toString())}return new kt(e)}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let n=this._type_decl();if(n===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let r=new Xe(e.toString(),n);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 H(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 Ye(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 It(r,o.toString(),i,a)}let n=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 Qe(i.toString(),n,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 n=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),n,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let n=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(),n,r)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let n=this._consume(s.attribute_name,"Expected attribute name"),r=new Yt(n.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,n){this.name=e,this.attributes=n,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Ze=class{constructor(e,n,r){this.name=e,this.type=n,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,n){super(e,n),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},ye=class extends K{constructor(e,n){super(e,n),this.count=0,this.stride=0}get isArray(){return!0}},Je=class extends K{constructor(e,n,r,o){super(e,r),this.format=n,this.access=o}get isTemplate(){return!0}},j;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(j||(j={}));var ie=class{constructor(e,n,r,o,i,a,c){this.name=e,this.type=n,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}},Gt=class{constructor(e,n){this.name=e,this.type=n}},se=class{constructor(e,n){this.align=e,this.size=n}},Ht=class{constructor(e,n,r,o){this.name=e,this.type=n,this.locationType=r,this.location=o,this.interpolation=null}},et=class{constructor(e,n,r,o){this.name=e,this.type=n,this.locationType=r,this.location=o}},Vt=class{constructor(e,n=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=n}},Wt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},jt=class{constructor(e,n,r,o){this.name=e,this.type=n,this.attributes=r,this.id=o}},$t=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},D=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 qt().parse(e);for(let o of r)o instanceof we&&this._functions.set(o.name,new $t(o));for(let o of r)if(o instanceof q){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i)}for(let o of r){if(o instanceof Xe){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof ze){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 jt(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),_=new ie(i.name,u,a,c,i.attributes,j.Uniform,i.access);this.uniforms.push(_);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),_=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,_?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),_=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,_?j.StorageTexture:j.Texture,i.access);_?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),_=new ie(i.name,u,a,c,i.attributes,j.Sampler,i.access);this.samplers.push(_);continue}if(o instanceof we){let i=this._getAttribute(o,"vertex"),a=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),u=i||a||c,_=new Vt(o.name,u?.name);_.startLine=o.startLine,_.endLine=o.endLine,this.functions.push(_),this._functions.get(o.name).info=_,u&&(this._functions.get(o.name).inUse=!0,_.inUse=!0,_.resources=this._findResources(o,!!u),_.inputs=this._getInputs(o.args),_.outputs=this._getOutputs(o.returnType),this.entry[u.name].push(_));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 n of e.members)this._markStructsInUse(n.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let n=this._getAlias(e.name);n&&this._markStructsInUse(n)}}_addCalls(e,n){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&&n.add(i)}}findResource(e,n){for(let r of this.uniforms)if(r.group==e&&r.binding==n)return r;for(let r of this.storage)if(r.group==e&&r.binding==n)return r;for(let r of this.textures)if(r.group==e&&r.binding==n)return r;for(let r of this.samplers)if(r.group==e&&r.binding==n)return r;return null}_findResource(e){for(let n of this.uniforms)if(n.name==e)return n;for(let n of this.storage)if(n.name==e)return n;for(let n of this.textures)if(n.name==e)return n;for(let n of this.samplers)if(n.name==e)return n;return null}_markStructsFromAST(e){let n=this._getTypeInfo(e,null);this._markStructsInUse(n)}_findResources(e,n){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 G){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof $){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type)}else if(a instanceof Pe){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof Se){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 Ge){let c=a,u=o._functions.get(c.name);u&&(n&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,n)),r.push(...u.resources))}else if(a instanceof Be){let c=a,u=o._functions.get(c.name);u&&(n&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,n)),r.push(...u.resources))}}),[...new Map(r.map(a=>[a.name,a])).values()]}getBindGroups(){let e=[];function n(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){n(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.storage){n(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.textures){n(r.group,r.binding);let o=e[r.group];o[r.binding]=r}for(let r of this.samplers){n(r.group,r.binding);let o=e[r.group];o[r.binding]=r}return e}_getOutputs(e,n=void 0){if(n===void 0&&(n=[]),e instanceof q)this._getStructOutputs(e,n);else{let r=this._getOutputInfo(e);r!==null&&n.push(r)}return n}_getStructOutputs(e,n){for(let r of e.members)if(r.type instanceof q)this._getStructOutputs(r.type,n);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 et(r.name,i,o.name,a);n.push(c)}}}_getOutputInfo(e){let n=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(n!==null){let r=this._getTypeInfo(e,e.attributes),o=this._parseInt(n.value);return new et("",r,n.name,o)}return null}_getInputs(e,n=void 0){n===void 0&&(n=[]);for(let r of e)if(r.type instanceof q)this._getStructInputs(r.type,n);else{let o=this._getInputInfo(r);o!==null&&n.push(o)}return n}_getStructInputs(e,n){for(let r of e.members)if(r.type instanceof q)this._getStructInputs(r.type,n);else{let o=this._getInputInfo(r);o!==null&&n.push(o)}}_getInputInfo(e){let n=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(n!==null){let r=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),i=this._parseInt(n.value),a=new Ht(e.name,o,n.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 n=parseInt(e);return isNaN(n)?e:n}_getAlias(e){for(let n of this.aliases)if(n.name==e)return n.type;return null}_getAliasInfo(e){return new Gt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,n){if(this._types.has(e))return this._types.get(e);if(e instanceof Qe){let o=e,i=this._getTypeInfo(o.format,o.attributes),a=new ye(o.name,n);return a.format=i,a.count=o.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof q){let o=e,i=new oe(o.name,n);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 Ze(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 H,a=o.format?i?this._getTypeInfo(o.format,null):new K(o.format,null):null,c=new Je(o.name,a,n,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Ye){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new Je(o.name,i,n,o.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let r=new K(e.name,n);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var n,r;let o=this._getTypeSize(e);if(e.size=(n=o?.size)!==null&&n!==void 0?n:0,e instanceof ye){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 n;let r=0,o=0,i=0,a=0;for(let c=0,u=e.members.length;c<u;++c){let _=e.members[c],p=this._getTypeSize(_);if(!p)continue;(n=this._getAlias(_.type.name))!==null&&n!==void 0||_.type;let d=p.align,m=p.size;r=this._roundUp(d,r+o),o=m,i=r,a=Math.max(a,d),_.offset=r,_.size=m,this._updateTypeInfo(_.type)}e.size=this._roundUp(a,i+o),e.align=a}_getTypeSize(e){var n;if(e==null)return null;let r=this._getAttributeNum(e.attributes,"size",0),o=this._getAttributeNum(e.attributes,"align",0);if(e instanceof Ze&&(e=e.type),e instanceof K){let i=this._getAlias(e.name);i!==null&&(e=i)}{let i=D._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=D._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 ye){let i=e,a=8,c=8,u=this._getTypeSize(i.format);u!==null&&(c=u.size,a=u.align);let _=i.count,p=this._getAttributeNum((n=e?.attributes)!==null&&n!==void 0?n:null,"stride",this._roundUp(a,c));return c=_*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,_=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,_=c)}return a=this._roundUp(i,_+u),new se(Math.max(o,i),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof G&&e.storage=="uniform"}_isStorageVar(e){return e instanceof G&&e.storage=="storage"}_isTextureVar(e){return e instanceof G&&e.type!==null&&D._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof G&&e.type!==null&&D._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,n){let r=e;if(!r||!r.attributes)return null;let o=r.attributes;for(let i of o)if(i.name==n)return i;return null}_getAttributeNum(e,n,r){if(e===null)return r;for(let o of e)if(o.name==n){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,n){return Math.ceil(n/e)*e}};D._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}};D._textureTypes=s.any_texture_type.map(t=>t.name);D._samplerTypes=s.sampler_type.map(t=>t.name);function Hn(t){let e={attributes:[],bindings:[]},n;try{n=Bo(t)}catch(i){return Gn.log.error(i.message)(),e}for(let i of n.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=n.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(t){return t.format?`${t.name}<${t.format.name}>`:t.name}function Bo(t){try{return new D(t)}catch(e){if(e instanceof Error)throw e;let n="WGSL parse error";throw typeof e=="object"&&e?.message&&(n+=`: ${e.message} `),typeof e=="object"&&e?.token&&(n+=e.token.line||""),new Error(n,{cause:e})}}var qs=1/Math.PI*180,Gs=1/180*Math.PI,Xo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Xo}};var R=globalThis.mathgl.config;function Kt(t,{precision:e=R.precision}={}){return t=Yo(t),`${parseFloat(t.toPrecision(e))}`}function fe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zt(t,e,n){return qo(t,r=>Math.max(e,Math.min(n,r)))}function tt(t,e,n){let r=R.EPSILON;n&&(R.EPSILON=n);try{if(t===e)return!0;if(fe(t)&&fe(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!tt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=R.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{R.EPSILON=r}}function Yo(t){return Math.round(t/R.EPSILON)*R.EPSILON}function Qo(t){return t.clone?t.clone():new Array(t.length)}function qo(t,e,n){if(fe(t)){let r=t;n=n||Qo(r);for(let o=0;o<n.length&&o<r.length;++o){let i=typeof t=="number"?t:t[o];n[o]=e(i,o,n)}return n}return e(t)}var nt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+n];return this.check()}toArray(e=[],n=0){for(let r=0;r<this.ELEMENTS;++r)e[n+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:fe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(e){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Kt(this[r],e);return`${e.printTypes?this.constructor.name:""}[${n}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!tt(this[n],e[n]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==e[n])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,n,r){if(r===void 0)return this.lerp(this,e,n);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof n=="number"?n:n[o];this[o]=i+r*(a-i)}return this.check()}min(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(e[n],this[n]);return this.check()}max(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(e[n],this[n]);return this.check()}clamp(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),n[r]);return this.check()}add(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(e){if(typeof e=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;else for(let n=0;n<this.ELEMENTS&&n<e.length;++n)this[n]*=e[n];return this.check()}multiplyByScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}check(){if(R.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 n=0;n<this.ELEMENTS;++n)e=e&&Number.isFinite(this[n]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=e;return this.check()}addScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),n);return this.check()}get elements(){return this}};function Go(t,e){if(t.length!==e)return!1;for(let n=0;n<t.length;++n)if(!Number.isFinite(t[n]))return!1;return!0}function Vn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function rt(t,e,n=""){if(R.debug&&!Go(t,e))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return t}var V=typeof Float32Array<"u"?Float32Array:Array;var Ks=Math.PI/180;function Ho(){let t=new V(2);return V!=Float32Array&&(t[0]=0,t[1]=0),t}function $n(t,e,n){let r=e[0],o=e[1];return t[0]=n[0]*r+n[4]*o+n[12],t[1]=n[1]*r+n[5]*o+n[13],t}var Zs=function(){let t=Ho();return function(e,n,r,o,i,a){let c,u;for(n||(n=2),r||(r=0),o?u=Math.min(o*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],i(t,t,a),e[c]=t[0],e[c+1]=t[1];return e}}();function Kn(t,e,n){let r=e[0],o=e[1],i=n[3]*r+n[7]*o||1;return t[0]=(n[0]*r+n[4]*o)/i,t[1]=(n[1]*r+n[5]*o)/i,t}function Zn(t,e,n){let r=e[0],o=e[1],i=e[2],a=n[3]*r+n[7]*o+n[11]*i||1;return t[0]=(n[0]*r+n[4]*o+n[8]*i)/a,t[1]=(n[1]*r+n[5]*o+n[9]*i)/a,t[2]=(n[2]*r+n[6]*o+n[10]*i)/a,t}function Vo(){let t=new V(3);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Jn(t,e,n){let r=e[0],o=e[1],i=e[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,t[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,t[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,t}var ta=function(){let t=Vo();return function(e,n,r,o,i,a){let c,u;for(n||(n=3),r||(r=0),o?u=Math.min(o*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],i(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2];return e}}();var ot=class extends nt{toString(){let e="[";if(R.printRowMajor){e+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+n]}`}else{e+="column-major:";for(let n=0;n<this.ELEMENTS;++n)e+=` ${this[n]}`}return e+="]",e}getElementIndex(e,n){return n*this.RANK+e}getElement(e,n){return this[n*this.RANK+e]}setElement(e,n,r){return this[n*this.RANK+e]=Vn(r),this}getColumn(e,n=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)n[o]=this[r+o];return n}setColumn(e,n){let r=e*this.RANK;for(let o=0;o<this.RANK;++o)this[r+o]=n[o];return this}};function Wo(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function er(t,e){if(t===e){let n=e[1],r=e[2],o=e[3],i=e[6],a=e[7],c=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=c}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function tr(t,e){let n=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],u=e[6],_=e[7],p=e[8],d=e[9],m=e[10],x=e[11],P=e[12],g=e[13],A=e[14],L=e[15],v=n*c-r*a,y=n*u-o*a,w=n*_-i*a,b=r*u-o*c,S=r*_-i*c,k=o*_-i*u,I=p*g-d*P,F=p*A-m*P,N=p*L-x*P,M=d*A-m*g,U=d*L-x*g,C=m*L-x*A,E=v*C-y*U+w*M+b*N-S*F+k*I;return E?(E=1/E,t[0]=(c*C-u*U+_*M)*E,t[1]=(o*U-r*C-i*M)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*C-_*F)*E,t[5]=(n*C-o*N+i*F)*E,t[6]=(A*w-P*k-L*y)*E,t[7]=(p*k-m*w+x*y)*E,t[8]=(a*U-c*N+_*I)*E,t[9]=(r*N-n*U-i*I)*E,t[10]=(P*S-g*w+L*v)*E,t[11]=(d*w-p*S-x*v)*E,t[12]=(c*F-a*M-u*I)*E,t[13]=(n*M-r*F+o*I)*E,t[14]=(g*y-P*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function nr(t){let e=t[0],n=t[1],r=t[2],o=t[3],i=t[4],a=t[5],c=t[6],u=t[7],_=t[8],p=t[9],d=t[10],m=t[11],x=t[12],P=t[13],g=t[14],A=t[15],L=e*a-n*i,v=e*c-r*i,y=n*c-r*a,w=_*P-p*x,b=_*g-d*x,S=p*g-d*P,k=e*S-n*b+r*w,I=i*S-a*b+c*w,F=_*y-p*v+d*L,N=x*y-P*v+g*L;return u*k-o*I+A*F-m*N}function en(t,e,n){let r=e[0],o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],_=e[6],p=e[7],d=e[8],m=e[9],x=e[10],P=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=n[0],w=n[1],b=n[2],S=n[3];return t[0]=y*r+w*c+b*d+S*g,t[1]=y*o+w*u+b*m+S*A,t[2]=y*i+w*_+b*x+S*L,t[3]=y*a+w*p+b*P+S*v,y=n[4],w=n[5],b=n[6],S=n[7],t[4]=y*r+w*c+b*d+S*g,t[5]=y*o+w*u+b*m+S*A,t[6]=y*i+w*_+b*x+S*L,t[7]=y*a+w*p+b*P+S*v,y=n[8],w=n[9],b=n[10],S=n[11],t[8]=y*r+w*c+b*d+S*g,t[9]=y*o+w*u+b*m+S*A,t[10]=y*i+w*_+b*x+S*L,t[11]=y*a+w*p+b*P+S*v,y=n[12],w=n[13],b=n[14],S=n[15],t[12]=y*r+w*c+b*d+S*g,t[13]=y*o+w*u+b*m+S*A,t[14]=y*i+w*_+b*x+S*L,t[15]=y*a+w*p+b*P+S*v,t}function rr(t,e,n){let r=n[0],o=n[1],i=n[2],a,c,u,_,p,d,m,x,P,g,A,L;return e===t?(t[12]=e[0]*r+e[4]*o+e[8]*i+e[12],t[13]=e[1]*r+e[5]*o+e[9]*i+e[13],t[14]=e[2]*r+e[6]*o+e[10]*i+e[14],t[15]=e[3]*r+e[7]*o+e[11]*i+e[15]):(a=e[0],c=e[1],u=e[2],_=e[3],p=e[4],d=e[5],m=e[6],x=e[7],P=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=c,t[2]=u,t[3]=_,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=P,t[9]=g,t[10]=A,t[11]=L,t[12]=a*r+p*o+P*i+e[12],t[13]=c*r+d*o+g*i+e[13],t[14]=u*r+m*o+A*i+e[14],t[15]=_*r+x*o+L*i+e[15]),t}function or(t,e,n){let r=n[0],o=n[1],i=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ir(t,e,n,r){let o=r[0],i=r[1],a=r[2],c=Math.sqrt(o*o+i*i+a*a),u,_,p,d,m,x,P,g,A,L,v,y,w,b,S,k,I,F,N,M,U,C,E,pe;return c<1e-6?null:(c=1/c,o*=c,i*=c,a*=c,_=Math.sin(n),u=Math.cos(n),p=1-u,d=e[0],m=e[1],x=e[2],P=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],w=e[9],b=e[10],S=e[11],k=o*o*p+u,I=i*o*p+a*_,F=a*o*p-i*_,N=o*i*p-a*_,M=i*i*p+u,U=a*i*p+o*_,C=o*a*p+i*_,E=i*a*p-o*_,pe=a*a*p+u,t[0]=d*k+g*I+y*F,t[1]=m*k+A*I+w*F,t[2]=x*k+L*I+b*F,t[3]=P*k+v*I+S*F,t[4]=d*N+g*M+y*U,t[5]=m*N+A*M+w*U,t[6]=x*N+L*M+b*U,t[7]=P*N+v*M+S*U,t[8]=d*C+g*E+y*pe,t[9]=m*C+A*E+w*pe,t[10]=x*C+L*E+b*pe,t[11]=P*C+v*E+S*pe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function sr(t,e,n){let r=Math.sin(n),o=Math.cos(n),i=e[4],a=e[5],c=e[6],u=e[7],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+_*r,t[5]=a*o+p*r,t[6]=c*o+d*r,t[7]=u*o+m*r,t[8]=_*o-i*r,t[9]=p*o-a*r,t[10]=d*o-c*r,t[11]=m*o-u*r,t}function ar(t,e,n){let r=Math.sin(n),o=Math.cos(n),i=e[0],a=e[1],c=e[2],u=e[3],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-_*r,t[1]=a*o-p*r,t[2]=c*o-d*r,t[3]=u*o-m*r,t[8]=i*r+_*o,t[9]=a*r+p*o,t[10]=c*r+d*o,t[11]=u*r+m*o,t}function cr(t,e,n){let r=Math.sin(n),o=Math.cos(n),i=e[0],a=e[1],c=e[2],u=e[3],_=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+_*r,t[1]=a*o+p*r,t[2]=c*o+d*r,t[3]=u*o+m*r,t[4]=_*o-i*r,t[5]=p*o-a*r,t[6]=d*o-c*r,t[7]=m*o-u*r,t}function lr(t,e){let n=e[0],r=e[1],o=e[2],i=e[3],a=n+n,c=r+r,u=o+o,_=n*a,p=r*a,d=r*c,m=o*a,x=o*c,P=o*u,g=i*a,A=i*c,L=i*u;return t[0]=1-d-P,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-_-P,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-_-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fr(t,e,n,r,o,i,a){let c=1/(n-e),u=1/(o-r),_=1/(i-a);return t[0]=i*2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(n+e)*c,t[9]=(o+r)*u,t[10]=(a+i)*_,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*_,t[15]=0,t}function jo(t,e,n,r,o){let i=1/Math.tan(e/2);if(t[0]=i/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(r-o);t[10]=(o+r)*a,t[14]=2*o*r*a}else t[10]=-1,t[14]=-2*r;return t}var ur=jo;function $o(t,e,n,r,o,i,a){let c=1/(e-n),u=1/(r-o),_=1/(i-a);return t[0]=-2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*_,t[11]=0,t[12]=(e+n)*c,t[13]=(o+r)*u,t[14]=(a+i)*_,t[15]=1,t}var hr=$o;function _r(t,e,n,r){let o,i,a,c,u,_,p,d,m,x,P=e[0],g=e[1],A=e[2],L=r[0],v=r[1],y=r[2],w=n[0],b=n[1],S=n[2];return Math.abs(P-w)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?Wo(t):(d=P-w,m=g-b,x=A-S,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,_=x*i-d*c,p=d*a-m*i,o=Math.sqrt(u*u+_*_+p*p),o?(o=1/o,u*=o,_*=o,p*=o):(u=0,_=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=_,t[6]=m,t[7]=0,t[8]=c,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*P+a*g+c*A),t[13]=-(u*P+_*g+p*A),t[14]=-(d*P+m*g+x*A),t[15]=1,t)}function Ko(){let t=new V(4);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pr(t,e,n){let r=e[0],o=e[1],i=e[2],a=e[3];return t[0]=n[0]*r+n[4]*o+n[8]*i+n[12]*a,t[1]=n[1]*r+n[5]*o+n[9]*i+n[13]*a,t[2]=n[2]*r+n[6]*o+n[10]*i+n[14]*a,t[3]=n[3]*r+n[7]*o+n[11]*i+n[15]*a,t}var ca=function(){let t=Ko();return function(e,n,r,o,i,a){let c,u;for(n||(n=4),r||(r=0),o?u=Math.min(o*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],t[3]=e[c+3],i(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2],e[c+3]=t[3];return e}}();var rn;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(rn||(rn={}));var Zo=45*Math.PI/180,Jo=1,tn=.1,nn=500,ei=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends ot{static get IDENTITY(){return ni()}static get ZERO(){return ti()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rn}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,n,r,o,i,a,c,u,_,p,d,m,x,P,g,A){return this[0]=e,this[1]=n,this[2]=r,this[3]=o,this[4]=i,this[5]=a,this[6]=c,this[7]=u,this[8]=_,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=P,this[14]=g,this[15]=A,this.check()}setRowMajor(e,n,r,o,i,a,c,u,_,p,d,m,x,P,g,A){return this[0]=e,this[1]=i,this[2]=_,this[3]=x,this[4]=n,this[5]=a,this[6]=p,this[7]=P,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(ei)}fromObject(e){return this.check()}fromQuaternion(e){return lr(this,e),this.check()}frustum(e){let{left:n,right:r,bottom:o,top:i,near:a=tn,far:c=nn}=e;return c===1/0?ri(this,n,r,o,i,a):fr(this,n,r,o,i,a,c),this.check()}lookAt(e){let{eye:n,center:r=[0,0,0],up:o=[0,1,0]}=e;return _r(this,n,r,o),this.check()}ortho(e){let{left:n,right:r,bottom:o,top:i,near:a=tn,far:c=nn}=e;return hr(this,n,r,o,i,a,c),this.check()}orthographic(e){let{fovy:n=Zo,aspect:r=Jo,focalDistance:o=1,near:i=tn,far:a=nn}=e;dr(n);let c=n/2,u=o*Math.tan(c),_=u*r;return this.ortho({left:-_,right:_,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:n=45*Math.PI/180,aspect:r=1,near:o=.1,far:i=500}=e;return dr(n),ur(this,n,r,o,i),this.check()}determinant(){return nr(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,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),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,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),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 tr(this,this),this.check()}multiplyLeft(e){return en(this,e,this),this.check()}multiplyRight(e){return en(this,this,e),this.check()}rotateX(e){return sr(this,this,e),this.check()}rotateY(e){return ar(this,this,e),this.check()}rotateZ(e){return cr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,n){return ir(this,this,e,n),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,n){return e.length===4?(n=pr(n||[-0,-0,-0,-0],e,this),rt(n,4),n):this.transformAsPoint(e,n)}transformAsPoint(e,n){let{length:r}=e,o;switch(r){case 2:o=$n(n||[-0,-0],e,this);break;case 3:o=Jn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(o,e.length),o}transformAsVector(e,n){let r;switch(e.length){case 2:r=Kn(n||[-0,-0],e,this);break;case 3:r=Zn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(r,e.length),r}transformPoint(e,n){return this.transformAsPoint(e,n)}transformVector(e,n){return this.transformAsPoint(e,n)}transformDirection(e,n){return this.transformAsVector(e,n)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,n,r){return this.identity().translate([e,n,r])}},it,st;function ti(){return it||(it=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(it)),it}function ni(){return st||(st=new ee,Object.freeze(st)),st}function dr(t){if(t>Math.PI*2)throw Error("expected radians")}function ri(t,e,n,r,o,i){let a=2*i/(n-e),c=2*i/(o-r),u=(n+e)/(n-e),_=(o+r)/(o-r),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=u,t[9]=_,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var te=null,mr=new ArrayBuffer(4),gr=new Float32Array(mr),xr=new Uint32Array(mr);function vr(t){te||=br(),t=Zt(t,-65504,65504),gr[0]=t;let e=xr[0],n=e>>23&511;return te.baseTable[n]+((e&8388607)>>te.shiftTable[n])}function Ar(t){te||=br();let e=t>>10;return xr[0]=te.mantissaTable[te.offsetTable[e]+(t&1023)]+te.exponentTable[e],gr[0]}function br(){let t=new Uint32Array(512),e=new Uint32Array(512);for(let i=0;i<256;++i){let a=i-127;a<-27?(t[i]=0,t[i|256]=32768,e[i]=24,e[i|256]=24):a<-14?(t[i]=1024>>-a-14,t[i|256]=1024>>-a-14|32768,e[i]=-a-1,e[i|256]=-a-1):a<=15?(t[i]=a+15<<10,t[i|256]=a+15<<10|32768,e[i]=13,e[i|256]=13):a<128?(t[i]=31744,t[i|256]=64512,e[i]=24,e[i|256]=24):(t[i]=31744,t[i|256]=64512,e[i]=13,e[i|256]=13)}let n=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let i=1;i<1024;++i){let a=i<<13,c=0;for(;!(a&8388608);)a<<=1,c-=8388608;a&=-8388609,c+=947912704,n[i]=a|c}for(let i=1024;i<2048;++i)n[i]=939524096+(i-1024<<13);for(let i=1;i<31;++i)r[i]=i<<23;r[31]=1199570944,r[32]=2147483648;for(let i=33;i<63;++i)r[i]=2147483648+(i-32<<23);r[63]=3347054592;for(let i=1;i<64;++i)i!==32&&(o[i]=1024);return{baseTable:t,shiftTable:e,mantissaTable:n,exponentTable:r,offsetTable:o}}function he(t,e=[],n=0){let r=Math.fround(t),o=t-r;return e[n]=r,e[n+1]=o,e}function ke(t){return t-Math.fround(t)}function Te(t){let e=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let o=n*4+r;he(t[r*4+n],e,o*2)}return e}var oi=`float random(vec3 scale, float seed) {
103
+ `)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 n=s.simpleTokens[e];if(n)return this._addToken(n),!0;let r=s.none,i=this._isAlpha(e),o=e==="_";if(this._isAlphaNumeric(e)){let a=this._peekAhead();for(;this._isAlphaNumeric(a);)e+=this._advance(),a=this._peekAhead()}if(i){let a=s.keywords[e];if(a)return this._addToken(a),!0}if(i||o)return this._addToken(s.tokens.ident),!0;for(;;){let a=this._findType(e),c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let u=!1,_=this._tokens.length-1;for(let p=0;p<5&&_>=0;++p,--_)if(this._tokens[_].type===s.tokens.less_than){_>0&&this._tokens[_-1].isArrayOrTemplateType()&&(u=!0);break}if(u)return this._addToken(a),!0}if(a===s.none){let u=e,_=0,p=2;for(let d=0;d<p;++d)if(u+=this._peekAhead(d),a=this._findType(u),a!==s.none){_=d;break}if(a===s.none)return r===s.none?!1:(this._current--,this._addToken(r),!0);e=u,this._current+=_+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 i=s.regexTokens[r];if(this._match(e,i.rule))return i}let n=s.literalTokens[e];return n||s.none}_match(e,n){let r=n.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 n=this._source[this._current];return e=e||0,e++,this._current+=e,n}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let n=this._source.substring(this._start,this._current);this._tokens.push(new Ke(e,n,this._line))}},Gt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new dt,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let n=[];for(;!this._isAtEnd();){let r=this._global_decl_or_directive();if(!r)break;n.push(r)}if(this._deferArrayCountEval.length>0){for(let r of this._deferArrayCountEval){let i=r.arrayType,o=r.countNode;if(o instanceof Se){let c=o.name,u=this._context.constants.get(c);if(u)try{let _=u.evaluate(this._context);i.count=_}catch{}}}this._deferArrayCountEval.length=0}return n}_initialize(e){if(e)if(typeof e=="string"){let n=new Qt(e);this._tokens=n.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,n){return{token:e,message:n,toString:function(){return`${n}`}}}_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 n=0,r=e.length;n<r;++n){let i=e[n];if(this._check(i))return this._advance(),!0}return!1}_consume(e,n){if(this._check(e))return this._advance();throw this._error(this._peek(),n)}_check(e){if(this._isAtEnd())return!1;let n=this._peek();if(e instanceof Array){let r=n.type;return e.indexOf(r)!=-1}return n.type==e}_advance(){var e,n;return this._currentLine=(n=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&n!==void 0?n:-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 n=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.diagnostic)){let n=this._diagnostic();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.requires)){let n=this._requires_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),n}if(this._match(s.keywords.enable)){let n=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),n}let e=this._attribute();if(this._check(s.keywords.var)){let n=this._global_variable_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.override)){let n=this._override_variable_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.let)){let n=this._global_let_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.const)){let n=this._global_const_decl();return n!=null&&(n.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),n}if(this._check(s.keywords.struct)){let n=this._struct_decl();return n!=null&&(n.attributes=e),n}if(this._check(s.keywords.fn)){let n=this._function_decl();return n!=null&&(n.attributes=e),n}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=this._currentLine,n=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 _=this._attribute(),p=this._type_decl();p!=null&&(p.attributes=_,r.push(new Dt(u,p,c)))}while(this._match(s.tokens.comma));this._consume(s.tokens.paren_right,"Expected ')' after function arguments.");let i=null;if(this._match(s.tokens.arrow)){let c=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=c)}let o=this._compound_statement(),a=this._currentLine;return new we(n,r,i,o,e,a)}_compound_statement(){let e=[];for(this._consume(s.tokens.brace_left,"Expected '{' for block.");!this._check(s.tokens.brace_right);){let n=this._statement();n!==null&&e.push(n)}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 Et:this._match(s.keywords.break)?e=new Nt:this._match(s.keywords.continue)?e=new It: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 mt(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 n=this._compound_statement();return new gt(e,n)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new xt(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 n=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 i=this._compound_statement();return new vt(e,n,r,i)}_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 n=null;return this._match(s.tokens.equal)&&(n=this._short_circuit_or_expression()),new q(e.name,e.type,e.storage,e.access,n)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),n=null;if(this._match(s.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(s.tokens.equal,"Expected '=' for let.");let r=this._short_circuit_or_expression();return new Le(e,n,null,null,r)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),n=null;if(this._match(s.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(s.tokens.equal,"Expected '=' for const.");let r=this._short_circuit_or_expression();return new De(e,n,null,null,r)}return null}_increment_decrement_statement(){let e=this._current,n=this._unary_expression();if(n==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 At(r.type===s.tokens.plus_plus?le.increment:le.decrement,n)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let n=this._match(s.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e==null)return null;let r=this._consume(s.assignment_operators,"Expected assignment operator."),i=this._short_circuit_or_expression();return new bt(Pe.parse(r.lexeme),e,i)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,n=this._consume(s.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=e,null):new Be(n.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=[],n=this._statement();for(;n!==null;){if(Array.isArray(n))for(let i of n)e.push(i);else e.push(n);n=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 yt(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 n=this._switch_body();if(n==null||n.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new wt(e,n)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let n=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 Ut(n,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 n=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new zt(n))}if(this._check([s.keywords.default,s.keywords.case])){let n=this._switch_body();e.push(n[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 n=this._case_body();return n.length==0?e:[...e,n[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 n=this._compound_statement(),r=[];this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let i=null;return this._match(s.keywords.else)&&(this._check(s.tokens.attr)&&this._attribute(),i=this._compound_statement()),new Lt(e,n,r,i)}_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 n=this._optional_paren_expression(),r=this._compound_statement();return e.push(new Bt(n,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 z(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 z(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 z(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 z(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new z(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 z(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 z(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 z(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 z(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 z(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 Ot(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),n=this._postfix_expression();return n&&(e.postfix=n),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 n=new Rt(e),r=this._postfix_expression();return r&&(n.postfix=r),n}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),n=this._postfix_expression(),r=new Ge(e.lexeme);return n&&(r.postfix=n),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 i=this._argument_expression_list(),o=this._getStruct(r);return o!=null?new $(o,i):new qe(r,i)}if(this._context.constants.has(r)){let i=this._context.constants.get(r);return new He(r,i.value)}return new Se(r)}if(this._match(s.const_literal))return new Ve(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 i=this._paren_expression();return new Mt(r,i)}let e=this._type_decl(),n=this._argument_expression_list();return new Ct(e,n)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let n=this._short_circuit_or_expression();e.push(n)}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 We([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 We([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=this._currentLine,n=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(),_=this._type_decl();_!=null&&(_.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 Xt(c,_,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let i=this._currentLine,o=new G(n,r,e,i);return this._context.structs.set(n,o),o}_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"),n=null;if(this._match(s.tokens.colon)){let o=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=o)}let r=null;if(this._match(s.tokens.equal)){let o=this._short_circuit_or_expression();if(o instanceof $)r=o;else if(o instanceof He&&o.initializer instanceof $)r=o.initializer;else try{let a=o.evaluate(this._context);r=new Ve(a)}catch{r=o}}let i=new De(e.toString(),n,"","",r);return this._context.constants.set(i.name,i),i}_global_let_decl(){if(!this._match(s.keywords.let))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),n=null;if(this._match(s.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}let r=null;return this._match(s.tokens.equal)&&(r=this._const_expression()),new Le(e.toString(),n,"","",r)}_const_expression(){if(this._match(s.const_literal))return new Ge(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let n=[];for(;!this._check(s.tokens.paren_right)&&(n.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new $(e,n)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",n="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(n=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"),i=null;if(this._match(s.tokens.colon)){let o=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=o)}return new q(r.toString(),i,e,n,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),n=null;if(this._match(s.tokens.colon)){let r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}return new ze(e.toString(),n,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 n=this._consume(s.tokens.ident,"Expected diagnostic rule name.");return this._consume(s.tokens.paren_right,"Expected ')'"),new Tt(e.toString(),n.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new St(e.toString())}_requires_directive(){let e=[this._consume(s.tokens.ident,"identity expected.").toString()];for(;this._match(s.tokens.comma);){let n=this._consume(s.tokens.ident,"identity expected.");e.push(n.toString())}return new kt(e)}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let n=this._type_decl();if(n===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let r=new Xe(e.toString(),n);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(),i=r.toString();return this._context.structs.has(i)?this._context.structs.get(i):this._context.aliases.has(i)?this._context.aliases.get(i).type:new H(r.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(s.template_types)){let r=this._advance().toString(),i=null,o=null;return this._match(s.tokens.less_than)&&(i=this._type_decl(),o=null,this._match(s.tokens.comma)&&(o=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for type.")),new Ye(r,i,o)}if(this._match(s.keywords.ptr)){let r=this._previous().toString();this._consume(s.tokens.less_than,"Expected '<' for pointer.");let i=this._consume(s.storage_class,"Expected storage_class for pointer");this._consume(s.tokens.comma,"Expected ',' for pointer.");let o=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 Ft(r,i.toString(),o,a)}let n=this._attribute();if(this._match(s.keywords.array)){let r=null,i=-1,o=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."),i=u?parseInt(u):0}let c=new Qe(o.toString(),n,r,i);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 n=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),n,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let n=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(),n,r)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let n=this._consume(s.attribute_name,"Expected attribute name"),r=new Yt(n.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 i=this._consume(s.literal_or_ident,"Expected attribute value").toString();r.value instanceof Array||(r.value=[r.value]),r.value.push(i)}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,n){this.name=e,this.attributes=n,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Ze=class{constructor(e,n,r){this.name=e,this.type=n,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}},ie=class extends K{constructor(e,n){super(e,n),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},ye=class extends K{constructor(e,n){super(e,n),this.count=0,this.stride=0}get isArray(){return!0}},Je=class extends K{constructor(e,n,r,i){super(e,r),this.format=n,this.access=i}get isTemplate(){return!0}},j;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(j||(j={}));var oe=class{constructor(e,n,r,i,o,a,c){this.name=e,this.type=n,this.group=r,this.binding=i,this.attributes=o,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,n){this.name=e,this.type=n}},se=class{constructor(e,n){this.align=e,this.size=n}},Ht=class{constructor(e,n,r,i){this.name=e,this.type=n,this.locationType=r,this.location=i,this.interpolation=null}},et=class{constructor(e,n,r,i){this.name=e,this.type=n,this.locationType=r,this.location=i}},Vt=class{constructor(e,n=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=n}},Wt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},jt=class{constructor(e,n,r,i){this.name=e,this.type=n,this.attributes=r,this.id=i}},$t=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},D=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 Gt().parse(e);for(let i of r)i instanceof we&&this._functions.set(i.name,new $t(i));for(let i of r)if(i instanceof G){let o=this._getTypeInfo(i,null);o instanceof ie&&this.structs.push(o)}for(let i of r){if(i instanceof Xe){this.aliases.push(this._getAliasInfo(i));continue}if(i instanceof ze){let o=i,a=this._getAttributeNum(o.attributes,"id",0),c=o.type!=null?this._getTypeInfo(o.type,o.attributes):null;this.overrides.push(new jt(o.name,c,o.attributes,a));continue}if(this._isUniformVar(i)){let o=i,a=this._getAttributeNum(o.attributes,"group",0),c=this._getAttributeNum(o.attributes,"binding",0),u=this._getTypeInfo(o.type,o.attributes),_=new oe(o.name,u,a,c,o.attributes,j.Uniform,o.access);this.uniforms.push(_);continue}if(this._isStorageVar(i)){let o=i,a=this._getAttributeNum(o.attributes,"group",0),c=this._getAttributeNum(o.attributes,"binding",0),u=this._getTypeInfo(o.type,o.attributes),_=this._isStorageTexture(u),p=new oe(o.name,u,a,c,o.attributes,_?j.StorageTexture:j.Storage,o.access);this.storage.push(p);continue}if(this._isTextureVar(i)){let o=i,a=this._getAttributeNum(o.attributes,"group",0),c=this._getAttributeNum(o.attributes,"binding",0),u=this._getTypeInfo(o.type,o.attributes),_=this._isStorageTexture(u),p=new oe(o.name,u,a,c,o.attributes,_?j.StorageTexture:j.Texture,o.access);_?this.storage.push(p):this.textures.push(p);continue}if(this._isSamplerVar(i)){let o=i,a=this._getAttributeNum(o.attributes,"group",0),c=this._getAttributeNum(o.attributes,"binding",0),u=this._getTypeInfo(o.type,o.attributes),_=new oe(o.name,u,a,c,o.attributes,j.Sampler,o.access);this.samplers.push(_);continue}if(i instanceof we){let o=this._getAttribute(i,"vertex"),a=this._getAttribute(i,"fragment"),c=this._getAttribute(i,"compute"),u=o||a||c,_=new Vt(i.name,u?.name);_.startLine=i.startLine,_.endLine=i.endLine,this.functions.push(_),this._functions.get(i.name).info=_,u&&(this._functions.get(i.name).inUse=!0,_.inUse=!0,_.resources=this._findResources(i,!!u),_.inputs=this._getInputs(i.args),_.outputs=this._getOutputs(i.returnType),this.entry[u.name].push(_));continue}}for(let i of this._functions.values())i.info&&(i.info.inUse=i.inUse,this._addCalls(i.node,i.info.calls));for(let i of this.uniforms)this._markStructsInUse(i.type);for(let i of this.storage)this._markStructsInUse(i.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(let n of e.members)this._markStructsInUse(n.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let n=this._getAlias(e.name);n&&this._markStructsInUse(n)}}_addCalls(e,n){var r;for(let i of e.calls){let o=(r=this._functions.get(i.name))===null||r===void 0?void 0:r.info;o&&n.add(o)}}findResource(e,n){for(let r of this.uniforms)if(r.group==e&&r.binding==n)return r;for(let r of this.storage)if(r.group==e&&r.binding==n)return r;for(let r of this.textures)if(r.group==e&&r.binding==n)return r;for(let r of this.samplers)if(r.group==e&&r.binding==n)return r;return null}_findResource(e){for(let n of this.uniforms)if(n.name==e)return n;for(let n of this.storage)if(n.name==e)return n;for(let n of this.textures)if(n.name==e)return n;for(let n of this.samplers)if(n.name==e)return n;return null}_markStructsFromAST(e){let n=this._getTypeInfo(e,null);this._markStructsInUse(n)}_findResources(e,n){let r=[],i=this,o=[];return e.search(a=>{if(a instanceof ae)o.push({});else if(a instanceof ce)o.pop();else if(a instanceof q){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type),o.length>0&&(o[o.length-1][c.name]=c)}else if(a instanceof $){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type)}else if(a instanceof Le){let c=a;n&&c.type!==null&&this._markStructsFromAST(c.type),o.length>0&&(o[o.length-1][c.name]=c)}else if(a instanceof Se){let c=a;if(o.length>0&&o[o.length-1][c.name])return;let u=i._findResource(c.name);u&&r.push(u)}else if(a instanceof qe){let c=a,u=i._functions.get(c.name);u&&(n&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=i._findResources(u.node,n)),r.push(...u.resources))}else if(a instanceof Be){let c=a,u=i._functions.get(c.name);u&&(n&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=i._findResources(u.node,n)),r.push(...u.resources))}}),[...new Map(r.map(a=>[a.name,a])).values()]}getBindGroups(){let e=[];function n(r,i){r>=e.length&&(e.length=r+1),e[r]===void 0&&(e[r]=[]),i>=e[r].length&&(e[r].length=i+1)}for(let r of this.uniforms){n(r.group,r.binding);let i=e[r.group];i[r.binding]=r}for(let r of this.storage){n(r.group,r.binding);let i=e[r.group];i[r.binding]=r}for(let r of this.textures){n(r.group,r.binding);let i=e[r.group];i[r.binding]=r}for(let r of this.samplers){n(r.group,r.binding);let i=e[r.group];i[r.binding]=r}return e}_getOutputs(e,n=void 0){if(n===void 0&&(n=[]),e instanceof G)this._getStructOutputs(e,n);else{let r=this._getOutputInfo(e);r!==null&&n.push(r)}return n}_getStructOutputs(e,n){for(let r of e.members)if(r.type instanceof G)this._getStructOutputs(r.type,n);else{let i=this._getAttribute(r,"location")||this._getAttribute(r,"builtin");if(i!==null){let o=this._getTypeInfo(r.type,r.type.attributes),a=this._parseInt(i.value),c=new et(r.name,o,i.name,a);n.push(c)}}}_getOutputInfo(e){let n=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(n!==null){let r=this._getTypeInfo(e,e.attributes),i=this._parseInt(n.value);return new et("",r,n.name,i)}return null}_getInputs(e,n=void 0){n===void 0&&(n=[]);for(let r of e)if(r.type instanceof G)this._getStructInputs(r.type,n);else{let i=this._getInputInfo(r);i!==null&&n.push(i)}return n}_getStructInputs(e,n){for(let r of e.members)if(r.type instanceof G)this._getStructInputs(r.type,n);else{let i=this._getInputInfo(r);i!==null&&n.push(i)}}_getInputInfo(e){let n=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(n!==null){let r=this._getAttribute(e,"interpolation"),i=this._getTypeInfo(e.type,e.attributes),o=this._parseInt(n.value),a=new Ht(e.name,i,n.name,o);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 n=parseInt(e);return isNaN(n)?e:n}_getAlias(e){for(let n of this.aliases)if(n.name==e)return n.type;return null}_getAliasInfo(e){return new qt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,n){if(this._types.has(e))return this._types.get(e);if(e instanceof Qe){let i=e,o=this._getTypeInfo(i.format,i.attributes),a=new ye(i.name,n);return a.format=o,a.count=i.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof G){let i=e,o=new ie(i.name,n);o.startLine=i.startLine,o.endLine=i.endLine;for(let a of i.members){let c=this._getTypeInfo(a.type,a.attributes);o.members.push(new Ze(a.name,c,a.attributes))}return this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof J){let i=e,o=i.format instanceof H,a=i.format?o?this._getTypeInfo(i.format,null):new K(i.format,null):null,c=new Je(i.name,a,n,i.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Ye){let i=e,o=i.format?this._getTypeInfo(i.format,null):null,a=new Je(i.name,o,n,i.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let r=new K(e.name,n);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var n,r;let i=this._getTypeSize(e);if(e.size=(n=i?.size)!==null&&n!==void 0?n:0,e instanceof ye){let o=this._getTypeSize(e.format);e.stride=(r=o?.size)!==null&&r!==void 0?r:0,this._updateTypeInfo(e.format)}e instanceof ie&&this._updateStructInfo(e)}_updateStructInfo(e){var n;let r=0,i=0,o=0,a=0;for(let c=0,u=e.members.length;c<u;++c){let _=e.members[c],p=this._getTypeSize(_);if(!p)continue;(n=this._getAlias(_.type.name))!==null&&n!==void 0||_.type;let d=p.align,m=p.size;r=this._roundUp(d,r+i),i=m,o=r,a=Math.max(a,d),_.offset=r,_.size=m,this._updateTypeInfo(_.type)}e.size=this._roundUp(a,o+i),e.align=a}_getTypeSize(e){var n;if(e==null)return null;let r=this._getAttributeNum(e.attributes,"size",0),i=this._getAttributeNum(e.attributes,"align",0);if(e instanceof Ze&&(e=e.type),e instanceof K){let o=this._getAlias(e.name);o!==null&&(e=o)}{let o=D._typeInfo[e.name];if(o!==void 0){let a=e.format==="f16"?2:1;return new se(Math.max(i,o.align/a),Math.max(r,o.size/a))}}{let o=D._typeInfo[e.name.substring(0,e.name.length-1)];if(o){let a=e.name[e.name.length-1]==="h"?2:1;return new se(Math.max(i,o.align/a),Math.max(r,o.size/a))}}if(e instanceof ye){let o=e,a=8,c=8,u=this._getTypeSize(o.format);u!==null&&(c=u.size,a=u.align);let _=o.count,p=this._getAttributeNum((n=e?.attributes)!==null&&n!==void 0?n:null,"stride",this._roundUp(a,c));return c=_*p,r&&(c=r),new se(Math.max(i,a),Math.max(r,c))}if(e instanceof ie){let o=0,a=0,c=0,u=0,_=0;for(let p of e.members){let d=this._getTypeSize(p.type);d!==null&&(o=Math.max(d.align,o),c=this._roundUp(d.align,c+u),u=d.size,_=c)}return a=this._roundUp(o,_+u),new se(Math.max(i,o),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof q&&e.storage=="uniform"}_isStorageVar(e){return e instanceof q&&e.storage=="storage"}_isTextureVar(e){return e instanceof q&&e.type!==null&&D._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof q&&e.type!==null&&D._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,n){let r=e;if(!r||!r.attributes)return null;let i=r.attributes;for(let o of i)if(o.name==n)return o;return null}_getAttributeNum(e,n,r){if(e===null)return r;for(let i of e)if(i.name==n){let o=i!==null&&i.value!==null?i.value:r;return o instanceof Array&&(o=o[0]),typeof o=="number"?o:typeof o=="string"?parseInt(o):r}return r}_roundUp(e,n){return Math.ceil(n/e)*e}};D._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}};D._textureTypes=s.any_texture_type.map(t=>t.name);D._samplerTypes=s.sampler_type.map(t=>t.name);function Hn(t){let e={attributes:[],bindings:[]},n;try{n=Xi(t)}catch(o){return qn.log.error(o.message)(),e}for(let o of n.uniforms){let a=[];for(let c of o.type?.members||[])a.push({name:c.name,type:Gn(c.type)});e.bindings.push({type:"uniform",name:o.name,location:o.binding,group:o.group,members:a})}let r=n.entry.vertex[0],i=r?.inputs.length||0;for(let o=0;o<i;o++){let a=r.inputs[o];if(a.locationType==="location"){let c=Gn(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Gn(t){return t.format?`${t.name}<${t.format.name}>`:t.name}function Xi(t){try{return new D(t)}catch(e){if(e instanceof Error)throw e;let n="WGSL parse error";throw typeof e=="object"&&e?.message&&(n+=`: ${e.message} `),typeof e=="object"&&e?.token&&(n+=e.token.line||""),new Error(n,{cause:e})}}var Vs=1/Math.PI*180,Ws=1/180*Math.PI,Yi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Yi}};var R=globalThis.mathgl.config;function Kt(t,{precision:e=R.precision}={}){return t=Qi(t),`${parseFloat(t.toPrecision(e))}`}function fe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zt(t,e,n){return qi(t,r=>Math.max(e,Math.min(n,r)))}function tt(t,e,n){let r=R.EPSILON;n&&(R.EPSILON=n);try{if(t===e)return!0;if(fe(t)&&fe(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(!tt(t[i],e[i]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=R.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{R.EPSILON=r}}function Qi(t){return Math.round(t/R.EPSILON)*R.EPSILON}function Gi(t){return t.clone?t.clone():new Array(t.length)}function qi(t,e,n){if(fe(t)){let r=t;n=n||Gi(r);for(let i=0;i<n.length&&i<r.length;++i){let o=typeof t=="number"?t:t[i];n[i]=e(o,i,n)}return n}return e(t)}var nt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+n];return this.check()}toArray(e=[],n=0){for(let r=0;r<this.ELEMENTS;++r)e[n+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:fe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(e){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Kt(this[r],e);return`${e.printTypes?this.constructor.name:""}[${n}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!tt(this[n],e[n]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==e[n])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,n,r){if(r===void 0)return this.lerp(this,e,n);for(let i=0;i<this.ELEMENTS;++i){let o=e[i],a=typeof n=="number"?n:n[i];this[i]=o+r*(a-o)}return this.check()}min(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(e[n],this[n]);return this.check()}max(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(e[n],this[n]);return this.check()}clamp(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),n[r]);return this.check()}add(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(e){if(typeof e=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;else for(let n=0;n<this.ELEMENTS&&n<e.length;++n)this[n]*=e[n];return this.check()}multiplyByScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}check(){if(R.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 n=0;n<this.ELEMENTS;++n)e=e&&Number.isFinite(this[n]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=e;return this.check()}addScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),n);return this.check()}get elements(){return this}};function Hi(t,e){if(t.length!==e)return!1;for(let n=0;n<t.length;++n)if(!Number.isFinite(t[n]))return!1;return!0}function Vn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function rt(t,e,n=""){if(R.debug&&!Hi(t,e))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return t}var V=typeof Float32Array<"u"?Float32Array:Array;var ea=Math.PI/180;function Vi(){let t=new V(2);return V!=Float32Array&&(t[0]=0,t[1]=0),t}function $n(t,e,n){let r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t}var ta=function(){let t=Vi();return function(e,n,r,i,o,a){let c,u;for(n||(n=2),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],o(t,t,a),e[c]=t[0],e[c+1]=t[1];return e}}();function Kn(t,e,n){let r=e[0],i=e[1],o=n[3]*r+n[7]*i||1;return t[0]=(n[0]*r+n[4]*i)/o,t[1]=(n[1]*r+n[5]*i)/o,t}function Zn(t,e,n){let r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o||1;return t[0]=(n[0]*r+n[4]*i+n[8]*o)/a,t[1]=(n[1]*r+n[5]*i+n[9]*o)/a,t[2]=(n[2]*r+n[6]*i+n[10]*o)/a,t}function Wi(){let t=new V(3);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Jn(t,e,n){let r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}var ia=function(){let t=Wi();return function(e,n,r,i,o,a){let c,u;for(n||(n=3),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],o(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2];return e}}();var it=class extends nt{toString(){let e="[";if(R.printRowMajor){e+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+n]}`}else{e+="column-major:";for(let n=0;n<this.ELEMENTS;++n)e+=` ${this[n]}`}return e+="]",e}getElementIndex(e,n){return n*this.RANK+e}getElement(e,n){return this[n*this.RANK+e]}setElement(e,n,r){return this[n*this.RANK+e]=Vn(r),this}getColumn(e,n=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let i=0;i<this.RANK;++i)n[i]=this[r+i];return n}setColumn(e,n){let r=e*this.RANK;for(let i=0;i<this.RANK;++i)this[r+i]=n[i];return this}};function ji(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function er(t,e){if(t===e){let n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],c=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=c}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function tr(t,e){let n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],_=e[7],p=e[8],d=e[9],m=e[10],x=e[11],L=e[12],g=e[13],A=e[14],P=e[15],v=n*c-r*a,y=n*u-i*a,w=n*_-o*a,b=r*u-i*c,S=r*_-o*c,k=i*_-o*u,F=p*g-d*L,I=p*A-m*L,E=p*P-x*L,M=d*A-m*g,U=d*P-x*g,C=m*P-x*A,N=v*C-y*U+w*M+b*E-S*I+k*F;return N?(N=1/N,t[0]=(c*C-u*U+_*M)*N,t[1]=(i*U-r*C-o*M)*N,t[2]=(g*k-A*S+P*b)*N,t[3]=(m*S-d*k-x*b)*N,t[4]=(u*E-a*C-_*I)*N,t[5]=(n*C-i*E+o*I)*N,t[6]=(A*w-L*k-P*y)*N,t[7]=(p*k-m*w+x*y)*N,t[8]=(a*U-c*E+_*F)*N,t[9]=(r*E-n*U-o*F)*N,t[10]=(L*S-g*w+P*v)*N,t[11]=(d*w-p*S-x*v)*N,t[12]=(c*I-a*M-u*F)*N,t[13]=(n*M-r*I+i*F)*N,t[14]=(g*y-L*b-A*v)*N,t[15]=(p*b-d*y+m*v)*N,t):null}function nr(t){let e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],_=t[8],p=t[9],d=t[10],m=t[11],x=t[12],L=t[13],g=t[14],A=t[15],P=e*a-n*o,v=e*c-r*o,y=n*c-r*a,w=_*L-p*x,b=_*g-d*x,S=p*g-d*L,k=e*S-n*b+r*w,F=o*S-a*b+c*w,I=_*y-p*v+d*P,E=x*y-L*v+g*P;return u*k-i*F+A*I-m*E}function en(t,e,n){let r=e[0],i=e[1],o=e[2],a=e[3],c=e[4],u=e[5],_=e[6],p=e[7],d=e[8],m=e[9],x=e[10],L=e[11],g=e[12],A=e[13],P=e[14],v=e[15],y=n[0],w=n[1],b=n[2],S=n[3];return t[0]=y*r+w*c+b*d+S*g,t[1]=y*i+w*u+b*m+S*A,t[2]=y*o+w*_+b*x+S*P,t[3]=y*a+w*p+b*L+S*v,y=n[4],w=n[5],b=n[6],S=n[7],t[4]=y*r+w*c+b*d+S*g,t[5]=y*i+w*u+b*m+S*A,t[6]=y*o+w*_+b*x+S*P,t[7]=y*a+w*p+b*L+S*v,y=n[8],w=n[9],b=n[10],S=n[11],t[8]=y*r+w*c+b*d+S*g,t[9]=y*i+w*u+b*m+S*A,t[10]=y*o+w*_+b*x+S*P,t[11]=y*a+w*p+b*L+S*v,y=n[12],w=n[13],b=n[14],S=n[15],t[12]=y*r+w*c+b*d+S*g,t[13]=y*i+w*u+b*m+S*A,t[14]=y*o+w*_+b*x+S*P,t[15]=y*a+w*p+b*L+S*v,t}function rr(t,e,n){let r=n[0],i=n[1],o=n[2],a,c,u,_,p,d,m,x,L,g,A,P;return e===t?(t[12]=e[0]*r+e[4]*i+e[8]*o+e[12],t[13]=e[1]*r+e[5]*i+e[9]*o+e[13],t[14]=e[2]*r+e[6]*i+e[10]*o+e[14],t[15]=e[3]*r+e[7]*i+e[11]*o+e[15]):(a=e[0],c=e[1],u=e[2],_=e[3],p=e[4],d=e[5],m=e[6],x=e[7],L=e[8],g=e[9],A=e[10],P=e[11],t[0]=a,t[1]=c,t[2]=u,t[3]=_,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=L,t[9]=g,t[10]=A,t[11]=P,t[12]=a*r+p*i+L*o+e[12],t[13]=c*r+d*i+g*o+e[13],t[14]=u*r+m*i+A*o+e[14],t[15]=_*r+x*i+P*o+e[15]),t}function ir(t,e,n){let r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function or(t,e,n,r){let i=r[0],o=r[1],a=r[2],c=Math.sqrt(i*i+o*o+a*a),u,_,p,d,m,x,L,g,A,P,v,y,w,b,S,k,F,I,E,M,U,C,N,pe;return c<1e-6?null:(c=1/c,i*=c,o*=c,a*=c,_=Math.sin(n),u=Math.cos(n),p=1-u,d=e[0],m=e[1],x=e[2],L=e[3],g=e[4],A=e[5],P=e[6],v=e[7],y=e[8],w=e[9],b=e[10],S=e[11],k=i*i*p+u,F=o*i*p+a*_,I=a*i*p-o*_,E=i*o*p-a*_,M=o*o*p+u,U=a*o*p+i*_,C=i*a*p+o*_,N=o*a*p-i*_,pe=a*a*p+u,t[0]=d*k+g*F+y*I,t[1]=m*k+A*F+w*I,t[2]=x*k+P*F+b*I,t[3]=L*k+v*F+S*I,t[4]=d*E+g*M+y*U,t[5]=m*E+A*M+w*U,t[6]=x*E+P*M+b*U,t[7]=L*E+v*M+S*U,t[8]=d*C+g*N+y*pe,t[9]=m*C+A*N+w*pe,t[10]=x*C+P*N+b*pe,t[11]=L*C+v*N+S*pe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function sr(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],c=e[6],u=e[7],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+_*r,t[5]=a*i+p*r,t[6]=c*i+d*r,t[7]=u*i+m*r,t[8]=_*i-o*r,t[9]=p*i-a*r,t[10]=d*i-c*r,t[11]=m*i-u*r,t}function ar(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],c=e[2],u=e[3],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-_*r,t[1]=a*i-p*r,t[2]=c*i-d*r,t[3]=u*i-m*r,t[8]=o*r+_*i,t[9]=a*r+p*i,t[10]=c*r+d*i,t[11]=u*r+m*i,t}function cr(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],c=e[2],u=e[3],_=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+_*r,t[1]=a*i+p*r,t[2]=c*i+d*r,t[3]=u*i+m*r,t[4]=_*i-o*r,t[5]=p*i-a*r,t[6]=d*i-c*r,t[7]=m*i-u*r,t}function lr(t,e){let n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,c=r+r,u=i+i,_=n*a,p=r*a,d=r*c,m=i*a,x=i*c,L=i*u,g=o*a,A=o*c,P=o*u;return t[0]=1-d-L,t[1]=p+P,t[2]=m-A,t[3]=0,t[4]=p-P,t[5]=1-_-L,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-_-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fr(t,e,n,r,i,o,a){let c=1/(n-e),u=1/(i-r),_=1/(o-a);return t[0]=o*2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*u,t[6]=0,t[7]=0,t[8]=(n+e)*c,t[9]=(i+r)*u,t[10]=(a+o)*_,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*_,t[15]=0,t}function $i(t,e,n,r,i){let o=1/Math.tan(e/2);if(t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let a=1/(r-i);t[10]=(i+r)*a,t[14]=2*i*r*a}else t[10]=-1,t[14]=-2*r;return t}var ur=$i;function Ki(t,e,n,r,i,o,a){let c=1/(e-n),u=1/(r-i),_=1/(o-a);return t[0]=-2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*_,t[11]=0,t[12]=(e+n)*c,t[13]=(i+r)*u,t[14]=(a+o)*_,t[15]=1,t}var hr=Ki;function _r(t,e,n,r){let i,o,a,c,u,_,p,d,m,x,L=e[0],g=e[1],A=e[2],P=r[0],v=r[1],y=r[2],w=n[0],b=n[1],S=n[2];return Math.abs(L-w)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?ji(t):(d=L-w,m=g-b,x=A-S,i=1/Math.sqrt(d*d+m*m+x*x),d*=i,m*=i,x*=i,o=v*x-y*m,a=y*d-P*x,c=P*m-v*d,i=Math.sqrt(o*o+a*a+c*c),i?(i=1/i,o*=i,a*=i,c*=i):(o=0,a=0,c=0),u=m*c-x*a,_=x*o-d*c,p=d*a-m*o,i=Math.sqrt(u*u+_*_+p*p),i?(i=1/i,u*=i,_*=i,p*=i):(u=0,_=0,p=0),t[0]=o,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=_,t[6]=m,t[7]=0,t[8]=c,t[9]=p,t[10]=x,t[11]=0,t[12]=-(o*L+a*g+c*A),t[13]=-(u*L+_*g+p*A),t[14]=-(d*L+m*g+x*A),t[15]=1,t)}function Zi(){let t=new V(4);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pr(t,e,n){let r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}var ua=function(){let t=Zi();return function(e,n,r,i,o,a){let c,u;for(n||(n=4),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],t[3]=e[c+3],o(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2],e[c+3]=t[3];return e}}();var rn;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(rn||(rn={}));var Ji=45*Math.PI/180,eo=1,tn=.1,nn=500,to=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends it{static get IDENTITY(){return ro()}static get ZERO(){return no()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rn}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,n,r,i,o,a,c,u,_,p,d,m,x,L,g,A){return this[0]=e,this[1]=n,this[2]=r,this[3]=i,this[4]=o,this[5]=a,this[6]=c,this[7]=u,this[8]=_,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=L,this[14]=g,this[15]=A,this.check()}setRowMajor(e,n,r,i,o,a,c,u,_,p,d,m,x,L,g,A){return this[0]=e,this[1]=o,this[2]=_,this[3]=x,this[4]=n,this[5]=a,this[6]=p,this[7]=L,this[8]=r,this[9]=c,this[10]=d,this[11]=g,this[12]=i,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(to)}fromObject(e){return this.check()}fromQuaternion(e){return lr(this,e),this.check()}frustum(e){let{left:n,right:r,bottom:i,top:o,near:a=tn,far:c=nn}=e;return c===1/0?io(this,n,r,i,o,a):fr(this,n,r,i,o,a,c),this.check()}lookAt(e){let{eye:n,center:r=[0,0,0],up:i=[0,1,0]}=e;return _r(this,n,r,i),this.check()}ortho(e){let{left:n,right:r,bottom:i,top:o,near:a=tn,far:c=nn}=e;return hr(this,n,r,i,o,a,c),this.check()}orthographic(e){let{fovy:n=Ji,aspect:r=eo,focalDistance:i=1,near:o=tn,far:a=nn}=e;dr(n);let c=n/2,u=i*Math.tan(c),_=u*r;return this.ortho({left:-_,right:_,bottom:-u,top:u,near:o,far:a})}perspective(e){let{fovy:n=45*Math.PI/180,aspect:r=1,near:i=.1,far:o=500}=e;return dr(n),ur(this,n,r,i,o),this.check()}determinant(){return nr(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,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),i=1/r[0],o=1/r[1],a=1/r[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*i,e[5]=this[5]*o,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*i,e[9]=this[9]*o,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),i=1/r[0],o=1/r[1],a=1/r[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*a,e[3]=this[4]*i,e[4]=this[5]*o,e[5]=this[6]*a,e[6]=this[8]*i,e[7]=this[9]*o,e[8]=this[10]*a,e}transpose(){return er(this,this),this.check()}invert(){return tr(this,this),this.check()}multiplyLeft(e){return en(this,e,this),this.check()}multiplyRight(e){return en(this,this,e),this.check()}rotateX(e){return sr(this,this,e),this.check()}rotateY(e){return ar(this,this,e),this.check()}rotateZ(e){return cr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,n){return or(this,this,e,n),this.check()}scale(e){return ir(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return rr(this,this,e),this.check()}transform(e,n){return e.length===4?(n=pr(n||[-0,-0,-0,-0],e,this),rt(n,4),n):this.transformAsPoint(e,n)}transformAsPoint(e,n){let{length:r}=e,i;switch(r){case 2:i=$n(n||[-0,-0],e,this);break;case 3:i=Jn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(i,e.length),i}transformAsVector(e,n){let r;switch(e.length){case 2:r=Kn(n||[-0,-0],e,this);break;case 3:r=Zn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(r,e.length),r}transformPoint(e,n){return this.transformAsPoint(e,n)}transformVector(e,n){return this.transformAsPoint(e,n)}transformDirection(e,n){return this.transformAsVector(e,n)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,n,r){return this.identity().translate([e,n,r])}},ot,st;function no(){return ot||(ot=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ot)),ot}function ro(){return st||(st=new ee,Object.freeze(st)),st}function dr(t){if(t>Math.PI*2)throw Error("expected radians")}function io(t,e,n,r,i,o){let a=2*o/(n-e),c=2*o/(i-r),u=(n+e)/(n-e),_=(i+r)/(i-r),p=-1,d=-1,m=-2*o;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=u,t[9]=_,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var te=null,mr=new ArrayBuffer(4),gr=new Float32Array(mr),xr=new Uint32Array(mr);function vr(t){te||=br(),t=Zt(t,-65504,65504),gr[0]=t;let e=xr[0],n=e>>23&511;return te.baseTable[n]+((e&8388607)>>te.shiftTable[n])}function Ar(t){te||=br();let e=t>>10;return xr[0]=te.mantissaTable[te.offsetTable[e]+(t&1023)]+te.exponentTable[e],gr[0]}function br(){let t=new Uint32Array(512),e=new Uint32Array(512);for(let o=0;o<256;++o){let a=o-127;a<-27?(t[o]=0,t[o|256]=32768,e[o]=24,e[o|256]=24):a<-14?(t[o]=1024>>-a-14,t[o|256]=1024>>-a-14|32768,e[o]=-a-1,e[o|256]=-a-1):a<=15?(t[o]=a+15<<10,t[o|256]=a+15<<10|32768,e[o]=13,e[o|256]=13):a<128?(t[o]=31744,t[o|256]=64512,e[o]=24,e[o|256]=24):(t[o]=31744,t[o|256]=64512,e[o]=13,e[o|256]=13)}let n=new Uint32Array(2048),r=new Uint32Array(64),i=new Uint32Array(64);for(let o=1;o<1024;++o){let a=o<<13,c=0;for(;!(a&8388608);)a<<=1,c-=8388608;a&=-8388609,c+=947912704,n[o]=a|c}for(let o=1024;o<2048;++o)n[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)r[o]=o<<23;r[31]=1199570944,r[32]=2147483648;for(let o=33;o<63;++o)r[o]=2147483648+(o-32<<23);r[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(i[o]=1024);return{baseTable:t,shiftTable:e,mantissaTable:n,exponentTable:r,offsetTable:i}}function he(t,e=[],n=0){let r=Math.fround(t),i=t-r;return e[n]=r,e[n+1]=i,e}function ke(t){return t-Math.fround(t)}function Te(t){let e=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let i=n*4+r;he(t[r*4+n],e,i*2)}return e}var oo=`float random(vec3 scale, float seed) {
105
104
  /* use the fragment position for a different seed per-pixel */
106
105
  return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
107
106
  }
108
- `,Q={name:"random",fs:oi};var ii=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
107
+ `,Q={name:"random",fs:oo};var so=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
109
108
 
110
109
  // All these functions are for substituting tan() function from Intel GPU only
111
110
  const float TWO_PI = 6.2831854820251465;
@@ -255,7 +254,7 @@ float tan_fp32(float a) {
255
254
  return tan(a);
256
255
  #endif
257
256
  }
258
- `,yr={name:"fp32",vs:ii};var si=new Float32Array([0,1,1,1]),ai=`uniform pickingUniforms {
257
+ `,yr={name:"fp32",vs:so};var ao=new Float32Array([0,1,1,1]),co=`uniform pickingUniforms {
259
258
  float isActive;
260
259
  float isAttribute;
261
260
  float isHighlightActive;
@@ -326,7 +325,7 @@ void picking_setPickingAttribute(vec3 value) {
326
325
  picking_vRGBcolor_Avalid.rgb = value;
327
326
  }
328
327
  }
329
- `,ci=`uniform pickingUniforms {
328
+ `,lo=`uniform pickingUniforms {
330
329
  float isActive;
331
330
  float isAttribute;
332
331
  float isHighlightActive;
@@ -382,7 +381,7 @@ vec4 picking_filterColor(vec4 color) {
382
381
  vec4 highlightColor = picking_filterHighlightColor(color);
383
382
  return picking_filterPickingColor(highlightColor);
384
383
  }
385
- `,wr={props:{},uniforms:{},name:"picking",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:new Float32Array([0,0,0]),highlightColor:si},vs:ai,fs:ci,getUniforms:li};function li(t={},e){let n={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)n.isHighlightActive=!1;else{n.isHighlightActive=!0;let r=t.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=r}if(t.highlightColor){let r=Array.from(t.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),n.highlightColor=r}return t.isActive!==void 0&&(n.isActive=Boolean(t.isActive),n.isAttribute=Boolean(t.isAttribute)),t.useFloatColors!==void 0&&(n.useFloatColors=Boolean(t.useFloatColors)),n}var on=`precision highp int;
384
+ `,wr={props:{},uniforms:{},name:"picking",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:new Float32Array([0,0,0]),highlightColor:ao},vs:co,fs:lo,getUniforms:fo};function fo(t={},e){let n={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)n.isHighlightActive=!1;else{n.isHighlightActive=!0;let r=t.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=r}if(t.highlightColor){let r=Array.from(t.highlightColor,i=>i/255);Number.isFinite(r[3])||(r[3]=1),n.highlightColor=r}return t.isActive!==void 0&&(n.isActive=Boolean(t.isActive),n.isAttribute=Boolean(t.isAttribute)),t.useFloatColors!==void 0&&(n.useFloatColors=Boolean(t.useFloatColors)),n}var on=`precision highp int;
386
385
 
387
386
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
388
387
  struct AmbientLight {
@@ -433,12 +432,89 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
433
432
  }
434
433
 
435
434
  // #endif
436
- `;var fi=5,ui=255,Ne;(function(t){t[t.POINT=0]="POINT",t[t.DIRECTIONAL=1]="DIRECTIONAL"})(Ne||(Ne={}));var X={props:{},uniforms:{},name:"lighting",defines:{MAX_LIGHTS:fi},uniformTypes:{enabled:"i32",ambientLightColor:"vec3<f32>",numberOfLights:"i32",lightType:"i32",lightColor:"vec3<f32>",lightPosition:"vec3<f32>",lightDirection:"vec3<f32>",lightAttenuation:"vec3<f32>"},defaultUniforms:{enabled:1,ambientLightColor:[.1,.1,.1],numberOfLights:0,lightType:Ne.POINT,lightColor:[1,1,1],lightPosition:[1,1,2],lightDirection:[1,1,1],lightAttenuation:[1,1,1]},vs:on,fs:on,getUniforms:hi};function hi(t,e={}){if(t=t&&{...t},!t)return{...X.defaultUniforms};t.lights&&(t={...t,...pi(t.lights),lights:void 0});let{ambientLight:n,pointLights:r,directionalLights:o}=t||{};if(!(n||r&&r.length>0||o&&o.length>0))return{...X.defaultUniforms,enabled:0};let a={...X.defaultUniforms,...e,..._i({ambientLight:n,pointLights:r,directionalLights:o})};return t.enabled!==void 0&&(a.enabled=t.enabled?1:0),a}function _i({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};r.ambientLightColor=sn(t);let o=0;for(let i of e)r.lightType=Ne.POINT,r.lightColor=sn(i),r.lightPosition=i.position,r.lightAttenuation=[i.attenuation||1,0,0],o++;for(let i of n)r.lightType=Ne.DIRECTIONAL,r.lightColor=sn(i),r.lightPosition=i.position,r.lightDirection=i.direction,o++;return r.numberOfLights=o,r}function pi(t){let e={pointLights:[],directionalLights:[]};for(let n of t||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;default:}return e}function sn(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/ui)}var di=`out vec3 dirlight_vNormal;
435
+ `;var Lr=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
436
+ struct AmbientLight {
437
+ color: vec3<f32>,
438
+ };
439
+
440
+ struct PointLight {
441
+ color: vec3<f32>,
442
+ position: vec3<f32>,
443
+ attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
444
+ };
445
+
446
+ struct DirectionalLight {
447
+ color: vec3<f32>,
448
+ direction: vec3<f32>,
449
+ };
450
+
451
+ struct lightingUniforms {
452
+ enabled: i32,
453
+ poightCount: i32,
454
+ directionalLightCount: i32,
455
+
456
+ ambientColor: vec3<f32>,
457
+
458
+ // TODO - support multiple lights by uncommenting arrays below
459
+ lightType: i32,
460
+ lightColor: vec3<f32>,
461
+ lightDirection: vec3<f32>,
462
+ lightPosition: vec3<f32>,
463
+ lightAttenuation: vec3<f32>,
464
+
465
+ // AmbientLight ambientLight;
466
+ // PointLight pointLight[MAX_LIGHTS];
467
+ // DirectionalLight directionalLight[MAX_LIGHTS];
468
+ };
469
+
470
+ // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
471
+ @binding(1) @group(0) var<uniform> lighting : lightingUniforms;
472
+
473
+ fn lighting_getPointLight(index: i32) -> PointLight {
474
+ return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
475
+ }
476
+
477
+ fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
478
+ return DirectionalLight(lighting.lightColor, lighting.lightDirection);
479
+ }
480
+
481
+ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
482
+ return pointLight.attenuation.x
483
+ + pointLight.attenuation.y * distance
484
+ + pointLight.attenuation.z * distance * distance;
485
+ }
486
+ `;var uo=5,ho=255,Ee;(function(t){t[t.POINT=0]="POINT",t[t.DIRECTIONAL=1]="DIRECTIONAL"})(Ee||(Ee={}));var X={props:{},uniforms:{},name:"lighting",defines:{MAX_LIGHTS:uo},uniformTypes:{enabled:"i32",ambientLightColor:"vec3<f32>",numberOfLights:"i32",lightType:"i32",lightColor:"vec3<f32>",lightPosition:"vec3<f32>",lightDirection:"vec3<f32>",lightAttenuation:"vec3<f32>"},defaultUniforms:{enabled:1,ambientLightColor:[.1,.1,.1],numberOfLights:0,lightType:Ee.POINT,lightColor:[1,1,1],lightPosition:[1,1,2],lightDirection:[1,1,1],lightAttenuation:[1,1,1]},source:Lr,vs:on,fs:on,getUniforms:_o};function _o(t,e={}){if(t=t&&{...t},!t)return{...X.defaultUniforms};t.lights&&(t={...t,...mo(t.lights),lights:void 0});let{ambientLight:n,pointLights:r,directionalLights:i}=t||{};if(!(n||r&&r.length>0||i&&i.length>0))return{...X.defaultUniforms,enabled:0};let a={...X.defaultUniforms,...e,...po({ambientLight:n,pointLights:r,directionalLights:i})};return t.enabled!==void 0&&(a.enabled=t.enabled?1:0),a}function po({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};r.ambientLightColor=sn(t);let i=0;for(let o of e)r.lightType=Ee.POINT,r.lightColor=sn(o),r.lightPosition=o.position,r.lightAttenuation=[o.attenuation||1,0,0],i++;for(let o of n)r.lightType=Ee.DIRECTIONAL,r.lightColor=sn(o),r.lightPosition=o.position,r.lightDirection=o.direction,i++;return r.numberOfLights=i,r}function mo(t){let e={pointLights:[],directionalLights:[]};for(let n of t||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;default:}return e}function sn(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/ho)}var go=`
487
+ struct dirlightUniforms {
488
+ lightDirection: vec3<f32>,
489
+ };
490
+
491
+ alias DirlightNormal = vec3<f32>;
492
+
493
+ struct DirlightInputs {
494
+ normal: DirlightNormal,
495
+ };
496
+
497
+ @binding(1) @group(0) var<uniform> dirlight : dirlightUniforms;
498
+
499
+ // For vertex
500
+ fn dirlight_setNormal(normal: vec3<f32>) -> DirlightNormal {
501
+ return normalize(normal);
502
+ }
503
+
504
+ // Returns color attenuated by angle from light source
505
+ fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
506
+ // TODO - fix default light direction
507
+ // let lightDirection = dirlight.lightDirection;
508
+ let lightDirection = vec3<f32>(1, 1, 1);
509
+ let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
510
+ return vec4<f32>(color.rgb * d, color.a);
511
+ }
512
+ `,xo=`out vec3 dirlight_vNormal;
437
513
 
438
514
  void dirlight_setNormal(vec3 normal) {
439
515
  dirlight_vNormal = normalize(normal);
440
516
  }
441
- `,mi=`uniform dirlightUniforms {
517
+ `,vo=`uniform dirlightUniforms {
442
518
  vec3 lightDirection;
443
519
  } dirlight;
444
520
 
@@ -449,13 +525,13 @@ vec4 dirlight_filterColor(vec4 color) {
449
525
  float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
450
526
  return vec4(color.rgb * d, color.a);
451
527
  }
452
- `,an={props:{},uniforms:{},name:"dirlight",dependencies:[],vs:di,fs:mi,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:new Float32Array([1,1,2])},getUniforms:gi};function gi(t=an.defaultUniforms){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var Pr=`uniform materialUniforms {
528
+ `,an={props:{},uniforms:{},name:"dirlight",dependencies:[],source:go,vs:xo,fs:vo,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:new Float32Array([1,1,2])},getUniforms:Ao};function Ao(t=an.defaultUniforms){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var Pr=`uniform materialUniforms {
453
529
  uniform float ambient;
454
530
  uniform float diffuse;
455
531
  uniform float shininess;
456
532
  uniform vec3 specularColor;
457
533
  } material;
458
- `,Lr=`uniform materialUniforms {
534
+ `,Sr=`uniform materialUniforms {
459
535
  uniform float ambient;
460
536
  uniform float diffuse;
461
537
  uniform float shininess;
@@ -536,13 +612,98 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
536
612
  }
537
613
  return lightColor;
538
614
  }
539
- `;var cn={props:{},uniforms:{},name:"gouraud-lighting",vs:Pr,fs:Lr,defines:{LIGHTING_VERTEX:1},dependencies:[X],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){return{...cn.defaultUniforms,...t}}};var Sr=`uniform phongMaterialUniforms {
615
+ `;var cn={props:{},uniforms:{},name:"gouraud-lighting",vs:Pr,fs:Sr,defines:{LIGHTING_VERTEX:1},dependencies:[X],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){return{...cn.defaultUniforms,...t}}};var kr=`struct phongMaterialUniforms {
616
+ ambient: f32,
617
+ diffuse: f32,
618
+ shininess: f32,
619
+ specularColor: vec3<f32>,
620
+ };
621
+
622
+ @binding(2) @group(0) var<uniform> material : phongMaterialUniforms;
623
+
624
+ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
625
+ let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
626
+ var lambertian: f32 = dot(light_direction, normal_worldspace);
627
+ var specular: f32 = 0.0;
628
+ if (lambertian > 0.0) {
629
+ let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
630
+ specular = pow(specular_angle, material.shininess);
631
+ }
632
+ lambertian = max(lambertian, 0.0);
633
+ return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
634
+ }
635
+
636
+ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
637
+ var lightColor: vec3<f32> = surfaceColor;
638
+
639
+ if (lighting.enabled == 0) {
640
+ return lightColor;
641
+ }
642
+
643
+ let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);
644
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
645
+
646
+ if (lighting.lightType == 0) {
647
+ let pointLight: PointLight = lighting_getPointLight(0);
648
+ let light_position_worldspace: vec3<f32> = pointLight.position;
649
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
650
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
651
+ } else if (lighting.lightType == 1) {
652
+ var directionalLight: DirectionalLight = lighting_getDirectionalLight(0);
653
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
654
+ }
655
+
656
+ return lightColor;
657
+ /*
658
+ for (int i = 0; i < MAX_LIGHTS; i++) {
659
+ if (i >= lighting.pointLightCount) {
660
+ break;
661
+ }
662
+ PointLight pointLight = lighting.pointLight[i];
663
+ vec3 light_position_worldspace = pointLight.position;
664
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
665
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
666
+ }
667
+
668
+ for (int i = 0; i < MAX_LIGHTS; i++) {
669
+ if (i >= lighting.directionalLightCount) {
670
+ break;
671
+ }
672
+ DirectionalLight directionalLight = lighting.directionalLight[i];
673
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
674
+ }
675
+ */
676
+ }
677
+
678
+ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{
679
+ var lightColor = vec3<f32>(0, 0, 0);
680
+ let surfaceColor = vec3<f32>(0, 0, 0);
681
+
682
+ if (lighting.enabled == 0) {
683
+ let view_direction = normalize(cameraPosition - position_worldspace);
684
+
685
+ switch (lighting.lightType) {
686
+ case 0, default: {
687
+ let pointLight: PointLight = lighting_getPointLight(0);
688
+ let light_position_worldspace: vec3<f32> = pointLight.position;
689
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
690
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
691
+ }
692
+ case 1: {
693
+ let directionalLight: DirectionalLight = lighting_getDirectionalLight(0);
694
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
695
+ }
696
+ }
697
+ }
698
+ return lightColor;
699
+ }
700
+ `;var Tr=`uniform phongMaterialUniforms {
540
701
  uniform float ambient;
541
702
  uniform float diffuse;
542
703
  uniform float shininess;
543
704
  uniform vec3 specularColor;
544
705
  } material;
545
- `,kr=`uniform phongMaterialUniforms {
706
+ `,Er=`uniform phongMaterialUniforms {
546
707
  uniform float ambient;
547
708
  uniform float diffuse;
548
709
  uniform float shininess;
@@ -626,7 +787,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
626
787
  }
627
788
  return lightColor;
628
789
  }
629
- `;var ln={props:{},uniforms:{},name:"phong-lighting",dependencies:[X],vs:Sr,fs:kr,defines:{LIGHTING_FRAGMENT:1},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){return{...ln.defaultUniforms,...t}}};var Tr=`uniform projection {
790
+ `;var ln={props:{},uniforms:{},name:"phong-lighting",dependencies:[X],source:kr,vs:Tr,fs:Er,defines:{LIGHTING_FRAGMENT:1},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){return{...ln.defaultUniforms,...t}}};var Nr=`uniform projection {
630
791
  mat4 u_MVPMatrix;
631
792
  mat4 u_ModelMatrix;
632
793
  mat4 u_NormalMatrix;
@@ -667,7 +828,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
667
828
  pbr_vUV = vec2(0.,0.);
668
829
  #endif
669
830
  }
670
- `;var Nr=`precision highp float;
831
+ `;var Ir=`precision highp float;
671
832
 
672
833
  uniform Projection {
673
834
  // Projection
@@ -1072,7 +1233,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
1072
1233
 
1073
1234
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
1074
1235
  }
1075
- `;var Er={props:{},uniforms:{},name:"pbr",dependencies:[X],vs:Tr,fs:Nr,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>"},bindings:{baseColorSampler:{type:"texture",location:8},normalSampler:{type:"texture",location:9},emissiveSampler:{type:"texture",location:10},metallicRoughnessSampler:{type:"texture",location:11},occlusionSampler:{type:"texture",location:12},diffuseEnvSampler:{type:"texture",location:13},specularEnvSampler:{type:"texture",location:14},brdfLUT:{type:"texture",location:15}}};var xi=`
1236
+ `;var Fr={props:{},uniforms:{},name:"pbr",dependencies:[X],vs:Nr,fs:Ir,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>"},bindings:{baseColorSampler:{type:"texture",location:8},normalSampler:{type:"texture",location:9},emissiveSampler:{type:"texture",location:10},metallicRoughnessSampler:{type:"texture",location:11},occlusionSampler:{type:"texture",location:12},diffuseEnvSampler:{type:"texture",location:13},specularEnvSampler:{type:"texture",location:14},brdfLUT:{type:"texture",location:15}}};var bo=`
1076
1237
  uniform brightnessContrastUniforms {
1077
1238
  float brightness;
1078
1239
  float contrast;
@@ -1091,7 +1252,7 @@ vec4 brightnessContrast_filterColor(vec4 color) {
1091
1252
  vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
1092
1253
  return brightnessContrast_filterColor(color);
1093
1254
  }
1094
- `,Fr={props:{},uniforms:{},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:xi,passes:[{filter:!0}]};var vi=`uniform denoiseUniforms {
1255
+ `,Mr={props:{},uniforms:{},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:bo,passes:[{filter:!0}]};var yo=`uniform denoiseUniforms {
1095
1256
  float strength;
1096
1257
  } noise;
1097
1258
 
@@ -1113,7 +1274,7 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1113
1274
 
1114
1275
  return color / total;
1115
1276
  }
1116
- `,Ir={props:{},uniforms:{},name:"denoise",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:vi,passes:[{sampler:!0},{sampler:!0}]};var Ai=`uniform hueSaturationUniforms {
1277
+ `,Cr={props:{},uniforms:{},name:"denoise",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:yo,passes:[{sampler:!0},{sampler:!0}]};var wo=`uniform hueSaturationUniforms {
1117
1278
  float hue;
1118
1279
  float saturation;
1119
1280
  } hueSaturation;
@@ -1144,7 +1305,7 @@ vec4 hueSaturation_filterColor(vec4 color) {
1144
1305
  vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1145
1306
  return hueSaturation_filterColor(color);
1146
1307
  }
1147
- `,Mr={props:{},uniforms:{},name:"hueSaturation",fs:Ai,uniformTypes:{hue:"f32",saturation:"f32"},uniformPropTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},passes:[{filter:!0}]};var bi=`uniform noiseUniforms {
1308
+ `,Rr={props:{},uniforms:{},name:"hueSaturation",fs:wo,uniformTypes:{hue:"f32",saturation:"f32"},uniformPropTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},passes:[{filter:!0}]};var Lo=`uniform noiseUniforms {
1148
1309
  float amount;
1149
1310
  } noise;
1150
1311
 
@@ -1163,7 +1324,7 @@ vec4 noise_filterColor(vec4 color, vec2 texCoord) {
1163
1324
  vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1164
1325
  return noise_filterColor(color, texCoord);
1165
1326
  }
1166
- `,Cr={props:{},uniforms:{},name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:bi,passes:[{filter:!0}]};var yi=`uniform sepiaUniforms {
1327
+ `,Or={props:{},uniforms:{},name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Lo,passes:[{filter:!0}]};var Po=`uniform sepiaUniforms {
1167
1328
  float amount;
1168
1329
  } sepia;
1169
1330
 
@@ -1183,7 +1344,7 @@ vec4 sepia_filterColor(vec4 color) {
1183
1344
  vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1184
1345
  return sepia_filterColor(color);
1185
1346
  }
1186
- `,Rr={props:{},uniforms:{},name:"sepia",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:yi,passes:[{filter:!0}]};var wi=`uniform vibranceUniforms {
1347
+ `,Ur={props:{},uniforms:{},name:"sepia",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Po,passes:[{filter:!0}]};var So=`uniform vibranceUniforms {
1187
1348
  float amount;
1188
1349
  } vibrance;
1189
1350
 
@@ -1198,7 +1359,7 @@ vec4 vibrance_filterColor(vec4 color) {
1198
1359
  vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1199
1360
  return vibrance_filterColor(color);
1200
1361
  }
1201
- `,Or={props:{},uniforms:{},name:"vibrance",uniformPropTypes:{amount:{value:0,min:-1,max:1}},fs:wi,passes:[{filter:!0}]};var Pi=`uniform vignetteUniforms {
1362
+ `,zr={props:{},uniforms:{},name:"vibrance",uniformPropTypes:{amount:{value:0,min:-1,max:1}},fs:So,passes:[{filter:!0}]};var ko=`uniform vignetteUniforms {
1202
1363
  float radius;
1203
1364
  float amount;
1204
1365
  } vignette;
@@ -1212,7 +1373,7 @@ vec4 vignette_filterColor(vec4 color, vec2 texCoord) {
1212
1373
  vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1213
1374
  return vignette_filterColor(color, texCoord);
1214
1375
  }
1215
- `,Ur={props:{},uniforms:{},name:"vignette",uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}],fs:Pi};var Li=`uniform tiltShiftUniforms {
1376
+ `,Dr={props:{},uniforms:{},name:"vignette",uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}],fs:ko};var To=`uniform tiltShiftUniforms {
1216
1377
  float blurRadius;
1217
1378
  float gradientRadius;
1218
1379
  vec2 start;
@@ -1255,7 +1416,7 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1255
1416
 
1256
1417
  return color;
1257
1418
  }
1258
- `,zr={props:{},uniforms:{},name:"tiltShift",dependencies:[Q],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}}],fs:Li};var Si=`uniform triangleBlurUniforms {
1419
+ `,Br={props:{},uniforms:{},name:"tiltShift",dependencies:[Q],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}}],fs:To};var Eo=`uniform triangleBlurUniforms {
1259
1420
  float radius;
1260
1421
  vec2 delta;
1261
1422
  } triangleBlur;
@@ -1288,7 +1449,7 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1288
1449
 
1289
1450
  return color;
1290
1451
  }
1291
- `,Dr={props:{},uniforms:{},name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},uniformPropTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Si,dependencies:[Q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var ki=`
1452
+ `,Xr={props:{},uniforms:{},name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},uniformPropTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Eo,dependencies:[Q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var No=`
1292
1453
  uniform zoomBlurUniforms {
1293
1454
  vec2 center;
1294
1455
  float strength;
@@ -1321,7 +1482,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1321
1482
 
1322
1483
  return color;
1323
1484
  }
1324
- `,Br={props:{},uniforms:{},name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:ki,dependencies:[Q],passes:[{sampler:!0}]};var Ti=`uniform colorHalftoneUniforms {
1485
+ `,Yr={props:{},uniforms:{},name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:No,dependencies:[Q],passes:[{sampler:!0}]};var Io=`uniform colorHalftoneUniforms {
1325
1486
  vec2 center;
1326
1487
  float angle;
1327
1488
  float size;
@@ -1355,7 +1516,7 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1355
1516
  k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
1356
1517
  return vec4(1.0 - cmy - k, color.a);
1357
1518
  }
1358
- `,Xr={props:{},uniforms:{},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 {
1519
+ `,Qr={props:{},uniforms:{},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:Io,passes:[{filter:!0}]};var Fo=`uniform dotScreenUniforms {
1359
1520
  vec2 center;
1360
1521
  float angle;
1361
1522
  float size;
@@ -1377,7 +1538,7 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
1377
1538
  float average = (color.r + color.g + color.b) / 3.0;
1378
1539
  return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
1379
1540
  }
1380
- `,Yr={props:{},uniforms:{},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 Ei=`uniform edgeWorkUniforms {
1541
+ `,Gr={props:{},uniforms:{},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:Fo,passes:[{filter:!0}]};var Mo=`uniform edgeWorkUniforms {
1381
1542
  float radius;
1382
1543
  vec2 delta;
1383
1544
  } edgeWork;
@@ -1431,7 +1592,7 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
1431
1592
  float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
1432
1593
  return vec4(c, c, c, 1.0);
1433
1594
  }
1434
- `,Qr={props:{},uniforms:{},name:"edgeWork",dependencies:[Q],fs:Ei,uniformPropTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},passes:[{sampler:"edgeWork_sampleColor1",uniformPropTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",uniformPropTypes:{delta:[0,1]}}]};var Fi=`uniform hexagonalPixelateUniforms {
1595
+ `,qr={props:{},uniforms:{},name:"edgeWork",dependencies:[Q],fs:Mo,uniformPropTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},passes:[{sampler:"edgeWork_sampleColor1",uniformPropTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",uniformPropTypes:{delta:[0,1]}}]};var Co=`uniform hexagonalPixelateUniforms {
1435
1596
  vec2 center;
1436
1597
  float scale;
1437
1598
  } hexagonalPixelate;
@@ -1473,7 +1634,7 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
1473
1634
 
1474
1635
  return texture(source, choice + hexagonalPixelate.center);
1475
1636
  }
1476
- `,qr={props:{},uniforms:{},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:Fi,passes:[{sampler:!0}]};var Ii=`uniform inkUniforms {
1637
+ `,Hr={props:{},uniforms:{},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:Co,passes:[{sampler:!0}]};var Ro=`uniform inkUniforms {
1477
1638
  float strength;
1478
1639
  } ink;
1479
1640
 
@@ -1500,7 +1661,7 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1500
1661
  float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
1501
1662
  return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
1502
1663
  }
1503
- `,Gr={props:{},uniforms:{},name:"ink",fs:Ii,uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{value:.25,min:0,softMax:1}},passes:[{sampler:!0}]};var Mi=`uniform magnifyUniforms {
1664
+ `,Vr={props:{},uniforms:{},name:"ink",fs:Ro,uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{value:.25,min:0,softMax:1}},passes:[{sampler:!0}]};var Oo=`uniform magnifyUniforms {
1504
1665
  vec2 screenXY;
1505
1666
  float radiusPixels;
1506
1667
  float zoom;
@@ -1520,7 +1681,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1520
1681
  }
1521
1682
  return texture(source, texCoord);
1522
1683
  }
1523
- `,Hr={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:Mi,passes:[{sampler:!0}]};var Ci=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1684
+ `,Wr={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:Oo,passes:[{sampler:!0}]};var Uo=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1524
1685
  vec4 color = texture(source, coord / texSize);
1525
1686
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
1526
1687
  if (coord != clampedCoord) {
@@ -1530,7 +1691,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1530
1691
 
1531
1692
  return color;
1532
1693
  }
1533
- `,_e={name:"warp",passes:[],fs:Ci};var Ri=`uniform bulgePinchUniforms {
1694
+ `,_e={name:"warp",passes:[],fs:Uo};var zo=`uniform bulgePinchUniforms {
1534
1695
  float radius;
1535
1696
  float strength;
1536
1697
  vec2 center;
@@ -1557,7 +1718,7 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1557
1718
 
1558
1719
  return warp_sampleColor(source, texSize, coord);
1559
1720
  }
1560
- `,Vr={props:{},uniforms:{},name:"bulgePinch",dependencies:[_e],fs:Ri,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}},passes:[{sampler:!0}]};var Oi=`uniform swirlUniforms {
1721
+ `,jr={props:{},uniforms:{},name:"bulgePinch",dependencies:[_e],fs:zo,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}},passes:[{sampler:!0}]};var Do=`uniform swirlUniforms {
1561
1722
  float radius;
1562
1723
  float angle;
1563
1724
  vec2 center;
@@ -1586,7 +1747,7 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1586
1747
 
1587
1748
  return warp_sampleColor(source, texSize, coord);
1588
1749
  }
1589
- `,Wr={props:{},uniforms:{},name:"swirl",dependencies:[_e],fs:Oi,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}},passes:[{sampler:!0}]};var Ui=`
1750
+ `,$r={props:{},uniforms:{},name:"swirl",dependencies:[_e],fs:Do,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}},passes:[{sampler:!0}]};var Bo=`
1590
1751
  #define FXAA_QUALITY_PRESET 29
1591
1752
 
1592
1753
  #if (FXAA_QUALITY_PRESET == 10)
@@ -2166,7 +2327,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
2166
2327
  fxaa_QualityEdgeThresholdMin
2167
2328
  );
2168
2329
  }
2169
- `,jr={name:"fxaa",uniformPropTypes:{},fs:Ui,passes:[{sampler:!0}],getUniforms:t=>t};var $r=`uniform float ONE;
2330
+ `,Kr={name:"fxaa",uniformPropTypes:{},fs:Bo,passes:[{sampler:!0}],getUniforms:t=>t};var Zr=`uniform float ONE;
2170
2331
 
2171
2332
  /*
2172
2333
  About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
@@ -2331,7 +2492,7 @@ vec2 sqrt_fp64(vec2 a) {
2331
2492
  return sum_fp64(vec2(yn, 0.0), prod);
2332
2493
  #endif
2333
2494
  }
2334
- `;var Kr=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
2495
+ `;var Jr=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
2335
2496
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
2336
2497
  const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
2337
2498
  const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
@@ -3000,7 +3161,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
3000
3161
  vec4_dot_fp64(a, tmp, out_val[i]);
3001
3162
  }
3002
3163
  }
3003
- `;var zi={ONE:1};function Di(){return zi}var fn={name:"fp64-arithmetic",vs:$r,getUniforms:Di,fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te},Zr={name:"fp64",vs:Kr,dependencies:[fn],fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te};var Bi=`varying vec4 geometry_vPosition;
3164
+ `;var Xo={ONE:1};function Yo(){return Xo}var fn={name:"fp64-arithmetic",vs:Zr,getUniforms:Yo,fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te},ei={name:"fp64",vs:Jr,dependencies:[fn],fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te};var Qo=`varying vec4 geometry_vPosition;
3004
3165
  varying vec3 geometry_vNormal;
3005
3166
 
3006
3167
  void geometry_setNormal(vec3 normal) {
@@ -3014,7 +3175,7 @@ void geometry_setPosition(vec4 position) {
3014
3175
  void geometry_setPosition(vec3 position) {
3015
3176
  geometry_vPosition = vec4(position, 1.);
3016
3177
  }
3017
- `,Xi=`varying vec4 geometry_vPosition;
3178
+ `,Go=`varying vec4 geometry_vPosition;
3018
3179
  varying vec3 geometry_vNormal;
3019
3180
 
3020
3181
  vec4 geometry_getPosition() {
@@ -3024,7 +3185,7 @@ vec4 geometry_getPosition() {
3024
3185
  vec3 geometry_getNormal() {
3025
3186
  return geometry_vNormal;
3026
3187
  }
3027
- `,Jr={name:"geometry",vs:Bi,fs:Xi};var un=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Yi={modelMatrix:un,viewMatrix:un,projectionMatrix:un,cameraPositionWorld:[0,0,0]};function Qi(t=Yi,e={}){let n={};return t.modelMatrix!==void 0&&(n.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(n.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(n.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(n.cameraPositionWorld=t.cameraPositionWorld),t.projectionMatrix!==void 0&&t.viewMatrix!==void 0&&(n.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),n}var eo=`varying vec4 project_vPositionWorld;
3188
+ `,ti={name:"geometry",vs:Qo,fs:Go};var un=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],qo={modelMatrix:un,viewMatrix:un,projectionMatrix:un,cameraPositionWorld:[0,0,0]};function Ho(t=qo,e={}){let n={};return t.modelMatrix!==void 0&&(n.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(n.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(n.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(n.cameraPositionWorld=t.cameraPositionWorld),t.projectionMatrix!==void 0&&t.viewMatrix!==void 0&&(n.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),n}var ni=`varying vec4 project_vPositionWorld;
3028
3189
  varying vec3 project_vNormalWorld;
3029
3190
 
3030
3191
  vec4 project_getPosition_World() {
@@ -3034,7 +3195,7 @@ vec4 project_getPosition_World() {
3034
3195
  vec3 project_getNormal_World() {
3035
3196
  return project_vNormalWorld;
3036
3197
  }
3037
- `,qi=`${eo}
3198
+ `,Vo=`${ni}
3038
3199
 
3039
3200
  // Unprefixed uniforms
3040
3201
  uniform mat4 modelMatrix;
@@ -3087,8 +3248,8 @@ vec4 project_view_to_clipspace(vec3 position) {
3087
3248
  vec4 project_to_clipspace(vec3 position) {
3088
3249
  return viewProjectionMatrix * vec4(position, 1.);
3089
3250
  }
3090
- `,Gi=`
3091
- ${eo}`,at={name:"project",getUniforms:Qi,vs:qi,fs:Gi};var hn=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3251
+ `,Wo=`
3252
+ ${ni}`,at={name:"project",getUniforms:Ho,vs:Vo,fs:Wo};var hn=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3092
3253
 
3093
3254
  struct AmbientLight {
3094
3255
  vec3 color;
@@ -3122,7 +3283,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
3122
3283
  }
3123
3284
 
3124
3285
  #endif
3125
- `;var Hi={lightSources:{}};function _n(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/255)}function Vi({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};return t?r["lighting_uAmbientLight.color"]=_n(t):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,n.forEach((o,i)=>{r[`lighting_uDirectionalLight[${i}].color`]=_n(o),r[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),r.lighting_uDirectionalLightCount=n.length,r}function to(t=Hi){if("lightSources"in t){let{ambientLight:e,pointLights:n,directionalLights:r}=t.lightSources||{};return e||n&&n.length>0||r&&r.length>0?Object.assign({},Vi({ambientLight:e,pointLights:n,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let n of t.lights||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;default:}return to({lightSources:e})}return{}}var ne={name:"lights",vs:hn,fs:hn,getUniforms:to,defines:{MAX_LIGHTS:3}};var Wi={lightDirection:new Float32Array([1,1,2])};function ji(t=Wi){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var $i=`uniform vec3 dirlight_uLightDirection;
3286
+ `;var jo={lightSources:{}};function _n(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/255)}function $o({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};return t?r["lighting_uAmbientLight.color"]=_n(t):r["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((i,o)=>{r[`lighting_uPointLight[${o}].color`]=_n(i),r[`lighting_uPointLight[${o}].position`]=i.position,r[`lighting_uPointLight[${o}].attenuation`]=i.attenuation||[1,0,0]}),r.lighting_uPointLightCount=e.length,n.forEach((i,o)=>{r[`lighting_uDirectionalLight[${o}].color`]=_n(i),r[`lighting_uDirectionalLight[${o}].direction`]=i.direction}),r.lighting_uDirectionalLightCount=n.length,r}function ri(t=jo){if("lightSources"in t){let{ambientLight:e,pointLights:n,directionalLights:r}=t.lightSources||{};return e||n&&n.length>0||r&&r.length>0?Object.assign({},$o({ambientLight:e,pointLights:n,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let n of t.lights||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;default:}return ri({lightSources:e})}return{}}var ne={name:"lights",vs:hn,fs:hn,getUniforms:ri,defines:{MAX_LIGHTS:3}};var Ko={lightDirection:new Float32Array([1,1,2])};function Zo(t=Ko){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var Jo=`uniform vec3 dirlight_uLightDirection;
3126
3287
 
3127
3288
  /*
3128
3289
  * Returns color attenuated by angle from light source
@@ -3132,7 +3293,7 @@ vec4 dirlight_filterColor(vec4 color) {
3132
3293
  float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
3133
3294
  return vec4(color.rgb * d, color.a);
3134
3295
  }
3135
- `,no={name:"dirlight",fs:$i,getUniforms:ji,dependencies:[at]};var pn=`
3296
+ `,ii={name:"dirlight",fs:Jo,getUniforms:Zo,dependencies:[at]};var pn=`
3136
3297
  uniform float lighting_uAmbient;
3137
3298
  uniform float lighting_uDiffuse;
3138
3299
  uniform float lighting_uShininess;
@@ -3205,7 +3366,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
3205
3366
  }
3206
3367
  return lightColor;
3207
3368
  }
3208
- `;var Ki={};function Zi(t){let{ambient:e=.35,diffuse:n=.6,shininess:r=32,specularColor:o=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:n,lighting_uShininess:r,lighting_uSpecularColor:o.map(i=>i/255)}}function ro(t=Ki){if(!("material"in t))return{};let{material:e}=t;return e?Zi(e):{lighting_uEnabled:!1}}var oo={name:"gouraud-lighting",dependencies:[ne],vs:pn,defines:{LIGHTING_VERTEX:1},getUniforms:ro},io={name:"phong-lighting",dependencies:[ne],fs:pn,defines:{LIGHTING_FRAGMENT:1},getUniforms:ro};var so=`uniform mat4 u_MVPMatrix;
3369
+ `;var es={};function ts(t){let{ambient:e=.35,diffuse:n=.6,shininess:r=32,specularColor:i=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:n,lighting_uShininess:r,lighting_uSpecularColor:i.map(o=>o/255)}}function oi(t=es){if(!("material"in t))return{};let{material:e}=t;return e?ts(e):{lighting_uEnabled:!1}}var si={name:"gouraud-lighting",dependencies:[ne],vs:pn,defines:{LIGHTING_VERTEX:1},getUniforms:oi},ai={name:"phong-lighting",dependencies:[ne],fs:pn,defines:{LIGHTING_FRAGMENT:1},getUniforms:oi};var ci=`uniform mat4 u_MVPMatrix;
3209
3370
  uniform mat4 u_ModelMatrix;
3210
3371
  uniform mat4 u_NormalMatrix;
3211
3372
 
@@ -3242,7 +3403,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
3242
3403
  pbr_vUV = vec2(0.,0.);
3243
3404
  #endif
3244
3405
  }
3245
- `;var ao=`precision highp float;
3406
+ `;var li=`precision highp float;
3246
3407
 
3247
3408
  uniform bool pbr_uUnlit;
3248
3409
 
@@ -3623,7 +3784,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
3623
3784
 
3624
3785
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
3625
3786
  }
3626
- `;var co={name:"pbr",vs:so,fs:ao,defines:{LIGHTING_FRAGMENT:1},dependencies:[ne],getUniforms:t=>t};return xo(Ee);})();
3787
+ `;var fi={name:"pbr",vs:ci,fs:li,defines:{LIGHTING_FRAGMENT:1},dependencies:[ne],getUniforms:t=>t};return vi(Ne);})();
3627
3788
  /**
3628
3789
  * ORIGINAL LICENCE
3629
3790
  * @license