@luma.gl/shadertools 9.1.0-alpha.16 → 9.1.0-alpha.17

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 (118) hide show
  1. package/dist/dist.dev.js +277 -344
  2. package/dist/dist.min.js +215 -314
  3. package/dist/index.cjs +276 -346
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -1
  8. package/dist/lib/shader-module/shader-module.d.ts +24 -14
  9. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  10. package/dist/lib/shader-module/shader-module.js +11 -15
  11. package/dist/lib/shader-module/shader-pass.d.ts +4 -2
  12. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  13. package/dist/lib/utils/uniform-types.d.ts +11 -0
  14. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  15. package/dist/lib/utils/uniform-types.js +1 -0
  16. package/dist/modules/engine/picking/picking.d.ts +7 -7
  17. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  18. package/dist/modules/engine/picking/picking.js +2 -2
  19. package/dist/modules/engine/project/project.d.ts +9 -8
  20. package/dist/modules/engine/project/project.d.ts.map +1 -1
  21. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +3 -57
  22. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  23. package/dist/modules/lighting/gouraud-material/gouraud-material.js +9 -6
  24. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  25. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  26. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +35 -12
  27. package/dist/modules/lighting/lights/lighting.d.ts +55 -29
  28. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  29. package/dist/modules/lighting/lights/lighting.js +46 -35
  30. package/dist/modules/lighting/no-material/dirlight.d.ts +3 -3
  31. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  32. package/dist/modules/lighting/no-material/dirlight.js +1 -1
  33. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  34. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  35. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +56 -60
  36. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +56 -98
  37. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  38. package/dist/modules/lighting/pbr-material/pbr-material.js +14 -22
  39. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
  40. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
  41. package/dist/modules/lighting/pbr-material/pbr-projection.js +24 -0
  42. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  43. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  44. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +8 -16
  45. package/dist/modules/lighting/phong-material/phong-material.d.ts +5 -59
  46. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  47. package/dist/modules/lighting/phong-material/phong-material.js +6 -4
  48. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -40
  49. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  50. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +8 -87
  51. package/dist/modules-webgl1/project/project.d.ts +6 -4
  52. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  53. package/dist/passes/postprocessing/fxaa/fxaa.d.ts +1 -1
  54. package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  55. package/dist/passes/postprocessing/fxaa/fxaa.js +1 -1
  56. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +0 -1
  57. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  58. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +0 -1
  59. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +0 -1
  60. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  61. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +0 -1
  62. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +3 -0
  63. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  64. package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +3 -0
  65. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
  66. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  67. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
  68. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  69. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
  70. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  71. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
  72. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  73. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
  74. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  75. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +15 -11
  76. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  77. package/dist/passes/postprocessing/image-fun-filters/edgework.js +24 -12
  78. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
  79. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  80. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -2
  81. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  82. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
  83. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  84. package/package.json +3 -3
  85. package/src/index.ts +9 -3
  86. package/src/lib/shader-module/shader-module.ts +31 -20
  87. package/src/lib/shader-module/shader-pass.ts +7 -4
  88. package/src/lib/utils/uniform-types.ts +66 -0
  89. package/src/modules/engine/picking/picking.ts +9 -9
  90. package/src/modules/engine/project/project.ts +10 -9
  91. package/src/modules/lighting/gouraud-material/gouraud-material.ts +14 -12
  92. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +35 -12
  93. package/src/modules/lighting/lights/lighting.ts +83 -54
  94. package/src/modules/lighting/no-material/dirlight.ts +3 -3
  95. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
  96. package/src/modules/lighting/pbr-material/pbr-material.ts +40 -74
  97. package/src/modules/lighting/pbr-material/pbr-projection.ts +39 -0
  98. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
  99. package/src/modules/lighting/phong-material/phong-material.ts +12 -12
  100. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +8 -88
  101. package/src/modules-webgl1/project/project.ts +8 -7
  102. package/src/passes/postprocessing/fxaa/fxaa.ts +2 -2
  103. package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +0 -1
  104. package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +0 -1
  105. package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +3 -0
  106. package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +2 -2
  107. package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +1 -1
  108. package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +1 -1
  109. package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +1 -1
  110. package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +1 -1
  111. package/src/passes/postprocessing/image-fun-filters/edgework.ts +26 -15
  112. package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
  113. package/src/passes/postprocessing/image-fun-filters/magnify.ts +2 -2
  114. package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
  115. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +0 -42
  116. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +0 -1
  117. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +0 -134
  118. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +0 -137
