@luma.gl/shaders 10.0.0-alpha.11 → 10.0.0-alpha.12
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 +147 -2
- package/dist/dist.min.js +235 -131
- package/dist/glsl.cjs.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/lighting/lightmap/lightmap-filter.cjs +93 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.d.ts +35 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.d.ts.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.js +71 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.js.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap.cjs +89 -0
- package/dist/modules/lighting/lightmap/lightmap.d.ts +405 -0
- package/dist/modules/lighting/lightmap/lightmap.d.ts.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap.js +67 -0
- package/dist/modules/lighting/lightmap/lightmap.js.map +1 -0
- package/dist/types/shader-type-decoder.cjs +12 -2
- package/dist/types/shader-type-decoder.d.ts +7 -7
- package/dist/types/shader-type-decoder.d.ts.map +1 -1
- package/dist/types/shader-type-decoder.js +13 -2
- package/dist/types/shader-type-decoder.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/wgsl.cjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +4 -0
- package/src/modules/lighting/lightmap/lightmap-filter.ts +73 -0
- package/src/modules/lighting/lightmap/lightmap.ts +76 -0
- package/src/types/shader-type-decoder.ts +22 -9
package/dist/dist.min.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
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 xt=Object.defineProperty;var
|
|
7
|
+
"use strict";var __exports__=(()=>{var xt=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var Co=(e,t)=>{for(var i in t)xt(e,i,{get:t[i],enumerable:!0})},Io=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of So(t))!yo.call(e,r)&&r!==i&&xt(e,r,{get:()=>t[r],enumerable:!(n=xo(t,r))||n.enumerable});return e};var wo=e=>Io(xt({},"__esModule",{value:!0}),e);var Dl={};Co(Dl,{GLSLShaderAssembler:()=>ye,PBR_ENVIRONMENT_FRAGMENT_GLSL:()=>to,PBR_ENVIRONMENT_FRAGMENT_WGSL:()=>io,PBR_TONE_MAP_MODE:()=>li,SKIN_MAX_JOINTS:()=>$,STORAGE_COLOR_DEFAULT_BYTE_STRIDES:()=>rt,STORAGE_COLOR_FORMAT:()=>k,STORAGE_COLOR_FORMAT_BYTE_LENGTHS:()=>nt,ShaderAssembler:()=>H,WGSLShaderAssembler:()=>Ce,_resolveModules:()=>Mi,areaLighting:()=>mt,assembleGLSLShaderPair:()=>Se,atmosphere:()=>Yr,capitalize:()=>ee,checkShaderModuleDeprecations:()=>se,clipShaderPlugin:()=>vr,clouds:()=>_t,clusteredLightGrid:()=>go,colors:()=>pr,combineInjects:()=>Pi,contactShadowBilateralBlur:()=>fo,contactShadowComposite:()=>uo,contactShadowTrace:()=>co,convertToVec4:()=>zt,dggs:()=>rr,dirlight:()=>ii,filterShaderPlugin:()=>hr,firefly:()=>Jr,floatColors:()=>me,fp32:()=>Xn,fp64:()=>ir,fp64LowPart:()=>Ie,fp64arithmetic:()=>Jt,fp64ify:()=>ge,fp64ifyMatrix4:()=>we,fromHalfFloat:()=>Gn,generateShaderForModule:()=>hn,getGLSLUniformBlocks:()=>Be,getPassthroughFS:()=>un,getQualifierDetails:()=>fn,getShaderInfo:()=>Ye,getShaderModuleDependencies:()=>V,getShaderModuleSource:()=>J,getShaderModuleUniformBlockFields:()=>Et,getShaderModuleUniformBlockName:()=>Ne,getShaderModuleUniformLayoutValidationResult:()=>Pt,getShaderModuleUniforms:()=>Li,globeClouds:()=>Qr,gouraudMaterial:()=>ri,gpuAnimation:()=>br,heightFog:()=>Hr,heightFogFunctions:()=>vt,ibl:()=>lt,initializeShaderModule:()=>Ee,initializeShaderModules:()=>Z,integrateSurfaceWeather:()=>Xr,lambertMaterial:()=>ni,lighting:()=>F,lightmapBake:()=>ho,lightmapFilter:()=>vo,mergeShaderPluginModules:()=>Gi,normalizeByteColor3:()=>ne,normalizeByteColor4:()=>it,pathDash:()=>$n,patternFill:()=>qr,pbrAmbientOcclusion:()=>mo,pbrContactShadow:()=>po,pbrEnvironmentFilter:()=>eo,pbrMaterial:()=>U,pbrScene:()=>ht,pbrShadow:()=>ao,pbrSurface:()=>so,phongMaterial:()=>oi,picking:()=>mr,pointGlow:()=>$r,precipitation:()=>Kr,preprocess:()=>q,random:()=>Kn,resolveShaderPlugins:()=>Vi,resolveUseByteColors:()=>ie,riverWaterMaterial:()=>Dr,scanWGSLInterface:()=>Re,shadow:()=>bt,sketchStroke:()=>qn,skin:()=>_r,storageColors:()=>gr,surfaceWeather:()=>Zr,toHalfFloat:()=>Vn,typeToChannelCount:()=>pn,typeToChannelSuffix:()=>dn,unlitMaterial:()=>Ir,validateShaderModuleUniformLayout:()=>Fe,valueNoise:()=>Y,volumeRaymarch:()=>Yn,warnIfGLSLUniformBlocksAreNotStd140:()=>Oe,waterMaterial:()=>gt});var B="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";var ae=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${B}`,"g")],Me=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${B}`,"g")],hi=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g")],Lo=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${B}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${B}`,"g")];function O(e){let t=e.split(""),i=0,n=0,r=!1,o=!1,a=!1;for(;i<e.length;){let s=e[i],l=e[i+1];if(o){a?a=!1:s==="\\"?a=!0:s==='"'&&(o=!1),i++;continue}if(r){s===`
|
|
8
8
|
`||s==="\r"?r=!1:t[i]=" ",i++;continue}if(n>0){if(s==="/"&&l==="*"){t[i]=" ",t[i+1]=" ",n++,i+=2;continue}if(s==="*"&&l==="/"){t[i]=" ",t[i+1]=" ",n--,i+=2;continue}s!==`
|
|
9
|
-
`&&s!=="\r"&&(t[i]=" "),i++;continue}if(s==='"'){o=!0,i++;continue}if(s==="/"&&l==="/"){t[i]=" ",t[i+1]=" ",r=!0,i+=2;continue}if(s==="/"&&l==="*"){t[i]=" ",t[i+1]=" ",n=1,i+=2;continue}i++}return t.join("")}function X(e,t){let i=O(e),n=[];for(let r of t){r.lastIndex=0;let o;for(o=r.exec(i);o;){let a=r===t[0],s=o.index,l=o[0].length;n.push({match:e.slice(s,s+l),index:s,length:l,bindingToken:o[a?1:2],groupToken:o[a?2:1],accessDeclaration:o[3]?.trim(),name:o[4]}),o=r.exec(i)}}return n.sort((r,o)=>r.index-o.index)}function St(e,t,i){let n=X(e,t);if(!n.length)return e;let r="",o=0;for(let a of n)r+=e.slice(o,a.index),r+=i(a),o=a.index+a.length;return r+=e.slice(o),r}function yt(e){return/@binding\(\s*auto\s*\)/.test(O(e))}function _i(e,t){return X(e,t===ae||t===Me?yo:t).find(n=>n.bindingToken==="auto")}function Re(e,t={}){let i=vi(e),n=Co(i);if(!n)return null;let r=Io(i,n);if(!r)return null;let o=Lo(i,n,r);if(!o)return null;if(t.scanVertexAttributes===!1)return{attributes:[],bindings:o};let a=wo(i,n);if(!a)return null;let s=Eo(i,n,r,a,t.vertexEntryPoint);return s?{attributes:s,bindings:o}:null}function vi(e){let t=O(e),i=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,n=[],r=i.exec(t);for(;r;)n.push({value:r[0],index:r.index}),r=i.exec(t);return n}function Co(e){let t=[],i=0;for(let n of e){if(n.value==="}"&&i===0)return null;t.push(i),n.value==="{"?i++:n.value==="}"&&i--}return i===0?t:null}function Io(e,t){let i=new Map;for(let n=0;n<e.length;n++){if(t[n]!==0||e[n].value!=="alias")continue;let r=e[n+1]?.value;if(!he(r)||e[n+2]?.value!=="="||i.has(r))return null;let o=Si(e,t,n+3,";");if(o<0||o===n+3)return null;i.set(r,Ae(e.slice(n+3,o))),n=o}return i}function wo(e,t){let i=new Map;for(let n=0;n<e.length;n++){if(t[n]!==0||e[n].value!=="struct")continue;let r=e[n+1]?.value,o=n+2;if(!he(r)||i.has(r)||e[o]?.value!=="{")return null;let a=Lt(e,o,"{","}");if(a<0)return null;i.set(r,e.slice(o+1,a)),n=a}return i}function Lo(e,t,i){let n=[],r=new Set,o=new Set;for(let a=0;a<e.length;a++){if(t[a]!==0||e[a].value!=="var")continue;let s=yi(e,t,a),l=e.slice(s,a),c=Ct(l,"group"),f=Ct(l,"binding");if(c===null||f===null||c===void 0!=(f===void 0))return null;if(c===void 0||f===void 0)continue;let d=a+1,u=[];if(e[d]?.value==="<"){let S=Lt(e,d,"<",">");if(S<0)return null;let x=Te(e.slice(d+1,S),",");if(!x)return null;u=x.map(Ae),d=S+1}let p=e[d]?.value;if(!he(p)||e[d+1]?.value!==":")return null;let m=Si(e,t,d+2,";");if(m<0||m===d+2)return null;let g=wt(Ae(e.slice(d+2,m)),i);if(!g)return null;let b=Mo({name:p,group:c,location:f,addressSpace:u,resourceType:g}),y=`${c}:${f}`;if(!b||r.has(y)||o.has(p))return null;n.push(b),r.add(y),o.add(p),a=m}return To(n),n.sort((a,s)=>a.group-s.group||a.location-s.location||a.name.localeCompare(s.name))}function Mo(e){let{name:t,group:i,location:n,addressSpace:r,resourceType:o}=e,a={name:t,group:i,location:n};if(r[0]==="uniform"&&r.length===1)return{...a,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let s=r[1]||"read";return s==="read"?{...a,type:"read-only-storage"}:s==="read_write"?{...a,type:"storage"}:null}return r.length>0?null:o==="sampler"||o==="sampler_comparison"?{...a,type:"sampler",...o==="sampler_comparison"?{samplerType:"comparison"}:{}}:o==="texture_external"?{...a,type:"external-texture"}:Ao(a,o)||Ro(a,o)}function Ao(e,t){let i=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(t);if(!i)return null;let n={read:"read-only",write:"write-only",read_write:"read-write"}[i[3]];return{...e,type:"storage",format:i[2],access:n,viewDimension:It(i[1])}}function Ro(e,t){let i=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(t);if(i){if(i[1]&&i[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[i[3]];return{...e,type:"texture",viewDimension:It(i[2]),sampleType:r,multisampled:!!i[1]}}let n=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(t);return!n||n[1]&&n[2]!=="2d"?null:{...e,type:"texture",viewDimension:It(n[2]),sampleType:"depth",multisampled:!!n[1]}}function To(e){for(let t of e){if(t.type!=="sampler"||t.samplerType||!t.name.endsWith("Sampler"))continue;let i=t.name.slice(0,-7);e.find(r=>r.type==="texture"&&r.name===i&&r.group===t.group)?.sampleType==="depth"&&(t.samplerType="non-filtering")}}function Eo(e,t,i,n,r){let o=Po(e,t);if(!o)return null;let a=o.filter(p=>p.vertex),s=r?a.find(p=>p.name===r):a.length===1?a[0]:void 0;if(!s)return a.length===0&&!r?[]:null;let l=Te(s.parameters,",");if(!l)return null;let c=[],f=new Set,d=new Set,u=new Set;for(let p of l)if(p.length>0&&!bi({declaration:p,aliases:i,structures:n,attributes:c,attributeLocations:f,attributeNames:d,visitedStructures:u}))return null;return c.sort((p,m)=>p.location-m.location||p.name.localeCompare(m.name))}function Po(e,t){let i=[],n=new Set;for(let r=0;r<e.length;r++){if(t[r]!==0||e[r].value!=="fn")continue;let o=e[r+1]?.value,a=r+2;if(!he(o)||n.has(o)||e[a]?.value!=="(")return null;let s=Lt(e,a,"(",")");if(s<0)return null;let l=yi(e,t,r);i.push({name:o,vertex:xi(e.slice(l,r),"vertex"),parameters:e.slice(a+1,s)}),n.add(o),r=s}return i}function bi(e){let{declaration:t,aliases:i,structures:n,attributes:r,attributeLocations:o,attributeNames:a,visitedStructures:s}=e,l=Fo(t,":");if(l<1||l===t.length-1)return!1;let c=Bo(t.slice(0,l)),f=Ct(t.slice(0,l),"location"),d=xi(t.slice(0,l),"builtin"),u=wt(Ae(t.slice(l+1)),i);if(!c||f===null||!u||f!==void 0&&d)return!1;if(f!==void 0){let g=No(u);return!g||o.has(f)||a.has(c)?!1:(r.push({name:c,location:f,type:g}),o.add(f),a.add(c),!0)}if(d)return!0;let p=n.get(u);if(!p||s.has(u))return!1;let m=Te(p,",");if(!m)return!1;s.add(u);for(let g of m)if(g.length>0&&!bi({...e,declaration:g}))return!1;return s.delete(u),!0}function wt(e,t,i=new Set){let n=vi(e),r="";for(let o of n){let a=t.get(o.value);if(!a){r+=Do(o.value);continue}if(i.has(o.value))return null;let s=new Set(i);s.add(o.value);let l=wt(a,t,s);if(!l)return null;r+=l}return r}function Do(e){let t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;let i={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${i}>`}function No(e){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(e)?e:null}function Ct(e,t){let i;for(let n=0;n<e.length;n++)if(!(e[n].value!=="@"||e[n+1]?.value!==t)){if(i!==void 0||e[n+2]?.value!=="("||!/^\d+$/.test(e[n+3]?.value||"")||e[n+4]?.value!==")")return null;i=Number(e[n+3].value)}return i}function xi(e,t){return e.some((i,n)=>i.value==="@"&&e[n+1]?.value===t)}function It(e){return e.replace("_","-")}function Lt(e,t,i,n){let r=0;for(let o=t;o<e.length;o++)if(e[o].value===i)r++;else if(e[o].value===n&&--r===0)return o;return-1}function Te(e,t){let i=[],n=0,r={"(":0,"<":0,"[":0,"{":0},o=Object.keys(r),a={")":"(",">":"<","]":"[","}":"{"};for(let s=0;s<e.length;s++){let l=e[s].value;if(l===t&&o.every(c=>r[c]===0)){i.push(e.slice(n,s)),n=s+1;continue}if(l in r)r[l]++;else if(l in a){let c=a[l];if(r[c]--,r[c]<0)return null}}return o.every(s=>r[s]===0)?(i.push(e.slice(n)),i):null}function Fo(e,t){let i=Te(e,t);return i&&i.length===2?i[0].length:-1}function Si(e,t,i,n){for(let r=i;r<e.length;r++)if(t[r]===0&&e[r].value===n)return r;return-1}function yi(e,t,i){for(let n=i-1;n>=0;n--)if(e[n].value===";"&&t[n]===0||e[n].value==="}"&&t[n]===1)return n+1;return 0}function Bo(e){for(let t=e.length-1;t>=0;t--)if(he(e[t].value))return e[t].value;return null}function Ae(e){return e.map(t=>t.value).join("")}function he(e){return!!(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function E(e,t){if(!e){let i=new Error(t||"shaders: assertion failed.");throw Error.captureStackTrace?.(i,E),i}}var Mt={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 Ii(e){let t={};for(let[i,n]of Object.entries(e))t[i]=Oo(n);return t}function wi(e,t,i){let n={};for(let[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&E(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}function Oo(e){let t=Ci(e);if(t!=="object")return{value:e,...Mt[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Mt[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=Ci(e.value),{...e,...Mt[t],type:t}):{type:"object",value:null};throw new Error("props")}function Ci(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}function Z(e){e.map(t=>Ee(t))}function Ee(e){if(e.instance)return;Z(e.dependencies||[]);let{propTypes:t={},deprecations:i=[]}=e,n={parsedDeprecations:Uo(i),normalizedInjections:{vertex:{},fragment:{}}};t&&(n.propValidators=Ii(t)),e.instance=n;let r={};t&&(r=Object.entries(t).reduce((o,[a,s])=>{let l=s?.value;return l&&(o[a]=l),o},{})),e.defaultUniforms={...e.defaultUniforms,...r}}function Li(e,t,i){Ee(e);let n=i||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,n):wi(t,e.instance?.propValidators,e.name)}function se(e,t,i){e.deprecations?.forEach(n=>{n.regex?.test(t)&&(n.deprecated?i.deprecated(n.old,n.new)():i.removed(n.old,n.new)())})}function Uo(e){return e.forEach(t=>{t.type==="function"?t.regex=new RegExp(`\\b${t.old}\\(`):t.regex=new RegExp(`${t.type} ${t.old};`)}),e}function z(e){let t=new Set,i=new Set,n=[],r=new Map;function o(l){let c=r.get(l.name);if(c&&c!==l)throw new Error(`Shader module name collision: Multiple different module objects share the name "${l.name}". Each module object must have a unique name.`);r.set(l.name,l)}function a(l,c){if(i.has(l)){let d=[...c,l.name].join(" -> ");throw new Error(`Shader module dependency cycle detected: ${d}`)}if(t.has(l))return;o(l),i.add(l);let f=[...c,l.name];if(l.dependencies)for(let d of l.dependencies)a(d,f);i.delete(l),t.add(l),n.push(l)}for(let l of e)a(l,[]);let s=new Set;for(let l of n)l.implements!==void 0&&(E(!s.has(l.implements)),s.add(l.implements));return Z(n),n}function ko(e){return z(e)}function Mi(e){return ko(e)}var Ai=`#ifdef MODULE_LOGDEPTH
|
|
9
|
+
`&&s!=="\r"&&(t[i]=" "),i++;continue}if(s==='"'){o=!0,i++;continue}if(s==="/"&&l==="/"){t[i]=" ",t[i+1]=" ",r=!0,i+=2;continue}if(s==="/"&&l==="*"){t[i]=" ",t[i+1]=" ",n=1,i+=2;continue}i++}return t.join("")}function X(e,t){let i=O(e),n=[];for(let r of t){r.lastIndex=0;let o;for(o=r.exec(i);o;){let a=r===t[0],s=o.index,l=o[0].length;n.push({match:e.slice(s,s+l),index:s,length:l,bindingToken:o[a?1:2],groupToken:o[a?2:1],accessDeclaration:o[3]?.trim(),name:o[4]}),o=r.exec(i)}}return n.sort((r,o)=>r.index-o.index)}function St(e,t,i){let n=X(e,t);if(!n.length)return e;let r="",o=0;for(let a of n)r+=e.slice(o,a.index),r+=i(a),o=a.index+a.length;return r+=e.slice(o),r}function yt(e){return/@binding\(\s*auto\s*\)/.test(O(e))}function vi(e,t){return X(e,t===ae||t===Me?Lo:t).find(n=>n.bindingToken==="auto")}function Re(e,t={}){let i=_i(e),n=Mo(i);if(!n)return null;let r=Ao(i,n);if(!r)return null;let o=To(i,n,r);if(!o)return null;if(t.scanVertexAttributes===!1)return{attributes:[],bindings:o};let a=Ro(i,n);if(!a)return null;let s=Fo(i,n,r,a,t.vertexEntryPoint);return s?{attributes:s,bindings:o}:null}function _i(e){let t=O(e),i=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,n=[],r=i.exec(t);for(;r;)n.push({value:r[0],index:r.index}),r=i.exec(t);return n}function Mo(e){let t=[],i=0;for(let n of e){if(n.value==="}"&&i===0)return null;t.push(i),n.value==="{"?i++:n.value==="}"&&i--}return i===0?t:null}function Ao(e,t){let i=new Map;for(let n=0;n<e.length;n++){if(t[n]!==0||e[n].value!=="alias")continue;let r=e[n+1]?.value;if(!he(r)||e[n+2]?.value!=="="||i.has(r))return null;let o=Si(e,t,n+3,";");if(o<0||o===n+3)return null;i.set(r,Ae(e.slice(n+3,o))),n=o}return i}function Ro(e,t){let i=new Map;for(let n=0;n<e.length;n++){if(t[n]!==0||e[n].value!=="struct")continue;let r=e[n+1]?.value,o=n+2;if(!he(r)||i.has(r)||e[o]?.value!=="{")return null;let a=Lt(e,o,"{","}");if(a<0)return null;i.set(r,e.slice(o+1,a)),n=a}return i}function To(e,t,i){let n=[],r=new Set,o=new Set;for(let a=0;a<e.length;a++){if(t[a]!==0||e[a].value!=="var")continue;let s=yi(e,t,a),l=e.slice(s,a),c=Ct(l,"group"),f=Ct(l,"binding");if(c===null||f===null||c===void 0!=(f===void 0))return null;if(c===void 0||f===void 0)continue;let d=a+1,u=[];if(e[d]?.value==="<"){let S=Lt(e,d,"<",">");if(S<0)return null;let x=Te(e.slice(d+1,S),",");if(!x)return null;u=x.map(Ae),d=S+1}let p=e[d]?.value;if(!he(p)||e[d+1]?.value!==":")return null;let g=Si(e,t,d+2,";");if(g<0||g===d+2)return null;let m=wt(Ae(e.slice(d+2,g)),i);if(!m)return null;let b=Eo({name:p,group:c,location:f,addressSpace:u,resourceType:m}),y=`${c}:${f}`;if(!b||r.has(y)||o.has(p))return null;n.push(b),r.add(y),o.add(p),a=g}return No(n),n.sort((a,s)=>a.group-s.group||a.location-s.location||a.name.localeCompare(s.name))}function Eo(e){let{name:t,group:i,location:n,addressSpace:r,resourceType:o}=e,a={name:t,group:i,location:n};if(r[0]==="uniform"&&r.length===1)return{...a,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let s=r[1]||"read";return s==="read"?{...a,type:"read-only-storage"}:s==="read_write"?{...a,type:"storage"}:null}return r.length>0?null:o==="sampler"||o==="sampler_comparison"?{...a,type:"sampler",...o==="sampler_comparison"?{samplerType:"comparison"}:{}}:o==="texture_external"?{...a,type:"external-texture"}:Po(a,o)||Do(a,o)}function Po(e,t){let i=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(t);if(!i)return null;let n={read:"read-only",write:"write-only",read_write:"read-write"}[i[3]];return{...e,type:"storage",format:i[2],access:n,viewDimension:It(i[1])}}function Do(e,t){let i=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(t);if(i){if(i[1]&&i[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[i[3]];return{...e,type:"texture",viewDimension:It(i[2]),sampleType:r,multisampled:!!i[1]}}let n=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(t);return!n||n[1]&&n[2]!=="2d"?null:{...e,type:"texture",viewDimension:It(n[2]),sampleType:"depth",multisampled:!!n[1]}}function No(e){for(let t of e){if(t.type!=="sampler"||t.samplerType||!t.name.endsWith("Sampler"))continue;let i=t.name.slice(0,-7);e.find(r=>r.type==="texture"&&r.name===i&&r.group===t.group)?.sampleType==="depth"&&(t.samplerType="non-filtering")}}function Fo(e,t,i,n,r){let o=Bo(e,t);if(!o)return null;let a=o.filter(p=>p.vertex),s=r?a.find(p=>p.name===r):a.length===1?a[0]:void 0;if(!s)return a.length===0&&!r?[]:null;let l=Te(s.parameters,",");if(!l)return null;let c=[],f=new Set,d=new Set,u=new Set;for(let p of l)if(p.length>0&&!bi({declaration:p,aliases:i,structures:n,attributes:c,attributeLocations:f,attributeNames:d,visitedStructures:u}))return null;return c.sort((p,g)=>p.location-g.location||p.name.localeCompare(g.name))}function Bo(e,t){let i=[],n=new Set;for(let r=0;r<e.length;r++){if(t[r]!==0||e[r].value!=="fn")continue;let o=e[r+1]?.value,a=r+2;if(!he(o)||n.has(o)||e[a]?.value!=="(")return null;let s=Lt(e,a,"(",")");if(s<0)return null;let l=yi(e,t,r);i.push({name:o,vertex:xi(e.slice(l,r),"vertex"),parameters:e.slice(a+1,s)}),n.add(o),r=s}return i}function bi(e){let{declaration:t,aliases:i,structures:n,attributes:r,attributeLocations:o,attributeNames:a,visitedStructures:s}=e,l=ko(t,":");if(l<1||l===t.length-1)return!1;let c=zo(t.slice(0,l)),f=Ct(t.slice(0,l),"location"),d=xi(t.slice(0,l),"builtin"),u=wt(Ae(t.slice(l+1)),i);if(!c||f===null||!u||f!==void 0&&d)return!1;if(f!==void 0){let m=Uo(u);return!m||o.has(f)||a.has(c)?!1:(r.push({name:c,location:f,type:m}),o.add(f),a.add(c),!0)}if(d)return!0;let p=n.get(u);if(!p||s.has(u))return!1;let g=Te(p,",");if(!g)return!1;s.add(u);for(let m of g)if(m.length>0&&!bi({...e,declaration:m}))return!1;return s.delete(u),!0}function wt(e,t,i=new Set){let n=_i(e),r="";for(let o of n){let a=t.get(o.value);if(!a){r+=Oo(o.value);continue}if(i.has(o.value))return null;let s=new Set(i);s.add(o.value);let l=wt(a,t,s);if(!l)return null;r+=l}return r}function Oo(e){let t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;let i={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${i}>`}function Uo(e){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(e)?e:null}function Ct(e,t){let i;for(let n=0;n<e.length;n++)if(!(e[n].value!=="@"||e[n+1]?.value!==t)){if(i!==void 0||e[n+2]?.value!=="("||!/^\d+$/.test(e[n+3]?.value||"")||e[n+4]?.value!==")")return null;i=Number(e[n+3].value)}return i}function xi(e,t){return e.some((i,n)=>i.value==="@"&&e[n+1]?.value===t)}function It(e){return e.replace("_","-")}function Lt(e,t,i,n){let r=0;for(let o=t;o<e.length;o++)if(e[o].value===i)r++;else if(e[o].value===n&&--r===0)return o;return-1}function Te(e,t){let i=[],n=0,r={"(":0,"<":0,"[":0,"{":0},o=Object.keys(r),a={")":"(",">":"<","]":"[","}":"{"};for(let s=0;s<e.length;s++){let l=e[s].value;if(l===t&&o.every(c=>r[c]===0)){i.push(e.slice(n,s)),n=s+1;continue}if(l in r)r[l]++;else if(l in a){let c=a[l];if(r[c]--,r[c]<0)return null}}return o.every(s=>r[s]===0)?(i.push(e.slice(n)),i):null}function ko(e,t){let i=Te(e,t);return i&&i.length===2?i[0].length:-1}function Si(e,t,i,n){for(let r=i;r<e.length;r++)if(t[r]===0&&e[r].value===n)return r;return-1}function yi(e,t,i){for(let n=i-1;n>=0;n--)if(e[n].value===";"&&t[n]===0||e[n].value==="}"&&t[n]===1)return n+1;return 0}function zo(e){for(let t=e.length-1;t>=0;t--)if(he(e[t].value))return e[t].value;return null}function Ae(e){return e.map(t=>t.value).join("")}function he(e){return!!(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function E(e,t){if(!e){let i=new Error(t||"shaders: assertion failed.");throw Error.captureStackTrace?.(i,E),i}}var Mt={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 Ii(e){let t={};for(let[i,n]of Object.entries(e))t[i]=Vo(n);return t}function wi(e,t,i){let n={};for(let[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&E(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}function Vo(e){let t=Ci(e);if(t!=="object")return{value:e,...Mt[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Mt[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=Ci(e.value),{...e,...Mt[t],type:t}):{type:"object",value:null};throw new Error("props")}function Ci(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}function Z(e){e.map(t=>Ee(t))}function Ee(e){if(e.instance)return;Z(e.dependencies||[]);let{propTypes:t={},deprecations:i=[]}=e,n={parsedDeprecations:Go(i),normalizedInjections:{vertex:{},fragment:{}}};t&&(n.propValidators=Ii(t)),e.instance=n;let r={};t&&(r=Object.entries(t).reduce((o,[a,s])=>{let l=s?.value;return l&&(o[a]=l),o},{})),e.defaultUniforms={...e.defaultUniforms,...r}}function Li(e,t,i){Ee(e);let n=i||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,n):wi(t,e.instance?.propValidators,e.name)}function se(e,t,i){e.deprecations?.forEach(n=>{n.regex?.test(t)&&(n.deprecated?i.deprecated(n.old,n.new)():i.removed(n.old,n.new)())})}function Go(e){return e.forEach(t=>{t.type==="function"?t.regex=new RegExp(`\\b${t.old}\\(`):t.regex=new RegExp(`${t.type} ${t.old};`)}),e}function V(e){let t=new Set,i=new Set,n=[],r=new Map;function o(l){let c=r.get(l.name);if(c&&c!==l)throw new Error(`Shader module name collision: Multiple different module objects share the name "${l.name}". Each module object must have a unique name.`);r.set(l.name,l)}function a(l,c){if(i.has(l)){let d=[...c,l.name].join(" -> ");throw new Error(`Shader module dependency cycle detected: ${d}`)}if(t.has(l))return;o(l),i.add(l);let f=[...c,l.name];if(l.dependencies)for(let d of l.dependencies)a(d,f);i.delete(l),t.add(l),n.push(l)}for(let l of e)a(l,[]);let s=new Set;for(let l of n)l.implements!==void 0&&(E(!s.has(l.implements)),s.add(l.implements));return Z(n),n}function Ho(e){return V(e)}function Mi(e){return Ho(e)}var Ai=`#ifdef MODULE_LOGDEPTH
|
|
10
10
|
logdepth_adjustPosition(gl_Position);
|
|
11
11
|
#endif
|
|
12
12
|
`,Ri=`#ifdef MODULE_MATERIAL
|
|
@@ -29,60 +29,60 @@
|
|
|
29
29
|
#ifdef MODULE_LOGDEPTH
|
|
30
30
|
logdepth_setFragDepth();
|
|
31
31
|
#endif
|
|
32
|
-
`;var
|
|
32
|
+
`;var Wo={vertex:Ai,fragment:Ri},Ti=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ei=/}\n?[^{}]*$/,At=[],ve="__LUMA_INJECT_DECLARATIONS__";function le(e,t,i){let n={};for(let r of e){let o=r[t];if(o===void 0)continue;if(r.stage!=="vertex"&&r.stage!=="fragment"||r.target.includes(":"))throw new Error("Shader injection targets require an explicit stage and unqualified target");let a=`${r.stage==="vertex"?"vs":"fs"}:${r.target}`;if(!/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][A-Za-z0-9_]*)$/.test(a))throw new Error(`Shader injection target "${a}" must be a named shader injection target`);n[a]||=[],n[a].push({injection:o,order:r.order??0,...i?{pluginName:i}:{}})}return n}function ce(e,t,i,n=!1,r="glsl",o={}){let a=t==="vertex";for(let s in i){let l=i[s];l.sort((f,d)=>f.order-d.order),At.length=l.length;for(let f=0,d=l.length;f<d;++f)At[f]=l[f].injection;let c=`${At.join(`
|
|
33
33
|
`)}
|
|
34
|
-
`;switch(s){case"vs:#decl":(r==="wgsl"||a)&&(e=e.replace(
|
|
35
|
-
${i[n]}`:i[n]}),t}function Pe(e,t,i,n,r){let o=
|
|
36
|
-
${i}${e.slice(a)}`}return`${e.slice(0,o.closeBraceIndex)}${i}${e.slice(o.closeBraceIndex)}`}function
|
|
37
|
-
`)){let a=o.replace(/\/\/.*$/,"").trim();if(!a||a.startsWith("#"))continue;let s=t==="wgsl"?a.match(/^([A-Za-z0-9_]+)\s*:/):a.match(
|
|
34
|
+
`;switch(s){case"vs:#decl":(r==="wgsl"||a)&&(e=e.replace(ve,c));break;case"vs:#main-start":(r==="wgsl"||a)&&(e=r==="wgsl"?Pe(e,"vertex",c,"start",o.vertex):e.replace(Ti,f=>f+c));break;case"vs:#main-end":(r==="wgsl"||a)&&(e=r==="wgsl"?Pe(e,"vertex",c,"end",o.vertex):e.replace(Ei,f=>c+f));break;case"fs:#decl":(r==="wgsl"||!a)&&(e=e.replace(ve,c));break;case"fs:#main-start":(r==="wgsl"||!a)&&(e=r==="wgsl"?Pe(e,"fragment",c,"start",o.fragment):e.replace(Ti,f=>f+c));break;case"fs:#main-end":(r==="wgsl"||!a)&&(e=r==="wgsl"?Pe(e,"fragment",c,"end",o.fragment):e.replace(Ei,f=>c+f));break;default:e=e.replace(s,f=>f+c)}}return e=e.replace(ve,""),n&&(e=e.replace(/\}\s*$/,s=>s+Wo[t])),e}function Pi(e){let t={};return E(Array.isArray(e)&&e.length>1),e.forEach(i=>{for(let n in i)t[n]=t[n]?`${t[n]}
|
|
35
|
+
${i[n]}`:i[n]}),t}function Pe(e,t,i,n,r){let o=jo(e,t,r);if(!o)return e;if(n==="start"){let a=o.openBraceIndex+1;return`${e.slice(0,a)}
|
|
36
|
+
${i}${e.slice(a)}`}return`${e.slice(0,o.closeBraceIndex)}${i}${e.slice(o.closeBraceIndex)}`}function jo(e,t,i){let n=t==="vertex"?"@vertex":"@fragment",r=e.indexOf(n);if(r<0)return null;let o=i?e.search(new RegExp(`\\bfn\\s+${qo(i)}\\s*\\(`)):e.indexOf("fn",r);if(o<0)return null;let a=e.indexOf("{",o);if(a<0)return null;let s=0;for(let l=a;l<e.length;l++){let c=e[l];if(c==="{")s++;else if(c==="}"&&(s--,s===0))return{openBraceIndex:a,closeBraceIndex:l}}return null}function qo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ni(e){let t=Tt(e),i=Oi[t];if(!i)throw new Error(`Unsupported variable shader type: ${e}`);return i}var Di=new Map;function Fi(e){let t=Rt(e),i=Di.get(t);if(i)return i;let n=Ko[t];if(!n)throw new Error(`Unsupported attribute shader type: ${e}`);let[r,o]=n,a=r==="i32"||r==="u32",s=r!=="u32",l=$o[r]*o,c=Object.freeze({primitiveType:r,components:o,byteLength:l,integer:a,signed:s});return Di.set(t,c),c}var De=class{getVariableShaderTypeInfo(t){return Ni(t)}getAttributeShaderTypeInfo(t){return Fi(t)}makeShaderAttributeType(t,i){return Bi(t,i)}resolveAttributeShaderTypeAlias(t){return Rt(t)}resolveVariableShaderTypeAlias(t){return Tt(t)}};function Bi(e,t){return t===1?e:`vec${t}<${e}>`}function Rt(e){return Ui[e]||e}function Tt(e){return ki[e]||e}var j=new De,$o={f32:4,f16:2,i32:4,u32:4},Ko={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Oi={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};for(let e of Object.values(Oi))Object.freeze(e);var Ui={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},ki={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};function Vi(e=[],t){let i={modules:[],injectionTargets:[],defines:{},injections:{},vertexInputs:{},interStageVariables:{}};for(let o of e)Yo(i,o,t);let{vertexInputs:n,interStageVariables:r}=i;for(let o of Object.keys(r))if(n[o])throw new Error(`ShaderPlugin name "${o}" cannot be both a vertex input and a varying`);return i}function Gi(e=[],t=[],i={}){let n=[...e],r=new Map;for(let o of n){let a=r.get(o.name);a&&a!==o&&i.onConflict?.(o.name,a,o),a||r.set(o.name,o)}for(let o of t){let a=r.get(o.name);a&&a!==o&&i.onConflict?.(o.name,a,o),a||(n.push(o),r.set(o.name,o))}return n}function Yo(e,t,i){t.module&&e.modules.push(t.module),t.defines&&Object.assign(e.defines,t.defines);for(let[o,a]of Object.entries(t.vertexInputs||{})){zi(o,"vertex input");let s=e.vertexInputs[o];if(s&&s!==a)throw new Error(`ShaderPlugin vertex input "${o}" has conflicting types "${s}" and "${a}"`);e.vertexInputs[o]=a}for(let[o,a]of Object.entries(t.interStageVariables||{})){zi(o,"varying");let s=Xo(o,a),l=e.interStageVariables[o];if(l&&(l.type!==s.type||l.interpolation!==s.interpolation))throw new Error(`ShaderPlugin varying "${o}" has conflicting declarations "${l.type}/${l.interpolation}" and "${s.type}/${s.interpolation}"`);e.interStageVariables[o]=s}for(let o of t.injectionTargets||[]){let a=o[i];if(!a)continue;let s=`${o.stage==="vertex"?"vs":"fs"}:${o.name}`;if(!/^(vs|fs):[A-Za-z_][A-Za-z0-9_]*$/.test(s))throw new Error(`Invalid ShaderPlugin injection target ${s}`);let l=e.injectionTargets.find(f=>f.stage===o.stage&&f.name===o.name),c=l?.[i];if(c&&(c.parameters!==a.parameters||(c.returnType||"void")!==(a.returnType||"void")||c.header!==a.header||c.footer!==a.footer))throw new Error(`Conflicting ShaderPlugin injection target ${s}`);l||e.injectionTargets.push({name:o.name,stage:o.stage,[i]:a})}let n=Array.isArray(t.injections)?t.injections:Object.entries(t.injections||{}).flatMap(([o,a])=>{let s=Zo(o,i);if(s===void 0)return[];let[l,...c]=s.split(":");if(l!=="vs"&&l!=="fs")throw new Error(`Invalid ShaderPlugin injection ${o}`);return[{stage:l==="vs"?"vertex":"fragment",target:c.join(":"),[i]:a}]}),r=le(n,i,t.name);for(let[o,a]of Object.entries(r))e.injections[o]||=[],e.injections[o].push(...a)}function zi(e,t){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)||e.startsWith("_luma_"))throw new Error(`ShaderPlugin ${t} "${e}" must be a valid non-reserved identifier`)}function Xo(e,t){let{primitiveType:i}=j.getAttributeShaderTypeInfo(t.type),n=i==="i32"||i==="u32",r=t.interpolation||(n?"flat":"smooth");if(n&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${e}" must use flat interpolation`);return{type:t.type,interpolation:r}}function Zo(e,t){let i=/^(glsl|wgsl):([\s\S]+)$/.exec(e);return i?i[1]===t?i[2]:void 0:e}var Jo=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Qo=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Ne(e){return`${e.name}Uniforms`}function Et(e,t){let i=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!i)return null;let n=Ne(e);return ea(i,t==="wgsl"?"wgsl":"glsl",n)}function Pt(e,t){let i=Object.keys(e.uniformTypes||{});if(!i.length)return null;let n=Et(e,t);return n?{moduleName:e.name,uniformBlockName:Ne(e),stage:t,expectedUniformNames:i,actualUniformNames:n,matches:na(i,n)}:null}function Fe(e,t,i={}){let n=Pt(e,t);if(!n||n.matches)return n;let r=ra(n);return i.log?.error?.(r,n)(),i.throwOnError!==!1&&E(!1,r),n}function Be(e){let t=[],i=oa(e);for(let n of i.matchAll(Qo)){let r=n[1]?.trim()||null;t.push({blockName:n[2],body:n[3],instanceName:n[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return t}function Oe(e,t,i,n){let r=Be(e).filter(a=>!a.isStd140),o=new Set;for(let a of r){if(o.has(a.blockName))continue;o.add(a.blockName);let s=n?.label?`${n.label} `:"",l=a.hasLayoutQualifier?`declares ${aa(a.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",c=`${s}${t} shader uniform block ${a.blockName} ${l}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;i?.warn?.(c,a)()}return r}function ea(e,t,i){let n=t==="wgsl"?ta(e,i):ia(e,i);if(!n)return null;let r=[];for(let o of n.split(`
|
|
37
|
+
`)){let a=o.replace(/\/\/.*$/,"").trim();if(!a||a.startsWith("#"))continue;let s=t==="wgsl"?a.match(/^([A-Za-z0-9_]+)\s*:/):a.match(Jo);s&&r.push(s[1])}return r}function ta(e,t){let i=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!i)return null;let n=e.indexOf("{",i.index);if(n<0)return null;let r=0;for(let o=n;o<e.length;o++){let a=e[o];if(a==="{"){r++;continue}if(a==="}"&&(r--,r===0))return e.slice(n+1,o)}return null}function ia(e,t){return Be(e).find(n=>n.blockName===t)?.body||null}function na(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function ra(e){let{expectedUniformNames:t,actualUniformNames:i}=e,n=t.filter(s=>!i.includes(s)),r=i.filter(s=>!t.includes(s)),o=[`Expected ${t.length} fields, found ${i.length}.`],a=sa(t,i);return a&&o.push(a),n.length&&o.push(`Missing from shader block (${n.length}): ${Hi(n)}.`),r.length&&o.push(`Unexpected in shader block (${r.length}): ${Hi(r)}.`),t.length<=12&&i.length<=12&&(n.length||r.length)&&(o.push(`Expected: ${t.join(", ")}.`),o.push(`Actual: ${i.join(", ")}.`)),`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${o.join(" ")}`}function oa(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function aa(e){return e.replace(/\s+/g," ").trim()}function sa(e,t){let i=Math.min(e.length,t.length);for(let n=0;n<i;n++)if(e[n]!==t[n])return`First mismatch at field ${n+1}: expected ${e[n]}, found ${t[n]}.`;return e.length>t.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}function Hi(e,t=8){if(e.length<=t)return e.join(", ");let i=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${i} more)`}var Wi=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${B}\\s*:\\s*([^;]+);`,"g")];function $i(e,t=[]){let i=O(e),n=new Map;for(let o of t)n.set(ji(o.name,o.group,o.location),o.moduleName);let r=[];for(let o of Wi){o.lastIndex=0;let a;for(a=o.exec(i);a;){let s=o===Wi[0],l=Number(a[s?1:2]),c=Number(a[s?2:1]),f=a[3]?.trim(),d=a[4],u=a[5].trim(),p=n.get(ji(d,c,l));r.push(la({name:d,group:c,binding:l,owner:p?"module":"application",moduleName:p,accessDeclaration:f,resourceType:u})),a=o.exec(i)}}return r.sort((o,a)=>o.group!==a.group?o.group-a.group:o.binding!==a.binding?o.binding-a.binding:o.name.localeCompare(a.name))}function la(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 i=e.accessDeclaration.split(",").map(n=>n.trim());if(i[0]==="uniform")return{...t,kind:"uniform",access:"uniform"};if(i[0]==="storage"){let n=i[1]||"read_write";return{...t,kind:n==="read"?"read-only-storage":"storage",access:n}}}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:fa(e.resourceType),viewDimension:qi(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:qi(e.resourceType),sampleType:ca(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function ji(e,t,i){return`${t}:${i}:${e}`}function qi(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 ca(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 fa(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}function ke(e,t=""){let i=new Map,n=Object.values(e).flatMap(o=>Object.entries(o).map(([a,s])=>`${a.slice(3)}
|
|
38
38
|
${s.signature}
|
|
39
39
|
${s.header||""}
|
|
40
40
|
${s.footer||""}`)),r=new Set(O(`${t}
|
|
41
41
|
${n.join(`
|
|
42
|
-
`)}`).match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));for(let o of Object.keys(e.vertex)){let a=o.slice(3);e.fragment[`fs:${a}`]&&i.set(a,{vertex:Ue(`_luma_vertex_target_${a}`,r),fragment:Ue(`_luma_fragment_target_${a}`,r)})}return i}function
|
|
43
|
-
`)+e.slice(u.end)}return e}function Ue(e,t){let i=e,n=0;for(;t.has(i);)i=`${e}_${++n}`;return t.add(i),i}var
|
|
42
|
+
`)}`).match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));for(let o of Object.keys(e.vertex)){let a=o.slice(3);e.fragment[`fs:${a}`]&&i.set(a,{vertex:Ue(`_luma_vertex_target_${a}`,r),fragment:Ue(`_luma_fragment_target_${a}`,r)})}return i}function Ki(e,t,i=ke(t)){if(!i.size)return e;let n=O(e),r=new Map,o=/((?:@\w+(?:\([^)]*\))?\s*)*)\bfn\s+([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu;for(let u=o.exec(n);u;u=o.exec(n)){let p=n.indexOf("{",o.lastIndex),g=p+1,m=1;for(;g<n.length&&m;g++)n[g]==="{"&&m++,n[g]==="}"&&m--;E(p>=0&&m===0);let b=u[2],y=u.index+u[0].lastIndexOf(b),S=Array.from(n.slice(p+1,g-1).matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu),x=>x[1]);r.set(b,{name:b,start:u.index,end:g,nameStart:y,bodyStart:p,calls:S,stages:new Set,entryStage:/@vertex\b/.test(u[1])?"vertex":/@fragment\b/.test(u[1])?"fragment":void 0}),o.lastIndex=g}function a(u,p){let g=r.get(u);if(!(!g||g.stages.has(p))){g.stages.add(p);for(let m of g.calls)a(i.get(m)?.[p]||m,p)}}for(let u of r.values())u.entryStage&&a(u.name,u.entryStage);for(let u of["vertex","fragment"])for(let p of Object.keys(t[u])){let g=p.slice(3);a(i.get(g)?.[u]||g,u)}let s=new Set,l=!0;for(;l;){l=!1;for(let u of r.values())!s.has(u.name)&&u.calls.some(p=>i.has(p)||s.has(p))&&(s.add(u.name),l=!0)}let c=new Map,f=new Set(n.match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));for(let u of s)r.get(u)?.stages.size===2&&c.set(u,{vertex:Ue(`_luma_vertex_helper_${u}`,f),fragment:Ue(`_luma_fragment_helper_${u}`,f)});function d(u,p){let g=i.get(u)?.[p];return g||c.get(u)?.[p]||u}for(let u of[...r.values()].reverse()){if(!s.has(u.name))continue;if(!u.stages.size)throw new Error(`Cannot infer WGSL target stage in ${u.name}`);let p=[],g=u.start;for(let m of u.stages){let b=e.slice(g,u.end),S=[...n.slice(u.bodyStart+1,u.end-1).matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu)];for(let v of S.reverse()){let h=u.bodyStart+1+v.index-g,_=d(v[1],m);b=b.slice(0,h)+_+b.slice(h+v[1].length)}let x=u.nameStart-g;b=b.slice(0,x)+d(u.name,m)+b.slice(x+u.name.length),p.push(b)}e=e.slice(0,g)+p.join(`
|
|
43
|
+
`)+e.slice(u.end)}return e}function Ue(e,t){let i=e,n=0;for(;t.has(i);)i=`${e}_${++n}`;return t.add(i),i}var _e=`
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${ve}
|
|
46
46
|
`;function ze(e){return function(i){let n={};for(let r of e){let o=r.getUniforms?.(i,n);Object.assign(n,o)}return n}}function fe(e,t,i,n){for(let r in e){let o=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(o){let a=o[2],s=o[3],l=a?s==="decl"?i:n:t;l[r]=l[r]||[],l[r].push(...e[r])}else n[r]=n[r]||[],n[r].push(...e[r])}}function J(e,t,i){let n;switch(t){case"vertex":n=e.vs||"";break;case"fragment":n=e.fs||"";break;case"wgsl":n=e.source||"";break;default:E(!1)}if(!e.name)throw new Error("Shader module must have a name");Fe(e,t,{log:i});let r=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),o=`// ----- MODULE ${e.name} ---------------
|
|
47
47
|
|
|
48
48
|
`;return t!=="wgsl"&&(o+=`#define MODULE_${r}
|
|
49
49
|
`),o+=`${n}
|
|
50
|
-
`,o}var Q="([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
51
|
-
`),n=[],r=[],o=!0;for(let a of i){let s=a.match(
|
|
52
|
-
`)}function
|
|
53
|
-
`)}function
|
|
50
|
+
`,o}var Q="([a-zA-Z_][a-zA-Z0-9_]*)",ua=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,da=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Q}\\s*$`),pa=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Q}\\s*(?:\\/\\/.*)?$`),ga=/^\s*\#\s*else\s*(?:\/\/.*)?$/,ma=/^\s*\#\s*endif\s*$/,ha=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Q}\\s*(?:\\/\\/.*)?$`),va=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function q(e,t){let i=e.split(`
|
|
51
|
+
`),n=[],r=[],o=!0;for(let a of i){let s=a.match(ua),l=a.match(ha)||a.match(da),c=a.match(pa),f=a.match(ga),d=a.match(va)||a.match(ma);if(s){let u=_a(s[1],t?.defines||{}),p=o&&u;r.push({parentActive:o,branchTaken:u,active:p}),o=p}else if(l||c){let u=(l||c)?.[1],p=!!t?.defines?.[u],g=l?p:!p,m=o&&g;r.push({parentActive:o,branchTaken:g,active:m}),o=m}else if(f){let u=r[r.length-1];if(!u)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");u.active=u.parentActive&&!u.branchTaken,u.branchTaken=!0,o=u.active}else d?(r.pop(),o=r.length?r[r.length-1].active:!0):o&&n.push(a)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return n.join(`
|
|
52
|
+
`)}function _a(e,t){let i=e.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(i))return Number(i)!==0;if(i==="true")return!0;if(i==="false")return!1;let n="(?:[A-Za-z_][A-Za-z0-9_]*|[+-]?\\d+(?:\\.\\d+)?)",r=i.match(new RegExp(`^(${n})\\s*(==|!=|<=|>=|<|>)\\s*(${n})$`));if(r){let c=u=>/^[A-Za-z_]/.test(u)?Number(t[u]??0):Number(u),f=c(r[1]),d=c(r[3]);switch(r[2]){case"==":return f===d;case"!=":return f!==d;case"<=":return f<=d;case">=":return f>=d;case"<":return f<d;case">":return f>d}}let o=i.match(new RegExp(`^!\\s*${Q}$`));if(o)return!t[o[1]];let a=i.match(new RegExp(`^${Q}$`));if(a)return!!t[a[1]];let s=i.match(new RegExp(`^defined\\s*\\(\\s*${Q}\\s*\\)$`));if(s)return t[s[1]]!==void 0;let l=i.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Q}\\s*\\)$`));if(l)return t[l[1]]===void 0;throw new Error(`Unsupported #if expression "${e}"`)}function Zi(e,t){let i=[];for(let[n,r]of Object.entries(t))ba(e,n),i.push(`in ${Ve(r)} ${n};`);return i.join(`
|
|
53
|
+
`)}function Ji(e,t,i){let n=Object.entries(i);if(n.length===0)return{source:e,declarations:"",initialization:""};let r=xa(e,t),o=e.slice(r.openParenthesis+1,r.closeParenthesis),a=Sa(e,o),s=new Set(a.locations),l=[],c=[],f=[];for(let[m,b]of n){if(a.names.has(m)||Ia(e,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let y=wa(s);s.add(y);let S=`_luma_${m}`;l.push(`@location(${y}) ${S}: ${b}`),c.push(`var<private> ${m}: ${b};`),f.push(`${m} = ${S};`)}let d=o.trim()?`,
|
|
54
54
|
`:`
|
|
55
55
|
`,u=o.trim()?"":`
|
|
56
56
|
`,p=`${o}${d}${l.join(`,
|
|
57
57
|
`)}${u}`;return{source:e.slice(0,r.openParenthesis+1)+p+e.slice(r.closeParenthesis),declarations:c.join(`
|
|
58
58
|
`),initialization:f.join(`
|
|
59
|
-
`)}}function Ve(e){let{primitiveType:t,components:i}=j.getAttributeShaderTypeInfo(e),n=t==="i32"?"int":t==="u32"?"uint":"float";return i===1?n:`${n==="int"?"i":n==="uint"?"u":""}vec${i}`}function
|
|
60
|
-
`&&(a=!1);continue}if(o>0){l==="/"&&c==="*"?(o++,s++):l==="*"&&c==="/"&&(o--,s++);continue}if(l==="/"&&c==="/"){a=!0,s++;continue}if(l==="/"&&c==="*"){o=1,s++;continue}if(l===i&&r++,l===n&&--r===0)return s}return-1}function
|
|
61
|
-
`&&(r=!1);continue}if(n>0){a==="/"&&s==="*"?(n++,o++):a==="*"&&s==="/"&&(n--,o++);continue}a==="/"&&s==="/"?(r=!0,o++):a==="/"&&s==="*"?(n=1,o++):a==="{"?i++:a==="}"&&i--}return i}function Ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function
|
|
59
|
+
`)}}function Ve(e){let{primitiveType:t,components:i}=j.getAttributeShaderTypeInfo(e),n=t==="i32"?"int":t==="u32"?"uint":"float";return i===1?n:`${n==="int"?"i":n==="uint"?"u":""}vec${i}`}function ba(e,t){let i=Ge(t);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${i}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin vertex input "${t}" conflicts with an existing GLSL input`)}function xa(e,t){let n=new RegExp(`\\bfn\\s+${Ge(t)}\\s*\\(`,"g").exec(e);if(!n)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${t}"`);let r=e.indexOf("(",n.index),o=Qi(e,r,"(",")");if(o<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:r,closeParenthesis:o}}function Sa(e,t){let i=Yi(t),n=new Set(Xi(t)),r=ya(t);for(let o of r){let a=Ca(e,o);if(a!==null){i.push(...Yi(a));for(let s of Xi(a))n.add(s)}}return{locations:i,names:n}}function Yi(e){let t=[],i=/@location\s*\(\s*(\d+)\s*\)/g,n=i.exec(e);for(;n;)t.push(Number(n[1])),n=i.exec(e);return t}function Xi(e){let t=[],i=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,n=i.exec(e);for(;n;)t.push(n[1]),n=i.exec(e);return t}function ya(e){let t=[],i=/:\s*([A-Za-z_][\w]*)\b/g,n=i.exec(e);for(;n;)t.push(n[1]),n=i.exec(e);return t}function Ca(e,t){let n=new RegExp(`\\bstruct\\s+${Ge(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=Qi(e,r,"{","}");return o<0?null:e.slice(r+1,o)}function Ia(e,t){let i=Ge(t),n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${i}\\b`,"g"),r=n.exec(e);for(;r;){if(La(e,r.index)===0)return!0;r=n.exec(e)}return!1}function wa(e){let t=0;for(;e.has(t);)t++;return t}function Qi(e,t,i,n){let r=0,o=0,a=!1;for(let s=t;s<e.length;s++){let l=e[s],c=e[s+1];if(a){l===`
|
|
60
|
+
`&&(a=!1);continue}if(o>0){l==="/"&&c==="*"?(o++,s++):l==="*"&&c==="/"&&(o--,s++);continue}if(l==="/"&&c==="/"){a=!0,s++;continue}if(l==="/"&&c==="*"){o=1,s++;continue}if(l===i&&r++,l===n&&--r===0)return s}return-1}function La(e,t){let i=0,n=0,r=!1;for(let o=0;o<t;o++){let a=e[o],s=e[o+1];if(r){a===`
|
|
61
|
+
`&&(r=!1);continue}if(n>0){a==="/"&&s==="*"?(n++,o++):a==="*"&&s==="/"&&(n--,o++);continue}a==="/"&&s==="/"?(r=!0,o++):a==="/"&&s==="*"?(n=1,o++):a==="{"?i++:a==="}"&&i--}return i}function Ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function en(e,t,i){let n=[],r=[];for(let[o,a]of Object.entries(i)){ka(e,o);let s=a.interpolation==="flat"?"flat ":"",l=t==="vertex"?"out":"in";n.push(`${s}${l} ${Ve(a.type)} ${o};`),t==="vertex"&&r.push(`${o} = ${Oa(a.type)};`)}return{declarations:n.join(`
|
|
62
62
|
`),initialization:r.join(`
|
|
63
|
-
`)}}function
|
|
63
|
+
`)}}function tn(e,t,i,n){let r=Object.entries(n);if(r.length===0)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let o=e,a=He(o,t,"vertex"),s=Ma(o,a),l=He(o,i,"fragment"),c=Aa(o,l),f=Dt(o,s),d=c?Dt(o,c.type):null,u=new Set([...We(a.parameters),...We(f.body),...We(l.parameters),...We(d?.body||"")]),p=new Set([...Nt(f.body),...Nt(d?.body||""),...Nt(l.parameters)]),g=[],m=[],b=[],y=[],S=[];for(let[h,_]of r){if(u.has(h)||Fa(o,h))throw new Error(`ShaderPlugin varying "${h}" conflicts with existing WGSL stage I/O or a module variable`);let L=Ba(p);p.add(L);let I=_.interpolation==="flat"?" @interpolate(flat)":"";if(g.push(` @location(${L})${I} ${h}: ${_.type},`),b.push(`var<private> ${h}: ${_.type};`),y.push(`${h} = ${Ua(_.type)};`),c)S.push(`${h} = ${c.name}.${h};`);else{let A=`_luma_${h}`;if(u.has(A))throw new Error(`ShaderPlugin varying "${h}" conflicts with a generated fragment parameter`);m.push(`@location(${L})${I} ${A}: ${_.type}`),S.push(`${h} = ${A};`)}}Ra(o,s,a.openBrace,a.closeBrace),o=Ta(o,s,a,r.map(([h])=>h)),a=He(o,t,"vertex"),o=Ea(o,a,r.map(([h])=>h));let v=(!c||s===c.type?[s]:[s,c.type]).map(h=>Dt(o,h).closeBrace).sort((h,_)=>_-h);for(let h of v)o=o.slice(0,h)+`${g.join(`
|
|
64
64
|
`)}
|
|
65
|
-
`+o.slice(h);if(l=He(o,i,"fragment"),
|
|
66
|
-
`+
|
|
65
|
+
`+o.slice(h);if(l=He(o,i,"fragment"),m.length){let h=l.parameters,_=O(h).trimEnd();if(_.trim()&&!_.endsWith(",")){let L=_.length;h=`${h.slice(0,L)},${h.slice(L)}`}o=o.slice(0,l.openParenthesis+1)+h+`
|
|
66
|
+
`+m.join(`,
|
|
67
67
|
`)+`
|
|
68
68
|
`+o.slice(l.closeParenthesis)}return{source:o,declarations:b.join(`
|
|
69
69
|
`),vertexInitialization:y.join(`
|
|
70
70
|
`),fragmentInitialization:S.join(`
|
|
71
|
-
`)}}function He(e,t,i){let r=new RegExp(`\\bfn\\s+${ue(t)}\\s*\\(`,"g").exec(e);if(!r)throw new Error(`ShaderPlugin interStageVariables require WGSL ${i} entry point "${t}"`);let o=e.indexOf("(",r.index),a=je(e,o,"(",")"),s=e.indexOf("{",a),l=je(e,s,"{","}");if(a<0||s<0||l<0)throw new Error(`Unable to parse WGSL ${i} entry point "${t}"`);return{openParenthesis:o,closeParenthesis:a,openBrace:s,closeBrace:l,parameters:e.slice(o+1,a)}}function
|
|
71
|
+
`)}}function He(e,t,i){let r=new RegExp(`\\bfn\\s+${ue(t)}\\s*\\(`,"g").exec(e);if(!r)throw new Error(`ShaderPlugin interStageVariables require WGSL ${i} entry point "${t}"`);let o=e.indexOf("(",r.index),a=je(e,o,"(",")"),s=e.indexOf("{",a),l=je(e,s,"{","}");if(a<0||s<0||l<0)throw new Error(`Unable to parse WGSL ${i} entry point "${t}"`);return{openParenthesis:o,closeParenthesis:a,openBrace:s,closeBrace:l,parameters:e.slice(o+1,a)}}function Ma(e,t){let i=e.slice(t.closeParenthesis+1,t.openBrace),n=/->\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());if(!n||Ft(e,n[1])===null)throw new Error("ShaderPlugin interStageVariables require the WGSL vertex entry point to return a named struct");return n[1]}function Aa(e,t){let i=[];for(let n of Na(O(t.parameters),",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(n.trim());r&&Ft(e,r[2])&&i.push({name:r[1],type:r[2]})}if(i.length>1)throw new Error(`ShaderPlugin interStageVariables require exactly one named WGSL fragment input struct; found ${i.length}`);return i[0]||null}function Dt(e,t){let i=Ft(e,t);if(!i)throw new Error(`Unable to find WGSL stage I/O struct "${t}"`);return i}function Ft(e,t){let n=new RegExp(`\\bstruct\\s+${ue(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=je(e,r,"{","}");return o<0?null:{openBrace:r,closeBrace:o,body:e.slice(r+1,o)}}function Ra(e,t,i,n){let r=new RegExp(`\\b${ue(t)}\\s*\\(`,"g"),o=r.exec(e);for(;o;){if(o.index<i||o.index>n)throw new Error(`ShaderPlugin varying output struct "${t}" is constructed outside the selected vertex entry point`);o=r.exec(e)}}function Ta(e,t,i,n){let r=new RegExp(`\\b${ue(t)}\\s*\\(`,"g"),o=[],a=r.exec(e);for(;a;){if(a.index>i.openBrace&&a.index<i.closeBrace){let s=e.indexOf("(",a.index),l=je(e,s,"(",")");if(l<0||l>i.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${t}"`);o.push({openParenthesis:s,closeParenthesis:l})}a=r.exec(e)}for(let s of o.sort((l,c)=>c.closeParenthesis-l.closeParenthesis)){let c=e.slice(s.openParenthesis+1,s.closeParenthesis).trim()?", ":"";e=e.slice(0,s.closeParenthesis)+c+n.join(", ")+e.slice(s.closeParenthesis)}return e}function Ea(e,t,i){let n=Pa(e,t.openBrace+1,t.closeBrace);for(let r=n.length-1;r>=0;r--){let o=n[r],a=e.slice(o.expressionStart,o.semicolon).trim();if(!a)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let s=`_luma_vertexOutput${r}`,l=i.map(f=>`${s}.${f} = ${f};`).join(`
|
|
72
72
|
`),c=`{
|
|
73
73
|
var ${s} = ${a};
|
|
74
74
|
${l}
|
|
75
75
|
return ${s};
|
|
76
|
-
}`;e=e.slice(0,o.start)+c+e.slice(o.semicolon+1)}return e}function
|
|
77
|
-
`,n+2);return r<0||r>i?i:r+1}if(e[n]==="/"&&e[n+1]==="*"){let r=1;for(n+=2;n<i&&r>0;)e[n]==="/"&&e[n+1]==="*"?(r++,n+=2):e[n]==="*"&&e[n+1]==="/"?(r--,n+=2):n++}return n}function
|
|
78
|
-
`&&(a=!1);continue}if(o>0){l==="/"&&c==="*"?(o++,s++):l==="*"&&c==="/"&&(o--,s++);continue}if(l==="/"&&c==="/"){a=!0,s++;continue}if(l==="/"&&c==="*"){o=1,s++;continue}if(l===i&&r++,l===n&&--r===0)return s}return-1}function
|
|
76
|
+
}`;e=e.slice(0,o.start)+c+e.slice(o.semicolon+1)}return e}function Pa(e,t,i){let n=[],r=t;for(;r<i;)if(r=Bt(e,r,i),e.slice(r,r+6)==="return"&&!/[A-Za-z0-9_]/.test(e[r+6]||"")){let o=r+6,a=Da(e,o,i);if(a<0)throw new Error("Unable to parse WGSL return statement in selected vertex entry point");n.push({start:r,expressionStart:o,semicolon:a}),r=a+1}else r++;return n}function Da(e,t,i){let n=0,r=0;for(let o=t;o<i;o++){let a=Bt(e,o,i);if(a!==o){o=a-1;continue}let s=e[o];if(s==="("&&n++,s===")"&&n--,s==="["&&r++,s==="]"&&r--,s===";"&&n===0&&r===0)return o}return-1}function Bt(e,t,i){let n=t;if(e[n]==="/"&&e[n+1]==="/"){let r=e.indexOf(`
|
|
77
|
+
`,n+2);return r<0||r>i?i:r+1}if(e[n]==="/"&&e[n+1]==="*"){let r=1;for(n+=2;n<i&&r>0;)e[n]==="/"&&e[n+1]==="*"?(r++,n+=2):e[n]==="*"&&e[n+1]==="/"?(r--,n+=2):n++}return n}function Na(e,t){let i=[],n=0,r=0,o=0;for(let a=0;a<e.length;a++){let s=e[a];s==="("&&r++,s===")"&&r--,s==="<"&&o++,s===">"&&o--,s===t&&r===0&&o===0&&(i.push(e.slice(n,a)),n=a+1)}return i.push(e.slice(n)),i}function Nt(e){let t=[],i=/@location\s*\(\s*(\d+)\s*\)/g,n=i.exec(e);for(;n;)t.push(Number(n[1])),n=i.exec(e);return t}function We(e){let t=[],i=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,n=i.exec(e);for(;n;)t.push(n[1]),n=i.exec(e);return t}function Fa(e,t){let i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${ue(t)}\\b`,"g"),n=i.exec(e);for(;n;){if(za(e,n.index)===0)return!0;n=i.exec(e)}return!1}function Ba(e){let t=0;for(;e.has(t);)t++;return t}function Oa(e){let{primitiveType:t,components:i}=j.getAttributeShaderTypeInfo(e),n=t==="u32"?"0u":t==="i32"?"0":"0.0";return i===1?n:`${Ve(e)}(${n})`}function Ua(e){let{primitiveType:t,components:i}=j.getAttributeShaderTypeInfo(e),n=`${t}(0)`;return i===1?n:`${e}(${n})`}function ka(e,t){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${ue(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function je(e,t,i,n){let r=0,o=0,a=!1;for(let s=t;s<e.length;s++){let l=e[s],c=e[s+1];if(a){l===`
|
|
78
|
+
`&&(a=!1);continue}if(o>0){l==="/"&&c==="*"?(o++,s++):l==="*"&&c==="/"&&(o--,s++);continue}if(l==="/"&&c==="/"){a=!0,s++;continue}if(l==="/"&&c==="*"){o=1,s++;continue}if(l===i&&r++,l===n&&--r===0)return s}return-1}function za(e,t){let i=0;for(let n=0;n<t;n++){let r=Bt(e,n,t);if(r!==n){n=r-1;continue}e[n]==="{"&&i++,e[n]==="}"&&i--}return i}function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(e,t,i="glsl"){let n="";for(let r in e){let o=e[r],a=o.returnType||"void",s=i==="wgsl"?"fn":a,l=i==="wgsl"&&a!=="void"?` -> ${a}`:"";if(n+=`${s} ${o.signature}${l} {
|
|
79
79
|
`,o.header&&(n+=` ${o.header}`),t[r]){let c=t[r];c.sort((f,d)=>f.order-d.order);for(let f of c)n+=` ${f.injection}
|
|
80
80
|
`}o.footer&&(n+=` ${o.footer}`),n+=`}
|
|
81
|
-
`}return n}function be(e,t=[],i="glsl"){let n={vertex:{},fragment:{}};for(let r of e){let o=r[i];if(o){let a=r.stage==="vertex"?"vs":"fs";n[r.stage][`${a}:${r.name}`]={...o,signature:`${r.name}(${o.parameters})`}}}for(let r of t){let o=be([r],[],i);for(let a of["vertex","fragment"])for(let[s,l]of Object.entries(o[a])){let c=n[a][s];if(c&&(c.signature!==l.signature||(c.returnType||"void")!==(l.returnType||"void")))throw new Error(`Conflicting ShaderPlugin injection target ${s}`);n[a][s]=c||l}}return n}function
|
|
82
|
-
`));return S+=
|
|
81
|
+
`}return n}function be(e,t=[],i="glsl"){let n={vertex:{},fragment:{}};for(let r of e){let o=r[i];if(o){let a=r.stage==="vertex"?"vs":"fs";n[r.stage][`${a}:${r.name}`]={...o,signature:`${r.name}(${o.parameters})`}}}for(let r of t){let o=be([r],[],i);for(let a of["vertex","fragment"])for(let[s,l]of Object.entries(o[a])){let c=n[a][s];if(c&&(c.signature!==l.signature||(c.returnType||"void")!==(l.returnType||"void")))throw new Error(`Conflicting ShaderPlugin injection target ${s}`);n[a][s]=c||l}}return n}function Va(e,t){return!!(t.startsWith("vs:")?e.vertex:e.fragment)[t]}function $e(e,t,i){let n=i==="vertex"?"vs:":i==="fragment"?"fs:":null;for(let r in t)if(!(n&&!r.startsWith(n))&&!Va(e,r)){let o=[...new Set(t[r].map(a=>a.pluginName).filter(Boolean))];throw new Error(`Unknown shader injection target ${r}${o.length?` (plugins: ${o.join(", ")})`:""}`)}}var xe=100;function rn(e){let t=V(e.modules||[]),{source:i,bindingAssignments:n}=Ga(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:i,getUniforms:ze(t),bindingAssignments:n}}function Ga(e,t){let{source:i,stage:n,modules:r,defines:o={},injectionTargets:a=[],inject:s={},pluginInjections:l={},pluginVertexInputs:c={},pluginInterStageVariables:f={},vertexEntryPoint:d="vertexMain",fragmentEntryPoint:u="fragmentMain",log:p}=t;E(typeof i=="string","shader source must be a string");let g=q(i,{defines:o}),m=Ji(g,d,c),b=tn(m.source,d,u,f),y=b.source,S="",x=be(a,t.pluginInjectionTargets,"wgsl"),v={},h={},_={};fe(l,v,h,_);let L=Array.isArray(s)?le(s,"wgsl"):{};fe(L,v,h,_);let I=Array.isArray(s)?{}:s;for(let M in I){let W=typeof I[M]=="string"?{injection:I[M],order:0}:I[M],oe=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(oe){let _o=oe[2],bo=oe[3];_o?bo==="decl"?h[M]=[...h[M]||[],W]:_[M]=[..._[M]||[],W]:v[M]=[...v[M]||[],W]}else _[M]=[..._[M]||[],W]}Ha(m.declarations,m.initialization,h,_),Wa(b,h,_),$e(x,v);let A=r.map(M=>({module:M,source:q(J(M,"wgsl",p),{defines:o})})),R=Ka(y),D=$a(R.source),C=Ja(A,t._bindingRegistry,D),T=[],w=A.map(({module:M,source:W})=>{let oe=Ya(W,M,{usedBindingsByGroup:D,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:C});return T.push(...oe.bindingAssignments),{module:M,source:oe.source}});for(let{module:M,source:W}of w)p&&se(M,y,p),S+=W;S+=_e,S=ce(S,n,ja(h),!1,"wgsl",{vertex:d,fragment:u});let z=ke(x,[S,R.source,...Object.values(v).flat().map(M=>M.injection),...Object.values(_).flat().map(M=>M.injection)].join(`
|
|
82
|
+
`));return S+=qa(x,v,z),S+=is(T),S+=R.source,S=ce(S,n,_,!1,"wgsl",{vertex:d,fragment:u}),S=Ki(S,x,z),ts(S),{source:S,bindingAssignments:T}}function Ha(e,t,i,n){e&&(i["vs:#decl"]=i["vs:#decl"]||[],i["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER})),t&&(n["vs:#main-start"]=n["vs:#main-start"]||[],n["vs:#main-start"].push({injection:t,order:Number.MIN_SAFE_INTEGER}))}function Wa(e,t,i){e.declarations&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:e.declarations,order:Number.MIN_SAFE_INTEGER})),e.vertexInitialization&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),e.fragmentInitialization&&(i["fs:#main-start"]=i["fs:#main-start"]||[],i["fs:#main-start"].push({injection:e.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function ja(e){let t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}function qa(e,t,i=ke(e)){return["vertex","fragment"].map(n=>{let r=Object.fromEntries(Object.entries(e[n]).map(([o,a])=>{let s=o.slice(3),l=i.get(s)?.[n]||s;return[o,{...a,signature:l+a.signature.slice(s.length)}]}));return qe(r,t,"wgsl")}).join("")}function $a(e){let t=new Map;for(let i of X(e,hi)){let n=Number(i.bindingToken),r=Number(i.groupToken);Ut(r,n,i.name),de(t,r,n,`application binding "${i.name}"`)}return t}function Ka(e){let t=X(e,Me),i=new Map;for(let o of t){if(o.bindingToken==="auto")continue;let a=Number(o.bindingToken),s=Number(o.groupToken);Ut(s,a,o.name),de(i,s,a,`application binding "${o.name}"`)}let n={sawSupportedBindingDeclaration:t.length>0},r=St(e,Me,o=>Za(o,i,n));if(yt(e)&&!n.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function Ya(e,t,i){let n=[],o={sawSupportedBindingDeclaration:X(e,ae).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},a=St(e,ae,s=>Xa(s,{module:t,context:i,bindingAssignments:n,relocationState:o}));if(yt(e)&&!o.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:a,bindingAssignments:n}}function Xa(e,t){let{module:i,context:n,bindingAssignments:r,relocationState:o}=t,{match:a,bindingToken:s,groupToken:l,name:c}=e,f=Number(l);if(s==="auto"){let p=Ke(f,i.name,c),g=n.bindingRegistry?.get(p),m=g!==void 0?g:Qa(f,n.usedBindingsByGroup,i.name,o.nextHintedBindingLocation??void 0,n.bindingRegistry);return Ot(i.name,f,m,c),g!==void 0&&nn(n.reservedBindingKeysByGroup,f,m,p)?(r.push({moduleName:i.name,name:c,group:f,location:m}),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(de(n.usedBindingsByGroup,f,m,`module "${i.name}" binding "${c}"`),n.bindingRegistry?.set(p,m),r.push({moduleName:i.name,name:c,group:f,location:m}),o.nextHintedBindingLocation!==null&&g===void 0&&(o.nextHintedBindingLocation=m+1),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}let d=Number(s);Ot(i.name,f,d,c);let u=Ke(f,i.name,c);return nn(n.reservedBindingKeysByGroup,f,d,u)||de(n.usedBindingsByGroup,f,d,`module "${i.name}" binding "${c}"`),r.push({moduleName:i.name,name:c,group:f,location:d}),a}function Za(e,t,i){let{match:n,bindingToken:r,groupToken:o,name:a}=e,s=Number(o);if(r==="auto"){let l=es(s,t);return Ut(s,l,a),de(t,s,l,`application binding "${a}"`),n.replace(/@binding\(\s*auto\s*\)/,`@binding(${l})`)}return i.sawSupportedBindingDeclaration=!0,n}function Ja(e,t,i){let n=new Map,r=[];function o(a,s,l,c){de(i,a,s,c);let f=n.get(a)||new Map;f.set(s,l),n.set(a,f)}for(let{module:a,source:s}of e)for(let l of X(s,ae)){let c=Number(l.groupToken);if(l.bindingToken==="auto"){r.push({module:a,name:l.name,group:c});continue}let f=Number(l.bindingToken);Ot(a.name,c,f,l.name),o(c,f,Ke(c,a.name,l.name),`module "${a.name}" binding "${l.name}"`)}for(let{module:a,name:s,group:l}of r){let c=Ke(l,a.name,s),f=t?.get(c);f!==void 0&&o(l,f,c,`registered module binding "${c}"`)}return n}function nn(e,t,i,n){let r=e.get(t);if(!r)return!1;let o=r.get(i);if(!o)return!1;if(o!==n)throw new Error(`Registered module binding "${n}" collided with "${o}": group ${t}, binding ${i}.`);return r.delete(i),!0}function Ut(e,t,i){if(e===0&&t>=xe)throw new Error(`Application binding "${i}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${xe}.`)}function Ot(e,t,i,n){if(t===0&&i<xe)throw new Error(`Module "${e}" binding "${n}" in group 0 uses reserved application binding ${i}. Module-owned explicit group-0 bindings must be ${xe} or higher.`)}function de(e,t,i,n){let r=e.get(t)||new Set;if(r.has(i))throw new Error(`Duplicate WGSL binding assignment for ${n}: group ${t}, binding ${i}.`);r.add(i),e.set(t,r)}function Qa(e,t,i,n,r){let o=t.get(e)||new Set,a=new Set,s=`${e}:`,l=`${s}${i}:`;for(let[f,d]of r||[])f.startsWith(l)&&a.add(d);let c=n??(e===0?xe:o.size>0?Math.max(...o)+1:0);for(;o.has(c)||a.has(c);)c++;for(let[f,d]of r||[])d===c&&f.startsWith(s)&&r?.delete(f);return c}function es(e,t){let i=t.get(e)||new Set,n=0;for(;i.has(n);)n++;return n}function ts(e){let t=vi(e,ae);if(!t)return;let i=ns(e,t.index);throw i?new Error(`Unresolved @binding(auto) for module "${i}" binding "${t.name}" remained in assembled WGSL source.`):rs(e,t.index)?new Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${os(t.match)}".`)}function is(e){if(e.length===0)return"";let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
|
83
83
|
`;for(let i of e)t+=`// ${i.moduleName}.${i.name} -> @group(${i.group}) @binding(${i.location})
|
|
84
84
|
`;return t+=`
|
|
85
|
-
`,t}function Ke(e,t,i){return`${e}:${t}:${i}`}function
|
|
85
|
+
`,t}function Ke(e,t,i){return`${e}:${t}:${i}`}function ns(e,t){let i=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,n,r;for(r=i.exec(e);r&&r.index<=t;)n=r[1],r=i.exec(e);return n}function rs(e,t){let i=e.indexOf(_e);return i>=0?t>i:!0}function os(e){return e.replace(/\s+/g," ").trim()}function Ye(e,t){return{name:as(e,t),language:"glsl",version:ss(e)}}function as(e,t="unnamed"){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function ss(e){let t=100,i=e.match(/[^\s]+/g);if(i&&i.length>=2&&i[0]==="#version"){let n=parseInt(i[1],10);Number.isFinite(n)&&(t=n)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}function on(e){switch(e?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
86
86
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
87
87
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
88
88
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -106,40 +106,40 @@ return ${s};
|
|
|
106
106
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
107
107
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
108
108
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
109
|
-
`}}function
|
|
110
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
111
|
-
`;function Se(e){let{vs:t,fs:i}=e,n=
|
|
109
|
+
`}}function sn(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=an(e,ls),e;case"fragment":return e=an(e,cs),e;default:throw new Error(t)}}var ln=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
110
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],ls=[...ln,[kt("attribute"),"in $1"],[kt("varying"),"out $1"]],cs=[...ln,[kt("varying"),"in $1"]];function an(e,t){for(let[i,n]of t)e=e.replace(i,n);return e}function kt(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var fs=`precision highp float;
|
|
111
|
+
`;function Se(e){let{vs:t,fs:i}=e,n=V(e.modules||[]);return{vs:cn(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:cn(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:ze(n)}}function cn(e,t){let{source:i,stage:n,language:r="glsl",modules:o,defines:a={},injectionTargets:s=[],inject:l={},pluginInjections:c={},pluginVertexInputs:f={},pluginInterStageVariables:d={},prologue:u=!0,log:p}=t;E(typeof i=="string","shader source must be a string");let g=r==="glsl"?Ye(i).version:-1,m=e.shaderLanguageVersion,b=g===100?"#version 100":"#version 300 es",S=i.split(`
|
|
112
112
|
`).slice(1).join(`
|
|
113
|
-
`),x={};o.forEach(C=>{Object.assign(x,C.defines)}),Object.assign(x,a);let
|
|
113
|
+
`),x={};o.forEach(C=>{Object.assign(x,C.defines)}),Object.assign(x,a);let v="";switch(r){case"wgsl":break;case"glsl":v=u?`${b}
|
|
114
114
|
|
|
115
115
|
// ----- PROLOGUE -------------------------
|
|
116
116
|
${`#define SHADER_TYPE_${n.toUpperCase()}`}
|
|
117
117
|
|
|
118
|
-
${
|
|
119
|
-
${n==="fragment"?
|
|
118
|
+
${on(e)}
|
|
119
|
+
${n==="fragment"?fs:""}
|
|
120
120
|
|
|
121
121
|
// ----- APPLICATION DEFINES -------------------------
|
|
122
122
|
|
|
123
|
-
${
|
|
123
|
+
${us(x)}
|
|
124
124
|
|
|
125
125
|
`:`${b}
|
|
126
|
-
`;break}let h=be(s,t.pluginInjectionTargets,"glsl"),
|
|
127
|
-
`)}let D=
|
|
128
|
-
`),D.initialization&&(I["vs:#main-start"]=I["vs:#main-start"]||[],I["vs:#main-start"].push({injection:D.initialization,order:Number.MIN_SAFE_INTEGER}));for(let C of o){p&&se(C,S,p);let T=J(C,n,p);
|
|
129
|
-
`)}return t}var H=class{_shaderTranspilers=new Map;_injectionTargets=[];_defaultModules=[];addShaderTranspiler(t){this._shaderTranspilers.set(t.sourceLanguage,t)}removeShaderTranspiler(t){this._shaderTranspilers.delete(t)}_transpileShader(t,i,n,r){let o=t.sourceLanguage||this.shaderLanguage;if(o===this.shaderLanguage)return E(!
|
|
126
|
+
`;break}let h=be(s,t.pluginInjectionTargets,"glsl"),_={},L={},I={};fe(c,_,L,I);let A=Array.isArray(l)?le(l,"glsl"):{};fe(A,_,L,I);let R=Array.isArray(l)?{}:l;for(let C in R){let T=typeof R[C]=="string"?{injection:R[C],order:0}:R[C],w=/^(v|f)s:(#)?([\w-]+)$/.exec(C);if(w){let z=w[2],M=w[3];z?M==="decl"?L[C]=[...L[C]||[],T]:I[C]=[...I[C]||[],T]:_[C]=[..._[C]||[],T]}else I[C]=[...I[C]||[],T]}if(n==="vertex"){let C=Zi(S,f);C&&(v+=`${C}
|
|
127
|
+
`)}let D=en(S,n,d);D.declarations&&(v+=`${D.declarations}
|
|
128
|
+
`),D.initialization&&(I["vs:#main-start"]=I["vs:#main-start"]||[],I["vs:#main-start"].push({injection:D.initialization,order:Number.MIN_SAFE_INTEGER}));for(let C of o){p&&se(C,S,p);let T=J(C,n,p);v+=T}return $e(h,_,n),v+="// ----- MAIN SHADER SOURCE -------------------------",v+=_e,v=ce(v,n,L),v+=qe(h[n],_),v+=S,v=ce(v,n,I),r==="glsl"&&g!==m&&(v=sn(v,n)),r==="glsl"&&Oe(v,n,p),v.trim()}function us(e={}){let t="";for(let i in e){let n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}
|
|
129
|
+
`)}return t}var H=class{_shaderTranspilers=new Map;_injectionTargets=[];_defaultModules=[];addShaderTranspiler(t){this._shaderTranspilers.set(t.sourceLanguage,t)}removeShaderTranspiler(t){this._shaderTranspilers.delete(t)}_transpileShader(t,i,n,r){let o=t.sourceLanguage||this.shaderLanguage;if(o===this.shaderLanguage)return E(!V(i).some(u=>u.sourceLanguage&&u.sourceLanguage!==this.shaderLanguage)),{code:n||"",modules:i};let a=this._shaderTranspilers.get(o);E(a);let s=V(i);E(!s.some(u=>u.sourceLanguage&&u.sourceLanguage!==o&&u.sourceLanguage!==this.shaderLanguage));let l=s.filter(u=>u.sourceLanguage===o).map(u=>u.source||"").join(`
|
|
130
130
|
`),c={vertex:t.vertexEntryPoint,fragment:t.fragmentEntryPoint,compute:t.computeEntryPoint},f=n==null?{code:""}:a.transpile({source:[l,n].filter(Boolean).join(`
|
|
131
|
-
`),target:this.shaderLanguage,stage:r,entryPoints:c,platformInfo:t.platformInfo}),d=s.map(u=>({...u,dependencies:void 0,...u.sourceLanguage===o?{source:void 0,vs:void 0,fs:void 0}:{}}));return{...f,modules:d}}addDefaultModule(t){this._defaultModules.find(i=>i.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let i=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==i)}addShaderInjectionTarget(t){this._injectionTargets.push(t)}resetShaderInjectionTargets(){this._injectionTargets.length=0}_getModuleList(t=[]){let i=new Array(this._defaultModules.length+t.length),n={},r=0;for(let o=0,a=this._defaultModules.length;o<a;++o){let s=this._defaultModules[o],l=s.name;i[r++]=s,n[l]=!0}for(let o=0,a=t.length;o<a;++o){let s=t[o],l=s.name;n[l]||(i[r++]=s,n[l]=!0)}return i.length=r,Z(i),i}};var ye=class extends H{shaderLanguage="glsl";assembleGLSLShaderPair(t){let i=this._getModuleList(t.modules),n=[...this._injectionTargets,...t.injectionTargets||[]],r=this._transpileShader(t,i,t.vs,"vertex"),o=this._transpileShader(t,i,t.fs,"fragment");return{...Se({...t,vs:r.code,fs:t.fs==null?void 0:o.code,modules:r.modules,injectionTargets:n}),modules:i}}};var Ce=class e extends H{shaderLanguage="wgsl";_wgslBindingRegistry=new Map;assembleWGSLShader(t){let i=this._getModuleList(t.modules),n=[...this._injectionTargets,...t.injectionTargets||[]],r=this._transpileShader(t,i,t.source,t.shaderStage??(t.computeEntryPoint?"compute":void 0)),o={vertex:r.entryPoints?.vertex??t.vertexEntryPoint,fragment:r.entryPoints?.fragment??t.fragmentEntryPoint,compute:r.entryPoints?.compute??t.computeEntryPoint},a=e.getShaderPreprocessorDefines(t,i),s=t.platformInfo.shaderLanguage==="wgsl"&&r.code?q(r.code,{defines:a}):r.code,{source:l,getUniforms:c,bindingAssignments:f}=
|
|
131
|
+
`),target:this.shaderLanguage,stage:r,entryPoints:c,platformInfo:t.platformInfo}),d=s.map(u=>({...u,dependencies:void 0,...u.sourceLanguage===o?{source:void 0,vs:void 0,fs:void 0}:{}}));return{...f,modules:d}}addDefaultModule(t){this._defaultModules.find(i=>i.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let i=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==i)}addShaderInjectionTarget(t){this._injectionTargets.push(t)}resetShaderInjectionTargets(){this._injectionTargets.length=0}_getModuleList(t=[]){let i=new Array(this._defaultModules.length+t.length),n={},r=0;for(let o=0,a=this._defaultModules.length;o<a;++o){let s=this._defaultModules[o],l=s.name;i[r++]=s,n[l]=!0}for(let o=0,a=t.length;o<a;++o){let s=t[o],l=s.name;n[l]||(i[r++]=s,n[l]=!0)}return i.length=r,Z(i),i}};var ye=class extends H{shaderLanguage="glsl";assembleGLSLShaderPair(t){let i=this._getModuleList(t.modules),n=[...this._injectionTargets,...t.injectionTargets||[]],r=this._transpileShader(t,i,t.vs,"vertex"),o=this._transpileShader(t,i,t.fs,"fragment");return{...Se({...t,vs:r.code,fs:t.fs==null?void 0:o.code,modules:r.modules,injectionTargets:n}),modules:i}}};var Ce=class e extends H{shaderLanguage="wgsl";_wgslBindingRegistry=new Map;assembleWGSLShader(t){let i=this._getModuleList(t.modules),n=[...this._injectionTargets,...t.injectionTargets||[]],r=this._transpileShader(t,i,t.source,t.shaderStage??(t.computeEntryPoint?"compute":void 0)),o={vertex:r.entryPoints?.vertex??t.vertexEntryPoint,fragment:r.entryPoints?.fragment??t.fragmentEntryPoint,compute:r.entryPoints?.compute??t.computeEntryPoint},a=e.getShaderPreprocessorDefines(t,i),s=t.platformInfo.shaderLanguage==="wgsl"&&r.code?q(r.code,{defines:a}):r.code,{source:l,getUniforms:c,bindingAssignments:f}=rn({...t,source:s,vertexEntryPoint:o.vertex,fragmentEntryPoint:o.fragment,defines:a,_bindingRegistry:this._wgslBindingRegistry,modules:r.modules,injectionTargets:n}),d=t.platformInfo.shaderLanguage==="wgsl"?q(l,{defines:a}):l;return{source:d,entryPoints:o,getUniforms:c,modules:i,bindingAssignments:f,bindingTable:$i(d,f),shaderLayout:Re(d,{vertexEntryPoint:o.vertex,scanVertexAttributes:t.scanVertexAttributes})}}static getShaderPreprocessorDefines(t,i){return{...e.getPlatformPreprocessorDefines(t.platformInfo),...i.reduce((n,r)=>(Object.assign(n,r.defines),n),{}),...t.defines}}static getPlatformPreprocessorDefines(t){let i=t.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:t.type==="webgpu"&&(i.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:t.type==="webgpu"&&t.gpu.toLowerCase()!=="nvidia"&&t.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:t.type==="webgpu"&&t.gpu.toLowerCase()==="apple"}}};var ds=`out vec4 transform_output;
|
|
132
132
|
void main() {
|
|
133
133
|
transform_output = vec4(0);
|
|
134
|
-
}`,
|
|
135
|
-
${
|
|
134
|
+
}`,ps=`#version 300 es
|
|
135
|
+
${ds}`;function fn(e,t){t=Array.isArray(t)?t:[t];let i=e.replace(/^\s+/,"").split(/\s+/),[n,r,o]=i;if(!t.includes(n)||!r||!o)return null;let a=o.split(";")[0];return{qualifier:n,type:r,name:a}}function un(e){let{input:t,inputChannels:i,output:n}=e||{};if(!t)return ps;if(!i)throw new Error("inputChannels");let r=gs(i),o=zt(t,i);return`#version 300 es
|
|
136
136
|
in ${r} ${t};
|
|
137
137
|
out vec4 ${n};
|
|
138
138
|
void main() {
|
|
139
139
|
${n} = ${o};
|
|
140
|
-
}`}function
|
|
141
|
-
`)}function
|
|
142
|
-
`)}function mn(e,t){switch(t.shaderLanguage){case"glsl":return dn(e,t);case"wgsl":return pn(e,t)}}var yf=1/Math.PI*180,Cf=1/180*Math.PI,gs={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...gs}};var N=globalThis.mathgl.config;function Vt(e,{precision:t=N.precision}={}){return e=hs(e),`${parseFloat(e.toPrecision(t))}`}function pe(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Gt(e,t,i){return vs(e,n=>Math.max(t,Math.min(i,n)))}function Xe(e,t,i){let n=N.EPSILON;i&&(N.EPSILON=i);try{if(e===t)return!0;if(pe(e)&&pe(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Xe(e[r],t[r]))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)<=N.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{N.EPSILON=n}}function hs(e){return Math.round(e/N.EPSILON)*N.EPSILON}function _s(e){return e.clone?e.clone():new Array(e.length)}function vs(e,t,i){if(pe(e)){let n=e;i=i||_s(n);for(let r=0;r<i.length&&r<n.length;++r){let o=typeof e=="number"?e:e[r];i[r]=t(o,r,i)}return i}return t(e)}var Ze=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,i=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+i];return this.check()}toArray(t=[],i=0){for(let n=0;n<this.ELEMENTS;++n)t[i+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:pe(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(N)}formatString(t){let i="";for(let n=0;n<this.ELEMENTS;++n)i+=(n>0?", ":"")+Vt(this[n],t);return`${t.printTypes?this.constructor.name:""}[${i}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(!Xe(this[i],t[i]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(this[i]!==t[i])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,i,n){if(n===void 0)return this.lerp(this,t,i);for(let r=0;r<this.ELEMENTS;++r){let o=t[r],a=typeof i=="number"?i:i[r];this[r]=o+n*(a-o)}return this.check()}min(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(t[i],this[i]);return this.check()}max(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.max(t[i],this[i]);return this.check()}clamp(t,i){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),i[n]);return this.check()}add(...t){for(let i of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=i[n];return this.check()}subtract(...t){for(let i of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=i[n];return this.check()}scale(t){if(typeof t=="number")for(let i=0;i<this.ELEMENTS;++i)this[i]*=t;else for(let i=0;i<this.ELEMENTS&&i<t.length;++i)this[i]*=t[i];return this.check()}multiplyByScalar(t){for(let i=0;i<this.ELEMENTS;++i)this[i]*=t;return this.check()}check(){if(N.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 i=0;i<this.ELEMENTS;++i)t=t&&Number.isFinite(this[i]);return t}};function bs(e,t){if(e.length!==t)return!1;for(let i=0;i<e.length;++i)if(!Number.isFinite(e[i]))return!1;return!0}function gn(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Je(e,t,i=""){if(N.debug&&!bs(e,t))throw new Error(`math.gl: ${i} some fields set to invalid numbers'`);return e}var Qe=class extends Ze{toString(){let t="[";if(N.printRowMajor){t+="row-major:";for(let i=0;i<this.RANK;++i)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+i]}`}else{t+="column-major:";for(let i=0;i<this.ELEMENTS;++i)t+=` ${this[i]}`}return t+="]",t}getElementIndex(t,i){return i*this.RANK+t}getElement(t,i){return this[i*this.RANK+t]}setElement(t,i,n){return this[i*this.RANK+t]=gn(n),this}getColumn(t,i=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let r=0;r<this.RANK;++r)i[r]=this[n+r];return i}setColumn(t,i){let n=t*this.RANK;for(let r=0;r<this.RANK;++r)this[n+r]=i[r];return this}};function hn(e,t,i){let n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e}function _n(e,t,i){let n=t[0],r=t[1],o=i[3]*n+i[7]*r||1;return e[0]=(i[0]*n+i[4]*r)/o,e[1]=(i[1]*n+i[5]*r)/o,e}function vn(e,t,i){let n=t[0],r=t[1],o=t[2],a=i[3]*n+i[7]*r+i[11]*o||1;return e[0]=(i[0]*n+i[4]*r+i[8]*o)/a,e[1]=(i[1]*n+i[5]*r+i[9]*o)/a,e[2]=(i[2]*n+i[6]*r+i[10]*o)/a,e}function bn(e,t,i){let n=t[0],r=t[1],o=t[2],a=i[3]*n+i[7]*r+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/a,e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/a,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/a,e}function xs(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 xn(e,t){if(e===t){let i=t[1],n=t[2],r=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=r,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 Sn(e,t){let i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],f=t[8],d=t[9],u=t[10],p=t[11],m=t[12],g=t[13],b=t[14],y=t[15],S=i*s-n*a,x=i*l-r*a,_=i*c-o*a,h=n*l-r*s,v=n*c-o*s,L=r*c-o*l,I=f*g-d*m,A=f*b-u*m,R=f*y-p*m,D=d*b-u*g,C=d*y-p*g,T=u*y-p*b,w=S*T-x*C+_*D+h*R-v*A+L*I;return w?(w=1/w,e[0]=(s*T-l*C+c*D)*w,e[1]=(r*C-n*T-o*D)*w,e[2]=(g*L-b*v+y*h)*w,e[3]=(u*v-d*L-p*h)*w,e[4]=(l*R-a*T-c*A)*w,e[5]=(i*T-r*R+o*A)*w,e[6]=(b*_-m*L-y*x)*w,e[7]=(f*L-u*_+p*x)*w,e[8]=(a*C-s*R+c*I)*w,e[9]=(n*R-i*C-o*I)*w,e[10]=(m*v-g*_+y*S)*w,e[11]=(d*_-f*v-p*S)*w,e[12]=(s*A-a*D-l*I)*w,e[13]=(i*D-n*A+r*I)*w,e[14]=(g*x-m*h-b*S)*w,e[15]=(f*h-d*x+u*S)*w,e):null}function yn(e){let t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],f=e[9],d=e[10],u=e[11],p=e[12],m=e[13],g=e[14],b=e[15],y=t*a-i*o,S=t*s-n*o,x=i*s-n*a,_=c*m-f*p,h=c*g-d*p,v=f*g-d*m,L=t*v-i*h+n*_,I=o*v-a*h+s*_,A=c*x-f*S+d*y,R=p*x-m*S+g*y;return l*L-r*I+b*A-u*R}function Wt(e,t,i){let n=t[0],r=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],f=t[7],d=t[8],u=t[9],p=t[10],m=t[11],g=t[12],b=t[13],y=t[14],S=t[15],x=i[0],_=i[1],h=i[2],v=i[3];return e[0]=x*n+_*s+h*d+v*g,e[1]=x*r+_*l+h*u+v*b,e[2]=x*o+_*c+h*p+v*y,e[3]=x*a+_*f+h*m+v*S,x=i[4],_=i[5],h=i[6],v=i[7],e[4]=x*n+_*s+h*d+v*g,e[5]=x*r+_*l+h*u+v*b,e[6]=x*o+_*c+h*p+v*y,e[7]=x*a+_*f+h*m+v*S,x=i[8],_=i[9],h=i[10],v=i[11],e[8]=x*n+_*s+h*d+v*g,e[9]=x*r+_*l+h*u+v*b,e[10]=x*o+_*c+h*p+v*y,e[11]=x*a+_*f+h*m+v*S,x=i[12],_=i[13],h=i[14],v=i[15],e[12]=x*n+_*s+h*d+v*g,e[13]=x*r+_*l+h*u+v*b,e[14]=x*o+_*c+h*p+v*y,e[15]=x*a+_*f+h*m+v*S,e}function Cn(e,t,i){let n=i[0],r=i[1],o=i[2],a,s,l,c,f,d,u,p,m,g,b,y;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*o+t[12],e[13]=t[1]*n+t[5]*r+t[9]*o+t[13],e[14]=t[2]*n+t[6]*r+t[10]*o+t[14],e[15]=t[3]*n+t[7]*r+t[11]*o+t[15]):(a=t[0],s=t[1],l=t[2],c=t[3],f=t[4],d=t[5],u=t[6],p=t[7],m=t[8],g=t[9],b=t[10],y=t[11],e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=f,e[5]=d,e[6]=u,e[7]=p,e[8]=m,e[9]=g,e[10]=b,e[11]=y,e[12]=a*n+f*r+m*o+t[12],e[13]=s*n+d*r+g*o+t[13],e[14]=l*n+u*r+b*o+t[14],e[15]=c*n+p*r+y*o+t[15]),e}function In(e,t,i){let n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function wn(e,t,i,n){let r=n[0],o=n[1],a=n[2],s=Math.sqrt(r*r+o*o+a*a),l,c,f,d,u,p,m,g,b,y,S,x,_,h,v,L,I,A,R,D,C,T,w,k;return s<1e-6?null:(s=1/s,r*=s,o*=s,a*=s,c=Math.sin(i),l=Math.cos(i),f=1-l,d=t[0],u=t[1],p=t[2],m=t[3],g=t[4],b=t[5],y=t[6],S=t[7],x=t[8],_=t[9],h=t[10],v=t[11],L=r*r*f+l,I=o*r*f+a*c,A=a*r*f-o*c,R=r*o*f-a*c,D=o*o*f+l,C=a*o*f+r*c,T=r*a*f+o*c,w=o*a*f-r*c,k=a*a*f+l,e[0]=d*L+g*I+x*A,e[1]=u*L+b*I+_*A,e[2]=p*L+y*I+h*A,e[3]=m*L+S*I+v*A,e[4]=d*R+g*D+x*C,e[5]=u*R+b*D+_*C,e[6]=p*R+y*D+h*C,e[7]=m*R+S*D+v*C,e[8]=d*T+g*w+x*k,e[9]=u*T+b*w+_*k,e[10]=p*T+y*w+h*k,e[11]=m*T+S*w+v*k,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ln(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],f=t[9],d=t[10],u=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]=o*r+c*n,e[5]=a*r+f*n,e[6]=s*r+d*n,e[7]=l*r+u*n,e[8]=c*r-o*n,e[9]=f*r-a*n,e[10]=d*r-s*n,e[11]=u*r-l*n,e}function Mn(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[8],f=t[9],d=t[10],u=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]=o*r-c*n,e[1]=a*r-f*n,e[2]=s*r-d*n,e[3]=l*r-u*n,e[8]=o*n+c*r,e[9]=a*n+f*r,e[10]=s*n+d*r,e[11]=l*n+u*r,e}function An(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[4],f=t[5],d=t[6],u=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]=o*r+c*n,e[1]=a*r+f*n,e[2]=s*r+d*n,e[3]=l*r+u*n,e[4]=c*r-o*n,e[5]=f*r-a*n,e[6]=d*r-s*n,e[7]=u*r-l*n,e}function Rn(e,t){let i=t[0],n=t[1],r=t[2],o=t[3],a=i+i,s=n+n,l=r+r,c=i*a,f=n*a,d=n*s,u=r*a,p=r*s,m=r*l,g=o*a,b=o*s,y=o*l;return e[0]=1-d-m,e[1]=f+y,e[2]=u-b,e[3]=0,e[4]=f-y,e[5]=1-c-m,e[6]=p+g,e[7]=0,e[8]=u+b,e[9]=p-g,e[10]=1-c-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Tn(e,t,i,n,r,o,a){let s=1/(i-t),l=1/(r-n),c=1/(o-a);return e[0]=o*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*l,e[6]=0,e[7]=0,e[8]=(i+t)*s,e[9]=(r+n)*l,e[10]=(a+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*c,e[15]=0,e}function Ss(e,t,i,n,r){let o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,r!=null&&r!==1/0){let a=1/(n-r);e[10]=(r+n)*a,e[14]=2*r*n*a}else e[10]=-1,e[14]=-2*n;return e}var En=Ss;function ys(e,t,i,n,r,o,a){let s=1/(t-i),l=1/(n-r),c=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*s,e[13]=(r+n)*l,e[14]=(a+o)*c,e[15]=1,e}var Pn=ys;function Dn(e,t,i,n){let r,o,a,s,l,c,f,d,u,p,m=t[0],g=t[1],b=t[2],y=n[0],S=n[1],x=n[2],_=i[0],h=i[1],v=i[2];return Math.abs(m-_)<1e-6&&Math.abs(g-h)<1e-6&&Math.abs(b-v)<1e-6?xs(e):(d=m-_,u=g-h,p=b-v,r=1/Math.sqrt(d*d+u*u+p*p),d*=r,u*=r,p*=r,o=S*p-x*u,a=x*d-y*p,s=y*u-S*d,r=Math.sqrt(o*o+a*a+s*s),r?(r=1/r,o*=r,a*=r,s*=r):(o=0,a=0,s=0),l=u*s-p*a,c=p*o-d*s,f=d*a-u*o,r=Math.sqrt(l*l+c*c+f*f),r?(r=1/r,l*=r,c*=r,f*=r):(l=0,c=0,f=0),e[0]=o,e[1]=l,e[2]=d,e[3]=0,e[4]=a,e[5]=c,e[6]=u,e[7]=0,e[8]=s,e[9]=f,e[10]=p,e[11]=0,e[12]=-(o*m+a*g+s*b),e[13]=-(l*m+c*g+f*b),e[14]=-(d*m+u*g+p*b),e[15]=1,e)}function jt(e){if(e.length!==16||Array.from(e).some(r=>!Number.isFinite(r))||e[3]!==0||e[7]!==0||e[11]!==0||e[15]!==1)throw new RangeError("Expected a finite affine matrix");let t=[Math.hypot(e[0],e[1],e[2]),Math.hypot(e[4],e[5],e[6]),Math.hypot(e[8],e[9],e[10])];if(t.some(r=>r===0||!Number.isFinite(r)))throw new RangeError("Singular transform");let i=Array.from({length:9},(r,o)=>e[Math.floor(o/3)*4+o%3]/t[Math.floor(o/3)]);for(let[r,o]of[[0,3],[0,6],[3,6]])if(Math.abs(i[r]*i[o]+i[r+1]*i[o+1]+i[r+2]*i[o+2])>1e-7)throw new RangeError("Sheared transforms do not have a TRS decomposition");if(i[0]*(i[4]*i[8]-i[5]*i[7])-i[3]*(i[1]*i[8]-i[2]*i[7])+i[6]*(i[1]*i[5]-i[2]*i[4])<0){t[0]=-t[0];for(let r=0;r<3;r++)i[r]=-i[r]}return{rotation:i,scale:t,translation:[e[12],e[13],e[14]]}}function Nn(e,t,i){let n=t[0],r=t[1],o=t[2],a=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*a,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*a,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*a,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*a,e}var Kt;(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"})(Kt||(Kt={}));var Cs=45*Math.PI/180,Is=1,qt=.1,$t=500,ws=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends Qe{static get IDENTITY(){return Ms()}static get ZERO(){return Ls()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kt}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,i,n,r,o,a,s,l,c,f,d,u,p,m,g,b){return this[0]=t,this[1]=i,this[2]=n,this[3]=r,this[4]=o,this[5]=a,this[6]=s,this[7]=l,this[8]=c,this[9]=f,this[10]=d,this[11]=u,this[12]=p,this[13]=m,this[14]=g,this[15]=b,this.check()}setRowMajor(t,i,n,r,o,a,s,l,c,f,d,u,p,m,g,b){return this[0]=t,this[1]=o,this[2]=c,this[3]=p,this[4]=i,this[5]=a,this[6]=f,this[7]=m,this[8]=n,this[9]=s,this[10]=d,this[11]=g,this[12]=r,this[13]=l,this[14]=u,this[15]=b,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(ws)}fromObject(t){return this.check()}fromQuaternion(t){return Rn(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:i,right:n,bottom:r,top:o,near:a=qt,far:s=$t}=t;return s===1/0?As(this,i,n,r,o,a):Tn(this,i,n,r,o,a,s),this.check()}lookAt(t){let{eye:i,center:n=[0,0,0],up:r=[0,1,0]}=t;return Dn(this,i,n,r),this.check()}ortho(t){let{left:i,right:n,bottom:r,top:o,near:a=qt,far:s=$t}=t;return Pn(this,i,n,r,o,a,s),this.check()}orthographic(t){let{fovy:i=Cs,aspect:n=Is,focalDistance:r=1,near:o=qt,far:a=$t}=t;Fn(i);let s=i/2,l=r*Math.tan(s),c=l*n;return this.ortho({left:-c,right:c,bottom:-l,top:l,near:o,far:a})}perspective(t){let{fovy:i=45*Math.PI/180,aspect:n=1,near:r=.1,far:o=500}=t;return Fn(i),En(this,i,n,r,o),this.check()}determinant(){return yn(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,i){let{rotation:n,scale:r}=jt(this);if(t=t||new Array(16),i)for(let o=0;o<3;o++)i[o]=r[o];for(let o=0;o<16;o++)t[o]=0;for(let o=0;o<9;o++)t[Math.floor(o/3)*4+o%3]=n[o];return t[15]=1,t}getRotationMatrix3(t,i){let{rotation:n,scale:r}=jt(this);if(t=t||new Array(9),i)for(let o=0;o<3;o++)i[o]=r[o];for(let o=0;o<9;o++)t[o]=n[o];return t}transpose(){return xn(this,this),this.check()}invert(){return Sn(this,this),this.check()}multiplyLeft(t){return Wt(this,t,this),this.check()}multiplyRight(t){return Wt(this,this,t),this.check()}rotateX(t){return Ln(this,this,t),this.check()}rotateY(t){return Mn(this,this,t),this.check()}rotateZ(t){return An(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return wn(this,this,t,i),this.check()}scale(t){return In(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Cn(this,this,t),this.check()}transform(t,i){return t.length===4?(i=Nn(i||[-0,-0,-0,-0],t,this),Je(i,4),i):this.transformAsPoint(t,i)}transformAsPoint(t,i){let{length:n}=t,r;switch(n){case 2:r=hn(i||[-0,-0],t,this);break;case 3:r=bn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Je(r,t.length),r}transformAsVector(t,i){let n;switch(t.length){case 2:n=_n(i||[-0,-0],t,this);break;case 3:n=vn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Je(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,i,n){return this.identity().translate([t,i,n])}},et,tt;function Ls(){return et||(et=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(et)),et}function Ms(){return tt||(tt=new V,Object.freeze(tt)),tt}function Fn(e){if(e>Math.PI*2)throw Error("expected radians")}function As(e,t,i,n,r,o){let a=2*o/(i-t),s=2*o/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),f=-1,d=-1,u=-2*o;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]=l,e[9]=c,e[10]=f,e[11]=d,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var te=null,Bn=new ArrayBuffer(4),On=new Float32Array(Bn),Un=new Uint32Array(Bn);function kn(e){te||=Vn(),e=Gt(e,-65504,65504),On[0]=e;let t=Un[0],i=t>>23&511;return te.baseTable[i]+((t&8388607)>>te.shiftTable[i])}function zn(e){te||=Vn();let t=e>>10;return Un[0]=te.mantissaTable[te.offsetTable[t]+(e&1023)]+te.exponentTable[t],On[0]}function Vn(){let e=new Uint32Array(512),t=new Uint32Array(512);for(let o=0;o<256;++o){let a=o-127;a<-27?(e[o]=0,e[o|256]=32768,t[o]=24,t[o|256]=24):a<-14?(e[o]=1024>>-a-14,e[o|256]=1024>>-a-14|32768,t[o]=-a-1,t[o|256]=-a-1):a<=15?(e[o]=a+15<<10,e[o|256]=a+15<<10|32768,t[o]=13,t[o|256]=13):a<128?(e[o]=31744,e[o|256]=64512,t[o]=24,t[o|256]=24):(e[o]=31744,e[o|256]=64512,t[o]=13,t[o|256]=13)}let i=new Uint32Array(2048),n=new Uint32Array(64),r=new Uint32Array(64);for(let o=1;o<1024;++o){let a=o<<13,s=0;for(;(a&8388608)===0;)a<<=1,s-=8388608;a&=-8388609,s+=947912704,i[o]=a|s}for(let o=1024;o<2048;++o)i[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)n[o]=o<<23;n[31]=1199570944,n[32]=2147483648;for(let o=33;o<63;++o)n[o]=2147483648+(o-32<<23);n[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(r[o]=1024);return{baseTable:e,shiftTable:t,mantissaTable:i,exponentTable:n,offsetTable:r}}function me(e,t=[],i=0){let n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function Ie(e){return e-Math.fround(e)}function we(e){let t=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){let r=i*4+n;me(e[n*4+i],t,r*2)}return t}function ie(e,t=!0){return e??t}function ne(e=[0,0,0],t=!0){return t?e.map(i=>i/255):[...e]}function it(e,t=!0){let i=ne(e.slice(0,3),t),n=Number.isFinite(e[3]),r=n?e[3]:1;return[i[0],i[1],i[2],t&&n?r/255:r]}var Gn={width:2,jitter:.7,variation:.35,grain:.45,offset:0,extension:3,sketch:1,minimumAntialias:.7},Hn=`
|
|
140
|
+
}`}function dn(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 pn(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 gs(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 zt(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 ee(e){return typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):e}function gn(e,t){return ms(e,t)}function ms(e,t){let i=[];switch(t.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":i.push(`layout(std140) uniform ${ee(e.name)} {`);break;case"uniforms":}for(let[n,r]of Object.entries(e.uniformTypes||{})){if(typeof r!="string")throw new Error(`Composite uniform types are not supported by GLSL shader generation: ${e.name}.${n}`);let o=hs(r);switch(t.uniforms){case"scoped-interface-blocks":i.push(` ${o} ${n};`);break;case"unscoped-interface-blocks":i.push(` ${o} ${e.name}_${n};`);break;case"uniforms":i.push(`uniform ${o} ${e.name}_${n};`)}}switch(t.uniforms){case"scoped-interface-blocks":i.push(`} ${e.name};`);break;case"unscoped-interface-blocks":i.push("};");break;case"uniforms":}return i.push(""),i.join(`
|
|
141
|
+
`)}function hs(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 mn(e,t){return vs(e,t)}function vs(e,t){let i=[];i.push(`struct ${ee(e.name)} {`);for(let[n,r]of Object.entries(e?.uniformTypes||{})){if(typeof r!="string")throw new Error(`Composite uniform types are not supported by WGSL shader generation: ${e.name}.${n}`);let o=r;i.push(` ${n} : ${o};`)}return i.push("};"),i.push(`var<uniform> ${e.name} : ${ee(e.name)};`),i.join(`
|
|
142
|
+
`)}function hn(e,t){switch(t.shaderLanguage){case"glsl":return gn(e,t);case"wgsl":return mn(e,t)}}var wf=1/Math.PI*180,Lf=1/180*Math.PI,_s={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{..._s}};var N=globalThis.mathgl.config;function Vt(e,{precision:t=N.precision}={}){return e=bs(e),`${parseFloat(e.toPrecision(t))}`}function pe(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Gt(e,t,i){return Ss(e,n=>Math.max(t,Math.min(i,n)))}function Xe(e,t,i){let n=N.EPSILON;i&&(N.EPSILON=i);try{if(e===t)return!0;if(pe(e)&&pe(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Xe(e[r],t[r]))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)<=N.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{N.EPSILON=n}}function bs(e){return Math.round(e/N.EPSILON)*N.EPSILON}function xs(e){return e.clone?e.clone():new Array(e.length)}function Ss(e,t,i){if(pe(e)){let n=e;i=i||xs(n);for(let r=0;r<i.length&&r<n.length;++r){let o=typeof e=="number"?e:e[r];i[r]=t(o,r,i)}return i}return t(e)}var Ze=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,i=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+i];return this.check()}toArray(t=[],i=0){for(let n=0;n<this.ELEMENTS;++n)t[i+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:pe(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(N)}formatString(t){let i="";for(let n=0;n<this.ELEMENTS;++n)i+=(n>0?", ":"")+Vt(this[n],t);return`${t.printTypes?this.constructor.name:""}[${i}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(!Xe(this[i],t[i]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(this[i]!==t[i])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,i,n){if(n===void 0)return this.lerp(this,t,i);for(let r=0;r<this.ELEMENTS;++r){let o=t[r],a=typeof i=="number"?i:i[r];this[r]=o+n*(a-o)}return this.check()}min(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(t[i],this[i]);return this.check()}max(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.max(t[i],this[i]);return this.check()}clamp(t,i){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),i[n]);return this.check()}add(...t){for(let i of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=i[n];return this.check()}subtract(...t){for(let i of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=i[n];return this.check()}scale(t){if(typeof t=="number")for(let i=0;i<this.ELEMENTS;++i)this[i]*=t;else for(let i=0;i<this.ELEMENTS&&i<t.length;++i)this[i]*=t[i];return this.check()}multiplyByScalar(t){for(let i=0;i<this.ELEMENTS;++i)this[i]*=t;return this.check()}check(){if(N.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 i=0;i<this.ELEMENTS;++i)t=t&&Number.isFinite(this[i]);return t}};function ys(e,t){if(e.length!==t)return!1;for(let i=0;i<e.length;++i)if(!Number.isFinite(e[i]))return!1;return!0}function vn(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Je(e,t,i=""){if(N.debug&&!ys(e,t))throw new Error(`math.gl: ${i} some fields set to invalid numbers'`);return e}var Qe=class extends Ze{toString(){let t="[";if(N.printRowMajor){t+="row-major:";for(let i=0;i<this.RANK;++i)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+i]}`}else{t+="column-major:";for(let i=0;i<this.ELEMENTS;++i)t+=` ${this[i]}`}return t+="]",t}getElementIndex(t,i){return i*this.RANK+t}getElement(t,i){return this[i*this.RANK+t]}setElement(t,i,n){return this[i*this.RANK+t]=vn(n),this}getColumn(t,i=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let r=0;r<this.RANK;++r)i[r]=this[n+r];return i}setColumn(t,i){let n=t*this.RANK;for(let r=0;r<this.RANK;++r)this[n+r]=i[r];return this}};function _n(e,t,i){let n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e}function bn(e,t,i){let n=t[0],r=t[1],o=i[3]*n+i[7]*r||1;return e[0]=(i[0]*n+i[4]*r)/o,e[1]=(i[1]*n+i[5]*r)/o,e}function xn(e,t,i){let n=t[0],r=t[1],o=t[2],a=i[3]*n+i[7]*r+i[11]*o||1;return e[0]=(i[0]*n+i[4]*r+i[8]*o)/a,e[1]=(i[1]*n+i[5]*r+i[9]*o)/a,e[2]=(i[2]*n+i[6]*r+i[10]*o)/a,e}function Sn(e,t,i){let n=t[0],r=t[1],o=t[2],a=i[3]*n+i[7]*r+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/a,e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/a,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/a,e}function Cs(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 yn(e,t){if(e===t){let i=t[1],n=t[2],r=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=r,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 Cn(e,t){let i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],f=t[8],d=t[9],u=t[10],p=t[11],g=t[12],m=t[13],b=t[14],y=t[15],S=i*s-n*a,x=i*l-r*a,v=i*c-o*a,h=n*l-r*s,_=n*c-o*s,L=r*c-o*l,I=f*m-d*g,A=f*b-u*g,R=f*y-p*g,D=d*b-u*m,C=d*y-p*m,T=u*y-p*b,w=S*T-x*C+v*D+h*R-_*A+L*I;return w?(w=1/w,e[0]=(s*T-l*C+c*D)*w,e[1]=(r*C-n*T-o*D)*w,e[2]=(m*L-b*_+y*h)*w,e[3]=(u*_-d*L-p*h)*w,e[4]=(l*R-a*T-c*A)*w,e[5]=(i*T-r*R+o*A)*w,e[6]=(b*v-g*L-y*x)*w,e[7]=(f*L-u*v+p*x)*w,e[8]=(a*C-s*R+c*I)*w,e[9]=(n*R-i*C-o*I)*w,e[10]=(g*_-m*v+y*S)*w,e[11]=(d*v-f*_-p*S)*w,e[12]=(s*A-a*D-l*I)*w,e[13]=(i*D-n*A+r*I)*w,e[14]=(m*x-g*h-b*S)*w,e[15]=(f*h-d*x+u*S)*w,e):null}function In(e){let t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],f=e[9],d=e[10],u=e[11],p=e[12],g=e[13],m=e[14],b=e[15],y=t*a-i*o,S=t*s-n*o,x=i*s-n*a,v=c*g-f*p,h=c*m-d*p,_=f*m-d*g,L=t*_-i*h+n*v,I=o*_-a*h+s*v,A=c*x-f*S+d*y,R=p*x-g*S+m*y;return l*L-r*I+b*A-u*R}function Wt(e,t,i){let n=t[0],r=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],f=t[7],d=t[8],u=t[9],p=t[10],g=t[11],m=t[12],b=t[13],y=t[14],S=t[15],x=i[0],v=i[1],h=i[2],_=i[3];return e[0]=x*n+v*s+h*d+_*m,e[1]=x*r+v*l+h*u+_*b,e[2]=x*o+v*c+h*p+_*y,e[3]=x*a+v*f+h*g+_*S,x=i[4],v=i[5],h=i[6],_=i[7],e[4]=x*n+v*s+h*d+_*m,e[5]=x*r+v*l+h*u+_*b,e[6]=x*o+v*c+h*p+_*y,e[7]=x*a+v*f+h*g+_*S,x=i[8],v=i[9],h=i[10],_=i[11],e[8]=x*n+v*s+h*d+_*m,e[9]=x*r+v*l+h*u+_*b,e[10]=x*o+v*c+h*p+_*y,e[11]=x*a+v*f+h*g+_*S,x=i[12],v=i[13],h=i[14],_=i[15],e[12]=x*n+v*s+h*d+_*m,e[13]=x*r+v*l+h*u+_*b,e[14]=x*o+v*c+h*p+_*y,e[15]=x*a+v*f+h*g+_*S,e}function wn(e,t,i){let n=i[0],r=i[1],o=i[2],a,s,l,c,f,d,u,p,g,m,b,y;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*o+t[12],e[13]=t[1]*n+t[5]*r+t[9]*o+t[13],e[14]=t[2]*n+t[6]*r+t[10]*o+t[14],e[15]=t[3]*n+t[7]*r+t[11]*o+t[15]):(a=t[0],s=t[1],l=t[2],c=t[3],f=t[4],d=t[5],u=t[6],p=t[7],g=t[8],m=t[9],b=t[10],y=t[11],e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=f,e[5]=d,e[6]=u,e[7]=p,e[8]=g,e[9]=m,e[10]=b,e[11]=y,e[12]=a*n+f*r+g*o+t[12],e[13]=s*n+d*r+m*o+t[13],e[14]=l*n+u*r+b*o+t[14],e[15]=c*n+p*r+y*o+t[15]),e}function Ln(e,t,i){let n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Mn(e,t,i,n){let r=n[0],o=n[1],a=n[2],s=Math.sqrt(r*r+o*o+a*a),l,c,f,d,u,p,g,m,b,y,S,x,v,h,_,L,I,A,R,D,C,T,w,z;return s<1e-6?null:(s=1/s,r*=s,o*=s,a*=s,c=Math.sin(i),l=Math.cos(i),f=1-l,d=t[0],u=t[1],p=t[2],g=t[3],m=t[4],b=t[5],y=t[6],S=t[7],x=t[8],v=t[9],h=t[10],_=t[11],L=r*r*f+l,I=o*r*f+a*c,A=a*r*f-o*c,R=r*o*f-a*c,D=o*o*f+l,C=a*o*f+r*c,T=r*a*f+o*c,w=o*a*f-r*c,z=a*a*f+l,e[0]=d*L+m*I+x*A,e[1]=u*L+b*I+v*A,e[2]=p*L+y*I+h*A,e[3]=g*L+S*I+_*A,e[4]=d*R+m*D+x*C,e[5]=u*R+b*D+v*C,e[6]=p*R+y*D+h*C,e[7]=g*R+S*D+_*C,e[8]=d*T+m*w+x*z,e[9]=u*T+b*w+v*z,e[10]=p*T+y*w+h*z,e[11]=g*T+S*w+_*z,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function An(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],f=t[9],d=t[10],u=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]=o*r+c*n,e[5]=a*r+f*n,e[6]=s*r+d*n,e[7]=l*r+u*n,e[8]=c*r-o*n,e[9]=f*r-a*n,e[10]=d*r-s*n,e[11]=u*r-l*n,e}function Rn(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[8],f=t[9],d=t[10],u=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]=o*r-c*n,e[1]=a*r-f*n,e[2]=s*r-d*n,e[3]=l*r-u*n,e[8]=o*n+c*r,e[9]=a*n+f*r,e[10]=s*n+d*r,e[11]=l*n+u*r,e}function Tn(e,t,i){let n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[4],f=t[5],d=t[6],u=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]=o*r+c*n,e[1]=a*r+f*n,e[2]=s*r+d*n,e[3]=l*r+u*n,e[4]=c*r-o*n,e[5]=f*r-a*n,e[6]=d*r-s*n,e[7]=u*r-l*n,e}function En(e,t){let i=t[0],n=t[1],r=t[2],o=t[3],a=i+i,s=n+n,l=r+r,c=i*a,f=n*a,d=n*s,u=r*a,p=r*s,g=r*l,m=o*a,b=o*s,y=o*l;return e[0]=1-d-g,e[1]=f+y,e[2]=u-b,e[3]=0,e[4]=f-y,e[5]=1-c-g,e[6]=p+m,e[7]=0,e[8]=u+b,e[9]=p-m,e[10]=1-c-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Pn(e,t,i,n,r,o,a){let s=1/(i-t),l=1/(r-n),c=1/(o-a);return e[0]=o*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*l,e[6]=0,e[7]=0,e[8]=(i+t)*s,e[9]=(r+n)*l,e[10]=(a+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*c,e[15]=0,e}function Is(e,t,i,n,r){let o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,r!=null&&r!==1/0){let a=1/(n-r);e[10]=(r+n)*a,e[14]=2*r*n*a}else e[10]=-1,e[14]=-2*n;return e}var Dn=Is;function ws(e,t,i,n,r,o,a){let s=1/(t-i),l=1/(n-r),c=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*s,e[13]=(r+n)*l,e[14]=(a+o)*c,e[15]=1,e}var Nn=ws;function Fn(e,t,i,n){let r,o,a,s,l,c,f,d,u,p,g=t[0],m=t[1],b=t[2],y=n[0],S=n[1],x=n[2],v=i[0],h=i[1],_=i[2];return Math.abs(g-v)<1e-6&&Math.abs(m-h)<1e-6&&Math.abs(b-_)<1e-6?Cs(e):(d=g-v,u=m-h,p=b-_,r=1/Math.sqrt(d*d+u*u+p*p),d*=r,u*=r,p*=r,o=S*p-x*u,a=x*d-y*p,s=y*u-S*d,r=Math.sqrt(o*o+a*a+s*s),r?(r=1/r,o*=r,a*=r,s*=r):(o=0,a=0,s=0),l=u*s-p*a,c=p*o-d*s,f=d*a-u*o,r=Math.sqrt(l*l+c*c+f*f),r?(r=1/r,l*=r,c*=r,f*=r):(l=0,c=0,f=0),e[0]=o,e[1]=l,e[2]=d,e[3]=0,e[4]=a,e[5]=c,e[6]=u,e[7]=0,e[8]=s,e[9]=f,e[10]=p,e[11]=0,e[12]=-(o*g+a*m+s*b),e[13]=-(l*g+c*m+f*b),e[14]=-(d*g+u*m+p*b),e[15]=1,e)}function jt(e){if(e.length!==16||Array.from(e).some(r=>!Number.isFinite(r))||e[3]!==0||e[7]!==0||e[11]!==0||e[15]!==1)throw new RangeError("Expected a finite affine matrix");let t=[Math.hypot(e[0],e[1],e[2]),Math.hypot(e[4],e[5],e[6]),Math.hypot(e[8],e[9],e[10])];if(t.some(r=>r===0||!Number.isFinite(r)))throw new RangeError("Singular transform");let i=Array.from({length:9},(r,o)=>e[Math.floor(o/3)*4+o%3]/t[Math.floor(o/3)]);for(let[r,o]of[[0,3],[0,6],[3,6]])if(Math.abs(i[r]*i[o]+i[r+1]*i[o+1]+i[r+2]*i[o+2])>1e-7)throw new RangeError("Sheared transforms do not have a TRS decomposition");if(i[0]*(i[4]*i[8]-i[5]*i[7])-i[3]*(i[1]*i[8]-i[2]*i[7])+i[6]*(i[1]*i[5]-i[2]*i[4])<0){t[0]=-t[0];for(let r=0;r<3;r++)i[r]=-i[r]}return{rotation:i,scale:t,translation:[e[12],e[13],e[14]]}}function Bn(e,t,i){let n=t[0],r=t[1],o=t[2],a=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*a,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*a,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*a,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*a,e}var Kt;(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"})(Kt||(Kt={}));var Ls=45*Math.PI/180,Ms=1,qt=.1,$t=500,As=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends Qe{static get IDENTITY(){return Ts()}static get ZERO(){return Rs()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kt}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,i,n,r,o,a,s,l,c,f,d,u,p,g,m,b){return this[0]=t,this[1]=i,this[2]=n,this[3]=r,this[4]=o,this[5]=a,this[6]=s,this[7]=l,this[8]=c,this[9]=f,this[10]=d,this[11]=u,this[12]=p,this[13]=g,this[14]=m,this[15]=b,this.check()}setRowMajor(t,i,n,r,o,a,s,l,c,f,d,u,p,g,m,b){return this[0]=t,this[1]=o,this[2]=c,this[3]=p,this[4]=i,this[5]=a,this[6]=f,this[7]=g,this[8]=n,this[9]=s,this[10]=d,this[11]=m,this[12]=r,this[13]=l,this[14]=u,this[15]=b,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(As)}fromObject(t){return this.check()}fromQuaternion(t){return En(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:i,right:n,bottom:r,top:o,near:a=qt,far:s=$t}=t;return s===1/0?Es(this,i,n,r,o,a):Pn(this,i,n,r,o,a,s),this.check()}lookAt(t){let{eye:i,center:n=[0,0,0],up:r=[0,1,0]}=t;return Fn(this,i,n,r),this.check()}ortho(t){let{left:i,right:n,bottom:r,top:o,near:a=qt,far:s=$t}=t;return Nn(this,i,n,r,o,a,s),this.check()}orthographic(t){let{fovy:i=Ls,aspect:n=Ms,focalDistance:r=1,near:o=qt,far:a=$t}=t;On(i);let s=i/2,l=r*Math.tan(s),c=l*n;return this.ortho({left:-c,right:c,bottom:-l,top:l,near:o,far:a})}perspective(t){let{fovy:i=45*Math.PI/180,aspect:n=1,near:r=.1,far:o=500}=t;return On(i),Dn(this,i,n,r,o),this.check()}determinant(){return In(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,i){let{rotation:n,scale:r}=jt(this);if(t=t||new Array(16),i)for(let o=0;o<3;o++)i[o]=r[o];for(let o=0;o<16;o++)t[o]=0;for(let o=0;o<9;o++)t[Math.floor(o/3)*4+o%3]=n[o];return t[15]=1,t}getRotationMatrix3(t,i){let{rotation:n,scale:r}=jt(this);if(t=t||new Array(9),i)for(let o=0;o<3;o++)i[o]=r[o];for(let o=0;o<9;o++)t[o]=n[o];return t}transpose(){return yn(this,this),this.check()}invert(){return Cn(this,this),this.check()}multiplyLeft(t){return Wt(this,t,this),this.check()}multiplyRight(t){return Wt(this,this,t),this.check()}rotateX(t){return An(this,this,t),this.check()}rotateY(t){return Rn(this,this,t),this.check()}rotateZ(t){return Tn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return Mn(this,this,t,i),this.check()}scale(t){return Ln(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return wn(this,this,t),this.check()}transform(t,i){return t.length===4?(i=Bn(i||[-0,-0,-0,-0],t,this),Je(i,4),i):this.transformAsPoint(t,i)}transformAsPoint(t,i){let{length:n}=t,r;switch(n){case 2:r=_n(i||[-0,-0],t,this);break;case 3:r=Sn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Je(r,t.length),r}transformAsVector(t,i){let n;switch(t.length){case 2:n=bn(i||[-0,-0],t,this);break;case 3:n=xn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Je(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,i,n){return this.identity().translate([t,i,n])}},et,tt;function Rs(){return et||(et=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(et)),et}function Ts(){return tt||(tt=new G,Object.freeze(tt)),tt}function On(e){if(e>Math.PI*2)throw Error("expected radians")}function Es(e,t,i,n,r,o){let a=2*o/(i-t),s=2*o/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),f=-1,d=-1,u=-2*o;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]=l,e[9]=c,e[10]=f,e[11]=d,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var te=null,Un=new ArrayBuffer(4),kn=new Float32Array(Un),zn=new Uint32Array(Un);function Vn(e){te||=Hn(),e=Gt(e,-65504,65504),kn[0]=e;let t=zn[0],i=t>>23&511;return te.baseTable[i]+((t&8388607)>>te.shiftTable[i])}function Gn(e){te||=Hn();let t=e>>10;return zn[0]=te.mantissaTable[te.offsetTable[t]+(e&1023)]+te.exponentTable[t],kn[0]}function Hn(){let e=new Uint32Array(512),t=new Uint32Array(512);for(let o=0;o<256;++o){let a=o-127;a<-27?(e[o]=0,e[o|256]=32768,t[o]=24,t[o|256]=24):a<-14?(e[o]=1024>>-a-14,e[o|256]=1024>>-a-14|32768,t[o]=-a-1,t[o|256]=-a-1):a<=15?(e[o]=a+15<<10,e[o|256]=a+15<<10|32768,t[o]=13,t[o|256]=13):a<128?(e[o]=31744,e[o|256]=64512,t[o]=24,t[o|256]=24):(e[o]=31744,e[o|256]=64512,t[o]=13,t[o|256]=13)}let i=new Uint32Array(2048),n=new Uint32Array(64),r=new Uint32Array(64);for(let o=1;o<1024;++o){let a=o<<13,s=0;for(;(a&8388608)===0;)a<<=1,s-=8388608;a&=-8388609,s+=947912704,i[o]=a|s}for(let o=1024;o<2048;++o)i[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)n[o]=o<<23;n[31]=1199570944,n[32]=2147483648;for(let o=33;o<63;++o)n[o]=2147483648+(o-32<<23);n[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(r[o]=1024);return{baseTable:e,shiftTable:t,mantissaTable:i,exponentTable:n,offsetTable:r}}function ge(e,t=[],i=0){let n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function Ie(e){return e-Math.fround(e)}function we(e){let t=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){let r=i*4+n;ge(e[n*4+i],t,r*2)}return t}function ie(e,t=!0){return e??t}function ne(e=[0,0,0],t=!0){return t?e.map(i=>i/255):[...e]}function it(e,t=!0){let i=ne(e.slice(0,3),t),n=Number.isFinite(e[3]),r=n?e[3]:1;return[i[0],i[1],i[2],t&&n?r/255:r]}var Wn={width:2,jitter:.7,variation:.35,grain:.45,offset:0,extension:3,sketch:1,minimumAntialias:.7},jn=`
|
|
143
143
|
layout(std140) uniform sketchStrokeUniforms {
|
|
144
144
|
float width;
|
|
145
145
|
float jitter;
|
|
@@ -150,7 +150,7 @@ layout(std140) uniform sketchStrokeUniforms {
|
|
|
150
150
|
float sketch;
|
|
151
151
|
float minimumAntialias;
|
|
152
152
|
} sketchStroke;
|
|
153
|
-
`,
|
|
153
|
+
`,Ps=`
|
|
154
154
|
float sketchStroke_noise(float coordinate) {
|
|
155
155
|
float cell = floor(coordinate);
|
|
156
156
|
float fraction = fract(coordinate);
|
|
@@ -189,7 +189,7 @@ float sketchStroke_getCoverage(vec2 coordinates, float strokeLength, float seed)
|
|
|
189
189
|
// Keep the pigment opaque; grain changes the stroke edge so the paper does not show through as white flecks.
|
|
190
190
|
return coverage;
|
|
191
191
|
}
|
|
192
|
-
`,
|
|
192
|
+
`,Ds=`
|
|
193
193
|
struct sketchStrokeUniforms {
|
|
194
194
|
width: f32,
|
|
195
195
|
jitter: f32,
|
|
@@ -237,7 +237,7 @@ fn sketchStroke_getCoverage(coordinates: vec2<f32>, strokeLength: f32, seed: f32
|
|
|
237
237
|
// Keep the pigment opaque; grain changes the stroke edge so the paper does not show through as white flecks.
|
|
238
238
|
return coverage;
|
|
239
239
|
}
|
|
240
|
-
`,
|
|
240
|
+
`,qn={name:"sketchStroke",bindingLayout:[{name:"sketchStroke",group:3}],source:Ds,vs:jn,fs:jn+Ps,uniformTypes:{width:"f32",jitter:"f32",variation:"f32",grain:"f32",offset:"f32",extension:"f32",sketch:"f32",minimumAntialias:"f32"},defaultUniforms:Wn,getUniforms(e={}){return{...Wn,...e}}};var Yt={dashLength:12,gapLength:8,offset:0},$n={name:"pathDash",bindingLayout:[{name:"pathDash",group:3}],firstBindingSlot:0,uniformTypes:{dashLength:"f32",gapLength:"f32",offset:"f32"},defaultUniforms:Yt,getUniforms(e={},t=Yt){let i={...Yt,...t};return e.dashLength!==void 0&&(i.dashLength=Math.max(0,e.dashLength)),e.gapLength!==void 0&&(i.gapLength=Math.max(0,e.gapLength)),e.offset!==void 0&&(i.offset=e.offset),i},fs:`
|
|
241
241
|
layout(std140) uniform pathDashUniforms {
|
|
242
242
|
float dashLength;
|
|
243
243
|
float gapLength;
|
|
@@ -278,14 +278,14 @@ fn pathDash_getCoverage(distanceAlongPath: f32) -> f32 {
|
|
|
278
278
|
if (pathDash.dashLength <= 0.0) { return 0.0; }
|
|
279
279
|
return clamp(coverage, 0.0, 1.0);
|
|
280
280
|
}
|
|
281
|
-
`};var
|
|
281
|
+
`};var Ns=`fn random(scale: vec3f, seed: f32) -> f32 {
|
|
282
282
|
return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);
|
|
283
283
|
}
|
|
284
|
-
`,
|
|
284
|
+
`,Fs=`float random(vec3 scale, float seed) {
|
|
285
285
|
/* use the fragment position for a different seed per-pixel */
|
|
286
286
|
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
|
287
287
|
}
|
|
288
|
-
`,
|
|
288
|
+
`,Kn={name:"random",source:Ns,fs:Fs};var Bs=`fn volumeRaymarch_intersectBox(origin: vec3f, direction: vec3f, minimum: vec3f, maximum: vec3f) -> vec2f {
|
|
289
289
|
let safeDirection = select(vec3f(0.000001), direction, abs(direction) > vec3f(0.000001));
|
|
290
290
|
let first = (minimum - origin) / safeDirection;
|
|
291
291
|
let second = (maximum - origin) / safeDirection;
|
|
@@ -358,7 +358,7 @@ fn volumeRaymarch_composite(accumulated: vec4f, color: vec3f, alpha: f32) -> vec
|
|
|
358
358
|
let contribution = (1.0 - accumulated.a) * clamp(alpha, 0.0, 1.0);
|
|
359
359
|
return vec4f(accumulated.rgb + color * contribution, accumulated.a + contribution);
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
`,Yn={name:"volumeRaymarch",source:Bs};var Os=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
362
362
|
|
|
363
363
|
// All these functions are for substituting tan() function from Intel GPU only
|
|
364
364
|
const float TWO_PI = 6.2831854820251465;
|
|
@@ -508,7 +508,7 @@ float tan_fp32(float a) {
|
|
|
508
508
|
return tan(a);
|
|
509
509
|
#endif
|
|
510
510
|
}
|
|
511
|
-
`,
|
|
511
|
+
`,Us=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
512
512
|
const FP32_TWO_PI: f32 = 6.2831854820251465;
|
|
513
513
|
const FP32_PI_2: f32 = 1.5707963705062866;
|
|
514
514
|
const FP32_PI_16: f32 = 0.1963495463132858;
|
|
@@ -629,7 +629,7 @@ fn tan_fp32(a: f32) -> f32 {
|
|
|
629
629
|
return tan(a);
|
|
630
630
|
}
|
|
631
631
|
#endif
|
|
632
|
-
`,
|
|
632
|
+
`,Xn={name:"fp32",source:Us,vs:Os};var Xt=`
|
|
633
633
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
634
634
|
uniform float ONE;
|
|
635
635
|
uniform float SPLIT;
|
|
@@ -1107,7 +1107,7 @@ fn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
#endif
|
|
1109
1109
|
|
|
1110
|
-
`,
|
|
1110
|
+
`,Zn=`${Zt}
|
|
1111
1111
|
|
|
1112
1112
|
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
1113
1113
|
fn split(a: f32) -> vec2f {
|
|
@@ -1375,7 +1375,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
1375
1375
|
return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2);
|
|
1376
1376
|
}
|
|
1377
1377
|
#endif
|
|
1378
|
-
`;var
|
|
1378
|
+
`;var Jn=`${Zt}
|
|
1379
1379
|
|
|
1380
1380
|
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
1381
1381
|
fn split(a: f32) -> vec2f {
|
|
@@ -1488,7 +1488,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
1488
1488
|
return sum_fp64(vec2f(estimate, 0.0), correction);
|
|
1489
1489
|
}
|
|
1490
1490
|
#endif
|
|
1491
|
-
`;var
|
|
1491
|
+
`;var Qn=`struct Fp64ArithmeticUniforms {
|
|
1492
1492
|
ONE: f32,
|
|
1493
1493
|
SPLIT: f32,
|
|
1494
1494
|
};
|
|
@@ -2121,10 +2121,10 @@ fn prevent_fp64_optimization(value: f32) -> f32 {
|
|
|
2121
2121
|
#endif
|
|
2122
2122
|
|
|
2123
2123
|
#ifdef LUMA_FP64_INTEGER_ARITHMETIC
|
|
2124
|
-
${
|
|
2124
|
+
${Zn}
|
|
2125
2125
|
#else
|
|
2126
2126
|
#ifdef LUMA_FP64_HYBRID_ARITHMETIC
|
|
2127
|
-
${
|
|
2127
|
+
${Jn}
|
|
2128
2128
|
#else
|
|
2129
2129
|
fn split(a: f32) -> vec2f {
|
|
2130
2130
|
let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
|
|
@@ -2402,7 +2402,7 @@ fn fp64_scale_fp64(value: vec2f, exponent: i32) -> vec2f {
|
|
|
2402
2402
|
#endif
|
|
2403
2403
|
}
|
|
2404
2404
|
#endif
|
|
2405
|
-
`;var
|
|
2405
|
+
`;var er=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
2406
2406
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
2407
2407
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
2408
2408
|
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -3071,7 +3071,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
3071
3071
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
3072
3072
|
}
|
|
3073
3073
|
}
|
|
3074
|
-
`;var
|
|
3074
|
+
`;var tr=`const E_FP64 = vec2f(2.7182817459106445, 8.254840366817007e-8);
|
|
3075
3075
|
const LOG2_FP64 = vec2f(0.6931471824645996, -1.9046542121259336e-9);
|
|
3076
3076
|
const PI_FP64 = vec2f(3.1415927410125732, -8.742278012618954e-8);
|
|
3077
3077
|
const TWO_PI_FP64 = vec2f(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -3221,7 +3221,7 @@ fn mat4_vec4_mul_fp64(matrix: array<vec2f, 16>, a: array<vec2f, 4>) -> array<vec
|
|
|
3221
3221
|
}
|
|
3222
3222
|
return result;
|
|
3223
3223
|
}
|
|
3224
|
-
`;var
|
|
3224
|
+
`;var ks={ONE:1,SPLIT:4097},Jt={name:"fp64arithmetic",source:Qn,fs:Xt,vs:Xt,defaultUniforms:ks,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:ge,fp64LowPart:Ie,fp64ifyMatrix4:we},ir={name:"fp64",source:tr,vs:er,dependencies:[Jt],fp64ify:ge,fp64LowPart:Ie,fp64ifyMatrix4:we};var nr=`const DGGS_H3_CELL_MODE: u32 = 1u;
|
|
3225
3225
|
const DGGS_H3_MAX_RESOLUTION: u32 = 15u;
|
|
3226
3226
|
const DGGS_H3_MAX_BASE_CELL: u32 = 121u;
|
|
3227
3227
|
const DGGS_H3_UNUSED_DIGIT: u32 = 7u;
|
|
@@ -5495,7 +5495,7 @@ fn dggs_s2_get_boundary_point(index: vec2u, vertexIndex: u32) -> vec2f {
|
|
|
5495
5495
|
fn dggs_s2_get_boundary_point_fp64_split(index: vec2u, vertexIndex: u32) -> vec4f {
|
|
5496
5496
|
return dggs_boundary_point_to_fp64_split(dggs_s2_get_boundary_point(index, vertexIndex));
|
|
5497
5497
|
}
|
|
5498
|
-
`;var
|
|
5498
|
+
`;var rr={name:"dggs",source:nr};var k={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},nt={rgba8unorm:4,rgba16float:8,rgba32float:16},rt={...nt},Qt={rgba8unorm:k.RGBA8UNORM,rgba16float:k.RGBA16FLOAT,rgba32float:k.RGBA32FLOAT},lr={[k.RGBA8UNORM]:"rgba8unorm",[k.RGBA16FLOAT]:"rgba16float",[k.RGBA32FLOAT]:"rgba32float"},cr={useByteColors:"f32"},fr={useByteColors:!0},zs={format:"u32",wordStride:"u32",wordOffset:"u32",_padding:"u32"},Vs={format:k.RGBA8UNORM,wordStride:rt.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},or=ur("colors"),ar=ur("floatColors"),Gs=dr("colors"),Hs=dr("floatColors"),Ws=`struct storageColorsUniforms {
|
|
5499
5499
|
format: u32,
|
|
5500
5500
|
wordStride: u32,
|
|
5501
5501
|
wordOffset: u32,
|
|
@@ -5505,8 +5505,8 @@ fn dggs_s2_get_boundary_point_fp64_split(index: vec2u, vertexIndex: u32) -> vec4
|
|
|
5505
5505
|
@group(0) @binding(auto) var<uniform> storageColors : storageColorsUniforms;
|
|
5506
5506
|
@group(0) @binding(auto) var<storage, read> storageColorsBuffer : array<u32>;
|
|
5507
5507
|
|
|
5508
|
-
const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${
|
|
5509
|
-
const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${
|
|
5508
|
+
const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${k.RGBA8UNORM}u;
|
|
5509
|
+
const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${k.RGBA16FLOAT}u;
|
|
5510
5510
|
|
|
5511
5511
|
fn storageColors_getWordIndex(rowIndex: u32) -> u32 {
|
|
5512
5512
|
return storageColors.wordOffset + rowIndex * storageColors.wordStride;
|
|
@@ -5541,7 +5541,7 @@ fn storageColors_readColor(rowIndex: u32) -> vec4<f32> {
|
|
|
5541
5541
|
}
|
|
5542
5542
|
return storageColors_readRgba32FloatColor(wordIndex);
|
|
5543
5543
|
}
|
|
5544
|
-
`;function
|
|
5544
|
+
`;function ur(e){return`layout(std140) uniform ${e}Uniforms {
|
|
5545
5545
|
float useByteColors;
|
|
5546
5546
|
} ${e};
|
|
5547
5547
|
|
|
@@ -5568,7 +5568,7 @@ vec4 ${e}_premultiply_alpha(vec4 inputColor) {
|
|
|
5568
5568
|
vec4 ${e}_unpremultiply_alpha(vec4 inputColor) {
|
|
5569
5569
|
return ${e}_unpremultiplyAlpha(inputColor);
|
|
5570
5570
|
}
|
|
5571
|
-
`}function
|
|
5571
|
+
`}function dr(e){return`struct ${e}Uniforms {
|
|
5572
5572
|
useByteColors: f32
|
|
5573
5573
|
};
|
|
5574
5574
|
|
|
@@ -5601,7 +5601,7 @@ fn ${e}_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
|
5601
5601
|
fn ${e}_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
5602
5602
|
return ${e}_unpremultiplyAlpha(inputColor);
|
|
5603
5603
|
}
|
|
5604
|
-
`}function
|
|
5604
|
+
`}function js(e={}){let t=qs(e.format),i=lr[t],n=e.byteStride??rt[i],r=e.byteOffset??0,o=nt[i];if(sr("byteStride",n),sr("byteOffset",r),n<o)throw new Error(`storageColors byteStride must be at least ${o} for ${i}`);return{format:t,wordStride:n/Uint32Array.BYTES_PER_ELEMENT,wordOffset:r/Uint32Array.BYTES_PER_ELEMENT,_padding:0}}function qs(e="rgba8unorm"){if(typeof e=="number"){if(e in lr)return e}else if(e in Qt)return Qt[e];throw new Error(`storageColors format must be one of ${Object.keys(Qt).join(", ")}`)}function sr(e,t){if(!Number.isInteger(t)||t<0||t%Uint32Array.BYTES_PER_ELEMENT!==0)throw new Error(`storageColors ${e} must be a non-negative 4-byte aligned integer`)}var pr={name:"colors",props:{},uniforms:{},vs:or,fs:or,source:Gs,uniformTypes:cr,defaultUniforms:fr},me={name:"floatColors",props:{},uniforms:{},vs:ar,fs:ar,source:Hs,uniformTypes:cr,defaultUniforms:fr},gr={name:"storageColors",props:{},uniforms:{},bindings:{},source:Ws,uniformTypes:zs,defaultUniforms:Vs,bindingLayout:[{name:"storageColors",group:0},{name:"storageColorsBuffer",group:0}],getUniforms(e={}){return{...js(e),...e.colorBuffer?{storageColorsBuffer:e.colorBuffer}:{}}}};var $s=[0,1,1,1],Ks=`layout(std140) uniform pickingUniforms {
|
|
5605
5605
|
float isActive;
|
|
5606
5606
|
float isAttribute;
|
|
5607
5607
|
float isHighlightActive;
|
|
@@ -5672,7 +5672,7 @@ void picking_setPickingAttribute(vec3 value) {
|
|
|
5672
5672
|
picking_vRGBcolor_Avalid.rgb = value;
|
|
5673
5673
|
}
|
|
5674
5674
|
}
|
|
5675
|
-
`,
|
|
5675
|
+
`,Ys=`layout(std140) uniform pickingUniforms {
|
|
5676
5676
|
float isActive;
|
|
5677
5677
|
float isAttribute;
|
|
5678
5678
|
float isHighlightActive;
|
|
@@ -5728,7 +5728,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
5728
5728
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
5729
5729
|
return picking_filterPickingColor(highlightColor);
|
|
5730
5730
|
}
|
|
5731
|
-
`,
|
|
5731
|
+
`,mr={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:$s},vs:Ks,fs:Ys,getUniforms:Xs};function Xs(e={},t){let i={},n=ie(e.useByteColors,!0);if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)i.isHighlightActive=!1;else{i.isHighlightActive=!0;let r=e.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=r}return e.highlightColor&&(i.highlightColor=it(e.highlightColor,n)),e.isActive!==void 0&&(i.isActive=!!e.isActive,i.isAttribute=!!e.isAttribute),e.useByteColors!==void 0&&(i.useByteColors=!!e.useByteColors),i}var Zs={name:"filter",props:{},uniforms:{},bindingLayout:[{name:"filter",group:2}],uniformTypes:{enabled:"i32",min:"f32",max:"f32"},defaultUniforms:{enabled:1,min:0,max:1},vs:`layout(std140) uniform filterUniforms {
|
|
5732
5732
|
int enabled;
|
|
5733
5733
|
float min;
|
|
5734
5734
|
float max;
|
|
@@ -5749,11 +5749,11 @@ fn filter_isVisible(value: f32) -> bool {
|
|
|
5749
5749
|
return filterUniforms.enabled == 0 ||
|
|
5750
5750
|
(value >= filterUniforms.min && value <= filterUniforms.max);
|
|
5751
5751
|
}
|
|
5752
|
-
`,getUniforms(e={}){let t={};return e.enabled!==void 0&&(t.enabled=Number(e.enabled)),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),t}},
|
|
5752
|
+
`,getUniforms(e={}){let t={};return e.enabled!==void 0&&(t.enabled=Number(e.enabled)),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),t}},hr={name:"filter",module:Zs,vertexInputs:{filterValues:"f32"},injections:[{stage:"vertex",target:"FILTER_POSITION",glsl:`if (!filter_isVisible(filterValues)) {
|
|
5753
5753
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
5754
5754
|
}`,wgsl:`if (!filter_isVisible(filterValues)) {
|
|
5755
5755
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
5756
|
-
}`}]};var
|
|
5756
|
+
}`}]};var Js={name:"clip",props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4<f32>"},defaultUniforms:{enabled:1,mode:0,bounds:[0,0,1,1]},vs:`layout(std140) uniform clipUniforms {
|
|
5757
5757
|
highp int enabled;
|
|
5758
5758
|
highp int mode;
|
|
5759
5759
|
highp vec4 bounds;
|
|
@@ -5791,7 +5791,7 @@ fn clip_isInBounds(coordinates: vec2<f32>) -> bool {
|
|
|
5791
5791
|
coordinates.x < clipUniforms.bounds.z &&
|
|
5792
5792
|
coordinates.y < clipUniforms.bounds.w;
|
|
5793
5793
|
}
|
|
5794
|
-
`,getUniforms(e={}){let t={};return e.enabled!==void 0&&(t.enabled=Number(e.enabled)),e.mode!==void 0&&(t.mode=e.mode==="instance"?1:0),e.bounds!==void 0&&(t.bounds=e.bounds),t}},
|
|
5794
|
+
`,getUniforms(e={}){let t={};return e.enabled!==void 0&&(t.enabled=Number(e.enabled)),e.mode!==void 0&&(t.mode=e.mode==="instance"?1:0),e.bounds!==void 0&&(t.bounds=e.bounds),t}},vr={name:"clip",module:Js,interStageVariables:{clipCoordinates:{type:"vec2<f32>",interpolation:"smooth"}},injections:[{stage:"vertex",target:"CLIP_POSITION",glsl:`clipCoordinates = geometryCoordinates;
|
|
5795
5795
|
if (clipState.enabled != 0 && clipState.mode == 1 &&
|
|
5796
5796
|
!clip_isInBounds(instanceCoordinates)) {
|
|
5797
5797
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
@@ -5805,7 +5805,7 @@ if (clipUniforms.enabled != 0 && clipUniforms.mode == 1 &&
|
|
|
5805
5805
|
}`,wgsl:`if (clipUniforms.enabled != 0 && clipUniforms.mode == 0 &&
|
|
5806
5806
|
!clip_isInBounds(clipCoordinates)) {
|
|
5807
5807
|
discard;
|
|
5808
|
-
}`}]};var $=64,
|
|
5808
|
+
}`}]};var $=64,Qs=`
|
|
5809
5809
|
struct skinUniforms {
|
|
5810
5810
|
jointMatrix: array<mat4x4<f32>, ${$}>,
|
|
5811
5811
|
};
|
|
@@ -5846,7 +5846,7 @@ fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {
|
|
|
5846
5846
|
+ (weights.w * skin.jointMatrix[joints.w]);
|
|
5847
5847
|
#endif
|
|
5848
5848
|
}
|
|
5849
|
-
`,
|
|
5849
|
+
`,el=`
|
|
5850
5850
|
layout(std140) uniform skinUniforms {
|
|
5851
5851
|
mat4 jointMatrix[SKIN_MAX_JOINTS];
|
|
5852
5852
|
} skin;
|
|
@@ -5906,7 +5906,7 @@ mat4 getSkinMatrix(vec4 weights, uvec4 joints) {
|
|
|
5906
5906
|
#endif
|
|
5907
5907
|
}
|
|
5908
5908
|
|
|
5909
|
-
`,
|
|
5909
|
+
`,tl="",_r={props:{},uniforms:{},bindings:{},name:"skin",bindingLayout:[{name:"skin",group:0},{name:"skinJointMatrices",group:0,visibility:1}],dependencies:[],source:Qs,vs:el,fs:tl,defines:{SKIN_MAX_JOINTS:$},getUniforms:(e={},t)=>{let{jointMatrices:i,skinJointMatrices:n,scenegraphsFromGLTF:r,skinIndex:o=0,meshWorldMatrix:a}=e,s=n?{skinJointMatrices:n}:{};if(i)return{jointMatrix:il(i),...s};let l=r?.gltf?.skins?.[o];if(!l)return{jointMatrix:[],...s};let{inverseBindMatrices:c,joints:f,skeleton:d}=l,u=r.gltfNodeIndexToNodeMap,p=new Map,g=d===void 0?void 0:u?.get(d),m=g?[g]:r.scenes||[];for(let x of m)x.preorderTraversal((v,{worldMatrix:h})=>{p.set(v.id,h)});let b=a?new G(a).invert():null,y=new Float32Array($*16),S=c?.value;for(let x=0;x<Math.min(f.length,$);x++){let v=u?.get(f[x]);if(!v)continue;let h=p.get(v.id)||v.matrix,_=b?new G(b).multiplyRight(h):new G(h);S&&S.length>=(x+1)*16&&_.multiplyRight(new G(Array.from(S.slice(x*16,(x+1)*16)))),y.set(_,x*16)}return{jointMatrix:y,...s}},uniformTypes:{jointMatrix:["mat4x4<f32>",$]}};function il(e){let t=new Float32Array($*16);return t.set(e instanceof Float32Array?e.subarray(0,t.length):e.slice(0,t.length)),t}var nl=`
|
|
5910
5910
|
#ifdef HAS_GPU_CROWD_ANIMATION
|
|
5911
5911
|
@group(0) @binding(auto) var<storage, read> gpuAnimationFrames: array<vec4f>;
|
|
5912
5912
|
|
|
@@ -6018,7 +6018,7 @@ fn getGPUCrowdMorphDelta(
|
|
|
6018
6018
|
return result;
|
|
6019
6019
|
}
|
|
6020
6020
|
#endif
|
|
6021
|
-
`,
|
|
6021
|
+
`,rl=`
|
|
6022
6022
|
#ifdef HAS_GPU_CROWD_ANIMATION
|
|
6023
6023
|
uniform highp sampler2D gpuAnimationFrames;
|
|
6024
6024
|
|
|
@@ -6110,7 +6110,7 @@ vec3 getGPUCrowdMorphDelta(
|
|
|
6110
6110
|
return result;
|
|
6111
6111
|
}
|
|
6112
6112
|
#endif
|
|
6113
|
-
`,
|
|
6113
|
+
`,br={name:"gpuAnimation",props:{},uniforms:{},bindings:{},source:nl,vs:rl,fs:"",bindingLayout:[{name:"gpuAnimationFrames",group:0,visibility:1},{name:"gpuMorphTargets",group:0,visibility:1},{name:"gpuMorphWeights",group:0,visibility:1}],getUniforms(e={}){return e}};var K=4;function ei(){return{color:[0,0,0],position:[0,0,0],halfAxisX:[0,0,0],halfAxisY:[0,0,0],normal:[0,0,-1],disk:0}}var ot={color:"vec3<f32>",position:"vec3<f32>",halfAxisX:"vec3<f32>",halfAxisY:"vec3<f32>",normal:"vec3<f32>",disk:"i32"};function Le(e,t=!1){return Array.from({length:K},(i,n)=>{let r=e[n];if(!r)return ei();let o=ne(r.color||(t?[255,255,255]:[1,1,1]),t);return{position:r.position,halfAxisX:r.halfAxisX,halfAxisY:r.halfAxisY,normal:r.normal,disk:r.type==="disk"?1:0,color:o.map(a=>a*(r.intensity??1e3))}})}var ti=`precision highp int;
|
|
6114
6114
|
|
|
6115
6115
|
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6116
6116
|
struct AmbientLight {
|
|
@@ -6196,7 +6196,7 @@ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
|
|
6196
6196
|
}
|
|
6197
6197
|
|
|
6198
6198
|
// #endif
|
|
6199
|
-
`;var
|
|
6199
|
+
`;var xr=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6200
6200
|
const MAX_LIGHTS: i32 = 5;
|
|
6201
6201
|
|
|
6202
6202
|
struct AmbientLight {
|
|
@@ -6281,7 +6281,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
6281
6281
|
);
|
|
6282
6282
|
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
6283
6283
|
}
|
|
6284
|
-
`;var re=5,
|
|
6284
|
+
`;var re=5,ol={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:[ol,re],areaLightCount:"i32",areaLights:[ot,K]},defaultUniforms:st(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:xr,vs:ti,fs:ti,getUniforms:al};function al(e,t={}){e=e&&{...e};let i=(e?.lights||[]).filter(f=>f.type==="rect"||f.type==="disk");if(!e)return st();e.lights&&(e={...e,...ll(e.lights),lights:void 0});let{useByteColors:n,ambientLight:r,pointLights:o,spotLights:a,directionalLights:s}=e||{};if(!(r||o&&o.length>0||a&&a.length>0||s&&s.length>0)&&i.length===0)return{...st(),enabled:0};let c={...st(),...sl({useByteColors:n,ambientLight:r,pointLights:o,spotLights:a,directionalLights:s})};return c.areaLightCount=Math.min(i.length,K),c.areaLights=Le(i,ie(e.useByteColors,!0)),e.enabled!==void 0&&(c.enabled=e.enabled?1:0),c}function sl({useByteColors:e,ambientLight:t,pointLights:i=[],spotLights:n=[],directionalLights:r=[]}){let o=Sr(),a=0,s=0,l=0,c=0;for(let f of i){if(a>=re)break;o[a]={...o[a],color:at(f,e),position:f.position,attenuation:f.attenuation||[1,0,0]},a++,s++}for(let f of n){if(a>=re)break;o[a]={...o[a],color:at(f,e),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:fl(f)},a++,l++}for(let f of r){if(a>=re)break;o[a]={...o[a],color:at(f,e),direction:f.direction},a++,c++}return i.length+n.length+r.length>re&&console.warn(`MAX_LIGHTS exceeded, truncating to ${re}`),{ambientColor:at(t,e),directionalLightCount:c,pointLightCount:s,spotLightCount:l,lights:o}}function ll(e){let t={pointLights:[],spotLights:[],directionalLights:[]};for(let i of e||[])switch(i.type){case"ambient":t.ambientLight=i;break;case"directional":t.directionalLights?.push(i);break;case"point":t.pointLights?.push(i);break;case"spot":t.spotLights?.push(i);break;default:}return t}function at(e={},t){let{color:i=[0,0,0],intensity:n=1}=e;return ne(i,ie(t,!0)).map(o=>o*n)}function st(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Sr(),areaLightCount:0,areaLights:Le([])}}function Sr(){return Array.from({length:re},()=>cl())}function cl(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function fl(e){let t=e.innerConeAngle??0,i=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(i)]}var ul=`#ifdef USE_IBL
|
|
6285
6285
|
@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
|
|
6286
6286
|
@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
|
|
6287
6287
|
@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
|
|
@@ -6289,12 +6289,12 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
6289
6289
|
@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;
|
|
6290
6290
|
@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;
|
|
6291
6291
|
#endif
|
|
6292
|
-
`,
|
|
6292
|
+
`,yr=`#ifdef USE_IBL
|
|
6293
6293
|
uniform samplerCube pbr_diffuseEnvSampler;
|
|
6294
6294
|
uniform samplerCube pbr_specularEnvSampler;
|
|
6295
6295
|
uniform sampler2D pbr_brdfLUT;
|
|
6296
6296
|
#endif
|
|
6297
|
-
`,lt={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:
|
|
6297
|
+
`,lt={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:ul,vs:yr,fs:yr};var dl=`struct dirlightUniforms {
|
|
6298
6298
|
lightDirection: vec3<f32>,
|
|
6299
6299
|
};
|
|
6300
6300
|
|
|
@@ -6319,12 +6319,12 @@ fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
|
|
|
6319
6319
|
let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
|
|
6320
6320
|
return vec4<f32>(color.rgb * d, color.a);
|
|
6321
6321
|
}
|
|
6322
|
-
`,
|
|
6322
|
+
`,pl=`out vec3 dirlight_vNormal;
|
|
6323
6323
|
|
|
6324
6324
|
void dirlight_setNormal(vec3 normal) {
|
|
6325
6325
|
dirlight_vNormal = normalize(normal);
|
|
6326
6326
|
}
|
|
6327
|
-
`,
|
|
6327
|
+
`,gl=`layout(std140) uniform dirlightUniforms {
|
|
6328
6328
|
vec3 lightDirection;
|
|
6329
6329
|
} dirlight;
|
|
6330
6330
|
|
|
@@ -6335,7 +6335,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
6335
6335
|
float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
|
|
6336
6336
|
return vec4(color.rgb * d, color.a);
|
|
6337
6337
|
}
|
|
6338
|
-
`,ii={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:
|
|
6338
|
+
`,ii={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:dl,vs:pl,fs:gl,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:ml};function ml(e=ii.defaultUniforms){let t={};return e.lightDirection&&(t.lightDirection=e.lightDirection),t}var hl=`fn unlitMaterial_getColor(surfaceColor: vec4<f32>) -> vec4<f32> {
|
|
6339
6339
|
return surfaceColor;
|
|
6340
6340
|
}
|
|
6341
6341
|
|
|
@@ -6343,7 +6343,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
6343
6343
|
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, positionWorldspace: vec3<f32>, normalWorldspace: vec3<f32>) -> vec3<f32> {
|
|
6344
6344
|
return surfaceColor;
|
|
6345
6345
|
}
|
|
6346
|
-
`,
|
|
6346
|
+
`,Cr=`vec4 unlitMaterial_getColor(vec4 surfaceColor) {
|
|
6347
6347
|
return surfaceColor;
|
|
6348
6348
|
}
|
|
6349
6349
|
|
|
@@ -6351,7 +6351,7 @@ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, p
|
|
|
6351
6351
|
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positionWorldspace, vec3 normalWorldspace) {
|
|
6352
6352
|
return surfaceColor;
|
|
6353
6353
|
}
|
|
6354
|
-
`,
|
|
6354
|
+
`,Ir={name:"unlitMaterial",source:hl,vs:Cr,fs:Cr,dependencies:[],bindingLayout:[],uniformTypes:{},defaultUniforms:{}};var wr=`struct lambertMaterialUniforms {
|
|
6355
6355
|
unlit: u32,
|
|
6356
6356
|
ambient: f32,
|
|
6357
6357
|
diffuse: f32,
|
|
@@ -6418,12 +6418,12 @@ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, p
|
|
|
6418
6418
|
|
|
6419
6419
|
return lightColor;
|
|
6420
6420
|
}
|
|
6421
|
-
`;var
|
|
6421
|
+
`;var Lr=`layout(std140) uniform lambertMaterialUniforms {
|
|
6422
6422
|
uniform bool unlit;
|
|
6423
6423
|
uniform float ambient;
|
|
6424
6424
|
uniform float diffuse;
|
|
6425
6425
|
} material;
|
|
6426
|
-
`,
|
|
6426
|
+
`,Mr=`layout(std140) uniform lambertMaterialUniforms {
|
|
6427
6427
|
uniform bool unlit;
|
|
6428
6428
|
uniform float ambient;
|
|
6429
6429
|
uniform float diffuse;
|
|
@@ -6470,7 +6470,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
6470
6470
|
|
|
6471
6471
|
return lightColor;
|
|
6472
6472
|
}
|
|
6473
|
-
`;var ni={name:"lambertMaterial",firstBindingSlot:0,bindingLayout:[{name:"lambertMaterial",group:3}],dependencies:[F],source:
|
|
6473
|
+
`;var ni={name:"lambertMaterial",firstBindingSlot:0,bindingLayout:[{name:"lambertMaterial",group:3}],dependencies:[F],source:wr,vs:Lr,fs:Mr,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6},getUniforms(e){return{...ni.defaultUniforms,...e}}};var ct=`layout(std140) uniform phongMaterialUniforms {
|
|
6474
6474
|
uniform bool unlit;
|
|
6475
6475
|
uniform float ambient;
|
|
6476
6476
|
uniform float diffuse;
|
|
@@ -6657,7 +6657,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
6657
6657
|
}
|
|
6658
6658
|
return lightColor;
|
|
6659
6659
|
}
|
|
6660
|
-
`;var
|
|
6660
|
+
`;var vl=[38.25,38.25,38.25],ri={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:ft.replace("phongMaterial","gouraudMaterial"),fs:ct.replace("phongMaterial","gouraudMaterial"),source:ut.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[F,me],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:vl},getUniforms(e){return{...ri.defaultUniforms,...e}}};var _l=[38.25,38.25,38.25],oi={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[F,me],source:ut,vs:ct,fs:ft,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:_l},getUniforms(e){return{...oi.defaultUniforms,...e}}};var Ar=`layout(std140) uniform waterMaterialUniforms {
|
|
6661
6661
|
uniform float time;
|
|
6662
6662
|
uniform vec3 baseColor;
|
|
6663
6663
|
uniform float opacity;
|
|
@@ -6677,7 +6677,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
6677
6677
|
uniform float waveBFrequency;
|
|
6678
6678
|
uniform float waveBAmplitude;
|
|
6679
6679
|
} waterMaterial;
|
|
6680
|
-
`,
|
|
6680
|
+
`,Rr=`layout(std140) uniform waterMaterialUniforms {
|
|
6681
6681
|
uniform float time;
|
|
6682
6682
|
uniform vec3 baseColor;
|
|
6683
6683
|
uniform float opacity;
|
|
@@ -6881,7 +6881,7 @@ vec4 water_getColor(
|
|
|
6881
6881
|
uv
|
|
6882
6882
|
);
|
|
6883
6883
|
}
|
|
6884
|
-
`;var
|
|
6884
|
+
`;var Tr=`struct waterMaterialUniforms {
|
|
6885
6885
|
time: f32,
|
|
6886
6886
|
baseColor: vec3<f32>,
|
|
6887
6887
|
opacity: f32,
|
|
@@ -7105,7 +7105,7 @@ fn water_getColor(
|
|
|
7105
7105
|
uv
|
|
7106
7106
|
);
|
|
7107
7107
|
}
|
|
7108
|
-
`;var P={time:0,baseColor:[.04,.18,.31],opacity:.82,fresnelColor:[.86,.95,1],fresnelPower:5,specularIntensity:1.4,normalStrength:.35,mappingMode:0,coordinateScale:[1,1],coordinateOffset:[0,0],waveADirection:[.9805806756909201,.19611613513818402],waveASpeed:.6,waveAFrequency:4,waveAAmplitude:.08,waveBDirection:[.09950371902099893,.9950371902099893],waveBSpeed:-.45,waveBFrequency:7,waveBAmplitude:.04},
|
|
7108
|
+
`;var P={time:0,baseColor:[.04,.18,.31],opacity:.82,fresnelColor:[.86,.95,1],fresnelPower:5,specularIntensity:1.4,normalStrength:.35,mappingMode:0,coordinateScale:[1,1],coordinateOffset:[0,0],waveADirection:[.9805806756909201,.19611613513818402],waveASpeed:.6,waveAFrequency:4,waveAAmplitude:.08,waveBDirection:[.09950371902099893,.9950371902099893],waveBSpeed:-.45,waveBFrequency:7,waveBAmplitude:.04},gt={name:"waterMaterial",firstBindingSlot:0,bindingLayout:[{name:"waterMaterial",group:3}],dependencies:[F],source:Tr,vs:Ar,fs:Rr,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{time:"f32",baseColor:"vec3<f32>",opacity:"f32",fresnelColor:"vec3<f32>",fresnelPower:"f32",specularIntensity:"f32",normalStrength:"f32",mappingMode:"i32",coordinateScale:"vec2<f32>",coordinateOffset:"vec2<f32>",waveADirection:"vec2<f32>",waveASpeed:"f32",waveAFrequency:"f32",waveAAmplitude:"f32",waveBDirection:"vec2<f32>",waveBSpeed:"f32",waveBFrequency:"f32",waveBAmplitude:"f32"},defaultUniforms:P,getUniforms(e,t=P){let{mapping:i,...n}=e||{},r=bl(t);return n.time!==void 0&&(r.time=n.time),n.opacity!==void 0&&(r.opacity=n.opacity),n.fresnelPower!==void 0&&(r.fresnelPower=n.fresnelPower),n.specularIntensity!==void 0&&(r.specularIntensity=n.specularIntensity),n.normalStrength!==void 0&&(r.normalStrength=n.normalStrength),n.coordinateScale!==void 0&&(r.coordinateScale=[Number(n.coordinateScale[0]),Number(n.coordinateScale[1])]),n.coordinateOffset!==void 0&&(r.coordinateOffset=[Number(n.coordinateOffset[0]),Number(n.coordinateOffset[1])]),n.waveASpeed!==void 0&&(r.waveASpeed=n.waveASpeed),n.waveAFrequency!==void 0&&(r.waveAFrequency=n.waveAFrequency),n.waveAAmplitude!==void 0&&(r.waveAAmplitude=n.waveAAmplitude),n.waveBSpeed!==void 0&&(r.waveBSpeed=n.waveBSpeed),n.waveBFrequency!==void 0&&(r.waveBFrequency=n.waveBFrequency),n.waveBAmplitude!==void 0&&(r.waveBAmplitude=n.waveBAmplitude),n.baseColor&&(r.baseColor=dt(n.baseColor)),n.fresnelColor&&(r.fresnelColor=dt(n.fresnelColor)),n.waveADirection&&(r.waveADirection=pt(n.waveADirection)),n.waveBDirection&&(r.waveBDirection=pt(n.waveBDirection)),i!==void 0&&(r.mappingMode=i==="world"?1:i==="object"?2:0),r}};function bl(e){return{time:e.time??P.time,baseColor:e.baseColor?dt(e.baseColor):P.baseColor,opacity:e.opacity??P.opacity,fresnelColor:e.fresnelColor?dt(e.fresnelColor):P.fresnelColor,fresnelPower:e.fresnelPower??P.fresnelPower,specularIntensity:e.specularIntensity??P.specularIntensity,normalStrength:e.normalStrength??P.normalStrength,mappingMode:e.mappingMode??P.mappingMode,coordinateScale:e.coordinateScale?[Number(e.coordinateScale[0]),Number(e.coordinateScale[1])]:P.coordinateScale,coordinateOffset:e.coordinateOffset?[Number(e.coordinateOffset[0]),Number(e.coordinateOffset[1])]:P.coordinateOffset,waveADirection:e.waveADirection?pt(e.waveADirection):P.waveADirection,waveASpeed:e.waveASpeed??P.waveASpeed,waveAFrequency:e.waveAFrequency??P.waveAFrequency,waveAAmplitude:e.waveAAmplitude??P.waveAAmplitude,waveBDirection:e.waveBDirection?pt(e.waveBDirection):P.waveBDirection,waveBSpeed:e.waveBSpeed??P.waveBSpeed,waveBFrequency:e.waveBFrequency??P.waveBFrequency,waveBAmplitude:e.waveBAmplitude??P.waveBAmplitude}}function dt(e){let t=[Number(e[0]),Number(e[1]),Number(e[2])];return Math.max(...t.map(n=>Math.abs(n)))>1&&(t[0]/=255,t[1]/=255,t[2]/=255),t}function pt(e){let t=Number(e[0]),i=Number(e[1]),n=Math.hypot(t,i);return n===0?[1,0]:[t/n,i/n]}var Er=`struct riverWaterMaterialUniforms {
|
|
7109
7109
|
enabled: i32,
|
|
7110
7110
|
flowDirection: vec2<f32>,
|
|
7111
7111
|
skyZenithColor: vec3<f32>,
|
|
@@ -7221,7 +7221,7 @@ fn riverWater_getColorMapped(
|
|
|
7221
7221
|
color = mix(color, reflectedColor, clamp(fresnel * 0.3, 0.0, 0.3));
|
|
7222
7222
|
return vec4<f32>(color, waterMaterial.opacity);
|
|
7223
7223
|
}
|
|
7224
|
-
`,
|
|
7224
|
+
`,Pr=`layout(std140) uniform riverWaterMaterialUniforms {
|
|
7225
7225
|
uniform int enabled;
|
|
7226
7226
|
uniform vec2 flowDirection;
|
|
7227
7227
|
uniform vec3 skyZenithColor;
|
|
@@ -7330,7 +7330,7 @@ vec4 riverWater_getColorMapped(
|
|
|
7330
7330
|
color = mix(color, reflectedColor, clamp(fresnel * 0.3, 0.0, 0.3));
|
|
7331
7331
|
return vec4(color, waterMaterial.opacity);
|
|
7332
7332
|
}
|
|
7333
|
-
`;var
|
|
7333
|
+
`;var Dr={name:"riverWaterMaterial",firstBindingSlot:1,bindingLayout:[{name:"riverWaterMaterial",group:3}],dependencies:[gt],source:Er,fs:Pr,uniformTypes:{enabled:"i32",flowDirection:"vec2<f32>",skyZenithColor:"vec3<f32>",skyUpDirection:"vec3<f32>"},defaultUniforms:{enabled:0,flowDirection:[0,1],skyZenithColor:[.22,.48,.57],skyUpDirection:[0,0,1]},getUniforms(e={},t={}){return{enabled:e.enabled??t.enabled??0,flowDirection:e.flowDirection??t.flowDirection??[0,1],skyZenithColor:e.skyZenithColor??t.skyZenithColor??[.22,.48,.57],skyUpDirection:e.skyUpDirection??t.skyUpDirection??[0,0,1]}}};var ai=`
|
|
7334
7334
|
#ifdef USE_AREA_LIGHT_LTC
|
|
7335
7335
|
uniform sampler2D areaLTCMatrix;
|
|
7336
7336
|
uniform sampler2D areaLTCAmplitude;
|
|
@@ -7410,7 +7410,7 @@ vec3 areaLTC_evaluate(int index, vec3 receiver, vec3 normal, vec3 view, float ro
|
|
|
7410
7410
|
areaLTC_specular(light, receiver, normal, view, roughness, reflectance0, reflectance90);
|
|
7411
7411
|
}
|
|
7412
7412
|
#endif
|
|
7413
|
-
`,
|
|
7413
|
+
`,Nr=`
|
|
7414
7414
|
#ifdef USE_AREA_LIGHT_LTC
|
|
7415
7415
|
@group(2) @binding(auto) var areaLTCMatrix: texture_2d<f32>;
|
|
7416
7416
|
@group(2) @binding(auto) var areaLTCAmplitude: texture_2d<f32>;
|
|
@@ -7518,7 +7518,7 @@ PointLight areaLighting_getSample(int lightIndex, int sampleIndex, vec3 receiver
|
|
|
7518
7518
|
float emissionCosine = max(dot(light.normal, displacement * inversesqrt(distanceSquared)), 0.0);
|
|
7519
7519
|
return PointLight(light.color * (area * emissionCosine / (float(areaLighting.sampleCount) * distanceSquared)), position, vec3(1.0, 0.0, 0.0));
|
|
7520
7520
|
}
|
|
7521
|
-
`,
|
|
7521
|
+
`,Fr=`
|
|
7522
7522
|
struct AreaLightingUniforms {
|
|
7523
7523
|
lightCount: i32,
|
|
7524
7524
|
sampleCount: i32,
|
|
@@ -7551,7 +7551,7 @@ fn areaLighting_getSample(lightIndex: i32, sampleIndex: i32, receiver: vec3f) ->
|
|
|
7551
7551
|
let emissionCosine = max(dot(light.normal, displacement * inverseSqrt(distanceSquared)), 0.0);
|
|
7552
7552
|
return PointLight(light.color * (area * emissionCosine / (f32(areaLighting.sampleCount) * distanceSquared)), position, vec3f(1.0, 0.0, 0.0));
|
|
7553
7553
|
}
|
|
7554
|
-
`;var
|
|
7554
|
+
`;var mt={name:"areaLighting",props:{},uniforms:{},dependencies:[F],defaultUniforms:{lightCount:0,sampleCount:64,lights:Array.from({length:K},ei)},uniformTypes:{lightCount:"i32",sampleCount:"i32",lights:[ot,K]},bindingLayout:[{name:"areaLighting",group:2},{name:"areaLTCMatrix",group:2},{name:"areaLTCAmplitude",group:2}],source:Fr+Nr,vs:si+ai,fs:si+ai,getUniforms(e={}){let t=e.lights||[];return{lightCount:Math.min(t.length,K),sampleCount:e.sampleCount||64,lights:Le(t,e.useByteColors)}}};var Br=`out vec3 pbr_vPosition;
|
|
7555
7555
|
out vec2 pbr_vUV0;
|
|
7556
7556
|
out vec2 pbr_vUV1;
|
|
7557
7557
|
|
|
@@ -7593,7 +7593,7 @@ void pbr_setPositionNormalTangentUV(
|
|
|
7593
7593
|
|
|
7594
7594
|
pbr_vUV1 = uv1;
|
|
7595
7595
|
}
|
|
7596
|
-
`,
|
|
7596
|
+
`,Or=`precision highp float;
|
|
7597
7597
|
|
|
7598
7598
|
layout(std140) uniform pbrMaterialUniforms {
|
|
7599
7599
|
// Material is unlit
|
|
@@ -9304,7 +9304,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility) {
|
|
|
9304
9304
|
vec4 pbr_filterColor(vec4 vertexColor) {
|
|
9305
9305
|
return pbr_filterColorWithSpotShadows(vertexColor, vec4(1.0));
|
|
9306
9306
|
}
|
|
9307
|
-
`;var
|
|
9307
|
+
`;var Ur=`#ifdef DOUBLE_SIDED
|
|
9308
9308
|
var<private> pbr_frontFacing: bool = true;
|
|
9309
9309
|
#endif
|
|
9310
9310
|
struct PBRFragmentInputs {
|
|
@@ -11213,13 +11213,13 @@ fn pbr_filterColorWithSpotShadows(vertexColor: vec4f, spotVisibility: vec4f) ->
|
|
|
11213
11213
|
fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
11214
11214
|
return pbr_filterColorWithSpotShadows(vertexColor, vec4f(1.0));
|
|
11215
11215
|
}
|
|
11216
|
-
`;var
|
|
11216
|
+
`;var kr=`layout(std140) uniform pbrProjectionUniforms {
|
|
11217
11217
|
mat4 modelViewProjectionMatrix;
|
|
11218
11218
|
mat4 modelMatrix;
|
|
11219
11219
|
mat4 normalMatrix;
|
|
11220
11220
|
vec3 camera;
|
|
11221
11221
|
} pbrProjection;
|
|
11222
|
-
`,
|
|
11222
|
+
`,xl=`struct pbrProjectionUniforms {
|
|
11223
11223
|
modelViewProjectionMatrix: mat4x4<f32>,
|
|
11224
11224
|
modelMatrix: mat4x4<f32>,
|
|
11225
11225
|
normalMatrix: mat4x4<f32>,
|
|
@@ -11227,7 +11227,7 @@ fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
|
11227
11227
|
};
|
|
11228
11228
|
|
|
11229
11229
|
@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
|
|
11230
|
-
`,
|
|
11230
|
+
`,zr={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:xl,vs:kr,fs:kr,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var li={NONE:0,REINHARD:1,KHRONOS_PBR_NEUTRAL:2,ACES:3},Vr=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Gr=`layout(std140) uniform pbrSceneUniforms {
|
|
11231
11231
|
float exposure;
|
|
11232
11232
|
highp int toneMapMode;
|
|
11233
11233
|
float environmentIntensity;
|
|
@@ -11242,7 +11242,7 @@ fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
|
11242
11242
|
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
11243
11243
|
uniform sampler2D pbr_transmissionFramebufferSampler;
|
|
11244
11244
|
#endif
|
|
11245
|
-
`,
|
|
11245
|
+
`,Sl=`struct pbrSceneUniforms {
|
|
11246
11246
|
exposure: f32,
|
|
11247
11247
|
toneMapMode: i32,
|
|
11248
11248
|
environmentIntensity: f32,
|
|
@@ -11260,7 +11260,7 @@ uniform sampler2D pbr_transmissionFramebufferSampler;
|
|
|
11260
11260
|
@group(1) @binding(auto) var pbr_transmissionFramebufferSampler: texture_2d<f32>;
|
|
11261
11261
|
@group(1) @binding(auto) var pbr_transmissionFramebufferSamplerSampler: sampler;
|
|
11262
11262
|
#endif
|
|
11263
|
-
`,ht={name:"pbrScene",bindingLayout:[{name:"pbrScene",group:1},{name:"pbr_transmissionFramebufferSampler",group:1}],source:
|
|
11263
|
+
`,ht={name:"pbrScene",bindingLayout:[{name:"pbrScene",group:1},{name:"pbr_transmissionFramebufferSampler",group:1}],source:Sl,vs:Gr,fs:Gr,getUniforms:e=>e,uniformTypes:{exposure:"f32",toneMapMode:"i32",environmentIntensity:"f32",environmentRotation:"f32",environmentMipCount:"f32",outputEncoding:"i32",framebufferSize:"vec2<f32>",viewMatrix:"mat4x4<f32>",projectionMatrix:"mat4x4<f32>"},defaultUniforms:{exposure:1,toneMapMode:li.KHRONOS_PBR_NEUTRAL,environmentIntensity:1,environmentRotation:Math.PI*.5,environmentMipCount:1,outputEncoding:1,framebufferSize:[1,1],viewMatrix:Vr,projectionMatrix:Vr}};var U={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,lightmapMapEnabled:!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,lightmapIntensity:1,scatterStrengthFactor:0,dispersion:0,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,lightmapUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],lightmapUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1],bumpFactor:1,bumpMapEnabled:!1,diffuseTransmissionFactor:0,diffuseTransmissionMapEnabled:!1,diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorMapEnabled:!1,multiscatterColorFactor:[0,0,0],multiscatterColorMapEnabled:!1,scatterAnisotropy:0,bumpUVSet:0,bumpUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionUVSet:0,diffuseTransmissionUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionColorUVSet:0,diffuseTransmissionColorUVTransform:[1,0,0,0,1,0,0,0,1],multiscatterColorUVSet:0,multiscatterColorUVTransform:[1,0,0,0,1,0,0,0,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_lightmapSampler",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},{name:"pbr_bumpSampler",group:3},{name:"pbr_diffuseTransmissionSampler",group:3},{name:"pbr_diffuseTransmissionColorSampler",group:3},{name:"pbr_multiscatterColorSampler",group:3}],dependencies:[F,mt,lt,zr,ht],source:Ur,vs:Br,fs:Or,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_LIGHTMAP:!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,HAS_BUMPMAP:!1,HAS_DIFFUSETRANSMISSIONMAP:!1,HAS_DIFFUSETRANSMISSIONCOLORMAP:!1,HAS_MULTISCATTERCOLORMAP:!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",dispersion:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>",bumpFactor:"f32",bumpMapEnabled:"i32",diffuseTransmissionFactor:"f32",diffuseTransmissionMapEnabled:"i32",diffuseTransmissionColorFactor:"vec3<f32>",diffuseTransmissionColorMapEnabled:"i32",multiscatterColorFactor:"vec3<f32>",multiscatterColorMapEnabled:"i32",scatterAnisotropy:"f32",bumpUVSet:"i32",bumpUVTransform:"mat3x3<f32>",diffuseTransmissionUVSet:"i32",diffuseTransmissionUVTransform:"mat3x3<f32>",diffuseTransmissionColorUVSet:"i32",diffuseTransmissionColorUVTransform:"mat3x3<f32>",multiscatterColorUVSet:"i32",multiscatterColorUVTransform:"mat3x3<f32>",lightmapMapEnabled:"i32",lightmapIntensity:"f32",lightmapUVSet:"i32",lightmapUVTransform:"mat3x3<f32>",scatterStrengthFactor:"f32"}};var Y={name:"valueNoise",fs:`
|
|
11264
11264
|
float valueNoise_hash(vec2 cell) {
|
|
11265
11265
|
vec3 value = fract(vec3(cell.x, cell.y, cell.x) * 0.1031);
|
|
11266
11266
|
value += dot(value, value.yzx + 33.33);
|
|
@@ -11318,7 +11318,7 @@ fn valueNoise_noise3(position: vec3f) -> f32 {
|
|
|
11318
11318
|
mix(valueNoise_hash3(cell + vec3f(0.0, 1.0, 1.0)), valueNoise_hash3(cell + vec3f(1.0)), blend.x), blend.y);
|
|
11319
11319
|
return mix(bottom, top, blend.z);
|
|
11320
11320
|
}
|
|
11321
|
-
`};var
|
|
11321
|
+
`};var vt={name:"heightFogFunctions",dependencies:[Y],fs:`
|
|
11322
11322
|
float heightFog_getRayTransmittance(float rayLength, float cameraHeight, float fragmentHeight, float density, float baseHeight, float heightFalloff) {
|
|
11323
11323
|
float startHeight = (cameraHeight - baseHeight) * max(heightFalloff, 0.0);
|
|
11324
11324
|
float endHeight = (fragmentHeight - baseHeight) * max(heightFalloff, 0.0);
|
|
@@ -11418,7 +11418,7 @@ fn heightFog_getSpatialTransmittance(camera: vec3f, position: vec3f, upDirection
|
|
|
11418
11418
|
return transmittance;
|
|
11419
11419
|
}
|
|
11420
11420
|
|
|
11421
|
-
`};var
|
|
11421
|
+
`};var Hr={name:"heightFog",dependencies:[vt],bindingLayout:[{name:"heightFog",group:3}],uniformTypes:{color:"vec3<f32>",density:"f32",baseHeight:"f32",heightFalloff:"f32",variation:"f32",wispScale:"f32",velocity:"vec3<f32>",time:"f32",evolutionSpeed:"f32"},defaultUniforms:{color:[.65,.72,.78],density:0,baseHeight:0,heightFalloff:.01,variation:0,wispScale:160,velocity:[0,0,0],time:0,evolutionSpeed:0},getUniforms(e={}){return e},fs:`
|
|
11422
11422
|
layout(std140) uniform heightFogUniforms {
|
|
11423
11423
|
vec3 color;
|
|
11424
11424
|
float density;
|
|
@@ -11457,7 +11457,7 @@ fn heightFog_getTransmittance(position: vec3<f32>, cameraPosition: vec3<f32>) ->
|
|
|
11457
11457
|
fn heightFog_getColor(color: vec4<f32>, position: vec3<f32>, cameraPosition: vec3<f32>) -> vec4<f32> {
|
|
11458
11458
|
return vec4<f32>(mix(heightFog.color, color.rgb, heightFog_getTransmittance(position, cameraPosition)), color.a);
|
|
11459
11459
|
}
|
|
11460
|
-
`};var
|
|
11460
|
+
`};var Wr=`
|
|
11461
11461
|
layout(std140) uniform patternFillUniforms {
|
|
11462
11462
|
int patternType;
|
|
11463
11463
|
float spacing;
|
|
@@ -11498,7 +11498,7 @@ float patternFill_getCoverage(vec2 coordinates) {
|
|
|
11498
11498
|
if (patternFill.patternType == 1) return first + second - first * second;
|
|
11499
11499
|
return first;
|
|
11500
11500
|
}
|
|
11501
|
-
`,
|
|
11501
|
+
`,jr=`
|
|
11502
11502
|
struct patternFillUniforms {
|
|
11503
11503
|
patternType: i32,
|
|
11504
11504
|
spacing: f32,
|
|
@@ -11538,7 +11538,7 @@ fn patternFill_getCoverage(coordinates: vec2<f32>) -> f32 {
|
|
|
11538
11538
|
if (patternFill.patternType == 1) { return first + second - first * second; }
|
|
11539
11539
|
return first;
|
|
11540
11540
|
}
|
|
11541
|
-
`;var ci={patternType:0,spacing:8,width:.12,angle:Math.PI/4,offset:[0,0]},
|
|
11541
|
+
`;var ci={patternType:0,spacing:8,width:.12,angle:Math.PI/4,offset:[0,0]},qr={name:"patternFill",firstBindingSlot:0,bindingLayout:[{name:"patternFill",group:3}],source:jr,fs:Wr,uniformTypes:{patternType:"i32",spacing:"f32",width:"f32",angle:"f32",offset:"vec2<f32>"},defaultUniforms:ci,getUniforms(e={},t=ci){let i={...ci,...t};return e.pattern!==void 0&&(i.patternType={hatch:0,crosshatch:1,dots:2}[e.pattern]),e.spacing!==void 0&&(i.spacing=Math.max(e.spacing,1e-4)),e.width!==void 0&&(i.width=Math.min(1,Math.max(0,e.width))),e.angle!==void 0&&(i.angle=e.angle),e.offset!==void 0&&(i.offset=e.offset),i}};var fi={coreRadius:.12,coreIntensity:1,haloIntensity:.6,falloff:5},$r={name:"pointGlow",firstBindingSlot:0,bindingLayout:[{name:"pointGlow",group:3}],uniformTypes:{coreRadius:"f32",coreIntensity:"f32",haloIntensity:"f32",falloff:"f32"},defaultUniforms:fi,getUniforms(e={},t=fi){let i={...fi,...t};return e.coreRadius!==void 0&&(i.coreRadius=Math.min(1,Math.max(0,e.coreRadius))),e.coreIntensity!==void 0&&(i.coreIntensity=Math.max(0,e.coreIntensity)),e.haloIntensity!==void 0&&(i.haloIntensity=Math.max(0,e.haloIntensity)),e.falloff!==void 0&&(i.falloff=Math.max(.01,e.falloff)),i},fs:`
|
|
11542
11542
|
layout(std140) uniform pointGlowUniforms {
|
|
11543
11543
|
float coreRadius;
|
|
11544
11544
|
float coreIntensity;
|
|
@@ -11578,7 +11578,7 @@ fn pointGlow_getColor(coordinates: vec2<f32>, tint: vec3<f32>) -> vec3<f32> {
|
|
|
11578
11578
|
let halo = max(0.0, (exp(-pointGlow.falloff * radius * radius) - outer) / (1.0 - outer));
|
|
11579
11579
|
return (vec3<f32>(core * pointGlow.coreIntensity) + tint * halo * pointGlow.haloIntensity) * envelope;
|
|
11580
11580
|
}
|
|
11581
|
-
`};var
|
|
11581
|
+
`};var Kr={name:"precipitation",bindingLayout:[{name:"precipitation",group:3}],uniformTypes:{time:"f32",fallSpeed:"f32",turbulence:"f32",seed:"f32",volumeCenter:"vec3<f32>",volumeSize:"vec3<f32>",wind:"vec2<f32>"},defaultUniforms:{time:0,fallSpeed:20,turbulence:0,seed:29,volumeCenter:[0,0,150],volumeSize:[1200,1600,300],wind:[2,0]},getUniforms(e={}){return e},vs:`
|
|
11582
11582
|
layout(std140) uniform precipitationUniforms {
|
|
11583
11583
|
float time;
|
|
11584
11584
|
float fallSpeed;
|
|
@@ -11641,7 +11641,7 @@ fn precipitation_getFade(position: vec3<f32>) -> f32 {
|
|
|
11641
11641
|
let edge = 0.5 - abs((position - precipitation.volumeCenter) / max(precipitation.volumeSize, vec3<f32>(0.001)));
|
|
11642
11642
|
return smoothstep(0.0, 0.08, min(edge.x, min(edge.y, edge.z)));
|
|
11643
11643
|
}
|
|
11644
|
-
`};var ui={cover:.45,altitude:1e3,thickness:1200,scale:1400,density:.005,time:0,velocity:[14,4],sunDirection:[0,.8,.6],sunColor:[1,.95,.85]},
|
|
11644
|
+
`};var ui={cover:.45,altitude:1e3,thickness:1200,scale:1400,density:.005,time:0,velocity:[14,4],sunDirection:[0,.8,.6],sunColor:[1,.95,.85]},_t={name:"clouds",dependencies:[Y],uniformTypes:{cover:"f32",altitude:"f32",thickness:"f32",scale:"f32",density:"f32",time:"f32",velocity:"vec2<f32>",sunDirection:"vec3<f32>",sunColor:"vec3<f32>"},defaultUniforms:ui,getUniforms(e={},t=ui){return{...ui,...t,...e}},fs:`
|
|
11645
11645
|
layout(std140) uniform cloudsUniforms {
|
|
11646
11646
|
float cover;
|
|
11647
11647
|
float altitude;
|
|
@@ -11792,7 +11792,7 @@ fn clouds_getColor(camera: vec3f, rayDirection: vec3f) -> vec4f {
|
|
|
11792
11792
|
let distanceFade = 1.0 - smoothstep(10000.0, 20000.0, start);
|
|
11793
11793
|
return vec4f(radiance, 1.0 - transmittance) * distanceFade;
|
|
11794
11794
|
}
|
|
11795
|
-
`};var di={enabled:1,sunDirection:[0,.8,.6],sunIntensity:20,haze:1,rayleigh:1,planetRadius:6371e3,exposure:1,groundColor:[.18,.17,.14]}
|
|
11795
|
+
`};var di={enabled:1,sunDirection:[0,.8,.6],sunIntensity:20,haze:1,rayleigh:1,planetRadius:6371e3,exposure:1,groundColor:[.18,.17,.14]},Yr={name:"atmosphere",uniformTypes:{enabled:"f32",sunDirection:"vec3<f32>",sunIntensity:"f32",haze:"f32",rayleigh:"f32",planetRadius:"f32",exposure:"f32",groundColor:"vec3<f32>"},defaultUniforms:di,getUniforms(e={},t=di){return{...di,...t,...e}},fs:`
|
|
11796
11796
|
layout(std140) uniform atmosphereUniforms {
|
|
11797
11797
|
float enabled;
|
|
11798
11798
|
vec3 sunDirection;
|
|
@@ -11984,7 +11984,7 @@ fn atmosphere_getColor(color: vec4f,
|
|
|
11984
11984
|
var scattering: vec3f = vec3f(1.0) - exp(-scatteringSample.radiance * atmosphere.exposure);
|
|
11985
11985
|
return vec4f(color.rgb * scatteringSample.transmittance + scattering, color.a);
|
|
11986
11986
|
}
|
|
11987
|
-
`};function
|
|
11987
|
+
`};function Xr(e,t,i){function n(r,o,a){let s=Math.max(o,0)+Math.max(a,0),l=Math.min(1,Math.max(0,r));if(s===0||i<=0)return l;let c=Math.max(o,0)/s;return c+(l-c)*Math.exp(-s*Math.max(i,0))}return{wetness:n(e.wetness,t.rainfall,t.evaporation),snow:n(e.snow,t.snowfall,t.snowmelt)}}var pi={wetness:0,snow:0,puddles:.8,scale:20,snowColor:[.9,.94,.98],skyColor:[.48,.6,.72]},Zr={name:"surfaceWeather",dependencies:[Y],uniformTypes:{wetness:"f32",snow:"f32",puddles:"f32",scale:"f32",snowColor:"vec3<f32>",skyColor:"vec3<f32>"},defaultUniforms:pi,getUniforms(e={},t=pi){return{...pi,...t,...e}},fs:`
|
|
11988
11988
|
layout(std140) uniform surfaceWeatherUniforms {
|
|
11989
11989
|
float wetness;
|
|
11990
11990
|
float snow;
|
|
@@ -12108,7 +12108,7 @@ fn surfaceWeather_getReflection(position: vec3f,
|
|
|
12108
12108
|
var highlight: f32 = pow(max(dot(surfaceNormal, halfway), 0.0), mix(36.0, 160.0, puddle)) * max(dot(surfaceNormal, normalize(lightDirection)), 0.0);
|
|
12109
12109
|
return wetness * (surfaceWeather.skyColor * fresnel * (0.15 + puddle * 0.85) + lightColor * highlight * 0.6);
|
|
12110
12110
|
}
|
|
12111
|
-
`};var
|
|
12111
|
+
`};var gi={enabled:0,time:0,radius:8,speed:.6,pulse:.85},Jr={name:"firefly",uniformTypes:{enabled:"f32",time:"f32",radius:"f32",speed:"f32",pulse:"f32"},defaultUniforms:gi,getUniforms(e={},t=gi){return{...gi,...t,...e}},source:`struct FireflyUniforms {enabled: f32, time: f32, radius: f32, speed: f32, pulse: f32};
|
|
12112
12112
|
@group(3) @binding(auto) var<uniform> firefly: FireflyUniforms;
|
|
12113
12113
|
fn firefly_getPosition(position: vec3f, seed: f32, time: f32) -> vec3f {
|
|
12114
12114
|
if (firefly.enabled <= 0.0) { return position; }
|
|
@@ -12145,7 +12145,7 @@ fn surfaceWeather_getReflection(position: vec3f,
|
|
|
12145
12145
|
float phase = seed * 2.399963;
|
|
12146
12146
|
float pulse = pow(0.5 + 0.5 * sin(time * firefly.speed * (1.6 + fract(seed * 0.37)) + phase), 3.0);
|
|
12147
12147
|
return mix(1.0, mix(0.08, 1.0, pulse), firefly.pulse * firefly.enabled);
|
|
12148
|
-
}`};var
|
|
12148
|
+
}`};var Qr={name:"globeClouds",dependencies:[_t],uniformTypes:{planetRadius:"f32"},defaultUniforms:{planetRadius:6370972},fs:`
|
|
12149
12149
|
layout(std140) uniform globeCloudsUniforms { float planetRadius; } globeClouds;
|
|
12150
12150
|
vec2 globeClouds_intersectSphere(vec3 camera, vec3 direction, float radius) {
|
|
12151
12151
|
float projected = dot(camera, direction);
|
|
@@ -12247,7 +12247,7 @@ fn globeClouds_getColor(camera: vec3f, direction: vec3f) -> vec4f {
|
|
|
12247
12247
|
}
|
|
12248
12248
|
return vec4f(radiance, 1.0 - transmittance);
|
|
12249
12249
|
}
|
|
12250
|
-
`};var
|
|
12250
|
+
`};var yl=`layout(std140) uniform pbrEnvironmentFilterUniforms {
|
|
12251
12251
|
int face;
|
|
12252
12252
|
float roughness;
|
|
12253
12253
|
int mode;
|
|
@@ -12256,7 +12256,7 @@ fn globeClouds_getColor(camera: vec3f, direction: vec3f) -> vec4f {
|
|
|
12256
12256
|
} pbrEnvironmentFilter;
|
|
12257
12257
|
|
|
12258
12258
|
uniform sampler2D pbrEnvironmentSource;
|
|
12259
|
-
`,
|
|
12259
|
+
`,Cl=`struct PBREnvironmentFilterUniforms {
|
|
12260
12260
|
face: i32,
|
|
12261
12261
|
roughness: f32,
|
|
12262
12262
|
mode: i32,
|
|
@@ -12267,7 +12267,7 @@ uniform sampler2D pbrEnvironmentSource;
|
|
|
12267
12267
|
@group(0) @binding(auto) var<uniform> pbrEnvironmentFilter: PBREnvironmentFilterUniforms;
|
|
12268
12268
|
@group(0) @binding(auto) var pbrEnvironmentSource: texture_2d<f32>;
|
|
12269
12269
|
@group(0) @binding(auto) var pbrEnvironmentSourceSampler: sampler;
|
|
12270
|
-
`,
|
|
12270
|
+
`,eo={name:"pbrEnvironmentFilter",bindingLayout:[{name:"pbrEnvironmentFilter",group:0},{name:"pbrEnvironmentSource",group:0}],fs:yl,source:Cl,getUniforms:e=>e,uniformTypes:{face:"i32",roughness:"f32",mode:"i32",sampleCount:"i32",sourceEncoding:"i32"},defaultUniforms:{face:0,roughness:0,mode:0,sampleCount:64,sourceEncoding:0}},to=`#version 300 es
|
|
12271
12271
|
precision highp float;
|
|
12272
12272
|
precision highp int;
|
|
12273
12273
|
|
|
@@ -12419,7 +12419,7 @@ void main(void)
|
|
|
12419
12419
|
vec3 direction = getEnvironmentFaceDirection(pbrEnvironmentFilter.face, uv);
|
|
12420
12420
|
fragmentColor = vec4(integrateEnvironmentDirection(direction, sampleCount), 1.0);
|
|
12421
12421
|
}
|
|
12422
|
-
`,
|
|
12422
|
+
`,io=`const ENVIRONMENT_PI: f32 = 3.141592653589793;
|
|
12423
12423
|
|
|
12424
12424
|
fn getEnvironmentHammersley(index: u32, sampleCount: u32) -> vec2f {
|
|
12425
12425
|
return vec2f(f32(index) / f32(sampleCount), f32(reverseBits(index)) * 2.3283064365386963e-10);
|
|
@@ -12556,7 +12556,7 @@ fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {
|
|
|
12556
12556
|
let direction = getEnvironmentFaceDirection(pbrEnvironmentFilter.face, textureCoordinate);
|
|
12557
12557
|
return vec4f(integrateEnvironmentDirection(direction, sampleCount), 1.0);
|
|
12558
12558
|
}
|
|
12559
|
-
`;var
|
|
12559
|
+
`;var no=`
|
|
12560
12560
|
precision highp sampler2DArray;
|
|
12561
12561
|
struct DirectionalShadowLightUniform {
|
|
12562
12562
|
vec3 direction;
|
|
@@ -12754,7 +12754,7 @@ float shadow_getPointFactor(int lightIndex, vec3 worldPosition, vec3 worldNormal
|
|
|
12754
12754
|
}
|
|
12755
12755
|
return mix(1.0, visibility / max(float(shadow.filterSampleCount), 1.0), light.strength);
|
|
12756
12756
|
}
|
|
12757
|
-
`;var
|
|
12757
|
+
`;var Il=4,mi=4,ro=4,wl=24,Ll={direction:"vec3<f32>",strength:"f32",normalBias:"f32",sourceAngularRadius:"f32",cascadeBlendFraction:"f32",farFadeFraction:"f32",shadowDistance:"f32"},Ml={position:"vec3<f32>",range:"f32",direction:"vec3<f32>",outerConeCos:"f32",sourceRadius:"f32",normalBias:"f32",strength:"f32",nearPlane:"f32"},Al={position:"vec3<f32>",range:"f32",sourceRadius:"f32",normalBias:"f32",strength:"f32",nearPlane:"f32"},Rl=`const SHADOW_PI: f32 = 3.141592653589793;
|
|
12758
12758
|
|
|
12759
12759
|
struct DirectionalShadowLightUniform {
|
|
12760
12760
|
direction: vec3f,
|
|
@@ -13029,7 +13029,7 @@ fn shadow_getPointFactor(lightIndex: i32, worldPosition: vec3f, worldNormal: vec
|
|
|
13029
13029
|
visibility /= max(f32(shadow.filterSampleCount), 1.0);
|
|
13030
13030
|
return mix(1.0, visibility, light.strength);
|
|
13031
13031
|
}
|
|
13032
|
-
`,bt={name:"shadow",source:
|
|
13032
|
+
`,bt={name:"shadow",source:Rl,fs:no,props:{},uniforms:{},bindings:{},uniformTypes:{directionalLightCount:"i32",spotLightCount:"i32",pointLightCount:"i32",cascadeCount:"i32",blockerSampleCount:"i32",filterSampleCount:"i32",cascadeSplits:"vec4<f32>",directionalViewProjectionMatrices:["mat4x4<f32>",Il],spotViewProjectionMatrices:["mat4x4<f32>",mi],pointViewProjectionMatrices:["mat4x4<f32>",wl],directionalLights:[Ll,1],spotLights:[Ml,mi],pointLights:[Al,ro]},bindingLayout:[{name:"shadow",group:2},{name:"directionalShadowTexture",group:2},{name:"spotShadowTexture",group:2},{name:"pointShadowTexture",group:2},{name:"shadowComparisonSampler",group:2}],getUniforms(e){return!e.directionalLights||!e.spotLights||!e.pointLights||!e.cascadeSplits||!e.directionalViewProjectionMatrices||!e.spotViewProjectionMatrices||!e.pointViewProjectionMatrices||!e.directionalShadowTexture||!e.spotShadowTexture||!e.pointShadowTexture||!e.nonFilteringSampler||!e.comparisonSampler?{}:{directionalLightCount:e.directionalLights.length,spotLightCount:e.spotLights.length,pointLightCount:e.pointLights.length,cascadeCount:e.cascadeCount,blockerSampleCount:e.blockerSampleCount,filterSampleCount:e.filterSampleCount,cascadeSplits:e.cascadeSplits,directionalViewProjectionMatrices:e.directionalViewProjectionMatrices,spotViewProjectionMatrices:e.spotViewProjectionMatrices,pointViewProjectionMatrices:e.pointViewProjectionMatrices,directionalLights:Tl(e.directionalLights),spotLights:El(e.spotLights),pointLights:Pl(e.pointLights),directionalShadowTexture:e.directionalShadowTexture,spotShadowTexture:e.spotShadowTexture,pointShadowTexture:e.pointShadowTexture,...e.directionalShadowTexture.device.type==="webgpu"?{shadowComparisonSampler:e.comparisonSampler}:{}}}};function Tl(e){let t=e[0];return[t?{direction:t.direction,strength:t.strength??1,normalBias:t.normalBias??.04,sourceAngularRadius:t.sourceAngularRadius??.00465,cascadeBlendFraction:t.cascadeBlendFraction??.1,farFadeFraction:t.farFadeFraction??.1,shadowDistance:t.shadowDistance??1}:{direction:[0,1,0],strength:0,normalBias:0,sourceAngularRadius:0,cascadeBlendFraction:0,farFadeFraction:0,shadowDistance:1}]}function El(e){return oo(e.map(t=>({position:t.position,range:t.range,direction:t.direction,outerConeCos:Math.cos(t.outerConeAngle),sourceRadius:t.sourceRadius??.2,normalBias:t.normalBias??.025,strength:t.strength??1,nearPlane:t.nearPlane??.1})),mi,{position:[0,0,0],range:1,direction:[0,-1,0],outerConeCos:1,sourceRadius:0,normalBias:0,strength:0,nearPlane:.1})}function Pl(e){return oo(e.map(t=>({position:t.position,range:t.range,sourceRadius:t.sourceRadius??.2,normalBias:t.normalBias??.025,strength:t.strength??1,nearPlane:t.nearPlane??.1})),ro,{position:[0,0,0],range:1,sourceRadius:0,normalBias:0,strength:0,nearPlane:.1})}function oo(e,t,i){let n=e.slice(0,t);for(;n.length<t;)n.push(i);return n}var ao={name:"pbrShadow",dependencies:[U,bt],bindingLayout:[{name:"pbrShadow",group:0}],uniformTypes:{viewMatrix:"mat4x4<f32>",enabled:"i32"},defaultUniforms:{viewMatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],enabled:1},getUniforms(e={}){return{...e.viewMatrix?{viewMatrix:e.viewMatrix}:{},...e.enabled===void 0?{}:{enabled:Number(e.enabled)}}},source:`
|
|
13033
13033
|
struct PBRShadowUniforms {
|
|
13034
13034
|
viewMatrix: mat4x4f,
|
|
13035
13035
|
enabled: i32,
|
|
@@ -13074,7 +13074,7 @@ vec4 pbrShadow_filterColorWithDirectionalContact(vec4 vertexColor, vec3 worldPos
|
|
|
13074
13074
|
}
|
|
13075
13075
|
vec4 pbrShadow_filterColor(vec4 vertexColor, vec3 worldPosition, vec3 worldNormal) {
|
|
13076
13076
|
return pbrShadow_filterColorWithDirectionalContact(vertexColor, worldPosition, worldNormal, 1.0);
|
|
13077
|
-
}`};var
|
|
13077
|
+
}`};var so={name:"pbrSurface",dependencies:[U],bindingLayout:[{name:"pbrSurface",group:0}],uniformTypes:{viewMatrix:"mat4x4<f32>",useMaterialNormals:"i32"},defaultUniforms:{viewMatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],useMaterialNormals:0},getUniforms(e={}){return{...e.viewMatrix?{viewMatrix:e.viewMatrix}:{},...e.useMaterialNormals===void 0?{}:{useMaterialNormals:Number(e.useMaterialNormals)}}},source:`
|
|
13078
13078
|
struct PBRSurfaceUniforms {
|
|
13079
13079
|
viewMatrix: mat4x4f,
|
|
13080
13080
|
useMaterialNormals: i32,
|
|
@@ -13137,7 +13137,7 @@ vec4 pbrSurface_getColor() {
|
|
|
13137
13137
|
#endif
|
|
13138
13138
|
vec3 viewNormal = normalize((pbrSurface.viewMatrix * vec4(normal, 0.0)).xyz);
|
|
13139
13139
|
return vec4(viewNormal * 0.5 + 0.5, 1.0);
|
|
13140
|
-
}`};var
|
|
13140
|
+
}`};var lo=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],co={name:"contactShadowTrace",source:`struct contactShadowTraceUniforms {
|
|
13141
13141
|
projectionMatrix: mat4x4f,
|
|
13142
13142
|
inverseProjectionMatrix: mat4x4f,
|
|
13143
13143
|
lightDirectionView: vec3f,
|
|
@@ -13241,7 +13241,7 @@ vec4 contactShadowTrace_sampleColor(sampler2D sourceTexture,vec2 texSize,vec2 te
|
|
|
13241
13241
|
}
|
|
13242
13242
|
return vec4(1.0);
|
|
13243
13243
|
}
|
|
13244
|
-
`,bindingLayout:[{name:"depthTexture",group:0},{name:"normalTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{projectionMatrix:"mat4x4<f32>",inverseProjectionMatrix:"mat4x4<f32>",lightDirectionView:"vec3<f32>",maxDistance:"f32",thickness:"f32",stepCount:"f32",frameIndex:"f32",normalBias:"f32"},propTypes:{projectionMatrix:{value:
|
|
13244
|
+
`,bindingLayout:[{name:"depthTexture",group:0},{name:"normalTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{projectionMatrix:"mat4x4<f32>",inverseProjectionMatrix:"mat4x4<f32>",lightDirectionView:"vec3<f32>",maxDistance:"f32",thickness:"f32",stepCount:"f32",frameIndex:"f32",normalBias:"f32"},propTypes:{projectionMatrix:{value:lo,private:!0},inverseProjectionMatrix:{value:lo,private:!0},lightDirectionView:{value:[0,1,0],private:!0},maxDistance:{value:4,min:.1,softMax:16},thickness:{value:.12,min:.005,softMax:1},stepCount:{value:24,min:1,max:40},frameIndex:{value:0,private:!0},normalBias:{value:.035,min:0,softMax:.2}},passes:[{sampler:!0}]},fo={name:"contactShadowBilateralBlur",source:`struct contactShadowBilateralBlurUniforms {
|
|
13245
13245
|
direction: vec2f,
|
|
13246
13246
|
radius: f32,
|
|
13247
13247
|
depthSigma: f32,
|
|
@@ -13310,7 +13310,7 @@ vec4 contactShadowBilateralBlur_sampleColor(sampler2D sourceTexture,vec2 texSize
|
|
|
13310
13310
|
}
|
|
13311
13311
|
return vec4(vec3(result/totalWeight),1.0);
|
|
13312
13312
|
}
|
|
13313
|
-
`,bindingLayout:[{name:"depthTexture",group:0},{name:"normalTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{direction:"vec2<f32>",radius:"f32",depthSigma:"f32",normalPower:"f32"},propTypes:{direction:{value:[1,0],private:!0},radius:{value:4,min:1,max:6},depthSigma:{value:.006,min:1e-4,softMax:.05},normalPower:{value:24,min:1,softMax:64}},passes:[{sampler:!0}]},
|
|
13313
|
+
`,bindingLayout:[{name:"depthTexture",group:0},{name:"normalTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{direction:"vec2<f32>",radius:"f32",depthSigma:"f32",normalPower:"f32"},propTypes:{direction:{value:[1,0],private:!0},radius:{value:4,min:1,max:6},depthSigma:{value:.006,min:1e-4,softMax:.05},normalPower:{value:24,min:1,softMax:64}},passes:[{sampler:!0}]},uo={name:"contactShadowComposite",source:`struct contactShadowCompositeUniforms {
|
|
13314
13314
|
strength: f32,
|
|
13315
13315
|
debugMode: f32,
|
|
13316
13316
|
};
|
|
@@ -13359,7 +13359,7 @@ vec4 contactShadowComposite_sampleColor(sampler2D sourceTexture,vec2 texSize,vec
|
|
|
13359
13359
|
vec3 directionalDirect=texture(directionalDirectTexture,texCoord).rgb;
|
|
13360
13360
|
return vec4(max(color.rgb-directionalDirect*(1.0-appliedContact),vec3(0.0)),color.a);
|
|
13361
13361
|
}
|
|
13362
|
-
`,bindingLayout:[{name:"contactShadowTexture",group:0},{name:"directionalDirectTexture",group:0},{name:"shadowDebugTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{strength:"f32",debugMode:"f32"},propTypes:{strength:{value:1,min:0,max:1},debugMode:{value:0,min:0,max:2,private:!0}},passes:[{sampler:!0}]};var
|
|
13362
|
+
`,bindingLayout:[{name:"contactShadowTexture",group:0},{name:"directionalDirectTexture",group:0},{name:"shadowDebugTexture",group:0}],props:{},uniforms:{},bindings:{},uniformTypes:{strength:"f32",debugMode:"f32"},propTypes:{strength:{value:1,min:0,max:1},debugMode:{value:0,min:0,max:2,private:!0}},passes:[{sampler:!0}]};var po={name:"pbrContactShadow",dependencies:[U],bindingLayout:[{name:"pbrContactShadow",group:0},{name:"contactShadowTexture",group:2}],uniformTypes:{viewport:"vec4<f32>",strength:"f32",enabled:"i32"},defaultUniforms:{viewport:[0,0,1,1],strength:1,enabled:1},getUniforms(e={}){return{...e.viewport?{viewport:e.viewport}:{},...e.strength===void 0?{}:{strength:e.strength},...e.enabled===void 0?{}:{enabled:Number(e.enabled)},...e.contactShadowTexture?{contactShadowTexture:e.contactShadowTexture}:{}}},source:`
|
|
13363
13363
|
struct PBRContactShadowUniforms {
|
|
13364
13364
|
viewport: vec4f,
|
|
13365
13365
|
strength: f32,
|
|
@@ -13393,14 +13393,14 @@ float pbrContactShadow_getFactor(vec2 pixelPosition) {
|
|
|
13393
13393
|
}
|
|
13394
13394
|
vec4 pbrContactShadow_filterColor(vec4 vertexColor,vec2 pixelPosition) {
|
|
13395
13395
|
return pbr_filterColorWithShadows(vertexColor,pbrContactShadow_getFactor(pixelPosition),vec4(1.0),vec4(1.0));
|
|
13396
|
-
}`};var
|
|
13396
|
+
}`};var go={name:"clusteredLightGrid",source:`
|
|
13397
13397
|
fn clusteredLightGrid_getIndex(coordinates: vec2f, viewDepth: f32, dimensions: vec3u, nearPlane: f32, farPlane: f32) -> u32 {
|
|
13398
13398
|
let tile = min(vec2u(clamp(coordinates, vec2f(0.0), vec2f(0.999999)) * vec2f(dimensions.xy)), dimensions.xy - vec2u(1));
|
|
13399
13399
|
let normalizedDepth = clamp(log(clamp(viewDepth, nearPlane, farPlane) / nearPlane) / log(farPlane / nearPlane), 0.0, 0.999999);
|
|
13400
13400
|
let depthSlice = min(u32(normalizedDepth * f32(dimensions.z)), dimensions.z - 1u);
|
|
13401
13401
|
return (depthSlice * dimensions.y + tile.y) * dimensions.x + tile.x;
|
|
13402
13402
|
}
|
|
13403
|
-
`};var
|
|
13403
|
+
`};var mo={name:"pbrAmbientOcclusion",dependencies:[U],bindingLayout:[{name:"pbrAmbientOcclusion",group:0},{name:"ambientOcclusionTexture",group:2}],uniformTypes:{viewport:"vec4<f32>",strength:"f32",enabled:"i32"},defaultUniforms:{viewport:[0,0,1,1],strength:1,enabled:1},getUniforms(e={}){return{...e.viewport?{viewport:e.viewport}:{},...e.strength===void 0?{}:{strength:e.strength},...e.enabled===void 0?{}:{enabled:Number(e.enabled)},...e.ambientOcclusionTexture?{ambientOcclusionTexture:e.ambientOcclusionTexture}:{}}},source:`
|
|
13404
13404
|
struct PBRAmbientOcclusionUniforms {
|
|
13405
13405
|
viewport: vec4f,
|
|
13406
13406
|
strength: f32,
|
|
@@ -13434,6 +13434,110 @@ float pbrAmbientOcclusion_getFactor(vec2 pixelPosition) {
|
|
|
13434
13434
|
}
|
|
13435
13435
|
void pbrAmbientOcclusion_setFactor(vec2 pixelPosition) {
|
|
13436
13436
|
pbr_ambientVisibility = pbrAmbientOcclusion_getFactor(pixelPosition);
|
|
13437
|
-
}`};
|
|
13437
|
+
}`};var ho={name:"lightmapBake",dependencies:[U],bindingLayout:[{name:"lightmapBake",group:0}],uniformTypes:{uvSet:"i32",uvTransform:"mat3x3<f32>",chartId:"f32"},defaultUniforms:{uvSet:1,uvTransform:[1,0,0,0,1,0,0,0,1],chartId:1},getUniforms:e=>e,source:`
|
|
13438
|
+
struct LightmapBakeUniforms {uvSet: i32, uvTransform: mat3x3f, chartId: f32};
|
|
13439
|
+
@group(0) @binding(auto) var<uniform> lightmapBake: LightmapBakeUniforms;
|
|
13440
|
+
|
|
13441
|
+
fn lightmap_getIrradiance(position: vec3f, normal: vec3f, directionalVisibility: f32, pointVisibility: vec4f, spotVisibility: vec4f) -> vec3f {
|
|
13442
|
+
if (lighting.enabled == 0) {return vec3f(0.0);}
|
|
13443
|
+
var irradiance = lighting.ambientColor;
|
|
13444
|
+
for (var index = 0; index < lighting.directionalLightCount; index++) {
|
|
13445
|
+
let light = lighting_getDirectionalLight(index);
|
|
13446
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * select(1.0, directionalVisibility, index == 0);
|
|
13447
|
+
}
|
|
13448
|
+
for (var index = 0; index < lighting.pointLightCount; index++) {
|
|
13449
|
+
let light = lighting_getPointLight(index);
|
|
13450
|
+
let offset = light.position - position;
|
|
13451
|
+
let visibility = select(1.0, pointVisibility[min(index, 3)], index < 4);
|
|
13452
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * visibility / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
13453
|
+
}
|
|
13454
|
+
for (var index = 0; index < lighting.spotLightCount; index++) {
|
|
13455
|
+
let light = lighting_getSpotLight(index);
|
|
13456
|
+
irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * select(1.0, spotVisibility[min(index, 3)], index < 4) / max(getSpotLightAttenuation(light, position), 0.0001);
|
|
13457
|
+
}
|
|
13458
|
+
return irradiance;
|
|
13459
|
+
}
|
|
13460
|
+
`,vs:`layout(std140) uniform lightmapBakeUniforms {
|
|
13461
|
+
int uvSet;
|
|
13462
|
+
mat3 uvTransform;
|
|
13463
|
+
float chartId;
|
|
13464
|
+
} lightmapBake;`,fs:`layout(std140) uniform lightmapBakeUniforms {
|
|
13465
|
+
int uvSet;
|
|
13466
|
+
mat3 uvTransform;
|
|
13467
|
+
float chartId;
|
|
13468
|
+
} lightmapBake;
|
|
13469
|
+
|
|
13470
|
+
vec3 lightmap_getIrradiance(vec3 position, vec3 normal, float directionalVisibility, vec4 pointVisibility, vec4 spotVisibility) {
|
|
13471
|
+
if (lighting.enabled == 0) {return vec3(0.0);}
|
|
13472
|
+
vec3 irradiance = lighting.ambientColor;
|
|
13473
|
+
for (int index = 0; index < lighting.directionalLightCount; index++) {
|
|
13474
|
+
DirectionalLight light = lighting_getDirectionalLight(index);
|
|
13475
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * (index == 0 ? directionalVisibility : 1.0);
|
|
13476
|
+
}
|
|
13477
|
+
for (int index = 0; index < lighting.pointLightCount; index++) {
|
|
13478
|
+
PointLight light = lighting_getPointLight(index);
|
|
13479
|
+
vec3 offset = light.position - position;
|
|
13480
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * (index < 4 ? pointVisibility[index] : 1.0) / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
13481
|
+
}
|
|
13482
|
+
for (int index = 0; index < lighting.spotLightCount; index++) {
|
|
13483
|
+
SpotLight light = lighting_getSpotLight(index);
|
|
13484
|
+
irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * (index < 4 ? spotVisibility[index] : 1.0) / max(getSpotLightAttenuation(light, position), 0.0001);
|
|
13485
|
+
}
|
|
13486
|
+
return irradiance;
|
|
13487
|
+
}
|
|
13488
|
+
`};var vo={name:"lightmapFilter",bindingLayout:[{name:"lightmapFilter",group:0},{name:"currentTexture",group:0},{name:"previousTexture",group:0},{name:"chartTexture",group:0}],uniformTypes:{weight:"f32",mode:"i32"},defaultUniforms:{weight:1,mode:0},getUniforms:e=>e,source:`
|
|
13489
|
+
struct LightmapFilterUniforms {weight: f32, mode: i32};
|
|
13490
|
+
@group(0) @binding(auto) var<uniform> lightmapFilter: LightmapFilterUniforms;
|
|
13491
|
+
@group(0) @binding(auto) var currentTexture: texture_2d<f32>;
|
|
13492
|
+
@group(0) @binding(auto) var previousTexture: texture_2d<f32>;
|
|
13493
|
+
@group(0) @binding(auto) var chartTexture: texture_2d<f32>;
|
|
13494
|
+
fn lightmapFilter_getColor(coordinates: vec2i) -> vec4f {
|
|
13495
|
+
let current = textureLoad(currentTexture, coordinates, 0);
|
|
13496
|
+
if (lightmapFilter.mode == 0) {
|
|
13497
|
+
let previous = textureLoad(previousTexture, coordinates, 0);
|
|
13498
|
+
return vec4f(mix(previous.rgb, current.rgb, lightmapFilter.weight), current.a);
|
|
13499
|
+
}
|
|
13500
|
+
if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
|
|
13501
|
+
let chart = textureLoad(chartTexture, coordinates, 0).r;
|
|
13502
|
+
if (chart <= 0.0) {return current;}
|
|
13503
|
+
let size = vec2i(textureDimensions(currentTexture));
|
|
13504
|
+
for (var y = -1; y <= 1; y++) {
|
|
13505
|
+
for (var x = -1; x <= 1; x++) {
|
|
13506
|
+
let neighbor = coordinates + vec2i(x, y);
|
|
13507
|
+
if (all(neighbor >= vec2i(0)) && all(neighbor < size)) {
|
|
13508
|
+
let candidate = textureLoad(currentTexture, neighbor, 0);
|
|
13509
|
+
if (candidate.a == chart) {return candidate;}
|
|
13510
|
+
}
|
|
13511
|
+
}
|
|
13512
|
+
}
|
|
13513
|
+
return current;
|
|
13514
|
+
}`,fs:`
|
|
13515
|
+
layout(std140) uniform lightmapFilterUniforms {
|
|
13516
|
+
float weight;
|
|
13517
|
+
int mode;
|
|
13518
|
+
} lightmapFilter;
|
|
13519
|
+
uniform sampler2D currentTexture;
|
|
13520
|
+
uniform sampler2D previousTexture;
|
|
13521
|
+
uniform sampler2D chartTexture;
|
|
13522
|
+
vec4 lightmapFilter_getColor(ivec2 coordinates) {
|
|
13523
|
+
vec4 current = texelFetch(currentTexture, coordinates, 0);
|
|
13524
|
+
if (lightmapFilter.mode == 0) {
|
|
13525
|
+
return vec4(mix(texelFetch(previousTexture, coordinates, 0).rgb, current.rgb, lightmapFilter.weight), current.a);
|
|
13526
|
+
}
|
|
13527
|
+
if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
|
|
13528
|
+
float chart = texelFetch(chartTexture, coordinates, 0).r;
|
|
13529
|
+
ivec2 size = textureSize(currentTexture, 0);
|
|
13530
|
+
if (chart <= 0.0) return current;
|
|
13531
|
+
for (int y = -1; y <= 1; y++) {
|
|
13532
|
+
for (int x = -1; x <= 1; x++) {
|
|
13533
|
+
ivec2 neighbor = coordinates + ivec2(x,y);
|
|
13534
|
+
if (all(greaterThanEqual(neighbor, ivec2(0))) && all(lessThan(neighbor,size))) {
|
|
13535
|
+
vec4 candidate = texelFetch(currentTexture, neighbor, 0);
|
|
13536
|
+
if (candidate.a == chart) {return candidate;}
|
|
13537
|
+
}
|
|
13538
|
+
}
|
|
13539
|
+
}
|
|
13540
|
+
return current;
|
|
13541
|
+
}`};return wo(Dl);})();
|
|
13438
13542
|
return __exports__;
|
|
13439
13543
|
});
|