@luma.gl/shadertools 9.3.0-alpha.8 → 9.3.0-alpha.9

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 CHANGED
@@ -416,6 +416,7 @@ ${inject[key]}` : inject[key];
416
416
  }
417
417
 
418
418
  // src/lib/shader-module/shader-module-uniform-layout.ts
419
+ var GLSL_UNIFORM_BLOCK_FIELD_REGEXP = /^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;
419
420
  function getShaderModuleUniformBlockName(module) {
420
421
  return `${module.name}Uniforms`;
421
422
  }
@@ -472,9 +473,7 @@ ${inject[key]}` : inject[key];
472
473
  if (!line || line.startsWith("#")) {
473
474
  continue;
474
475
  }
475
- const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(
476
- /^(?:uniform\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/
477
- );
476
+ const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
478
477
  if (fieldMatch) {
479
478
  fieldNames.push(fieldMatch[1]);
480
479
  }
package/dist/dist.min.js CHANGED
@@ -4,7 +4,7 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var Nn=Object.create;var j=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var Tn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty;var wn=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kn=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},re=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of On(t))!Fn.call(e,o)&&o!==n&&j(e,o,{get:()=>t[o],enumerable:!(r=yn(t,o))||r.enumerable});return e},oe=(e,t,n)=>(re(e,t,"default"),n&&re(n,t,"default")),Ze=(e,t,n)=>(n=e!=null?Nn(Tn(e)):{},re(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),Dn=e=>re(j({},"__esModule",{value:!0}),e);var Je=(e,t,n)=>(wn(e,typeof t!="symbol"?t+"":t,n),n);var Ie=Bn((go,Qe)=>{Qe.exports=globalThis.luma});var ne={};kn(ne,{ShaderAssembler:()=>J,_getDependencyGraph:()=>X,_resolveModules:()=>ft,assembleGLSLShaderPair:()=>he,capitalize:()=>k,checkShaderModuleDeprecations:()=>K,combineInjects:()=>ct,convertToVec4:()=>Be,dirlight:()=>qe,fp32:()=>pn,fp64:()=>gn,fp64LowPart:()=>Q,fp64arithmetic:()=>je,fp64ify:()=>V,fp64ifyMatrix4:()=>ee,fromHalfFloat:()=>cn,generateShaderForModule:()=>Tt,getPassthroughFS:()=>Ct,getQualifierDetails:()=>It,getShaderInfo:()=>ce,getShaderModuleDependencies:()=>Y,getShaderModuleSource:()=>ue,getShaderModuleUniformBlockFields:()=>Ne,getShaderModuleUniformBlockName:()=>ae,getShaderModuleUniformLayoutValidationResult:()=>ye,getShaderModuleUniforms:()=>lt,gouraudMaterial:()=>Ye,ibl:()=>Le,initializeShaderModule:()=>ie,initializeShaderModules:()=>T,lambertMaterial:()=>Ke,lighting:()=>F,pbrMaterial:()=>Pn,phongMaterial:()=>Xe,picking:()=>mn,preprocess:()=>ge,random:()=>fn,skin:()=>dn,toHalfFloat:()=>sn,typeToChannelCount:()=>Nt,typeToChannelSuffix:()=>Pt,validateShaderModuleUniformLayout:()=>se});oe(ne,Ze(Ie(),1));function O(e,t){if(!e){let n=new Error(t||"shadertools: assertion failed.");throw Error.captureStackTrace?.(n,O),n}}var Ce={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function tt(e){let t={};for(let[n,r]of Object.entries(e))t[n]=Un(r);return t}function nt(e,t,n){let r={};for(let[o,i]of Object.entries(t))e&&o in e&&!i.private?(i.validate&&O(i.validate(e[o],i),`${n}: invalid ${o}`),r[o]=e[o]):r[o]=i.value;return r}function Un(e){let t=et(e);if(t!=="object")return{value:e,...Ce[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Ce[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=et(e.value),{...e,...Ce[t],type:t}):{type:"object",value:null};throw new Error("props")}function et(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var rt=`#ifdef MODULE_LOGDEPTH
7
+ "use strict";var __exports__=(()=>{var Nn=Object.create;var j=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var Tn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty;var wn=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kn=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},re=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of On(t))!Fn.call(e,o)&&o!==n&&j(e,o,{get:()=>t[o],enumerable:!(r=yn(t,o))||r.enumerable});return e},oe=(e,t,n)=>(re(e,t,"default"),n&&re(n,t,"default")),Ze=(e,t,n)=>(n=e!=null?Nn(Tn(e)):{},re(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),Dn=e=>re(j({},"__esModule",{value:!0}),e);var Je=(e,t,n)=>(wn(e,typeof t!="symbol"?t+"":t,n),n);var Ie=Bn((mo,Qe)=>{Qe.exports=globalThis.luma});var ne={};kn(ne,{ShaderAssembler:()=>J,_getDependencyGraph:()=>X,_resolveModules:()=>ft,assembleGLSLShaderPair:()=>he,capitalize:()=>k,checkShaderModuleDeprecations:()=>K,combineInjects:()=>ct,convertToVec4:()=>Be,dirlight:()=>qe,fp32:()=>pn,fp64:()=>gn,fp64LowPart:()=>Q,fp64arithmetic:()=>je,fp64ify:()=>V,fp64ifyMatrix4:()=>ee,fromHalfFloat:()=>cn,generateShaderForModule:()=>Tt,getPassthroughFS:()=>Ct,getQualifierDetails:()=>It,getShaderInfo:()=>ce,getShaderModuleDependencies:()=>Y,getShaderModuleSource:()=>ue,getShaderModuleUniformBlockFields:()=>Ne,getShaderModuleUniformBlockName:()=>ae,getShaderModuleUniformLayoutValidationResult:()=>ye,getShaderModuleUniforms:()=>lt,gouraudMaterial:()=>Ye,ibl:()=>Le,initializeShaderModule:()=>ie,initializeShaderModules:()=>T,lambertMaterial:()=>Ke,lighting:()=>F,pbrMaterial:()=>Pn,phongMaterial:()=>Xe,picking:()=>mn,preprocess:()=>ge,random:()=>fn,skin:()=>dn,toHalfFloat:()=>sn,typeToChannelCount:()=>Nt,typeToChannelSuffix:()=>Pt,validateShaderModuleUniformLayout:()=>se});oe(ne,Ze(Ie(),1));function O(e,t){if(!e){let n=new Error(t||"shadertools: assertion failed.");throw Error.captureStackTrace?.(n,O),n}}var Ce={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function tt(e){let t={};for(let[n,r]of Object.entries(e))t[n]=Un(r);return t}function nt(e,t,n){let r={};for(let[o,i]of Object.entries(t))e&&o in e&&!i.private?(i.validate&&O(i.validate(e[o],i),`${n}: invalid ${o}`),r[o]=e[o]):r[o]=i.value;return r}function Un(e){let t=et(e);if(t!=="object")return{value:e,...Ce[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Ce[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=et(e.value),{...e,...Ce[t],type:t}):{type:"object",value:null};throw new Error("props")}function et(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var rt=`#ifdef MODULE_LOGDEPTH
8
8
  logdepth_adjustPosition(gl_Position);
9
9
  #endif
10
10
  `,ot=`#ifdef MODULE_MATERIAL
@@ -30,8 +30,8 @@
30
30
  `;var zn={vertex:rt,fragment:ot},it=/void\s+main\s*\([^)]*\)\s*\{\n?/,at=/}\n?[^{}]*$/,Pe=[],$="__LUMA_INJECT_DECLARATIONS__";function st(e){let t={vertex:{},fragment:{}};for(let n in e){let r=e[n],o=Hn(n);typeof r=="string"&&(r={order:0,injection:r}),t[o][n]=r}return t}function Hn(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function q(e,t,n,r=!1){let o=t==="vertex";for(let i in n){let a=n[i];a.sort((c,l)=>c.order-l.order),Pe.length=a.length;for(let c=0,l=a.length;c<l;++c)Pe[c]=a[c].injection;let s=`${Pe.join(`
31
31
  `)}
32
32
  `;switch(i){case"vs:#decl":o&&(e=e.replace($,s));break;case"vs:#main-start":o&&(e=e.replace(it,c=>c+s));break;case"vs:#main-end":o&&(e=e.replace(at,c=>s+c));break;case"fs:#decl":o||(e=e.replace($,s));break;case"fs:#main-start":o||(e=e.replace(it,c=>c+s));break;case"fs:#main-end":o||(e=e.replace(at,c=>s+c));break;default:e=e.replace(i,c=>c+s)}}return e=e.replace($,""),r&&(e=e.replace(/\}\s*$/,i=>i+zn[t])),e}function ct(e){let t={};return O(Array.isArray(e)&&e.length>1),e.forEach(n=>{for(let r in n)t[r]=t[r]?`${t[r]}
33
- ${n[r]}`:n[r]}),t}function T(e){e.map(t=>ie(t))}function ie(e){if(e.instance)return;T(e.dependencies||[]);let{propTypes:t={},deprecations:n=[],inject:r={}}=e,o={normalizedInjections:st(r),parsedDeprecations:Gn(n)};t&&(o.propValidators=tt(t)),e.instance=o;let i={};t&&(i=Object.entries(t).reduce((a,[s,c])=>{let l=c?.value;return l&&(a[s]=l),a},{})),e.defaultUniforms={...e.defaultUniforms,...i}}function lt(e,t,n){ie(e);let r=n||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,r):nt(t,e.instance?.propValidators,e.name)}function K(e,t,n){e.deprecations?.forEach(r=>{r.regex?.test(t)&&(r.deprecated?n.deprecated(r.old,r.new)():n.removed(r.old,r.new)())})}function Gn(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}function Y(e){T(e);let t={},n={};X({modules:e,level:0,moduleMap:t,moduleDepth:n});let r=Object.keys(n).sort((o,i)=>n[i]-n[o]).map(o=>t[o]);return T(r),r}function X(e){let{modules:t,level:n,moduleMap:r,moduleDepth:o}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(let i of t)r[i.name]=i,(o[i.name]===void 0||o[i.name]<n)&&(o[i.name]=n);for(let i of t)i.dependencies&&X({modules:i.dependencies,level:n+1,moduleMap:r,moduleDepth:o})}function Vn(e){T(e);let t={},n={};return X({modules:e,level:0,moduleMap:t,moduleDepth:n}),e=Object.keys(n).sort((r,o)=>n[o]-n[r]).map(r=>t[r]),T(e),e}function ft(e){return Vn(e)}function ae(e){return`${e.name}Uniforms`}function Ne(e,t){let n=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!n)return null;let r=ae(e);return Wn(n,t==="wgsl"?"wgsl":"glsl",r)}function ye(e,t){let n=Object.keys(e.uniformTypes||{});if(!n.length)return null;let r=Ne(e,t);return r?{moduleName:e.name,uniformBlockName:ae(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:qn(n,r)}:null}function se(e,t,n={}){let r=ye(e,t);if(!r||r.matches)return r;let o=Kn(r);return n.log?.error?.(o,r)(),n.throwOnError!==!1&&O(!1,o),r}function Wn(e,t,n){let r=t==="wgsl"?jn(e,n):$n(e,n);if(!r)return null;let o=[];for(let i of r.split(`
34
- `)){let a=i.replace(/\/\/.*$/,"").trim();if(!a||a.startsWith("#"))continue;let s=t==="wgsl"?a.match(/^([A-Za-z0-9_]+)\s*:/):a.match(/^(?:uniform\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/);s&&o.push(s[1])}return o}function jn(e,t){let n=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!n)return null;let r=e.indexOf("{",n.index);if(r<0)return null;let o=0;for(let i=r;i<e.length;i++){let a=e[i];if(a==="{"){o++;continue}if(a==="}"&&(o--,o===0))return e.slice(r+1,i)}return null}function $n(e,t){return e.match(new RegExp(`uniform\\s+${t}\\s*\\{([\\s\\S]*?)\\}\\s*[A-Za-z0-9_]+\\s*;`,"m"))?.[1]||null}function qn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Kn(e){return`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes.
33
+ ${n[r]}`:n[r]}),t}function T(e){e.map(t=>ie(t))}function ie(e){if(e.instance)return;T(e.dependencies||[]);let{propTypes:t={},deprecations:n=[],inject:r={}}=e,o={normalizedInjections:st(r),parsedDeprecations:Gn(n)};t&&(o.propValidators=tt(t)),e.instance=o;let i={};t&&(i=Object.entries(t).reduce((a,[s,c])=>{let l=c?.value;return l&&(a[s]=l),a},{})),e.defaultUniforms={...e.defaultUniforms,...i}}function lt(e,t,n){ie(e);let r=n||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,r):nt(t,e.instance?.propValidators,e.name)}function K(e,t,n){e.deprecations?.forEach(r=>{r.regex?.test(t)&&(r.deprecated?n.deprecated(r.old,r.new)():n.removed(r.old,r.new)())})}function Gn(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}function Y(e){T(e);let t={},n={};X({modules:e,level:0,moduleMap:t,moduleDepth:n});let r=Object.keys(n).sort((o,i)=>n[i]-n[o]).map(o=>t[o]);return T(r),r}function X(e){let{modules:t,level:n,moduleMap:r,moduleDepth:o}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(let i of t)r[i.name]=i,(o[i.name]===void 0||o[i.name]<n)&&(o[i.name]=n);for(let i of t)i.dependencies&&X({modules:i.dependencies,level:n+1,moduleMap:r,moduleDepth:o})}function Vn(e){T(e);let t={},n={};return X({modules:e,level:0,moduleMap:t,moduleDepth:n}),e=Object.keys(n).sort((r,o)=>n[o]-n[r]).map(r=>t[r]),T(e),e}function ft(e){return Vn(e)}var Wn=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;function ae(e){return`${e.name}Uniforms`}function Ne(e,t){let n=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!n)return null;let r=ae(e);return jn(n,t==="wgsl"?"wgsl":"glsl",r)}function ye(e,t){let n=Object.keys(e.uniformTypes||{});if(!n.length)return null;let r=Ne(e,t);return r?{moduleName:e.name,uniformBlockName:ae(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:Kn(n,r)}:null}function se(e,t,n={}){let r=ye(e,t);if(!r||r.matches)return r;let o=Yn(r);return n.log?.error?.(o,r)(),n.throwOnError!==!1&&O(!1,o),r}function jn(e,t,n){let r=t==="wgsl"?$n(e,n):qn(e,n);if(!r)return null;let o=[];for(let i of r.split(`
34
+ `)){let a=i.replace(/\/\/.*$/,"").trim();if(!a||a.startsWith("#"))continue;let s=t==="wgsl"?a.match(/^([A-Za-z0-9_]+)\s*:/):a.match(Wn);s&&o.push(s[1])}return o}function $n(e,t){let n=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!n)return null;let r=e.indexOf("{",n.index);if(r<0)return null;let o=0;for(let i=r;i<e.length;i++){let a=e[i];if(a==="{"){o++;continue}if(a==="}"&&(o--,o===0))return e.slice(r+1,i)}return null}function qn(e,t){return e.match(new RegExp(`uniform\\s+${t}\\s*\\{([\\s\\S]*?)\\}\\s*[A-Za-z0-9_]+\\s*;`,"m"))?.[1]||null}function Kn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yn(e){return`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes.
35
35
  Expected: ${e.expectedUniformNames.join(", ")}
36
36
  Actual: ${e.actualUniformNames.join(", ")}`}function pt(e){switch(e?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
37
37
  // Apple optimizes away the calculation necessary for emulated fp64
@@ -57,15 +57,15 @@ Actual: ${e.actualUniformNames.join(", ")}`}function pt(e){switch(e?.gpu.toLower
57
57
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
58
58
  // If the GPU doesn't have full 32 bits precision, will causes overflow
59
59
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
60
- `}}function ut(e,t){if(Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return e=ht(e,Yn),e;case"fragment":return e=ht(e,Xn),e;default:throw new Error(t)}}var gt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
61
- `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Yn=[...gt,[Oe("attribute"),"in $1"],[Oe("varying"),"out $1"]],Xn=[...gt,[Oe("varying"),"in $1"]];function ht(e,t){for(let[n,r]of t)e=e.replace(n,r);return e}function Oe(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Te(e,t){let n="";for(let r in e){let o=e[r];if(n+=`void ${o.signature} {
60
+ `}}function ut(e,t){if(Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return e=ht(e,Xn),e;case"fragment":return e=ht(e,Zn),e;default:throw new Error(t)}}var gt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
61
+ `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Xn=[...gt,[Oe("attribute"),"in $1"],[Oe("varying"),"out $1"]],Zn=[...gt,[Oe("varying"),"in $1"]];function ht(e,t){for(let[n,r]of t)e=e.replace(n,r);return e}function Oe(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Te(e,t){let n="";for(let r in e){let o=e[r];if(n+=`void ${o.signature} {
62
62
  `,o.header&&(n+=` ${o.header}`),t[r]){let i=t[r];i.sort((a,s)=>a.order-s.order);for(let a of i)n+=` ${a.injection}
63
63
  `}o.footer&&(n+=` ${o.footer}`),n+=`}
64
- `}return n}function Fe(e){let t={vertex:{},fragment:{}};for(let n of e){let r,o;typeof n!="string"?(r=n,o=r.hook):(r={},o=n),o=o.trim();let[i,a]=o.split(":"),s=o.replace(/\(.+/,""),c=Object.assign(r,{signature:a});switch(i){case"vs":t.vertex[s]=c;break;case"fs":t.fragment[s]=c;break;default:throw new Error(i)}}return t}function ce(e,t){return{name:Zn(e,t),language:"glsl",version:Jn(e)}}function Zn(e,t="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return r?r[1]:t}function Jn(e){let t=100,n=e.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]==="#version"){let r=parseInt(n[1],10);Number.isFinite(r)&&(t=r)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}var mt=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g];function le(e,t=[]){let n=new Map;for(let o of t)n.set(dt(o.name,o.group,o.location),o.moduleName);let r=[];for(let o of mt){o.lastIndex=0;let i;for(;i=o.exec(e);){let a=o===mt[0],s=Number(i[a?1:2]),c=Number(i[a?2:1]),l=i[3]?.trim(),p=i[4],f=i[5].trim(),h=n.get(dt(p,c,s));r.push(Qn({name:p,group:c,binding:s,owner:h?"module":"application",moduleName:h,accessDeclaration:l,resourceType:f}))}}return r.sort((o,i)=>o.group!==i.group?o.group-i.group:o.binding!==i.binding?o.binding-i.binding:o.name.localeCompare(i.name))}function Qn(e){let t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){let n=e.accessDeclaration.split(",").map(r=>r.trim());if(n[0]==="uniform")return{...t,kind:"uniform",access:"uniform"};if(n[0]==="storage"){let r=n[1]||"read_write";return{...t,kind:r==="read"?"read-only-storage":"storage",access:r}}}return e.resourceType==="sampler"||e.resourceType==="sampler_comparison"?{...t,kind:"sampler",samplerKind:e.resourceType==="sampler_comparison"?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:tr(e.resourceType),viewDimension:_t(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:_t(e.resourceType),sampleType:er(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function dt(e,t,n){return`${t}:${n}:${e}`}function _t(e){if(e.includes("cube_array"))return"cube-array";if(e.includes("2d_array"))return"2d-array";if(e.includes("cube"))return"cube";if(e.includes("3d"))return"3d";if(e.includes("2d"))return"2d";if(e.includes("1d"))return"1d"}function er(e){if(e.startsWith("texture_depth_"))return"depth";if(e.includes("<i32>"))return"sint";if(e.includes("<u32>"))return"uint";if(e.includes("<f32>"))return"float"}function tr(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var Lt=`
64
+ `}return n}function Fe(e){let t={vertex:{},fragment:{}};for(let n of e){let r,o;typeof n!="string"?(r=n,o=r.hook):(r={},o=n),o=o.trim();let[i,a]=o.split(":"),s=o.replace(/\(.+/,""),c=Object.assign(r,{signature:a});switch(i){case"vs":t.vertex[s]=c;break;case"fs":t.fragment[s]=c;break;default:throw new Error(i)}}return t}function ce(e,t){return{name:Jn(e,t),language:"glsl",version:Qn(e)}}function Jn(e,t="unnamed"){let r=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return r?r[1]:t}function Qn(e){let t=100,n=e.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]==="#version"){let r=parseInt(n[1],10);Number.isFinite(r)&&(t=r)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}var mt=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g];function le(e,t=[]){let n=new Map;for(let o of t)n.set(dt(o.name,o.group,o.location),o.moduleName);let r=[];for(let o of mt){o.lastIndex=0;let i;for(;i=o.exec(e);){let a=o===mt[0],s=Number(i[a?1:2]),c=Number(i[a?2:1]),l=i[3]?.trim(),p=i[4],f=i[5].trim(),h=n.get(dt(p,c,s));r.push(er({name:p,group:c,binding:s,owner:h?"module":"application",moduleName:h,accessDeclaration:l,resourceType:f}))}}return r.sort((o,i)=>o.group!==i.group?o.group-i.group:o.binding!==i.binding?o.binding-i.binding:o.name.localeCompare(i.name))}function er(e){let t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){let n=e.accessDeclaration.split(",").map(r=>r.trim());if(n[0]==="uniform")return{...t,kind:"uniform",access:"uniform"};if(n[0]==="storage"){let r=n[1]||"read_write";return{...t,kind:r==="read"?"read-only-storage":"storage",access:r}}}return e.resourceType==="sampler"||e.resourceType==="sampler_comparison"?{...t,kind:"sampler",samplerKind:e.resourceType==="sampler_comparison"?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:nr(e.resourceType),viewDimension:_t(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:_t(e.resourceType),sampleType:tr(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function dt(e,t,n){return`${t}:${n}:${e}`}function _t(e){if(e.includes("cube_array"))return"cube-array";if(e.includes("2d_array"))return"2d-array";if(e.includes("cube"))return"cube";if(e.includes("3d"))return"3d";if(e.includes("2d"))return"2d";if(e.includes("1d"))return"1d"}function tr(e){if(e.startsWith("texture_depth_"))return"depth";if(e.includes("<i32>"))return"sint";if(e.includes("<u32>"))return"uint";if(e.includes("<f32>"))return"float"}function nr(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var Lt=`
65
65
 
66
66
  ${$}
67
- `,fe=[/@binding\(\s*(auto|\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(auto|\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],bt=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],Z=100,nr=`precision highp float;
68
- `;function At(e){let t=Y(e.modules||[]),{source:n,bindingAssignments:r}=rr(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:n,getUniforms:Et(t),bindingAssignments:r,bindingTable:le(n,r)}}function he(e){let{vs:t,fs:n}=e,r=Y(e.modules||[]);return{vs:vt(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:vt(e.platformInfo,{...e,source:n,stage:"fragment",modules:r}),getUniforms:Et(r)}}function rr(e,t){let{source:n,stage:r,modules:o,hookFunctions:i=[],inject:a={},log:s}=t;O(typeof n=="string","shader source must be a string");let c=n,l="",p=Fe(i),f={},h={},g={};for(let M in a){let b=typeof a[M]=="string"?{injection:a[M],order:0}:a[M],S=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(S){let v=S[2],u=S[3];v?u==="decl"?h[M]=[b]:g[M]=[b]:f[M]=[b]}else g[M]=[b]}let _=o,m=ir(c),x=cr(_,t._bindingRegistry,m),d=[];for(let M of _){s&&K(M,c,s);let b=ar(ue(M,"wgsl",s),M,{usedBindingsByGroup:m,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:x});d.push(...b.bindingAssignments);let S=b.source;l+=S;let v=M.injections?.[r]||{};for(let u in v){let E=/^(v|f)s:#([\w-]+)$/.exec(u);if(E){let L=E[2]==="decl"?h:g;L[u]=L[u]||[],L[u].push(v[u])}else f[u]=f[u]||[],f[u].push(v[u])}}return l+=Lt,l=q(l,r,h),l+=Te(p[r],f),l+=ur(d),l+=c,l=q(l,r,g),hr(l),{source:l,bindingAssignments:d}}function vt(e,t){let{source:n,stage:r,language:o="glsl",modules:i,defines:a={},hookFunctions:s=[],inject:c={},prologue:l=!0,log:p}=t;O(typeof n=="string","shader source must be a string");let f=o==="glsl"?ce(n).version:-1,h=e.shaderLanguageVersion,g=f===100?"#version 100":"#version 300 es",m=n.split(`
67
+ `,fe=[/@binding\(\s*(auto|\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(auto|\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],bt=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],Z=100,rr=`precision highp float;
68
+ `;function At(e){let t=Y(e.modules||[]),{source:n,bindingAssignments:r}=or(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:n,getUniforms:Et(t),bindingAssignments:r,bindingTable:le(n,r)}}function he(e){let{vs:t,fs:n}=e,r=Y(e.modules||[]);return{vs:vt(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:vt(e.platformInfo,{...e,source:n,stage:"fragment",modules:r}),getUniforms:Et(r)}}function or(e,t){let{source:n,stage:r,modules:o,hookFunctions:i=[],inject:a={},log:s}=t;O(typeof n=="string","shader source must be a string");let c=n,l="",p=Fe(i),f={},h={},g={};for(let M in a){let b=typeof a[M]=="string"?{injection:a[M],order:0}:a[M],S=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(S){let v=S[2],u=S[3];v?u==="decl"?h[M]=[b]:g[M]=[b]:f[M]=[b]}else g[M]=[b]}let _=o,m=ar(c),x=lr(_,t._bindingRegistry,m),d=[];for(let M of _){s&&K(M,c,s);let b=sr(ue(M,"wgsl",s),M,{usedBindingsByGroup:m,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:x});d.push(...b.bindingAssignments);let S=b.source;l+=S;let v=M.injections?.[r]||{};for(let u in v){let E=/^(v|f)s:#([\w-]+)$/.exec(u);if(E){let L=E[2]==="decl"?h:g;L[u]=L[u]||[],L[u].push(v[u])}else f[u]=f[u]||[],f[u].push(v[u])}}return l+=Lt,l=q(l,r,h),l+=Te(p[r],f),l+=gr(d),l+=c,l=q(l,r,g),ur(l),{source:l,bindingAssignments:d}}function vt(e,t){let{source:n,stage:r,language:o="glsl",modules:i,defines:a={},hookFunctions:s=[],inject:c={},prologue:l=!0,log:p}=t;O(typeof n=="string","shader source must be a string");let f=o==="glsl"?ce(n).version:-1,h=e.shaderLanguageVersion,g=f===100?"#version 100":"#version 300 es",m=n.split(`
69
69
  `).slice(1).join(`
70
70
  `),x={};i.forEach(u=>{Object.assign(x,u.defines)}),Object.assign(x,a);let d="";switch(o){case"wgsl":break;case"glsl":d=l?`${g}
71
71
 
@@ -73,42 +73,42 @@ ${$}
73
73
  ${`#define SHADER_TYPE_${r.toUpperCase()}`}
74
74
 
75
75
  ${pt(e)}
76
- ${r==="fragment"?nr:""}
76
+ ${r==="fragment"?rr:""}
77
77
 
78
78
  // ----- APPLICATION DEFINES -------------------------
79
79
 
80
- ${or(x)}
80
+ ${ir(x)}
81
81
 
82
82
  `:`${g}
83
- `;break}let M=Fe(s),b={},S={},v={};for(let u in c){let E=typeof c[u]=="string"?{injection:c[u],order:0}:c[u],R=/^(v|f)s:(#)?([\w-]+)$/.exec(u);if(R){let L=R[2],I=R[3];L?I==="decl"?S[u]=[E]:v[u]=[E]:b[u]=[E]}else v[u]=[E]}for(let u of i){p&&K(u,m,p);let E=ue(u,r,p);d+=E;let R=u.instance?.normalizedInjections[r]||{};for(let L in R){let I=/^(v|f)s:#([\w-]+)$/.exec(L);if(I){let C=I[2]==="decl"?S:v;C[L]=C[L]||[],C[L].push(R[L])}else b[L]=b[L]||[],b[L].push(R[L])}}return d+="// ----- MAIN SHADER SOURCE -------------------------",d+=Lt,d=q(d,r,S),d+=Te(M[r],b),d+=m,d=q(d,r,v),o==="glsl"&&f!==h&&(d=ut(d,r)),d.trim()}function Et(e){return function(n){let r={};for(let o of e){let i=o.getUniforms?.(n,r);Object.assign(r,i)}return r}}function or(e={}){let t="";for(let n in e){let r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}
83
+ `;break}let M=Fe(s),b={},S={},v={};for(let u in c){let E=typeof c[u]=="string"?{injection:c[u],order:0}:c[u],R=/^(v|f)s:(#)?([\w-]+)$/.exec(u);if(R){let L=R[2],I=R[3];L?I==="decl"?S[u]=[E]:v[u]=[E]:b[u]=[E]}else v[u]=[E]}for(let u of i){p&&K(u,m,p);let E=ue(u,r,p);d+=E;let R=u.instance?.normalizedInjections[r]||{};for(let L in R){let I=/^(v|f)s:#([\w-]+)$/.exec(L);if(I){let C=I[2]==="decl"?S:v;C[L]=C[L]||[],C[L].push(R[L])}else b[L]=b[L]||[],b[L].push(R[L])}}return d+="// ----- MAIN SHADER SOURCE -------------------------",d+=Lt,d=q(d,r,S),d+=Te(M[r],b),d+=m,d=q(d,r,v),o==="glsl"&&f!==h&&(d=ut(d,r)),d.trim()}function Et(e){return function(n){let r={};for(let o of e){let i=o.getUniforms?.(n,r);Object.assign(r,i)}return r}}function ir(e={}){let t="";for(let n in e){let r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}
84
84
  `)}return t}function ue(e,t,n){let r;switch(t){case"vertex":r=e.vs||"";break;case"fragment":r=e.fs||"";break;case"wgsl":r=e.source||"";break;default:O(!1)}if(!e.name)throw new Error("Shader module must have a name");se(e,t,{log:n});let o=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),i=`// ----- MODULE ${e.name} ---------------
85
85
 
86
86
  `;return t!=="wgsl"&&(i+=`#define MODULE_${o}
87
87
  `),i+=`${r}
88
- `,i}function ir(e){let t=new Map;for(let n of bt){n.lastIndex=0;let r;for(;r=n.exec(e);){let o=n===bt[0],i=Number(r[o?1:2]),a=Number(r[o?2:1]),s=r[4];pr(a,i,s),pe(t,a,i,`application binding "${s}"`)}}return t}function ar(e,t,n){let r=[],o={sawSupportedBindingDeclaration:!1,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},i=St(e,fe[0],{isBindingFirst:!0,module:t,context:n,bindingAssignments:r,relocationState:o});if(i=St(i,fe[1],{isBindingFirst:!1,module:t,context:n,bindingAssignments:r,relocationState:o}),e.includes("@binding(auto)")&&!o.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use "@group(N) @binding(auto) var ..." or "@binding(auto) @group(N) var ..." on a single line.`);return{source:i,bindingAssignments:r}}function St(e,t,n){return e.replace(t,(...r)=>sr(r,n))}function sr(e,t){let{isBindingFirst:n,module:r,context:o,bindingAssignments:i,relocationState:a}=t;a.sawSupportedBindingDeclaration=!0;let s=e[0],c=e[n?1:2],l=e[n?2:1],p=e[4],f=Number(l);if(c==="auto"){let g=Rt(f,r.name,p),_=o.bindingRegistry?.get(g),m=_!==void 0?_:a.nextHintedBindingLocation===null?Mt(f,o.usedBindingsByGroup):Mt(f,o.usedBindingsByGroup,a.nextHintedBindingLocation);return xt(r.name,f,m,p),_!==void 0&&lr(o.reservedBindingKeysByGroup,f,m,g)?(i.push({moduleName:r.name,name:p,group:f,location:m}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(pe(o.usedBindingsByGroup,f,m,`module "${r.name}" binding "${p}"`),o.bindingRegistry?.set(g,m),i.push({moduleName:r.name,name:p,group:f,location:m}),a.nextHintedBindingLocation!==null&&_===void 0&&(a.nextHintedBindingLocation=m+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}let h=Number(c);return xt(r.name,f,h,p),pe(o.usedBindingsByGroup,f,h,`module "${r.name}" binding "${p}"`),i.push({moduleName:r.name,name:p,group:f,location:h}),s}function cr(e,t,n){let r=new Map;if(!t)return r;for(let o of e)for(let i of fr(o)){let a=Rt(i.group,o.name,i.name),s=t.get(a);if(s!==void 0){let c=r.get(i.group)||new Map,l=c.get(s);if(l&&l!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${a}": group ${i.group}, binding ${s}.`);pe(n,i.group,s,`registered module binding "${a}"`),c.set(s,a),r.set(i.group,c)}}return r}function lr(e,t,n,r){let o=e.get(t);if(!o)return!1;let i=o.get(n);if(!i)return!1;if(i!==r)throw new Error(`Registered module binding "${r}" collided with "${i}": group ${t}, binding ${n}.`);return!0}function fr(e){let t=[],n=e.source||"";for(let r of fe){r.lastIndex=0;let o;for(;o=r.exec(n);){let i=r===fe[0];t.push({name:o[4],group:Number(o[i?2:1])})}}return t}function pr(e,t,n){if(e===0&&t>=Z)throw new Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${Z}.`)}function xt(e,t,n,r){if(t===0&&n<Z)throw new Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be ${Z} or higher.`)}function pe(e,t,n,r){let o=e.get(t)||new Set;if(o.has(n))throw new Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);o.add(n),e.set(t,o)}function Mt(e,t,n){let r=t.get(e)||new Set,o=n??(e===0?Z:r.size>0?Math.max(...r)+1:0);for(;r.has(o);)o++;return o}function hr(e){if(/@binding\(\s*auto\s*\)/.test(e))throw new Error("Unresolved @binding(auto) remained in assembled WGSL source.")}function ur(e){if(e.length===0)return"";let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
88
+ `,i}function ar(e){let t=new Map;for(let n of bt){n.lastIndex=0;let r;for(;r=n.exec(e);){let o=n===bt[0],i=Number(r[o?1:2]),a=Number(r[o?2:1]),s=r[4];hr(a,i,s),pe(t,a,i,`application binding "${s}"`)}}return t}function sr(e,t,n){let r=[],o={sawSupportedBindingDeclaration:!1,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},i=St(e,fe[0],{isBindingFirst:!0,module:t,context:n,bindingAssignments:r,relocationState:o});if(i=St(i,fe[1],{isBindingFirst:!1,module:t,context:n,bindingAssignments:r,relocationState:o}),e.includes("@binding(auto)")&&!o.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use "@group(N) @binding(auto) var ..." or "@binding(auto) @group(N) var ..." on a single line.`);return{source:i,bindingAssignments:r}}function St(e,t,n){return e.replace(t,(...r)=>cr(r,n))}function cr(e,t){let{isBindingFirst:n,module:r,context:o,bindingAssignments:i,relocationState:a}=t;a.sawSupportedBindingDeclaration=!0;let s=e[0],c=e[n?1:2],l=e[n?2:1],p=e[4],f=Number(l);if(c==="auto"){let g=Rt(f,r.name,p),_=o.bindingRegistry?.get(g),m=_!==void 0?_:a.nextHintedBindingLocation===null?Mt(f,o.usedBindingsByGroup):Mt(f,o.usedBindingsByGroup,a.nextHintedBindingLocation);return xt(r.name,f,m,p),_!==void 0&&fr(o.reservedBindingKeysByGroup,f,m,g)?(i.push({moduleName:r.name,name:p,group:f,location:m}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(pe(o.usedBindingsByGroup,f,m,`module "${r.name}" binding "${p}"`),o.bindingRegistry?.set(g,m),i.push({moduleName:r.name,name:p,group:f,location:m}),a.nextHintedBindingLocation!==null&&_===void 0&&(a.nextHintedBindingLocation=m+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}let h=Number(c);return xt(r.name,f,h,p),pe(o.usedBindingsByGroup,f,h,`module "${r.name}" binding "${p}"`),i.push({moduleName:r.name,name:p,group:f,location:h}),s}function lr(e,t,n){let r=new Map;if(!t)return r;for(let o of e)for(let i of pr(o)){let a=Rt(i.group,o.name,i.name),s=t.get(a);if(s!==void 0){let c=r.get(i.group)||new Map,l=c.get(s);if(l&&l!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${a}": group ${i.group}, binding ${s}.`);pe(n,i.group,s,`registered module binding "${a}"`),c.set(s,a),r.set(i.group,c)}}return r}function fr(e,t,n,r){let o=e.get(t);if(!o)return!1;let i=o.get(n);if(!i)return!1;if(i!==r)throw new Error(`Registered module binding "${r}" collided with "${i}": group ${t}, binding ${n}.`);return!0}function pr(e){let t=[],n=e.source||"";for(let r of fe){r.lastIndex=0;let o;for(;o=r.exec(n);){let i=r===fe[0];t.push({name:o[4],group:Number(o[i?2:1])})}}return t}function hr(e,t,n){if(e===0&&t>=Z)throw new Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${Z}.`)}function xt(e,t,n,r){if(t===0&&n<Z)throw new Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be ${Z} or higher.`)}function pe(e,t,n,r){let o=e.get(t)||new Set;if(o.has(n))throw new Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);o.add(n),e.set(t,o)}function Mt(e,t,n){let r=t.get(e)||new Set,o=n??(e===0?Z:r.size>0?Math.max(...r)+1:0);for(;r.has(o);)o++;return o}function ur(e){if(/@binding\(\s*auto\s*\)/.test(e))throw new Error("Unresolved @binding(auto) remained in assembled WGSL source.")}function gr(e){if(e.length===0)return"";let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
89
89
  `;for(let n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})
90
90
  `;return t+=`
91
- `,t}function Rt(e,t,n){return`${e}:${t}:${n}`}var we="([a-zA-Z_][a-zA-Z0-9_]*)",gr=new RegExp(`^\\s*\\#\\s*ifdef\\s*${we}\\s*$`),mr=new RegExp(`^\\s*\\#\\s*ifndef\\s*${we}\\s*(?:\\/\\/.*)?$`),dr=/^\s*\#\s*else\s*(?:\/\/.*)?$/,_r=/^\s*\#\s*endif\s*$/,br=new RegExp(`^\\s*\\#\\s*ifdef\\s*${we}\\s*(?:\\/\\/.*)?$`),vr=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function ge(e,t){let n=e.split(`
92
- `),r=[],o=[],i=!0;for(let a of n){let s=a.match(br)||a.match(gr),c=a.match(mr),l=a.match(dr),p=a.match(vr)||a.match(_r);if(s||c){let f=(s||c)?.[1],h=Boolean(t?.defines?.[f]),g=s?h:!h,_=i&&g;o.push({parentActive:i,branchTaken:g,active:_}),i=_}else if(l){let f=o[o.length-1];if(!f)throw new Error("Encountered #else without matching #ifdef or #ifndef");f.active=f.parentActive&&!f.branchTaken,f.branchTaken=!0,i=f.active}else p?(o.pop(),i=o.length?o[o.length-1].active:!0):i&&r.push(a)}if(o.length>0)throw new Error("Unterminated conditional block in shader source");return r.join(`
93
- `)}var z=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return z.defaultShaderAssembler=z.defaultShaderAssembler||new z,z.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(n=>n.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let n=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==n)}addShaderHook(t,n){n&&(t=Object.assign(n,{hook:t})),this._hookFunctions.push(t)}assembleWGSLShader(t){let n=this._getModuleList(t.modules),r=this._hookFunctions,{source:o,getUniforms:i,bindingAssignments:a}=At({...t,source:t.source,_bindingRegistry:this._wgslBindingRegistry,modules:n,hookFunctions:r}),s={...n.reduce((l,p)=>(Object.assign(l,p.defines),l),{}),...t.defines},c=t.platformInfo.shaderLanguage==="wgsl"?ge(o,{defines:s}):o;return{source:c,getUniforms:i,modules:n,bindingAssignments:a,bindingTable:le(c,a)}}assembleGLSLShaderPair(t){let n=this._getModuleList(t.modules),r=this._hookFunctions;return{...he({...t,vs:t.vs,fs:t.fs,modules:n,hookFunctions:r}),modules:n}}_getModuleList(t=[]){let n=new Array(this._defaultModules.length+t.length),r={},o=0;for(let i=0,a=this._defaultModules.length;i<a;++i){let s=this._defaultModules[i],c=s.name;n[o++]=s,r[c]=!0}for(let i=0,a=t.length;i<a;++i){let s=t[i],c=s.name;r[c]||(n[o++]=s,r[c]=!0)}return n.length=o,T(n),n}},J=z;Je(J,"defaultShaderAssembler");var Sr=`out vec4 transform_output;
91
+ `,t}function Rt(e,t,n){return`${e}:${t}:${n}`}var we="([a-zA-Z_][a-zA-Z0-9_]*)",mr=new RegExp(`^\\s*\\#\\s*ifdef\\s*${we}\\s*$`),dr=new RegExp(`^\\s*\\#\\s*ifndef\\s*${we}\\s*(?:\\/\\/.*)?$`),_r=/^\s*\#\s*else\s*(?:\/\/.*)?$/,br=/^\s*\#\s*endif\s*$/,vr=new RegExp(`^\\s*\\#\\s*ifdef\\s*${we}\\s*(?:\\/\\/.*)?$`),Sr=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function ge(e,t){let n=e.split(`
92
+ `),r=[],o=[],i=!0;for(let a of n){let s=a.match(vr)||a.match(mr),c=a.match(dr),l=a.match(_r),p=a.match(Sr)||a.match(br);if(s||c){let f=(s||c)?.[1],h=Boolean(t?.defines?.[f]),g=s?h:!h,_=i&&g;o.push({parentActive:i,branchTaken:g,active:_}),i=_}else if(l){let f=o[o.length-1];if(!f)throw new Error("Encountered #else without matching #ifdef or #ifndef");f.active=f.parentActive&&!f.branchTaken,f.branchTaken=!0,i=f.active}else p?(o.pop(),i=o.length?o[o.length-1].active:!0):i&&r.push(a)}if(o.length>0)throw new Error("Unterminated conditional block in shader source");return r.join(`
93
+ `)}var z=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return z.defaultShaderAssembler=z.defaultShaderAssembler||new z,z.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(n=>n.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let n=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(r=>r.name!==n)}addShaderHook(t,n){n&&(t=Object.assign(n,{hook:t})),this._hookFunctions.push(t)}assembleWGSLShader(t){let n=this._getModuleList(t.modules),r=this._hookFunctions,{source:o,getUniforms:i,bindingAssignments:a}=At({...t,source:t.source,_bindingRegistry:this._wgslBindingRegistry,modules:n,hookFunctions:r}),s={...n.reduce((l,p)=>(Object.assign(l,p.defines),l),{}),...t.defines},c=t.platformInfo.shaderLanguage==="wgsl"?ge(o,{defines:s}):o;return{source:c,getUniforms:i,modules:n,bindingAssignments:a,bindingTable:le(c,a)}}assembleGLSLShaderPair(t){let n=this._getModuleList(t.modules),r=this._hookFunctions;return{...he({...t,vs:t.vs,fs:t.fs,modules:n,hookFunctions:r}),modules:n}}_getModuleList(t=[]){let n=new Array(this._defaultModules.length+t.length),r={},o=0;for(let i=0,a=this._defaultModules.length;i<a;++i){let s=this._defaultModules[i],c=s.name;n[o++]=s,r[c]=!0}for(let i=0,a=t.length;i<a;++i){let s=t[i],c=s.name;r[c]||(n[o++]=s,r[c]=!0)}return n.length=o,T(n),n}},J=z;Je(J,"defaultShaderAssembler");var xr=`out vec4 transform_output;
94
94
  void main() {
95
95
  transform_output = vec4(0);
96
- }`,xr=`#version 300 es
97
- ${Sr}`;function It(e,t){t=Array.isArray(t)?t:[t];let n=e.replace(/^\s+/,"").split(/\s+/),[r,o,i]=n;if(!t.includes(r)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:r,type:o,name:a}}function Ct(e){let{input:t,inputChannels:n,output:r}=e||{};if(!t)return xr;if(!n)throw new Error("inputChannels");let o=Mr(n),i=Be(t,n);return`#version 300 es
96
+ }`,Mr=`#version 300 es
97
+ ${xr}`;function It(e,t){t=Array.isArray(t)?t:[t];let n=e.replace(/^\s+/,"").split(/\s+/),[r,o,i]=n;if(!t.includes(r)||!o||!i)return null;let a=i.split(";")[0];return{qualifier:r,type:o,name:a}}function Ct(e){let{input:t,inputChannels:n,output:r}=e||{};if(!t)return Mr;if(!n)throw new Error("inputChannels");let o=Lr(n),i=Be(t,n);return`#version 300 es
98
98
  in ${o} ${t};
99
99
  out vec4 ${r};
100
100
  void main() {
101
101
  ${r} = ${i};
102
- }`}function Pt(e){switch(e){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(e)}}function Nt(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(e)}}function Mr(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}function Be(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}function k(e){return typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):e}function yt(e,t){return Lr(e,t)}function Lr(e,t){let n=[];switch(t.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":n.push(`uniform ${k(e.name)} {`);break;case"uniforms":}for(let[r,o]of Object.entries(e.uniformTypes||{})){if(typeof o!="string")throw new Error(`Composite uniform types are not supported by GLSL shader generation: ${e.name}.${r}`);let i=Ar(o);switch(t.uniforms){case"scoped-interface-blocks":n.push(` ${i} ${r};`);break;case"unscoped-interface-blocks":n.push(` ${i} ${e.name}_${r};`);break;case"uniforms":n.push(`uniform ${i} ${e.name}_${r};`)}}switch(t.uniforms){case"scoped-interface-blocks":n.push(`} ${e.name};`);break;case"unscoped-interface-blocks":n.push("};");break;case"uniforms":}return n.push(""),n.join(`
103
- `)}function Ar(e){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"}[e]}function Ot(e,t){return Er(e,t)}function Er(e,t){let n=[];n.push(`struct ${k(e.name)} {`);for(let[r,o]of Object.entries(e?.uniformTypes||{})){if(typeof o!="string")throw new Error(`Composite uniform types are not supported by WGSL shader generation: ${e.name}.${r}`);let i=o;n.push(` ${r} : ${i};`)}return n.push("};"),n.push(`var<uniform> ${e.name} : ${k(e.name)};`),n.join(`
104
- `)}function Tt(e,t){switch(t.shaderLanguage){case"glsl":return yt(e,t);case"wgsl":return Ot(e,t)}}var ci=1/Math.PI*180,li=1/180*Math.PI,Rr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Rr}};var P=globalThis.mathgl.config;function ke(e,{precision:t=P.precision}={}){return e=Ir(e),`${parseFloat(e.toPrecision(t))}`}function H(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function De(e,t,n){return Pr(e,r=>Math.max(t,Math.min(n,r)))}function me(e,t,n){let r=P.EPSILON;n&&(P.EPSILON=n);try{if(e===t)return!0;if(H(e)&&H(t)){if(e.length!==t.length)return!1;for(let o=0;o<e.length;++o)if(!me(e[o],t[o]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=P.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{P.EPSILON=r}}function Ir(e){return Math.round(e/P.EPSILON)*P.EPSILON}function Cr(e){return e.clone?e.clone():new Array(e.length)}function Pr(e,t,n){if(H(e)){let r=e;n=n||Cr(r);for(let o=0;o<n.length&&o<r.length;++o){let i=typeof e=="number"?e:e[o];n[o]=t(i,o,n)}return n}return t(e)}var de=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:H(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(P)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+ke(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!me(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let o=0;o<this.ELEMENTS;++o){let i=t[o],a=typeof n=="number"?n:n[o];this[o]=i+r*(a-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(P.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function Nr(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function Ft(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function _e(e,t,n=""){if(P.debug&&!Nr(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}var w=typeof Float32Array<"u"?Float32Array:Array;var mi=Math.PI/180;function yr(){let e=new w(2);return w!=Float32Array&&(e[0]=0,e[1]=0),e}function kt(e,t,n){let r=t[0],o=t[1];return e[0]=n[0]*r+n[4]*o+n[12],e[1]=n[1]*r+n[5]*o+n[13],e}var di=function(){let e=yr();return function(t,n,r,o,i,a){let s,c;for(n||(n=2),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],i(e,e,a),t[s]=e[0],t[s+1]=e[1];return t}}();function Dt(e,t,n){let r=t[0],o=t[1],i=n[3]*r+n[7]*o||1;return e[0]=(n[0]*r+n[4]*o)/i,e[1]=(n[1]*r+n[5]*o)/i,e}function Ut(e,t,n){let r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i||1;return e[0]=(n[0]*r+n[4]*o+n[8]*i)/a,e[1]=(n[1]*r+n[5]*o+n[9]*i)/a,e[2]=(n[2]*r+n[6]*o+n[10]*i)/a,e}function Or(){let e=new w(3);return w!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function zt(e,t,n){let r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}var vi=function(){let e=Or();return function(t,n,r,o,i,a){let s,c;for(n||(n=3),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],i(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}();var be=class extends de{toString(){let t="[";if(P.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=Ft(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let o=0;o<this.RANK;++o)n[o]=this[r+o];return n}setColumn(t,n){let r=t*this.RANK;for(let o=0;o<this.RANK;++o)this[r+o]=n[o];return this}};function Tr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ht(e,t){if(e===t){let n=t[1],r=t[2],o=t[3],i=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=o,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Gt(e,t){let n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],p=t[8],f=t[9],h=t[10],g=t[11],_=t[12],m=t[13],x=t[14],d=t[15],M=n*s-r*a,b=n*c-o*a,S=n*l-i*a,v=r*c-o*s,u=r*l-i*s,E=o*l-i*c,R=p*m-f*_,L=p*x-h*_,I=p*d-g*_,N=f*x-h*m,C=f*d-g*m,y=h*d-g*x,A=M*y-b*C+S*N+v*I-u*L+E*R;return A?(A=1/A,e[0]=(s*y-c*C+l*N)*A,e[1]=(o*C-r*y-i*N)*A,e[2]=(m*E-x*u+d*v)*A,e[3]=(h*u-f*E-g*v)*A,e[4]=(c*I-a*y-l*L)*A,e[5]=(n*y-o*I+i*L)*A,e[6]=(x*S-_*E-d*b)*A,e[7]=(p*E-h*S+g*b)*A,e[8]=(a*C-s*I+l*R)*A,e[9]=(r*I-n*C-i*R)*A,e[10]=(_*u-m*S+d*M)*A,e[11]=(f*S-p*u-g*M)*A,e[12]=(s*L-a*N-c*R)*A,e[13]=(n*N-r*L+o*R)*A,e[14]=(m*b-_*v-x*M)*A,e[15]=(p*v-f*b+h*M)*A,e):null}function Vt(e){let t=e[0],n=e[1],r=e[2],o=e[3],i=e[4],a=e[5],s=e[6],c=e[7],l=e[8],p=e[9],f=e[10],h=e[11],g=e[12],_=e[13],m=e[14],x=e[15],d=t*a-n*i,M=t*s-r*i,b=n*s-r*a,S=l*_-p*g,v=l*m-f*g,u=p*m-f*_,E=t*u-n*v+r*S,R=i*u-a*v+s*S,L=l*b-p*M+f*d,I=g*b-_*M+m*d;return c*E-o*R+x*L-h*I}function ze(e,t,n){let r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],c=t[5],l=t[6],p=t[7],f=t[8],h=t[9],g=t[10],_=t[11],m=t[12],x=t[13],d=t[14],M=t[15],b=n[0],S=n[1],v=n[2],u=n[3];return e[0]=b*r+S*s+v*f+u*m,e[1]=b*o+S*c+v*h+u*x,e[2]=b*i+S*l+v*g+u*d,e[3]=b*a+S*p+v*_+u*M,b=n[4],S=n[5],v=n[6],u=n[7],e[4]=b*r+S*s+v*f+u*m,e[5]=b*o+S*c+v*h+u*x,e[6]=b*i+S*l+v*g+u*d,e[7]=b*a+S*p+v*_+u*M,b=n[8],S=n[9],v=n[10],u=n[11],e[8]=b*r+S*s+v*f+u*m,e[9]=b*o+S*c+v*h+u*x,e[10]=b*i+S*l+v*g+u*d,e[11]=b*a+S*p+v*_+u*M,b=n[12],S=n[13],v=n[14],u=n[15],e[12]=b*r+S*s+v*f+u*m,e[13]=b*o+S*c+v*h+u*x,e[14]=b*i+S*l+v*g+u*d,e[15]=b*a+S*p+v*_+u*M,e}function Wt(e,t,n){let r=n[0],o=n[1],i=n[2],a,s,c,l,p,f,h,g,_,m,x,d;return t===e?(e[12]=t[0]*r+t[4]*o+t[8]*i+t[12],e[13]=t[1]*r+t[5]*o+t[9]*i+t[13],e[14]=t[2]*r+t[6]*o+t[10]*i+t[14],e[15]=t[3]*r+t[7]*o+t[11]*i+t[15]):(a=t[0],s=t[1],c=t[2],l=t[3],p=t[4],f=t[5],h=t[6],g=t[7],_=t[8],m=t[9],x=t[10],d=t[11],e[0]=a,e[1]=s,e[2]=c,e[3]=l,e[4]=p,e[5]=f,e[6]=h,e[7]=g,e[8]=_,e[9]=m,e[10]=x,e[11]=d,e[12]=a*r+p*o+_*i+t[12],e[13]=s*r+f*o+m*i+t[13],e[14]=c*r+h*o+x*i+t[14],e[15]=l*r+g*o+d*i+t[15]),e}function jt(e,t,n){let r=n[0],o=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*o,e[5]=t[5]*o,e[6]=t[6]*o,e[7]=t[7]*o,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function $t(e,t,n,r){let o=r[0],i=r[1],a=r[2],s=Math.sqrt(o*o+i*i+a*a),c,l,p,f,h,g,_,m,x,d,M,b,S,v,u,E,R,L,I,N,C,y,A,W;return s<1e-6?null:(s=1/s,o*=s,i*=s,a*=s,l=Math.sin(n),c=Math.cos(n),p=1-c,f=t[0],h=t[1],g=t[2],_=t[3],m=t[4],x=t[5],d=t[6],M=t[7],b=t[8],S=t[9],v=t[10],u=t[11],E=o*o*p+c,R=i*o*p+a*l,L=a*o*p-i*l,I=o*i*p-a*l,N=i*i*p+c,C=a*i*p+o*l,y=o*a*p+i*l,A=i*a*p-o*l,W=a*a*p+c,e[0]=f*E+m*R+b*L,e[1]=h*E+x*R+S*L,e[2]=g*E+d*R+v*L,e[3]=_*E+M*R+u*L,e[4]=f*I+m*N+b*C,e[5]=h*I+x*N+S*C,e[6]=g*I+d*N+v*C,e[7]=_*I+M*N+u*C,e[8]=f*y+m*A+b*W,e[9]=h*y+x*A+S*W,e[10]=g*y+d*A+v*W,e[11]=_*y+M*A+u*W,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function qt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[4],a=t[5],s=t[6],c=t[7],l=t[8],p=t[9],f=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*o+l*r,e[5]=a*o+p*r,e[6]=s*o+f*r,e[7]=c*o+h*r,e[8]=l*o-i*r,e[9]=p*o-a*r,e[10]=f*o-s*r,e[11]=h*o-c*r,e}function Kt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[0],a=t[1],s=t[2],c=t[3],l=t[8],p=t[9],f=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*o-l*r,e[1]=a*o-p*r,e[2]=s*o-f*r,e[3]=c*o-h*r,e[8]=i*r+l*o,e[9]=a*r+p*o,e[10]=s*r+f*o,e[11]=c*r+h*o,e}function Yt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[0],a=t[1],s=t[2],c=t[3],l=t[4],p=t[5],f=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*o+l*r,e[1]=a*o+p*r,e[2]=s*o+f*r,e[3]=c*o+h*r,e[4]=l*o-i*r,e[5]=p*o-a*r,e[6]=f*o-s*r,e[7]=h*o-c*r,e}function Xt(e,t){let n=t[0],r=t[1],o=t[2],i=t[3],a=n+n,s=r+r,c=o+o,l=n*a,p=r*a,f=r*s,h=o*a,g=o*s,_=o*c,m=i*a,x=i*s,d=i*c;return e[0]=1-f-_,e[1]=p+d,e[2]=h-x,e[3]=0,e[4]=p-d,e[5]=1-l-_,e[6]=g+m,e[7]=0,e[8]=h+x,e[9]=g-m,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Zt(e,t,n,r,o,i,a){let s=1/(n-t),c=1/(o-r),l=1/(i-a);return e[0]=i*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*c,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(o+r)*c,e[10]=(a+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*i*2*l,e[15]=0,e}function Fr(e,t,n,r,o){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,o!=null&&o!==1/0){let a=1/(r-o);e[10]=(o+r)*a,e[14]=2*o*r*a}else e[10]=-1,e[14]=-2*r;return e}var Jt=Fr;function wr(e,t,n,r,o,i,a){let s=1/(t-n),c=1/(r-o),l=1/(i-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(o+r)*c,e[14]=(a+i)*l,e[15]=1,e}var Qt=wr;function en(e,t,n,r){let o,i,a,s,c,l,p,f,h,g,_=t[0],m=t[1],x=t[2],d=r[0],M=r[1],b=r[2],S=n[0],v=n[1],u=n[2];return Math.abs(_-S)<1e-6&&Math.abs(m-v)<1e-6&&Math.abs(x-u)<1e-6?Tr(e):(f=_-S,h=m-v,g=x-u,o=1/Math.sqrt(f*f+h*h+g*g),f*=o,h*=o,g*=o,i=M*g-b*h,a=b*f-d*g,s=d*h-M*f,o=Math.sqrt(i*i+a*a+s*s),o?(o=1/o,i*=o,a*=o,s*=o):(i=0,a=0,s=0),c=h*s-g*a,l=g*i-f*s,p=f*a-h*i,o=Math.sqrt(c*c+l*l+p*p),o?(o=1/o,c*=o,l*=o,p*=o):(c=0,l=0,p=0),e[0]=i,e[1]=c,e[2]=f,e[3]=0,e[4]=a,e[5]=l,e[6]=h,e[7]=0,e[8]=s,e[9]=p,e[10]=g,e[11]=0,e[12]=-(i*_+a*m+s*x),e[13]=-(c*_+l*m+p*x),e[14]=-(f*_+h*m+g*x),e[15]=1,e)}function Br(){let e=new w(4);return w!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function tn(e,t,n){let r=t[0],o=t[1],i=t[2],a=t[3];return e[0]=n[0]*r+n[4]*o+n[8]*i+n[12]*a,e[1]=n[1]*r+n[5]*o+n[9]*i+n[13]*a,e[2]=n[2]*r+n[6]*o+n[10]*i+n[14]*a,e[3]=n[3]*r+n[7]*o+n[11]*i+n[15]*a,e}var Ri=function(){let e=Br();return function(t,n,r,o,i,a){let s,c;for(n||(n=4),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],i(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var Ve;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Ve||(Ve={}));var kr=45*Math.PI/180,Dr=1,He=.1,Ge=500,Ur=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),B=class extends be{static get IDENTITY(){return Hr()}static get ZERO(){return zr()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ve}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,o,i,a,s,c,l,p,f,h,g,_,m,x){return this[0]=t,this[1]=n,this[2]=r,this[3]=o,this[4]=i,this[5]=a,this[6]=s,this[7]=c,this[8]=l,this[9]=p,this[10]=f,this[11]=h,this[12]=g,this[13]=_,this[14]=m,this[15]=x,this.check()}setRowMajor(t,n,r,o,i,a,s,c,l,p,f,h,g,_,m,x){return this[0]=t,this[1]=i,this[2]=l,this[3]=g,this[4]=n,this[5]=a,this[6]=p,this[7]=_,this[8]=r,this[9]=s,this[10]=f,this[11]=m,this[12]=o,this[13]=c,this[14]=h,this[15]=x,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Ur)}fromObject(t){return this.check()}fromQuaternion(t){return Xt(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:o,top:i,near:a=He,far:s=Ge}=t;return s===1/0?Gr(this,n,r,o,i,a):Zt(this,n,r,o,i,a,s),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:o=[0,1,0]}=t;return en(this,n,r,o),this.check()}ortho(t){let{left:n,right:r,bottom:o,top:i,near:a=He,far:s=Ge}=t;return Qt(this,n,r,o,i,a,s),this.check()}orthographic(t){let{fovy:n=kr,aspect:r=Dr,focalDistance:o=1,near:i=He,far:a=Ge}=t;nn(n);let s=n/2,c=o*Math.tan(s),l=c*r;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:a})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:o=.1,far:i=500}=t;return nn(n),Jt(this,n,r,o,i),this.check()}determinant(){return Vt(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),o=1/r[0],i=1/r[1],a=1/r[2];return t[0]=this[0]*o,t[1]=this[1]*i,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*o,t[5]=this[5]*i,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*o,t[9]=this[9]*i,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),o=1/r[0],i=1/r[1],a=1/r[2];return t[0]=this[0]*o,t[1]=this[1]*i,t[2]=this[2]*a,t[3]=this[4]*o,t[4]=this[5]*i,t[5]=this[6]*a,t[6]=this[8]*o,t[7]=this[9]*i,t[8]=this[10]*a,t}transpose(){return Ht(this,this),this.check()}invert(){return Gt(this,this),this.check()}multiplyLeft(t){return ze(this,t,this),this.check()}multiplyRight(t){return ze(this,this,t),this.check()}rotateX(t){return qt(this,this,t),this.check()}rotateY(t){return Kt(this,this,t),this.check()}rotateZ(t){return Yt(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return $t(this,this,t,n),this.check()}scale(t){return jt(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Wt(this,this,t),this.check()}transform(t,n){return t.length===4?(n=tn(n||[-0,-0,-0,-0],t,this),_e(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,o;switch(r){case 2:o=kt(n||[-0,-0],t,this);break;case 3:o=zt(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return _e(o,t.length),o}transformAsVector(t,n){let r;switch(t.length){case 2:r=Dt(n||[-0,-0],t,this);break;case 3:r=Ut(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return _e(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},ve,Se;function zr(){return ve||(ve=new B([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ve)),ve}function Hr(){return Se||(Se=new B,Object.freeze(Se)),Se}function nn(e){if(e>Math.PI*2)throw Error("expected radians")}function Gr(e,t,n,r,o,i){let a=2*i/(n-t),s=2*i/(o-r),c=(n+t)/(n-t),l=(o+r)/(o-r),p=-1,f=-1,h=-2*i;return e[0]=a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=p,e[11]=f,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}var D=null,rn=new ArrayBuffer(4),on=new Float32Array(rn),an=new Uint32Array(rn);function sn(e){D||=ln(),e=De(e,-65504,65504),on[0]=e;let t=an[0],n=t>>23&511;return D.baseTable[n]+((t&8388607)>>D.shiftTable[n])}function cn(e){D||=ln();let t=e>>10;return an[0]=D.mantissaTable[D.offsetTable[t]+(e&1023)]+D.exponentTable[t],on[0]}function ln(){let e=new Uint32Array(512),t=new Uint32Array(512);for(let i=0;i<256;++i){let a=i-127;a<-27?(e[i]=0,e[i|256]=32768,t[i]=24,t[i|256]=24):a<-14?(e[i]=1024>>-a-14,e[i|256]=1024>>-a-14|32768,t[i]=-a-1,t[i|256]=-a-1):a<=15?(e[i]=a+15<<10,e[i|256]=a+15<<10|32768,t[i]=13,t[i|256]=13):a<128?(e[i]=31744,e[i|256]=64512,t[i]=24,t[i|256]=24):(e[i]=31744,e[i|256]=64512,t[i]=13,t[i|256]=13)}let n=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let i=1;i<1024;++i){let a=i<<13,s=0;for(;!(a&8388608);)a<<=1,s-=8388608;a&=-8388609,s+=947912704,n[i]=a|s}for(let i=1024;i<2048;++i)n[i]=939524096+(i-1024<<13);for(let i=1;i<31;++i)r[i]=i<<23;r[31]=1199570944,r[32]=2147483648;for(let i=33;i<63;++i)r[i]=2147483648+(i-32<<23);r[63]=3347054592;for(let i=1;i<64;++i)i!==32&&(o[i]=1024);return{baseTable:e,shiftTable:t,mantissaTable:n,exponentTable:r,offsetTable:o}}function V(e,t=[],n=0){let r=Math.fround(e),o=e-r;return t[n]=r,t[n+1]=o,t}function Q(e){return e-Math.fround(e)}function ee(e){let t=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let o=n*4+r;V(e[r*4+n],t,o*2)}return t}var Vr=`fn random(scale: vec3f, seed: f32) -> f32 {
102
+ }`}function Pt(e){switch(e){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:throw new Error(e)}}function Nt(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:throw new Error(e)}}function Lr(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}function Be(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}function k(e){return typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):e}function yt(e,t){return Ar(e,t)}function Ar(e,t){let n=[];switch(t.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":n.push(`uniform ${k(e.name)} {`);break;case"uniforms":}for(let[r,o]of Object.entries(e.uniformTypes||{})){if(typeof o!="string")throw new Error(`Composite uniform types are not supported by GLSL shader generation: ${e.name}.${r}`);let i=Er(o);switch(t.uniforms){case"scoped-interface-blocks":n.push(` ${i} ${r};`);break;case"unscoped-interface-blocks":n.push(` ${i} ${e.name}_${r};`);break;case"uniforms":n.push(`uniform ${i} ${e.name}_${r};`)}}switch(t.uniforms){case"scoped-interface-blocks":n.push(`} ${e.name};`);break;case"unscoped-interface-blocks":n.push("};");break;case"uniforms":}return n.push(""),n.join(`
103
+ `)}function Er(e){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"}[e]}function Ot(e,t){return Rr(e,t)}function Rr(e,t){let n=[];n.push(`struct ${k(e.name)} {`);for(let[r,o]of Object.entries(e?.uniformTypes||{})){if(typeof o!="string")throw new Error(`Composite uniform types are not supported by WGSL shader generation: ${e.name}.${r}`);let i=o;n.push(` ${r} : ${i};`)}return n.push("};"),n.push(`var<uniform> ${e.name} : ${k(e.name)};`),n.join(`
104
+ `)}function Tt(e,t){switch(t.shaderLanguage){case"glsl":return yt(e,t);case"wgsl":return Ot(e,t)}}var li=1/Math.PI*180,fi=1/180*Math.PI,Ir={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Ir}};var P=globalThis.mathgl.config;function ke(e,{precision:t=P.precision}={}){return e=Cr(e),`${parseFloat(e.toPrecision(t))}`}function H(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function De(e,t,n){return Nr(e,r=>Math.max(t,Math.min(n,r)))}function me(e,t,n){let r=P.EPSILON;n&&(P.EPSILON=n);try{if(e===t)return!0;if(H(e)&&H(t)){if(e.length!==t.length)return!1;for(let o=0;o<e.length;++o)if(!me(e[o],t[o]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=P.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{P.EPSILON=r}}function Cr(e){return Math.round(e/P.EPSILON)*P.EPSILON}function Pr(e){return e.clone?e.clone():new Array(e.length)}function Nr(e,t,n){if(H(e)){let r=e;n=n||Pr(r);for(let o=0;o<n.length&&o<r.length;++o){let i=typeof e=="number"?e:e[o];n[o]=t(i,o,n)}return n}return t(e)}var de=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:H(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(P)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+ke(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!me(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let o=0;o<this.ELEMENTS;++o){let i=t[o],a=typeof n=="number"?n:n[o];this[o]=i+r*(a-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(P.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function yr(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function Ft(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function _e(e,t,n=""){if(P.debug&&!yr(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}var w=typeof Float32Array<"u"?Float32Array:Array;var di=Math.PI/180;function Or(){let e=new w(2);return w!=Float32Array&&(e[0]=0,e[1]=0),e}function kt(e,t,n){let r=t[0],o=t[1];return e[0]=n[0]*r+n[4]*o+n[12],e[1]=n[1]*r+n[5]*o+n[13],e}var _i=function(){let e=Or();return function(t,n,r,o,i,a){let s,c;for(n||(n=2),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],i(e,e,a),t[s]=e[0],t[s+1]=e[1];return t}}();function Dt(e,t,n){let r=t[0],o=t[1],i=n[3]*r+n[7]*o||1;return e[0]=(n[0]*r+n[4]*o)/i,e[1]=(n[1]*r+n[5]*o)/i,e}function Ut(e,t,n){let r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i||1;return e[0]=(n[0]*r+n[4]*o+n[8]*i)/a,e[1]=(n[1]*r+n[5]*o+n[9]*i)/a,e[2]=(n[2]*r+n[6]*o+n[10]*i)/a,e}function Tr(){let e=new w(3);return w!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function zt(e,t,n){let r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}var Si=function(){let e=Tr();return function(t,n,r,o,i,a){let s,c;for(n||(n=3),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],i(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}();var be=class extends de{toString(){let t="[";if(P.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=Ft(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let o=0;o<this.RANK;++o)n[o]=this[r+o];return n}setColumn(t,n){let r=t*this.RANK;for(let o=0;o<this.RANK;++o)this[r+o]=n[o];return this}};function Fr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ht(e,t){if(e===t){let n=t[1],r=t[2],o=t[3],i=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=o,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Gt(e,t){let n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],p=t[8],f=t[9],h=t[10],g=t[11],_=t[12],m=t[13],x=t[14],d=t[15],M=n*s-r*a,b=n*c-o*a,S=n*l-i*a,v=r*c-o*s,u=r*l-i*s,E=o*l-i*c,R=p*m-f*_,L=p*x-h*_,I=p*d-g*_,N=f*x-h*m,C=f*d-g*m,y=h*d-g*x,A=M*y-b*C+S*N+v*I-u*L+E*R;return A?(A=1/A,e[0]=(s*y-c*C+l*N)*A,e[1]=(o*C-r*y-i*N)*A,e[2]=(m*E-x*u+d*v)*A,e[3]=(h*u-f*E-g*v)*A,e[4]=(c*I-a*y-l*L)*A,e[5]=(n*y-o*I+i*L)*A,e[6]=(x*S-_*E-d*b)*A,e[7]=(p*E-h*S+g*b)*A,e[8]=(a*C-s*I+l*R)*A,e[9]=(r*I-n*C-i*R)*A,e[10]=(_*u-m*S+d*M)*A,e[11]=(f*S-p*u-g*M)*A,e[12]=(s*L-a*N-c*R)*A,e[13]=(n*N-r*L+o*R)*A,e[14]=(m*b-_*v-x*M)*A,e[15]=(p*v-f*b+h*M)*A,e):null}function Vt(e){let t=e[0],n=e[1],r=e[2],o=e[3],i=e[4],a=e[5],s=e[6],c=e[7],l=e[8],p=e[9],f=e[10],h=e[11],g=e[12],_=e[13],m=e[14],x=e[15],d=t*a-n*i,M=t*s-r*i,b=n*s-r*a,S=l*_-p*g,v=l*m-f*g,u=p*m-f*_,E=t*u-n*v+r*S,R=i*u-a*v+s*S,L=l*b-p*M+f*d,I=g*b-_*M+m*d;return c*E-o*R+x*L-h*I}function ze(e,t,n){let r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],c=t[5],l=t[6],p=t[7],f=t[8],h=t[9],g=t[10],_=t[11],m=t[12],x=t[13],d=t[14],M=t[15],b=n[0],S=n[1],v=n[2],u=n[3];return e[0]=b*r+S*s+v*f+u*m,e[1]=b*o+S*c+v*h+u*x,e[2]=b*i+S*l+v*g+u*d,e[3]=b*a+S*p+v*_+u*M,b=n[4],S=n[5],v=n[6],u=n[7],e[4]=b*r+S*s+v*f+u*m,e[5]=b*o+S*c+v*h+u*x,e[6]=b*i+S*l+v*g+u*d,e[7]=b*a+S*p+v*_+u*M,b=n[8],S=n[9],v=n[10],u=n[11],e[8]=b*r+S*s+v*f+u*m,e[9]=b*o+S*c+v*h+u*x,e[10]=b*i+S*l+v*g+u*d,e[11]=b*a+S*p+v*_+u*M,b=n[12],S=n[13],v=n[14],u=n[15],e[12]=b*r+S*s+v*f+u*m,e[13]=b*o+S*c+v*h+u*x,e[14]=b*i+S*l+v*g+u*d,e[15]=b*a+S*p+v*_+u*M,e}function Wt(e,t,n){let r=n[0],o=n[1],i=n[2],a,s,c,l,p,f,h,g,_,m,x,d;return t===e?(e[12]=t[0]*r+t[4]*o+t[8]*i+t[12],e[13]=t[1]*r+t[5]*o+t[9]*i+t[13],e[14]=t[2]*r+t[6]*o+t[10]*i+t[14],e[15]=t[3]*r+t[7]*o+t[11]*i+t[15]):(a=t[0],s=t[1],c=t[2],l=t[3],p=t[4],f=t[5],h=t[6],g=t[7],_=t[8],m=t[9],x=t[10],d=t[11],e[0]=a,e[1]=s,e[2]=c,e[3]=l,e[4]=p,e[5]=f,e[6]=h,e[7]=g,e[8]=_,e[9]=m,e[10]=x,e[11]=d,e[12]=a*r+p*o+_*i+t[12],e[13]=s*r+f*o+m*i+t[13],e[14]=c*r+h*o+x*i+t[14],e[15]=l*r+g*o+d*i+t[15]),e}function jt(e,t,n){let r=n[0],o=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*o,e[5]=t[5]*o,e[6]=t[6]*o,e[7]=t[7]*o,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function $t(e,t,n,r){let o=r[0],i=r[1],a=r[2],s=Math.sqrt(o*o+i*i+a*a),c,l,p,f,h,g,_,m,x,d,M,b,S,v,u,E,R,L,I,N,C,y,A,W;return s<1e-6?null:(s=1/s,o*=s,i*=s,a*=s,l=Math.sin(n),c=Math.cos(n),p=1-c,f=t[0],h=t[1],g=t[2],_=t[3],m=t[4],x=t[5],d=t[6],M=t[7],b=t[8],S=t[9],v=t[10],u=t[11],E=o*o*p+c,R=i*o*p+a*l,L=a*o*p-i*l,I=o*i*p-a*l,N=i*i*p+c,C=a*i*p+o*l,y=o*a*p+i*l,A=i*a*p-o*l,W=a*a*p+c,e[0]=f*E+m*R+b*L,e[1]=h*E+x*R+S*L,e[2]=g*E+d*R+v*L,e[3]=_*E+M*R+u*L,e[4]=f*I+m*N+b*C,e[5]=h*I+x*N+S*C,e[6]=g*I+d*N+v*C,e[7]=_*I+M*N+u*C,e[8]=f*y+m*A+b*W,e[9]=h*y+x*A+S*W,e[10]=g*y+d*A+v*W,e[11]=_*y+M*A+u*W,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function qt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[4],a=t[5],s=t[6],c=t[7],l=t[8],p=t[9],f=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*o+l*r,e[5]=a*o+p*r,e[6]=s*o+f*r,e[7]=c*o+h*r,e[8]=l*o-i*r,e[9]=p*o-a*r,e[10]=f*o-s*r,e[11]=h*o-c*r,e}function Kt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[0],a=t[1],s=t[2],c=t[3],l=t[8],p=t[9],f=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*o-l*r,e[1]=a*o-p*r,e[2]=s*o-f*r,e[3]=c*o-h*r,e[8]=i*r+l*o,e[9]=a*r+p*o,e[10]=s*r+f*o,e[11]=c*r+h*o,e}function Yt(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=t[0],a=t[1],s=t[2],c=t[3],l=t[4],p=t[5],f=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*o+l*r,e[1]=a*o+p*r,e[2]=s*o+f*r,e[3]=c*o+h*r,e[4]=l*o-i*r,e[5]=p*o-a*r,e[6]=f*o-s*r,e[7]=h*o-c*r,e}function Xt(e,t){let n=t[0],r=t[1],o=t[2],i=t[3],a=n+n,s=r+r,c=o+o,l=n*a,p=r*a,f=r*s,h=o*a,g=o*s,_=o*c,m=i*a,x=i*s,d=i*c;return e[0]=1-f-_,e[1]=p+d,e[2]=h-x,e[3]=0,e[4]=p-d,e[5]=1-l-_,e[6]=g+m,e[7]=0,e[8]=h+x,e[9]=g-m,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Zt(e,t,n,r,o,i,a){let s=1/(n-t),c=1/(o-r),l=1/(i-a);return e[0]=i*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*c,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(o+r)*c,e[10]=(a+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*i*2*l,e[15]=0,e}function wr(e,t,n,r,o){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,o!=null&&o!==1/0){let a=1/(r-o);e[10]=(o+r)*a,e[14]=2*o*r*a}else e[10]=-1,e[14]=-2*r;return e}var Jt=wr;function Br(e,t,n,r,o,i,a){let s=1/(t-n),c=1/(r-o),l=1/(i-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(o+r)*c,e[14]=(a+i)*l,e[15]=1,e}var Qt=Br;function en(e,t,n,r){let o,i,a,s,c,l,p,f,h,g,_=t[0],m=t[1],x=t[2],d=r[0],M=r[1],b=r[2],S=n[0],v=n[1],u=n[2];return Math.abs(_-S)<1e-6&&Math.abs(m-v)<1e-6&&Math.abs(x-u)<1e-6?Fr(e):(f=_-S,h=m-v,g=x-u,o=1/Math.sqrt(f*f+h*h+g*g),f*=o,h*=o,g*=o,i=M*g-b*h,a=b*f-d*g,s=d*h-M*f,o=Math.sqrt(i*i+a*a+s*s),o?(o=1/o,i*=o,a*=o,s*=o):(i=0,a=0,s=0),c=h*s-g*a,l=g*i-f*s,p=f*a-h*i,o=Math.sqrt(c*c+l*l+p*p),o?(o=1/o,c*=o,l*=o,p*=o):(c=0,l=0,p=0),e[0]=i,e[1]=c,e[2]=f,e[3]=0,e[4]=a,e[5]=l,e[6]=h,e[7]=0,e[8]=s,e[9]=p,e[10]=g,e[11]=0,e[12]=-(i*_+a*m+s*x),e[13]=-(c*_+l*m+p*x),e[14]=-(f*_+h*m+g*x),e[15]=1,e)}function kr(){let e=new w(4);return w!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function tn(e,t,n){let r=t[0],o=t[1],i=t[2],a=t[3];return e[0]=n[0]*r+n[4]*o+n[8]*i+n[12]*a,e[1]=n[1]*r+n[5]*o+n[9]*i+n[13]*a,e[2]=n[2]*r+n[6]*o+n[10]*i+n[14]*a,e[3]=n[3]*r+n[7]*o+n[11]*i+n[15]*a,e}var Ii=function(){let e=kr();return function(t,n,r,o,i,a){let s,c;for(n||(n=4),r||(r=0),o?c=Math.min(o*n+r,t.length):c=t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],i(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var Ve;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Ve||(Ve={}));var Dr=45*Math.PI/180,Ur=1,He=.1,Ge=500,zr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),B=class extends be{static get IDENTITY(){return Gr()}static get ZERO(){return Hr()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ve}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,o,i,a,s,c,l,p,f,h,g,_,m,x){return this[0]=t,this[1]=n,this[2]=r,this[3]=o,this[4]=i,this[5]=a,this[6]=s,this[7]=c,this[8]=l,this[9]=p,this[10]=f,this[11]=h,this[12]=g,this[13]=_,this[14]=m,this[15]=x,this.check()}setRowMajor(t,n,r,o,i,a,s,c,l,p,f,h,g,_,m,x){return this[0]=t,this[1]=i,this[2]=l,this[3]=g,this[4]=n,this[5]=a,this[6]=p,this[7]=_,this[8]=r,this[9]=s,this[10]=f,this[11]=m,this[12]=o,this[13]=c,this[14]=h,this[15]=x,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(zr)}fromObject(t){return this.check()}fromQuaternion(t){return Xt(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:o,top:i,near:a=He,far:s=Ge}=t;return s===1/0?Vr(this,n,r,o,i,a):Zt(this,n,r,o,i,a,s),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:o=[0,1,0]}=t;return en(this,n,r,o),this.check()}ortho(t){let{left:n,right:r,bottom:o,top:i,near:a=He,far:s=Ge}=t;return Qt(this,n,r,o,i,a,s),this.check()}orthographic(t){let{fovy:n=Dr,aspect:r=Ur,focalDistance:o=1,near:i=He,far:a=Ge}=t;nn(n);let s=n/2,c=o*Math.tan(s),l=c*r;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:a})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:o=.1,far:i=500}=t;return nn(n),Jt(this,n,r,o,i),this.check()}determinant(){return Vt(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),o=1/r[0],i=1/r[1],a=1/r[2];return t[0]=this[0]*o,t[1]=this[1]*i,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*o,t[5]=this[5]*i,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*o,t[9]=this[9]*i,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),o=1/r[0],i=1/r[1],a=1/r[2];return t[0]=this[0]*o,t[1]=this[1]*i,t[2]=this[2]*a,t[3]=this[4]*o,t[4]=this[5]*i,t[5]=this[6]*a,t[6]=this[8]*o,t[7]=this[9]*i,t[8]=this[10]*a,t}transpose(){return Ht(this,this),this.check()}invert(){return Gt(this,this),this.check()}multiplyLeft(t){return ze(this,t,this),this.check()}multiplyRight(t){return ze(this,this,t),this.check()}rotateX(t){return qt(this,this,t),this.check()}rotateY(t){return Kt(this,this,t),this.check()}rotateZ(t){return Yt(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return $t(this,this,t,n),this.check()}scale(t){return jt(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Wt(this,this,t),this.check()}transform(t,n){return t.length===4?(n=tn(n||[-0,-0,-0,-0],t,this),_e(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,o;switch(r){case 2:o=kt(n||[-0,-0],t,this);break;case 3:o=zt(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return _e(o,t.length),o}transformAsVector(t,n){let r;switch(t.length){case 2:r=Dt(n||[-0,-0],t,this);break;case 3:r=Ut(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return _e(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},ve,Se;function Hr(){return ve||(ve=new B([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ve)),ve}function Gr(){return Se||(Se=new B,Object.freeze(Se)),Se}function nn(e){if(e>Math.PI*2)throw Error("expected radians")}function Vr(e,t,n,r,o,i){let a=2*i/(n-t),s=2*i/(o-r),c=(n+t)/(n-t),l=(o+r)/(o-r),p=-1,f=-1,h=-2*i;return e[0]=a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=p,e[11]=f,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}var D=null,rn=new ArrayBuffer(4),on=new Float32Array(rn),an=new Uint32Array(rn);function sn(e){D||=ln(),e=De(e,-65504,65504),on[0]=e;let t=an[0],n=t>>23&511;return D.baseTable[n]+((t&8388607)>>D.shiftTable[n])}function cn(e){D||=ln();let t=e>>10;return an[0]=D.mantissaTable[D.offsetTable[t]+(e&1023)]+D.exponentTable[t],on[0]}function ln(){let e=new Uint32Array(512),t=new Uint32Array(512);for(let i=0;i<256;++i){let a=i-127;a<-27?(e[i]=0,e[i|256]=32768,t[i]=24,t[i|256]=24):a<-14?(e[i]=1024>>-a-14,e[i|256]=1024>>-a-14|32768,t[i]=-a-1,t[i|256]=-a-1):a<=15?(e[i]=a+15<<10,e[i|256]=a+15<<10|32768,t[i]=13,t[i|256]=13):a<128?(e[i]=31744,e[i|256]=64512,t[i]=24,t[i|256]=24):(e[i]=31744,e[i|256]=64512,t[i]=13,t[i|256]=13)}let n=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let i=1;i<1024;++i){let a=i<<13,s=0;for(;!(a&8388608);)a<<=1,s-=8388608;a&=-8388609,s+=947912704,n[i]=a|s}for(let i=1024;i<2048;++i)n[i]=939524096+(i-1024<<13);for(let i=1;i<31;++i)r[i]=i<<23;r[31]=1199570944,r[32]=2147483648;for(let i=33;i<63;++i)r[i]=2147483648+(i-32<<23);r[63]=3347054592;for(let i=1;i<64;++i)i!==32&&(o[i]=1024);return{baseTable:e,shiftTable:t,mantissaTable:n,exponentTable:r,offsetTable:o}}function V(e,t=[],n=0){let r=Math.fround(e),o=e-r;return t[n]=r,t[n+1]=o,t}function Q(e){return e-Math.fround(e)}function ee(e){let t=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let o=n*4+r;V(e[r*4+n],t,o*2)}return t}var Wr=`fn random(scale: vec3f, seed: f32) -> f32 {
105
105
  return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);
106
106
  }
107
- `,Wr=`float random(vec3 scale, float seed) {
107
+ `,jr=`float random(vec3 scale, float seed) {
108
108
  /* use the fragment position for a different seed per-pixel */
109
109
  return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
110
110
  }
111
- `,fn={name:"random",source:Vr,fs:Wr};var jr=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
111
+ `,fn={name:"random",source:Wr,fs:jr};var $r=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
112
112
 
113
113
  // All these functions are for substituting tan() function from Intel GPU only
114
114
  const float TWO_PI = 6.2831854820251465;
@@ -258,7 +258,7 @@ float tan_fp32(float a) {
258
258
  return tan(a);
259
259
  #endif
260
260
  }
261
- `,pn={name:"fp32",vs:jr};var We=`
261
+ `,pn={name:"fp32",vs:$r};var We=`
262
262
  uniform fp64arithmeticUniforms {
263
263
  uniform float ONE;
264
264
  uniform float SPLIT;
@@ -1332,7 +1332,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
1332
1332
  vec4_dot_fp64(a, tmp, out_val[i]);
1333
1333
  }
1334
1334
  }
1335
- `;var $r={ONE:1,SPLIT:4097},je={name:"fp64arithmetic",source:hn,fs:We,vs:We,defaultUniforms:$r,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:V,fp64LowPart:Q,fp64ifyMatrix4:ee},gn={name:"fp64",vs:un,dependencies:[je],fp64ify:V,fp64LowPart:Q,fp64ifyMatrix4:ee};var qr=[0,1,1,1],Kr=`uniform pickingUniforms {
1335
+ `;var qr={ONE:1,SPLIT:4097},je={name:"fp64arithmetic",source:hn,fs:We,vs:We,defaultUniforms:qr,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:V,fp64LowPart:Q,fp64ifyMatrix4:ee},gn={name:"fp64",vs:un,dependencies:[je],fp64ify:V,fp64LowPart:Q,fp64ifyMatrix4:ee};var Kr=[0,1,1,1],Yr=`uniform pickingUniforms {
1336
1336
  float isActive;
1337
1337
  float isAttribute;
1338
1338
  float isHighlightActive;
@@ -1403,7 +1403,7 @@ void picking_setPickingAttribute(vec3 value) {
1403
1403
  picking_vRGBcolor_Avalid.rgb = value;
1404
1404
  }
1405
1405
  }
1406
- `,Yr=`uniform pickingUniforms {
1406
+ `,Xr=`uniform pickingUniforms {
1407
1407
  float isActive;
1408
1408
  float isAttribute;
1409
1409
  float isHighlightActive;
@@ -1459,7 +1459,7 @@ vec4 picking_filterColor(vec4 color) {
1459
1459
  vec4 highlightColor = picking_filterHighlightColor(color);
1460
1460
  return picking_filterPickingColor(highlightColor);
1461
1461
  }
1462
- `,mn={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:qr},vs:Kr,fs:Yr,getUniforms:Xr};function Xr(e={},t){let n={};if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)n.isHighlightActive=!1;else{n.isHighlightActive=!0;let r=e.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=r}if(e.highlightColor){let r=Array.from(e.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),n.highlightColor=r}return e.isActive!==void 0&&(n.isActive=Boolean(e.isActive),n.isAttribute=Boolean(e.isAttribute)),e.useFloatColors!==void 0&&(n.useFloatColors=Boolean(e.useFloatColors)),n}var te=20,Zr=`
1462
+ `,mn={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:Kr},vs:Yr,fs:Xr,getUniforms:Zr};function Zr(e={},t){let n={};if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)n.isHighlightActive=!1;else{n.isHighlightActive=!0;let r=e.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=r}if(e.highlightColor){let r=Array.from(e.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),n.highlightColor=r}return e.isActive!==void 0&&(n.isActive=Boolean(e.isActive),n.isAttribute=Boolean(e.isAttribute)),e.useFloatColors!==void 0&&(n.useFloatColors=Boolean(e.useFloatColors)),n}var te=20,Jr=`
1463
1463
  struct skinUniforms {
1464
1464
  jointMatrix: array<mat4x4<f32>, ${te}>,
1465
1465
  };
@@ -1472,7 +1472,7 @@ fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {
1472
1472
  + (weights.z * skin.jointMatrix[joints.z])
1473
1473
  + (weights.w * skin.jointMatrix[joints.w]);
1474
1474
  }
1475
- `,Jr=`
1475
+ `,Qr=`
1476
1476
  uniform skinUniforms {
1477
1477
  mat4 jointMatrix[SKIN_MAX_JOINTS];
1478
1478
  } skin;
@@ -1484,7 +1484,7 @@ mat4 getSkinMatrix(vec4 weights, uvec4 joints) {
1484
1484
  + (weights.w * skin.jointMatrix[joints.w]);
1485
1485
  }
1486
1486
 
1487
- `,Qr="",dn={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:Zr,vs:Jr,fs:Qr,defines:{SKIN_MAX_JOINTS:te},getUniforms:(e={},t)=>{let{scenegraphsFromGLTF:n}=e;if(!n?.gltf?.skins?.[0])return{jointMatrix:[]};let{inverseBindMatrices:r,joints:o,skeleton:i}=n.gltf.skins[0],a=[],s=r.value.length/16;for(let f=0;f<s;f++){let h=r.value.subarray(f*16,f*16+16);a.push(new B(Array.from(h)))}let c=n.gltfNodeIndexToNodeMap.get(i),l={};c.preorderTraversal((f,{worldMatrix:h})=>{l[f.id]=h});let p=new Float32Array(te*16);for(let f=0;f<te;++f){let h=o[f];if(h===void 0)break;let g=l[n.gltfNodeIndexToNodeMap.get(h).id],_=a[f],m=new B().copy(g).multiplyRight(_),x=f*16;for(let d=0;d<16;d++)p[x+d]=m[d]}return{jointMatrix:p}},uniformTypes:{jointMatrix:["mat4x4<f32>",te]}};var bn=Ze(Ie(),1);var $e=`precision highp int;
1487
+ `,eo="",dn={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:Jr,vs:Qr,fs:eo,defines:{SKIN_MAX_JOINTS:te},getUniforms:(e={},t)=>{let{scenegraphsFromGLTF:n}=e;if(!n?.gltf?.skins?.[0])return{jointMatrix:[]};let{inverseBindMatrices:r,joints:o,skeleton:i}=n.gltf.skins[0],a=[],s=r.value.length/16;for(let f=0;f<s;f++){let h=r.value.subarray(f*16,f*16+16);a.push(new B(Array.from(h)))}let c=n.gltfNodeIndexToNodeMap.get(i),l={};c.preorderTraversal((f,{worldMatrix:h})=>{l[f.id]=h});let p=new Float32Array(te*16);for(let f=0;f<te;++f){let h=o[f];if(h===void 0)break;let g=l[n.gltfNodeIndexToNodeMap.get(h).id],_=a[f],m=new B().copy(g).multiplyRight(_),x=f*16;for(let d=0;d<16;d++)p[x+d]=m[d]}return{jointMatrix:p}},uniformTypes:{jointMatrix:["mat4x4<f32>",te]}};var bn=Ze(Ie(),1);var $e=`precision highp int;
1488
1488
 
1489
1489
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
1490
1490
  struct AmbientLight {
@@ -1643,7 +1643,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
1643
1643
  );
1644
1644
  return distanceAttenuation / max(coneFactor, 0.0001);
1645
1645
  }
1646
- `;var U=5,eo=255,to={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},F={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[to,U]},defaultUniforms:Me(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:_n,vs:$e,fs:$e,getUniforms:no};function no(e,t={}){if(e=e&&{...e},!e)return Me();e.lights&&(e={...e,...oo(e.lights),lights:void 0});let{ambientLight:n,pointLights:r,spotLights:o,directionalLights:i}=e||{};if(!(n||r&&r.length>0||o&&o.length>0||i&&i.length>0))return{...Me(),enabled:0};let s={...Me(),...ro({ambientLight:n,pointLights:r,spotLights:o,directionalLights:i})};return e.enabled!==void 0&&(s.enabled=e.enabled?1:0),s}function ro({ambientLight:e,pointLights:t=[],spotLights:n=[],directionalLights:r=[]}){let o=vn(),i=0,a=0,s=0,c=0;for(let l of t){if(i>=U)break;o[i]={...o[i],color:xe(l),position:l.position,attenuation:l.attenuation||[1,0,0]},i++,a++}for(let l of n){if(i>=U)break;o[i]={...o[i],color:xe(l),position:l.position,direction:l.direction,attenuation:l.attenuation||[1,0,0],coneCos:ao(l)},i++,s++}for(let l of r){if(i>=U)break;o[i]={...o[i],color:xe(l),direction:l.direction},i++,c++}return t.length+n.length+r.length>U&&bn.log.warn(`MAX_LIGHTS exceeded, truncating to ${U}`)(),{ambientColor:xe(e),directionalLightCount:c,pointLightCount:a,spotLightCount:s,lights:o}}function oo(e){let t={pointLights:[],spotLights:[],directionalLights:[]};for(let n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;case"spot":t.spotLights?.push(n);break;default:}return t}function xe(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/eo)}function Me(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:vn()}}function vn(){return Array.from({length:U},()=>io())}function io(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function ao(e){let t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}var so=`#ifdef USE_IBL
1646
+ `;var U=5,to=255,no={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},F={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[no,U]},defaultUniforms:Me(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:_n,vs:$e,fs:$e,getUniforms:ro};function ro(e,t={}){if(e=e&&{...e},!e)return Me();e.lights&&(e={...e,...io(e.lights),lights:void 0});let{ambientLight:n,pointLights:r,spotLights:o,directionalLights:i}=e||{};if(!(n||r&&r.length>0||o&&o.length>0||i&&i.length>0))return{...Me(),enabled:0};let s={...Me(),...oo({ambientLight:n,pointLights:r,spotLights:o,directionalLights:i})};return e.enabled!==void 0&&(s.enabled=e.enabled?1:0),s}function oo({ambientLight:e,pointLights:t=[],spotLights:n=[],directionalLights:r=[]}){let o=vn(),i=0,a=0,s=0,c=0;for(let l of t){if(i>=U)break;o[i]={...o[i],color:xe(l),position:l.position,attenuation:l.attenuation||[1,0,0]},i++,a++}for(let l of n){if(i>=U)break;o[i]={...o[i],color:xe(l),position:l.position,direction:l.direction,attenuation:l.attenuation||[1,0,0],coneCos:so(l)},i++,s++}for(let l of r){if(i>=U)break;o[i]={...o[i],color:xe(l),direction:l.direction},i++,c++}return t.length+n.length+r.length>U&&bn.log.warn(`MAX_LIGHTS exceeded, truncating to ${U}`)(),{ambientColor:xe(e),directionalLightCount:c,pointLightCount:a,spotLightCount:s,lights:o}}function io(e){let t={pointLights:[],spotLights:[],directionalLights:[]};for(let n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;case"spot":t.spotLights?.push(n);break;default:}return t}function xe(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/to)}function Me(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:vn()}}function vn(){return Array.from({length:U},()=>ao())}function ao(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function so(e){let t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}var co=`#ifdef USE_IBL
1647
1647
  @group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
1648
1648
  @group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
1649
1649
  @group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
@@ -1656,7 +1656,7 @@ uniform samplerCube pbr_diffuseEnvSampler;
1656
1656
  uniform samplerCube pbr_specularEnvSampler;
1657
1657
  uniform sampler2D pbr_brdfLUT;
1658
1658
  #endif
1659
- `,Le={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:so,vs:Sn,fs:Sn};var co=`
1659
+ `,Le={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:co,vs:Sn,fs:Sn};var lo=`
1660
1660
  struct dirlightUniforms {
1661
1661
  lightDirection: vec3<f32>,
1662
1662
  };
@@ -1682,12 +1682,12 @@ fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
1682
1682
  let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
1683
1683
  return vec4<f32>(color.rgb * d, color.a);
1684
1684
  }
1685
- `,lo=`out vec3 dirlight_vNormal;
1685
+ `,fo=`out vec3 dirlight_vNormal;
1686
1686
 
1687
1687
  void dirlight_setNormal(vec3 normal) {
1688
1688
  dirlight_vNormal = normalize(normal);
1689
1689
  }
1690
- `,fo=`uniform dirlightUniforms {
1690
+ `,po=`uniform dirlightUniforms {
1691
1691
  vec3 lightDirection;
1692
1692
  } dirlight;
1693
1693
 
@@ -1698,7 +1698,7 @@ vec4 dirlight_filterColor(vec4 color) {
1698
1698
  float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
1699
1699
  return vec4(color.rgb * d, color.a);
1700
1700
  }
1701
- `,qe={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:co,vs:lo,fs:fo,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:po};function po(e=qe.defaultUniforms){let t={};return e.lightDirection&&(t.lightDirection=e.lightDirection),t}var xn=`struct lambertMaterialUniforms {
1701
+ `,qe={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:lo,vs:fo,fs:po,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:ho};function ho(e=qe.defaultUniforms){let t={};return e.lightDirection&&(t.lightDirection=e.lightDirection),t}var xn=`struct lambertMaterialUniforms {
1702
1702
  unlit: u32,
1703
1703
  ambient: f32,
1704
1704
  diffuse: f32,
@@ -4078,7 +4078,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
4078
4078
  mat4 normalMatrix;
4079
4079
  vec3 camera;
4080
4080
  } pbrProjection;
4081
- `,ho=`struct pbrProjectionUniforms {
4081
+ `,uo=`struct pbrProjectionUniforms {
4082
4082
  modelViewProjectionMatrix: mat4x4<f32>,
4083
4083
  modelMatrix: mat4x4<f32>,
4084
4084
  normalMatrix: mat4x4<f32>,
@@ -4086,6 +4086,6 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
4086
4086
  };
4087
4087
 
4088
4088
  @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
4089
- `,Cn={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:ho,vs:In,fs:In,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var Pn={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[F,Le,Cn],source:Rn,vs:An,fs:En,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:e=>e,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",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"}};return Dn(ne);})();
4089
+ `,Cn={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:uo,vs:In,fs:In,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var Pn={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[F,Le,Cn],source:Rn,vs:An,fs:En,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:e=>e,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",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"}};return Dn(ne);})();
4090
4090
  return __exports__;
4091
4091
  });
package/dist/index.cjs CHANGED
@@ -386,6 +386,7 @@ function resolveModules(modules) {
386
386
  }
387
387
 
388
388
  // dist/lib/shader-module/shader-module-uniform-layout.js
389
+ var GLSL_UNIFORM_BLOCK_FIELD_REGEXP = /^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;
389
390
  function getShaderModuleUniformBlockName(module2) {
390
391
  return `${module2.name}Uniforms`;
391
392
  }
@@ -439,7 +440,7 @@ function extractShaderUniformBlockFieldNames(shaderSource, language, uniformBloc
439
440
  if (!line || line.startsWith("#")) {
440
441
  continue;
441
442
  }
442
- const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(/^(?:uniform\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/);
443
+ const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
443
444
  if (fieldMatch) {
444
445
  fieldNames.push(fieldMatch[1]);
445
446
  }