package/dist/dist.min.js CHANGED
@@ -4,10 +4,10 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var 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((is,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
7
+ "use strict";var __exports__=(()=>{var _o=Object.create;var de=Object.defineProperty;var po=Object.getOwnPropertyDescriptor;var mo=Object.getOwnPropertyNames;var go=Object.getPrototypeOf,xo=Object.prototype.hasOwnProperty;var vo=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ao=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bo=(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 o of mo(e))!xo.call(t,o)&&o!==n&&de(t,o,{get:()=>e[o],enumerable:!(r=po(e,o))||r.enumerable});return t},Fe=(t,e,n)=>(Ie(t,e,"default"),n&&Ie(n,e,"default")),ut=(t,e,n)=>(n=t!=null?_o(go(t)):{},Ie(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),yo=t=>Ie(de({},"__esModule",{value:!0}),t);var xn=(t,e,n)=>(vo(t,typeof e!="symbol"?e+"":e,n),n);var Me=Ao((is,vn)=>{vn.exports=globalThis.luma});var Ee={};bo(Ee,{ShaderAssembler:()=>be,_getDependencyGraph:()=>Ae,_resolveModules:()=>En,_warp:()=>_e,assembleGLSLShaderPair:()=>Oe,brightnessContrast:()=>Rr,bulgePinch:()=>Kr,capitalize:()=>Z,checkShaderModuleDeprecations:()=>xe,colorHalftone:()=>qr,combineInjects:()=>Tn,convertToVec4:()=>gt,denoise:()=>Or,dirlight:()=>fn,dirlight1:()=>so,dotScreen:()=>Hr,edgeWork:()=>Vr,fp32:()=>Pr,fp64:()=>no,fp64LowPart:()=>ke,fp64arithmetic:()=>_n,fp64ify:()=>he,fp64ifyMatrix4:()=>Te,fromHalfFloat:()=>yr,fxaa:()=>Jr,generateShaderForModule:()=>qn,geometry1:()=>ro,getPassthroughFS:()=>Bn,getQualifierDetails:()=>Dn,getShaderInfo:()=>Re,getShaderLayoutFromWGSL:()=>Wn,getShaderModuleDependencies:()=>ve,getShaderModuleSource:()=>Ue,getShaderModuleUniforms:()=>Nn,gouraudLighting:()=>co,gouraudMaterial:()=>un,hexagonalPixelate:()=>Wr,hueSaturation:()=>Ur,initializeShaderModule:()=>Ce,initializeShaderModules:()=>Y,ink:()=>jr,lighting:()=>X,lights1:()=>ne,magnify:()=>$r,noise:()=>zr,pbr:()=>ho,pbrMaterial:()=>Cr,phongLighting:()=>lo,phongMaterial:()=>hn,picking:()=>Lr,preprocess:()=>ze,project1:()=>ft,random:()=>Q,sepia:()=>Dr,swirl:()=>Zr,tiltShift:()=>Yr,toHalfFloat:()=>br,triangleBlur:()=>Qr,typeToChannelCount:()=>Yn,typeToChannelSuffix:()=>Xn,vibrance:()=>Br,vignette:()=>Xr,zoomBlur:()=>Gr});Fe(Ee,ut(Me(),1));function W(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var ht={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 bn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=wo(r);return e}function yn(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 wo(t){let e=An(t);if(e!=="object")return{value:t,...ht[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...ht[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=An(t.value),{...t,...ht[e],type:e}):{type:"object",value:null};throw new Error("props")}function An(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var wn=`#ifdef MODULE_LOGDEPTH
8
8
  logdepth_adjustPosition(gl_Position);
9
9
  #endif
10
- `,yn=`#ifdef MODULE_MATERIAL
10
+ `,Pn=`#ifdef MODULE_MATERIAL
11
11
  fragColor = material_filterColor(fragColor);
12
12
  #endif
13
13
 
@@ -27,10 +27,10 @@
27
27
  #ifdef MODULE_LOGDEPTH
28
28
  logdepth_setFragDepth();
29
29
  #endif
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(`
30
+ `;var Po={vertex:wn,fragment:Pn},Ln=/void\s+main\s*\([^)]*\)\s*\{\n?/,Sn=/}\n?[^{}]*$/,_t=[],me="__LUMA_INJECT_DECLARATIONS__";function kn(t){let e={vertex:{},fragment:{}};for(let n in t){let r=t[n],o=Lo(n);typeof r=="string"&&(r={order:0,injection:r}),e[o][n]=r}return e}function Lo(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),_t.length=a.length;for(let u=0,_=a.length;u<_;++u)_t[u]=a[u].injection;let c=`${_t.join(`
31
31
  `)}
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{propTypes: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 e&&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
32
+ `;switch(i){case"vs:#decl":o&&(t=t.replace(me,c));break;case"vs:#main-start":o&&(t=t.replace(Ln,u=>u+c));break;case"vs:#main-end":o&&(t=t.replace(Sn,u=>c+u));break;case"fs:#decl":o||(t=t.replace(me,c));break;case"fs:#main-start":o||(t=t.replace(Ln,u=>u+c));break;case"fs:#main-end":o||(t=t.replace(Sn,u=>c+u));break;default:t=t.replace(i,u=>u+c)}}return t=t.replace(me,""),r&&(t=t.replace(/\}\s*$/,i=>i+Po[e])),t}function Tn(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=>Ce(e))}function Ce(t){if(t.instance)return;Y(t.dependencies||[]);let{propTypes:e={},deprecations:n=[],inject:r={}}=t,o={normalizedInjections:kn(r),parsedDeprecations:So(n)};e&&(o.propValidators=bn(e)),t.instance=o;let i={};e&&(i=Object.entries(e).reduce((a,[c,u])=>{let _=u?.value;return _&&(a[c]=_),a},{})),t.defaultUniforms={...t.defaultUniforms,...i}}function Nn(t,e,n){Ce(t);let r=n||{...t.defaultUniforms};return e&&t.getUniforms?t.getUniforms(e,r):yn(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 So(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 ko(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 En(t){return ko(t)}function In(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,57 +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 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=`
57
+ `}}function Mn(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=Fn(t,To),t;case"fragment":return t=Fn(t,No),t;default:throw new Error(e)}}var Cn=[[/^(#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("]],To=[...Cn,[pt("attribute"),"in $1"],[pt("varying"),"out $1"]],No=[...Cn,[pt("varying"),"in $1"]];function Fn(t,e){for(let[n,r]of e)t=t.replace(n,r);return t}function pt(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function dt(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 mt(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 Re(t,e){return{name:Eo(t,e),language:"glsl",version:Io(t)}}function Eo(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 Io(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 On=`
62
62
 
63
63
  ${me}
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(`
64
+ `,Fo=`precision highp float;
65
+ `;function Un(t){let e=ve(t.modules||[]);return{source:Mo(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:zn(e)}}function Oe(t){let{vs:e,fs:n}=t,r=ve(t.modules||[]);return{vs:Rn(t.platformInfo,{...t,source:e,stage:"vertex",modules:r}),fs:Rn(t.platformInfo,{...t,source:n,stage:"fragment",modules:r}),getUniforms:zn(r)}}function Mo(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=mt(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=o;for(let g of P){c&&xe(g,u,c);let A=Ue(g,"wgsl");_+=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 _+=On,_=ge(_,r,m),_+=dt(p[r],d),_+=u,_=ge(_,r,x),_}function Rn(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"?Re(r).version:-1,x=t.shaderLanguageVersion,P=m===100?"#version 100":"#version 300 es",A=r.split(`
66
66
  `).slice(1).join(`
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}
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}
68
68
 
69
69
  // ----- PROLOGUE -------------------------
70
- ${Ii({id:n,source:r,stage:i})}
71
- ${`#define SHADER_TYPE_${i.toUpperCase()}`}
70
+ ${Co({id:n,source:r,stage:o})}
71
+ ${`#define SHADER_TYPE_${o.toUpperCase()}`}
72
72
 
73
- ${En(t)}
74
- ${i==="fragment"?Ei:""}
73
+ ${In(t)}
74
+ ${o==="fragment"?Fo:""}
75
75
 
76
76
  // ----- APPLICATION DEFINES -------------------------
77
77
 
78
- ${Fi(P)}
78
+ ${Ro(L)}
79
79
 
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} ---------------
80
+ `:`${P}
81
+ `;break}let y=mt(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 N=I[2],M=I[3];N?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=Ue(k,o);v+=F;let I=k.instance?.normalizedInjections[o]||{};for(let N in I){let M=/^(v|f)s:#([\w-]+)$/.exec(N);if(M){let C=M[2]==="decl"?b:S;C[N]=C[N]||[],C[N].push(I[N])}else w[N]=w[N]||[],w[N].push(I[N])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=On,v=ge(v,o,b),v+=dt(y[o],w),v+=A,v=ge(v,o,S),i==="glsl"&&m!==x&&(v=Mn(v,o)),v.trim()}function zn(t){return function(n){let r={};for(let o of t){let i=o.getUniforms?.(n,r);Object.assign(r,i)}return r}}function Co(t){let{id:e,source:n,stage:r}=t;return e&&n.indexOf("SHADER_NAME")===-1?`
82
+ #define SHADER_NAME ${e}_${r}`:""}function Ro(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 Ue(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,"_"),o=`// ----- MODULE ${t.name} ---------------
84
84
 
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;
85
+ `;return e!=="wgsl"&&(o+=`#define MODULE_${r}
86
+ `),o+=`${n}
87
+ `,o}var Oo=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Uo=/^\s*\#\s*endif\s*$/;function ze(t,e){let n=t.split(`
88
+ `),r=[],o=!0,i=null;for(let a of n){let c=a.match(Oo),u=a.match(Uo);c?(i=c[1],o=Boolean(e?.defines?.[i])):u?o=!0:o&&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:o,getUniforms:i}=Un({...e,source:e.source,modules:n,hookFunctions:r});return{source:e.platformInfo.shaderLanguage==="wgsl"?ze(o):o,getUniforms:i,modules:n}}assembleGLSLShaderPair(e){let n=this._getModuleList(e.modules),r=this._hookFunctions;return{...Oe({...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;xn(be,"defaultShaderAssembler");var zo=`out vec4 transform_output;
90
90
  void main() {
91
91
  transform_output = vec4(0);
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};
92
+ }`,Do=`#version 300 es
93
+ ${zo}`;function Dn(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 Bn(t){let{input:e,inputChannels:n,output:r}=t||{};if(!e)return Do;if(!n)throw new Error("inputChannels");let o=Bo(n),i=gt(e,n);return`#version 300 es
94
+ in ${o} ${e};
95
95
  out vec4 ${r};
96
96
  void main() {
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==`
97
+ ${r} = ${i};
98
+ }`}function Xn(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 Yn(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 Bo(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 gt(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 Qn(t,e){return Xo(t,e)}function Xo(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=Yo(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(`
99
+ `)}function Yo(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 Gn(t,e){return Qo(t,e)}function Qo(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(`
100
+ `)}function qn(t,e){switch(e.shaderLanguage){case"glsl":return Qn(t,e);case"wgsl":return Gn(t,e)}}var Vn=ut(Me(),1);var xt=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)}},vt=class extends T{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},At=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)}},bt=class extends T{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},yt=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)}},q=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)}},De=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)}},Be=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 wt=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 Pt=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)}},Xe=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)}},Lt=class extends T{constructor(e,n){super(),this.body=e,this.continuing=n}get astNodeType(){return"loop"}},St=class extends T{constructor(e,n){super(),this.condition=e,this.body=n}get astNodeType(){return"body"}},kt=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)}},Tt=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)}},Nt=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Et=class extends T{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},It=class extends T{constructor(e,n){super(),this.severity=e,this.rule=n}get astNodeType(){return"diagnostic"}},Ye=class extends T{constructor(e,n){super(),this.name=e,this.type=n}get astNodeType(){return"alias"}},Ft=class extends T{constructor(){super()}get astNodeType(){return"discard"}},Mt=class extends T{constructor(){super()}get astNodeType(){return"break"}},Ct=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,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}},Qe=class extends H{constructor(e,n,r){super(e),this.format=n,this.access=r}get astNodeType(){return"template"}},Rt=class extends H{constructor(e,n,r,o){super(e),this.storage=n,this.type=r,this.access=o}get astNodeType(){return"pointer"}},Ge=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)}},He=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)}},Ve=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)}},We=class extends O{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Ot=class extends O{constructor(e,n){super(),this.type=e,this.value=n}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},Ut=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)}},je=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)}},zt=class extends O{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},$e=class extends O{constructor(){super()}},Dt=class extends $e{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 $e{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)}},Ke=class extends B{constructor(){super()}},Bt=class extends Ke{constructor(e,n){super(),this.selector=e,this.body=n}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},Xt=class extends Ke{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Yt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"argument"}},Qt=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)}},Gt=class extends B{constructor(e,n,r){super(),this.name=e,this.type=n,this.attributes=r}get astNodeType(){return"member"}},qt=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 Ze=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()}},Ht=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 Ze(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
101
101
  `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
102
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==`
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 Ws=1/Math.PI*180,js=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 ta=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 na=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 oa=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 ha=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) {
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,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 Ze(e,n,this._line))}},Vt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new xt,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 Ht(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 Yt(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 Ft:this._match(s.keywords.break)?e=new Mt:this._match(s.keywords.continue)?e=new Ct: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 vt(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 At(e,n)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new bt(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 yt(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 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 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 Be(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 wt(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 Pt(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 Xe(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 Lt(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 St(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 Bt(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 Xt(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 kt(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 Qt(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 Tt(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 Dt(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 zt(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 He(r,o)}if(this._context.constants.has(r)){let o=this._context.constants.get(r);return new Ve(r,o.value)}return new Se(r)}if(this._match(s.const_literal))return new We(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 Ot(r,o)}let e=this._type_decl(),n=this._argument_expression_list();return new Ut(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 je([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 je([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 Gt(c,_,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let o=this._currentLine,i=new G(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 Ve&&i.initializer instanceof $)r=i.initializer;else try{let a=i.evaluate(this._context);r=new We(a)}catch{r=i}}let o=new Be(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 q(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 De(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 It(e.toString(),n.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new Nt(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 Et(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 Ye(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 Qe(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 Rt(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 Ge(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 qt(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}},Je=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}},et=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}},Wt=class{constructor(e,n){this.name=e,this.type=n}},se=class{constructor(e,n){this.align=e,this.size=n}},jt=class{constructor(e,n,r,o){this.name=e,this.type=n,this.locationType=r,this.location=o,this.interpolation=null}},tt=class{constructor(e,n,r,o){this.name=e,this.type=n,this.locationType=r,this.location=o}},$t=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}},Kt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Zt=class{constructor(e,n,r,o){this.name=e,this.type=n,this.attributes=r,this.id=o}},Jt=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 Kt,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 Vt().parse(e);for(let o of r)o instanceof we&&this._functions.set(o.name,new Jt(o));for(let o of r)if(o instanceof G){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i)}for(let o of r){if(o instanceof Ye){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof De){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 Zt(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 $t(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 q){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 He){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 Xe){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 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 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 tt(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 tt("",r,n.name,o)}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 o=this._getInputInfo(r);o!==null&&n.push(o)}return n}_getStructInputs(e,n){for(let r of e.members)if(r.type instanceof G)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 jt(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 Wt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,n){if(this._types.has(e))return this._types.get(e);if(e instanceof Ge){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 G){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 Je(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 et(o.name,a,n,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Qe){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new et(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 Je&&(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 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 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 Wn(t){let e={attributes:[],bindings:[]},n;try{n=Go(t)}catch(i){return Vn.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:Hn(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=Hn(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Hn(t){return t.format?`${t.name}<${t.format.name}>`:t.name}function Go(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 js=1/Math.PI*180,$s=1/180*Math.PI,qo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...qo}};var R=globalThis.mathgl.config;function en(t,{precision:e=R.precision}={}){return t=Ho(t),`${parseFloat(t.toPrecision(e))}`}function fe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function tn(t,e,n){return Wo(t,r=>Math.max(e,Math.min(n,r)))}function nt(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(!nt(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 Ho(t){return Math.round(t/R.EPSILON)*R.EPSILON}function Vo(t){return t.clone?t.clone():new Array(t.length)}function Wo(t,e,n){if(fe(t)){let r=t;n=n||Vo(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 rt=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?", ":"")+en(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(!nt(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 jo(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 jn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function ot(t,e,n=""){if(R.debug&&!jo(t,e))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return t}var V=typeof Float32Array<"u"?Float32Array:Array;var na=Math.PI/180;function $o(){let t=new V(2);return V!=Float32Array&&(t[0]=0,t[1]=0),t}function Zn(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 ra=function(){let t=$o();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 Jn(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 er(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 Ko(){let t=new V(3);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function tr(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 sa=function(){let t=Ko();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 it=class extends rt{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]=jn(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 Zo(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 nr(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 rr(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,F=p*g-d*P,I=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*I+k*F;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-_*I)*E,t[5]=(n*C-o*N+i*I)*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+_*F)*E,t[9]=(r*N-n*U-i*F)*E,t[10]=(P*S-g*w+L*v)*E,t[11]=(d*w-p*S-x*v)*E,t[12]=(c*I-a*M-u*F)*E,t[13]=(n*M-r*I+o*F)*E,t[14]=(g*y-P*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function or(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,F=i*S-a*b+c*w,I=_*y-p*v+d*L,N=x*y-P*v+g*L;return u*k-o*F+A*I-m*N}function rn(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 ir(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 sr(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 ar(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,F,I,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,F=i*o*p+a*_,I=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*F+y*I,t[1]=m*k+A*F+w*I,t[2]=x*k+L*F+b*I,t[3]=P*k+v*F+S*I,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 cr(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 lr(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 fr(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 ur(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 hr(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 _r=Jo;function ei(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 pr=ei;function dr(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?Zo(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 ti(){let t=new V(4);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function mr(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 _a=function(){let t=ti();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 an;(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"})(an||(an={}));var ni=45*Math.PI/180,ri=1,on=.1,sn=500,oi=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 si()}static get ZERO(){return ii()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return an}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(oi)}fromObject(e){return this.check()}fromQuaternion(e){return ur(this,e),this.check()}frustum(e){let{left:n,right:r,bottom:o,top:i,near:a=on,far:c=sn}=e;return c===1/0?ai(this,n,r,o,i,a):hr(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 dr(this,n,r,o),this.check()}ortho(e){let{left:n,right:r,bottom:o,top:i,near:a=on,far:c=sn}=e;return pr(this,n,r,o,i,a,c),this.check()}orthographic(e){let{fovy:n=ni,aspect:r=ri,focalDistance:o=1,near:i=on,far:a=sn}=e;gr(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 gr(n),_r(this,n,r,o,i),this.check()}determinant(){return or(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 nr(this,this),this.check()}invert(){return rr(this,this),this.check()}multiplyLeft(e){return rn(this,e,this),this.check()}multiplyRight(e){return rn(this,this,e),this.check()}rotateX(e){return cr(this,this,e),this.check()}rotateY(e){return lr(this,this,e),this.check()}rotateZ(e){return fr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,n){return ar(this,this,e,n),this.check()}scale(e){return sr(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return ir(this,this,e),this.check()}transform(e,n){return e.length===4?(n=mr(n||[-0,-0,-0,-0],e,this),ot(n,4),n):this.transformAsPoint(e,n)}transformAsPoint(e,n){let{length:r}=e,o;switch(r){case 2:o=Zn(n||[-0,-0],e,this);break;case 3:o=tr(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return ot(o,e.length),o}transformAsVector(e,n){let r;switch(e.length){case 2:r=Jn(n||[-0,-0],e,this);break;case 3:r=er(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return ot(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])}},st,at;function ii(){return st||(st=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(st)),st}function si(){return at||(at=new ee,Object.freeze(at)),at}function gr(t){if(t>Math.PI*2)throw Error("expected radians")}function ai(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,xr=new ArrayBuffer(4),vr=new Float32Array(xr),Ar=new Uint32Array(xr);function br(t){te||=wr(),t=tn(t,-65504,65504),vr[0]=t;let e=Ar[0],n=e>>23&511;return te.baseTable[n]+((e&8388607)>>te.shiftTable[n])}function yr(t){te||=wr();let e=t>>10;return Ar[0]=te.mantissaTable[te.offsetTable[e]+(t&1023)]+te.exponentTable[e],vr[0]}function wr(){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 ci=`float random(vec3 scale, float seed) {
104
104
  /* use the fragment position for a different seed per-pixel */
105
105
  return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
106
106
  }
107
- `,Q={name:"random",fs:oo};var so=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
107
+ `,Q={name:"random",fs:ci};var li=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
108
108
 
109
109
  // All these functions are for substituting tan() function from Intel GPU only
110
110
  const float TWO_PI = 6.2831854820251465;
@@ -254,7 +254,7 @@ float tan_fp32(float a) {
254
254
  return tan(a);
255
255
  #endif
256
256
  }
257
- `,yr={name:"fp32",vs:so};var ao=new Float32Array([0,1,1,1]),co=`uniform pickingUniforms {
257
+ `,Pr={name:"fp32",vs:li};var fi=[0,1,1,1],ui=`uniform pickingUniforms {
258
258
  float isActive;
259
259
  float isAttribute;
260
260
  float isHighlightActive;
@@ -325,7 +325,7 @@ void picking_setPickingAttribute(vec3 value) {
325
325
  picking_vRGBcolor_Avalid.rgb = value;
326
326
  }
327
327
  }
328
- `,lo=`uniform pickingUniforms {
328
+ `,hi=`uniform pickingUniforms {
329
329
  float isActive;
330
330
  float isAttribute;
331
331
  float isHighlightActive;
@@ -381,7 +381,7 @@ vec4 picking_filterColor(vec4 color) {
381
381
  vec4 highlightColor = picking_filterHighlightColor(color);
382
382
  return picking_filterPickingColor(highlightColor);
383
383
  }
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;
384
+ `,Lr={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:[0,0,0],highlightColor:fi},vs:ui,fs:hi,getUniforms:_i};function _i(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 kr=ut(Me(),1);var cn=`precision highp int;
385
385
 
386
386
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
387
387
  struct AmbientLight {
@@ -401,28 +401,51 @@ struct DirectionalLight {
401
401
 
402
402
  uniform lightingUniforms {
403
403
  int enabled;
404
- int pointLightCount;
404
+ int lightType;
405
+
405
406
  int directionalLightCount;
407
+ int pointLightCount;
406
408
 
407
409
  vec3 ambientColor;
408
410
 
409
- int lightType;
410
- vec3 lightColor;
411
- vec3 lightDirection;
412
- vec3 lightPosition;
413
- vec3 lightAttenuation;
411
+ vec3 lightColor0;
412
+ vec3 lightPosition0;
413
+ vec3 lightDirection0;
414
+ vec3 lightAttenuation0;
414
415
 
415
- // AmbientLight ambientLight;
416
- // PointLight pointLight[MAX_LIGHTS];
417
- // DirectionalLight directionalLight[MAX_LIGHTS];
416
+ vec3 lightColor1;
417
+ vec3 lightPosition1;
418
+ vec3 lightDirection1;
419
+ vec3 lightAttenuation1;
420
+
421
+ vec3 lightColor2;
422
+ vec3 lightPosition2;
423
+ vec3 lightDirection2;
424
+ vec3 lightAttenuation2;
418
425
  } lighting;
419
426
 
420
427
  PointLight lighting_getPointLight(int index) {
421
- return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
428
+ switch (index) {
429
+ case 0:
430
+ return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
431
+ case 1:
432
+ return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
433
+ case 2:
434
+ default:
435
+ return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
436
+ }
422
437
  }
423
438
 
424
439
  DirectionalLight lighting_getDirectionalLight(int index) {
425
- return DirectionalLight(lighting.lightColor, lighting.lightDirection);
440
+ switch (index) {
441
+ case 0:
442
+ return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
443
+ case 1:
444
+ return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
445
+ case 2:
446
+ default:
447
+ return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
448
+ }
426
449
  }
427
450
 
428
451
  float getPointLightAttenuation(PointLight pointLight, float distance) {
@@ -432,7 +455,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
432
455
  }
433
456
 
434
457
  // #endif
435
- `;var Lr=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
458
+ `;var Sr=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
436
459
  struct AmbientLight {
437
460
  color: vec3<f32>,
438
461
  };
@@ -483,7 +506,7 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
483
506
  + pointLight.attenuation.y * distance
484
507
  + pointLight.attenuation.z * distance * distance;
485
508
  }
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=`
509
+ `;var Tr=3,pi=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:Tr},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:Ne.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:Sr,vs:cn,fs:cn,getUniforms:di};function di(t,e={}){if(t=t&&{...t},!t)return{...X.defaultUniforms};t.lights&&(t={...t,...gi(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,...mi({ambientLight:n,pointLights:r,directionalLights:o})};return t.enabled!==void 0&&(a.enabled=t.enabled?1:0),a}function mi({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};r.ambientLightColor=ln(t);let o=0;for(let i of e){r.lightType=Ne.POINT;let a=o;r[`lightColor${a}`]=ln(i),r[`lightPosition${a}`]=i.position,r[`lightAttenuation${a}`]=i.attenuation||[1,0,0],o++}for(let i of n){r.lightType=Ne.DIRECTIONAL;let a=o;r[`lightColor${a}`]=ln(i),r[`lightDirection${a}`]=i.direction,o++}return o>Tr&&kr.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=n.length,r.pointLightCount=e.length,r}function gi(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 ln(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/pi)}var xi=`
487
510
  struct dirlightUniforms {
488
511
  lightDirection: vec3<f32>,
489
512
  };
@@ -509,12 +532,12 @@ fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
509
532
  let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
510
533
  return vec4<f32>(color.rgb * d, color.a);
511
534
  }
512
- `,xo=`out vec3 dirlight_vNormal;
535
+ `,vi=`out vec3 dirlight_vNormal;
513
536
 
514
537
  void dirlight_setNormal(vec3 normal) {
515
538
  dirlight_vNormal = normalize(normal);
516
539
  }
517
- `,vo=`uniform dirlightUniforms {
540
+ `,Ai=`uniform dirlightUniforms {
518
541
  vec3 lightDirection;
519
542
  } dirlight;
520
543
 
@@ -525,13 +548,13 @@ vec4 dirlight_filterColor(vec4 color) {
525
548
  float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
526
549
  return vec4(color.rgb * d, color.a);
527
550
  }
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 {
551
+ `,fn={props:{},uniforms:{},name:"dirlight",dependencies:[],source:xi,vs:vi,fs:Ai,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:bi};function bi(t=fn.defaultUniforms){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var ct=`uniform phongMaterialUniforms {
529
552
  uniform float ambient;
530
553
  uniform float diffuse;
531
554
  uniform float shininess;
532
555
  uniform vec3 specularColor;
533
556
  } material;
534
- `,Sr=`uniform materialUniforms {
557
+ `,lt=`uniform phongMaterialUniforms {
535
558
  uniform float ambient;
536
559
  uniform float diffuse;
537
560
  uniform float shininess;
@@ -553,66 +576,30 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
553
576
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
554
577
  vec3 lightColor = surfaceColor;
555
578
 
556
- if (lighting.enabled) {
557
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
558
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
559
-
560
- if (lighting.lightType == 0) {
561
- PointLight pointLight = lighting_getPointLight(0);
562
- vec3 light_position_worldspace = pointLight.position;
563
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
564
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
565
- } else if (lighting.lightType == 1) {
566
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
567
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
568
- }
569
- /*
570
- for (int i = 0; i < MAX_LIGHTS; i++) {
571
- if (i >= lighting.pointLightCount) {
572
- break;
573
- }
574
- PointLight pointLight = lighting.pointLight[i];
575
- vec3 light_position_worldspace = pointLight.position;
576
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
577
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
578
- }
579
-
580
- for (int i = 0; i < MAX_LIGHTS; i++) {
581
- if (i >= lighting.directionalLightCount) {
582
- break;
583
- }
584
- DirectionalLight directionalLight = lighting.directionalLight[i];
585
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
586
- }
587
- */
579
+ if (lighting.enabled == 0) {
580
+ return lightColor;
588
581
  }
589
- return lightColor;
590
- }
591
582
 
592
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
593
- vec3 lightColor = vec3(0, 0, 0);
594
- vec3 surfaceColor = vec3(0, 0, 0);
595
-
596
- if (lighting.enabled) {
597
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
583
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
584
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
598
585
 
599
- switch (lighting.lightType) {
600
- case 0:
601
- PointLight pointLight = lighting_getPointLight(0);
602
- vec3 light_position_worldspace = pointLight.position;
603
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
604
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
605
- break;
586
+ for (int i = 0; i < lighting.pointLightCount; i++) {
587
+ PointLight pointLight = lighting_getPointLight(i);
588
+ vec3 light_position_worldspace = pointLight.position;
589
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
590
+ float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
591
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
592
+ }
606
593
 
607
- case 1:
608
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
609
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
610
- break;
611
- }
594
+ int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
595
+ for (int i = lighting.pointLightCount; i < totalLights; i++) {
596
+ DirectionalLight directionalLight = lighting_getDirectionalLight(i);
597
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
612
598
  }
599
+
613
600
  return lightColor;
614
601
  }
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 {
602
+ `;var un={props:{},name:"gouraudMaterial",vs:lt.replace("phongMaterial","gouraudMaterial"),fs:ct.replace("phongMaterial","gouraudMaterial"),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){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(n=>n/255)),{...un.defaultUniforms,...e}}};var Nr=`struct phongMaterialUniforms {
616
603
  ambient: f32,
617
604
  diffuse: f32,
618
605
  shininess: f32,
@@ -697,128 +684,30 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
697
684
  }
698
685
  return lightColor;
699
686
  }
700
- `;var Tr=`uniform phongMaterialUniforms {
701
- uniform float ambient;
702
- uniform float diffuse;
703
- uniform float shininess;
704
- uniform vec3 specularColor;
705
- } material;
706
- `,Er=`uniform phongMaterialUniforms {
707
- uniform float ambient;
708
- uniform float diffuse;
709
- uniform float shininess;
710
- uniform vec3 specularColor;
711
- } material;
712
-
713
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
714
- vec3 halfway_direction = normalize(light_direction + view_direction);
715
- float lambertian = dot(light_direction, normal_worldspace);
716
- float specular = 0.0;
717
- if (lambertian > 0.0) {
718
- float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
719
- specular = pow(specular_angle, material.shininess);
720
- }
721
- lambertian = max(lambertian, 0.0);
722
- return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
723
- }
724
-
725
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
726
- vec3 lightColor = surfaceColor;
727
-
728
- if (lighting.enabled == 0) {
729
- return lightColor;
730
- }
731
-
732
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
733
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
734
-
735
- if (lighting.lightType == 0) {
736
- PointLight pointLight = lighting_getPointLight(0);
737
- vec3 light_position_worldspace = pointLight.position;
738
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
739
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
740
- } else if (lighting.lightType == 1) {
741
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
742
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
743
- }
744
-
745
- /*
746
- for (int i = 0; i < MAX_LIGHTS; i++) {
747
- if (i >= lighting.pointLightCount) {
748
- break;
749
- }
750
- PointLight pointLight = lighting.pointLight[i];
751
- vec3 light_position_worldspace = pointLight.position;
752
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
753
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
754
- }
755
-
756
- for (int i = 0; i < MAX_LIGHTS; i++) {
757
- if (i >= lighting.directionalLightCount) {
758
- break;
759
- }
760
- DirectionalLight directionalLight = lighting.directionalLight[i];
761
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
762
- }
763
- */
764
- return lightColor;
765
- }
766
-
767
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
768
- vec3 lightColor = vec3(0, 0, 0);
769
- vec3 surfaceColor = vec3(0, 0, 0);
770
-
771
- if (lighting.enabled == 0) {
772
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
773
-
774
- switch (lighting.lightType) {
775
- case 0:
776
- PointLight pointLight = lighting_getPointLight(0);
777
- vec3 light_position_worldspace = pointLight.position;
778
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
779
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
780
- break;
781
-
782
- case 1:
783
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
784
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
785
- break;
786
- }
787
- }
788
- return lightColor;
789
- }
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 {
791
- mat4 u_MVPMatrix;
792
- mat4 u_ModelMatrix;
793
- mat4 u_NormalMatrix;
794
- // Projection
795
- vec3 u_Camera;
796
- }
797
-
798
- varying vec3 pbr_vPosition;
799
- varying vec2 pbr_vUV;
687
+ `;var hn={name:"phongMaterial",dependencies:[X],source:Nr,vs:ct,fs:lt,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){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(n=>n/255)),{...hn.defaultUniforms,...e}}};var Er=`out vec3 pbr_vPosition;
688
+ out vec2 pbr_vUV;
800
689
 
801
690
  #ifdef HAS_NORMALS
802
691
  # ifdef HAS_TANGENTS
803
- varying mat3 pbr_vTBN;
692
+ out mat3 pbr_vTBN;
804
693
  # else
805
- varying vec3 pbr_vNormal;
694
+ out vec3 pbr_vNormal;
806
695
  # endif
807
696
  #endif
808
697
 
809
698
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
810
699
  {
811
- vec4 pos = u_ModelMatrix * position;
700
+ vec4 pos = pbrProjection.modelMatrix * position;
812
701
  pbr_vPosition = vec3(pos.xyz) / pos.w;
813
702
 
814
703
  #ifdef HAS_NORMALS
815
704
  #ifdef HAS_TANGENTS
816
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
817
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
705
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
706
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
818
707
  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
819
708
  pbr_vTBN = mat3(tangentW, bitangentW, normalW);
820
709
  #else // HAS_TANGENTS != 1
821
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
710
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
822
711
  #endif
823
712
  #endif
824
713
 
@@ -830,12 +719,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
830
719
  }
831
720
  `;var Ir=`precision highp float;
832
721
 
833
- uniform Projection {
834
- // Projection
835
- uniform vec3 u_Camera;
836
- };
837
-
838
- uniform pbrMaterial {
722
+ uniform pbrMaterialUniforms {
839
723
  // Material is unlit
840
724
  bool unlit;
841
725
 
@@ -867,40 +751,40 @@ uniform pbrMaterial {
867
751
  vec4 scaleDiffBaseMR;
868
752
  vec4 scaleFGDSpec;
869
753
  // #endif
870
- } u_pbrMaterial;
754
+ } pbrMaterial;
871
755
 
872
756
  // Samplers
873
757
  #ifdef HAS_BASECOLORMAP
874
- uniform sampler2D u_BaseColorSampler;
758
+ uniform sampler2D pbr_baseColorSampler;
875
759
  #endif
876
760
  #ifdef HAS_NORMALMAP
877
- uniform sampler2D u_NormalSampler;
761
+ uniform sampler2D pbr_normalSampler;
878
762
  #endif
879
763
  #ifdef HAS_EMISSIVEMAP
880
- uniform sampler2D u_EmissiveSampler;
764
+ uniform sampler2D pbr_emissiveSampler;
881
765
  #endif
882
766
  #ifdef HAS_METALROUGHNESSMAP
883
- uniform sampler2D u_MetallicRoughnessSampler;
767
+ uniform sampler2D pbr_metallicRoughnessSampler;
884
768
  #endif
885
769
  #ifdef HAS_OCCLUSIONMAP
886
- uniform sampler2D u_OcclusionSampler;
770
+ uniform sampler2D pbr_occlusionSampler;
887
771
  #endif
888
772
  #ifdef USE_IBL
889
- uniform samplerCube u_DiffuseEnvSampler;
890
- uniform samplerCube u_SpecularEnvSampler;
891
- uniform sampler2D u_brdfLUT;
773
+ uniform samplerCube pbr_diffuseEnvSampler;
774
+ uniform samplerCube pbr_specularEnvSampler;
775
+ uniform sampler2D pbr_brdfLUT;
892
776
  #endif
893
777
 
894
778
  // Inputs from vertex shader
895
779
 
896
- varying vec3 pbr_vPosition;
897
- varying vec2 pbr_vUV;
780
+ in vec3 pbr_vPosition;
781
+ in vec2 pbr_vUV;
898
782
 
899
783
  #ifdef HAS_NORMALS
900
784
  #ifdef HAS_TANGENTS
901
- varying mat3 pbr_vTBN;
785
+ in mat3 pbr_vTBN;
902
786
  #else
903
- varying vec3 pbr_vNormal;
787
+ in vec3 pbr_vNormal;
904
788
  #endif
905
789
  #endif
906
790
 
@@ -968,8 +852,8 @@ vec3 getNormal()
968
852
  #endif
969
853
 
970
854
  #ifdef HAS_NORMALMAP
971
- vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;
972
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_pbrMaterial.normalScale, u_pbrMaterial.normalScale, 1.0)));
855
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
856
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
973
857
  #else
974
858
  // The tbn matrix is linearly interpolated, so we need to re-normalize
975
859
  vec3 n = normalize(tbn[2].xyz);
@@ -987,22 +871,22 @@ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
987
871
  float mipCount = 9.0; // resolution of 512x512
988
872
  float lod = (pbrInfo.perceptualRoughness * mipCount);
989
873
  // retrieve a scale and bias to F0. See [1], Figure 3
990
- vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,
874
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
991
875
  vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
992
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
876
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
993
877
 
994
878
  #ifdef USE_TEX_LOD
995
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
879
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
996
880
  #else
997
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
881
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
998
882
  #endif
999
883
 
1000
884
  vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
1001
885
  vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
1002
886
 
1003
887
  // For presentation, this allows us to disable IBL terms
1004
- diffuse *= u_pbrMaterial.scaleIBLAmbient.x;
1005
- specular *= u_pbrMaterial.scaleIBLAmbient.y;
888
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
889
+ specular *= pbrMaterial.scaleIBLAmbient.y;
1006
890
 
1007
891
  return diffuse + specular;
1008
892
  }
@@ -1094,32 +978,32 @@ vec4 pbr_filterColor(vec4 colorUnused)
1094
978
  {
1095
979
  // The albedo may be defined from a base texture or a flat color
1096
980
  #ifdef HAS_BASECOLORMAP
1097
- vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_pbrMaterial.baseColorFactor;
981
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
1098
982
  #else
1099
- vec4 baseColor = u_pbrMaterial.baseColorFactor;
983
+ vec4 baseColor = pbrMaterial.baseColorFactor;
1100
984
  #endif
1101
985
 
1102
986
  #ifdef ALPHA_CUTOFF
1103
- if (baseColor.a < u_pbrMaterial.alphaCutoff) {
987
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
1104
988
  discard;
1105
989
  }
1106
990
  #endif
1107
991
 
1108
992
  vec3 color = vec3(0, 0, 0);
1109
993
 
1110
- if(u_pbrMaterial.unlit){
994
+ if(pbrMaterial.unlit){
1111
995
  color.rgb = baseColor.rgb;
1112
996
  }
1113
997
  else{
1114
998
  // Metallic and Roughness material properties are packed together
1115
999
  // In glTF, these factors can be specified by fixed scalar values
1116
1000
  // or from a metallic-roughness map
1117
- float perceptualRoughness = u_pbrMaterial.metallicRoughnessValues.y;
1118
- float metallic = u_pbrMaterial.metallicRoughnessValues.x;
1001
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
1002
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
1119
1003
  #ifdef HAS_METALROUGHNESSMAP
1120
1004
  // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
1121
1005
  // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
1122
- vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);
1006
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
1123
1007
  perceptualRoughness = mrSample.g * perceptualRoughness;
1124
1008
  metallic = mrSample.b * metallic;
1125
1009
  #endif
@@ -1146,7 +1030,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
1146
1030
  vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
1147
1031
 
1148
1032
  vec3 n = getNormal(); // normal at surface point
1149
- vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera
1033
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
1150
1034
 
1151
1035
  float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
1152
1036
  vec3 reflection = -normalize(reflect(v, n));
@@ -1168,47 +1052,48 @@ vec4 pbr_filterColor(vec4 colorUnused)
1168
1052
  v
1169
1053
  );
1170
1054
 
1055
+
1171
1056
  #ifdef USE_LIGHTS
1172
1057
  // Apply ambient light
1173
1058
  PBRInfo_setAmbientLight(pbrInfo);
1174
- color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color);
1059
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
1175
1060
 
1176
1061
  // Apply directional light
1177
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
1178
- if (i < lighting_uDirectionalLightCount) {
1179
- PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction);
1180
- color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color);
1062
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
1063
+ if (i < lighting.directionalLightCount) {
1064
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
1065
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
1181
1066
  }
1182
1067
  }
1183
1068
 
1184
1069
  // Apply point light
1185
- for(int i = 0; i < lighting_uPointLightCount; i++) {
1186
- if (i < lighting_uPointLightCount) {
1187
- PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]);
1188
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
1189
- color += calculateFinalColor(pbrInfo, lighting_uPointLight[i].color / attenuation);
1070
+ for(int i = 0; i < lighting.pointLightCount; i++) {
1071
+ if (i < lighting.pointLightCount) {
1072
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
1073
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
1074
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
1190
1075
  }
1191
1076
  }
1192
1077
  #endif
1193
1078
 
1194
1079
  // Calculate lighting contribution from image based lighting source (IBL)
1195
1080
  #ifdef USE_IBL
1196
- if (u_pbrMateral.IBLEnabled) {
1081
+ if (pbrMaterial.IBLenabled) {
1197
1082
  color += getIBLContribution(pbrInfo, n, reflection);
1198
1083
  }
1199
1084
  #endif
1200
1085
 
1201
- // Apply optional PBR terms for additional (optional) shading
1086
+ // Apply optional PBR terms for additional (optional) shading
1202
1087
  #ifdef HAS_OCCLUSIONMAP
1203
- if (u_pbrMaterial.occlusionMapEnabled) {
1204
- float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;
1205
- color = mix(color, color * ao, u_pbrMaterial.occlusionStrength);
1088
+ if (pbrMaterial.occlusionMapEnabled) {
1089
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
1090
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
1206
1091
  }
1207
1092
  #endif
1208
1093
 
1209
1094
  #ifdef HAS_EMISSIVEMAP
1210
- if (u_pbrMaterial.emmissiveMapEnabled) {
1211
- vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_pbrMaterial.emissiveFactor;
1095
+ if (pbrMaterial.emissiveMapEnabled) {
1096
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
1212
1097
  color += emissive;
1213
1098
  }
1214
1099
  #endif
@@ -1218,22 +1103,28 @@ vec4 pbr_filterColor(vec4 colorUnused)
1218
1103
  #ifdef PBR_DEBUG
1219
1104
  // TODO: Figure out how to debug multiple lights
1220
1105
 
1221
- // color = mix(color, F, u_ScaleFGDSpec.x);
1222
- // color = mix(color, vec3(G), u_ScaleFGDSpec.y);
1223
- // color = mix(color, vec3(D), u_ScaleFGDSpec.z);
1224
- // color = mix(color, specContrib, u_ScaleFGDSpec.w);
1106
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
1107
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
1108
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
1109
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
1225
1110
 
1226
- // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);
1227
- color = mix(color, baseColor.rgb, u_pbrMaterial.scaleDiffBaseMR.y);
1228
- color = mix(color, vec3(metallic), u_pbrMaterial.scaleDiffBaseMR.z);
1229
- color = mix(color, vec3(perceptualRoughness), u_pbrMaterial.scaleDiffBaseMR.w);
1111
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
1112
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
1113
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
1114
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
1230
1115
  #endif
1231
1116
 
1232
1117
  }
1233
1118
 
1234
1119
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
1235
1120
  }
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=`struct brightnessContrastUniforms {
1121
+ `;var Fr=`uniform pbrProjectionUniforms {
1122
+ mat4 modelViewProjectionMatrix;
1123
+ mat4 modelMatrix;
1124
+ mat4 normalMatrix;
1125
+ vec3 camera;
1126
+ } pbrProjection;
1127
+ `,Mr={name:"pbrProjection",vs:Fr,fs:Fr,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<i32>"}};var Cr={props:{},uniforms:{},name:"pbrMaterial",dependencies:[X,Mr],vs:Er,fs:Ir,defines:{LIGHTING_FRAGMENT:1},getUniforms:t=>t,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>"}};var yi=`struct brightnessContrastUniforms {
1237
1128
  float brightness;
1238
1129
  float contrast;
1239
1130
  };
@@ -1250,7 +1141,7 @@ fn brightnessContrast_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texC
1250
1141
  }
1251
1142
  return color;
1252
1143
  }
1253
- `,yo=`uniform brightnessContrastUniforms {
1144
+ `,wi=`uniform brightnessContrastUniforms {
1254
1145
  float brightness;
1255
1146
  float contrast;
1256
1147
  } brightnessContrast;
@@ -1268,7 +1159,7 @@ vec4 brightnessContrast_filterColor(vec4 color) {
1268
1159
  vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1269
1160
  return brightnessContrast_filterColor(color);
1270
1161
  }
1271
- `,Mr={props:{},uniforms:{},name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},defaultUniforms:{brightness:0,contrast:0},propTypes:{brightness:{format:"f32",value:0,min:-1,max:1},contrast:{format:"f32",value:0,min:-1,max:1}},passes:[{filter:!0}],source:bo,fs:yo};var wo=`uniform denoiseUniforms {
1162
+ `,Rr={props:{},name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},defaultUniforms:{brightness:0,contrast:0},propTypes:{brightness:{format:"f32",value:0,min:-1,max:1},contrast:{format:"f32",value:0,min:-1,max:1}},passes:[{filter:!0}],source:yi,fs:wi};var Pi=`uniform denoiseUniforms {
1272
1163
  float strength;
1273
1164
  } noise;
1274
1165
 
@@ -1290,7 +1181,7 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1290
1181
 
1291
1182
  return color / total;
1292
1183
  }
1293
- `,Cr={props:{},uniforms:{},name:"denoise",uniformTypes:{strength:"f32"},propTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:wo,passes:[{sampler:!0},{sampler:!0}]};var Lo=`uniform hueSaturationUniforms {
1184
+ `,Or={props:{},uniforms:{},name:"denoise",uniformTypes:{strength:"f32"},propTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:Pi,passes:[{sampler:!0},{sampler:!0}]};var Li=`uniform hueSaturationUniforms {
1294
1185
  float hue;
1295
1186
  float saturation;
1296
1187
  } hueSaturation;
@@ -1321,7 +1212,7 @@ vec4 hueSaturation_filterColor(vec4 color) {
1321
1212
  vec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1322
1213
  return hueSaturation_filterColor(color);
1323
1214
  }
1324
- `,Rr={props:{},uniforms:{},name:"hueSaturation",fs:Lo,uniformTypes:{hue:"f32",saturation:"f32"},propTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},passes:[{filter:!0}]};var Po=`uniform noiseUniforms {
1215
+ `,Ur={props:{},name:"hueSaturation",fs:Li,uniformTypes:{hue:"f32",saturation:"f32"},propTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},passes:[{filter:!0}]};var Si=`uniform noiseUniforms {
1325
1216
  float amount;
1326
1217
  } noise;
1327
1218
 
@@ -1336,7 +1227,7 @@ vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1336
1227
  color.b += diff;
1337
1228
  return color;
1338
1229
  }
1339
- `,Or={props:{},uniforms:{},name:"noise",uniformTypes:{amount:"f32"},propTypes:{amount:{value:.5,min:0,max:1}},fs:Po,passes:[{filter:!0}]};var So=`uniform sepiaUniforms {
1230
+ `,zr={props:{},uniforms:{},name:"noise",uniformTypes:{amount:"f32"},propTypes:{amount:{value:.5,min:0,max:1}},fs:Si,passes:[{filter:!0}]};var ki=`uniform sepiaUniforms {
1340
1231
  float amount;
1341
1232
  } sepia;
1342
1233
 
@@ -1356,7 +1247,7 @@ vec4 sepia_filterColor(vec4 color) {
1356
1247
  vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1357
1248
  return sepia_filterColor(color);
1358
1249
  }
1359
- `,Ur={props:{},uniforms:{},name:"sepia",uniformTypes:{amount:"f32"},propTypes:{amount:{value:.5,min:0,max:1}},fs:So,passes:[{filter:!0}]};var ko=`uniform vibranceUniforms {
1250
+ `,Dr={props:{},uniforms:{},name:"sepia",uniformTypes:{amount:"f32"},propTypes:{amount:{value:.5,min:0,max:1}},fs:ki,passes:[{filter:!0}]};var Ti=`uniform vibranceUniforms {
1360
1251
  float amount;
1361
1252
  } vibrance;
1362
1253
 
@@ -1371,7 +1262,7 @@ vec4 vibrance_filterColor(vec4 color) {
1371
1262
  vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1372
1263
  return vibrance_filterColor(color);
1373
1264
  }
1374
- `,zr={props:{},uniforms:{},name:"vibrance",propTypes:{amount:{value:0,min:-1,max:1}},fs:ko,passes:[{filter:!0}]};var To=`uniform vignetteUniforms {
1265
+ `,Br={props:{},uniforms:{},name:"vibrance",uniformTypes:{amount:"f32"},propTypes:{amount:{value:0,min:-1,max:1}},fs:Ti,passes:[{filter:!0}]};var Ni=`uniform vignetteUniforms {
1375
1266
  float radius;
1376
1267
  float amount;
1377
1268
  } vignette;
@@ -1381,7 +1272,7 @@ vec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1381
1272
  float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
1382
1273
  return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
1383
1274
  }
1384
- `,Dr={props:{},uniforms:{},name:"vignette",uniformTypes:{radius:"f32",amount:"f32"},defaultUniforms:{radius:.5,amount:.5},propTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}],fs:To};var Eo=`uniform tiltShiftUniforms {
1275
+ `,Xr={props:{},uniforms:{},name:"vignette",uniformTypes:{radius:"f32",amount:"f32"},defaultUniforms:{radius:.5,amount:.5},propTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}],fs:Ni};var Ei=`uniform tiltShiftUniforms {
1385
1276
  float blurRadius;
1386
1277
  float gradientRadius;
1387
1278
  vec2 start;
@@ -1424,7 +1315,7 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1424
1315
 
1425
1316
  return color;
1426
1317
  }
1427
- `,Br={props:{},uniforms:{},name:"tiltShift",dependencies:[Q],uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},propTypes:{blurRadius:{value:15,min:0,max:50},gradientRadius:{value:200,min:0,max:400},start:{value:[0,0]},end:{value:[1,1]},invert:{value:0,private:!0}},passes:[{sampler:!0,uniforms:{invert:0}},{sampler:!0,uniforms:{invert:1}}],fs:Eo};var No=`uniform triangleBlurUniforms {
1318
+ `,Yr={props:{},uniforms:{},name:"tiltShift",dependencies:[Q],uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},propTypes:{blurRadius:{value:15,min:0,max:50},gradientRadius:{value:200,min:0,max:400},start:{value:[0,0]},end:{value:[1,1]},invert:{value:0,private:!0}},passes:[{sampler:!0,uniforms:{invert:0}},{sampler:!0,uniforms:{invert:1}}],fs:Ei};var Ii=`uniform triangleBlurUniforms {
1428
1319
  float radius;
1429
1320
  vec2 delta;
1430
1321
  } triangleBlur;
@@ -1457,7 +1348,7 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1457
1348
 
1458
1349
  return color;
1459
1350
  }
1460
- `,Xr={props:{},uniforms:{},name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},propTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:No,dependencies:[Q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var Io=`
1351
+ `,Qr={props:{},uniforms:{},name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},propTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Ii,dependencies:[Q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var Fi=`
1461
1352
  uniform zoomBlurUniforms {
1462
1353
  vec2 center;
1463
1354
  float strength;
@@ -1490,7 +1381,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1490
1381
 
1491
1382
  return color;
1492
1383
  }
1493
- `,Yr={props:{},uniforms:{},name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},propTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:Io,dependencies:[Q],passes:[{sampler:!0}]};var Fo=`uniform colorHalftoneUniforms {
1384
+ `,Gr={props:{},uniforms:{},name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},propTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:Fi,dependencies:[Q],passes:[{sampler:!0}]};var Mi=`uniform colorHalftoneUniforms {
1494
1385
  vec2 center;
1495
1386
  float angle;
1496
1387
  float size;
@@ -1524,7 +1415,7 @@ vec4 colorHalftone_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1524
1415
  k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
1525
1416
  return vec4(1.0 - cmy - k, color.a);
1526
1417
  }
1527
- `,Qr={props:{},uniforms:{},name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},propTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:4,min:1,softMin:3,softMax:20}},fs:Fo,passes:[{filter:!0}]};var Mo=`uniform dotScreenUniforms {
1418
+ `,qr={props:{},uniforms:{},name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},propTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:4,min:1,softMin:3,softMax:20}},fs:Mi,passes:[{filter:!0}]};var Ci=`uniform dotScreenUniforms {
1528
1419
  vec2 center;
1529
1420
  float angle;
1530
1421
  float size;
@@ -1546,13 +1437,13 @@ vec4 dotScreen_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
1546
1437
  float average = (color.r + color.g + color.b) / 3.0;
1547
1438
  return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
1548
1439
  }
1549
- `,Gr={props:{},uniforms:{},name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},propTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:3,min:1,softMin:3,softMax:20}},fs:Mo,passes:[{filter:!0}]};var Co=`uniform edgeWorkUniforms {
1440
+ `,Hr={props:{},uniforms:{},name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},propTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:3,min:1,softMin:3,softMax:20}},fs:Ci,passes:[{filter:!0}]};var Ri=`uniform edgeWorkUniforms {
1550
1441
  float radius;
1551
- vec2 delta;
1442
+ int mode;
1552
1443
  } edgeWork;
1553
1444
 
1554
- vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
1555
- vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
1445
+ vec4 edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
1446
+ vec2 relativeDelta = edgeWork.radius * delta / texSize;
1556
1447
 
1557
1448
  vec2 color = vec2(0.0);
1558
1449
  vec2 total = vec2(0.0);
@@ -1576,8 +1467,8 @@ vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
1576
1467
  return vec4(color / total, 0.0, 1.0);
1577
1468
  }
1578
1469
 
1579
- vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
1580
- vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
1470
+ vec4 edgeWork_sampleColorXY(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
1471
+ vec2 relativeDelta = edgeWork.radius * delta / texSize;
1581
1472
 
1582
1473
  vec2 color = vec2(0.0);
1583
1474
  vec2 total = vec2(0.0);
@@ -1600,7 +1491,17 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
1600
1491
  float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
1601
1492
  return vec4(c, c, c, 1.0);
1602
1493
  }
1603
- `,qr={props:{},uniforms:{},name:"edgeWork",dependencies:[Q],fs:Co,propTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},passes:[{sampler:"edgeWork_sampleColor1",propTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",propTypes:{delta:[0,1]}}]};var Ro=`uniform hexagonalPixelateUniforms {
1494
+
1495
+ vec4 edgeWork_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1496
+ switch (edgeWork.mode) {
1497
+ case 0:
1498
+ return edgeWork_sampleColorRGB(source, texSize, texCoord, vec2(1., 0.));
1499
+ case 1:
1500
+ default:
1501
+ return edgeWork_sampleColorXY(source, texSize, texCoord, vec2(0., 1.));
1502
+ }
1503
+ }
1504
+ `,Vr={props:{},uniforms:{},name:"edgeWork",dependencies:[Q],fs:Ri,uniformTypes:{radius:"f32",mode:"i32"},propTypes:{radius:{value:2,min:1,softMax:50},mode:{value:0,private:!0}},passes:[{sampler:!0,uniforms:{mode:0}},{sampler:!0,uniforms:{mode:1}}]};var Oi=`uniform hexagonalPixelateUniforms {
1604
1505
  vec2 center;
1605
1506
  float scale;
1606
1507
  } hexagonalPixelate;
@@ -1642,7 +1543,7 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
1642
1543
 
1643
1544
  return texture(source, choice + hexagonalPixelate.center);
1644
1545
  }
1645
- `,Hr={props:{},uniforms:{},name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},propTypes:{center:{value:[.5,.5],hint:"screenspace"},scale:{value:10,min:1,softMin:5,softMax:50}},fs:Ro,passes:[{sampler:!0}]};var Oo=`uniform inkUniforms {
1546
+ `,Wr={props:{},uniforms:{},name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},propTypes:{center:{value:[.5,.5],hint:"screenspace"},scale:{value:10,min:1,softMin:5,softMax:50}},fs:Oi,passes:[{sampler:!0}]};var Ui=`uniform inkUniforms {
1646
1547
  float strength;
1647
1548
  } ink;
1648
1549
 
@@ -1669,7 +1570,7 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1669
1570
  float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
1670
1571
  return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
1671
1572
  }
1672
- `,Vr={props:{},uniforms:{},name:"ink",fs:Oo,uniformTypes:{strength:"f32"},propTypes:{strength:{value:.25,min:0,softMax:1}},passes:[{sampler:!0}]};var Uo=`uniform magnifyUniforms {
1573
+ `,jr={props:{},uniforms:{},name:"ink",fs:Ui,uniformTypes:{strength:"f32"},propTypes:{strength:{value:.25,min:0,softMax:1}},passes:[{sampler:!0}]};var zi=`uniform magnifyUniforms {
1673
1574
  vec2 screenXY;
1674
1575
  float radiusPixels;
1675
1576
  float zoom;
@@ -1689,7 +1590,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1689
1590
  }
1690
1591
  return texture(source, texCoord);
1691
1592
  }
1692
- `,Wr={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},propTypes:{screenXY:{value:[0,0]},radiusPixels:200,zoom:2,borderWidthPixels:0,borderColor:{value:[255,255,255,255]}},fs:Uo,passes:[{sampler:!0}]};var zo=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1593
+ `,$r={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},propTypes:{screenXY:{value:[0,0]},radiusPixels:200,zoom:2,borderWidthPixels:0,borderColor:{value:[255,255,255,255]}},fs:zi,passes:[{sampler:!0}]};var Di=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
1693
1594
  vec4 color = texture(source, coord / texSize);
1694
1595
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
1695
1596
  if (coord != clampedCoord) {
@@ -1699,7 +1600,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1699
1600
 
1700
1601
  return color;
1701
1602
  }
1702
- `,_e={name:"warp",passes:[],fs:zo};var Do=`uniform bulgePinchUniforms {
1603
+ `,_e={name:"warp",passes:[],fs:Di};var Bi=`uniform bulgePinchUniforms {
1703
1604
  float radius;
1704
1605
  float strength;
1705
1606
  vec2 center;
@@ -1726,7 +1627,7 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1726
1627
 
1727
1628
  return warp_sampleColor(source, texSize, coord);
1728
1629
  }
1729
- `,jr={props:{},uniforms:{},name:"bulgePinch",dependencies:[_e],fs:Do,uniformTypes:{center:"vec2<f32>",radius:"f32",strength:"f32"},propTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},strength:{value:.5,min:-1,max:1}},passes:[{sampler:!0}]};var Bo=`uniform swirlUniforms {
1630
+ `,Kr={props:{},uniforms:{},name:"bulgePinch",dependencies:[_e],fs:Bi,uniformTypes:{center:"vec2<f32>",radius:"f32",strength:"f32"},propTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},strength:{value:.5,min:-1,max:1}},passes:[{sampler:!0}]};var Xi=`uniform swirlUniforms {
1730
1631
  float radius;
1731
1632
  float angle;
1732
1633
  vec2 center;
@@ -1755,7 +1656,7 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
1755
1656
 
1756
1657
  return warp_sampleColor(source, texSize, coord);
1757
1658
  }
1758
- `,$r={props:{},uniforms:{},name:"swirl",dependencies:[_e],fs:Bo,uniformTypes:{center:"vec2<f32>",radius:"f32",angle:"f32"},propTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},angle:{value:3,softMin:-25,softMax:25}},passes:[{sampler:!0}]};var Xo=`
1659
+ `,Zr={props:{},uniforms:{},name:"swirl",dependencies:[_e],fs:Xi,uniformTypes:{center:"vec2<f32>",radius:"f32",angle:"f32"},propTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},angle:{value:3,softMin:-25,softMax:25}},passes:[{sampler:!0}]};var Yi=`
1759
1660
  #define FXAA_QUALITY_PRESET 29
1760
1661
 
1761
1662
  #if (FXAA_QUALITY_PRESET == 10)
@@ -2335,7 +2236,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
2335
2236
  fxaa_QualityEdgeThresholdMin
2336
2237
  );
2337
2238
  }
2338
- `,Kr={name:"fxaa",propTypes:{},fs:Xo,passes:[{sampler:!0}],getUniforms:t=>t};var Zr=`uniform float ONE;
2239
+ `,Jr={name:"fxaa",propTypes:{},fs:Yi,passes:[{sampler:!0}],getUniforms:t=>t};var eo=`uniform float ONE;
2339
2240
 
2340
2241
  /*
2341
2242
  About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
@@ -2500,7 +2401,7 @@ vec2 sqrt_fp64(vec2 a) {
2500
2401
  return sum_fp64(vec2(yn, 0.0), prod);
2501
2402
  #endif
2502
2403
  }
2503
- `;var Jr=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
2404
+ `;var to=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
2504
2405
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
2505
2406
  const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
2506
2407
  const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
@@ -3169,7 +3070,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
3169
3070
  vec4_dot_fp64(a, tmp, out_val[i]);
3170
3071
  }
3171
3072
  }
3172
- `;var Yo={ONE:1};function Qo(){return Yo}var fn={name:"fp64-arithmetic",vs:Zr,getUniforms:Qo,fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te},ei={name:"fp64",vs:Jr,dependencies:[fn],fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te};var Go=`varying vec4 geometry_vPosition;
3073
+ `;var Qi={ONE:1};function Gi(){return Qi}var _n={name:"fp64-arithmetic",vs:eo,getUniforms:Gi,fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te},no={name:"fp64",vs:to,dependencies:[_n],fp64ify:he,fp64LowPart:ke,fp64ifyMatrix4:Te};var qi=`varying vec4 geometry_vPosition;
3173
3074
  varying vec3 geometry_vNormal;
3174
3075
 
3175
3076
  void geometry_setNormal(vec3 normal) {
@@ -3183,7 +3084,7 @@ void geometry_setPosition(vec4 position) {
3183
3084
  void geometry_setPosition(vec3 position) {
3184
3085
  geometry_vPosition = vec4(position, 1.);
3185
3086
  }
3186
- `,qo=`varying vec4 geometry_vPosition;
3087
+ `,Hi=`varying vec4 geometry_vPosition;
3187
3088
  varying vec3 geometry_vNormal;
3188
3089
 
3189
3090
  vec4 geometry_getPosition() {
@@ -3193,7 +3094,7 @@ vec4 geometry_getPosition() {
3193
3094
  vec3 geometry_getNormal() {
3194
3095
  return geometry_vNormal;
3195
3096
  }
3196
- `,ti={name:"geometry",vs:Go,fs:qo};var un=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ho={modelMatrix:un,viewMatrix:un,projectionMatrix:un,cameraPositionWorld:[0,0,0]};function Vo(t=Ho,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;
3097
+ `,ro={name:"geometry",vs:qi,fs:Hi};var pn=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Vi={modelMatrix:pn,viewMatrix:pn,projectionMatrix:pn,cameraPositionWorld:[0,0,0]};function Wi(t=Vi,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 oo=`varying vec4 project_vPositionWorld;
3197
3098
  varying vec3 project_vNormalWorld;
3198
3099
 
3199
3100
  vec4 project_getPosition_World() {
@@ -3203,7 +3104,7 @@ vec4 project_getPosition_World() {
3203
3104
  vec3 project_getNormal_World() {
3204
3105
  return project_vNormalWorld;
3205
3106
  }
3206
- `,Wo=`${ni}
3107
+ `,ji=`${oo}
3207
3108
 
3208
3109
  // Unprefixed uniforms
3209
3110
  uniform mat4 modelMatrix;
@@ -3256,8 +3157,8 @@ vec4 project_view_to_clipspace(vec3 position) {
3256
3157
  vec4 project_to_clipspace(vec3 position) {
3257
3158
  return viewProjectionMatrix * vec4(position, 1.);
3258
3159
  }
3259
- `,jo=`
3260
- ${ni}`,at={name:"project",getUniforms:Vo,vs:Wo,fs:jo};var hn=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3160
+ `,$i=`
3161
+ ${oo}`,ft={name:"project",getUniforms:Wi,vs:ji,fs:$i};var dn=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3261
3162
 
3262
3163
  struct AmbientLight {
3263
3164
  vec3 color;
@@ -3291,7 +3192,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
3291
3192
  }
3292
3193
 
3293
3194
  #endif
3294
- `;var $o={lightSources:{}};function _n(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/255)}function Ko({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=$o){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({},Ko({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 Zo={lightDirection:new Float32Array([1,1,2])};function Jo(t=Zo){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var es=`uniform vec3 dirlight_uLightDirection;
3195
+ `;var Ki={lightSources:{}};function mn(t={}){let{color:e=[0,0,0],intensity:n=1}=t;return e.map(r=>r*n/255)}function Zi({ambientLight:t,pointLights:e=[],directionalLights:n=[]}){let r={};return t?r["lighting_uAmbientLight.color"]=mn(t):r["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{r[`lighting_uPointLight[${i}].color`]=mn(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`]=mn(o),r[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),r.lighting_uDirectionalLightCount=n.length,r}function io(t=Ki){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({},Zi({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 io({lightSources:e})}return{}}var ne={name:"lights",vs:dn,fs:dn,getUniforms:io,defines:{MAX_LIGHTS:3}};var Ji={lightDirection:new Float32Array([1,1,2])};function es(t=Ji){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var ts=`uniform vec3 dirlight_uLightDirection;
3295
3196
 
3296
3197
  /*
3297
3198
  * Returns color attenuated by angle from light source
@@ -3301,7 +3202,7 @@ vec4 dirlight_filterColor(vec4 color) {
3301
3202
  float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
3302
3203
  return vec4(color.rgb * d, color.a);
3303
3204
  }
3304
- `,ii={name:"dirlight",fs:es,getUniforms:Jo,dependencies:[at]};var pn=`
3205
+ `,so={name:"dirlight",fs:ts,getUniforms:es,dependencies:[ft]};var gn=`
3305
3206
  uniform float lighting_uAmbient;
3306
3207
  uniform float lighting_uDiffuse;
3307
3208
  uniform float lighting_uShininess;
@@ -3374,7 +3275,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
3374
3275
  }
3375
3276
  return lightColor;
3376
3277
  }
3377
- `;var ts={};function ns(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=ts){if(!("material"in t))return{};let{material:e}=t;return e?ns(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;
3278
+ `;var ns={};function rs(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 ao(t=ns){if(!("material"in t))return{};let{material:e}=t;return e?rs(e):{lighting_uEnabled:!1}}var co={name:"gouraud-lighting",dependencies:[ne],vs:gn,defines:{LIGHTING_VERTEX:1},getUniforms:ao},lo={name:"phong-lighting",dependencies:[ne],fs:gn,defines:{LIGHTING_FRAGMENT:1},getUniforms:ao};var fo=`uniform mat4 u_MVPMatrix;
3378
3279
  uniform mat4 u_ModelMatrix;
3379
3280
  uniform mat4 u_NormalMatrix;
3380
3281
 
@@ -3411,7 +3312,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
3411
3312
  pbr_vUV = vec2(0.,0.);
3412
3313
  #endif
3413
3314
  }
3414
- `;var li=`precision highp float;
3315
+ `;var uo=`precision highp float;
3415
3316
 
3416
3317
  uniform bool pbr_uUnlit;
3417
3318
 
@@ -3792,7 +3693,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
3792
3693
 
3793
3694
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
3794
3695
  }
3795
- `;var fi={name:"pbr",vs:ci,fs:li,defines:{LIGHTING_FRAGMENT:1},dependencies:[ne],getUniforms:t=>t};return vi(Ne);})();
3696
+ `;var ho={name:"pbr",vs:fo,fs:uo,defines:{LIGHTING_FRAGMENT:1},dependencies:[ne],getUniforms:t=>t};return yo(Ee);})();
3796
3697
  /**
3797
3698
  * ORIGINAL LICENCE
3798
3699
  * @license