@luma.gl/shadertools 9.1.0-alpha.14 → 9.1.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +143 -122
- package/dist/dist.min.js +63 -55
- package/dist/index.cjs +141 -120
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +39 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -21
- package/dist/lib/shader-module/shader-module.d.ts +2 -2
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +22 -4
- package/dist/lib/shader-module/shader-pass.d.ts +13 -6
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/module-injectors.d.ts +1 -1
- package/dist/module-injectors.d.ts.map +1 -1
- package/dist/module-injectors.js +5 -5
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +1 -0
- package/dist/modules/module-injectors.d.ts +1 -1
- package/dist/modules/module-injectors.d.ts.map +1 -1
- package/dist/modules/module-injectors.js +5 -5
- package/dist/{modules → passes}/postprocessing/fxaa/fxaa.d.ts +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/fxaa/fxaa.js +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +44 -0
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/brightnesscontrast.js +28 -5
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/denoise.js +1 -1
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/huesaturation.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/noise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/noise.js +2 -6
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/sepia.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/vibrance.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/vibrance.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/vignette.d.ts +6 -2
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-adjust-filters/vignette.js +6 -6
- package/dist/{modules → passes}/postprocessing/image-blur-filters/tiltshift.d.ts +4 -4
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-blur-filters/tiltshift.js +5 -5
- package/dist/{modules → passes}/postprocessing/image-blur-filters/triangleblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-blur-filters/triangleblur.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-blur-filters/zoomblur.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-fun-filters/colorhalftone.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/colorhalftone.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-fun-filters/dotscreen.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/dotscreen.js +2 -2
- package/dist/{modules → passes}/postprocessing/image-fun-filters/edgework.d.ts +3 -3
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/edgework.js +4 -4
- package/dist/{modules → passes}/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/hexagonalpixelate.js +1 -1
- package/dist/{modules → passes}/postprocessing/image-fun-filters/ink.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/ink.js +1 -1
- package/dist/{modules → passes}/postprocessing/image-fun-filters/magnify.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-fun-filters/magnify.js +1 -1
- package/dist/{modules → passes}/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-warp-filters/bulgepinch.js +1 -1
- package/dist/{modules → passes}/postprocessing/image-warp-filters/swirl.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -0
- package/dist/{modules → passes}/postprocessing/image-warp-filters/swirl.js +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +40 -40
- package/src/lib/shader-module/shader-module.ts +25 -6
- package/src/lib/shader-module/shader-pass.ts +17 -5
- package/src/module-injectors.ts +5 -5
- package/src/modules/engine/picking/README.md +9 -9
- package/src/modules/lighting/lights/lighting.ts +1 -0
- package/src/modules/module-injectors.ts +5 -5
- package/src/{modules → passes}/postprocessing/fxaa/fxaa.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-adjust-filters/brightnesscontrast.ts +30 -5
- package/src/{modules → passes}/postprocessing/image-adjust-filters/denoise.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-adjust-filters/huesaturation.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-adjust-filters/noise.ts +2 -6
- package/src/{modules → passes}/postprocessing/image-adjust-filters/sepia.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-adjust-filters/vibrance.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-adjust-filters/vignette.ts +6 -6
- package/src/{modules → passes}/postprocessing/image-blur-filters/tiltshift.ts +5 -5
- package/src/{modules → passes}/postprocessing/image-blur-filters/triangleblur.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-blur-filters/zoomblur.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-fun-filters/colorhalftone.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-fun-filters/dotscreen.ts +2 -2
- package/src/{modules → passes}/postprocessing/image-fun-filters/edgework.ts +4 -4
- package/src/{modules → passes}/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-fun-filters/ink.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-fun-filters/magnify.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
- package/src/{modules → passes}/postprocessing/image-warp-filters/swirl.ts +1 -1
- package/dist/modules/postprocessing/fxaa/fxaa.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +0 -39
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +0 -1
- /package/dist/{modules → passes}/postprocessing/image-warp-filters/warp.d.ts +0 -0
- /package/dist/{modules → passes}/postprocessing/image-warp-filters/warp.js +0 -0
- /package/src/{modules → passes}/postprocessing/image-warp-filters/warp.ts +0 -0
package/dist/dist.min.js
CHANGED
|
@@ -4,24 +4,24 @@
|
|
|
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((
|
|
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
|
|
8
8
|
logdepth_adjustPosition(gl_Position);
|
|
9
9
|
#endif
|
|
10
10
|
`,yn=`#ifdef MODULE_MATERIAL
|
|
11
|
-
|
|
11
|
+
fragColor = material_filterColor(fragColor);
|
|
12
12
|
#endif
|
|
13
13
|
|
|
14
14
|
#ifdef MODULE_LIGHTING
|
|
15
|
-
|
|
15
|
+
fragColor = lighting_filterColor(fragColor);
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
#ifdef MODULE_FOG
|
|
19
|
-
|
|
19
|
+
fragColor = fog_filterColor(fragColor);
|
|
20
20
|
#endif
|
|
21
21
|
|
|
22
22
|
#ifdef MODULE_PICKING
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
fragColor = picking_filterHighlightColor(fragColor);
|
|
24
|
+
fragColor = picking_filterPickingColor(fragColor);
|
|
25
25
|
#endif
|
|
26
26
|
|
|
27
27
|
#ifdef MODULE_LOGDEPTH
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
`;var bi={vertex:bn,fragment:yn},wn=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ln=/}\n?[^{}]*$/,ft=[],me="__LUMA_INJECT_DECLARATIONS__";function Pn(t){let e={vertex:{},fragment:{}};for(let n in t){let r=t[n],i=yi(n);typeof r=="string"&&(r={order:0,injection:r}),e[i][n]=r}return e}function yi(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function ge(t,e,n,r=!1){let i=e==="vertex";for(let o in n){let a=n[o];a.sort((u,_)=>u.order-_.order),ft.length=a.length;for(let u=0,_=a.length;u<_;++u)ft[u]=a[u].injection;let c=`${ft.join(`
|
|
31
31
|
`)}
|
|
32
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{
|
|
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
|
|
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
|
|
@@ -100,7 +100,7 @@ void main() {
|
|
|
100
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==`
|
|
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 Vs=1/Math.PI*180,Ws=1/180*Math.PI,Yi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Yi}};var R=globalThis.mathgl.config;function Kt(t,{precision:e=R.precision}={}){return t=Qi(t),`${parseFloat(t.toPrecision(e))}`}function fe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zt(t,e,n){return qi(t,r=>Math.max(e,Math.min(n,r)))}function tt(t,e,n){let r=R.EPSILON;n&&(R.EPSILON=n);try{if(t===e)return!0;if(fe(t)&&fe(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(!tt(t[i],e[i]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=R.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{R.EPSILON=r}}function Qi(t){return Math.round(t/R.EPSILON)*R.EPSILON}function Gi(t){return t.clone?t.clone():new Array(t.length)}function qi(t,e,n){if(fe(t)){let r=t;n=n||Gi(r);for(let i=0;i<n.length&&i<r.length;++i){let o=typeof t=="number"?t:t[i];n[i]=e(o,i,n)}return n}return e(t)}var nt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+n];return this.check()}toArray(e=[],n=0){for(let r=0;r<this.ELEMENTS;++r)e[n+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:fe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(e){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Kt(this[r],e);return`${e.printTypes?this.constructor.name:""}[${n}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!tt(this[n],e[n]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==e[n])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,n,r){if(r===void 0)return this.lerp(this,e,n);for(let i=0;i<this.ELEMENTS;++i){let o=e[i],a=typeof n=="number"?n:n[i];this[i]=o+r*(a-o)}return this.check()}min(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(e[n],this[n]);return this.check()}max(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(e[n],this[n]);return this.check()}clamp(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),n[r]);return this.check()}add(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(e){if(typeof e=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;else for(let n=0;n<this.ELEMENTS&&n<e.length;++n)this[n]*=e[n];return this.check()}multiplyByScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}check(){if(R.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)e=e&&Number.isFinite(this[n]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=e;return this.check()}addScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),n);return this.check()}get elements(){return this}};function Hi(t,e){if(t.length!==e)return!1;for(let n=0;n<t.length;++n)if(!Number.isFinite(t[n]))return!1;return!0}function Vn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function rt(t,e,n=""){if(R.debug&&!Hi(t,e))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return t}var V=typeof Float32Array<"u"?Float32Array:Array;var ea=Math.PI/180;function Vi(){let t=new V(2);return V!=Float32Array&&(t[0]=0,t[1]=0),t}function $n(t,e,n){let r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t}var ta=function(){let t=Vi();return function(e,n,r,i,o,a){let c,u;for(n||(n=2),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],o(t,t,a),e[c]=t[0],e[c+1]=t[1];return e}}();function Kn(t,e,n){let r=e[0],i=e[1],o=n[3]*r+n[7]*i||1;return t[0]=(n[0]*r+n[4]*i)/o,t[1]=(n[1]*r+n[5]*i)/o,t}function Zn(t,e,n){let r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o||1;return t[0]=(n[0]*r+n[4]*i+n[8]*o)/a,t[1]=(n[1]*r+n[5]*i+n[9]*o)/a,t[2]=(n[2]*r+n[6]*i+n[10]*o)/a,t}function Wi(){let t=new V(3);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Jn(t,e,n){let r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}var ia=function(){let t=Wi();return function(e,n,r,i,o,a){let c,u;for(n||(n=3),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],o(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2];return e}}();var it=class extends nt{toString(){let e="[";if(R.printRowMajor){e+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+n]}`}else{e+="column-major:";for(let n=0;n<this.ELEMENTS;++n)e+=` ${this[n]}`}return e+="]",e}getElementIndex(e,n){return n*this.RANK+e}getElement(e,n){return this[n*this.RANK+e]}setElement(e,n,r){return this[n*this.RANK+e]=Vn(r),this}getColumn(e,n=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let i=0;i<this.RANK;++i)n[i]=this[r+i];return n}setColumn(e,n){let r=e*this.RANK;for(let i=0;i<this.RANK;++i)this[r+i]=n[i];return this}};function ji(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function er(t,e){if(t===e){let n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],c=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=c}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function tr(t,e){let n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],_=e[7],p=e[8],d=e[9],m=e[10],x=e[11],L=e[12],g=e[13],A=e[14],P=e[15],v=n*c-r*a,y=n*u-i*a,w=n*_-o*a,b=r*u-i*c,S=r*_-o*c,k=i*_-o*u,F=p*g-d*L,I=p*A-m*L,E=p*P-x*L,M=d*A-m*g,U=d*P-x*g,C=m*P-x*A,N=v*C-y*U+w*M+b*E-S*I+k*F;return N?(N=1/N,t[0]=(c*C-u*U+_*M)*N,t[1]=(i*U-r*C-o*M)*N,t[2]=(g*k-A*S+P*b)*N,t[3]=(m*S-d*k-x*b)*N,t[4]=(u*E-a*C-_*I)*N,t[5]=(n*C-i*E+o*I)*N,t[6]=(A*w-L*k-P*y)*N,t[7]=(p*k-m*w+x*y)*N,t[8]=(a*U-c*E+_*F)*N,t[9]=(r*E-n*U-o*F)*N,t[10]=(L*S-g*w+P*v)*N,t[11]=(d*w-p*S-x*v)*N,t[12]=(c*I-a*M-u*F)*N,t[13]=(n*M-r*I+i*F)*N,t[14]=(g*y-L*b-A*v)*N,t[15]=(p*b-d*y+m*v)*N,t):null}function nr(t){let e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],_=t[8],p=t[9],d=t[10],m=t[11],x=t[12],L=t[13],g=t[14],A=t[15],P=e*a-n*o,v=e*c-r*o,y=n*c-r*a,w=_*L-p*x,b=_*g-d*x,S=p*g-d*L,k=e*S-n*b+r*w,F=o*S-a*b+c*w,I=_*y-p*v+d*P,E=x*y-L*v+g*P;return u*k-i*F+A*I-m*E}function en(t,e,n){let r=e[0],i=e[1],o=e[2],a=e[3],c=e[4],u=e[5],_=e[6],p=e[7],d=e[8],m=e[9],x=e[10],L=e[11],g=e[12],A=e[13],P=e[14],v=e[15],y=n[0],w=n[1],b=n[2],S=n[3];return t[0]=y*r+w*c+b*d+S*g,t[1]=y*i+w*u+b*m+S*A,t[2]=y*o+w*_+b*x+S*P,t[3]=y*a+w*p+b*L+S*v,y=n[4],w=n[5],b=n[6],S=n[7],t[4]=y*r+w*c+b*d+S*g,t[5]=y*i+w*u+b*m+S*A,t[6]=y*o+w*_+b*x+S*P,t[7]=y*a+w*p+b*L+S*v,y=n[8],w=n[9],b=n[10],S=n[11],t[8]=y*r+w*c+b*d+S*g,t[9]=y*i+w*u+b*m+S*A,t[10]=y*o+w*_+b*x+S*P,t[11]=y*a+w*p+b*L+S*v,y=n[12],w=n[13],b=n[14],S=n[15],t[12]=y*r+w*c+b*d+S*g,t[13]=y*i+w*u+b*m+S*A,t[14]=y*o+w*_+b*x+S*P,t[15]=y*a+w*p+b*L+S*v,t}function rr(t,e,n){let r=n[0],i=n[1],o=n[2],a,c,u,_,p,d,m,x,L,g,A,P;return e===t?(t[12]=e[0]*r+e[4]*i+e[8]*o+e[12],t[13]=e[1]*r+e[5]*i+e[9]*o+e[13],t[14]=e[2]*r+e[6]*i+e[10]*o+e[14],t[15]=e[3]*r+e[7]*i+e[11]*o+e[15]):(a=e[0],c=e[1],u=e[2],_=e[3],p=e[4],d=e[5],m=e[6],x=e[7],L=e[8],g=e[9],A=e[10],P=e[11],t[0]=a,t[1]=c,t[2]=u,t[3]=_,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=L,t[9]=g,t[10]=A,t[11]=P,t[12]=a*r+p*i+L*o+e[12],t[13]=c*r+d*i+g*o+e[13],t[14]=u*r+m*i+A*o+e[14],t[15]=_*r+x*i+P*o+e[15]),t}function ir(t,e,n){let r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function or(t,e,n,r){let i=r[0],o=r[1],a=r[2],c=Math.sqrt(i*i+o*o+a*a),u,_,p,d,m,x,L,g,A,P,v,y,w,b,S,k,F,I,E,M,U,C,N,pe;return c<1e-6?null:(c=1/c,i*=c,o*=c,a*=c,_=Math.sin(n),u=Math.cos(n),p=1-u,d=e[0],m=e[1],x=e[2],L=e[3],g=e[4],A=e[5],P=e[6],v=e[7],y=e[8],w=e[9],b=e[10],S=e[11],k=i*i*p+u,F=o*i*p+a*_,I=a*i*p-o*_,E=i*o*p-a*_,M=o*o*p+u,U=a*o*p+i*_,C=i*a*p+o*_,N=o*a*p-i*_,pe=a*a*p+u,t[0]=d*k+g*F+y*I,t[1]=m*k+A*F+w*I,t[2]=x*k+P*F+b*I,t[3]=L*k+v*F+S*I,t[4]=d*E+g*M+y*U,t[5]=m*E+A*M+w*U,t[6]=x*E+P*M+b*U,t[7]=L*E+v*M+S*U,t[8]=d*C+g*N+y*pe,t[9]=m*C+A*N+w*pe,t[10]=x*C+P*N+b*pe,t[11]=L*C+v*N+S*pe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function sr(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],c=e[6],u=e[7],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+_*r,t[5]=a*i+p*r,t[6]=c*i+d*r,t[7]=u*i+m*r,t[8]=_*i-o*r,t[9]=p*i-a*r,t[10]=d*i-c*r,t[11]=m*i-u*r,t}function ar(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],c=e[2],u=e[3],_=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-_*r,t[1]=a*i-p*r,t[2]=c*i-d*r,t[3]=u*i-m*r,t[8]=o*r+_*i,t[9]=a*r+p*i,t[10]=c*r+d*i,t[11]=u*r+m*i,t}function cr(t,e,n){let r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],c=e[2],u=e[3],_=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+_*r,t[1]=a*i+p*r,t[2]=c*i+d*r,t[3]=u*i+m*r,t[4]=_*i-o*r,t[5]=p*i-a*r,t[6]=d*i-c*r,t[7]=m*i-u*r,t}function lr(t,e){let n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,c=r+r,u=i+i,_=n*a,p=r*a,d=r*c,m=i*a,x=i*c,L=i*u,g=o*a,A=o*c,P=o*u;return t[0]=1-d-L,t[1]=p+P,t[2]=m-A,t[3]=0,t[4]=p-P,t[5]=1-_-L,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-_-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fr(t,e,n,r,i,o,a){let c=1/(n-e),u=1/(i-r),_=1/(o-a);return t[0]=o*2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*u,t[6]=0,t[7]=0,t[8]=(n+e)*c,t[9]=(i+r)*u,t[10]=(a+o)*_,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*_,t[15]=0,t}function $i(t,e,n,r,i){let o=1/Math.tan(e/2);if(t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let a=1/(r-i);t[10]=(i+r)*a,t[14]=2*i*r*a}else t[10]=-1,t[14]=-2*r;return t}var ur=$i;function Ki(t,e,n,r,i,o,a){let c=1/(e-n),u=1/(r-i),_=1/(o-a);return t[0]=-2*c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*_,t[11]=0,t[12]=(e+n)*c,t[13]=(i+r)*u,t[14]=(a+o)*_,t[15]=1,t}var hr=Ki;function _r(t,e,n,r){let i,o,a,c,u,_,p,d,m,x,L=e[0],g=e[1],A=e[2],P=r[0],v=r[1],y=r[2],w=n[0],b=n[1],S=n[2];return Math.abs(L-w)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?ji(t):(d=L-w,m=g-b,x=A-S,i=1/Math.sqrt(d*d+m*m+x*x),d*=i,m*=i,x*=i,o=v*x-y*m,a=y*d-P*x,c=P*m-v*d,i=Math.sqrt(o*o+a*a+c*c),i?(i=1/i,o*=i,a*=i,c*=i):(o=0,a=0,c=0),u=m*c-x*a,_=x*o-d*c,p=d*a-m*o,i=Math.sqrt(u*u+_*_+p*p),i?(i=1/i,u*=i,_*=i,p*=i):(u=0,_=0,p=0),t[0]=o,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=_,t[6]=m,t[7]=0,t[8]=c,t[9]=p,t[10]=x,t[11]=0,t[12]=-(o*L+a*g+c*A),t[13]=-(u*L+_*g+p*A),t[14]=-(d*L+m*g+x*A),t[15]=1,t)}function Zi(){let t=new V(4);return V!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pr(t,e,n){let r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}var ua=function(){let t=Zi();return function(e,n,r,i,o,a){let c,u;for(n||(n=4),r||(r=0),i?u=Math.min(i*n+r,e.length):u=e.length,c=r;c<u;c+=n)t[0]=e[c],t[1]=e[c+1],t[2]=e[c+2],t[3]=e[c+3],o(t,t,a),e[c]=t[0],e[c+1]=t[1],e[c+2]=t[2],e[c+3]=t[3];return e}}();var rn;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(rn||(rn={}));var Ji=45*Math.PI/180,eo=1,tn=.1,nn=500,to=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends it{static get IDENTITY(){return ro()}static get ZERO(){return no()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rn}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,n,r,i,o,a,c,u,_,p,d,m,x,L,g,A){return this[0]=e,this[1]=n,this[2]=r,this[3]=i,this[4]=o,this[5]=a,this[6]=c,this[7]=u,this[8]=_,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=L,this[14]=g,this[15]=A,this.check()}setRowMajor(e,n,r,i,o,a,c,u,_,p,d,m,x,L,g,A){return this[0]=e,this[1]=o,this[2]=_,this[3]=x,this[4]=n,this[5]=a,this[6]=p,this[7]=L,this[8]=r,this[9]=c,this[10]=d,this[11]=g,this[12]=i,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(to)}fromObject(e){return this.check()}fromQuaternion(e){return lr(this,e),this.check()}frustum(e){let{left:n,right:r,bottom:i,top:o,near:a=tn,far:c=nn}=e;return c===1/0?io(this,n,r,i,o,a):fr(this,n,r,i,o,a,c),this.check()}lookAt(e){let{eye:n,center:r=[0,0,0],up:i=[0,1,0]}=e;return _r(this,n,r,i),this.check()}ortho(e){let{left:n,right:r,bottom:i,top:o,near:a=tn,far:c=nn}=e;return hr(this,n,r,i,o,a,c),this.check()}orthographic(e){let{fovy:n=Ji,aspect:r=eo,focalDistance:i=1,near:o=tn,far:a=nn}=e;dr(n);let c=n/2,u=i*Math.tan(c),_=u*r;return this.ortho({left:-_,right:_,bottom:-u,top:u,near:o,far:a})}perspective(e){let{fovy:n=45*Math.PI/180,aspect:r=1,near:i=.1,far:o=500}=e;return dr(n),ur(this,n,r,i,o),this.check()}determinant(){return nr(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),i=1/r[0],o=1/r[1],a=1/r[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*i,e[5]=this[5]*o,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*i,e[9]=this[9]*o,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),i=1/r[0],o=1/r[1],a=1/r[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*a,e[3]=this[4]*i,e[4]=this[5]*o,e[5]=this[6]*a,e[6]=this[8]*i,e[7]=this[9]*o,e[8]=this[10]*a,e}transpose(){return er(this,this),this.check()}invert(){return tr(this,this),this.check()}multiplyLeft(e){return en(this,e,this),this.check()}multiplyRight(e){return en(this,this,e),this.check()}rotateX(e){return sr(this,this,e),this.check()}rotateY(e){return ar(this,this,e),this.check()}rotateZ(e){return cr(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,n){return or(this,this,e,n),this.check()}scale(e){return ir(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return rr(this,this,e),this.check()}transform(e,n){return e.length===4?(n=pr(n||[-0,-0,-0,-0],e,this),rt(n,4),n):this.transformAsPoint(e,n)}transformAsPoint(e,n){let{length:r}=e,i;switch(r){case 2:i=$n(n||[-0,-0],e,this);break;case 3:i=Jn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(i,e.length),i}transformAsVector(e,n){let r;switch(e.length){case 2:r=Kn(n||[-0,-0],e,this);break;case 3:r=Zn(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return rt(r,e.length),r}transformPoint(e,n){return this.transformAsPoint(e,n)}transformVector(e,n){return this.transformAsPoint(e,n)}transformDirection(e,n){return this.transformAsVector(e,n)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,n,r){return this.identity().translate([e,n,r])}},ot,st;function no(){return ot||(ot=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ot)),ot}function ro(){return st||(st=new ee,Object.freeze(st)),st}function dr(t){if(t>Math.PI*2)throw Error("expected radians")}function io(t,e,n,r,i,o){let a=2*o/(n-e),c=2*o/(i-r),u=(n+e)/(n-e),_=(i+r)/(i-r),p=-1,d=-1,m=-2*o;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=u,t[9]=_,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var te=null,mr=new ArrayBuffer(4),gr=new Float32Array(mr),xr=new Uint32Array(mr);function vr(t){te||=br(),t=Zt(t,-65504,65504),gr[0]=t;let e=xr[0],n=e>>23&511;return te.baseTable[n]+((e&8388607)>>te.shiftTable[n])}function Ar(t){te||=br();let e=t>>10;return xr[0]=te.mantissaTable[te.offsetTable[e]+(t&1023)]+te.exponentTable[e],gr[0]}function br(){let t=new Uint32Array(512),e=new Uint32Array(512);for(let o=0;o<256;++o){let a=o-127;a<-27?(t[o]=0,t[o|256]=32768,e[o]=24,e[o|256]=24):a<-14?(t[o]=1024>>-a-14,t[o|256]=1024>>-a-14|32768,e[o]=-a-1,e[o|256]=-a-1):a<=15?(t[o]=a+15<<10,t[o|256]=a+15<<10|32768,e[o]=13,e[o|256]=13):a<128?(t[o]=31744,t[o|256]=64512,e[o]=24,e[o|256]=24):(t[o]=31744,t[o|256]=64512,e[o]=13,e[o|256]=13)}let n=new Uint32Array(2048),r=new Uint32Array(64),i=new Uint32Array(64);for(let o=1;o<1024;++o){let a=o<<13,c=0;for(;!(a&8388608);)a<<=1,c-=8388608;a&=-8388609,c+=947912704,n[o]=a|c}for(let o=1024;o<2048;++o)n[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)r[o]=o<<23;r[31]=1199570944,r[32]=2147483648;for(let o=33;o<63;++o)r[o]=2147483648+(o-32<<23);r[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(i[o]=1024);return{baseTable:t,shiftTable:e,mantissaTable:n,exponentTable:r,offsetTable:i}}function he(t,e=[],n=0){let r=Math.fround(t),i=t-r;return e[n]=r,e[n+1]=i,e}function ke(t){return t-Math.fround(t)}function Te(t){let e=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let i=n*4+r;he(t[r*4+n],e,i*2)}return e}var oo=`float random(vec3 scale, float seed) {
|
|
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) {
|
|
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
|
}
|
|
@@ -1233,8 +1233,24 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1233
1233
|
|
|
1234
1234
|
return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
|
|
1235
1235
|
}
|
|
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=`
|
|
1237
|
-
|
|
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 {
|
|
1237
|
+
float brightness;
|
|
1238
|
+
float contrast;
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
// Binding 0:1 is reserved for shader passes
|
|
1242
|
+
@binding(1) @group(0) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
1243
|
+
|
|
1244
|
+
fn brightnessContrast_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {
|
|
1245
|
+
color.rgb += brightnessContrast.brightness;
|
|
1246
|
+
if (brightnessContrast.contrast > 0.0) {
|
|
1247
|
+
color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
|
|
1248
|
+
} else {
|
|
1249
|
+
color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
|
|
1250
|
+
}
|
|
1251
|
+
return color;
|
|
1252
|
+
}
|
|
1253
|
+
`,yo=`uniform brightnessContrastUniforms {
|
|
1238
1254
|
float brightness;
|
|
1239
1255
|
float contrast;
|
|
1240
1256
|
} brightnessContrast;
|
|
@@ -1249,10 +1265,10 @@ vec4 brightnessContrast_filterColor(vec4 color) {
|
|
|
1249
1265
|
return color;
|
|
1250
1266
|
}
|
|
1251
1267
|
|
|
1252
|
-
vec4
|
|
1268
|
+
vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1253
1269
|
return brightnessContrast_filterColor(color);
|
|
1254
1270
|
}
|
|
1255
|
-
`,Mr={props:{},uniforms:{},name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},
|
|
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 {
|
|
1256
1272
|
float strength;
|
|
1257
1273
|
} noise;
|
|
1258
1274
|
|
|
@@ -1274,7 +1290,7 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1274
1290
|
|
|
1275
1291
|
return color / total;
|
|
1276
1292
|
}
|
|
1277
|
-
`,Cr={props:{},uniforms:{},name:"denoise",uniformTypes:{strength:"f32"},
|
|
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 {
|
|
1278
1294
|
float hue;
|
|
1279
1295
|
float saturation;
|
|
1280
1296
|
} hueSaturation;
|
|
@@ -1302,10 +1318,10 @@ vec4 hueSaturation_filterColor(vec4 color) {
|
|
|
1302
1318
|
return color;
|
|
1303
1319
|
}
|
|
1304
1320
|
|
|
1305
|
-
vec4
|
|
1321
|
+
vec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1306
1322
|
return hueSaturation_filterColor(color);
|
|
1307
1323
|
}
|
|
1308
|
-
`,Rr={props:{},uniforms:{},name:"hueSaturation",fs:
|
|
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 {
|
|
1309
1325
|
float amount;
|
|
1310
1326
|
} noise;
|
|
1311
1327
|
|
|
@@ -1313,18 +1329,14 @@ float rand(vec2 co) {
|
|
|
1313
1329
|
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
1314
1330
|
}
|
|
1315
1331
|
|
|
1316
|
-
vec4
|
|
1332
|
+
vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1317
1333
|
float diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
1318
1334
|
color.r += diff;
|
|
1319
1335
|
color.g += diff;
|
|
1320
1336
|
color.b += diff;
|
|
1321
1337
|
return color;
|
|
1322
1338
|
}
|
|
1323
|
-
|
|
1324
|
-
vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1325
|
-
return noise_filterColor(color, texCoord);
|
|
1326
|
-
}
|
|
1327
|
-
`,Or={props:{},uniforms:{},name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Lo,passes:[{filter:!0}]};var Po=`uniform sepiaUniforms {
|
|
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 {
|
|
1328
1340
|
float amount;
|
|
1329
1341
|
} sepia;
|
|
1330
1342
|
|
|
@@ -1341,10 +1353,10 @@ vec4 sepia_filterColor(vec4 color) {
|
|
|
1341
1353
|
return color;
|
|
1342
1354
|
}
|
|
1343
1355
|
|
|
1344
|
-
vec4
|
|
1356
|
+
vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1345
1357
|
return sepia_filterColor(color);
|
|
1346
1358
|
}
|
|
1347
|
-
`,Ur={props:{},uniforms:{},name:"sepia",uniformTypes:{amount:"f32"},
|
|
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 {
|
|
1348
1360
|
float amount;
|
|
1349
1361
|
} vibrance;
|
|
1350
1362
|
|
|
@@ -1356,24 +1368,20 @@ vec4 vibrance_filterColor(vec4 color) {
|
|
|
1356
1368
|
return color;
|
|
1357
1369
|
}
|
|
1358
1370
|
|
|
1359
|
-
vec4
|
|
1371
|
+
vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1360
1372
|
return vibrance_filterColor(color);
|
|
1361
1373
|
}
|
|
1362
|
-
`,zr={props:{},uniforms:{},name:"vibrance",
|
|
1374
|
+
`,zr={props:{},uniforms:{},name:"vibrance",propTypes:{amount:{value:0,min:-1,max:1}},fs:ko,passes:[{filter:!0}]};var To=`uniform vignetteUniforms {
|
|
1363
1375
|
float radius;
|
|
1364
1376
|
float amount;
|
|
1365
1377
|
} vignette;
|
|
1366
1378
|
|
|
1367
|
-
vec4
|
|
1379
|
+
vec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1368
1380
|
float dist = distance(texCoord, vec2(0.5, 0.5));
|
|
1369
1381
|
float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
1370
1382
|
return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
|
|
1371
1383
|
}
|
|
1372
|
-
|
|
1373
|
-
vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1374
|
-
return vignette_filterColor(color, texCoord);
|
|
1375
|
-
}
|
|
1376
|
-
`,Dr={props:{},uniforms:{},name:"vignette",uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}],fs:ko};var To=`uniform tiltShiftUniforms {
|
|
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 {
|
|
1377
1385
|
float blurRadius;
|
|
1378
1386
|
float gradientRadius;
|
|
1379
1387
|
vec2 start;
|
|
@@ -1416,7 +1424,7 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1416
1424
|
|
|
1417
1425
|
return color;
|
|
1418
1426
|
}
|
|
1419
|
-
`,Br={props:{},uniforms:{},name:"tiltShift",dependencies:[Q],uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},
|
|
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 {
|
|
1420
1428
|
float radius;
|
|
1421
1429
|
vec2 delta;
|
|
1422
1430
|
} triangleBlur;
|
|
@@ -1449,7 +1457,7 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1449
1457
|
|
|
1450
1458
|
return color;
|
|
1451
1459
|
}
|
|
1452
|
-
`,Xr={props:{},uniforms:{},name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},
|
|
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=`
|
|
1453
1461
|
uniform zoomBlurUniforms {
|
|
1454
1462
|
vec2 center;
|
|
1455
1463
|
float strength;
|
|
@@ -1482,7 +1490,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1482
1490
|
|
|
1483
1491
|
return color;
|
|
1484
1492
|
}
|
|
1485
|
-
`,Yr={props:{},uniforms:{},name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},
|
|
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 {
|
|
1486
1494
|
vec2 center;
|
|
1487
1495
|
float angle;
|
|
1488
1496
|
float size;
|
|
@@ -1498,7 +1506,7 @@ float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
|
|
|
1498
1506
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
1499
1507
|
}
|
|
1500
1508
|
|
|
1501
|
-
vec4
|
|
1509
|
+
vec4 colorHalftone_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1502
1510
|
float scale = 3.1514 / colorHalftone.size;
|
|
1503
1511
|
vec3 cmy = 1.0 - color.rgb;
|
|
1504
1512
|
float k = min(cmy.x, min(cmy.y, cmy.z));
|
|
@@ -1516,7 +1524,7 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
1516
1524
|
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
1517
1525
|
return vec4(1.0 - cmy - k, color.a);
|
|
1518
1526
|
}
|
|
1519
|
-
`,Qr={props:{},uniforms:{},name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},
|
|
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 {
|
|
1520
1528
|
vec2 center;
|
|
1521
1529
|
float angle;
|
|
1522
1530
|
float size;
|
|
@@ -1534,11 +1542,11 @@ float pattern(vec2 texSize, vec2 texCoord) {
|
|
|
1534
1542
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
1535
1543
|
}
|
|
1536
1544
|
|
|
1537
|
-
vec4
|
|
1545
|
+
vec4 dotScreen_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
1538
1546
|
float average = (color.r + color.g + color.b) / 3.0;
|
|
1539
1547
|
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
1540
1548
|
}
|
|
1541
|
-
`,Gr={props:{},uniforms:{},name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},
|
|
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 {
|
|
1542
1550
|
float radius;
|
|
1543
1551
|
vec2 delta;
|
|
1544
1552
|
} edgeWork;
|
|
@@ -1592,7 +1600,7 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1592
1600
|
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
1593
1601
|
return vec4(c, c, c, 1.0);
|
|
1594
1602
|
}
|
|
1595
|
-
`,qr={props:{},uniforms:{},name:"edgeWork",dependencies:[Q],fs:
|
|
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 {
|
|
1596
1604
|
vec2 center;
|
|
1597
1605
|
float scale;
|
|
1598
1606
|
} hexagonalPixelate;
|
|
@@ -1634,7 +1642,7 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
|
|
|
1634
1642
|
|
|
1635
1643
|
return texture(source, choice + hexagonalPixelate.center);
|
|
1636
1644
|
}
|
|
1637
|
-
`,Hr={props:{},uniforms:{},name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},
|
|
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 {
|
|
1638
1646
|
float strength;
|
|
1639
1647
|
} ink;
|
|
1640
1648
|
|
|
@@ -1661,7 +1669,7 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1661
1669
|
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
1662
1670
|
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
1663
1671
|
}
|
|
1664
|
-
`,Vr={props:{},uniforms:{},name:"ink",fs:
|
|
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 {
|
|
1665
1673
|
vec2 screenXY;
|
|
1666
1674
|
float radiusPixels;
|
|
1667
1675
|
float zoom;
|
|
@@ -1681,7 +1689,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1681
1689
|
}
|
|
1682
1690
|
return texture(source, texCoord);
|
|
1683
1691
|
}
|
|
1684
|
-
`,Wr={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},
|
|
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) {
|
|
1685
1693
|
vec4 color = texture(source, coord / texSize);
|
|
1686
1694
|
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
1687
1695
|
if (coord != clampedCoord) {
|
|
@@ -1691,7 +1699,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1691
1699
|
|
|
1692
1700
|
return color;
|
|
1693
1701
|
}
|
|
1694
|
-
`,_e={name:"warp",passes:[],fs:
|
|
1702
|
+
`,_e={name:"warp",passes:[],fs:zo};var Do=`uniform bulgePinchUniforms {
|
|
1695
1703
|
float radius;
|
|
1696
1704
|
float strength;
|
|
1697
1705
|
vec2 center;
|
|
@@ -1718,7 +1726,7 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1718
1726
|
|
|
1719
1727
|
return warp_sampleColor(source, texSize, coord);
|
|
1720
1728
|
}
|
|
1721
|
-
`,jr={props:{},uniforms:{},name:"bulgePinch",dependencies:[_e],fs:
|
|
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 {
|
|
1722
1730
|
float radius;
|
|
1723
1731
|
float angle;
|
|
1724
1732
|
vec2 center;
|
|
@@ -1747,7 +1755,7 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1747
1755
|
|
|
1748
1756
|
return warp_sampleColor(source, texSize, coord);
|
|
1749
1757
|
}
|
|
1750
|
-
`,$r={props:{},uniforms:{},name:"swirl",dependencies:[_e],fs:
|
|
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=`
|
|
1751
1759
|
#define FXAA_QUALITY_PRESET 29
|
|
1752
1760
|
|
|
1753
1761
|
#if (FXAA_QUALITY_PRESET == 10)
|
|
@@ -2327,7 +2335,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
2327
2335
|
fxaa_QualityEdgeThresholdMin
|
|
2328
2336
|
);
|
|
2329
2337
|
}
|
|
2330
|
-
`,Kr={name:"fxaa",
|
|
2338
|
+
`,Kr={name:"fxaa",propTypes:{},fs:Xo,passes:[{sampler:!0}],getUniforms:t=>t};var Zr=`uniform float ONE;
|
|
2331
2339
|
|
|
2332
2340
|
/*
|
|
2333
2341
|
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
@@ -3161,7 +3169,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
3161
3169
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
3162
3170
|
}
|
|
3163
3171
|
}
|
|
3164
|
-
`;var
|
|
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;
|
|
3165
3173
|
varying vec3 geometry_vNormal;
|
|
3166
3174
|
|
|
3167
3175
|
void geometry_setNormal(vec3 normal) {
|
|
@@ -3175,7 +3183,7 @@ void geometry_setPosition(vec4 position) {
|
|
|
3175
3183
|
void geometry_setPosition(vec3 position) {
|
|
3176
3184
|
geometry_vPosition = vec4(position, 1.);
|
|
3177
3185
|
}
|
|
3178
|
-
`,
|
|
3186
|
+
`,qo=`varying vec4 geometry_vPosition;
|
|
3179
3187
|
varying vec3 geometry_vNormal;
|
|
3180
3188
|
|
|
3181
3189
|
vec4 geometry_getPosition() {
|
|
@@ -3185,7 +3193,7 @@ vec4 geometry_getPosition() {
|
|
|
3185
3193
|
vec3 geometry_getNormal() {
|
|
3186
3194
|
return geometry_vNormal;
|
|
3187
3195
|
}
|
|
3188
|
-
`,ti={name:"geometry",vs:
|
|
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;
|
|
3189
3197
|
varying vec3 project_vNormalWorld;
|
|
3190
3198
|
|
|
3191
3199
|
vec4 project_getPosition_World() {
|
|
@@ -3195,7 +3203,7 @@ vec4 project_getPosition_World() {
|
|
|
3195
3203
|
vec3 project_getNormal_World() {
|
|
3196
3204
|
return project_vNormalWorld;
|
|
3197
3205
|
}
|
|
3198
|
-
`,
|
|
3206
|
+
`,Wo=`${ni}
|
|
3199
3207
|
|
|
3200
3208
|
// Unprefixed uniforms
|
|
3201
3209
|
uniform mat4 modelMatrix;
|
|
@@ -3248,8 +3256,8 @@ vec4 project_view_to_clipspace(vec3 position) {
|
|
|
3248
3256
|
vec4 project_to_clipspace(vec3 position) {
|
|
3249
3257
|
return viewProjectionMatrix * vec4(position, 1.);
|
|
3250
3258
|
}
|
|
3251
|
-
`,
|
|
3252
|
-
${ni}`,at={name:"project",getUniforms:
|
|
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))
|
|
3253
3261
|
|
|
3254
3262
|
struct AmbientLight {
|
|
3255
3263
|
vec3 color;
|
|
@@ -3283,7 +3291,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
3283
3291
|
}
|
|
3284
3292
|
|
|
3285
3293
|
#endif
|
|
3286
|
-
`;var
|
|
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;
|
|
3287
3295
|
|
|
3288
3296
|
/*
|
|
3289
3297
|
* Returns color attenuated by angle from light source
|
|
@@ -3293,7 +3301,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
3293
3301
|
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
3294
3302
|
return vec4(color.rgb * d, color.a);
|
|
3295
3303
|
}
|
|
3296
|
-
`,ii={name:"dirlight",fs:
|
|
3304
|
+
`,ii={name:"dirlight",fs:es,getUniforms:Jo,dependencies:[at]};var pn=`
|
|
3297
3305
|
uniform float lighting_uAmbient;
|
|
3298
3306
|
uniform float lighting_uDiffuse;
|
|
3299
3307
|
uniform float lighting_uShininess;
|
|
@@ -3366,7 +3374,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
3366
3374
|
}
|
|
3367
3375
|
return lightColor;
|
|
3368
3376
|
}
|
|
3369
|
-
`;var
|
|
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;
|
|
3370
3378
|
uniform mat4 u_ModelMatrix;
|
|
3371
3379
|
uniform mat4 u_NormalMatrix;
|
|
3372
3380
|
|