@luma.gl/shadertools 9.0.15 → 9.0.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 +784 -173
- package/dist/dist.min.js +75 -75
- package/dist/index.cjs +15 -2832
- package/dist/index.cjs.map +4 -4
- package/dist/lib/wgsl/get-shader-layout-wgsl.js +5 -5
- package/package.json +4 -3
- package/src/lib/wgsl/get-shader-layout-wgsl.ts +5 -5
- package/dist/libs/wgsl-reflect/wgsl_reflect.module.d.ts +0 -1112
- package/dist/libs/wgsl-reflect/wgsl_reflect.module.d.ts.map +0 -1
- package/dist/libs/wgsl-reflect/wgsl_reflect.module.js +0 -3389
- package/src/libs/wgsl-reflect/wgsl_reflect.module.js +0 -3394
- package/src/libs/wgsl-reflect/wgsl_reflect.module.js.map +0 -1
package/dist/dist.min.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var
|
|
7
|
+
"use strict";var __exports__=(()=>{var to=Object.create;var he=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var no=Object.getOwnPropertyNames;var oo=Object.getPrototypeOf,io=Object.prototype.hasOwnProperty;var so=(r,e,t)=>e in r?he(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ao=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),co=(r,e)=>{for(var t in e)he(r,t,{get:e[t],enumerable:!0})},we=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of no(e))!io.call(r,o)&&o!==t&&he(r,o,{get:()=>e[o],enumerable:!(n=ro(e,o))||n.enumerable});return r},Le=(r,e,t)=>(we(r,e,"default"),t&&we(t,e,"default")),fr=(r,e,t)=>(t=r!=null?to(oo(r)):{},we(e||!r||!r.__esModule?he(t,"default",{value:r,enumerable:!0}):t,r)),lo=r=>we(he({},"__esModule",{value:!0}),r);var ur=(r,e,t)=>(so(r,typeof e!="symbol"?e+"":e,t),t);var et=ao((Xi,_r)=>{_r.exports=globalThis.luma});var Pe={};co(Pe,{ShaderAssembler:()=>me,ShaderModuleInstance:()=>C,_ShaderModuleInstance:()=>C,_getDependencyGraph:()=>ke,_resolveModules:()=>re,_warp:()=>fe,assembleShaderPairGLSL:()=>Ne,brightnessContrast:()=>Zr,bulgePinch:()=>dn,capitalize:()=>Z,colorHalftone:()=>ln,combineInjects:()=>br,convertToVec4:()=>lt,denoise:()=>Jr,dirlight:()=>Wt,dirlight1:()=>Wn,dotScreen:()=>fn,edgeWork:()=>un,fp32:()=>Qr,fp64:()=>An,fp64arithmetic:()=>Jt,fxaa:()=>gn,generateShaderForModule:()=>Dr,geometry1:()=>yn,getPassthroughFS:()=>Cr,getQualifierDetails:()=>Ir,getShaderInfo:()=>Se,getShaderLayoutFromWGSL:()=>Br,glsl:()=>hr,gouraudLighting:()=>$n,gouraudMaterial:()=>jt,hexagonalPixelate:()=>_n,hueSaturation:()=>en,ink:()=>hn,lighting:()=>Q,lights1:()=>te,magnify:()=>pn,noise:()=>tn,normalizeShaderModule:()=>Fr,pbr:()=>eo,pbrMaterial:()=>Kr,phongLighting:()=>Kn,phongMaterial:()=>$t,picking:()=>qr,project1:()=>Je,random:()=>q,sepia:()=>rn,swirl:()=>mn,tiltShift:()=>sn,triangleBlur:()=>an,typeToChannelCount:()=>Or,typeToChannelSuffix:()=>Rr,vibrance:()=>nn,vignette:()=>on,zoomBlur:()=>cn});Le(Pe,fr(et(),1));var hr=r=>`${r}`;function D(r,e){if(!r)throw new Error(e||"shadertools: assertion failed.")}var tt={number:{type:"number",validate(r,e){return Number.isFinite(r)&&typeof e=="object"&&(e.max===void 0||r<=e.max)&&(e.min===void 0||r>=e.min)}},array:{type:"array",validate(r,e){return Array.isArray(r)||ArrayBuffer.isView(r)}}};function dr(r){let e={};for(let[t,n]of Object.entries(r))e[t]=fo(n);return e}function mr(r,e,t){let n={};for(let[o,i]of Object.entries(e))r&&o in r&&!i.private?(i.validate&&D(i.validate(r[o],i),`${t}: invalid ${o}`),n[o]=r[o]):n[o]=i.value;return n}function fo(r){let e=pr(r);if(e!=="object")return{value:r,...tt[e],type:e};if(typeof r=="object")return r?r.type!==void 0?{...r,...tt[r.type],type:r.type}:r.value===void 0?{type:"object",value:r}:(e=pr(r.value),{...r,...tt[e],type:e}):{type:"object",value:null};throw new Error("props")}function pr(r){return Array.isArray(r)||ArrayBuffer.isView(r)?"array":typeof r}var gr=`#ifdef MODULE_LOGDEPTH
|
|
8
8
|
logdepth_adjustPosition(gl_Position);
|
|
9
9
|
#endif
|
|
10
|
-
`,
|
|
10
|
+
`,xr=`#ifdef MODULE_MATERIAL
|
|
11
11
|
gl_FragColor = material_filterColor(gl_FragColor);
|
|
12
12
|
#endif
|
|
13
13
|
#ifdef MODULE_LIGHTING
|
|
@@ -23,15 +23,15 @@ gl_FragColor = picking_filterPickingColor(gl_FragColor);
|
|
|
23
23
|
#ifdef MODULE_LOGDEPTH
|
|
24
24
|
logdepth_setFragDepth();
|
|
25
25
|
#endif
|
|
26
|
-
`;var
|
|
26
|
+
`;var uo={vertex:gr,fragment:xr},vr=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ar=/}\n?[^{}]*$/,rt=[],pe="__LUMA_INJECT_DECLARATIONS__";function yr(r){let e={vertex:{},fragment:{}};for(let t in r){let n=r[t],o=_o(t);typeof n=="string"&&(n={order:0,injection:n}),e[o][t]=n}return e}function _o(r){let e=r.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function de(r,e,t,n=!1){let o=e==="vertex";for(let i in t){let a=t[i];a.sort((u,h)=>u.order-h.order),rt.length=a.length;for(let u=0,h=a.length;u<h;++u)rt[u]=a[u].injection;let c=`${rt.join(`
|
|
27
27
|
`)}
|
|
28
|
-
`;switch(i){case"vs:#decl":o&&(
|
|
29
|
-
${
|
|
28
|
+
`;switch(i){case"vs:#decl":o&&(r=r.replace(pe,c));break;case"vs:#main-start":o&&(r=r.replace(vr,u=>u+c));break;case"vs:#main-end":o&&(r=r.replace(Ar,u=>c+u));break;case"fs:#decl":o||(r=r.replace(pe,c));break;case"fs:#main-start":o||(r=r.replace(vr,u=>u+c));break;case"fs:#main-end":o||(r=r.replace(Ar,u=>c+u));break;default:r=r.replace(i,u=>u+c)}}return r=r.replace(pe,""),n&&(r=r.replace(/\}\s*$/,i=>i+uo[e])),r}function br(r){let e={};return D(Array.isArray(r)&&r.length>1),r.forEach(t=>{for(let n in t)e[n]=e[n]?`${e[n]}
|
|
29
|
+
${t[n]}`:t[n]}),e}var ho=1,C=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(t=>{if(t instanceof C)return t;D(typeof t!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(t)}' and use it directly.`),t.name||(console.warn("shader module has no name"),t.name=`shader-module-${ho++}`);let n=new C(t);return n.dependencies=C.instantiateModules(t.dependencies||[]),n})}constructor(e){let{name:t,vs:n,fs:o,dependencies:i=[],uniformTypes:a={},uniformPropTypes:c={},getUniforms:u,deprecations:h=[],defines:p={},inject:d={}}=e;D(typeof t=="string"),this.name=t,this.vs=n,this.fs=o,this.getModuleUniforms=u,this.dependencies=C.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(h),this.defines=p,this.injections=yr(d),this.uniformTypes=a,c&&(this.uniforms=dr(c))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:D(!1)}let n=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
|
|
30
30
|
|
|
31
31
|
#define MODULE_${n}
|
|
32
|
-
${
|
|
32
|
+
${t}
|
|
33
33
|
|
|
34
|
-
`}getUniforms(e,
|
|
34
|
+
`}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):mr(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(n=>{n.regex?.test(e)&&(n.deprecated?t.deprecated(n.old,n.new)():t.removed(n.old,n.new)())})}_parseDeprecationDefinitions(e){return e.forEach(t=>{switch(t.type){case"function":t.regex=new RegExp(`\\b${t.old}\\(`);break;default:t.regex=new RegExp(`${t.type} ${t.old};`)}}),e}_defaultGetUniforms(e={}){let t={},n=this.uniforms;for(let o in n){let i=n[o];o in e&&!i.private?(i.validate&&D(i.validate(e[o],i),`${this.name}: invalid ${o}`),t[o]=e[o]):t[o]=i.value}return t}};function nt(r){if(r.source&&r.platformInfo.type==="webgpu")return{...r,vs:void 0,fs:void 0};if(!r.vs)throw new Error("no vertex shader");let e=Pr(r.platformInfo,r.vs),t;return r.fs&&(t=Pr(r.platformInfo,r.fs)),{...r,vs:e,fs:t}}function Pr(r,e){if(typeof e=="string")return e;switch(r.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function re(r){let e=C.instantiateModules(r);return po(e)}function po(r){let e={},t={};return ke({modules:r,level:0,moduleMap:e,moduleDepth:t}),Object.keys(t).sort((n,o)=>t[o]-t[n]).map(n=>e[n])}function ke(r){let{modules:e,level:t,moduleMap:n,moduleDepth:o}=r;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)n[i.name]=i,(o[i.name]===void 0||o[i.name]<t)&&(o[i.name]=t);for(let i of e)i.dependencies&&ke({modules:i.dependencies,level:t+1,moduleMap:n,moduleDepth:o})}function wr(r){switch(r?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
35
35
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
36
36
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
37
37
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
@@ -46,51 +46,51 @@ ${r}
|
|
|
46
46
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
47
47
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
48
48
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
49
|
-
`}}function
|
|
50
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
51
|
-
`,o.header&&(
|
|
52
|
-
`}o.footer&&(
|
|
53
|
-
`}return
|
|
49
|
+
`}}function kr(r,e){if(Number(r.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return r=Lr(r,mo),r;case"fragment":return r=Lr(r,go),r;default:throw new Error(e)}}var Sr=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
50
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],mo=[...Sr,[ot("attribute"),"in $1"],[ot("varying"),"out $1"]],go=[...Sr,[ot("varying"),"in $1"]];function Lr(r,e){for(let[t,n]of e)r=r.replace(t,n);return r}function ot(r){return new RegExp(`\\b${r}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function it(r,e){let t="";for(let n in r){let o=r[n];if(t+=`void ${o.signature} {
|
|
51
|
+
`,o.header&&(t+=` ${o.header}`),e[n]){let i=e[n];i.sort((a,c)=>a.order-c.order);for(let a of i)t+=` ${a.injection}
|
|
52
|
+
`}o.footer&&(t+=` ${o.footer}`),t+=`}
|
|
53
|
+
`}return t}function st(r){let e={vertex:{},fragment:{}};for(let t of r){let n,o;typeof t!="string"?(n=t,o=n.hook):(n={},o=t),o=o.trim();let[i,a]=o.split(":"),c=o.replace(/\(.+/,""),u=Object.assign(n,{signature:a});switch(i){case"vs":e.vertex[c]=u;break;case"fs":e.fragment[c]=u;break;default:throw new Error(i)}}return e}function Se(r,e){return{name:xo(r,e),language:"glsl",version:vo(r)}}function xo(r,e="unnamed"){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(r);return n?n[1]:e}function vo(r){let e=100,t=r.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Tr=`
|
|
54
54
|
|
|
55
|
-
${
|
|
56
|
-
`,
|
|
57
|
-
`;function
|
|
55
|
+
${pe}
|
|
56
|
+
`,Ao=`precision highp float;
|
|
57
|
+
`;function Er(r){let e=re(r.modules||[]);return{source:at(r.platformInfo,{...r,source:r.source,stage:"vertex",modules:e}),getUniforms:ct(e)}}function Mr(r){let e=re(r.modules||[]);return{vs:at(r.platformInfo,{...r,source:r.vs,stage:"vertex",modules:e}),fs:at(r.platformInfo,{...r,source:r.fs,stage:"fragment",modules:e}),getUniforms:ct(e)}}function Ne(r){let{vs:e,fs:t}=r,n=re(r.modules||[]);return{vs:Nr(r.platformInfo,{...r,source:e,stage:"vertex",modules:n}),fs:Nr(r.platformInfo,{...r,source:t,stage:"fragment",modules:n}),getUniforms:ct(n)}}function at(r,e){let{source:t,stage:n,modules:o,hookFunctions:i=[],inject:a={},log:c}=e;D(typeof t=="string","shader source must be a string");let u=t,h="",p=st(i),d={},m={},x={};for(let g in a){let A=typeof a[g]=="string"?{injection:a[g],order:0}:a[g],L=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(L){let v=L[2],b=L[3];v?b==="decl"?m[g]=[A]:x[g]=[A]:d[g]=[A]}else x[g]=[A]}let w=r.type!=="webgpu"?o:[];for(let g of w){c&&g.checkDeprecations(u,c);let A=g.getModuleSource(n,"wgsl");h+=A;let L=g.injections[n];for(let v in L){let b=/^(v|f)s:#([\w-]+)$/.exec(v);if(b){let y=b[2]==="decl"?m:x;y[v]=y[v]||[],y[v].push(L[v])}else d[v]=d[v]||[],d[v].push(L[v])}}return h+=Tr,h=de(h,n,m),h+=it(p[n],d),h+=u,h=de(h,n,x),h}function Nr(r,e){let{id:t,source:n,stage:o,language:i="glsl",modules:a,defines:c={},hookFunctions:u=[],inject:h={},prologue:p=!0,log:d}=e;D(typeof n=="string","shader source must be a string");let m=i==="glsl"?Se(n).version:-1,x=r.shaderLanguageVersion,w=m===100?"#version 100":"#version 300 es",A=n.split(`
|
|
58
58
|
`).slice(1).join(`
|
|
59
|
-
`),L={};a.forEach(
|
|
59
|
+
`),L={};a.forEach(S=>{Object.assign(L,S.getDefines())}),Object.assign(L,c);let v="";switch(i){case"wgsl":break;case"glsl":v=p?`${w}
|
|
60
60
|
|
|
61
61
|
// ----- PROLOGUE -------------------------
|
|
62
|
-
${
|
|
62
|
+
${yo({id:t,source:n,stage:o})}
|
|
63
63
|
${`#define SHADER_TYPE_${o.toUpperCase()}`}
|
|
64
|
-
${
|
|
65
|
-
${o==="fragment"?
|
|
64
|
+
${wr(r)}
|
|
65
|
+
${o==="fragment"?Ao:""}
|
|
66
66
|
|
|
67
67
|
// ----- APPLICATION DEFINES -------------------------
|
|
68
68
|
|
|
69
|
-
${
|
|
69
|
+
${bo(L)}
|
|
70
70
|
|
|
71
71
|
`:`${w}
|
|
72
|
-
`;break}let
|
|
72
|
+
`;break}let b=st(u),P={},y={},k={};for(let S in h){let F=typeof h[S]=="string"?{injection:h[S],order:0}:h[S],M=/^(v|f)s:(#)?([\w-]+)$/.exec(S);if(M){let T=M[2],I=M[3];T?I==="decl"?y[S]=[F]:k[S]=[F]:P[S]=[F]}else k[S]=[F]}for(let S of a){d&&S.checkDeprecations(A,d);let F=S.getModuleSource(o);v+=F;let M=S.injections[o];for(let T in M){let I=/^(v|f)s:#([\w-]+)$/.exec(T);if(I){let R=I[2]==="decl"?y:k;R[T]=R[T]||[],R[T].push(M[T])}else P[T]=P[T]||[],P[T].push(M[T])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=Tr,v=de(v,o,y),v+=it(b[o],P),v+=A,v=de(v,o,k),i==="glsl"&&m!==x&&(v=kr(v,o)),v.trim()}function ct(r){return function(t){let n={};for(let o of r){let i=o.getUniforms(t,n);Object.assign(n,i)}return n}}function yo(r){let{id:e,source:t,stage:n}=r;return e&&t.indexOf("SHADER_NAME")===-1?`
|
|
73
73
|
#define SHADER_NAME ${e}_${n}
|
|
74
74
|
|
|
75
|
-
`:""}function
|
|
76
|
-
`)}return e}var ne=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return ne.defaultShaderAssembler=ne.defaultShaderAssembler||new ne,ne.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(
|
|
75
|
+
`:""}function bo(r={}){let e="";for(let t in r){let n=r[t];(n||Number.isFinite(n))&&(e+=`#define ${t.toUpperCase()} ${r[t]}
|
|
76
|
+
`)}return e}var ne=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return ne.defaultShaderAssembler=ne.defaultShaderAssembler||new ne,ne.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let t=this._getModuleList(e.modules),n=this._hookFunctions,o=nt(e);return{...Er({platformInfo:e.platformInfo,...o,modules:t,hookFunctions:n}),modules:t}}assembleShaderPair(e){let t=nt(e),n=this._getModuleList(e.modules),o=this._hookFunctions,{platformInfo:i}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?Mr({platformInfo:i,...t,modules:n,hookFunctions:o}):Ne({platformInfo:i,...t,modules:n,hookFunctions:o}),modules:n}}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),n={},o=0;for(let i=0,a=this._defaultModules.length;i<a;++i){let c=this._defaultModules[i],u=c.name;t[o++]=c,n[u]=!0}for(let i=0,a=e.length;i<a;++i){let c=e[i],u=c.name;n[u]||(t[o++]=c,n[u]=!0)}return t.length=o,C.instantiateModules(t)}},me=ne;ur(me,"defaultShaderAssembler");function Fr(r){if(!r.normalized&&(r.normalized=!0,r.uniformPropTypes&&!r.getUniforms)){let e=new C(r);r.getUniforms=e.getUniforms.bind(e)}return r}var Po=`out vec4 transform_output;
|
|
77
77
|
void main() {
|
|
78
78
|
transform_output = vec4(0);
|
|
79
|
-
}`,
|
|
80
|
-
${
|
|
79
|
+
}`,wo=`#version 300 es
|
|
80
|
+
${Po}`;function Ir(r,e){e=Array.isArray(e)?e:[e];let t=r.replace(/^\s+/,"").split(/\s+/),[n,o,i]=t;if(!e.includes(n)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:n,type:o,name:a}}function Cr(r){let{input:e,inputChannels:t,output:n}=r||{};if(!e)return wo;if(!t)throw new Error("inputChannels");let o=Lo(t),i=lt(e,t);return`#version 300 es
|
|
81
81
|
in ${o} ${e};
|
|
82
82
|
out vec4 ${n};
|
|
83
83
|
void main() {
|
|
84
84
|
${n} = ${i};
|
|
85
|
-
}`}function
|
|
86
|
-
`)}function
|
|
87
|
-
`)}function Ir(t,e){switch(e.shaderLanguage){case"glsl":return Mr(t,e);case"wgsl":return Fr(t,e)}}var Rr=or($e(),1);var st=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},q=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(e){throw new Error("Cannot evaluate node")}evaluateString(e){return this.evaluate(e).toString()}},T=class extends q{constructor(){super()}},we=class extends T{constructor(e,r,n,o){super(),this.name=e,this.args=r,this.returnType=n,this.body=o}get astNodeType(){return"function"}},at=class extends T{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}},ct=class extends T{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"while"}},lt=class extends T{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}},ft=class extends T{constructor(e,r,n,o){super(),this.init=e,this.condition=r,this.increment=n,this.body=o}get astNodeType(){return"for"}},j=class extends T{constructor(e,r,n,o,i){super(),this.name=e,this.type=r,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"var"}},Le=class extends T{constructor(e,r,n){super(),this.name=e,this.type=r,this.value=n}get astNodeType(){return"override"}},Se=class extends T{constructor(e,r,n,o,i){super(),this.name=e,this.type=r,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"let"}},ke=class extends T{constructor(e,r,n,o,i){super(),this.name=e,this.type=r,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}},ae;(function(t){t.increment="++",t.decrement="--"})(ae||(ae={}));(function(t){function e(r){let n=r;if(n=="parse")throw new Error("Invalid value for IncrementOperator");return t[n]}t.parse=e})(ae||(ae={}));var ut=class extends T{constructor(e,r){super(),this.operator=e,this.variable=r}get astNodeType(){return"increment"}},me;(function(t){t.assign="=",t.addAssign="+=",t.subtractAssin="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="})(me||(me={}));(function(t){function e(r){let n=r;if(n=="parse")throw new Error("Invalid value for AssignOperator");return t[n]}t.parse=e})(me||(me={}));var _t=class extends T{constructor(e,r,n){super(),this.operator=e,this.variable=r,this.value=n}get astNodeType(){return"assign"}},ht=class extends T{constructor(e,r){super(),this.name=e,this.args=r}get astNodeType(){return"call"}},pt=class extends T{constructor(e,r){super(),this.body=e,this.continuing=r}get astNodeType(){return"loop"}},dt=class extends T{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"body"}},mt=class extends T{constructor(e,r,n,o){super(),this.condition=e,this.body=r,this.elseif=n,this.else=o}get astNodeType(){return"if"}},gt=class extends T{constructor(e){super(),this.value=e}get astNodeType(){return"return"}},xt=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Ne=class extends T{constructor(e,r){super(),this.name=e,this.type=r}get astNodeType(){return"alias"}},vt=class extends T{constructor(){super()}get astNodeType(){return"discard"}},At=class extends T{constructor(){super()}get astNodeType(){return"break"}},bt=class extends T{constructor(){super()}get astNodeType(){return"continue"}},G=class extends T{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},V=class extends G{constructor(e,r){super(e),this.members=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let r=0;r<this.members.length;r++)if(this.members[r].name==e)return r;return-1}},Ee=class extends G{constructor(e,r,n){super(e),this.format=r,this.access=n}get astNodeType(){return"template"}},yt=class extends G{constructor(e,r,n,o){super(e),this.storage=r,this.type=n,this.access=o}get astNodeType(){return"pointer"}},Te=class extends G{constructor(e,r,n,o){super(e),this.attributes=r,this.format=n,this.count=o}get astNodeType(){return"array"}get isArray(){return!0}},Z=class extends G{constructor(e,r,n){super(e),this.format=r,this.access=n}get astNodeType(){return"sampler"}},X=class extends q{constructor(){super()}},Me=class extends X{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},J=class extends X{constructor(e,r){super(),this.type=e,this.args=r}get astNodeType(){return"createExpr"}},Pt=class extends X{constructor(e,r){super(),this.name=e,this.args=r}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)}}},wt=class extends X{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}},Fe=class extends X{constructor(e,r){super(),this.name=e,this.initializer=r}get astNodeType(){return"constExpr"}evaluate(e){var r,n;if(this.initializer instanceof J){let o=(r=this.postfix)===null||r===void 0?void 0:r.evaluateString(e),i=(n=this.initializer.type)===null||n===void 0?void 0:n.name,a=e.structs.get(i),f=a?.getMemberIndex(o);if(f!=-1)return this.initializer.args[f].evaluate(e);console.log(f)}return this.initializer.evaluate(e)}},Ie=class extends X{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Lt=class extends X{constructor(e,r){super(),this.type=e,this.value=r}get astNodeType(){return"bitcastExpr"}},St=class extends X{constructor(e,r){super(),this.type=e,this.args=r}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}},Ce=class extends X{constructor(e){super(),this.contents=e}get astNodeType(){return"groupExpr"}evaluate(e){return this.contents[0].evaluate(e)}},Re=class extends X{constructor(){super()}},kt=class extends Re{constructor(e,r){super(),this.operator=e,this.right=r}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)}}},D=class extends Re{constructor(e,r,n){super(),this.operator=e,this.left=r,this.right=n}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}`)}}},Oe=class extends q{constructor(){super()}},Nt=class extends Oe{constructor(e,r){super(),this.selector=e,this.body=r}get astNodeType(){return"case"}},Et=class extends Oe{constructor(e){super(),this.body=e}get astNodeType(){return"default"}},Tt=class extends q{constructor(e,r,n){super(),this.name=e,this.type=r,this.attributes=n}get astNodeType(){return"argument"}},Mt=class extends q{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"elseif"}},Ft=class extends q{constructor(e,r,n){super(),this.name=e,this.type=r,this.attributes=n}get astNodeType(){return"member"}},Ue=class extends q{constructor(e,r){super(),this.name=e,this.value=r}get astNodeType(){return"attribute"}},_,l;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(l||(l={}));var c=class{constructor(e,r,n){this.name=e,this.type=r,this.rule=n}toString(){return this.name}},s=class{};_=s;s.none=new c("",l.reserved,"");s.eof=new c("EOF",l.token,"");s.reserved={asm:new c("asm",l.reserved,"asm"),bf16:new c("bf16",l.reserved,"bf16"),do:new c("do",l.reserved,"do"),enum:new c("enum",l.reserved,"enum"),f16:new c("f16",l.reserved,"f16"),f64:new c("f64",l.reserved,"f64"),handle:new c("handle",l.reserved,"handle"),i8:new c("i8",l.reserved,"i8"),i16:new c("i16",l.reserved,"i16"),i64:new c("i64",l.reserved,"i64"),mat:new c("mat",l.reserved,"mat"),premerge:new c("premerge",l.reserved,"premerge"),regardless:new c("regardless",l.reserved,"regardless"),typedef:new c("typedef",l.reserved,"typedef"),u8:new c("u8",l.reserved,"u8"),u16:new c("u16",l.reserved,"u16"),u64:new c("u64",l.reserved,"u64"),unless:new c("unless",l.reserved,"unless"),using:new c("using",l.reserved,"using"),vec:new c("vec",l.reserved,"vec"),void:new c("void",l.reserved,"void")};s.keywords={array:new c("array",l.keyword,"array"),atomic:new c("atomic",l.keyword,"atomic"),bool:new c("bool",l.keyword,"bool"),f32:new c("f32",l.keyword,"f32"),i32:new c("i32",l.keyword,"i32"),mat2x2:new c("mat2x2",l.keyword,"mat2x2"),mat2x3:new c("mat2x3",l.keyword,"mat2x3"),mat2x4:new c("mat2x4",l.keyword,"mat2x4"),mat3x2:new c("mat3x2",l.keyword,"mat3x2"),mat3x3:new c("mat3x3",l.keyword,"mat3x3"),mat3x4:new c("mat3x4",l.keyword,"mat3x4"),mat4x2:new c("mat4x2",l.keyword,"mat4x2"),mat4x3:new c("mat4x3",l.keyword,"mat4x3"),mat4x4:new c("mat4x4",l.keyword,"mat4x4"),ptr:new c("ptr",l.keyword,"ptr"),sampler:new c("sampler",l.keyword,"sampler"),sampler_comparison:new c("sampler_comparison",l.keyword,"sampler_comparison"),struct:new c("struct",l.keyword,"struct"),texture_1d:new c("texture_1d",l.keyword,"texture_1d"),texture_2d:new c("texture_2d",l.keyword,"texture_2d"),texture_2d_array:new c("texture_2d_array",l.keyword,"texture_2d_array"),texture_3d:new c("texture_3d",l.keyword,"texture_3d"),texture_cube:new c("texture_cube",l.keyword,"texture_cube"),texture_cube_array:new c("texture_cube_array",l.keyword,"texture_cube_array"),texture_multisampled_2d:new c("texture_multisampled_2d",l.keyword,"texture_multisampled_2d"),texture_storage_1d:new c("texture_storage_1d",l.keyword,"texture_storage_1d"),texture_storage_2d:new c("texture_storage_2d",l.keyword,"texture_storage_2d"),texture_storage_2d_array:new c("texture_storage_2d_array",l.keyword,"texture_storage_2d_array"),texture_storage_3d:new c("texture_storage_3d",l.keyword,"texture_storage_3d"),texture_depth_2d:new c("texture_depth_2d",l.keyword,"texture_depth_2d"),texture_depth_2d_array:new c("texture_depth_2d_array",l.keyword,"texture_depth_2d_array"),texture_depth_cube:new c("texture_depth_cube",l.keyword,"texture_depth_cube"),texture_depth_cube_array:new c("texture_depth_cube_array",l.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new c("texture_depth_multisampled_2d",l.keyword,"texture_depth_multisampled_2d"),texture_external:new c("texture_external",l.keyword,"texture_external"),u32:new c("u32",l.keyword,"u32"),vec2:new c("vec2",l.keyword,"vec2"),vec3:new c("vec3",l.keyword,"vec3"),vec4:new c("vec4",l.keyword,"vec4"),bitcast:new c("bitcast",l.keyword,"bitcast"),block:new c("block",l.keyword,"block"),break:new c("break",l.keyword,"break"),case:new c("case",l.keyword,"case"),continue:new c("continue",l.keyword,"continue"),continuing:new c("continuing",l.keyword,"continuing"),default:new c("default",l.keyword,"default"),discard:new c("discard",l.keyword,"discard"),else:new c("else",l.keyword,"else"),enable:new c("enable",l.keyword,"enable"),fallthrough:new c("fallthrough",l.keyword,"fallthrough"),false:new c("false",l.keyword,"false"),fn:new c("fn",l.keyword,"fn"),for:new c("for",l.keyword,"for"),function:new c("function",l.keyword,"function"),if:new c("if",l.keyword,"if"),let:new c("let",l.keyword,"let"),const:new c("const",l.keyword,"const"),loop:new c("loop",l.keyword,"loop"),while:new c("while",l.keyword,"while"),private:new c("private",l.keyword,"private"),read:new c("read",l.keyword,"read"),read_write:new c("read_write",l.keyword,"read_write"),return:new c("return",l.keyword,"return"),storage:new c("storage",l.keyword,"storage"),switch:new c("switch",l.keyword,"switch"),true:new c("true",l.keyword,"true"),alias:new c("alias",l.keyword,"alias"),type:new c("type",l.keyword,"type"),uniform:new c("uniform",l.keyword,"uniform"),var:new c("var",l.keyword,"var"),override:new c("override",l.keyword,"override"),workgroup:new c("workgroup",l.keyword,"workgroup"),write:new c("write",l.keyword,"write"),r8unorm:new c("r8unorm",l.keyword,"r8unorm"),r8snorm:new c("r8snorm",l.keyword,"r8snorm"),r8uint:new c("r8uint",l.keyword,"r8uint"),r8sint:new c("r8sint",l.keyword,"r8sint"),r16uint:new c("r16uint",l.keyword,"r16uint"),r16sint:new c("r16sint",l.keyword,"r16sint"),r16float:new c("r16float",l.keyword,"r16float"),rg8unorm:new c("rg8unorm",l.keyword,"rg8unorm"),rg8snorm:new c("rg8snorm",l.keyword,"rg8snorm"),rg8uint:new c("rg8uint",l.keyword,"rg8uint"),rg8sint:new c("rg8sint",l.keyword,"rg8sint"),r32uint:new c("r32uint",l.keyword,"r32uint"),r32sint:new c("r32sint",l.keyword,"r32sint"),r32float:new c("r32float",l.keyword,"r32float"),rg16uint:new c("rg16uint",l.keyword,"rg16uint"),rg16sint:new c("rg16sint",l.keyword,"rg16sint"),rg16float:new c("rg16float",l.keyword,"rg16float"),rgba8unorm:new c("rgba8unorm",l.keyword,"rgba8unorm"),rgba8unorm_srgb:new c("rgba8unorm_srgb",l.keyword,"rgba8unorm_srgb"),rgba8snorm:new c("rgba8snorm",l.keyword,"rgba8snorm"),rgba8uint:new c("rgba8uint",l.keyword,"rgba8uint"),rgba8sint:new c("rgba8sint",l.keyword,"rgba8sint"),bgra8unorm:new c("bgra8unorm",l.keyword,"bgra8unorm"),bgra8unorm_srgb:new c("bgra8unorm_srgb",l.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new c("rgb10a2unorm",l.keyword,"rgb10a2unorm"),rg11b10float:new c("rg11b10float",l.keyword,"rg11b10float"),rg32uint:new c("rg32uint",l.keyword,"rg32uint"),rg32sint:new c("rg32sint",l.keyword,"rg32sint"),rg32float:new c("rg32float",l.keyword,"rg32float"),rgba16uint:new c("rgba16uint",l.keyword,"rgba16uint"),rgba16sint:new c("rgba16sint",l.keyword,"rgba16sint"),rgba16float:new c("rgba16float",l.keyword,"rgba16float"),rgba32uint:new c("rgba32uint",l.keyword,"rgba32uint"),rgba32sint:new c("rgba32sint",l.keyword,"rgba32sint"),rgba32float:new c("rgba32float",l.keyword,"rgba32float"),static_assert:new c("static_assert",l.keyword,"static_assert")};s.tokens={decimal_float_literal:new c("decimal_float_literal",l.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 c("hex_float_literal",l.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 c("int_literal",l.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new c("uint_literal",l.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new c("ident",l.token,/[a-zA-Z][0-9a-zA-Z_]*/),and:new c("and",l.token,"&"),and_and:new c("and_and",l.token,"&&"),arrow:new c("arrow ",l.token,"->"),attr:new c("attr",l.token,"@"),attr_left:new c("attr_left",l.token,"[["),attr_right:new c("attr_right",l.token,"]]"),forward_slash:new c("forward_slash",l.token,"/"),bang:new c("bang",l.token,"!"),bracket_left:new c("bracket_left",l.token,"["),bracket_right:new c("bracket_right",l.token,"]"),brace_left:new c("brace_left",l.token,"{"),brace_right:new c("brace_right",l.token,"}"),colon:new c("colon",l.token,":"),comma:new c("comma",l.token,","),equal:new c("equal",l.token,"="),equal_equal:new c("equal_equal",l.token,"=="),not_equal:new c("not_equal",l.token,"!="),greater_than:new c("greater_than",l.token,">"),greater_than_equal:new c("greater_than_equal",l.token,">="),shift_right:new c("shift_right",l.token,">>"),less_than:new c("less_than",l.token,"<"),less_than_equal:new c("less_than_equal",l.token,"<="),shift_left:new c("shift_left",l.token,"<<"),modulo:new c("modulo",l.token,"%"),minus:new c("minus",l.token,"-"),minus_minus:new c("minus_minus",l.token,"--"),period:new c("period",l.token,"."),plus:new c("plus",l.token,"+"),plus_plus:new c("plus_plus",l.token,"++"),or:new c("or",l.token,"|"),or_or:new c("or_or",l.token,"||"),paren_left:new c("paren_left",l.token,"("),paren_right:new c("paren_right",l.token,")"),semicolon:new c("semicolon",l.token,";"),star:new c("star",l.token,"*"),tilde:new c("tilde",l.token,"~"),underscore:new c("underscore",l.token,"_"),xor:new c("xor",l.token,"^"),plus_equal:new c("plus_equal",l.token,"+="),minus_equal:new c("minus_equal",l.token,"-="),times_equal:new c("times_equal",l.token,"*="),division_equal:new c("division_equal",l.token,"/="),modulo_equal:new c("modulo_equal",l.token,"%="),and_equal:new c("and_equal",l.token,"&="),or_equal:new c("or_equal",l.token,"|="),xor_equal:new c("xor_equal",l.token,"^="),shift_right_equal:new c("shift_right_equal",l.token,">>="),shift_left_equal:new c("shift_left_equal",l.token,"<<=")};s.storage_class=[_.keywords.function,_.keywords.private,_.keywords.workgroup,_.keywords.uniform,_.keywords.storage];s.access_mode=[_.keywords.read,_.keywords.write,_.keywords.read_write];s.sampler_type=[_.keywords.sampler,_.keywords.sampler_comparison];s.sampled_texture_type=[_.keywords.texture_1d,_.keywords.texture_2d,_.keywords.texture_2d_array,_.keywords.texture_3d,_.keywords.texture_cube,_.keywords.texture_cube_array];s.multisampled_texture_type=[_.keywords.texture_multisampled_2d];s.storage_texture_type=[_.keywords.texture_storage_1d,_.keywords.texture_storage_2d,_.keywords.texture_storage_2d_array,_.keywords.texture_storage_3d];s.depth_texture_type=[_.keywords.texture_depth_2d,_.keywords.texture_depth_2d_array,_.keywords.texture_depth_cube,_.keywords.texture_depth_cube_array,_.keywords.texture_depth_multisampled_2d];s.texture_external_type=[_.keywords.texture_external];s.any_texture_type=[..._.sampled_texture_type,..._.multisampled_texture_type,..._.storage_texture_type,..._.depth_texture_type,..._.texture_external_type];s.texel_format=[_.keywords.r8unorm,_.keywords.r8snorm,_.keywords.r8uint,_.keywords.r8sint,_.keywords.r16uint,_.keywords.r16sint,_.keywords.r16float,_.keywords.rg8unorm,_.keywords.rg8snorm,_.keywords.rg8uint,_.keywords.rg8sint,_.keywords.r32uint,_.keywords.r32sint,_.keywords.r32float,_.keywords.rg16uint,_.keywords.rg16sint,_.keywords.rg16float,_.keywords.rgba8unorm,_.keywords.rgba8unorm_srgb,_.keywords.rgba8snorm,_.keywords.rgba8uint,_.keywords.rgba8sint,_.keywords.bgra8unorm,_.keywords.bgra8unorm_srgb,_.keywords.rgb10a2unorm,_.keywords.rg11b10float,_.keywords.rg32uint,_.keywords.rg32sint,_.keywords.rg32float,_.keywords.rgba16uint,_.keywords.rgba16sint,_.keywords.rgba16float,_.keywords.rgba32uint,_.keywords.rgba32sint,_.keywords.rgba32float];s.const_literal=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal,_.keywords.true,_.keywords.false];s.literal_or_ident=[_.tokens.ident,_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal];s.element_count_expression=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.ident];s.template_types=[_.keywords.vec2,_.keywords.vec3,_.keywords.vec4,_.keywords.mat2x2,_.keywords.mat2x3,_.keywords.mat2x4,_.keywords.mat3x2,_.keywords.mat3x3,_.keywords.mat3x4,_.keywords.mat4x2,_.keywords.mat4x3,_.keywords.mat4x4,_.keywords.atomic,_.keywords.bitcast,..._.any_texture_type];s.attribute_name=[_.tokens.ident,_.keywords.block];s.assignment_operators=[_.tokens.equal,_.tokens.plus_equal,_.tokens.minus_equal,_.tokens.times_equal,_.tokens.division_equal,_.tokens.modulo_equal,_.tokens.and_equal,_.tokens.or_equal,_.tokens.xor_equal,_.tokens.shift_right_equal,_.tokens.shift_left_equal];s.increment_operators=[_.tokens.plus_plus,_.tokens.minus_minus];var ze=class{constructor(e,r,n){this.type=e,this.lexeme=r,this.line=n}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()}},It=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new ze(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
85
|
+
}`}function Rr(r){switch(r){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(r)}}function Or(r){switch(r){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(r)}}function Lo(r){switch(r){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${r}`)}}function lt(r,e){switch(e){case 1:return`vec4(${r}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${r}, 0.0, 1.0)`;case 3:return`vec4(${r}, 1.0)`;case 4:return r;default:throw new Error(`invalid channels: ${e}`)}}function Z(r){return typeof r=="string"?r.charAt(0).toUpperCase()+r.slice(1):r}function Ur(r,e){return ko(r,e)}function ko(r,e){let t=[];switch(e.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":t.push(`uniform ${Z(r.name)} {`);break;case"uniforms":}for(let[n,o]of Object.entries(r.uniformTypes||{})){let i=So(o);switch(e.uniforms){case"scoped-interface-blocks":t.push(` ${i} ${n};`);break;case"unscoped-interface-blocks":t.push(` ${i} ${r.name}_${n};`);break;case"uniforms":t.push(`uniform ${i} ${r.name}_${n};`)}}switch(e.uniforms){case"scoped-interface-blocks":t.push(`} ${r.name};`);break;case"unscoped-interface-blocks":t.push("};");break;case"uniforms":}return t.push(""),t.join(`
|
|
86
|
+
`)}function So(r){return{f32:"float",i32:"int",u32:"uint","vec2<f32>":"vec2","vec3<f32>":"vec3","vec4<f32>":"vec4","vec2<i32>":"ivec2","vec3<i32>":"ivec3","vec4<i32>":"ivec4","vec2<u32>":"uvec2","vec3<u32>":"uvec3","vec4<u32>":"uvec4","mat2x2<f32>":"mat2","mat2x3<f32>":"mat2x3","mat2x4<f32>":"mat2x4","mat3x2<f32>":"mat3x2","mat3x3<f32>":"mat3","mat3x4<f32>":"mat3x4","mat4x2<f32>":"mat4x2","mat4x3<f32>":"mat4x3","mat4x4<f32>":"mat4"}[r]}function zr(r,e){return No(r,e)}function No(r,e){let t=[];t.push(`struct ${Z(r.name)} {`);for(let[n,o]of Object.entries(r?.uniformTypes||{})){let i=o;t.push(` ${n} : ${i};`)}return t.push("};"),t.push(`var<uniform> ${r.name} : ${Z(r.name)};`),t.join(`
|
|
87
|
+
`)}function Dr(r,e){switch(e.shaderLanguage){case"glsl":return Ur(r,e);case"wgsl":return zr(r,e)}}var Xr=fr(et(),1);var ft=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},B=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(e){throw new Error("Cannot evaluate node")}evaluateString(e){return this.evaluate(e).toString()}search(e){}searchBlock(e,t){if(e){t(ae.instance);for(let n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(ce.instance)}}},ae=class extends B{};ae.instance=new ae;var ce=class extends B{};ce.instance=new ce;var N=class extends B{constructor(){super()}},xe=class extends N{constructor(e,t,n,o,i,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=o,this.startLine=i,this.endLine=a}get astNodeType(){return"function"}search(e){this.searchBlock(this.body,e)}},ut=class extends N{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},_t=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},ht=class extends N{constructor(e){super(),this.body=e}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},pt=class extends N{constructor(e,t,n,o){super(),this.init=e,this.condition=t,this.increment=n,this.body=o}get astNodeType(){return"for"}search(e){var t,n,o;(t=this.init)===null||t===void 0||t.search(e),(n=this.condition)===null||n===void 0||n.search(e),(o=this.increment)===null||o===void 0||o.search(e),this.searchBlock(this.body,e)}},G=class extends N{constructor(e,t,n,o,i){super(),this.name=e,this.type=t,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Te=class extends N{constructor(e,t,n){super(),this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},ve=class extends N{constructor(e,t,n,o,i){super(),this.name=e,this.type=t,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Ee=class extends N{constructor(e,t,n,o,i){super(),this.name=e,this.type=t,this.storage=n,this.access=o,this.value=i}get astNodeType(){return"const"}evaluate(e){return this.value.evaluate(e)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},le;(function(r){r.increment="++",r.decrement="--"})(le||(le={}));(function(r){function e(t){let n=t;if(n=="parse")throw new Error("Invalid value for IncrementOperator");return r[n]}r.parse=e})(le||(le={}));var dt=class extends N{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}},Ae;(function(r){r.assign="=",r.addAssign="+=",r.subtractAssin="-=",r.multiplyAssign="*=",r.divideAssign="/=",r.moduloAssign="%=",r.andAssign="&=",r.orAssign="|=",r.xorAssign="^=",r.shiftLeftAssign="<<=",r.shiftRightAssign=">>="})(Ae||(Ae={}));(function(r){function e(t){let n=t;if(n=="parse")throw new Error("Invalid value for AssignOperator");return n}r.parse=e})(Ae||(Ae={}));var mt=class extends N{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Me=class extends N{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}search(e){for(let t of this.args)t.search(e);e(this)}},gt=class extends N{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}},xt=class extends N{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"body"}},vt=class extends N{constructor(e,t,n,o){super(),this.condition=e,this.body=t,this.elseif=n,this.else=o}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}},At=class extends N{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},yt=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},bt=class extends N{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},Pt=class extends N{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}},Fe=class extends N{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}},wt=class extends N{constructor(){super()}get astNodeType(){return"discard"}},Lt=class extends N{constructor(){super()}get astNodeType(){return"break"}},kt=class extends N{constructor(){super()}get astNodeType(){return"continue"}},H=class extends N{constructor(e){super(),this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},V=class extends H{constructor(e,t,n,o){super(e),this.members=t,this.startLine=n,this.endLine=o}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}},Ie=class extends H{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}},St=class extends H{constructor(e,t,n,o){super(e),this.storage=t,this.type=n,this.access=o}get astNodeType(){return"pointer"}},Ce=class extends H{constructor(e,t,n,o){super(e),this.attributes=t,this.format=n,this.count=o}get astNodeType(){return"array"}get isArray(){return!0}},J=class extends H{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}},U=class extends B{constructor(){super()}},Re=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},$=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){e(this);for(let t of this.args)t.search(e)}},Oe=class extends U{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"callExpr"}evaluate(e){switch(this.name){case"abs":return Math.abs(this.args[0].evaluate(e));case"acos":return Math.acos(this.args[0].evaluate(e));case"acosh":return Math.acosh(this.args[0].evaluate(e));case"asin":return Math.asin(this.args[0].evaluate(e));case"asinh":return Math.asinh(this.args[0].evaluate(e));case"atan":return Math.atan(this.args[0].evaluate(e));case"atan2":return Math.atan2(this.args[0].evaluate(e),this.args[1].evaluate(e));case"atanh":return Math.atanh(this.args[0].evaluate(e));case"ceil":return Math.ceil(this.args[0].evaluate(e));case"clamp":return Math.min(Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e)),this.args[2].evaluate(e));case"cos":return Math.cos(this.args[0].evaluate(e));case"degrees":return this.args[0].evaluate(e)*180/Math.PI;case"distance":return Math.sqrt(Math.pow(this.args[0].evaluate(e)-this.args[1].evaluate(e),2));case"dot":case"exp":return Math.exp(this.args[0].evaluate(e));case"exp2":return Math.pow(2,this.args[0].evaluate(e));case"floor":return Math.floor(this.args[0].evaluate(e));case"fma":return this.args[0].evaluate(e)*this.args[1].evaluate(e)+this.args[2].evaluate(e);case"fract":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"inverseSqrt":return 1/Math.sqrt(this.args[0].evaluate(e));case"log":return Math.log(this.args[0].evaluate(e));case"log2":return Math.log2(this.args[0].evaluate(e));case"max":return Math.max(this.args[0].evaluate(e),this.args[1].evaluate(e));case"min":return Math.min(this.args[0].evaluate(e),this.args[1].evaluate(e));case"mix":return this.args[0].evaluate(e)*(1-this.args[2].evaluate(e))+this.args[1].evaluate(e)*this.args[2].evaluate(e);case"modf":return this.args[0].evaluate(e)-Math.floor(this.args[0].evaluate(e));case"pow":return Math.pow(this.args[0].evaluate(e),this.args[1].evaluate(e));case"radians":return this.args[0].evaluate(e)*Math.PI/180;case"round":return Math.round(this.args[0].evaluate(e));case"sign":return Math.sign(this.args[0].evaluate(e));case"sin":return Math.sin(this.args[0].evaluate(e));case"sinh":return Math.sinh(this.args[0].evaluate(e));case"saturate":return Math.min(Math.max(this.args[0].evaluate(e),0),1);case"smoothstep":return this.args[0].evaluate(e)*this.args[0].evaluate(e)*(3-2*this.args[0].evaluate(e));case"sqrt":return Math.sqrt(this.args[0].evaluate(e));case"step":return this.args[0].evaluate(e)<this.args[1].evaluate(e)?0:1;case"tan":return Math.tan(this.args[0].evaluate(e));case"tanh":return Math.tanh(this.args[0].evaluate(e));case"trunc":return Math.trunc(this.args[0].evaluate(e));default:throw new Error("Non const function: "+this.name)}}search(e){for(let t of this.args)t.search(e);e(this)}},ye=class extends U{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}evaluate(e){let t=e.constants.get(this.name);if(!t)throw new Error("Cannot evaluate node");return t.evaluate(e)}},Ue=class extends U{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}evaluate(e){var t,n;if(this.initializer instanceof $){let o=(t=this.postfix)===null||t===void 0?void 0:t.evaluateString(e),i=(n=this.initializer.type)===null||n===void 0?void 0:n.name,a=e.structs.get(i),c=a?.getMemberIndex(o);if(c!=-1)return this.initializer.args[c].evaluate(e);console.log(c)}return this.initializer.evaluate(e)}search(e){this.initializer.search(e)}},ze=class extends U{constructor(e){super(),this.value=e}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Nt=class extends U{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}},Tt=class extends U{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"typecastExpr"}evaluate(e){return this.args[0].evaluate(e)}search(e){this.searchBlock(this.args,e)}},De=class extends U{constructor(e){super(),this.contents=e}get astNodeType(){return"groupExpr"}evaluate(e){return this.contents[0].evaluate(e)}search(e){this.searchBlock(this.contents,e)}},Et=class extends U{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},Ye=class extends U{constructor(){super()}},Mt=class extends Ye{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}evaluate(e){switch(this.operator){case"+":return this.right.evaluate(e);case"-":return-this.right.evaluate(e);case"!":return this.right.evaluate(e)?0:1;case"~":return~this.right.evaluate(e);default:throw new Error("Unknown unary operator: "+this.operator)}}search(e){this.right.search(e)}},Y=class extends Ye{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}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)}},Xe=class extends B{constructor(){super()}},Ft=class extends Xe{constructor(e,t){super(),this.selector=e,this.body=t}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},It=class extends Xe{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Ct=class extends B{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}},Rt=class extends B{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Ot=class extends B{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}},Ut=class extends B{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}},_,f;(function(r){r[r.token=0]="token",r[r.keyword=1]="keyword",r[r.reserved=2]="reserved"})(f||(f={}));var l=class{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}},s=class{};_=s;s.none=new l("",f.reserved,"");s.eof=new l("EOF",f.token,"");s.reserved={asm:new l("asm",f.reserved,"asm"),bf16:new l("bf16",f.reserved,"bf16"),do:new l("do",f.reserved,"do"),enum:new l("enum",f.reserved,"enum"),f16:new l("f16",f.reserved,"f16"),f64:new l("f64",f.reserved,"f64"),handle:new l("handle",f.reserved,"handle"),i8:new l("i8",f.reserved,"i8"),i16:new l("i16",f.reserved,"i16"),i64:new l("i64",f.reserved,"i64"),mat:new l("mat",f.reserved,"mat"),premerge:new l("premerge",f.reserved,"premerge"),regardless:new l("regardless",f.reserved,"regardless"),typedef:new l("typedef",f.reserved,"typedef"),u8:new l("u8",f.reserved,"u8"),u16:new l("u16",f.reserved,"u16"),u64:new l("u64",f.reserved,"u64"),unless:new l("unless",f.reserved,"unless"),using:new l("using",f.reserved,"using"),vec:new l("vec",f.reserved,"vec"),void:new l("void",f.reserved,"void")};s.keywords={array:new l("array",f.keyword,"array"),atomic:new l("atomic",f.keyword,"atomic"),bool:new l("bool",f.keyword,"bool"),f32:new l("f32",f.keyword,"f32"),i32:new l("i32",f.keyword,"i32"),mat2x2:new l("mat2x2",f.keyword,"mat2x2"),mat2x3:new l("mat2x3",f.keyword,"mat2x3"),mat2x4:new l("mat2x4",f.keyword,"mat2x4"),mat3x2:new l("mat3x2",f.keyword,"mat3x2"),mat3x3:new l("mat3x3",f.keyword,"mat3x3"),mat3x4:new l("mat3x4",f.keyword,"mat3x4"),mat4x2:new l("mat4x2",f.keyword,"mat4x2"),mat4x3:new l("mat4x3",f.keyword,"mat4x3"),mat4x4:new l("mat4x4",f.keyword,"mat4x4"),ptr:new l("ptr",f.keyword,"ptr"),sampler:new l("sampler",f.keyword,"sampler"),sampler_comparison:new l("sampler_comparison",f.keyword,"sampler_comparison"),struct:new l("struct",f.keyword,"struct"),texture_1d:new l("texture_1d",f.keyword,"texture_1d"),texture_2d:new l("texture_2d",f.keyword,"texture_2d"),texture_2d_array:new l("texture_2d_array",f.keyword,"texture_2d_array"),texture_3d:new l("texture_3d",f.keyword,"texture_3d"),texture_cube:new l("texture_cube",f.keyword,"texture_cube"),texture_cube_array:new l("texture_cube_array",f.keyword,"texture_cube_array"),texture_multisampled_2d:new l("texture_multisampled_2d",f.keyword,"texture_multisampled_2d"),texture_storage_1d:new l("texture_storage_1d",f.keyword,"texture_storage_1d"),texture_storage_2d:new l("texture_storage_2d",f.keyword,"texture_storage_2d"),texture_storage_2d_array:new l("texture_storage_2d_array",f.keyword,"texture_storage_2d_array"),texture_storage_3d:new l("texture_storage_3d",f.keyword,"texture_storage_3d"),texture_depth_2d:new l("texture_depth_2d",f.keyword,"texture_depth_2d"),texture_depth_2d_array:new l("texture_depth_2d_array",f.keyword,"texture_depth_2d_array"),texture_depth_cube:new l("texture_depth_cube",f.keyword,"texture_depth_cube"),texture_depth_cube_array:new l("texture_depth_cube_array",f.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new l("texture_depth_multisampled_2d",f.keyword,"texture_depth_multisampled_2d"),texture_external:new l("texture_external",f.keyword,"texture_external"),u32:new l("u32",f.keyword,"u32"),vec2:new l("vec2",f.keyword,"vec2"),vec3:new l("vec3",f.keyword,"vec3"),vec4:new l("vec4",f.keyword,"vec4"),bitcast:new l("bitcast",f.keyword,"bitcast"),block:new l("block",f.keyword,"block"),break:new l("break",f.keyword,"break"),case:new l("case",f.keyword,"case"),continue:new l("continue",f.keyword,"continue"),continuing:new l("continuing",f.keyword,"continuing"),default:new l("default",f.keyword,"default"),diagnostic:new l("diagnostic",f.keyword,"diagnostic"),discard:new l("discard",f.keyword,"discard"),else:new l("else",f.keyword,"else"),enable:new l("enable",f.keyword,"enable"),fallthrough:new l("fallthrough",f.keyword,"fallthrough"),false:new l("false",f.keyword,"false"),fn:new l("fn",f.keyword,"fn"),for:new l("for",f.keyword,"for"),function:new l("function",f.keyword,"function"),if:new l("if",f.keyword,"if"),let:new l("let",f.keyword,"let"),const:new l("const",f.keyword,"const"),loop:new l("loop",f.keyword,"loop"),while:new l("while",f.keyword,"while"),private:new l("private",f.keyword,"private"),read:new l("read",f.keyword,"read"),read_write:new l("read_write",f.keyword,"read_write"),return:new l("return",f.keyword,"return"),requires:new l("requires",f.keyword,"requires"),storage:new l("storage",f.keyword,"storage"),switch:new l("switch",f.keyword,"switch"),true:new l("true",f.keyword,"true"),alias:new l("alias",f.keyword,"alias"),type:new l("type",f.keyword,"type"),uniform:new l("uniform",f.keyword,"uniform"),var:new l("var",f.keyword,"var"),override:new l("override",f.keyword,"override"),workgroup:new l("workgroup",f.keyword,"workgroup"),write:new l("write",f.keyword,"write"),r8unorm:new l("r8unorm",f.keyword,"r8unorm"),r8snorm:new l("r8snorm",f.keyword,"r8snorm"),r8uint:new l("r8uint",f.keyword,"r8uint"),r8sint:new l("r8sint",f.keyword,"r8sint"),r16uint:new l("r16uint",f.keyword,"r16uint"),r16sint:new l("r16sint",f.keyword,"r16sint"),r16float:new l("r16float",f.keyword,"r16float"),rg8unorm:new l("rg8unorm",f.keyword,"rg8unorm"),rg8snorm:new l("rg8snorm",f.keyword,"rg8snorm"),rg8uint:new l("rg8uint",f.keyword,"rg8uint"),rg8sint:new l("rg8sint",f.keyword,"rg8sint"),r32uint:new l("r32uint",f.keyword,"r32uint"),r32sint:new l("r32sint",f.keyword,"r32sint"),r32float:new l("r32float",f.keyword,"r32float"),rg16uint:new l("rg16uint",f.keyword,"rg16uint"),rg16sint:new l("rg16sint",f.keyword,"rg16sint"),rg16float:new l("rg16float",f.keyword,"rg16float"),rgba8unorm:new l("rgba8unorm",f.keyword,"rgba8unorm"),rgba8unorm_srgb:new l("rgba8unorm_srgb",f.keyword,"rgba8unorm_srgb"),rgba8snorm:new l("rgba8snorm",f.keyword,"rgba8snorm"),rgba8uint:new l("rgba8uint",f.keyword,"rgba8uint"),rgba8sint:new l("rgba8sint",f.keyword,"rgba8sint"),bgra8unorm:new l("bgra8unorm",f.keyword,"bgra8unorm"),bgra8unorm_srgb:new l("bgra8unorm_srgb",f.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new l("rgb10a2unorm",f.keyword,"rgb10a2unorm"),rg11b10float:new l("rg11b10float",f.keyword,"rg11b10float"),rg32uint:new l("rg32uint",f.keyword,"rg32uint"),rg32sint:new l("rg32sint",f.keyword,"rg32sint"),rg32float:new l("rg32float",f.keyword,"rg32float"),rgba16uint:new l("rgba16uint",f.keyword,"rgba16uint"),rgba16sint:new l("rgba16sint",f.keyword,"rgba16sint"),rgba16float:new l("rgba16float",f.keyword,"rgba16float"),rgba32uint:new l("rgba32uint",f.keyword,"rgba32uint"),rgba32sint:new l("rgba32sint",f.keyword,"rgba32sint"),rgba32float:new l("rgba32float",f.keyword,"rgba32float"),static_assert:new l("static_assert",f.keyword,"static_assert")};s.tokens={decimal_float_literal:new l("decimal_float_literal",f.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new l("hex_float_literal",f.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new l("int_literal",f.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new l("uint_literal",f.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new l("ident",f.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new l("and",f.token,"&"),and_and:new l("and_and",f.token,"&&"),arrow:new l("arrow ",f.token,"->"),attr:new l("attr",f.token,"@"),forward_slash:new l("forward_slash",f.token,"/"),bang:new l("bang",f.token,"!"),bracket_left:new l("bracket_left",f.token,"["),bracket_right:new l("bracket_right",f.token,"]"),brace_left:new l("brace_left",f.token,"{"),brace_right:new l("brace_right",f.token,"}"),colon:new l("colon",f.token,":"),comma:new l("comma",f.token,","),equal:new l("equal",f.token,"="),equal_equal:new l("equal_equal",f.token,"=="),not_equal:new l("not_equal",f.token,"!="),greater_than:new l("greater_than",f.token,">"),greater_than_equal:new l("greater_than_equal",f.token,">="),shift_right:new l("shift_right",f.token,">>"),less_than:new l("less_than",f.token,"<"),less_than_equal:new l("less_than_equal",f.token,"<="),shift_left:new l("shift_left",f.token,"<<"),modulo:new l("modulo",f.token,"%"),minus:new l("minus",f.token,"-"),minus_minus:new l("minus_minus",f.token,"--"),period:new l("period",f.token,"."),plus:new l("plus",f.token,"+"),plus_plus:new l("plus_plus",f.token,"++"),or:new l("or",f.token,"|"),or_or:new l("or_or",f.token,"||"),paren_left:new l("paren_left",f.token,"("),paren_right:new l("paren_right",f.token,")"),semicolon:new l("semicolon",f.token,";"),star:new l("star",f.token,"*"),tilde:new l("tilde",f.token,"~"),underscore:new l("underscore",f.token,"_"),xor:new l("xor",f.token,"^"),plus_equal:new l("plus_equal",f.token,"+="),minus_equal:new l("minus_equal",f.token,"-="),times_equal:new l("times_equal",f.token,"*="),division_equal:new l("division_equal",f.token,"/="),modulo_equal:new l("modulo_equal",f.token,"%="),and_equal:new l("and_equal",f.token,"&="),or_equal:new l("or_equal",f.token,"|="),xor_equal:new l("xor_equal",f.token,"^="),shift_right_equal:new l("shift_right_equal",f.token,">>="),shift_left_equal:new l("shift_left_equal",f.token,"<<=")};s.simpleTokens={"@":_.tokens.attr,"{":_.tokens.brace_left,"}":_.tokens.brace_right,":":_.tokens.colon,",":_.tokens.comma,"(":_.tokens.paren_left,")":_.tokens.paren_right,";":_.tokens.semicolon};s.literalTokens={"&":_.tokens.and,"&&":_.tokens.and_and,"->":_.tokens.arrow,"/":_.tokens.forward_slash,"!":_.tokens.bang,"[":_.tokens.bracket_left,"]":_.tokens.bracket_right,"=":_.tokens.equal,"==":_.tokens.equal_equal,"!=":_.tokens.not_equal,">":_.tokens.greater_than,">=":_.tokens.greater_than_equal,">>":_.tokens.shift_right,"<":_.tokens.less_than,"<=":_.tokens.less_than_equal,"<<":_.tokens.shift_left,"%":_.tokens.modulo,"-":_.tokens.minus,"--":_.tokens.minus_minus,".":_.tokens.period,"+":_.tokens.plus,"++":_.tokens.plus_plus,"|":_.tokens.or,"||":_.tokens.or_or,"*":_.tokens.star,"~":_.tokens.tilde,_:_.tokens.underscore,"^":_.tokens.xor,"+=":_.tokens.plus_equal,"-=":_.tokens.minus_equal,"*=":_.tokens.times_equal,"/=":_.tokens.division_equal,"%=":_.tokens.modulo_equal,"&=":_.tokens.and_equal,"|=":_.tokens.or_equal,"^=":_.tokens.xor_equal,">>=":_.tokens.shift_right_equal,"<<=":_.tokens.shift_left_equal};s.regexTokens={decimal_float_literal:_.tokens.decimal_float_literal,hex_float_literal:_.tokens.hex_float_literal,int_literal:_.tokens.int_literal,uint_literal:_.tokens.uint_literal,ident:_.tokens.ident};s.storage_class=[_.keywords.function,_.keywords.private,_.keywords.workgroup,_.keywords.uniform,_.keywords.storage];s.access_mode=[_.keywords.read,_.keywords.write,_.keywords.read_write];s.sampler_type=[_.keywords.sampler,_.keywords.sampler_comparison];s.sampled_texture_type=[_.keywords.texture_1d,_.keywords.texture_2d,_.keywords.texture_2d_array,_.keywords.texture_3d,_.keywords.texture_cube,_.keywords.texture_cube_array];s.multisampled_texture_type=[_.keywords.texture_multisampled_2d];s.storage_texture_type=[_.keywords.texture_storage_1d,_.keywords.texture_storage_2d,_.keywords.texture_storage_2d_array,_.keywords.texture_storage_3d];s.depth_texture_type=[_.keywords.texture_depth_2d,_.keywords.texture_depth_2d_array,_.keywords.texture_depth_cube,_.keywords.texture_depth_cube_array,_.keywords.texture_depth_multisampled_2d];s.texture_external_type=[_.keywords.texture_external];s.any_texture_type=[..._.sampled_texture_type,..._.multisampled_texture_type,..._.storage_texture_type,..._.depth_texture_type,..._.texture_external_type];s.texel_format=[_.keywords.r8unorm,_.keywords.r8snorm,_.keywords.r8uint,_.keywords.r8sint,_.keywords.r16uint,_.keywords.r16sint,_.keywords.r16float,_.keywords.rg8unorm,_.keywords.rg8snorm,_.keywords.rg8uint,_.keywords.rg8sint,_.keywords.r32uint,_.keywords.r32sint,_.keywords.r32float,_.keywords.rg16uint,_.keywords.rg16sint,_.keywords.rg16float,_.keywords.rgba8unorm,_.keywords.rgba8unorm_srgb,_.keywords.rgba8snorm,_.keywords.rgba8uint,_.keywords.rgba8sint,_.keywords.bgra8unorm,_.keywords.bgra8unorm_srgb,_.keywords.rgb10a2unorm,_.keywords.rg11b10float,_.keywords.rg32uint,_.keywords.rg32sint,_.keywords.rg32float,_.keywords.rgba16uint,_.keywords.rgba16sint,_.keywords.rgba16float,_.keywords.rgba32uint,_.keywords.rgba32sint,_.keywords.rgba32float];s.const_literal=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal,_.keywords.true,_.keywords.false];s.literal_or_ident=[_.tokens.ident,_.tokens.int_literal,_.tokens.uint_literal,_.tokens.decimal_float_literal,_.tokens.hex_float_literal];s.element_count_expression=[_.tokens.int_literal,_.tokens.uint_literal,_.tokens.ident];s.template_types=[_.keywords.vec2,_.keywords.vec3,_.keywords.vec4,_.keywords.mat2x2,_.keywords.mat2x3,_.keywords.mat2x4,_.keywords.mat3x2,_.keywords.mat3x3,_.keywords.mat3x4,_.keywords.mat4x2,_.keywords.mat4x3,_.keywords.mat4x4,_.keywords.atomic,_.keywords.bitcast,..._.any_texture_type];s.attribute_name=[_.tokens.ident,_.keywords.block,_.keywords.diagnostic];s.assignment_operators=[_.tokens.equal,_.tokens.plus_equal,_.tokens.minus_equal,_.tokens.times_equal,_.tokens.division_equal,_.tokens.modulo_equal,_.tokens.and_equal,_.tokens.or_equal,_.tokens.xor_equal,_.tokens.shift_right_equal,_.tokens.shift_left_equal];s.increment_operators=[_.tokens.plus_plus,_.tokens.minus_minus];var Be=class{constructor(e,t,n){this.type=e,this.lexeme=t,this.line=n}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()}},zt=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 Be(s.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
88
88
|
`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
|
|
89
|
-
`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let
|
|
90
|
-
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),n--,n==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),n++)}return!0}}let r=s.none;for(;;){let n=this._findType(e),o=this._peekAhead();if(e==">"&&(o==">"||o=="=")){let i=!1,a=this._tokens.length-1;for(let f=0;f<5&&a>=0;++f,--a)if(this._tokens[a].type===s.tokens.less_than){a>0&&this._tokens[a-1].isArrayOrTemplateType()&&(i=!0);break}if(i)return this._addToken(n),!0}if(n===s.none){let i=e,a=0,f=2;for(let u=0;u<f;++u)if(i+=this._peekAhead(u),n=this._findType(i),n!==s.none){a=u;break}if(n===s.none)return r===s.none?!1:(this._current--,this._addToken(r),!0);e=i,this._current+=a+1}if(r=n,this._isAtEnd())break;e+=this._advance()}return r===s.none?!1:(this._addToken(r),!0)}_findType(e){for(let r in s.keywords){let n=s.keywords[r];if(this._match(e,n.rule))return n}for(let r in s.tokens){let n=s.tokens[r];if(this._match(e,n.rule))return n}return s.none}_match(e,r){if(typeof r=="string"){if(r==e)return!0}else{let n=r.exec(e);if(n&&n.index==0&&n[0]==e)return!0}return!1}_isAtEnd(){return this._current>=this._source.length}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let r=this._source[this._current];return e=e||0,e++,this._current+=e,r}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let r=this._source.substring(this._start,this._current);this._tokens.push(new ze(e,r,this._line))}},Ct=class{constructor(){this._tokens=[],this._current=0,this._context=new st}parse(e){this._initialize(e);let r=[];for(;!this._isAtEnd();){let n=this._global_decl_or_directive();if(!n)break;r.push(n)}return r}_initialize(e){if(e)if(typeof e=="string"){let r=new It(e);this._tokens=r.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,r){return console.error(e,r),{token:e,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==s.eof}_match(e){if(e instanceof c)return this._check(e)?(this._advance(),!0):!1;for(let r=0,n=e.length;r<n;++r){let o=e[r];if(this._check(o))return this._advance(),!0}return!1}_consume(e,r){if(this._check(e))return this._advance();throw this._error(this._peek(),r)}_check(e){if(this._isAtEnd())return!1;let r=this._peek();if(e instanceof Array){let n=r.type;return e.indexOf(n)!=-1}return r.type==e}_advance(){return 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 r=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),r}if(this._match(s.keywords.enable)){let r=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),r}let e=this._attribute();if(this._check(s.keywords.var)){let r=this._global_variable_decl();return r!=null&&(r.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),r}if(this._check(s.keywords.override)){let r=this._override_variable_decl();return r!=null&&(r.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),r}if(this._check(s.keywords.let)){let r=this._global_let_decl();return r!=null&&(r.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),r}if(this._check(s.keywords.const)){let r=this._global_const_decl();return r!=null&&(r.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),r}if(this._check(s.keywords.struct)){let r=this._struct_decl();return r!=null&&(r.attributes=e),r}if(this._check(s.keywords.fn)){let r=this._function_decl();return r!=null&&(r.attributes=e),r}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=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 i=this._attribute(),a=this._consume(s.tokens.ident,"Expected argument name.").toString();this._consume(s.tokens.colon,"Expected ':' for argument type.");let f=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=f,r.push(new Tt(a,u,i)))}while(this._match(s.tokens.comma));this._consume(s.tokens.paren_right,"Expected ')' after function arguments.");let n=null;if(this._match(s.tokens.arrow)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}let o=this._compound_statement();return new we(e,r,n,o)}_compound_statement(){let e=[];for(this._consume(s.tokens.brace_left,"Expected '{' for block.");!this._check(s.tokens.brace_right);){let r=this._statement();r!==null&&e.push(r)}return this._consume(s.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(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 vt:this._match(s.keywords.break)?e=new At:this._match(s.keywords.continue)?e=new bt: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 at(e)}_while_statement(){if(!this._match(s.keywords.while))return null;let e=this._optional_paren_expression(),r=this._compound_statement();return new ct(e,r)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new lt(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 r=this._check(s.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(s.tokens.semicolon,"Expected ';'.");let n=this._check(s.tokens.paren_right)?null:this._for_increment();this._consume(s.tokens.paren_right,"Expected ')'.");let o=this._compound_statement();return new ft(e,r,n,o)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(s.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let r=null;return this._match(s.tokens.equal)&&(r=this._short_circuit_or_expression()),new j(e.name,e.type,e.storage,e.access,r)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),r=null;if(this._match(s.tokens.colon)){let o=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for let.");let n=this._short_circuit_or_expression();return new Se(e,r,null,null,n)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),r=null;if(this._match(s.tokens.colon)){let o=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for const.");let n=this._short_circuit_or_expression();return new ke(e,r,null,null,n)}return null}_increment_decrement_statement(){let e=this._current,r=this._unary_expression();if(r==null)return null;if(!this._check(s.increment_operators))return this._current=e,null;let n=this._consume(s.increment_operators,"Expected increment operator");return new ut(n.type===s.tokens.plus_plus?ae.increment:ae.decrement,r)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let r=this._match(s.tokens.underscore);if(r||(e=this._unary_expression()),!r&&e==null)return null;let n=this._consume(s.assignment_operators,"Expected assignment operator."),o=this._short_circuit_or_expression();return new _t(me.parse(n.lexeme),e,o)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,r=this._consume(s.tokens.ident,"Expected function name."),n=this._argument_expression_list();return n===null?(this._current=e,null):new ht(r.lexeme,n)}_loop_statement(){if(!this._match(s.keywords.loop))return null;this._consume(s.tokens.brace_left,"Expected '{' for loop.");let e=[],r=this._statement();for(;r!==null;){if(Array.isArray(r))for(let o of r)e.push(o);else e.push(r);r=this._statement()}let n=null;return this._match(s.keywords.continuing)&&(n=this._compound_statement()),this._consume(s.tokens.brace_right,"Expected '}' for loop."),new pt(e,n)}_switch_statement(){if(!this._match(s.keywords.switch))return null;let e=this._optional_paren_expression();this._consume(s.tokens.brace_left,"Expected '{' for switch.");let r=this._switch_body();if(r==null||r.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new dt(e,r)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let r=this._case_selectors();this._match(s.tokens.colon),this._consume(s.tokens.brace_left,"Exected '{' for switch case.");let n=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch case."),e.push(new Nt(r,n))}if(this._match(s.keywords.default)){this._match(s.tokens.colon),this._consume(s.tokens.brace_left,"Exected '{' for switch default.");let r=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new Et(r))}if(this._check([s.keywords.default,s.keywords.case])){let r=this._switch_body();e.push(r[0])}return e}_case_selectors(){var e,r,n,o;let i=[(r=(e=this._shift_expression())===null||e===void 0?void 0:e.evaluate(this._context).toString())!==null&&r!==void 0?r:""];for(;this._match(s.tokens.comma);)i.push((o=(n=this._shift_expression())===null||n===void 0?void 0:n.evaluate(this._context).toString())!==null&&o!==void 0?o:"");return i}_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 r=this._case_body();return r.length==0?e:[...e,r[0]]}_if_statement(){if(!this._match(s.keywords.if))return null;let e=this._optional_paren_expression(),r=this._compound_statement(),n=[];this._match_elseif()&&(n=this._elseif_statement(n));let o=null;return this._match(s.keywords.else)&&(o=this._compound_statement()),new mt(e,r,n,o)}_match_elseif(){return this._tokens[this._current].type===s.keywords.else&&this._tokens[this._current+1].type===s.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(e=[]){let r=this._optional_paren_expression(),n=this._compound_statement();return e.push(new Mt(r,n)),this._match_elseif()&&this._elseif_statement(e),e}_return_statement(){if(!this._match(s.keywords.return))return null;let e=this._short_circuit_or_expression();return new gt(e)}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(s.tokens.or_or);)e=new D(this._previous().toString(),e,this._short_circuit_and_expr());return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(s.tokens.and_and);)e=new D(this._previous().toString(),e,this._inclusive_or_expression());return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(s.tokens.or);)e=new D(this._previous().toString(),e,this._exclusive_or_expression());return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(s.tokens.xor);)e=new D(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new D(this._previous().toString(),e,this._equality_expression());return e}_equality_expression(){let e=this._relational_expression();return this._match([s.tokens.equal_equal,s.tokens.not_equal])?new D(this._previous().toString(),e,this._relational_expression()):e}_relational_expression(){let e=this._shift_expression();for(;this._match([s.tokens.less_than,s.tokens.greater_than,s.tokens.less_than_equal,s.tokens.greater_than_equal]);)e=new D(this._previous().toString(),e,this._shift_expression());return e}_shift_expression(){let e=this._additive_expression();for(;this._match([s.tokens.shift_left,s.tokens.shift_right]);)e=new D(this._previous().toString(),e,this._additive_expression());return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([s.tokens.plus,s.tokens.minus]);)e=new D(this._previous().toString(),e,this._multiplicative_expression());return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([s.tokens.star,s.tokens.forward_slash,s.tokens.modulo]);)e=new D(this._previous().toString(),e,this._unary_expression());return e}_unary_expression(){return this._match([s.tokens.minus,s.tokens.bang,s.tokens.tilde,s.tokens.star,s.tokens.and])?new kt(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),r=this._postfix_expression();return r&&(e.postfix=r),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 r=this._postfix_expression();return r&&(e.postfix=r),e}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),r=this._postfix_expression(),n=new Me(e.lexeme);return r&&(n.postfix=r),n}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 n=this._previous().toString();if(this._check(s.tokens.paren_left)){let o=this._argument_expression_list(),i=this._getStruct(n);return i!=null?new J(i,o):new Pt(n,o)}if(this._context.constants.has(n)){let o=this._context.constants.get(n);return new Fe(n,o.value)}return new wt(n)}if(this._match(s.const_literal))return new Ie(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 n=this._type_decl();this._consume(s.tokens.greater_than,"Expected '>'.");let o=this._paren_expression();return new Lt(n,o)}let e=this._type_decl(),r=this._argument_expression_list();return new St(e,r)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let r=this._short_circuit_or_expression();e.push(r)}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 Ce([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 Ce([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=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 o=this._attribute(),i=this._consume(s.tokens.ident,"Expected variable name.").toString();this._consume(s.tokens.colon,"Expected ':' for struct member type.");let a=this._attribute(),f=this._type_decl();f!=null&&(f.attributes=a),this._check(s.tokens.brace_right)?this._match(s.tokens.comma):this._consume(s.tokens.comma,"Expected ',' for struct member."),r.push(new Ft(i,f,o))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let n=new V(e,r);return this._context.structs.set(e,n),n}_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"),r=null;if(this._match(s.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}let n=null;if(this._match(s.tokens.equal)){let i=this._short_circuit_or_expression();if(i instanceof J)n=i;else if(i instanceof Fe&&i.initializer instanceof J)n=i.initializer;else try{let a=i.evaluate(this._context);n=new Ie(a)}catch{n=i}}let o=new ke(e.toString(),r,"","",n);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(s.keywords.let))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),r=null;if(this._match(s.tokens.colon)){let o=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=o)}let n=null;return this._match(s.tokens.equal)&&(n=this._const_expression()),new Se(e.toString(),r,"","",n)}_const_expression(){if(this._match(s.const_literal))return new Me(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(s.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new J(e,r)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",r="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(r=this._consume(s.access_mode,"Expected access_mode.").toString()),this._consume(s.tokens.greater_than,"Expected '>'."));let n=this._consume(s.tokens.ident,"Expected variable name"),o=null;if(this._match(s.tokens.colon)){let i=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=i)}return new j(n.toString(),o,e,r,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),r=null;if(this._match(s.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}return new Le(e.toString(),r,null)}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new xt(e.toString())}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let n=new Ne(e.toString(),r);return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([s.tokens.ident,...s.texel_format,s.keywords.bool,s.keywords.f32,s.keywords.i32,s.keywords.u32])){let n=this._advance(),o=n.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new G(n.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(s.template_types)){let n=this._advance().toString(),o=null,i=null;return this._match(s.tokens.less_than)&&(o=this._type_decl(),i=null,this._match(s.tokens.comma)&&(i=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for type.")),new Ee(n,o,i)}if(this._match(s.keywords.ptr)){let n=this._previous().toString();this._consume(s.tokens.less_than,"Expected '<' for pointer.");let o=this._consume(s.storage_class,"Expected storage_class for pointer");this._consume(s.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),a=null;return this._match(s.tokens.comma)&&(a=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for pointer."),new yt(n,o.toString(),i,a)}let r=this._attribute();if(this._match(s.keywords.array)){let n=null,o=-1,i=this._previous();if(this._match(s.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let a="";this._match(s.tokens.comma)&&(a=this._shift_expression().evaluate(this._context).toString()),this._consume(s.tokens.greater_than,"Expected '>' for array."),o=a?parseInt(a):0}return new Te(i.toString(),r,n,o)}return null}_texture_sampler_types(){if(this._match(s.sampler_type))return new Z(this._previous().toString(),null,null);if(this._match(s.depth_texture_type))return new Z(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 r=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new Z(e.toString(),r,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(s.texel_format,"Invalid texel format.").toString();this._consume(s.tokens.comma,"Expected ',' after texel format.");let n=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 Z(e.toString(),r,n)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let r=this._consume(s.attribute_name,"Expected attribute name"),n=new Ue(r.toString(),null);if(this._match(s.tokens.paren_left)){if(n.value=this._consume(s.literal_or_ident,"Expected attribute value").toString(),this._check(s.tokens.comma)){this._advance();do{let o=this._consume(s.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(o)}while(this._match(s.tokens.comma))}this._consume(s.tokens.paren_right,"Expected ')'")}e.push(n)}for(;this._match(s.tokens.attr_left);){if(!this._check(s.tokens.attr_right))do{let r=this._consume(s.attribute_name,"Expected attribute name"),n=new Ue(r.toString(),null);if(this._match(s.tokens.paren_left)){if(n.value=[this._consume(s.literal_or_ident,"Expected attribute value").toString()],this._check(s.tokens.comma)){this._advance();do{let o=this._consume(s.literal_or_ident,"Expected attribute value").toString();n.value.push(o)}while(this._match(s.tokens.comma))}this._consume(s.tokens.paren_right,"Expected ')'")}e.push(n)}while(this._match(s.tokens.comma));this._consume(s.tokens.attr_right,"Expected ']]' after attribute declarations")}return e.length==0?null:e}},$=class{constructor(e,r){this.name=e,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},De=class{constructor(e,r,n){this.name=e,this.type=r,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},oe=class extends ${constructor(e,r){super(e,r),this.members=[],this.align=0}get isStruct(){return!0}},de=class extends ${constructor(e,r){super(e,r),this.count=0,this.stride=0}get isArray(){return!0}},Ye=class extends ${constructor(e,r,n,o){super(e,n),this.format=r,this.access=o}get isTemplate(){return!0}},W;(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"})(W||(W={}));var ie=class{constructor(e,r,n,o,i,a,f){this.name=e,this.type=r,this.group=n,this.binding=o,this.attributes=i,this.resourceType=a,this.access=f}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}},Rt=class{constructor(e,r){this.name=e,this.type=r}},se=class{constructor(e,r){this.align=e,this.size=r}},Ot=class{constructor(e,r,n,o){this.name=e,this.type=r,this.locationType=n,this.location=o,this.interpolation=null}},Xe=class{constructor(e,r,n,o){this.name=e,this.type=r,this.locationType=n,this.location=o}},Ut=class{constructor(e,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.name=e,this.stage=r}},zt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Dt=class{constructor(e,r,n,o){this.name=e,this.type=r,this.attributes=n,this.id=o}},Y=class{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new zt,this._types=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 n=new Ct().parse(e);for(let o of n){if(o instanceof V){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i);continue}if(o instanceof Ne){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof Le){let i=o,a=this._getAttributeNum(i.attributes,"id",0),f=i.type!=null?this._getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Dt(i.name,f,i.attributes,a));continue}if(this._isUniformVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),f=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,f,i.attributes,W.Uniform,i.access);this.uniforms.push(h);continue}if(this._isStorageVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),f=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,f,i.attributes,h?W.StorageTexture:W.Storage,i.access);this.storage.push(p);continue}if(this._isTextureVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),f=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,f,i.attributes,h?W.StorageTexture:W.Texture,i.access);h?this.storage.push(p):this.textures.push(p);continue}if(this._isSamplerVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),f=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,f,i.attributes,W.Sampler,i.access);this.samplers.push(h);continue}if(o instanceof we){let i=this._getAttribute(o,"vertex"),a=this._getAttribute(o,"fragment"),f=this._getAttribute(o,"compute"),u=i||a||f;if(u){let h=new Ut(o.name,u.name);h.inputs=this._getInputs(o.args),h.outputs=this._getOutputs(o.returnType),this.entry[u.name].push(h)}continue}}}getBindGroups(){let e=[];function r(n,o){n>=e.length&&(e.length=n+1),e[n]===void 0&&(e[n]=[]),o>=e[n].length&&(e[n].length=o+1)}for(let n of this.uniforms){r(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.storage){r(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.textures){r(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.samplers){r(n.group,n.binding);let o=e[n.group];o[n.binding]=n}return e}_getOutputs(e,r=void 0){if(r===void 0&&(r=[]),e instanceof V)this._getStructOutputs(e,r);else{let n=this._getOutputInfo(e);n!==null&&r.push(n)}return r}_getStructOutputs(e,r){for(let n of e.members)if(n.type instanceof V)this._getStructOutputs(n.type,r);else{let o=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(o!==null){let i=this._getTypeInfo(n.type,n.type.attributes),a=this._parseInt(o.value),f=new Xe(n.name,i,o.name,a);r.push(f)}}}_getOutputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let n=this._getTypeInfo(e,e.attributes),o=this._parseInt(r.value);return new Xe("",n,r.name,o)}return null}_getInputs(e,r=void 0){r===void 0&&(r=[]);for(let n of e)if(n.type instanceof V)this._getStructInputs(n.type,r);else{let o=this._getInputInfo(n);o!==null&&r.push(o)}return r}_getStructInputs(e,r){for(let n of e.members)if(n.type instanceof V)this._getStructInputs(n.type,r);else{let o=this._getInputInfo(n);o!==null&&r.push(o)}}_getInputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let n=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),i=this._parseInt(r.value),a=new Ot(e.name,o,r.name,i);return n!==null&&(a.interpolation=this._parseString(n.value)),a}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let r=parseInt(e);return isNaN(r)?e:r}_getAlias(e){for(let r of this.aliases)if(r.name==e)return r.type;return null}_getAliasInfo(e){return new Rt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,r){if(this._types.has(e))return this._types.get(e);if(e instanceof Te){let o=e,i=this._getTypeInfo(o.format,o.attributes),a=new de(o.name,r);return a.format=i,a.count=o.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof V){let o=e,i=new oe(o.name,r);for(let a of o.members){let f=this._getTypeInfo(a.type,a.attributes);i.members.push(new De(a.name,f,a.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof Z){let o=e,i=o.format instanceof G,a=o.format?i?this._getTypeInfo(o.format,null):new $(o.format,null):null,f=new Ye(o.name,a,r,o.access);return this._types.set(e,f),this._updateTypeInfo(f),f}if(e instanceof Ee){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new Ye(o.name,i,r,o.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let n=new $(e.name,r);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var r,n;let o=this._getTypeSize(e);if(e.size=(r=o?.size)!==null&&r!==void 0?r:0,e instanceof de){let i=this._getTypeSize(e.format);e.stride=(n=i?.size)!==null&&n!==void 0?n:0,this._updateTypeInfo(e.format)}e instanceof oe&&this._updateStructInfo(e)}_updateStructInfo(e){var r;let n=0,o=0,i=0,a=0;for(let f=0,u=e.members.length;f<u;++f){let h=e.members[f],p=this._getTypeSize(h);if(!p)continue;(r=this._getAlias(h.type.name))!==null&&r!==void 0||h.type;let d=p.align,m=p.size;n=this._roundUp(d,n+o),o=m,i=n,a=Math.max(a,d),h.offset=n,h.size=m,this._updateTypeInfo(h.type)}e.size=this._roundUp(a,i+o),e.align=a}_getTypeSize(e){var r;if(e==null)return null;let n=this._getAttributeNum(e.attributes,"size",0),o=this._getAttributeNum(e.attributes,"align",0);if(e instanceof De&&(e=e.type),e instanceof $){let i=this._getAlias(e.name);i!==null&&(e=i)}{let i=Y._typeInfo[e.name];if(i!==void 0){let a=e.format==="f16"?2:1;return new se(Math.max(o,i.align/a),Math.max(n,i.size/a))}}{let i=Y._typeInfo[e.name.substring(0,e.name.length-1)];if(i){let a=e.name[e.name.length-1]==="h"?2:1;return new se(Math.max(o,i.align/a),Math.max(n,i.size/a))}}if(e instanceof de){let i=e,a=8,f=8,u=this._getTypeSize(i.format);u!==null&&(f=u.size,a=u.align);let h=i.count,p=this._getAttributeNum((r=e?.attributes)!==null&&r!==void 0?r:null,"stride",this._roundUp(a,f));return f=h*p,n&&(f=n),new se(Math.max(o,a),Math.max(n,f))}if(e instanceof oe){let i=0,a=0,f=0,u=0,h=0;for(let p of e.members){let d=this._getTypeSize(p.type);d!==null&&(i=Math.max(d.align,i),f=this._roundUp(d.align,f+u),u=d.size,h=f)}return a=this._roundUp(i,h+u),new se(Math.max(o,i),Math.max(n,a))}return null}_isUniformVar(e){return e instanceof j&&e.storage=="uniform"}_isStorageVar(e){return e instanceof j&&e.storage=="storage"}_isTextureVar(e){return e instanceof j&&e.type!==null&&Y._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof j&&e.type!==null&&Y._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,r){let n=e;if(!n||!n.attributes)return null;let o=n.attributes;for(let i of o)if(i.name==r)return i;return null}_getAttributeNum(e,r,n){if(e===null)return n;for(let o of e)if(o.name==r){let i=o!==null&&o.value!==null?o.value:n;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):n}return n}_roundUp(e,r){return Math.ceil(r/e)*e}};Y._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}};Y._textureTypes=s.any_texture_type.map(t=>t.name);Y._samplerTypes=s.sampler_type.map(t=>t.name);function Or(t){let e={attributes:[],bindings:[]},r;try{r=Po(t)}catch(i){return Rr.log.error(i.message)(),e}for(let i of r.uniforms){let a=[];for(let f of i.type.members)a.push({name:f.name,type:Cr(f.type)});e.bindings.push({type:"uniform",name:i.name,location:i.binding,group:i.group,members:a})}let n=r.entry.vertex[0],o=n?.inputs.length||0;for(let i=0;i<o;i++){let a=n.inputs[i];if(a.locationType==="location"){let f=Cr(a.type);e.attributes.push({name:a.name,location:a.location,type:f})}}return e}function Cr(t){return t.format?`${t.name}<${t.format.name}>`:t.name}function Po(t){try{return new Y(t)}catch(e){if(e instanceof Error)throw e;let r="WGSL parse error";throw typeof e=="object"&&e?.message&&(r+=`: ${e.message} `),typeof e=="object"&&e?.token&&(r+=e.token.line||""),new Error(r,{cause:e})}}var wo=`float random(vec3 scale, float seed) {
|
|
89
|
+
`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let a=1;for(;a>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
|
|
90
|
+
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),a--,a==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),a++)}return!0}}let t=s.simpleTokens[e];if(t)return this._addToken(t),!0;let n=s.none,o=this._isAlpha(e),i=e==="_";if(this._isAlphaNumeric(e)){let a=this._peekAhead();for(;this._isAlphaNumeric(a);)e+=this._advance(),a=this._peekAhead()}if(o){let a=s.keywords[e];if(a)return this._addToken(a),!0}if(o||i)return this._addToken(s.tokens.ident),!0;for(;;){let a=this._findType(e),c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let u=!1,h=this._tokens.length-1;for(let p=0;p<5&&h>=0;++p,--h)if(this._tokens[h].type===s.tokens.less_than){h>0&&this._tokens[h-1].isArrayOrTemplateType()&&(u=!0);break}if(u)return this._addToken(a),!0}if(a===s.none){let u=e,h=0,p=2;for(let d=0;d<p;++d)if(u+=this._peekAhead(d),a=this._findType(u),a!==s.none){h=d;break}if(a===s.none)return n===s.none?!1:(this._current--,this._addToken(n),!0);e=u,this._current+=h+1}if(n=a,this._isAtEnd())break;e+=this._advance()}return n===s.none?!1:(this._addToken(n),!0)}_findType(e){for(let n in s.regexTokens){let o=s.regexTokens[n];if(this._match(e,o.rule))return o}let t=s.literalTokens[e];return t||s.none}_match(e,t){let n=t.exec(e);return n&&n.index==0&&n[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new Be(e,t,this._line))}},Dt=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new ft,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let n=this._global_decl_or_directive();if(!n)break;t.push(n)}if(this._deferArrayCountEval.length>0){for(let n of this._deferArrayCountEval){let o=n.arrayType,i=n.countNode;if(i instanceof ye){let c=i.name,u=this._context.constants.get(c);if(u)try{let h=u.evaluate(this._context);o.count=h}catch{}}}this._deferArrayCountEval.length=0}return t}_initialize(e){if(e)if(typeof e=="string"){let t=new zt(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,t){return{token:e,message:t,toString:function(){return`${t}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==s.eof}_match(e){if(e instanceof l)return this._check(e)?(this._advance(),!0):!1;for(let t=0,n=e.length;t<n;++t){let o=e[t];if(this._check(o))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),t)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let n=t.type;return e.indexOf(n)!=-1}return t.type==e}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._match(s.keywords.alias)){let t=this._type_alias();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.diagnostic)){let t=this._diagnostic();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.requires)){let t=this._requires_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}if(this._match(s.keywords.enable)){let t=this._enable_directive();return this._consume(s.tokens.semicolon,"Expected ';'"),t}let e=this._attribute();if(this._check(s.keywords.var)){let t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.override)){let t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.let)){let t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.const)){let t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(s.tokens.semicolon,"Expected ';'."),t}if(this._check(s.keywords.struct)){let t=this._struct_decl();return t!=null&&(t.attributes=e),t}if(this._check(s.keywords.fn)){let t=this._function_decl();return t!=null&&(t.attributes=e),t}return null}_function_decl(){if(!this._match(s.keywords.fn))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected function name.").toString();this._consume(s.tokens.paren_left,"Expected '(' for function arguments.");let n=[];if(!this._check(s.tokens.paren_right))do{if(this._check(s.tokens.paren_right))break;let c=this._attribute(),u=this._consume(s.tokens.ident,"Expected argument name.").toString();this._consume(s.tokens.colon,"Expected ':' for argument type.");let h=this._attribute(),p=this._type_decl();p!=null&&(p.attributes=h,n.push(new Ct(u,p,c)))}while(this._match(s.tokens.comma));this._consume(s.tokens.paren_right,"Expected ')' after function arguments.");let o=null;if(this._match(s.tokens.arrow)){let c=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=c)}let i=this._compound_statement(),a=this._currentLine;return new xe(t,n,o,i,e,a)}_compound_statement(){let e=[];for(this._consume(s.tokens.brace_left,"Expected '{' for block.");!this._check(s.tokens.brace_right);){let t=this._statement();t!==null&&e.push(t)}return this._consume(s.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(s.tokens.semicolon)&&!this._isAtEnd(););if(this._check(s.tokens.attr)&&this._attribute(),this._check(s.keywords.if))return this._if_statement();if(this._check(s.keywords.switch))return this._switch_statement();if(this._check(s.keywords.loop))return this._loop_statement();if(this._check(s.keywords.for))return this._for_statement();if(this._check(s.keywords.while))return this._while_statement();if(this._check(s.keywords.continuing))return this._continuing_statement();if(this._check(s.keywords.static_assert))return this._static_assert_statement();if(this._check(s.tokens.brace_left))return this._compound_statement();let e=null;return this._check(s.keywords.return)?e=this._return_statement():this._check([s.keywords.var,s.keywords.let,s.keywords.const])?e=this._variable_statement():this._match(s.keywords.discard)?e=new wt:this._match(s.keywords.break)?e=new Lt:this._match(s.keywords.continue)?e=new kt: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 ut(e)}_while_statement(){if(!this._match(s.keywords.while))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement();return new _t(e,t)}_continuing_statement(){if(!this._match(s.keywords.continuing))return null;let e=this._compound_statement();return new ht(e)}_for_statement(){if(!this._match(s.keywords.for))return null;this._consume(s.tokens.paren_left,"Expected '('.");let e=this._check(s.tokens.semicolon)?null:this._for_init();this._consume(s.tokens.semicolon,"Expected ';'.");let t=this._check(s.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(s.tokens.semicolon,"Expected ';'.");let n=this._check(s.tokens.paren_right)?null:this._for_increment();this._consume(s.tokens.paren_right,"Expected ')'."),this._check(s.tokens.attr)&&this._attribute();let o=this._compound_statement();return new pt(e,t,n,o)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(s.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(s.tokens.equal)&&(t=this._short_circuit_or_expression()),new G(e.name,e.type,e.storage,e.access,t)}if(this._match(s.keywords.let)){let e=this._consume(s.tokens.ident,"Expected name for let.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for let.");let n=this._short_circuit_or_expression();return new ve(e,t,null,null,n)}if(this._match(s.keywords.const)){let e=this._consume(s.tokens.ident,"Expected name for const.").toString(),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}this._consume(s.tokens.equal,"Expected '=' for const.");let n=this._short_circuit_or_expression();return new Ee(e,t,null,null,n)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(s.increment_operators))return this._current=e,null;let n=this._consume(s.increment_operators,"Expected increment operator");return new dt(n.type===s.tokens.plus_plus?le.increment:le.decrement,t)}_assignment_statement(){let e=null;if(this._check(s.tokens.brace_right))return null;let t=this._match(s.tokens.underscore);if(t||(e=this._unary_expression()),!t&&e==null)return null;let n=this._consume(s.assignment_operators,"Expected assignment operator."),o=this._short_circuit_or_expression();return new mt(Ae.parse(n.lexeme),e,o)}_func_call_statement(){if(!this._check(s.tokens.ident))return null;let e=this._current,t=this._consume(s.tokens.ident,"Expected function name."),n=this._argument_expression_list();return n===null?(this._current=e,null):new Me(t.lexeme,n)}_loop_statement(){if(!this._match(s.keywords.loop))return null;this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for loop.");let e=[],t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let o of t)e.push(o);else e.push(t);t=this._statement()}let n=null;return this._match(s.keywords.continuing)&&(n=this._compound_statement()),this._consume(s.tokens.brace_right,"Expected '}' for loop."),new gt(e,n)}_switch_statement(){if(!this._match(s.keywords.switch))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Expected '{' for switch.");let t=this._switch_body();if(t==null||t.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(s.tokens.brace_right,"Expected '}' for switch."),new xt(e,t)}_switch_body(){let e=[];if(this._match(s.keywords.case)){let t=this._case_selectors();this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch case.");let n=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch case."),e.push(new Ft(t,n))}if(this._match(s.keywords.default)){this._match(s.tokens.colon),this._check(s.tokens.attr)&&this._attribute(),this._consume(s.tokens.brace_left,"Exected '{' for switch default.");let t=this._case_body();this._consume(s.tokens.brace_right,"Exected '}' for switch default."),e.push(new It(t))}if(this._check([s.keywords.default,s.keywords.case])){let t=this._switch_body();e.push(t[0])}return e}_case_selectors(){let e=[this._shift_expression()];for(;this._match(s.tokens.comma);)e.push(this._shift_expression());return e}_case_body(){if(this._match(s.keywords.fallthrough))return this._consume(s.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);let t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(s.keywords.if))return null;let e=this._optional_paren_expression();this._check(s.tokens.attr)&&this._attribute();let t=this._compound_statement(),n=[];this._match_elseif()&&(this._check(s.tokens.attr)&&this._attribute(),n=this._elseif_statement(n));let o=null;return this._match(s.keywords.else)&&(this._check(s.tokens.attr)&&this._attribute(),o=this._compound_statement()),new vt(e,t,n,o)}_match_elseif(){return this._tokens[this._current].type===s.keywords.else&&this._tokens[this._current+1].type===s.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(e=[]){let t=this._optional_paren_expression(),n=this._compound_statement();return e.push(new Rt(t,n)),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 At(e)}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(s.tokens.or_or);)e=new Y(this._previous().toString(),e,this._short_circuit_and_expr());return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(s.tokens.and_and);)e=new Y(this._previous().toString(),e,this._inclusive_or_expression());return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(s.tokens.or);)e=new Y(this._previous().toString(),e,this._exclusive_or_expression());return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(s.tokens.xor);)e=new Y(this._previous().toString(),e,this._and_expression());return e}_and_expression(){let e=this._equality_expression();for(;this._match(s.tokens.and);)e=new Y(this._previous().toString(),e,this._equality_expression());return e}_equality_expression(){let e=this._relational_expression();return this._match([s.tokens.equal_equal,s.tokens.not_equal])?new Y(this._previous().toString(),e,this._relational_expression()):e}_relational_expression(){let e=this._shift_expression();for(;this._match([s.tokens.less_than,s.tokens.greater_than,s.tokens.less_than_equal,s.tokens.greater_than_equal]);)e=new Y(this._previous().toString(),e,this._shift_expression());return e}_shift_expression(){let e=this._additive_expression();for(;this._match([s.tokens.shift_left,s.tokens.shift_right]);)e=new Y(this._previous().toString(),e,this._additive_expression());return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([s.tokens.plus,s.tokens.minus]);)e=new Y(this._previous().toString(),e,this._multiplicative_expression());return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([s.tokens.star,s.tokens.forward_slash,s.tokens.modulo]);)e=new Y(this._previous().toString(),e,this._unary_expression());return e}_unary_expression(){return this._match([s.tokens.minus,s.tokens.bang,s.tokens.tilde,s.tokens.star,s.tokens.and])?new Mt(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(s.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(s.tokens.bracket_right,"Expected ']'.");let t=new Et(e),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(s.tokens.period)){let e=this._consume(s.tokens.ident,"Expected member name."),t=this._postfix_expression(),n=new Re(e.lexeme);return t&&(n.postfix=t),n}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 n=this._previous().toString();if(this._check(s.tokens.paren_left)){let o=this._argument_expression_list(),i=this._getStruct(n);return i!=null?new $(i,o):new Oe(n,o)}if(this._context.constants.has(n)){let o=this._context.constants.get(n);return new Ue(n,o.value)}return new ye(n)}if(this._match(s.const_literal))return new ze(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 n=this._type_decl();this._consume(s.tokens.greater_than,"Expected '>'.");let o=this._paren_expression();return new Nt(n,o)}let e=this._type_decl(),t=this._argument_expression_list();return new Tt(e,t)}_argument_expression_list(){if(!this._match(s.tokens.paren_left))return null;let e=[];do{if(this._check(s.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(s.tokens.comma));return this._consume(s.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(s.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(s.tokens.paren_right),new De([e])}_paren_expression(){this._consume(s.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(s.tokens.paren_right,"Expected ')'."),new De([e])}_struct_decl(){if(!this._match(s.keywords.struct))return null;let e=this._currentLine,t=this._consume(s.tokens.ident,"Expected name for struct.").toString();this._consume(s.tokens.brace_left,"Expected '{' for struct body.");let n=[];for(;!this._check(s.tokens.brace_right);){let a=this._attribute(),c=this._consume(s.tokens.ident,"Expected variable name.").toString();this._consume(s.tokens.colon,"Expected ':' for struct member type.");let u=this._attribute(),h=this._type_decl();h!=null&&(h.attributes=u),this._check(s.tokens.brace_right)?this._match(s.tokens.comma):this._consume(s.tokens.comma,"Expected ',' for struct member."),n.push(new Ot(c,h,a))}this._consume(s.tokens.brace_right,"Expected '}' after struct body.");let o=this._currentLine,i=new V(t,n,e,o);return this._context.structs.set(t,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(s.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(s.keywords.const))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}let n=null;if(this._match(s.tokens.equal)){let i=this._short_circuit_or_expression();if(i instanceof $)n=i;else if(i instanceof Ue&&i.initializer instanceof $)n=i.initializer;else try{let a=i.evaluate(this._context);n=new ze(a)}catch{n=i}}let o=new Ee(e.toString(),t,"","",n);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(s.keywords.let))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let o=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=o)}let n=null;return this._match(s.tokens.equal)&&(n=this._const_expression()),new ve(e.toString(),t,"","",n)}_const_expression(){if(this._match(s.const_literal))return new Re(this._previous().toString());let e=this._type_decl();this._consume(s.tokens.paren_left,"Expected '('.");let t=[];for(;!this._check(s.tokens.paren_right)&&(t.push(this._const_expression()),!!this._check(s.tokens.comma));)this._advance();return this._consume(s.tokens.paren_right,"Expected ')'."),new $(e,t)}_variable_decl(){if(!this._match(s.keywords.var))return null;let e="",t="";this._match(s.tokens.less_than)&&(e=this._consume(s.storage_class,"Expected storage_class.").toString(),this._match(s.tokens.comma)&&(t=this._consume(s.access_mode,"Expected access_mode.").toString()),this._consume(s.tokens.greater_than,"Expected '>'."));let n=this._consume(s.tokens.ident,"Expected variable name"),o=null;if(this._match(s.tokens.colon)){let i=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=i)}return new G(n.toString(),o,e,t,null)}_override_decl(){if(!this._match(s.keywords.override))return null;let e=this._consume(s.tokens.ident,"Expected variable name"),t=null;if(this._match(s.tokens.colon)){let n=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=n)}return new Te(e.toString(),t,null)}_diagnostic(){this._consume(s.tokens.paren_left,"Expected '('");let e=this._consume(s.tokens.ident,"Expected severity control name.");this._consume(s.tokens.comma,"Expected ','");let t=this._consume(s.tokens.ident,"Expected diagnostic rule name.");return this._consume(s.tokens.paren_right,"Expected ')'"),new Pt(e.toString(),t.toString())}_enable_directive(){let e=this._consume(s.tokens.ident,"identity expected.");return new yt(e.toString())}_requires_directive(){let e=[this._consume(s.tokens.ident,"identity expected.").toString()];for(;this._match(s.tokens.comma);){let t=this._consume(s.tokens.ident,"identity expected.");e.push(t.toString())}return new bt(e)}_type_alias(){let e=this._consume(s.tokens.ident,"identity expected.");this._consume(s.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let n=new Fe(e.toString(),t);return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([s.tokens.ident,...s.texel_format,s.keywords.bool,s.keywords.f32,s.keywords.i32,s.keywords.u32])){let n=this._advance(),o=n.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new H(n.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(s.template_types)){let n=this._advance().toString(),o=null,i=null;return this._match(s.tokens.less_than)&&(o=this._type_decl(),i=null,this._match(s.tokens.comma)&&(i=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for type.")),new Ie(n,o,i)}if(this._match(s.keywords.ptr)){let n=this._previous().toString();this._consume(s.tokens.less_than,"Expected '<' for pointer.");let o=this._consume(s.storage_class,"Expected storage_class for pointer");this._consume(s.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),a=null;return this._match(s.tokens.comma)&&(a=this._consume(s.access_mode,"Expected access_mode for pointer").toString()),this._consume(s.tokens.greater_than,"Expected '>' for pointer."),new St(n,o.toString(),i,a)}let t=this._attribute();if(this._match(s.keywords.array)){let n=null,o=-1,i=this._previous(),a=null;if(this._match(s.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let u="";if(this._match(s.tokens.comma)){a=this._shift_expression();try{u=a.evaluate(this._context).toString(),a=null}catch{u="1"}}this._consume(s.tokens.greater_than,"Expected '>' for array."),o=u?parseInt(u):0}let c=new Ce(i.toString(),t,n,o);return a&&this._deferArrayCountEval.push({arrayType:c,countNode:a}),c}return null}_texture_sampler_types(){if(this._match(s.sampler_type))return new J(this._previous().toString(),null,null);if(this._match(s.depth_texture_type))return new J(this._previous().toString(),null,null);if(this._match(s.sampled_texture_type)||this._match(s.multisampled_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,null)}if(this._match(s.storage_texture_type)){let e=this._previous();this._consume(s.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(s.texel_format,"Invalid texel format.").toString();this._consume(s.tokens.comma,"Expected ',' after texel format.");let n=this._consume(s.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(s.tokens.greater_than,"Expected '>' for sampler type."),new J(e.toString(),t,n)}return null}_attribute(){let e=[];for(;this._match(s.tokens.attr);){let t=this._consume(s.attribute_name,"Expected attribute name"),n=new Ut(t.toString(),null);if(this._match(s.tokens.paren_left)){if(n.value=this._consume(s.literal_or_ident,"Expected attribute value").toString(),this._check(s.tokens.comma)){this._advance();do{let o=this._consume(s.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(o)}while(this._match(s.tokens.comma))}this._consume(s.tokens.paren_right,"Expected ')'")}e.push(n)}return e.length==0?null:e}},K=class{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Qe=class{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},oe=class extends K{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},ge=class extends K{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}},qe=class extends K{constructor(e,t,n,o){super(e,n),this.format=t,this.access=o}get isTemplate(){return!0}},j;(function(r){r[r.Uniform=0]="Uniform",r[r.Storage=1]="Storage",r[r.Texture=2]="Texture",r[r.Sampler=3]="Sampler",r[r.StorageTexture=4]="StorageTexture"})(j||(j={}));var ie=class{constructor(e,t,n,o,i,a,c){this.name=e,this.type=t,this.group=n,this.binding=o,this.attributes=i,this.resourceType=a,this.access=c}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Yt=class{constructor(e,t){this.name=e,this.type=t}},se=class{constructor(e,t){this.align=e,this.size=t}},Xt=class{constructor(e,t,n,o){this.name=e,this.type=t,this.locationType=n,this.location=o,this.interpolation=null}},Ve=class{constructor(e,t,n,o){this.name=e,this.type=t,this.locationType=n,this.location=o}},Bt=class{constructor(e,t=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t}},Qt=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},qt=class{constructor(e,t,n,o){this.name=e,this.type=t,this.attributes=n,this.id=o}},Vt=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},X=class{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Qt,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 n=new Dt().parse(e);for(let o of n)o instanceof xe&&this._functions.set(o.name,new Vt(o));for(let o of n)if(o instanceof V){let i=this._getTypeInfo(o,null);i instanceof oe&&this.structs.push(i)}for(let o of n){if(o instanceof Fe){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof Te){let i=o,a=this._getAttributeNum(i.attributes,"id",0),c=i.type!=null?this._getTypeInfo(i.type,i.attributes):null;this.overrides.push(new qt(i.name,c,i.attributes,a));continue}if(this._isUniformVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Uniform,i.access);this.uniforms.push(h);continue}if(this._isStorageVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Storage,i.access);this.storage.push(p);continue}if(this._isTextureVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=this._isStorageTexture(u),p=new ie(i.name,u,a,c,i.attributes,h?j.StorageTexture:j.Texture,i.access);h?this.storage.push(p):this.textures.push(p);continue}if(this._isSamplerVar(o)){let i=o,a=this._getAttributeNum(i.attributes,"group",0),c=this._getAttributeNum(i.attributes,"binding",0),u=this._getTypeInfo(i.type,i.attributes),h=new ie(i.name,u,a,c,i.attributes,j.Sampler,i.access);this.samplers.push(h);continue}if(o instanceof xe){let i=this._getAttribute(o,"vertex"),a=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),u=i||a||c,h=new Bt(o.name,u?.name);h.startLine=o.startLine,h.endLine=o.endLine,this.functions.push(h),this._functions.get(o.name).info=h,u&&(this._functions.get(o.name).inUse=!0,h.inUse=!0,h.resources=this._findResources(o,!!u),h.inputs=this._getInputs(o.args),h.outputs=this._getOutputs(o.returnType),this.entry[u.name].push(h));continue}}for(let o of this._functions.values())o.info&&(o.info.inUse=o.inUse,this._addCalls(o.node,o.info.calls));for(let o of this.uniforms)this._markStructsInUse(o.type);for(let o of this.storage)this._markStructsInUse(o.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var n;for(let o of e.calls){let i=(n=this._functions.get(o.name))===null||n===void 0?void 0:n.info;i&&t.add(i)}}findResource(e,t){for(let n of this.uniforms)if(n.group==e&&n.binding==t)return n;for(let n of this.storage)if(n.group==e&&n.binding==t)return n;for(let n of this.textures)if(n.group==e&&n.binding==t)return n;for(let n of this.samplers)if(n.group==e&&n.binding==t)return n;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this._getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let n=[],o=this,i=[];return e.search(a=>{if(a instanceof ae)i.push({});else if(a instanceof ce)i.pop();else if(a instanceof G){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof $){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type)}else if(a instanceof ve){let c=a;t&&c.type!==null&&this._markStructsFromAST(c.type),i.length>0&&(i[i.length-1][c.name]=c)}else if(a instanceof ye){let c=a;if(i.length>0&&i[i.length-1][c.name])return;let u=o._findResource(c.name);u&&n.push(u)}else if(a instanceof Oe){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),n.push(...u.resources))}else if(a instanceof Me){let c=a,u=o._functions.get(c.name);u&&(t&&(u.inUse=!0),e.calls.add(u.node),u.resources===null&&(u.resources=o._findResources(u.node,t)),n.push(...u.resources))}}),[...new Map(n.map(a=>[a.name,a])).values()]}getBindGroups(){let e=[];function t(n,o){n>=e.length&&(e.length=n+1),e[n]===void 0&&(e[n]=[]),o>=e[n].length&&(e[n].length=o+1)}for(let n of this.uniforms){t(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.storage){t(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.textures){t(n.group,n.binding);let o=e[n.group];o[n.binding]=n}for(let n of this.samplers){t(n.group,n.binding);let o=e[n.group];o[n.binding]=n}return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof V)this._getStructOutputs(e,t);else{let n=this._getOutputInfo(e);n!==null&&t.push(n)}return t}_getStructOutputs(e,t){for(let n of e.members)if(n.type instanceof V)this._getStructOutputs(n.type,t);else{let o=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(o!==null){let i=this._getTypeInfo(n.type,n.type.attributes),a=this._parseInt(o.value),c=new Ve(n.name,i,o.name,a);t.push(c)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this._getTypeInfo(e,e.attributes),o=this._parseInt(t.value);return new Ve("",n,t.name,o)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(let n of e)if(n.type instanceof V)this._getStructInputs(n.type,t);else{let o=this._getInputInfo(n);o!==null&&t.push(o)}return t}_getStructInputs(e,t){for(let n of e.members)if(n.type instanceof V)this._getStructInputs(n.type,t);else{let o=this._getInputInfo(n);o!==null&&t.push(o)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),a=new Xt(e.name,o,t.name,i);return n!==null&&(a.interpolation=this._parseString(n.value)),a}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Yt(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,t){if(this._types.has(e))return this._types.get(e);if(e instanceof Ce){let o=e,i=this._getTypeInfo(o.format,o.attributes),a=new ge(o.name,t);return a.format=i,a.count=o.count,this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof V){let o=e,i=new oe(o.name,t);i.startLine=o.startLine,i.endLine=o.endLine;for(let a of o.members){let c=this._getTypeInfo(a.type,a.attributes);i.members.push(new Qe(a.name,c,a.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof J){let o=e,i=o.format instanceof H,a=o.format?i?this._getTypeInfo(o.format,null):new K(o.format,null):null,c=new qe(o.name,a,t,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof Ie){let o=e,i=o.format?this._getTypeInfo(o.format,null):null,a=new qe(o.name,i,t,o.access);return this._types.set(e,a),this._updateTypeInfo(a),a}let n=new K(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n;let o=this._getTypeSize(e);if(e.size=(t=o?.size)!==null&&t!==void 0?t:0,e instanceof ge){let i=this._getTypeSize(e.format);e.stride=(n=i?.size)!==null&&n!==void 0?n:0,this._updateTypeInfo(e.format)}e instanceof oe&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,o=0,i=0,a=0;for(let c=0,u=e.members.length;c<u;++c){let h=e.members[c],p=this._getTypeSize(h);if(!p)continue;(t=this._getAlias(h.type.name))!==null&&t!==void 0||h.type;let d=p.align,m=p.size;n=this._roundUp(d,n+o),o=m,i=n,a=Math.max(a,d),h.offset=n,h.size=m,this._updateTypeInfo(h.type)}e.size=this._roundUp(a,i+o),e.align=a}_getTypeSize(e){var t;if(e==null)return null;let n=this._getAttributeNum(e.attributes,"size",0),o=this._getAttributeNum(e.attributes,"align",0);if(e instanceof Qe&&(e=e.type),e instanceof K){let i=this._getAlias(e.name);i!==null&&(e=i)}{let i=X._typeInfo[e.name];if(i!==void 0){let a=e.format==="f16"?2:1;return new se(Math.max(o,i.align/a),Math.max(n,i.size/a))}}{let i=X._typeInfo[e.name.substring(0,e.name.length-1)];if(i){let a=e.name[e.name.length-1]==="h"?2:1;return new se(Math.max(o,i.align/a),Math.max(n,i.size/a))}}if(e instanceof ge){let i=e,a=8,c=8,u=this._getTypeSize(i.format);u!==null&&(c=u.size,a=u.align);let h=i.count,p=this._getAttributeNum((t=e?.attributes)!==null&&t!==void 0?t:null,"stride",this._roundUp(a,c));return c=h*p,n&&(c=n),new se(Math.max(o,a),Math.max(n,c))}if(e instanceof oe){let i=0,a=0,c=0,u=0,h=0;for(let p of e.members){let d=this._getTypeSize(p.type);d!==null&&(i=Math.max(d.align,i),c=this._roundUp(d.align,c+u),u=d.size,h=c)}return a=this._roundUp(i,h+u),new se(Math.max(o,i),Math.max(n,a))}return null}_isUniformVar(e){return e instanceof G&&e.storage=="uniform"}_isStorageVar(e){return e instanceof G&&e.storage=="storage"}_isTextureVar(e){return e instanceof G&&e.type!==null&&X._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof G&&e.type!==null&&X._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){let n=e;if(!n||!n.attributes)return null;let o=n.attributes;for(let i of o)if(i.name==t)return i;return null}_getAttributeNum(e,t,n){if(e===null)return n;for(let o of e)if(o.name==t){let i=o!==null&&o.value!==null?o.value:n;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}};X._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}};X._textureTypes=s.any_texture_type.map(r=>r.name);X._samplerTypes=s.sampler_type.map(r=>r.name);function Br(r){let e={attributes:[],bindings:[]},t;try{t=To(r)}catch(i){return Xr.log.error(i.message)(),e}for(let i of t.uniforms){let a=[];for(let c of i.type?.members||[])a.push({name:c.name,type:Yr(c.type)});e.bindings.push({type:"uniform",name:i.name,location:i.binding,group:i.group,members:a})}let n=t.entry.vertex[0],o=n?.inputs.length||0;for(let i=0;i<o;i++){let a=n.inputs[i];if(a.locationType==="location"){let c=Yr(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Yr(r){return r.format?`${r.name}<${r.format.name}>`:r.name}function To(r){try{return new X(r)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e?.message&&(t+=`: ${e.message} `),typeof e=="object"&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}var Eo=`float random(vec3 scale, float seed) {
|
|
91
91
|
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
|
92
92
|
}
|
|
93
|
-
`,
|
|
93
|
+
`,q={name:"random",fs:Eo};var Mo=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
94
94
|
const float TWO_PI = 6.2831854820251465;
|
|
95
95
|
const float PI_2 = 1.5707963705062866;
|
|
96
96
|
const float PI_16 = 0.1963495463132858;
|
|
@@ -212,7 +212,7 @@ return tan_taylor_fp32(a);
|
|
|
212
212
|
return tan(a);
|
|
213
213
|
#endif
|
|
214
214
|
}
|
|
215
|
-
`,
|
|
215
|
+
`,Qr={name:"fp32",vs:Mo};var Fo=new Float32Array([0,1,1,1]),Io=`uniform pickingUniforms {
|
|
216
216
|
float isActive;
|
|
217
217
|
float isAttribute;
|
|
218
218
|
float isHighlightActive;
|
|
@@ -264,7 +264,7 @@ if (bool(picking.isAttribute)) {
|
|
|
264
264
|
picking_vRGBcolor_Avalid.rgb = value;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
`,
|
|
267
|
+
`,Co=`uniform pickingUniforms {
|
|
268
268
|
float isActive;
|
|
269
269
|
float isAttribute;
|
|
270
270
|
float isHighlightActive;
|
|
@@ -301,7 +301,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
301
301
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
302
302
|
return picking_filterPickingColor(highlightColor);
|
|
303
303
|
}
|
|
304
|
-
`,
|
|
304
|
+
`,qr={name:"picking",vs:Io,fs:Co,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:new Float32Array([0,0,0]),highlightColor:Fo},getUniforms:Ro};function Ro(r={},e){let t={};if(r.highlightedObjectColor!==void 0)if(r.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let n=r.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=n}if(r.highlightColor){let n=Array.from(r.highlightColor,o=>o/255);Number.isFinite(n[3])||(n[3]=1),t.highlightColor=n}return r.isActive!==void 0&&(t.isActive=Boolean(r.isActive),t.isAttribute=Boolean(r.isAttribute)),r.useFloatColors!==void 0&&(t.useFloatColors=Boolean(r.useFloatColors)),t}var Gt=`precision highp int;
|
|
305
305
|
struct AmbientLight {
|
|
306
306
|
vec3 color;
|
|
307
307
|
};
|
|
@@ -336,11 +336,11 @@ return pointLight.attenuation.x
|
|
|
336
336
|
+ pointLight.attenuation.y * distance
|
|
337
337
|
+ pointLight.attenuation.z * distance * distance;
|
|
338
338
|
}
|
|
339
|
-
`;var
|
|
339
|
+
`;var Oo=5,Uo=255,be;(function(r){r[r.POINT=0]="POINT",r[r.DIRECTIONAL=1]="DIRECTIONAL"})(be||(be={}));var Q={name:"lighting",vs:Gt,fs:Gt,getUniforms(r,e){return zo(r)},defines:{MAX_LIGHTS:Oo},uniformTypes:{enabled:"i32",ambientLightColor:"vec3<f32>",numberOfLights:"i32",lightType:"i32",lightColor:"vec3<f32>",lightPosition:"vec3<f32>",lightDirection:"vec3<f32>",lightAttenuation:"vec3<f32>"},defaultUniforms:{enabled:1,ambientLightColor:[.1,.1,.1],numberOfLights:0,lightType:be.POINT,lightColor:[1,1,1],lightPosition:[1,1,2],lightDirection:[1,1,1],lightAttenuation:[1,1,1]}};function zo(r,e={}){if(r=r&&{...r},!r)return{...Q.defaultUniforms};r.lights&&(r={...r,...Yo(r.lights),lights:void 0});let{ambientLight:t,pointLights:n,directionalLights:o}=r||{};if(!(t||n&&n.length>0||o&&o.length>0))return{...Q.defaultUniforms,enabled:0};let a={...Q.defaultUniforms,...e,...Do({ambientLight:t,pointLights:n,directionalLights:o})};return r.enabled!==void 0&&(a.enabled=r.enabled?1:0),a}function Do({ambientLight:r,pointLights:e=[],directionalLights:t=[]}){let n={};n.ambientLightColor=Ht(r);let o=0;for(let i of e)n.lightType=be.POINT,n.lightColor=Ht(i),n.lightPosition=i.position,n.lightAttenuation=[i.attenuation||1,0,0],o++;for(let i of t)n.lightType=be.DIRECTIONAL,n.lightColor=Ht(i),n.lightPosition=i.position,n.lightDirection=i.direction,o++;return n.numberOfLights=o,n}function Yo(r){let e={pointLights:[],directionalLights:[]};for(let t of r||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function Ht(r={}){let{color:e=[0,0,0],intensity:t=1}=r;return e.map(n=>n*t/Uo)}var Xo=`out vec3 dirlight_vNormal;
|
|
340
340
|
void dirlight_setNormal(vec3 normal) {
|
|
341
341
|
dirlight_vNormal = normalize(normal);
|
|
342
342
|
}
|
|
343
|
-
`,
|
|
343
|
+
`,Bo=`uniform dirlightUniforms {
|
|
344
344
|
vec3 lightDirection;
|
|
345
345
|
} dirlight;
|
|
346
346
|
in vec3 dirlight_vNormal;
|
|
@@ -348,13 +348,13 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
348
348
|
float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
|
|
349
349
|
return vec4(color.rgb * d, color.a);
|
|
350
350
|
}
|
|
351
|
-
`,
|
|
351
|
+
`,Wt={name:"dirlight",dependencies:[],vs:Xo,fs:Bo,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:new Float32Array([1,1,2])},getUniforms:Qo};function Qo(r=Wt.defaultUniforms){let e={};return r.lightDirection&&(e.dirlight_uLightDirection=r.lightDirection),e}var Vr=`uniform materialUniforms {
|
|
352
352
|
uniform float ambient;
|
|
353
353
|
uniform float diffuse;
|
|
354
354
|
uniform float shininess;
|
|
355
355
|
uniform vec3 specularColor;
|
|
356
356
|
} material;
|
|
357
|
-
`,
|
|
357
|
+
`,Gr=`uniform materialUniforms {
|
|
358
358
|
uniform float ambient;
|
|
359
359
|
uniform float diffuse;
|
|
360
360
|
uniform float shininess;
|
|
@@ -408,13 +408,13 @@ break;
|
|
|
408
408
|
}
|
|
409
409
|
return lightColor;
|
|
410
410
|
}
|
|
411
|
-
`;var
|
|
411
|
+
`;var jt={name:"gouraud-lighting",vs:Vr,fs:Gr,defines:{LIGHTING_VERTEX:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){return{...jt.defaultUniforms,...r}}};var Hr=`uniform phongMaterialUniforms {
|
|
412
412
|
uniform float ambient;
|
|
413
413
|
uniform float diffuse;
|
|
414
414
|
uniform float shininess;
|
|
415
415
|
uniform vec3 specularColor;
|
|
416
416
|
} material;
|
|
417
|
-
`,
|
|
417
|
+
`,Wr=`uniform phongMaterialUniforms {
|
|
418
418
|
uniform float ambient;
|
|
419
419
|
uniform float diffuse;
|
|
420
420
|
uniform float shininess;
|
|
@@ -469,7 +469,7 @@ break;
|
|
|
469
469
|
}
|
|
470
470
|
return lightColor;
|
|
471
471
|
}
|
|
472
|
-
`;var
|
|
472
|
+
`;var $t={name:"phong-lighting",vs:Hr,fs:Wr,defines:{LIGHTING_FRAGMENT:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){return{...$t.defaultUniforms,...r}}};var jr=`uniform projection {
|
|
473
473
|
mat4 u_MVPMatrix;
|
|
474
474
|
mat4 u_ModelMatrix;
|
|
475
475
|
mat4 u_NormalMatrix;
|
|
@@ -504,7 +504,7 @@ pbr_vUV = uv;
|
|
|
504
504
|
pbr_vUV = vec2(0.,0.);
|
|
505
505
|
#endif
|
|
506
506
|
}
|
|
507
|
-
`;var
|
|
507
|
+
`;var $r=`precision highp float;
|
|
508
508
|
uniform Projection {
|
|
509
509
|
uniform vec3 u_Camera;
|
|
510
510
|
};
|
|
@@ -785,7 +785,7 @@ color = mix(color, vec3(perceptualRoughness), u_pbrMaterial.scaleDiffBaseMR.w);
|
|
|
785
785
|
}
|
|
786
786
|
return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
|
|
787
787
|
}
|
|
788
|
-
`;var
|
|
788
|
+
`;var Kr={name:"pbr",vs:jr,fs:$r,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}},dependencies:[Q]};var qo=`uniform brightnessContrastUniforms {
|
|
789
789
|
float brightness;
|
|
790
790
|
float contrast;
|
|
791
791
|
} brightnessContrast;
|
|
@@ -801,7 +801,7 @@ return color;
|
|
|
801
801
|
vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
|
|
802
802
|
return brightnessContrast_filterColor(color);
|
|
803
803
|
}
|
|
804
|
-
`,
|
|
804
|
+
`,Zr={name:"brightnessContrast",uniformTypes:{brightness:"f32",contrast:"f32"},uniformPropTypes:{brightness:{format:"f32",value:0,min:-1,max:1},contrast:{format:"f32",value:0,min:-1,max:1}},fs:qo,passes:[{filter:!0}]};var Vo=`uniform denoiseUniforms {
|
|
805
805
|
float strength;
|
|
806
806
|
} noise;
|
|
807
807
|
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
@@ -820,7 +820,7 @@ total += weight;
|
|
|
820
820
|
}
|
|
821
821
|
return color / total;
|
|
822
822
|
}
|
|
823
|
-
`,
|
|
823
|
+
`,Jr={name:"denoise",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{format:"f32",value:.5,min:0,max:1}},fs:Vo,passes:[{sampler:!0},{sampler:!0}]};var Go=`uniform hueSaturationUniforms {
|
|
824
824
|
float hue;
|
|
825
825
|
float saturation;
|
|
826
826
|
} hueSaturation;
|
|
@@ -845,7 +845,7 @@ return color;
|
|
|
845
845
|
vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
846
846
|
return hueSaturation_filterColor(color);
|
|
847
847
|
}
|
|
848
|
-
`,
|
|
848
|
+
`,en={name:"hueSaturation",uniformTypes:{hue:"f32",saturation:"f32"},uniformPropTypes:{hue:{value:0,min:-1,max:1},saturation:{value:0,min:-1,max:1}},fs:Go,passes:[{filter:!0}]};var Ho=`uniform noiseUniforms {
|
|
849
849
|
float amount;
|
|
850
850
|
} noise;
|
|
851
851
|
float rand(vec2 co) {
|
|
@@ -861,7 +861,7 @@ return color;
|
|
|
861
861
|
vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
862
862
|
return noise_filterColor(color, texCoord);
|
|
863
863
|
}
|
|
864
|
-
`,
|
|
864
|
+
`,tn={name:"noise",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Ho,passes:[{filter:!0}]};var Wo=`uniform sepiaUniforms {
|
|
865
865
|
float amount;
|
|
866
866
|
} sepia;
|
|
867
867
|
vec4 sepia_filterColor(vec4 color) {
|
|
@@ -877,7 +877,7 @@ return color;
|
|
|
877
877
|
vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
878
878
|
return sepia_filterColor(color);
|
|
879
879
|
}
|
|
880
|
-
|
|
880
|
+
`,rn={name:"sepia",uniformTypes:{amount:"f32"},uniformPropTypes:{amount:{value:.5,min:0,max:1}},fs:Wo,passes:[{filter:!0}]};var jo=`uniform vibranceUniforms {
|
|
881
881
|
float amount;
|
|
882
882
|
} vibrance;
|
|
883
883
|
vec4 vibrance_filterColor(vec4 color) {
|
|
@@ -890,7 +890,7 @@ return color;
|
|
|
890
890
|
vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
891
891
|
return vibrance_filterColor(color);
|
|
892
892
|
}
|
|
893
|
-
`,
|
|
893
|
+
`,nn={name:"vibrance",uniformPropTypes:{amount:{value:0,min:-1,max:1}},fs:jo,passes:[{filter:!0}]};var $o=`uniform vignetteUniforms {
|
|
894
894
|
float radius;
|
|
895
895
|
float amount;
|
|
896
896
|
} vignette;
|
|
@@ -902,7 +902,7 @@ return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
902
902
|
vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
903
903
|
return vignette_filterColor(color, texCoord);
|
|
904
904
|
}
|
|
905
|
-
`,
|
|
905
|
+
`,on={name:"vignette",fs:$o,uniformTypes:{radius:"f32",amount:"f32"},uniformPropTypes:{radius:{value:.5,min:0,max:1},amount:{value:.5,min:0,max:1}},passes:[{filter:!0}]};var Ko=`uniform tiltShiftUniforms {
|
|
906
906
|
float blurRadius;
|
|
907
907
|
float gradientRadius;
|
|
908
908
|
vec2 start;
|
|
@@ -932,7 +932,7 @@ color = color / total;
|
|
|
932
932
|
color.rgb /= color.a + 0.00001;
|
|
933
933
|
return color;
|
|
934
934
|
}
|
|
935
|
-
`,
|
|
935
|
+
`,sn={name:"tiltShift",uniformTypes:{blurRadius:"f32",gradientRadius:"f32",start:"vec2<f32>",end:"vec2<f32>",invert:"i32"},uniformPropTypes:{blurRadius:{value:15,min:0,max:50},gradientRadius:{value:200,min:0,max:400},start:{value:[0,0]},end:{value:[1,1]},invert:{value:!1,private:!0}},passes:[{sampler:!0,uniforms:{invert:!1}},{sampler:!0,uniforms:{invert:!0}}],dependencies:[q],fs:Ko};var Zo=`uniform triangleBlurUniforms {
|
|
936
936
|
float radius;
|
|
937
937
|
vec2 delta;
|
|
938
938
|
} triangleBlur;
|
|
@@ -953,7 +953,7 @@ color = color / total;
|
|
|
953
953
|
color.rgb /= color.a + 0.00001;
|
|
954
954
|
return color;
|
|
955
955
|
}
|
|
956
|
-
`,
|
|
956
|
+
`,an={name:"triangleBlur",uniformTypes:{radius:"f32",delta:"vec2<f32>"},uniformPropTypes:{radius:{value:20,min:0,softMax:100},delta:{value:[1,0],private:!0}},fs:Zo,dependencies:[q],passes:[{sampler:!0,uniforms:{delta:[1,0]}},{sampler:!0,uniforms:{delta:[0,1]}}]};var Jo=`
|
|
957
957
|
uniform zoomBlurUniforms {
|
|
958
958
|
vec2 center;
|
|
959
959
|
float strength;
|
|
@@ -986,7 +986,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
986
986
|
|
|
987
987
|
return color;
|
|
988
988
|
}
|
|
989
|
-
`,
|
|
989
|
+
`,cn={name:"zoomBlur",uniformTypes:{center:"vec2<f32>",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},strength:{value:.3,min:0,softMax:1}},fs:Jo,dependencies:[q],passes:[{sampler:!0}]};var ei=`uniform colorHalftoneUniforms {
|
|
990
990
|
vec2 center;
|
|
991
991
|
float angle;
|
|
992
992
|
float size;
|
|
@@ -1017,7 +1017,7 @@ pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
|
1017
1017
|
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
1018
1018
|
return vec4(1.0 - cmy - k, color.a);
|
|
1019
1019
|
}
|
|
1020
|
-
`,
|
|
1020
|
+
`,ln={name:"colorHalftone",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:4,min:1,softMin:3,softMax:20}},fs:ei,passes:[{filter:!0}]};var ti=`uniform dotScreenUniforms {
|
|
1021
1021
|
vec2 center;
|
|
1022
1022
|
float angle;
|
|
1023
1023
|
float size;
|
|
@@ -1036,7 +1036,7 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
1036
1036
|
float average = (color.r + color.g + color.b) / 3.0;
|
|
1037
1037
|
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
1038
1038
|
}
|
|
1039
|
-
`,
|
|
1039
|
+
`,fn={name:"dotScreen",uniformTypes:{center:"vec2<f32>",angle:"f32",size:"f32"},uniformPropTypes:{center:{value:[.5,.5]},angle:{value:1.1,softMin:0,softMax:Math.PI/2},size:{value:3,min:1,softMin:3,softMax:20}},fs:ti,passes:[{filter:!0}]};var ri=`uniform edgeWorkUniforms {
|
|
1040
1040
|
float radius;
|
|
1041
1041
|
vec2 delta;
|
|
1042
1042
|
} edgeWork;
|
|
@@ -1080,7 +1080,7 @@ total.y += weight;
|
|
|
1080
1080
|
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
1081
1081
|
return vec4(c, c, c, 1.0);
|
|
1082
1082
|
}
|
|
1083
|
-
`,
|
|
1083
|
+
`,un={name:"edgeWork",uniformPropTypes:{radius:{value:2,min:1,softMax:50},delta:{value:[1,0],private:!0}},fs:ri,dependencies:[q],passes:[{sampler:"edgeWork_sampleColor1",uniformPropTypes:{delta:[1,0]}},{sampler:"edgeWork_sampleColor2",uniformPropTypes:{delta:[0,1]}}]};var ni=`uniform hexagonalPixelateUniforms {
|
|
1084
1084
|
vec2 center;
|
|
1085
1085
|
float scale;
|
|
1086
1086
|
} hexagonalPixelate;
|
|
@@ -1115,7 +1115,7 @@ choice.y *= 0.866025404;
|
|
|
1115
1115
|
choice *= hexagonalPixelate.scale / texSize;
|
|
1116
1116
|
return texture(source, choice + hexagonalPixelate.center);
|
|
1117
1117
|
}
|
|
1118
|
-
`,
|
|
1118
|
+
`,_n={name:"hexagonalPixelate",uniformTypes:{center:"vec2<f32>",scale:"f32"},uniformPropTypes:{center:{value:[.5,.5],hint:"screenspace"},scale:{value:10,min:1,softMin:5,softMax:50}},fs:ni,passes:[{sampler:!0}]};var oi=`uniform inkUniforms {
|
|
1119
1119
|
float strength;
|
|
1120
1120
|
} ink;
|
|
1121
1121
|
vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
@@ -1141,7 +1141,7 @@ vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
|
1141
1141
|
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
1142
1142
|
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
1143
1143
|
}
|
|
1144
|
-
`,
|
|
1144
|
+
`,hn={name:"ink",uniformTypes:{strength:"f32"},uniformPropTypes:{strength:{value:.25,min:0,softMax:1}},fs:oi,passes:[{sampler:!0}]};var ii=`uniform magnifyUniforms {
|
|
1145
1145
|
vec2 screenXY;
|
|
1146
1146
|
float radiusPixels;
|
|
1147
1147
|
float zoom;
|
|
@@ -1159,7 +1159,7 @@ return magnify.borderColor;
|
|
|
1159
1159
|
}
|
|
1160
1160
|
return texture(source, texCoord);
|
|
1161
1161
|
}
|
|
1162
|
-
`,
|
|
1162
|
+
`,pn={name:"magnify",uniformTypes:{screenXY:"vec2<f32>",radiusPixels:"f32",zoom:"f32",borderWidthPixels:"f32",borderColor:"vec4<f32>"},uniformPropTypes:{screenXY:{value:[0,0]},radiusPixels:200,zoom:2,borderWidthPixels:0,borderColor:{value:[255,255,255,255]}},fs:ii,passes:[{sampler:!0}]};var si=`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
|
|
1163
1163
|
vec4 color = texture(source, coord / texSize);
|
|
1164
1164
|
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
1165
1165
|
if (coord != clampedCoord) {
|
|
@@ -1167,7 +1167,7 @@ color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
|
1167
1167
|
}
|
|
1168
1168
|
return color;
|
|
1169
1169
|
}
|
|
1170
|
-
`,
|
|
1170
|
+
`,fe={name:"warp",passes:[],fs:si};var ai=`uniform bulgePinchUniforms {
|
|
1171
1171
|
float radius;
|
|
1172
1172
|
float strength;
|
|
1173
1173
|
vec2 center;
|
|
@@ -1191,7 +1191,7 @@ vec2 coord = texCoord * texSize;
|
|
|
1191
1191
|
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
1192
1192
|
return warp_sampleColor(source, texSize, coord);
|
|
1193
1193
|
}
|
|
1194
|
-
`,
|
|
1194
|
+
`,dn={name:"bulgePinch",fs:ai,uniformTypes:{center:"vec2<f32>",radius:"f32",strength:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},strength:{value:.5,min:-1,max:1}},dependencies:[fe],passes:[{sampler:!0}]};var ci=`uniform swirlUniforms {
|
|
1195
1195
|
float radius;
|
|
1196
1196
|
float angle;
|
|
1197
1197
|
vec2 center;
|
|
@@ -1217,7 +1217,7 @@ vec2 coord = texCoord * texSize;
|
|
|
1217
1217
|
coord = swirl_warp(coord, swirl.center * texSize);
|
|
1218
1218
|
return warp_sampleColor(source, texSize, coord);
|
|
1219
1219
|
}
|
|
1220
|
-
`,
|
|
1220
|
+
`,mn={name:"swirl",fs:ci,uniformTypes:{center:"vec2<f32>",radius:"f32",angle:"f32"},uniformPropTypes:{center:{value:[.5,.5]},radius:{value:200,min:1,softMax:600},angle:{value:3,softMin:-25,softMax:25}},dependencies:[fe],passes:[{sampler:!0}]};var li=`
|
|
1221
1221
|
#define FXAA_QUALITY_PRESET 29
|
|
1222
1222
|
|
|
1223
1223
|
#if (FXAA_QUALITY_PRESET == 10)
|
|
@@ -1797,7 +1797,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1797
1797
|
fxaa_QualityEdgeThresholdMin
|
|
1798
1798
|
);
|
|
1799
1799
|
}
|
|
1800
|
-
`,
|
|
1800
|
+
`,gn={name:"fxaa",uniformPropTypes:{},fs:li,passes:[{sampler:!0}]};function Ge(r,e=[],t=0){let n=Math.fround(r),o=r-n;return e[t]=n,e[t+1]=o,e}function Kt(r){return r-Math.fround(r)}function Zt(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let n=0;n<4;++n){let o=t*4+n;Ge(r[n*4+t],e,o*2)}return e}var xn=`uniform float ONE;
|
|
1801
1801
|
vec2 split(float a) {
|
|
1802
1802
|
const float SPLIT = 4097.0;
|
|
1803
1803
|
float t = a * SPLIT;
|
|
@@ -1929,7 +1929,7 @@ return sum_fp64(split(yn), prod);
|
|
|
1929
1929
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
1930
1930
|
#endif
|
|
1931
1931
|
}
|
|
1932
|
-
`;var
|
|
1932
|
+
`;var vn=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
1933
1933
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
1934
1934
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
1935
1935
|
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -2442,7 +2442,7 @@ tmp[j] = b[j + i * 4];
|
|
|
2442
2442
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
2443
2443
|
}
|
|
2444
2444
|
}
|
|
2445
|
-
`;var
|
|
2445
|
+
`;var fi={ONE:1};function ui(){return fi}var Jt={name:"fp64-arithmetic",vs:xn,getUniforms:ui,fp64ify:Ge,fp64LowPart:Kt,fp64ifyMatrix4:Zt},An={name:"fp64",vs:vn,dependencies:[Jt],fp64ify:Ge,fp64LowPart:Kt,fp64ifyMatrix4:Zt};var _i=`varying vec4 geometry_vPosition;
|
|
2446
2446
|
varying vec3 geometry_vNormal;
|
|
2447
2447
|
void geometry_setNormal(vec3 normal) {
|
|
2448
2448
|
geometry_vNormal = normal;
|
|
@@ -2453,7 +2453,7 @@ geometry_vPosition = position;
|
|
|
2453
2453
|
void geometry_setPosition(vec3 position) {
|
|
2454
2454
|
geometry_vPosition = vec4(position, 1.);
|
|
2455
2455
|
}
|
|
2456
|
-
`,
|
|
2456
|
+
`,hi=`varying vec4 geometry_vPosition;
|
|
2457
2457
|
varying vec3 geometry_vNormal;
|
|
2458
2458
|
vec4 geometry_getPosition() {
|
|
2459
2459
|
return geometry_vPosition;
|
|
@@ -2461,7 +2461,7 @@ return geometry_vPosition;
|
|
|
2461
2461
|
vec3 geometry_getNormal() {
|
|
2462
2462
|
return geometry_vNormal;
|
|
2463
2463
|
}
|
|
2464
|
-
`,dn={name:"geometry",vs:si,fs:ai};var Ea=1/Math.PI*180,Ta=1/180*Math.PI,ci={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ci}};var O=globalThis.mathgl.config;function mn(t,{precision:e=O.precision}={}){return t=li(t),`${parseFloat(t.toPrecision(e))}`}function Be(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wt(t,e,r){let n=O.EPSILON;r&&(O.EPSILON=r);try{if(t===e)return!0;if(Be(t)&&Be(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Wt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=n}}function li(t){return Math.round(t/O.EPSILON)*O.EPSILON}var Ve=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Be(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mn(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Wt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof r=="number"?r:r[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function fi(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function gn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function qe(t,e,r=""){if(O.debug&&!fi(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}var H=typeof Float32Array<"u"?Float32Array:Array;var Oa=Math.PI/180;function ui(){let t=new H(2);return H!=Float32Array&&(t[0]=0,t[1]=0),t}function An(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var Ua=function(){let t=ui();return function(e,r,n,o,i,a){let f,u;for(r||(r=2),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],i(t,t,a),e[f]=t[0],e[f+1]=t[1];return e}}();function bn(t,e,r){let n=e[0],o=e[1],i=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/i,t[1]=(r[1]*n+r[5]*o)/i,t}function yn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i||1;return t[0]=(r[0]*n+r[4]*o+r[8]*i)/a,t[1]=(r[1]*n+r[5]*o+r[9]*i)/a,t[2]=(r[2]*n+r[6]*o+r[10]*i)/a,t}function _i(){let t=new H(3);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Pn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/a,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}var Ya=function(){let t=_i();return function(e,r,n,o,i,a){let f,u;for(r||(r=3),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2];return e}}();var Ge=class extends Ve{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=gn(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function hi(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 wn(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],i=e[6],a=e[7],f=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=f}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 Ln(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],f=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=r*f-n*a,y=r*u-o*a,P=r*h-i*a,b=n*u-o*f,S=n*h-i*f,k=o*h-i*u,F=p*g-d*w,M=p*A-m*w,N=p*L-x*w,I=d*A-m*g,U=d*L-x*g,R=m*L-x*A,E=v*R-y*U+P*I+b*N-S*M+k*F;return E?(E=1/E,t[0]=(f*R-u*U+h*I)*E,t[1]=(o*U-n*R-i*I)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*R-h*M)*E,t[5]=(r*R-o*N+i*M)*E,t[6]=(A*P-w*k-L*y)*E,t[7]=(p*k-m*P+x*y)*E,t[8]=(a*U-f*N+h*F)*E,t[9]=(n*N-r*U-i*F)*E,t[10]=(w*S-g*P+L*v)*E,t[11]=(d*P-p*S-x*v)*E,t[12]=(f*M-a*I-u*F)*E,t[13]=(r*I-n*M+o*F)*E,t[14]=(g*y-w*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function Sn(t){let e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],f=t[6],u=t[7],h=t[8],p=t[9],d=t[10],m=t[11],x=t[12],w=t[13],g=t[14],A=t[15],L=e*a-r*i,v=e*f-n*i,y=r*f-n*a,P=h*w-p*x,b=h*g-d*x,S=p*g-d*w,k=e*S-r*b+n*P,F=i*S-a*b+f*P,M=h*y-p*v+d*L,N=x*y-w*v+g*L;return u*k-o*F+A*M-m*N}function $t(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=r[0],P=r[1],b=r[2],S=r[3];return t[0]=y*n+P*f+b*d+S*g,t[1]=y*o+P*u+b*m+S*A,t[2]=y*i+P*h+b*x+S*L,t[3]=y*a+P*p+b*w+S*v,y=r[4],P=r[5],b=r[6],S=r[7],t[4]=y*n+P*f+b*d+S*g,t[5]=y*o+P*u+b*m+S*A,t[6]=y*i+P*h+b*x+S*L,t[7]=y*a+P*p+b*w+S*v,y=r[8],P=r[9],b=r[10],S=r[11],t[8]=y*n+P*f+b*d+S*g,t[9]=y*o+P*u+b*m+S*A,t[10]=y*i+P*h+b*x+S*L,t[11]=y*a+P*p+b*w+S*v,y=r[12],P=r[13],b=r[14],S=r[15],t[12]=y*n+P*f+b*d+S*g,t[13]=y*o+P*u+b*m+S*A,t[14]=y*i+P*h+b*x+S*L,t[15]=y*a+P*p+b*w+S*v,t}function kn(t,e,r){let n=r[0],o=r[1],i=r[2],a,f,u,h,p,d,m,x,w,g,A,L;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],f=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=f,t[2]=u,t[3]=h,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=w,t[9]=g,t[10]=A,t[11]=L,t[12]=a*n+p*o+w*i+e[12],t[13]=f*n+d*o+g*i+e[13],t[14]=u*n+m*o+A*i+e[14],t[15]=h*n+x*o+L*i+e[15]),t}function Nn(t,e,r){let n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function En(t,e,r,n){let o=n[0],i=n[1],a=n[2],f=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,S,k,F,M,N,I,U,R,E,fe;return f<1e-6?null:(f=1/f,o*=f,i*=f,a*=f,h=Math.sin(r),u=Math.cos(r),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],S=e[11],k=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,N=o*i*p-a*h,I=i*i*p+u,U=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,fe=a*a*p+u,t[0]=d*k+g*F+y*M,t[1]=m*k+A*F+P*M,t[2]=x*k+L*F+b*M,t[3]=w*k+v*F+S*M,t[4]=d*N+g*I+y*U,t[5]=m*N+A*I+P*U,t[6]=x*N+L*I+b*U,t[7]=w*N+v*I+S*U,t[8]=d*R+g*E+y*fe,t[9]=m*R+A*E+P*fe,t[10]=x*R+L*E+b*fe,t[11]=w*R+v*E+S*fe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Tn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[4],a=e[5],f=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+h*n,t[5]=a*o+p*n,t[6]=f*o+d*n,t[7]=u*o+m*n,t[8]=h*o-i*n,t[9]=p*o-a*n,t[10]=d*o-f*n,t[11]=m*o-u*n,t}function Mn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-h*n,t[1]=a*o-p*n,t[2]=f*o-d*n,t[3]=u*o-m*n,t[8]=i*n+h*o,t[9]=a*n+p*o,t[10]=f*n+d*o,t[11]=u*n+m*o,t}function Fn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+h*n,t[1]=a*o+p*n,t[2]=f*o+d*n,t[3]=u*o+m*n,t[4]=h*o-i*n,t[5]=p*o-a*n,t[6]=d*o-f*n,t[7]=m*o-u*n,t}function In(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=r+r,f=n+n,u=o+o,h=r*a,p=n*a,d=n*f,m=o*a,x=o*f,w=o*u,g=i*a,A=i*f,L=i*u;return t[0]=1-d-w,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-h-w,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-h-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cn(t,e,r,n,o,i,a){let f=1/(r-e),u=1/(o-n),h=1/(i-a);return t[0]=i*2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(r+e)*f,t[9]=(o+n)*u,t[10]=(a+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*h,t[15]=0,t}function pi(t,e,r,n,o){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(n-o);t[10]=(o+n)*a,t[14]=2*o*n*a}else t[10]=-1,t[14]=-2*n;return t}var Rn=pi;function di(t,e,r,n,o,i,a){let f=1/(e-r),u=1/(n-o),h=1/(i-a);return t[0]=-2*f,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*h,t[11]=0,t[12]=(e+r)*f,t[13]=(o+n)*u,t[14]=(a+i)*h,t[15]=1,t}var On=di;function Un(t,e,r,n){let o,i,a,f,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],y=n[2],P=r[0],b=r[1],S=r[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?hi(t):(d=w-P,m=g-b,x=A-S,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,f=L*m-v*d,o=Math.sqrt(i*i+a*a+f*f),o?(o=1/o,i*=o,a*=o,f*=o):(i=0,a=0,f=0),u=m*f-x*a,h=x*i-d*f,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=h,t[6]=m,t[7]=0,t[8]=f,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*w+a*g+f*A),t[13]=-(u*w+h*g+p*A),t[14]=-(d*w+m*g+x*A),t[15]=1,t)}function mi(){let t=new H(4);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zn(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*i+r[12]*a,t[1]=r[1]*n+r[5]*o+r[9]*i+r[13]*a,t[2]=r[2]*n+r[6]*o+r[10]*i+r[14]*a,t[3]=r[3]*n+r[7]*o+r[11]*i+r[15]*a,t}var Ha=function(){let t=mi();return function(e,r,n,o,i,a){let f,u;for(r||(r=4),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],t[3]=e[f+3],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2],e[f+3]=t[3];return e}}();var Jt;(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"})(Jt||(Jt={}));var gi=45*Math.PI/180,xi=1,Kt=.1,Zt=500,vi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Ge{static get IDENTITY(){return bi()}static get ZERO(){return Ai()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jt}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,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=f,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=r,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=f,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(vi)}fromObject(e){return this.check()}fromQuaternion(e){return In(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return f===1/0?yi(this,r,n,o,i,a):Cn(this,r,n,o,i,a,f),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Un(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return On(this,r,n,o,i,a,f),this.check()}orthographic(e){let{fovy:r=gi,aspect:n=xi,focalDistance:o=1,near:i=Kt,far:a=Zt}=e;Dn(r);let f=r/2,u=o*Math.tan(f),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Dn(r),Rn(this,r,n,o,i),this.check()}determinant(){return Sn(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,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return wn(this,this),this.check()}invert(){return Ln(this,this),this.check()}multiplyLeft(e){return $t(this,e,this),this.check()}multiplyRight(e){return $t(this,this,e),this.check()}rotateX(e){return Tn(this,this,e),this.check()}rotateY(e){return Mn(this,this,e),this.check()}rotateZ(e){return Fn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return En(this,this,e,r),this.check()}scale(e){return Nn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kn(this,this,e),this.check()}transform(e,r){return e.length===4?(r=zn(r||[-0,-0,-0,-0],e,this),qe(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=An(r||[-0,-0],e,this);break;case 3:o=Pn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=bn(r||[-0,-0],e,this);break;case 3:n=yn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},He,We;function Ai(){return He||(He=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(He)),He}function bi(){return We||(We=new ee,Object.freeze(We)),We}function Dn(t){if(t>Math.PI*2)throw Error("expected radians")}function yi(t,e,r,n,o,i){let a=2*i/(r-e),f=2*i/(o-n),u=(r+e)/(r-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=f,t[6]=0,t[7]=0,t[8]=u,t[9]=h,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Pi={modelMatrix:er,viewMatrix:er,projectionMatrix:er,cameraPositionWorld:[0,0,0]};function wi(t=Pi,e={}){let r={};return t.modelMatrix!==void 0&&(r.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(r.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(r.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(r.cameraPositionWorld=t.cameraPositionWorld),(t.projectionMatrix!==void 0||t.viewMatrix!==void 0)&&(r.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),r}var Yn=`varying vec4 project_vPositionWorld;
|
|
2464
|
+
`,yn={name:"geometry",vs:_i,fs:hi};var Ra=1/Math.PI*180,Oa=1/180*Math.PI,pi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...pi}};var O=globalThis.mathgl.config;function bn(r,{precision:e=O.precision}={}){return r=di(r),`${parseFloat(r.toPrecision(e))}`}function He(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function er(r,e,t){let n=O.EPSILON;t&&(O.EPSILON=t);try{if(r===e)return!0;if(He(r)&&He(e)){if(r.length!==e.length)return!1;for(let o=0;o<r.length;++o)if(!er(r[o],e[o]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=O.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{O.EPSILON=n}}function di(r){return Math.round(r/O.EPSILON)*O.EPSILON}var We=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:He(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+bn(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!er(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof t=="number"?t:t[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n];return this.check()}subtract(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=t[n];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function mi(r,e){if(r.length!==e)return!1;for(let t=0;t<r.length;++t)if(!Number.isFinite(r[t]))return!1;return!0}function Pn(r){if(!Number.isFinite(r))throw new Error(`Invalid number ${JSON.stringify(r)}`);return r}function je(r,e,t=""){if(O.debug&&!mi(r,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return r}var W=typeof Float32Array<"u"?Float32Array:Array;var Ba=Math.PI/180;function gi(){let r=new W(2);return W!=Float32Array&&(r[0]=0,r[1]=0),r}function kn(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[4]*o+t[12],r[1]=t[1]*n+t[5]*o+t[13],r}var Qa=function(){let r=gi();return function(e,t,n,o,i,a){let c,u;for(t||(t=2),n||(n=0),o?u=Math.min(o*t+n,e.length):u=e.length,c=n;c<u;c+=t)r[0]=e[c],r[1]=e[c+1],i(r,r,a),e[c]=r[0],e[c+1]=r[1];return e}}();function Sn(r,e,t){let n=e[0],o=e[1],i=t[3]*n+t[7]*o||1;return r[0]=(t[0]*n+t[4]*o)/i,r[1]=(t[1]*n+t[5]*o)/i,r}function Nn(r,e,t){let n=e[0],o=e[1],i=e[2],a=t[3]*n+t[7]*o+t[11]*i||1;return r[0]=(t[0]*n+t[4]*o+t[8]*i)/a,r[1]=(t[1]*n+t[5]*o+t[9]*i)/a,r[2]=(t[2]*n+t[6]*o+t[10]*i)/a,r}function xi(){let r=new W(3);return W!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function Tn(r,e,t){let n=e[0],o=e[1],i=e[2],a=t[3]*n+t[7]*o+t[11]*i+t[15];return a=a||1,r[0]=(t[0]*n+t[4]*o+t[8]*i+t[12])/a,r[1]=(t[1]*n+t[5]*o+t[9]*i+t[13])/a,r[2]=(t[2]*n+t[6]*o+t[10]*i+t[14])/a,r}var Ga=function(){let r=xi();return function(e,t,n,o,i,a){let c,u;for(t||(t=3),n||(n=0),o?u=Math.min(o*t+n,e.length):u=e.length,c=n;c<u;c+=t)r[0]=e[c],r[1]=e[c+1],r[2]=e[c+2],i(r,r,a),e[c]=r[0],e[c+1]=r[1],e[c+2]=r[2];return e}}();var $e=class extends We{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=Pn(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)t[o]=this[n+o];return t}setColumn(e,t){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=t[o];return this}};function vi(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function En(r,e){if(r===e){let t=e[1],n=e[2],o=e[3],i=e[6],a=e[7],c=e[11];r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=t,r[6]=e[9],r[7]=e[13],r[8]=n,r[9]=i,r[11]=e[14],r[12]=o,r[13]=a,r[14]=c}else r[0]=e[0],r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=e[1],r[5]=e[5],r[6]=e[9],r[7]=e[13],r[8]=e[2],r[9]=e[6],r[10]=e[10],r[11]=e[14],r[12]=e[3],r[13]=e[7],r[14]=e[11],r[15]=e[15];return r}function Mn(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],a=e[4],c=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=t*c-n*a,b=t*u-o*a,P=t*h-i*a,y=n*u-o*c,k=n*h-i*c,S=o*h-i*u,F=p*g-d*w,M=p*A-m*w,T=p*L-x*w,I=d*A-m*g,z=d*L-x*g,R=m*L-x*A,E=v*R-b*z+P*I+y*T-k*M+S*F;return E?(E=1/E,r[0]=(c*R-u*z+h*I)*E,r[1]=(o*z-n*R-i*I)*E,r[2]=(g*S-A*k+L*y)*E,r[3]=(m*k-d*S-x*y)*E,r[4]=(u*T-a*R-h*M)*E,r[5]=(t*R-o*T+i*M)*E,r[6]=(A*P-w*S-L*b)*E,r[7]=(p*S-m*P+x*b)*E,r[8]=(a*z-c*T+h*F)*E,r[9]=(n*T-t*z-i*F)*E,r[10]=(w*k-g*P+L*v)*E,r[11]=(d*P-p*k-x*v)*E,r[12]=(c*M-a*I-u*F)*E,r[13]=(t*I-n*M+o*F)*E,r[14]=(g*b-w*y-A*v)*E,r[15]=(p*y-d*b+m*v)*E,r):null}function Fn(r){let e=r[0],t=r[1],n=r[2],o=r[3],i=r[4],a=r[5],c=r[6],u=r[7],h=r[8],p=r[9],d=r[10],m=r[11],x=r[12],w=r[13],g=r[14],A=r[15],L=e*a-t*i,v=e*c-n*i,b=t*c-n*a,P=h*w-p*x,y=h*g-d*x,k=p*g-d*w,S=e*k-t*y+n*P,F=i*k-a*y+c*P,M=h*b-p*v+d*L,T=x*b-w*v+g*L;return u*S-o*F+A*M-m*T}function rr(r,e,t){let n=e[0],o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],b=t[0],P=t[1],y=t[2],k=t[3];return r[0]=b*n+P*c+y*d+k*g,r[1]=b*o+P*u+y*m+k*A,r[2]=b*i+P*h+y*x+k*L,r[3]=b*a+P*p+y*w+k*v,b=t[4],P=t[5],y=t[6],k=t[7],r[4]=b*n+P*c+y*d+k*g,r[5]=b*o+P*u+y*m+k*A,r[6]=b*i+P*h+y*x+k*L,r[7]=b*a+P*p+y*w+k*v,b=t[8],P=t[9],y=t[10],k=t[11],r[8]=b*n+P*c+y*d+k*g,r[9]=b*o+P*u+y*m+k*A,r[10]=b*i+P*h+y*x+k*L,r[11]=b*a+P*p+y*w+k*v,b=t[12],P=t[13],y=t[14],k=t[15],r[12]=b*n+P*c+y*d+k*g,r[13]=b*o+P*u+y*m+k*A,r[14]=b*i+P*h+y*x+k*L,r[15]=b*a+P*p+y*w+k*v,r}function In(r,e,t){let n=t[0],o=t[1],i=t[2],a,c,u,h,p,d,m,x,w,g,A,L;return e===r?(r[12]=e[0]*n+e[4]*o+e[8]*i+e[12],r[13]=e[1]*n+e[5]*o+e[9]*i+e[13],r[14]=e[2]*n+e[6]*o+e[10]*i+e[14],r[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],c=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],r[0]=a,r[1]=c,r[2]=u,r[3]=h,r[4]=p,r[5]=d,r[6]=m,r[7]=x,r[8]=w,r[9]=g,r[10]=A,r[11]=L,r[12]=a*n+p*o+w*i+e[12],r[13]=c*n+d*o+g*i+e[13],r[14]=u*n+m*o+A*i+e[14],r[15]=h*n+x*o+L*i+e[15]),r}function Cn(r,e,t){let n=t[0],o=t[1],i=t[2];return r[0]=e[0]*n,r[1]=e[1]*n,r[2]=e[2]*n,r[3]=e[3]*n,r[4]=e[4]*o,r[5]=e[5]*o,r[6]=e[6]*o,r[7]=e[7]*o,r[8]=e[8]*i,r[9]=e[9]*i,r[10]=e[10]*i,r[11]=e[11]*i,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function Rn(r,e,t,n){let o=n[0],i=n[1],a=n[2],c=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,b,P,y,k,S,F,M,T,I,z,R,E,_e;return c<1e-6?null:(c=1/c,o*=c,i*=c,a*=c,h=Math.sin(t),u=Math.cos(t),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],b=e[8],P=e[9],y=e[10],k=e[11],S=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,T=o*i*p-a*h,I=i*i*p+u,z=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,_e=a*a*p+u,r[0]=d*S+g*F+b*M,r[1]=m*S+A*F+P*M,r[2]=x*S+L*F+y*M,r[3]=w*S+v*F+k*M,r[4]=d*T+g*I+b*z,r[5]=m*T+A*I+P*z,r[6]=x*T+L*I+y*z,r[7]=w*T+v*I+k*z,r[8]=d*R+g*E+b*_e,r[9]=m*R+A*E+P*_e,r[10]=x*R+L*E+y*_e,r[11]=w*R+v*E+k*_e,e!==r&&(r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r)}function On(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[4],a=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=i*o+h*n,r[5]=a*o+p*n,r[6]=c*o+d*n,r[7]=u*o+m*n,r[8]=h*o-i*n,r[9]=p*o-a*n,r[10]=d*o-c*n,r[11]=m*o-u*n,r}function Un(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*o-h*n,r[1]=a*o-p*n,r[2]=c*o-d*n,r[3]=u*o-m*n,r[8]=i*n+h*o,r[9]=a*n+p*o,r[10]=c*n+d*o,r[11]=u*n+m*o,r}function zn(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[0],a=e[1],c=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*o+h*n,r[1]=a*o+p*n,r[2]=c*o+d*n,r[3]=u*o+m*n,r[4]=h*o-i*n,r[5]=p*o-a*n,r[6]=d*o-c*n,r[7]=m*o-u*n,r}function Dn(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],a=t+t,c=n+n,u=o+o,h=t*a,p=n*a,d=n*c,m=o*a,x=o*c,w=o*u,g=i*a,A=i*c,L=i*u;return r[0]=1-d-w,r[1]=p+L,r[2]=m-A,r[3]=0,r[4]=p-L,r[5]=1-h-w,r[6]=x+g,r[7]=0,r[8]=m+A,r[9]=x-g,r[10]=1-h-d,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Yn(r,e,t,n,o,i,a){let c=1/(t-e),u=1/(o-n),h=1/(i-a);return r[0]=i*2*c,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i*2*u,r[6]=0,r[7]=0,r[8]=(t+e)*c,r[9]=(o+n)*u,r[10]=(a+i)*h,r[11]=-1,r[12]=0,r[13]=0,r[14]=a*i*2*h,r[15]=0,r}function Ai(r,e,t,n,o){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,o!=null&&o!==1/0){let a=1/(n-o);r[10]=(o+n)*a,r[14]=2*o*n*a}else r[10]=-1,r[14]=-2*n;return r}var Xn=Ai;function yi(r,e,t,n,o,i,a){let c=1/(e-t),u=1/(n-o),h=1/(i-a);return r[0]=-2*c,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*u,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*h,r[11]=0,r[12]=(e+t)*c,r[13]=(o+n)*u,r[14]=(a+i)*h,r[15]=1,r}var Bn=yi;function Qn(r,e,t,n){let o,i,a,c,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],b=n[2],P=t[0],y=t[1],k=t[2];return Math.abs(w-P)<1e-6&&Math.abs(g-y)<1e-6&&Math.abs(A-k)<1e-6?vi(r):(d=w-P,m=g-y,x=A-k,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-b*m,a=b*d-L*x,c=L*m-v*d,o=Math.sqrt(i*i+a*a+c*c),o?(o=1/o,i*=o,a*=o,c*=o):(i=0,a=0,c=0),u=m*c-x*a,h=x*i-d*c,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),r[0]=i,r[1]=u,r[2]=d,r[3]=0,r[4]=a,r[5]=h,r[6]=m,r[7]=0,r[8]=c,r[9]=p,r[10]=x,r[11]=0,r[12]=-(i*w+a*g+c*A),r[13]=-(u*w+h*g+p*A),r[14]=-(d*w+m*g+x*A),r[15]=1,r)}function bi(){let r=new W(4);return W!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0),r}function qn(r,e,t){let n=e[0],o=e[1],i=e[2],a=e[3];return r[0]=t[0]*n+t[4]*o+t[8]*i+t[12]*a,r[1]=t[1]*n+t[5]*o+t[9]*i+t[13]*a,r[2]=t[2]*n+t[6]*o+t[10]*i+t[14]*a,r[3]=t[3]*n+t[7]*o+t[11]*i+t[15]*a,r}var Ja=function(){let r=bi();return function(e,t,n,o,i,a){let c,u;for(t||(t=4),n||(n=0),o?u=Math.min(o*t+n,e.length):u=e.length,c=n;c<u;c+=t)r[0]=e[c],r[1]=e[c+1],r[2]=e[c+2],r[3]=e[c+3],i(r,r,a),e[c]=r[0],e[c+1]=r[1],e[c+2]=r[2],e[c+3]=r[3];return e}}();var ir;(function(r){r[r.COL0ROW0=0]="COL0ROW0",r[r.COL0ROW1=1]="COL0ROW1",r[r.COL0ROW2=2]="COL0ROW2",r[r.COL0ROW3=3]="COL0ROW3",r[r.COL1ROW0=4]="COL1ROW0",r[r.COL1ROW1=5]="COL1ROW1",r[r.COL1ROW2=6]="COL1ROW2",r[r.COL1ROW3=7]="COL1ROW3",r[r.COL2ROW0=8]="COL2ROW0",r[r.COL2ROW1=9]="COL2ROW1",r[r.COL2ROW2=10]="COL2ROW2",r[r.COL2ROW3=11]="COL2ROW3",r[r.COL3ROW0=12]="COL3ROW0",r[r.COL3ROW1=13]="COL3ROW1",r[r.COL3ROW2=14]="COL3ROW2",r[r.COL3ROW3=15]="COL3ROW3"})(ir||(ir={}));var Pi=45*Math.PI/180,wi=1,nr=.1,or=500,Li=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends $e{static get IDENTITY(){return Si()}static get ZERO(){return ki()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ir}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=t,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=c,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,t,n,o,i,a,c,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=t,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=c,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Li)}fromObject(e){return this.check()}fromQuaternion(e){return Dn(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:o,top:i,near:a=nr,far:c=or}=e;return c===1/0?Ni(this,t,n,o,i,a):Yn(this,t,n,o,i,a,c),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:o=[0,1,0]}=e;return Qn(this,t,n,o),this.check()}ortho(e){let{left:t,right:n,bottom:o,top:i,near:a=nr,far:c=or}=e;return Bn(this,t,n,o,i,a,c),this.check()}orthographic(e){let{fovy:t=Pi,aspect:n=wi,focalDistance:o=1,near:i=nr,far:a=or}=e;Vn(t);let c=t/2,u=o*Math.tan(c),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Vn(t),Xn(this,t,n,o,i),this.check()}determinant(){return Fn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return En(this,this),this.check()}invert(){return Mn(this,this),this.check()}multiplyLeft(e){return rr(this,e,this),this.check()}multiplyRight(e){return rr(this,this,e),this.check()}rotateX(e){return On(this,this,e),this.check()}rotateY(e){return Un(this,this,e),this.check()}rotateZ(e){return zn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Rn(this,this,e,t),this.check()}scale(e){return Cn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return In(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qn(t||[-0,-0,-0,-0],e,this),je(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,o;switch(n){case 2:o=kn(t||[-0,-0],e,this);break;case 3:o=Tn(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return je(o,e.length),o}transformAsVector(e,t){let n;switch(e.length){case 2:n=Sn(t||[-0,-0],e,this);break;case 3:n=Nn(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return je(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},Ke,Ze;function ki(){return Ke||(Ke=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ke)),Ke}function Si(){return Ze||(Ze=new ee,Object.freeze(Ze)),Ze}function Vn(r){if(r>Math.PI*2)throw Error("expected radians")}function Ni(r,e,t,n,o,i){let a=2*i/(t-e),c=2*i/(o-n),u=(t+e)/(t-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return r[0]=a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=c,r[6]=0,r[7]=0,r[8]=u,r[9]=h,r[10]=p,r[11]=d,r[12]=0,r[13]=0,r[14]=m,r[15]=0,r}var sr=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ti={modelMatrix:sr,viewMatrix:sr,projectionMatrix:sr,cameraPositionWorld:[0,0,0]};function Ei(r=Ti,e={}){let t={};return r.modelMatrix!==void 0&&(t.modelMatrix=r.modelMatrix),r.viewMatrix!==void 0&&(t.viewMatrix=r.viewMatrix),r.projectionMatrix!==void 0&&(t.projectionMatrix=r.projectionMatrix),r.cameraPositionWorld!==void 0&&(t.cameraPositionWorld=r.cameraPositionWorld),(r.projectionMatrix!==void 0||r.viewMatrix!==void 0)&&(t.viewProjectionMatrix=new ee(r.projectionMatrix).multiplyRight(r.viewMatrix)),t}var Gn=`varying vec4 project_vPositionWorld;
|
|
2465
2465
|
varying vec3 project_vNormalWorld;
|
|
2466
2466
|
vec4 project_getPosition_World() {
|
|
2467
2467
|
return project_vPositionWorld;
|
|
@@ -2469,7 +2469,7 @@ return project_vPositionWorld;
|
|
|
2469
2469
|
vec3 project_getNormal_World() {
|
|
2470
2470
|
return project_vNormalWorld;
|
|
2471
2471
|
}
|
|
2472
|
-
`,
|
|
2472
|
+
`,Mi=`${Gn}
|
|
2473
2473
|
|
|
2474
2474
|
// Unprefixed uniforms
|
|
2475
2475
|
uniform mat4 modelMatrix;
|
|
@@ -2522,8 +2522,8 @@ vec4 project_view_to_clipspace(vec3 position) {
|
|
|
2522
2522
|
vec4 project_to_clipspace(vec3 position) {
|
|
2523
2523
|
return viewProjectionMatrix * vec4(position, 1.);
|
|
2524
2524
|
}
|
|
2525
|
-
`,
|
|
2526
|
-
${
|
|
2525
|
+
`,Fi=`
|
|
2526
|
+
${Gn}`,Je={name:"project",getUniforms:Ei,vs:Mi,fs:Fi};var ar=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
2527
2527
|
struct AmbientLight {
|
|
2528
2528
|
vec3 color;
|
|
2529
2529
|
};
|
|
@@ -2548,13 +2548,13 @@ return pointLight.attenuation.x
|
|
|
2548
2548
|
+ pointLight.attenuation.z * distance * distance;
|
|
2549
2549
|
}
|
|
2550
2550
|
#endif
|
|
2551
|
-
`;var
|
|
2551
|
+
`;var Ii={lightSources:{}};function cr(r={}){let{color:e=[0,0,0],intensity:t=1}=r;return e.map(n=>n*t/255)}function Ci({ambientLight:r,pointLights:e=[],directionalLights:t=[]}){let n={};return r?n["lighting_uAmbientLight.color"]=cr(r):n["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{n[`lighting_uPointLight[${i}].color`]=cr(o),n[`lighting_uPointLight[${i}].position`]=o.position,n[`lighting_uPointLight[${i}].attenuation`]=o.attenuation||[1,0,0]}),n.lighting_uPointLightCount=e.length,t.forEach((o,i)=>{n[`lighting_uDirectionalLight[${i}].color`]=cr(o),n[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),n.lighting_uDirectionalLightCount=t.length,n}function Hn(r=Ii){if("lightSources"in r){let{ambientLight:e,pointLights:t,directionalLights:n}=r.lightSources||{};return e||t&&t.length>0||n&&n.length>0?Object.assign({},Ci({ambientLight:e,pointLights:t,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in r){let e={pointLights:[],directionalLights:[]};for(let t of r.lights||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return Hn({lightSources:e})}return{}}var te={name:"lights",vs:ar,fs:ar,getUniforms:Hn,defines:{MAX_LIGHTS:3}};var Ri={lightDirection:new Float32Array([1,1,2])};function Oi(r=Ri){let e={};return r.lightDirection&&(e.dirlight_uLightDirection=r.lightDirection),e}var Ui=`uniform vec3 dirlight_uLightDirection;
|
|
2552
2552
|
vec4 dirlight_filterColor(vec4 color) {
|
|
2553
2553
|
vec3 normal = project_getNormal_World();
|
|
2554
2554
|
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
2555
2555
|
return vec4(color.rgb * d, color.a);
|
|
2556
2556
|
}
|
|
2557
|
-
`,
|
|
2557
|
+
`,Wn={name:"dirlight",fs:Ui,getUniforms:Oi,dependencies:[Je]};var lr=`uniform float lighting_uAmbient;
|
|
2558
2558
|
uniform float lighting_uDiffuse;
|
|
2559
2559
|
uniform float lighting_uShininess;
|
|
2560
2560
|
uniform vec3 lighting_uSpecularColor;
|
|
@@ -2617,7 +2617,7 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
|
|
|
2617
2617
|
}
|
|
2618
2618
|
return lightColor;
|
|
2619
2619
|
}
|
|
2620
|
-
`;var
|
|
2620
|
+
`;var zi={};function Di(r){let{ambient:e=.35,diffuse:t=.6,shininess:n=32,specularColor:o=[30,30,30]}=r;return{lighting_uAmbient:e,lighting_uDiffuse:t,lighting_uShininess:n,lighting_uSpecularColor:o.map(i=>i/255)}}function jn(r=zi){if(!("material"in r))return{};let{material:e}=r;return e?Di(e):{lighting_uEnabled:!1}}var $n={name:"gouraud-lighting",dependencies:[te],vs:lr,defines:{LIGHTING_VERTEX:1},getUniforms:jn},Kn={name:"phong-lighting",dependencies:[te],fs:lr,defines:{LIGHTING_FRAGMENT:1},getUniforms:jn};var Zn=`uniform mat4 u_MVPMatrix;
|
|
2621
2621
|
uniform mat4 u_ModelMatrix;
|
|
2622
2622
|
uniform mat4 u_NormalMatrix;
|
|
2623
2623
|
out vec3 pbr_vPosition;
|
|
@@ -2649,7 +2649,7 @@ pbr_vUV = uv;
|
|
|
2649
2649
|
pbr_vUV = vec2(0.,0.);
|
|
2650
2650
|
#endif
|
|
2651
2651
|
}
|
|
2652
|
-
`;var
|
|
2652
|
+
`;var Jn=`precision highp float;
|
|
2653
2653
|
uniform bool pbr_uUnlit;
|
|
2654
2654
|
#ifdef USE_IBL
|
|
2655
2655
|
uniform samplerCube u_DiffuseEnvSampler;
|
|
@@ -2918,7 +2918,7 @@ color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
|
|
|
2918
2918
|
}
|
|
2919
2919
|
return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
|
|
2920
2920
|
}
|
|
2921
|
-
`;var
|
|
2921
|
+
`;var eo={name:"pbr",vs:Zn,fs:Jn,defines:{LIGHTING_FRAGMENT:1},dependencies:[te]};return lo(Pe);})();
|
|
2922
2922
|
/**
|
|
2923
2923
|
* ORIGINAL LICENCE
|
|
2924
2924
|
* @license
|