@luma.gl/shaders 10.0.0-alpha.7 → 10.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +233 -249
- package/dist/dist.min.js +124 -124
- package/dist/glsl.cjs.map +2 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/shader-assembler-base.cjs +3 -4
- package/dist/lib/shader-assembler-base.d.ts +4 -5
- package/dist/lib/shader-assembler-base.d.ts.map +1 -1
- package/dist/lib/shader-assembler-base.js +3 -4
- package/dist/lib/shader-assembler-base.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +6 -17
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +5 -4
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js +14 -19
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +6 -25
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts +5 -6
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +14 -27
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts +2 -2
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-shared.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts +11 -7
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.cjs +26 -29
- package/dist/lib/shader-assembly/shader-hooks.d.ts +34 -32
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.js +29 -33
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.cjs +26 -2
- package/dist/lib/shader-assembly/shader-injections.d.ts +20 -7
- package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.js +24 -0
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -1
- package/dist/lib/shader-module/shader-module.cjs +3 -9
- package/dist/lib/shader-module/shader-module.d.ts +4 -8
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +3 -6
- package/dist/lib/shader-module/shader-module.js.map +1 -1
- package/dist/lib/shader-plugin.cjs +38 -17
- package/dist/lib/shader-plugin.d.ts +9 -17
- package/dist/lib/shader-plugin.d.ts.map +1 -1
- package/dist/lib/shader-plugin.js +43 -16
- package/dist/lib/shader-plugin.js.map +1 -1
- package/dist/modules/engine/clip/clip.cjs +4 -2
- package/dist/modules/engine/clip/clip.d.ts.map +1 -1
- package/dist/modules/engine/clip/clip.js +4 -2
- package/dist/modules/engine/clip/clip.js.map +1 -1
- package/dist/modules/engine/filter/filter.cjs +2 -1
- package/dist/modules/engine/filter/filter.d.ts.map +1 -1
- package/dist/modules/engine/filter/filter.js +2 -1
- package/dist/modules/engine/filter/filter.js.map +1 -1
- package/dist/modules/lighting/lights/lighting.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.cjs +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.cjs +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +2 -2
- package/dist/types/texture-formats.d.ts +1 -1
- package/dist/types/texture-formats.d.ts.map +1 -1
- package/dist/wgsl.cjs.map +2 -2
- package/package.json +3 -3
- package/src/index.ts +5 -4
- package/src/lib/shader-assembler-base.ts +5 -6
- package/src/lib/shader-assembly/assemble-glsl-shaders.ts +27 -26
- package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +28 -43
- package/src/lib/shader-assembly/shader-assembly-shared.ts +5 -5
- package/src/lib/shader-assembly/shader-assembly-types.ts +11 -7
- package/src/lib/shader-assembly/shader-hooks.ts +65 -68
- package/src/lib/shader-assembly/shader-injections.ts +52 -8
- package/src/lib/shader-module/shader-module.ts +7 -14
- package/src/lib/shader-plugin.ts +59 -48
- package/src/modules/engine/clip/clip.ts +4 -2
- package/src/modules/engine/filter/filter.ts +2 -1
- package/src/modules/lighting/lights/lighting.ts +1 -1
- package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +2 -2
- package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +2 -2
- package/src/types/texture-formats.ts +2 -0
package/dist/dist.min.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
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 mt=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var jr=Object.getOwnPropertyNames;var $r=Object.prototype.hasOwnProperty;var Kr=(e,t)=>{for(var i in t)mt(e,i,{get:t[i],enumerable:!0})},Yr=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of jr(t))!$r.call(e,r)&&r!==i&&mt(e,r,{get:()=>t[r],enumerable:!(n=qr(t,r))||n.enumerable});return e};var Zr=e=>Yr(mt({},"__esModule",{value:!0}),e);var
|
|
7
|
+
"use strict";var __exports__=(()=>{var mt=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var jr=Object.getOwnPropertyNames;var $r=Object.prototype.hasOwnProperty;var Kr=(e,t)=>{for(var i in t)mt(e,i,{get:t[i],enumerable:!0})},Yr=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of jr(t))!$r.call(e,r)&&r!==i&&mt(e,r,{get:()=>t[r],enumerable:!(n=qr(t,r))||n.enumerable});return e};var Zr=e=>Yr(mt({},"__esModule",{value:!0}),e);var Ks={};Kr(Ks,{GLSLShaderAssembler:()=>Se,PBR_TONE_MAP_MODE:()=>ii,SKIN_MAX_JOINTS:()=>q,STORAGE_COLOR_DEFAULT_BYTE_STRIDES:()=>et,STORAGE_COLOR_FORMAT:()=>B,STORAGE_COLOR_FORMAT_BYTE_LENGTHS:()=>Qe,ShaderAssembler:()=>V,WGSLShaderAssembler:()=>ye,_resolveModules:()=>xi,areaLighting:()=>ut,assembleGLSLShaderPair:()=>xe,atmosphere:()=>Ur,capitalize:()=>J,checkShaderModuleDeprecations:()=>oe,clipShaderPlugin:()=>sr,clouds:()=>gt,colors:()=>nr,combineInjects:()=>Li,convertToVec4:()=>Dt,dggs:()=>Kn,dirlight:()=>Zt,filterShaderPlugin:()=>ar,firefly:()=>zr,floatColors:()=>de,fp32:()=>Gn,fp64:()=>jn,fp64LowPart:()=>Ie,fp64arithmetic:()=>jt,fp64ify:()=>pe,fp64ifyMatrix4:()=>Ce,fromHalfFloat:()=>Pn,generateShaderForModule:()=>an,getGLSLUniformBlocks:()=>De,getPassthroughFS:()=>en,getQualifierDetails:()=>Qi,getShaderInfo:()=>qe,getShaderModuleDependencies:()=>k,getShaderModuleSource:()=>Z,getShaderModuleUniformBlockFields:()=>At,getShaderModuleUniformBlockName:()=>Ne,getShaderModuleUniformLayoutValidationResult:()=>Mt,getShaderModuleUniforms:()=>bi,globeClouds:()=>Vr,gouraudMaterial:()=>Jt,gpuAnimation:()=>cr,heightFog:()=>Pr,heightFogFunctions:()=>dt,ibl:()=>rt,initializeShaderModule:()=>we,initializeShaderModules:()=>Y,integrateSurfaceWeather:()=>kr,lambertMaterial:()=>Xt,lighting:()=>D,mergeShaderPluginModules:()=>Ni,normalizeByteColor3:()=>te,normalizeByteColor4:()=>Je,pathDash:()=>Bn,patternFill:()=>Dr,pbrMaterial:()=>Tr,pbrScene:()=>pt,phongMaterial:()=>Qt,picking:()=>or,pointGlow:()=>Or,precipitation:()=>Br,preprocess:()=>W,random:()=>Un,resolveShaderPlugins:()=>Pi,resolveUseByteColors:()=>ee,riverWaterMaterial:()=>Sr,scanWGSLInterface:()=>Re,sketchStroke:()=>On,skin:()=>lr,storageColors:()=>rr,surfaceWeather:()=>Gr,toHalfFloat:()=>Tn,typeToChannelCount:()=>nn,typeToChannelSuffix:()=>tn,validateShaderModuleUniformLayout:()=>Fe,valueNoise:()=>$,volumeRaymarch:()=>kn,warnIfGLSLUniformBlocksAreNotStd140:()=>Oe,waterMaterial:()=>ft});var O="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";var re=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${O}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${O}`,"g")],Ae=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${O}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${O}`,"g")],ci=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${O}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${O}`,"g")],Xr=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${O}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${O}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${O}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${O}`,"g")];function z(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 K(e,t){let i=z(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 ht(e,t,i){let n=K(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 _t(e){return/@binding\(\s*auto\s*\)/.test(z(e))}function ui(e,t){return K(e,t===ne||t===ye?Xr:t).find(n=>n.bindingToken==="auto")}function Le(e,t={}){let i=pi(e),n=Jr(i);if(!n)return null;let r=Qr(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=eo(i,n);if(!a)return null;let s=ao(i,n,r,a,t.vertexEntryPoint);return s?{attributes:s,bindings:o}:null}function pi(e){let t=z(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 Jr(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 Qr(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(!ue(r)||e[n+2]?.value!=="="||i.has(r))return null;let o=mi(e,t,n+3,";");if(o<0||o===n+3)return null;i.set(r,Ce(e.slice(n+3,o))),n=o}return i}function eo(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(!ue(r)||i.has(r)||e[o]?.value!=="{")return null;let a=St(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=hi(e,t,a),l=e.slice(s,a),c=vt(l,"group"),f=vt(l,"binding");if(c===null||f===null||c===void 0!=(f===void 0))return null;if(c===void 0||f===void 0)continue;let u=a+1,p=[];if(e[u]?.value==="<"){let S=St(e,u,"<",">");if(S<0)return null;let b=Ae(e.slice(u+1,S),",");if(!b)return null;p=b.map(Ce),u=S+1}let d=e[u]?.value;if(!ue(d)||e[u+1]?.value!==":")return null;let v=mi(e,t,u+2,";");if(v<0||v===u+2)return null;let m=xt(Ce(e.slice(u+2,v)),i);if(!m)return null;let x=io({name:d,group:c,location:f,addressSpace:p,resourceType:m}),I=`${c}:${f}`;if(!x||r.has(I)||o.has(d))return null;n.push(x),r.add(I),o.add(d),a=v}return oo(n),n.sort((a,s)=>a.group-s.group||a.location-s.location||a.name.localeCompare(s.name))}function io(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"}:no(a,o)||ro(a,o)}function no(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:bt(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:bt(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:bt(n[2]),sampleType:"depth",multisampled:!!n[1]}}function oo(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 ao(e,t,i,n,r){let o=so(e,t);if(!o)return null;let a=o.filter(d=>d.vertex),s=r?a.find(d=>d.name===r):a.length===1?a[0]:void 0;if(!s)return a.length===0&&!r?[]:null;let l=Ae(s.parameters,",");if(!l)return null;let c=[],f=new Set,u=new Set,p=new Set;for(let d of l)if(d.length>0&&!di({declaration:d,aliases:i,structures:n,attributes:c,attributeLocations:f,attributeNames:u,visitedStructures:p}))return null;return c.sort((d,v)=>d.location-v.location||d.name.localeCompare(v.name))}function so(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(!ue(o)||n.has(o)||e[a]?.value!=="(")return null;let s=St(e,a,"(",")");if(s<0)return null;let l=hi(e,t,r);i.push({name:o,vertex:gi(e.slice(l,r),"vertex"),parameters:e.slice(a+1,s)}),n.add(o),r=s}return i}function di(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=uo(t.slice(0,l)),f=vt(t.slice(0,l),"location"),u=gi(t.slice(0,l),"builtin"),p=xt(Ce(t.slice(l+1)),i);if(!c||f===null||!p||f!==void 0&&u)return!1;if(f!==void 0){let m=co(p);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(u)return!0;let d=n.get(p);if(!d||s.has(p))return!1;let v=Ae(d,",");if(!v)return!1;s.add(p);for(let m of v)if(m.length>0&&!di({...e,declaration:m}))return!1;return s.delete(p),!0}function xt(e,t,i=new Set){let n=pi(e),r="";for(let o of n){let a=t.get(o.value);if(!a){r+=lo(o.value);continue}if(i.has(o.value))return null;let s=new Set(i);s.add(o.value);let l=xt(a,t,s);if(!l)return null;r+=l}return r}function lo(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 co(e){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(e)?e:null}function vt(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 gi(e,t){return e.some((i,n)=>i.value==="@"&&e[n+1]?.value===t)}function bt(e){return e.replace("_","-")}function St(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 Ae(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=Ae(e,t);return i&&i.length===2?i[0].length:-1}function mi(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 hi(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 uo(e){for(let t=e.length-1;t>=0;t--)if(ue(e[t].value))return e[t].value;return null}function Ce(e){return e.map(t=>t.value).join("")}function ue(e){return!!(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function P(e,t){if(!e){let i=new Error(t||"shaders: assertion failed.");throw Error.captureStackTrace?.(i,P),i}}var It={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 vi(e){let t={};for(let[i,n]of Object.entries(e))t[i]=po(n);return t}function bi(e,t,i){let n={};for(let[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&P(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}function po(e){let t=_i(e);if(t!=="object")return{value:e,...It[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...It[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=_i(e.value),{...e,...It[t],type:t}):{type:"object",value:null};throw new Error("props")}function _i(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var xi=`#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 K(e,t){let i=z(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 ht(e,t,i){let n=K(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 _t(e){return/@binding\(\s*auto\s*\)/.test(z(e))}function fi(e,t){return K(e,t===re||t===Ae?Xr:t).find(n=>n.bindingToken==="auto")}function Re(e,t={}){let i=ui(e),n=Jr(i);if(!n)return null;let r=Qr(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=eo(i,n);if(!a)return null;let s=ao(i,n,r,a,t.vertexEntryPoint);return s?{attributes:s,bindings:o}:null}function ui(e){let t=z(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 Jr(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 Qr(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(!ge(r)||e[n+2]?.value!=="="||i.has(r))return null;let o=gi(e,t,n+3,";");if(o<0||o===n+3)return null;i.set(r,Me(e.slice(n+3,o))),n=o}return i}function eo(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(!ge(r)||i.has(r)||e[o]?.value!=="{")return null;let a=St(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=mi(e,t,a),l=e.slice(s,a),c=vt(l,"group"),f=vt(l,"binding");if(c===null||f===null||c===void 0!=(f===void 0))return null;if(c===void 0||f===void 0)continue;let u=a+1,p=[];if(e[u]?.value==="<"){let S=St(e,u,"<",">");if(S<0)return null;let b=Ee(e.slice(u+1,S),",");if(!b)return null;p=b.map(Me),u=S+1}let d=e[u]?.value;if(!ge(d)||e[u+1]?.value!==":")return null;let h=gi(e,t,u+2,";");if(h<0||h===u+2)return null;let m=xt(Me(e.slice(u+2,h)),i);if(!m)return null;let x=io({name:d,group:c,location:f,addressSpace:p,resourceType:m}),y=`${c}:${f}`;if(!x||r.has(y)||o.has(d))return null;n.push(x),r.add(y),o.add(d),a=h}return oo(n),n.sort((a,s)=>a.group-s.group||a.location-s.location||a.name.localeCompare(s.name))}function io(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"}:no(a,o)||ro(a,o)}function no(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:bt(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:bt(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:bt(n[2]),sampleType:"depth",multisampled:!!n[1]}}function oo(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 ao(e,t,i,n,r){let o=so(e,t);if(!o)return null;let a=o.filter(d=>d.vertex),s=r?a.find(d=>d.name===r):a.length===1?a[0]:void 0;if(!s)return a.length===0&&!r?[]:null;let l=Ee(s.parameters,",");if(!l)return null;let c=[],f=new Set,u=new Set,p=new Set;for(let d of l)if(d.length>0&&!pi({declaration:d,aliases:i,structures:n,attributes:c,attributeLocations:f,attributeNames:u,visitedStructures:p}))return null;return c.sort((d,h)=>d.location-h.location||d.name.localeCompare(h.name))}function so(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(!ge(o)||n.has(o)||e[a]?.value!=="(")return null;let s=St(e,a,"(",")");if(s<0)return null;let l=mi(e,t,r);i.push({name:o,vertex:di(e.slice(l,r),"vertex"),parameters:e.slice(a+1,s)}),n.add(o),r=s}return i}function pi(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=uo(t.slice(0,l)),f=vt(t.slice(0,l),"location"),u=di(t.slice(0,l),"builtin"),p=xt(Me(t.slice(l+1)),i);if(!c||f===null||!p||f!==void 0&&u)return!1;if(f!==void 0){let m=co(p);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(u)return!0;let d=n.get(p);if(!d||s.has(p))return!1;let h=Ee(d,",");if(!h)return!1;s.add(p);for(let m of h)if(m.length>0&&!pi({...e,declaration:m}))return!1;return s.delete(p),!0}function xt(e,t,i=new Set){let n=ui(e),r="";for(let o of n){let a=t.get(o.value);if(!a){r+=lo(o.value);continue}if(i.has(o.value))return null;let s=new Set(i);s.add(o.value);let l=xt(a,t,s);if(!l)return null;r+=l}return r}function lo(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 co(e){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(e)?e:null}function vt(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 di(e,t){return e.some((i,n)=>i.value==="@"&&e[n+1]?.value===t)}function bt(e){return e.replace("_","-")}function St(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 Ee(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=Ee(e,t);return i&&i.length===2?i[0].length:-1}function gi(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 mi(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 uo(e){for(let t=e.length-1;t>=0;t--)if(ge(e[t].value))return e[t].value;return null}function Me(e){return e.map(t=>t.value).join("")}function ge(e){return!!(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function N(e,t){if(!e){let i=new Error(t||"shaders: assertion failed.");throw Error.captureStackTrace?.(i,N),i}}var yt={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 _i(e){let t={};for(let[i,n]of Object.entries(e))t[i]=po(n);return t}function vi(e,t,i){let n={};for(let[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&N(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}function po(e){let t=hi(e);if(t!=="object")return{value:e,...yt[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...yt[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=hi(e.value),{...e,...yt[t],type:t}):{type:"object",value:null};throw new Error("props")}function hi(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}function Y(e){e.map(t=>we(t))}function we(e){if(e.instance)return;Y(e.dependencies||[]);let{propTypes:t={},deprecations:i=[]}=e,n={parsedDeprecations:go(i),normalizedInjections:{vertex:{},fragment:{}}};t&&(n.propValidators=_i(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 bi(e,t,i){we(e);let n=i||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,n):vi(t,e.instance?.propValidators,e.name)}function oe(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 k(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 u=[...c,l.name].join(" -> ");throw new Error(`Shader module dependency cycle detected: ${u}`)}if(t.has(l))return;o(l),i.add(l);let f=[...c,l.name];if(l.dependencies)for(let u of l.dependencies)a(u,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&&(N(!s.has(l.implements)),s.add(l.implements));return Y(n),n}function mo(e){return k(e)}function xi(e){return mo(e)}var Si=`#ifdef MODULE_LOGDEPTH
|
|
10
10
|
logdepth_adjustPosition(gl_Position);
|
|
11
11
|
#endif
|
|
12
|
-
`,
|
|
12
|
+
`,yi=`#ifdef MODULE_MATERIAL
|
|
13
13
|
fragColor = material_filterColor(fragColor);
|
|
14
14
|
#endif
|
|
15
15
|
|
|
@@ -29,53 +29,53 @@
|
|
|
29
29
|
#ifdef MODULE_LOGDEPTH
|
|
30
30
|
logdepth_setFragDepth();
|
|
31
31
|
#endif
|
|
32
|
-
`;var
|
|
32
|
+
`;var ho={vertex:Si,fragment:yi},Ii=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ci=/}\n?[^{}]*$/,It=[],me="__LUMA_INJECT_DECLARATIONS__";function ae(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 anchor or hook`);n[a]||=[],n[a].push({injection:o,order:r.order??0,...i?{pluginName:i}:{}})}return n}function se(e,t,i,n=!1,r="glsl",o={}){let a=t==="vertex";for(let s in i){let l=i[s];l.sort((f,u)=>f.order-u.order),It.length=l.length;for(let f=0,u=l.length;f<u;++f)It[f]=l[f].injection;let c=`${It.join(`
|
|
33
33
|
`)}
|
|
34
|
-
`;switch(s){case"vs:#decl":(r==="wgsl"||a)&&(e=e.replace(
|
|
35
|
-
${i[n]}`:i[n]}),t}function
|
|
36
|
-
${i}${e.slice(a)}`}return`${e.slice(0,o.closeBraceIndex)}${i}${e.slice(o.closeBraceIndex)}`}function ho(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+${_o(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 _o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y(e){e.map(t=>Re(t))}function Re(e){if(e.instance)return;Y(e.dependencies||[]);let{propTypes:t={},deprecations:i=[],inject:n={}}=e,r={normalizedInjections:Ci(n),parsedDeprecations:vo(i)};t&&(r.propValidators=vi(t)),e.instance=r;let o={};t&&(o=Object.entries(t).reduce((a,[s,l])=>{let c=l?.value;return c&&(a[s]=c),a},{})),e.defaultUniforms={...e.defaultUniforms,...o}}function Ai(e,t,i){Re(e);let n=i||{...e.defaultUniforms};return t&&e.getUniforms?e.getUniforms(t,n):bi(t,e.instance?.propValidators,e.name)}function oe(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 vo(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 k(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 u=[...c,l.name].join(" -> ");throw new Error(`Shader module dependency cycle detected: ${u}`)}if(t.has(l))return;o(l),i.add(l);let f=[...c,l.name];if(l.dependencies)for(let u of l.dependencies)a(u,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&&(P(!s.has(l.implements)),s.add(l.implements));return Y(n),n}function bo(e){return k(e)}function Mi(e){return bo(e)}function Ri(e){let t=Lt(e),i=Io[t];if(!i)throw new Error(`Unsupported variable shader type: ${e}`);return i}function Ei(e){let t=Ct(e),i=So[t];if(!i)throw new Error(`Unsupported attribute shader type: ${e}`);let[n,r]=i,o=n==="i32"||n==="u32",a=n!=="u32",s=xo[n]*r;return{primitiveType:n,components:r,byteLength:s,integer:o,signed:a}}var Ee=class{getVariableShaderTypeInfo(t){return Ri(t)}getAttributeShaderTypeInfo(t){return Ei(t)}makeShaderAttributeType(t,i){return wi(t,i)}resolveAttributeShaderTypeAlias(t){return Ct(t)}resolveVariableShaderTypeAlias(t){return Lt(t)}};function wi(e,t){return t===1?e:`vec${t}<${e}>`}function Ct(e){return Ti[e]||e}function Lt(e){return Pi[e]||e}var H=new Ee,xo={f32:4,f16:2,i32:4,u32:4},So={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]},Io={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}},Ti={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>"},Pi={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>"};var yo=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;function Di(e=[],t){let i={modules:[],defines:{},injections:{},vertexInputs:{},interStageVariables:{}};for(let o of e)Co(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 Fi(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 Co(e,t,i){t.module&&e.modules.push(t.module),t.defines&&Object.assign(e.defines,t.defines);for(let[n,r]of Object.entries(t.vertexInputs||{})){Ni(n,"vertex input");let o=e.vertexInputs[n];if(o&&o!==r)throw new Error(`ShaderPlugin vertex input "${n}" has conflicting types "${o}" and "${r}"`);e.vertexInputs[n]=r}for(let[n,r]of Object.entries(t.interStageVariables||{})){Ni(n,"varying");let o=Lo(n,r),a=e.interStageVariables[n];if(a&&(a.type!==o.type||a.interpolation!==o.interpolation))throw new Error(`ShaderPlugin varying "${n}" has conflicting declarations "${a.type}/${a.interpolation}" and "${o.type}/${o.interpolation}"`);e.interStageVariables[n]=o}for(let n of t.injections||[]){let r=n[i];if(r===void 0)continue;Ao(n.target),e.injections[n.target]||(e.injections[n.target]=[]),e.injections[n.target].push({pluginName:t.name,injection:r,order:n.order??0})}}function Ni(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 Lo(e,t){let{primitiveType:i}=H.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 Ao(e){if(!yo.test(e))throw new Error(`ShaderPlugin injection target "${e}" must be a named shader anchor or hook`)}var Mo=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Ro=/((?: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 we(e){return`${e.name}Uniforms`}function At(e,t){let i=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!i)return null;let n=we(e);return Eo(i,t==="wgsl"?"wgsl":"glsl",n)}function Mt(e,t){let i=Object.keys(e.uniformTypes||{});if(!i.length)return null;let n=At(e,t);return n?{moduleName:e.name,uniformBlockName:we(e),stage:t,expectedUniformNames:i,actualUniformNames:n,matches:Po(i,n)}:null}function Te(e,t,i={}){let n=Mt(e,t);if(!n||n.matches)return n;let r=No(n);return i.log?.error?.(r,n)(),i.throwOnError!==!1&&P(!1,r),n}function Pe(e){let t=[],i=Do(e);for(let n of i.matchAll(Ro)){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 Ne(e,t,i,n){let r=Pe(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 ${Fo(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 Eo(e,t,i){let n=t==="wgsl"?wo(e,i):To(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(
|
|
34
|
+
`;switch(s){case"vs:#decl":(r==="wgsl"||a)&&(e=e.replace(me,c));break;case"vs:#main-start":(r==="wgsl"||a)&&(e=r==="wgsl"?Te(e,"vertex",c,"start",o.vertex):e.replace(Ii,f=>f+c));break;case"vs:#main-end":(r==="wgsl"||a)&&(e=r==="wgsl"?Te(e,"vertex",c,"end",o.vertex):e.replace(Ci,f=>c+f));break;case"fs:#decl":(r==="wgsl"||!a)&&(e=e.replace(me,c));break;case"fs:#main-start":(r==="wgsl"||!a)&&(e=r==="wgsl"?Te(e,"fragment",c,"start",o.fragment):e.replace(Ii,f=>f+c));break;case"fs:#main-end":(r==="wgsl"||!a)&&(e=r==="wgsl"?Te(e,"fragment",c,"end",o.fragment):e.replace(Ci,f=>c+f));break;default:e=e.replace(s,f=>f+c)}}return e=e.replace(me,""),n&&(e=e.replace(/\}\s*$/,s=>s+ho[t])),e}function Li(e){let t={};return N(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 Te(e,t,i,n,r){let o=_o(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 _o(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+${vo(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 vo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ai(e){let t=Lt(e),i=So[t];if(!i)throw new Error(`Unsupported variable shader type: ${e}`);return i}function Mi(e){let t=Ct(e),i=xo[t];if(!i)throw new Error(`Unsupported attribute shader type: ${e}`);let[n,r]=i,o=n==="i32"||n==="u32",a=n!=="u32",s=bo[n]*r;return{primitiveType:n,components:r,byteLength:s,integer:o,signed:a}}var Pe=class{getVariableShaderTypeInfo(t){return Ai(t)}getAttributeShaderTypeInfo(t){return Mi(t)}makeShaderAttributeType(t,i){return Ri(t,i)}resolveAttributeShaderTypeAlias(t){return Ct(t)}resolveVariableShaderTypeAlias(t){return Lt(t)}};function Ri(e,t){return t===1?e:`vec${t}<${e}>`}function Ct(e){return Ei[e]||e}function Lt(e){return wi[e]||e}var H=new Pe,bo={f32:4,f16:2,i32:4,u32:4},xo={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]},So={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}},Ei={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>"},wi={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 Pi(e=[],t){let i={modules:[],hooks:[],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 Ni(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||{})){Ti(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||{})){Ti(o,"varying");let s=Io(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.hooks||[]){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 hook ${s}`);let l=e.hooks.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 hook ${s}`);l||e.hooks.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=Co(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=ae(n,i,t.name);for(let[o,a]of Object.entries(r))e.injections[o]||=[],e.injections[o].push(...a)}function Ti(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 Io(e,t){let{primitiveType:i}=H.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 Co(e,t){let i=/^(glsl|wgsl):([\s\S]+)$/.exec(e);return i?i[1]===t?i[2]:void 0:e}var Lo=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Ao=/((?: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 At(e,t){let i=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!i)return null;let n=Ne(e);return Mo(i,t==="wgsl"?"wgsl":"glsl",n)}function Mt(e,t){let i=Object.keys(e.uniformTypes||{});if(!i.length)return null;let n=At(e,t);return n?{moduleName:e.name,uniformBlockName:Ne(e),stage:t,expectedUniformNames:i,actualUniformNames:n,matches:wo(i,n)}:null}function Fe(e,t,i={}){let n=Mt(e,t);if(!n||n.matches)return n;let r=To(n);return i.log?.error?.(r,n)(),i.throwOnError!==!1&&N(!1,r),n}function De(e){let t=[],i=Po(e);for(let n of i.matchAll(Ao)){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=De(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 ${No(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 Mo(e,t,i){let n=t==="wgsl"?Ro(e,i):Eo(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(Lo);s&&r.push(s[1])}return r}function Ro(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 Eo(e,t){return De(e).find(n=>n.blockName===t)?.body||null}function wo(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 To(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=Fo(t,i);return a&&o.push(a),n.length&&o.push(`Missing from shader block (${n.length}): ${Fi(n)}.`),r.length&&o.push(`Unexpected in shader block (${r.length}): ${Fi(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 Po(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function No(e){return e.replace(/\s+/g," ").trim()}function Fo(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 Fi(e,t=8){if(e.length<=t)return e.join(", ");let i=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${i} more)`}var Di=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${O}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${O}\\s*:\\s*([^;]+);`,"g")];function Ui(e,t=[]){let i=z(e),n=new Map;for(let o of t)n.set(Oi(o.name,o.group,o.location),o.moduleName);let r=[];for(let o of Di){o.lastIndex=0;let a;for(a=o.exec(i);a;){let s=o===Di[0],l=Number(a[s?1:2]),c=Number(a[s?2:1]),f=a[3]?.trim(),u=a[4],p=a[5].trim(),d=n.get(Oi(u,c,l));r.push(Do({name:u,group:c,binding:l,owner:d?"module":"application",moduleName:d,accessDeclaration:f,resourceType:p})),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 Do(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:Bo(e.resourceType),viewDimension:Bi(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:Bi(e.resourceType),sampleType:Oo(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function Oi(e,t,i){return`${t}:${i}:${e}`}function Bi(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 Oo(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 Bo(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var he=`
|
|
38
38
|
|
|
39
|
-
${
|
|
40
|
-
`;function
|
|
39
|
+
${me}
|
|
40
|
+
`;function Be(e){return function(i){let n={};for(let r of e){let o=r.getUniforms?.(i,n);Object.assign(n,o)}return n}}function le(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 Z(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:N(!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} ---------------
|
|
41
41
|
|
|
42
42
|
`;return t!=="wgsl"&&(o+=`#define MODULE_${r}
|
|
43
43
|
`),o+=`${n}
|
|
44
|
-
`,o}var X="([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
45
|
-
`),n=[],r=[],o=!0;for(let a of i){let s=a.match(
|
|
46
|
-
`)}function
|
|
47
|
-
`)}function
|
|
44
|
+
`,o}var X="([a-zA-Z_][a-zA-Z0-9_]*)",Uo=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,ko=new RegExp(`^\\s*\\#\\s*ifdef\\s*${X}\\s*$`),Go=new RegExp(`^\\s*\\#\\s*ifndef\\s*${X}\\s*(?:\\/\\/.*)?$`),zo=/^\s*\#\s*else\s*(?:\/\/.*)?$/,Vo=/^\s*\#\s*endif\s*$/,Ho=new RegExp(`^\\s*\\#\\s*ifdef\\s*${X}\\s*(?:\\/\\/.*)?$`),Wo=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function W(e,t){let i=e.split(`
|
|
45
|
+
`),n=[],r=[],o=!0;for(let a of i){let s=a.match(Uo),l=a.match(Ho)||a.match(ko),c=a.match(Go),f=a.match(zo),u=a.match(Wo)||a.match(Vo);if(s){let p=qo(s[1],t?.defines||{}),d=o&&p;r.push({parentActive:o,branchTaken:p,active:d}),o=d}else if(l||c){let p=(l||c)?.[1],d=!!t?.defines?.[p],h=l?d:!d,m=o&&h;r.push({parentActive:o,branchTaken:h,active:m}),o=m}else if(f){let p=r[r.length-1];if(!p)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");p.active=p.parentActive&&!p.branchTaken,p.branchTaken=!0,o=p.active}else u?(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(`
|
|
46
|
+
`)}function qo(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=p=>/^[A-Za-z_]/.test(p)?Number(t[p]??0):Number(p),f=c(r[1]),u=c(r[3]);switch(r[2]){case"==":return f===u;case"!=":return f!==u;case"<=":return f<=u;case">=":return f>=u;case"<":return f<u;case">":return f>u}}let o=i.match(new RegExp(`^!\\s*${X}$`));if(o)return!t[o[1]];let a=i.match(new RegExp(`^${X}$`));if(a)return!!t[a[1]];let s=i.match(new RegExp(`^defined\\s*\\(\\s*${X}\\s*\\)$`));if(s)return t[s[1]]!==void 0;let l=i.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${X}\\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))jo(e,n),i.push(`in ${Ue(r)} ${n};`);return i.join(`
|
|
47
|
+
`)}function Vi(e,t,i){let n=Object.entries(i);if(n.length===0)return{source:e,declarations:"",initialization:""};let r=$o(e,t),o=e.slice(r.openParenthesis+1,r.closeParenthesis),a=Ko(e,o),s=new Set(a.locations),l=[],c=[],f=[];for(let[m,x]of n){if(a.names.has(m)||Xo(e,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let y=Jo(s);s.add(y);let S=`_luma_${m}`;l.push(`@location(${y}) ${S}: ${x}`),c.push(`var<private> ${m}: ${x};`),f.push(`${m} = ${S};`)}let u=o.trim()?`,
|
|
48
48
|
`:`
|
|
49
49
|
`,p=o.trim()?"":`
|
|
50
50
|
`,d=`${o}${u}${l.join(`,
|
|
51
51
|
`)}${p}`;return{source:e.slice(0,r.openParenthesis+1)+d+e.slice(r.closeParenthesis),declarations:c.join(`
|
|
52
52
|
`),initialization:f.join(`
|
|
53
|
-
`)}}function
|
|
54
|
-
`&&(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
|
|
55
|
-
`&&(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
|
|
53
|
+
`)}}function Ue(e){let{primitiveType:t,components:i}=H.getAttributeShaderTypeInfo(e),n=t==="i32"?"int":t==="u32"?"uint":"float";return i===1?n:`${n==="int"?"i":n==="uint"?"u":""}vec${i}`}function jo(e,t){let i=ke(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 $o(e,t){let n=new RegExp(`\\bfn\\s+${ke(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=Hi(e,r,"(",")");if(o<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:r,closeParenthesis:o}}function Ko(e,t){let i=ki(t),n=new Set(Gi(t)),r=Yo(t);for(let o of r){let a=Zo(e,o);if(a!==null){i.push(...ki(a));for(let s of Gi(a))n.add(s)}}return{locations:i,names:n}}function ki(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 Gi(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 Yo(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 Zo(e,t){let n=new RegExp(`\\bstruct\\s+${ke(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=Hi(e,r,"{","}");return o<0?null:e.slice(r+1,o)}function Xo(e,t){let i=ke(t),n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${i}\\b`,"g"),r=n.exec(e);for(;r;){if(Qo(e,r.index)===0)return!0;r=n.exec(e)}return!1}function Jo(e){let t=0;for(;e.has(t);)t++;return t}function Hi(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===`
|
|
54
|
+
`&&(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 Qo(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===`
|
|
55
|
+
`&&(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 ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,i){let n=[],r=[];for(let[o,a]of Object.entries(i)){pa(e,o);let s=a.interpolation==="flat"?"flat ":"",l=t==="vertex"?"out":"in";n.push(`${s}${l} ${Ue(a.type)} ${o};`),t==="vertex"&&r.push(`${o} = ${fa(a.type)};`)}return{declarations:n.join(`
|
|
56
56
|
`),initialization:r.join(`
|
|
57
|
-
`)}}function
|
|
57
|
+
`)}}function qi(e,t,i,n){let r=Object.entries(n);if(r.length===0)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let o=e,a=Ge(o,t,"vertex"),s=ea(o,a),l=Ge(o,i,"fragment"),c=ta(o,l),f=Rt(o,s),u=c?Rt(o,c.type):null,p=new Set([...ze(a.parameters),...ze(f.body),...ze(l.parameters),...ze(u?.body||"")]),d=new Set([...Et(f.body),...Et(u?.body||""),...Et(l.parameters)]),h=[],m=[],x=[],y=[],S=[];for(let[g,v]of r){if(p.has(g)||la(o,g))throw new Error(`ShaderPlugin varying "${g}" conflicts with existing WGSL stage I/O or a module variable`);let A=ca(d);d.add(A);let C=v.interpolation==="flat"?" @interpolate(flat)":"";if(h.push(` @location(${A})${C} ${g}: ${v.type},`),x.push(`var<private> ${g}: ${v.type};`),y.push(`${g} = ${ua(v.type)};`),c)S.push(`${g} = ${c.name}.${g};`);else{let R=`_luma_${g}`;if(p.has(R))throw new Error(`ShaderPlugin varying "${g}" conflicts with a generated fragment parameter`);m.push(`@location(${A})${C} ${R}: ${v.type}`),S.push(`${g} = ${R};`)}}ia(o,s,a.openBrace,a.closeBrace),o=na(o,s,a,r.map(([g])=>g)),a=Ge(o,t,"vertex"),o=ra(o,a,r.map(([g])=>g));let _=(!c||s===c.type?[s]:[s,c.type]).map(g=>Rt(o,g).closeBrace).sort((g,v)=>v-g);for(let g of _)o=o.slice(0,g)+`${h.join(`
|
|
58
58
|
`)}
|
|
59
|
-
`+o.slice(g);if(l=
|
|
59
|
+
`+o.slice(g);if(l=Ge(o,i,"fragment"),m.length){let g=l.parameters,v=z(g).trimEnd();if(v.trim()&&!v.endsWith(",")){let A=v.length;g=`${g.slice(0,A)},${g.slice(A)}`}o=o.slice(0,l.openParenthesis+1)+g+`
|
|
60
60
|
`+m.join(`,
|
|
61
61
|
`)+`
|
|
62
62
|
`+o.slice(l.closeParenthesis)}return{source:o,declarations:x.join(`
|
|
63
|
-
`),vertexInitialization:
|
|
63
|
+
`),vertexInitialization:y.join(`
|
|
64
64
|
`),fragmentInitialization:S.join(`
|
|
65
|
-
`)}}function
|
|
65
|
+
`)}}function Ge(e,t,i){let r=new RegExp(`\\bfn\\s+${ce(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=Ve(e,o,"(",")"),s=e.indexOf("{",a),l=Ve(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 ea(e,t){let i=e.slice(t.closeParenthesis+1,t.openBrace),n=/->\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());if(!n||wt(e,n[1])===null)throw new Error("ShaderPlugin interStageVariables require the WGSL vertex entry point to return a named struct");return n[1]}function ta(e,t){let i=[];for(let n of sa(z(t.parameters),",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(n.trim());r&&wt(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 Rt(e,t){let i=wt(e,t);if(!i)throw new Error(`Unable to find WGSL stage I/O struct "${t}"`);return i}function wt(e,t){let n=new RegExp(`\\bstruct\\s+${ce(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=Ve(e,r,"{","}");return o<0?null:{openBrace:r,closeBrace:o,body:e.slice(r+1,o)}}function ia(e,t,i,n){let r=new RegExp(`\\b${ce(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 na(e,t,i,n){let r=new RegExp(`\\b${ce(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=Ve(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 ra(e,t,i){let n=oa(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(`
|
|
66
66
|
`),c=`{
|
|
67
67
|
var ${s} = ${a};
|
|
68
68
|
${l}
|
|
69
69
|
return ${s};
|
|
70
|
-
}`;e=e.slice(0,o.start)+c+e.slice(o.semicolon+1)}return e}function
|
|
71
|
-
`,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
|
|
72
|
-
`&&(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
|
|
73
|
-
`,o.header&&(n+=` ${o.header}`),t[r]){let
|
|
70
|
+
}`;e=e.slice(0,o.start)+c+e.slice(o.semicolon+1)}return e}function oa(e,t,i){let n=[],r=t;for(;r<i;)if(r=Tt(e,r,i),e.slice(r,r+6)==="return"&&!/[A-Za-z0-9_]/.test(e[r+6]||"")){let o=r+6,a=aa(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 aa(e,t,i){let n=0,r=0;for(let o=t;o<i;o++){let a=Tt(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 Tt(e,t,i){let n=t;if(e[n]==="/"&&e[n+1]==="/"){let r=e.indexOf(`
|
|
71
|
+
`,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 sa(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 Et(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 ze(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 la(e,t){let i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${ce(t)}\\b`,"g"),n=i.exec(e);for(;n;){if(da(e,n.index)===0)return!0;n=i.exec(e)}return!1}function ca(e){let t=0;for(;e.has(t);)t++;return t}function fa(e){let{primitiveType:t,components:i}=H.getAttributeShaderTypeInfo(e),n=t==="u32"?"0u":t==="i32"?"0":"0.0";return i===1?n:`${Ue(e)}(${n})`}function ua(e){let{primitiveType:t,components:i}=H.getAttributeShaderTypeInfo(e),n=`${t}(0)`;return i===1?n:`${e}(${n})`}function pa(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+${ce(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function Ve(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===`
|
|
72
|
+
`&&(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 da(e,t){let i=0;for(let n=0;n<t;n++){let r=Tt(e,n,t);if(r!==n){n=r-1;continue}e[n]==="{"&&i++,e[n]==="}"&&i--}return i}function ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _e(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} {
|
|
73
|
+
`,o.header&&(n+=` ${o.header}`),t[r]){let c=t[r];c.sort((f,u)=>f.order-u.order);for(let f of c)n+=` ${f.injection}
|
|
74
74
|
`}o.footer&&(n+=` ${o.footer}`),n+=`}
|
|
75
|
-
`}return n}function
|
|
75
|
+
`}return n}function ve(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=ve([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 hook ${s}`);n[a][s]=c||l}}return n}function ga(e,t){return!!(t.startsWith("vs:")?e.vertex:e.fragment)[t]}function He(e,t,i){let n=i==="vertex"?"vs:":i==="fragment"?"fs:":null;for(let r in t)if(!(n&&!r.startsWith(n))&&!ga(e,r)){let o=[...new Set(t[r].map(a=>a.pluginName).filter(Boolean))];throw new Error(`Unknown shader hook ${r}${o.length?` (plugins: ${o.join(", ")})`:""}`)}}var be=100;function $i(e){let t=k(e.modules||[]),{source:i,bindingAssignments:n}=ma(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:i,getUniforms:Be(t),bindingAssignments:n}}function ma(e,t){let{source:i,stage:n,modules:r,defines:o={},hookFunctions:a=[],inject:s={},pluginInjections:l={},pluginVertexInputs:c={},pluginInterStageVariables:f={},vertexEntryPoint:u="vertexMain",fragmentEntryPoint:p="fragmentMain",log:d}=t;N(typeof i=="string","shader source must be a string");let h=W(i,{defines:o}),m=Vi(h,u,c),x=qi(m.source,u,p,f),y=x.source,S="",b=ve(a,t.pluginHooks,"wgsl"),_={},g={},v={};le(l,_,g,v);let A=Array.isArray(s)?ae(s,"wgsl"):{};le(A,_,g,v);let C=Array.isArray(s)?{}:s;for(let M in C){let U=typeof C[M]=="string"?{injection:C[M],order:0}:C[M],ne=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(ne){let Hr=ne[2],Wr=ne[3];Hr?Wr==="decl"?g[M]=[...g[M]||[],U]:v[M]=[...v[M]||[],U]:_[M]=[..._[M]||[],U]}else v[M]=[...v[M]||[],U]}ha(m.declarations,m.initialization,g,v),_a(x,g,v),He(b,_);let R=r.map(M=>({module:M,source:W(Z(M,"wgsl",d),{defines:o})})),w=Sa(y),P=xa(w.source),I=La(R,t._bindingRegistry,P),E=[],L=R.map(({module:M,source:U})=>{let ne=ya(U,M,{usedBindingsByGroup:P,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:I});return E.push(...ne.bindingAssignments),{module:M,source:ne.source}});for(let{module:M,source:U}of L)d&&oe(M,y,d),S+=U;return S+=he,S=se(S,n,va(g),!1,"wgsl",{vertex:u,fragment:p}),S+=ba(b,_),S+=Ea(E),S+=w.source,S=se(S,n,v,!1,"wgsl",{vertex:u,fragment:p}),Ra(S),{source:S,bindingAssignments:E}}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 _a(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 va(e){let t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}function ba(e,t){return _e(e.vertex,t,"wgsl")+_e(e.fragment,t,"wgsl")}function xa(e){let t=new Map;for(let i of K(e,ci)){let n=Number(i.bindingToken),r=Number(i.groupToken);Nt(r,n,i.name),fe(t,r,n,`application binding "${i.name}"`)}return t}function Sa(e){let t=K(e,Ae),i=new Map;for(let o of t){if(o.bindingToken==="auto")continue;let a=Number(o.bindingToken),s=Number(o.groupToken);Nt(s,a,o.name),fe(i,s,a,`application binding "${o.name}"`)}let n={sawSupportedBindingDeclaration:t.length>0},r=ht(e,Ae,o=>Ca(o,i,n));if(_t(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:K(e,re).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},a=ht(e,re,s=>Ia(s,{module:t,context:i,bindingAssignments:n,relocationState:o}));if(_t(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 Ia(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 d=We(f,i.name,c),h=n.bindingRegistry?.get(d),m=h!==void 0?h:Aa(f,n.usedBindingsByGroup,i.name,o.nextHintedBindingLocation??void 0,n.bindingRegistry);return Pt(i.name,f,m,c),h!==void 0&&ji(n.reservedBindingKeysByGroup,f,m,d)?(r.push({moduleName:i.name,name:c,group:f,location:m}),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(fe(n.usedBindingsByGroup,f,m,`module "${i.name}" binding "${c}"`),n.bindingRegistry?.set(d,m),r.push({moduleName:i.name,name:c,group:f,location:m}),o.nextHintedBindingLocation!==null&&h===void 0&&(o.nextHintedBindingLocation=m+1),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}let u=Number(s);Pt(i.name,f,u,c);let p=We(f,i.name,c);return ji(n.reservedBindingKeysByGroup,f,u,p)||fe(n.usedBindingsByGroup,f,u,`module "${i.name}" binding "${c}"`),r.push({moduleName:i.name,name:c,group:f,location:u}),a}function Ca(e,t,i){let{match:n,bindingToken:r,groupToken:o,name:a}=e,s=Number(o);if(r==="auto"){let l=Ma(s,t);return Nt(s,l,a),fe(t,s,l,`application binding "${a}"`),n.replace(/@binding\(\s*auto\s*\)/,`@binding(${l})`)}return i.sawSupportedBindingDeclaration=!0,n}function La(e,t,i){let n=new Map,r=[];function o(a,s,l,c){fe(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 K(s,re)){let c=Number(l.groupToken);if(l.bindingToken==="auto"){r.push({module:a,name:l.name,group:c});continue}let f=Number(l.bindingToken);Pt(a.name,c,f,l.name),o(c,f,We(c,a.name,l.name),`module "${a.name}" binding "${l.name}"`)}for(let{module:a,name:s,group:l}of r){let c=We(l,a.name,s),f=t?.get(c);f!==void 0&&o(l,f,c,`registered module binding "${c}"`)}return n}function ji(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 Nt(e,t,i){if(e===0&&t>=be)throw new Error(`Application binding "${i}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${be}.`)}function Pt(e,t,i,n){if(t===0&&i<be)throw new Error(`Module "${e}" binding "${n}" in group 0 uses reserved application binding ${i}. Module-owned explicit group-0 bindings must be ${be} or higher.`)}function fe(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 Aa(e,t,i,n,r){let o=t.get(e)||new Set,a=new Set,s=`${e}:`,l=`${s}${i}:`;for(let[f,u]of r||[])f.startsWith(l)&&a.add(u);let c=n??(e===0?be:o.size>0?Math.max(...o)+1:0);for(;o.has(c)||a.has(c);)c++;for(let[f,u]of r||[])u===c&&f.startsWith(s)&&r?.delete(f);return c}function Ma(e,t){let i=t.get(e)||new Set,n=0;for(;i.has(n);)n++;return n}function Ra(e){let t=fi(e,re);if(!t)return;let i=wa(e,t.index);throw i?new Error(`Unresolved @binding(auto) for module "${i}" binding "${t.name}" remained in assembled WGSL source.`):Ta(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 "${Pa(t.match)}".`)}function Ea(e){if(e.length===0)return"";let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
|
76
76
|
`;for(let i of e)t+=`// ${i.moduleName}.${i.name} -> @group(${i.group}) @binding(${i.location})
|
|
77
77
|
`;return t+=`
|
|
78
|
-
`,t}function
|
|
78
|
+
`,t}function We(e,t,i){return`${e}:${t}:${i}`}function wa(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 Ta(e,t){let i=e.indexOf(he);return i>=0?t>i:!0}function Pa(e){return e.replace(/\s+/g," ").trim()}function qe(e,t){return{name:Na(e,t),language:"glsl",version:Fa(e)}}function Na(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 Fa(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 Ki(e){switch(e?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
79
79
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
80
80
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
81
81
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -99,40 +99,40 @@ return ${s};
|
|
|
99
99
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
100
100
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
101
101
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
102
|
-
`}}function
|
|
103
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
104
|
-
`;function
|
|
102
|
+
`}}function Zi(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=Yi(e,Da),e;case"fragment":return e=Yi(e,Oa),e;default:throw new Error(t)}}var Xi=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
103
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Da=[...Xi,[Ft("attribute"),"in $1"],[Ft("varying"),"out $1"]],Oa=[...Xi,[Ft("varying"),"in $1"]];function Yi(e,t){for(let[i,n]of t)e=e.replace(i,n);return e}function Ft(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var Ba=`precision highp float;
|
|
104
|
+
`;function xe(e){let{vs:t,fs:i}=e,n=k(e.modules||[]);return{vs:Ji(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:Ji(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:Be(n)}}function Ji(e,t){let{source:i,stage:n,language:r="glsl",modules:o,defines:a={},hookFunctions:s=[],inject:l={},pluginInjections:c={},pluginVertexInputs:f={},pluginInterStageVariables:u={},prologue:p=!0,log:d}=t;N(typeof i=="string","shader source must be a string");let h=r==="glsl"?qe(i).version:-1,m=e.shaderLanguageVersion,x=h===100?"#version 100":"#version 300 es",S=i.split(`
|
|
105
105
|
`).slice(1).join(`
|
|
106
|
-
`),b={};o.forEach(
|
|
106
|
+
`),b={};o.forEach(I=>{Object.assign(b,I.defines)}),Object.assign(b,a);let _="";switch(r){case"wgsl":break;case"glsl":_=p?`${x}
|
|
107
107
|
|
|
108
108
|
// ----- PROLOGUE -------------------------
|
|
109
109
|
${`#define SHADER_TYPE_${n.toUpperCase()}`}
|
|
110
110
|
|
|
111
|
-
${
|
|
112
|
-
${n==="fragment"?
|
|
111
|
+
${Ki(e)}
|
|
112
|
+
${n==="fragment"?Ba:""}
|
|
113
113
|
|
|
114
114
|
// ----- APPLICATION DEFINES -------------------------
|
|
115
115
|
|
|
116
|
-
${
|
|
116
|
+
${Ua(b)}
|
|
117
117
|
|
|
118
118
|
`:`${x}
|
|
119
|
-
`;break}let g=
|
|
120
|
-
`)}let
|
|
121
|
-
`),
|
|
122
|
-
`)}return t}var V=class{_shaderTranspilers=new Map;_hookFunctions=[];_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
|
|
119
|
+
`;break}let g=ve(s,t.pluginHooks,"glsl"),v={},A={},C={};le(c,v,A,C);let R=Array.isArray(l)?ae(l,"glsl"):{};le(R,v,A,C);let w=Array.isArray(l)?{}:l;for(let I in w){let E=typeof w[I]=="string"?{injection:w[I],order:0}:w[I],L=/^(v|f)s:(#)?([\w-]+)$/.exec(I);if(L){let M=L[2],U=L[3];M?U==="decl"?A[I]=[...A[I]||[],E]:C[I]=[...C[I]||[],E]:v[I]=[...v[I]||[],E]}else C[I]=[...C[I]||[],E]}if(n==="vertex"){let I=zi(S,f);I&&(_+=`${I}
|
|
120
|
+
`)}let P=Wi(S,n,u);P.declarations&&(_+=`${P.declarations}
|
|
121
|
+
`),P.initialization&&(C["vs:#main-start"]=C["vs:#main-start"]||[],C["vs:#main-start"].push({injection:P.initialization,order:Number.MIN_SAFE_INTEGER}));for(let I of o){d&&oe(I,S,d);let E=Z(I,n,d);_+=E}return He(g,v,n),_+="// ----- MAIN SHADER SOURCE -------------------------",_+=he,_=se(_,n,A),_+=_e(g[n],v),_+=S,_=se(_,n,C),r==="glsl"&&h!==m&&(_=Zi(_,n)),r==="glsl"&&Oe(_,n,d),_.trim()}function Ua(e={}){let t="";for(let i in e){let n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}
|
|
122
|
+
`)}return t}var V=class{_shaderTranspilers=new Map;_hookFunctions=[];_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 N(!k(i).some(p=>p.sourceLanguage&&p.sourceLanguage!==this.shaderLanguage)),{code:n||"",modules:i};let a=this._shaderTranspilers.get(o);N(a);let s=k(i);N(!s.some(p=>p.sourceLanguage&&p.sourceLanguage!==o&&p.sourceLanguage!==this.shaderLanguage));let l=s.filter(p=>p.sourceLanguage===o).map(p=>p.source||"").join(`
|
|
123
123
|
`),c={vertex:t.vertexEntryPoint,fragment:t.fragmentEntryPoint,compute:t.computeEntryPoint},f=n==null?{code:""}:a.transpile({source:[l,n].filter(Boolean).join(`
|
|
124
|
-
`),target:this.shaderLanguage,stage:r,entryPoints:c,platformInfo:t.platformInfo}),u=s.map(p=>({...p,dependencies:void 0,...p.sourceLanguage===o?{source:void 0,vs:void 0,fs:void 0}:{}}));return{...f,modules:u}}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)}addShaderHook(t
|
|
124
|
+
`),target:this.shaderLanguage,stage:r,entryPoints:c,platformInfo:t.platformInfo}),u=s.map(p=>({...p,dependencies:void 0,...p.sourceLanguage===o?{source:void 0,vs:void 0,fs:void 0}:{}}));return{...f,modules:u}}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)}addShaderHook(t){this._hookFunctions.push(t)}resetShaderHooks(){this._hookFunctions.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,Y(i),i}};var Se=class extends V{shaderLanguage="glsl";assembleGLSLShaderPair(t){let i=this._getModuleList(t.modules),n=[...this._hookFunctions,...t.hookFunctions||[]],r=this._transpileShader(t,i,t.vs,"vertex"),o=this._transpileShader(t,i,t.fs,"fragment");return{...xe({...t,vs:r.code,fs:t.fs==null?void 0:o.code,modules:r.modules,hookFunctions:n}),modules:i}}};var ye=class e extends V{shaderLanguage="wgsl";_wgslBindingRegistry=new Map;assembleWGSLShader(t){let i=this._getModuleList(t.modules),n=[...this._hookFunctions,...t.hookFunctions||[]],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?W(r.code,{defines:a}):r.code,{source:l,getUniforms:c,bindingAssignments:f}=$i({...t,source:s,vertexEntryPoint:o.vertex,fragmentEntryPoint:o.fragment,defines:a,_bindingRegistry:this._wgslBindingRegistry,modules:r.modules,hookFunctions:n}),u=t.platformInfo.shaderLanguage==="wgsl"?W(l,{defines:a}):l;return{source:u,entryPoints:o,getUniforms:c,modules:i,bindingAssignments:f,bindingTable:Ui(u,f),shaderLayout:Re(u,{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 ka=`out vec4 transform_output;
|
|
125
125
|
void main() {
|
|
126
126
|
transform_output = vec4(0);
|
|
127
|
-
}`,
|
|
128
|
-
${
|
|
127
|
+
}`,Ga=`#version 300 es
|
|
128
|
+
${ka}`;function Qi(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 en(e){let{input:t,inputChannels:i,output:n}=e||{};if(!t)return Ga;if(!i)throw new Error("inputChannels");let r=za(i),o=Dt(t,i);return`#version 300 es
|
|
129
129
|
in ${r} ${t};
|
|
130
130
|
out vec4 ${n};
|
|
131
131
|
void main() {
|
|
132
132
|
${n} = ${o};
|
|
133
|
-
}`}function
|
|
134
|
-
`)}function
|
|
135
|
-
`)}function ln(e,t){switch(t.shaderLanguage){case"glsl":return an(e,t);case"wgsl":return sn(e,t)}}var kc=1/Math.PI*180,Gc=1/180*Math.PI,Ka={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Ka}};var F=globalThis.mathgl.config;function Bt(e,{precision:t=F.precision}={}){return e=Ya(e),`${parseFloat(e.toPrecision(t))}`}function le(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ut(e,t,i){return Xa(e,n=>Math.max(t,Math.min(i,n)))}function qe(e,t,i){let n=F.EPSILON;i&&(F.EPSILON=i);try{if(e===t)return!0;if(le(e)&&le(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!qe(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)<=F.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{F.EPSILON=n}}function Ya(e){return Math.round(e/F.EPSILON)*F.EPSILON}function Za(e){return e.clone?e.clone():new Array(e.length)}function Xa(e,t,i){if(le(e)){let n=e;i=i||Za(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 je=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:le(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(F)}formatString(t){let i="";for(let n=0;n<this.ELEMENTS;++n)i+=(n>0?", ":"")+Bt(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(!qe(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(F.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 Ja(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 cn(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function $e(e,t,i=""){if(F.debug&&!Ja(e,t))throw new Error(`math.gl: ${i} some fields set to invalid numbers'`);return e}var Ke=class extends je{toString(){let t="[";if(F.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]=cn(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 fn(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 un(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 pn(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 dn(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 Qa(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 gn(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 mn(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],u=t[9],p=t[10],d=t[11],v=t[12],m=t[13],x=t[14],I=t[15],S=i*s-n*a,b=i*l-r*a,h=i*c-o*a,g=n*l-r*s,_=n*c-o*s,M=r*c-o*l,A=f*m-u*v,R=f*x-p*v,L=f*I-d*v,E=u*x-p*m,w=u*I-d*m,y=p*I-d*x,C=S*y-b*w+h*E+g*L-_*R+M*A;return C?(C=1/C,e[0]=(s*y-l*w+c*E)*C,e[1]=(r*w-n*y-o*E)*C,e[2]=(m*M-x*_+I*g)*C,e[3]=(p*_-u*M-d*g)*C,e[4]=(l*L-a*y-c*R)*C,e[5]=(i*y-r*L+o*R)*C,e[6]=(x*h-v*M-I*b)*C,e[7]=(f*M-p*h+d*b)*C,e[8]=(a*w-s*L+c*A)*C,e[9]=(n*L-i*w-o*A)*C,e[10]=(v*_-m*h+I*S)*C,e[11]=(u*h-f*_-d*S)*C,e[12]=(s*R-a*E-l*A)*C,e[13]=(i*E-n*R+r*A)*C,e[14]=(m*b-v*g-x*S)*C,e[15]=(f*g-u*b+p*S)*C,e):null}function hn(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],u=e[10],p=e[11],d=e[12],v=e[13],m=e[14],x=e[15],I=t*a-i*o,S=t*s-n*o,b=i*s-n*a,h=c*v-f*d,g=c*m-u*d,_=f*m-u*v,M=t*_-i*g+n*h,A=o*_-a*g+s*h,R=c*b-f*S+u*I,L=d*b-v*S+m*I;return l*M-r*A+x*R-p*L}function Gt(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],u=t[8],p=t[9],d=t[10],v=t[11],m=t[12],x=t[13],I=t[14],S=t[15],b=i[0],h=i[1],g=i[2],_=i[3];return e[0]=b*n+h*s+g*u+_*m,e[1]=b*r+h*l+g*p+_*x,e[2]=b*o+h*c+g*d+_*I,e[3]=b*a+h*f+g*v+_*S,b=i[4],h=i[5],g=i[6],_=i[7],e[4]=b*n+h*s+g*u+_*m,e[5]=b*r+h*l+g*p+_*x,e[6]=b*o+h*c+g*d+_*I,e[7]=b*a+h*f+g*v+_*S,b=i[8],h=i[9],g=i[10],_=i[11],e[8]=b*n+h*s+g*u+_*m,e[9]=b*r+h*l+g*p+_*x,e[10]=b*o+h*c+g*d+_*I,e[11]=b*a+h*f+g*v+_*S,b=i[12],h=i[13],g=i[14],_=i[15],e[12]=b*n+h*s+g*u+_*m,e[13]=b*r+h*l+g*p+_*x,e[14]=b*o+h*c+g*d+_*I,e[15]=b*a+h*f+g*v+_*S,e}function _n(e,t,i){let n=i[0],r=i[1],o=i[2],a,s,l,c,f,u,p,d,v,m,x,I;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],u=t[5],p=t[6],d=t[7],v=t[8],m=t[9],x=t[10],I=t[11],e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=f,e[5]=u,e[6]=p,e[7]=d,e[8]=v,e[9]=m,e[10]=x,e[11]=I,e[12]=a*n+f*r+v*o+t[12],e[13]=s*n+u*r+m*o+t[13],e[14]=l*n+p*r+x*o+t[14],e[15]=c*n+d*r+I*o+t[15]),e}function vn(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 bn(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,u,p,d,v,m,x,I,S,b,h,g,_,M,A,R,L,E,w,y,C,N;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,u=t[0],p=t[1],d=t[2],v=t[3],m=t[4],x=t[5],I=t[6],S=t[7],b=t[8],h=t[9],g=t[10],_=t[11],M=r*r*f+l,A=o*r*f+a*c,R=a*r*f-o*c,L=r*o*f-a*c,E=o*o*f+l,w=a*o*f+r*c,y=r*a*f+o*c,C=o*a*f-r*c,N=a*a*f+l,e[0]=u*M+m*A+b*R,e[1]=p*M+x*A+h*R,e[2]=d*M+I*A+g*R,e[3]=v*M+S*A+_*R,e[4]=u*L+m*E+b*w,e[5]=p*L+x*E+h*w,e[6]=d*L+I*E+g*w,e[7]=v*L+S*E+_*w,e[8]=u*y+m*C+b*N,e[9]=p*y+x*C+h*N,e[10]=d*y+I*C+g*N,e[11]=v*y+S*C+_*N,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function xn(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],u=t[10],p=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+u*n,e[7]=l*r+p*n,e[8]=c*r-o*n,e[9]=f*r-a*n,e[10]=u*r-s*n,e[11]=p*r-l*n,e}function Sn(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],u=t[10],p=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-u*n,e[3]=l*r-p*n,e[8]=o*n+c*r,e[9]=a*n+f*r,e[10]=s*n+u*r,e[11]=l*n+p*r,e}function In(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],u=t[6],p=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+u*n,e[3]=l*r+p*n,e[4]=c*r-o*n,e[5]=f*r-a*n,e[6]=u*r-s*n,e[7]=p*r-l*n,e}function yn(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,u=n*s,p=r*a,d=r*s,v=r*l,m=o*a,x=o*s,I=o*l;return e[0]=1-u-v,e[1]=f+I,e[2]=p-x,e[3]=0,e[4]=f-I,e[5]=1-c-v,e[6]=d+m,e[7]=0,e[8]=p+x,e[9]=d-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Cn(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 es(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 Ln=es;function ts(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 An=ts;function Mn(e,t,i,n){let r,o,a,s,l,c,f,u,p,d,v=t[0],m=t[1],x=t[2],I=n[0],S=n[1],b=n[2],h=i[0],g=i[1],_=i[2];return Math.abs(v-h)<1e-6&&Math.abs(m-g)<1e-6&&Math.abs(x-_)<1e-6?Qa(e):(u=v-h,p=m-g,d=x-_,r=1/Math.sqrt(u*u+p*p+d*d),u*=r,p*=r,d*=r,o=S*d-b*p,a=b*u-I*d,s=I*p-S*u,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=p*s-d*a,c=d*o-u*s,f=u*a-p*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]=u,e[3]=0,e[4]=a,e[5]=c,e[6]=p,e[7]=0,e[8]=s,e[9]=f,e[10]=d,e[11]=0,e[12]=-(o*v+a*m+s*x),e[13]=-(l*v+c*m+f*x),e[14]=-(u*v+p*m+d*x),e[15]=1,e)}function Rn(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 Ht;(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"})(Ht||(Ht={}));var is=45*Math.PI/180,ns=1,zt=.1,Vt=500,rs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends Ke{static get IDENTITY(){return as()}static get ZERO(){return os()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ht}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,u,p,d,v,m,x){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]=u,this[11]=p,this[12]=d,this[13]=v,this[14]=m,this[15]=x,this.check()}setRowMajor(t,i,n,r,o,a,s,l,c,f,u,p,d,v,m,x){return this[0]=t,this[1]=o,this[2]=c,this[3]=d,this[4]=i,this[5]=a,this[6]=f,this[7]=v,this[8]=n,this[9]=s,this[10]=u,this[11]=m,this[12]=r,this[13]=l,this[14]=p,this[15]=x,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(rs)}fromObject(t){return this.check()}fromQuaternion(t){return yn(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=zt,far:s=Vt}=t;return s===1/0?ss(this,i,n,r,o,a):Cn(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 Mn(this,i,n,r),this.check()}ortho(t){let{left:i,right:n,bottom:r,top:o,near:a=zt,far:s=Vt}=t;return An(this,i,n,r,o,a,s),this.check()}orthographic(t){let{fovy:i=is,aspect:n=ns,focalDistance:r=1,near:o=zt,far:a=Vt}=t;En(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 En(i),Ln(this,i,n,r,o),this.check()}determinant(){return hn(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){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let n=this.getScale(i),r=1/n[0],o=1/n[1],a=1/n[2];return t[0]=this[0]*r,t[1]=this[1]*o,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*r,t[5]=this[5]*o,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*r,t[9]=this[9]*o,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,i){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let n=this.getScale(i),r=1/n[0],o=1/n[1],a=1/n[2];return t[0]=this[0]*r,t[1]=this[1]*o,t[2]=this[2]*a,t[3]=this[4]*r,t[4]=this[5]*o,t[5]=this[6]*a,t[6]=this[8]*r,t[7]=this[9]*o,t[8]=this[10]*a,t}transpose(){return gn(this,this),this.check()}invert(){return mn(this,this),this.check()}multiplyLeft(t){return Gt(this,t,this),this.check()}multiplyRight(t){return Gt(this,this,t),this.check()}rotateX(t){return xn(this,this,t),this.check()}rotateY(t){return Sn(this,this,t),this.check()}rotateZ(t){return In(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return bn(this,this,t,i),this.check()}scale(t){return vn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return _n(this,this,t),this.check()}transform(t,i){return t.length===4?(i=Rn(i||[-0,-0,-0,-0],t,this),$e(i,4),i):this.transformAsPoint(t,i)}transformAsPoint(t,i){let{length:n}=t,r;switch(n){case 2:r=fn(i||[-0,-0],t,this);break;case 3:r=dn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $e(r,t.length),r}transformAsVector(t,i){let n;switch(t.length){case 2:n=un(i||[-0,-0],t,this);break;case 3:n=pn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $e(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,i,n){return this.identity().translate([t,i,n])}},Ye,Ze;function os(){return Ye||(Ye=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ye)),Ye}function as(){return Ze||(Ze=new G,Object.freeze(Ze)),Ze}function En(e){if(e>Math.PI*2)throw Error("expected radians")}function ss(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,u=-1,p=-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]=u,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}var Q=null,wn=new ArrayBuffer(4),Tn=new Float32Array(wn),Pn=new Uint32Array(wn);function Nn(e){Q||=Fn(),e=Ut(e,-65504,65504),Tn[0]=e;let t=Pn[0],i=t>>23&511;return Q.baseTable[i]+((t&8388607)>>Q.shiftTable[i])}function Dn(e){Q||=Fn();let t=e>>10;return Pn[0]=Q.mantissaTable[Q.offsetTable[t]+(e&1023)]+Q.exponentTable[t],Tn[0]}function Fn(){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 ce(e,t=[],i=0){let n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function be(e){return e-Math.fround(e)}function xe(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;ce(e[n*4+i],t,r*2)}return t}function ee(e,t=!0){return e??t}function te(e=[0,0,0],t=!0){return t?e.map(i=>i/255):[...e]}function Xe(e,t=!0){let i=te(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 On={width:2,jitter:.7,variation:.35,grain:.45,offset:0,extension:3,sketch:1,minimumAntialias:.7},Bn=`
|
|
133
|
+
}`}function tn(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 nn(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 za(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 Dt(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 J(e){return typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):e}function rn(e,t){return Va(e,t)}function Va(e,t){let i=[];switch(t.uniforms){case"scoped-interface-blocks":case"unscoped-interface-blocks":i.push(`layout(std140) uniform ${J(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=Ha(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(`
|
|
134
|
+
`)}function Ha(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 on(e,t){return Wa(e,t)}function Wa(e,t){let i=[];i.push(`struct ${J(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} : ${J(e.name)};`),i.join(`
|
|
135
|
+
`)}function an(e,t){switch(t.shaderLanguage){case"glsl":return rn(e,t);case"wgsl":return on(e,t)}}var Dc=1/Math.PI*180,Oc=1/180*Math.PI,qa={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...qa}};var F=globalThis.mathgl.config;function Ot(e,{precision:t=F.precision}={}){return e=ja(e),`${parseFloat(e.toPrecision(t))}`}function ue(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bt(e,t,i){return Ka(e,n=>Math.max(t,Math.min(i,n)))}function je(e,t,i){let n=F.EPSILON;i&&(F.EPSILON=i);try{if(e===t)return!0;if(ue(e)&&ue(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!je(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)<=F.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{F.EPSILON=n}}function ja(e){return Math.round(e/F.EPSILON)*F.EPSILON}function $a(e){return e.clone?e.clone():new Array(e.length)}function Ka(e,t,i){if(ue(e)){let n=e;i=i||$a(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 $e=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:ue(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(F)}formatString(t){let i="";for(let n=0;n<this.ELEMENTS;++n)i+=(n>0?", ":"")+Ot(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(!je(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(F.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 Ya(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 sn(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Ke(e,t,i=""){if(F.debug&&!Ya(e,t))throw new Error(`math.gl: ${i} some fields set to invalid numbers'`);return e}var Ye=class extends $e{toString(){let t="[";if(F.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]=sn(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 ln(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 cn(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 fn(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 un(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 Za(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 pn(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 dn(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],u=t[9],p=t[10],d=t[11],h=t[12],m=t[13],x=t[14],y=t[15],S=i*s-n*a,b=i*l-r*a,_=i*c-o*a,g=n*l-r*s,v=n*c-o*s,A=r*c-o*l,C=f*m-u*h,R=f*x-p*h,w=f*y-d*h,P=u*x-p*m,I=u*y-d*m,E=p*y-d*x,L=S*E-b*I+_*P+g*w-v*R+A*C;return L?(L=1/L,e[0]=(s*E-l*I+c*P)*L,e[1]=(r*I-n*E-o*P)*L,e[2]=(m*A-x*v+y*g)*L,e[3]=(p*v-u*A-d*g)*L,e[4]=(l*w-a*E-c*R)*L,e[5]=(i*E-r*w+o*R)*L,e[6]=(x*_-h*A-y*b)*L,e[7]=(f*A-p*_+d*b)*L,e[8]=(a*I-s*w+c*C)*L,e[9]=(n*w-i*I-o*C)*L,e[10]=(h*v-m*_+y*S)*L,e[11]=(u*_-f*v-d*S)*L,e[12]=(s*R-a*P-l*C)*L,e[13]=(i*P-n*R+r*C)*L,e[14]=(m*b-h*g-x*S)*L,e[15]=(f*g-u*b+p*S)*L,e):null}function gn(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],u=e[10],p=e[11],d=e[12],h=e[13],m=e[14],x=e[15],y=t*a-i*o,S=t*s-n*o,b=i*s-n*a,_=c*h-f*d,g=c*m-u*d,v=f*m-u*h,A=t*v-i*g+n*_,C=o*v-a*g+s*_,R=c*b-f*S+u*y,w=d*b-h*S+m*y;return l*A-r*C+x*R-p*w}function kt(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],u=t[8],p=t[9],d=t[10],h=t[11],m=t[12],x=t[13],y=t[14],S=t[15],b=i[0],_=i[1],g=i[2],v=i[3];return e[0]=b*n+_*s+g*u+v*m,e[1]=b*r+_*l+g*p+v*x,e[2]=b*o+_*c+g*d+v*y,e[3]=b*a+_*f+g*h+v*S,b=i[4],_=i[5],g=i[6],v=i[7],e[4]=b*n+_*s+g*u+v*m,e[5]=b*r+_*l+g*p+v*x,e[6]=b*o+_*c+g*d+v*y,e[7]=b*a+_*f+g*h+v*S,b=i[8],_=i[9],g=i[10],v=i[11],e[8]=b*n+_*s+g*u+v*m,e[9]=b*r+_*l+g*p+v*x,e[10]=b*o+_*c+g*d+v*y,e[11]=b*a+_*f+g*h+v*S,b=i[12],_=i[13],g=i[14],v=i[15],e[12]=b*n+_*s+g*u+v*m,e[13]=b*r+_*l+g*p+v*x,e[14]=b*o+_*c+g*d+v*y,e[15]=b*a+_*f+g*h+v*S,e}function mn(e,t,i){let n=i[0],r=i[1],o=i[2],a,s,l,c,f,u,p,d,h,m,x,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],u=t[5],p=t[6],d=t[7],h=t[8],m=t[9],x=t[10],y=t[11],e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=f,e[5]=u,e[6]=p,e[7]=d,e[8]=h,e[9]=m,e[10]=x,e[11]=y,e[12]=a*n+f*r+h*o+t[12],e[13]=s*n+u*r+m*o+t[13],e[14]=l*n+p*r+x*o+t[14],e[15]=c*n+d*r+y*o+t[15]),e}function hn(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 _n(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,u,p,d,h,m,x,y,S,b,_,g,v,A,C,R,w,P,I,E,L,M;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,u=t[0],p=t[1],d=t[2],h=t[3],m=t[4],x=t[5],y=t[6],S=t[7],b=t[8],_=t[9],g=t[10],v=t[11],A=r*r*f+l,C=o*r*f+a*c,R=a*r*f-o*c,w=r*o*f-a*c,P=o*o*f+l,I=a*o*f+r*c,E=r*a*f+o*c,L=o*a*f-r*c,M=a*a*f+l,e[0]=u*A+m*C+b*R,e[1]=p*A+x*C+_*R,e[2]=d*A+y*C+g*R,e[3]=h*A+S*C+v*R,e[4]=u*w+m*P+b*I,e[5]=p*w+x*P+_*I,e[6]=d*w+y*P+g*I,e[7]=h*w+S*P+v*I,e[8]=u*E+m*L+b*M,e[9]=p*E+x*L+_*M,e[10]=d*E+y*L+g*M,e[11]=h*E+S*L+v*M,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function vn(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],u=t[10],p=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+u*n,e[7]=l*r+p*n,e[8]=c*r-o*n,e[9]=f*r-a*n,e[10]=u*r-s*n,e[11]=p*r-l*n,e}function bn(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],u=t[10],p=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-u*n,e[3]=l*r-p*n,e[8]=o*n+c*r,e[9]=a*n+f*r,e[10]=s*n+u*r,e[11]=l*n+p*r,e}function xn(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],u=t[6],p=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+u*n,e[3]=l*r+p*n,e[4]=c*r-o*n,e[5]=f*r-a*n,e[6]=u*r-s*n,e[7]=p*r-l*n,e}function Sn(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,u=n*s,p=r*a,d=r*s,h=r*l,m=o*a,x=o*s,y=o*l;return e[0]=1-u-h,e[1]=f+y,e[2]=p-x,e[3]=0,e[4]=f-y,e[5]=1-c-h,e[6]=d+m,e[7]=0,e[8]=p+x,e[9]=d-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function yn(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 Xa(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 In=Xa;function Ja(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 Cn=Ja;function Ln(e,t,i,n){let r,o,a,s,l,c,f,u,p,d,h=t[0],m=t[1],x=t[2],y=n[0],S=n[1],b=n[2],_=i[0],g=i[1],v=i[2];return Math.abs(h-_)<1e-6&&Math.abs(m-g)<1e-6&&Math.abs(x-v)<1e-6?Za(e):(u=h-_,p=m-g,d=x-v,r=1/Math.sqrt(u*u+p*p+d*d),u*=r,p*=r,d*=r,o=S*d-b*p,a=b*u-y*d,s=y*p-S*u,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=p*s-d*a,c=d*o-u*s,f=u*a-p*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]=u,e[3]=0,e[4]=a,e[5]=c,e[6]=p,e[7]=0,e[8]=s,e[9]=f,e[10]=d,e[11]=0,e[12]=-(o*h+a*m+s*x),e[13]=-(l*h+c*m+f*x),e[14]=-(u*h+p*m+d*x),e[15]=1,e)}function An(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 Vt;(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"})(Vt||(Vt={}));var Qa=45*Math.PI/180,es=1,Gt=.1,zt=500,ts=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends Ye{static get IDENTITY(){return ns()}static get ZERO(){return is()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Vt}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,u,p,d,h,m,x){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]=u,this[11]=p,this[12]=d,this[13]=h,this[14]=m,this[15]=x,this.check()}setRowMajor(t,i,n,r,o,a,s,l,c,f,u,p,d,h,m,x){return this[0]=t,this[1]=o,this[2]=c,this[3]=d,this[4]=i,this[5]=a,this[6]=f,this[7]=h,this[8]=n,this[9]=s,this[10]=u,this[11]=m,this[12]=r,this[13]=l,this[14]=p,this[15]=x,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(ts)}fromObject(t){return this.check()}fromQuaternion(t){return Sn(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=Gt,far:s=zt}=t;return s===1/0?rs(this,i,n,r,o,a):yn(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 Ln(this,i,n,r),this.check()}ortho(t){let{left:i,right:n,bottom:r,top:o,near:a=Gt,far:s=zt}=t;return Cn(this,i,n,r,o,a,s),this.check()}orthographic(t){let{fovy:i=Qa,aspect:n=es,focalDistance:r=1,near:o=Gt,far:a=zt}=t;Mn(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 Mn(i),In(this,i,n,r,o),this.check()}determinant(){return gn(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){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let n=this.getScale(i),r=1/n[0],o=1/n[1],a=1/n[2];return t[0]=this[0]*r,t[1]=this[1]*o,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*r,t[5]=this[5]*o,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*r,t[9]=this[9]*o,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,i){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let n=this.getScale(i),r=1/n[0],o=1/n[1],a=1/n[2];return t[0]=this[0]*r,t[1]=this[1]*o,t[2]=this[2]*a,t[3]=this[4]*r,t[4]=this[5]*o,t[5]=this[6]*a,t[6]=this[8]*r,t[7]=this[9]*o,t[8]=this[10]*a,t}transpose(){return pn(this,this),this.check()}invert(){return dn(this,this),this.check()}multiplyLeft(t){return kt(this,t,this),this.check()}multiplyRight(t){return kt(this,this,t),this.check()}rotateX(t){return vn(this,this,t),this.check()}rotateY(t){return bn(this,this,t),this.check()}rotateZ(t){return xn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return _n(this,this,t,i),this.check()}scale(t){return hn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return mn(this,this,t),this.check()}transform(t,i){return t.length===4?(i=An(i||[-0,-0,-0,-0],t,this),Ke(i,4),i):this.transformAsPoint(t,i)}transformAsPoint(t,i){let{length:n}=t,r;switch(n){case 2:r=ln(i||[-0,-0],t,this);break;case 3:r=un(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Ke(r,t.length),r}transformAsVector(t,i){let n;switch(t.length){case 2:n=cn(i||[-0,-0],t,this);break;case 3:n=fn(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Ke(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,i,n){return this.identity().translate([t,i,n])}},Ze,Xe;function is(){return Ze||(Ze=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ze)),Ze}function ns(){return Xe||(Xe=new G,Object.freeze(Xe)),Xe}function Mn(e){if(e>Math.PI*2)throw Error("expected radians")}function rs(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,u=-1,p=-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]=u,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}var Q=null,Rn=new ArrayBuffer(4),En=new Float32Array(Rn),wn=new Uint32Array(Rn);function Tn(e){Q||=Nn(),e=Bt(e,-65504,65504),En[0]=e;let t=wn[0],i=t>>23&511;return Q.baseTable[i]+((t&8388607)>>Q.shiftTable[i])}function Pn(e){Q||=Nn();let t=e>>10;return wn[0]=Q.mantissaTable[Q.offsetTable[t]+(e&1023)]+Q.exponentTable[t],En[0]}function Nn(){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 pe(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 Ce(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;pe(e[n*4+i],t,r*2)}return t}function ee(e,t=!0){return e??t}function te(e=[0,0,0],t=!0){return t?e.map(i=>i/255):[...e]}function Je(e,t=!0){let i=te(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 Fn={width:2,jitter:.7,variation:.35,grain:.45,offset:0,extension:3,sketch:1,minimumAntialias:.7},Dn=`
|
|
136
136
|
layout(std140) uniform sketchStrokeUniforms {
|
|
137
137
|
float width;
|
|
138
138
|
float jitter;
|
|
@@ -143,7 +143,7 @@ layout(std140) uniform sketchStrokeUniforms {
|
|
|
143
143
|
float sketch;
|
|
144
144
|
float minimumAntialias;
|
|
145
145
|
} sketchStroke;
|
|
146
|
-
`,
|
|
146
|
+
`,os=`
|
|
147
147
|
float sketchStroke_noise(float coordinate) {
|
|
148
148
|
float cell = floor(coordinate);
|
|
149
149
|
float fraction = fract(coordinate);
|
|
@@ -182,7 +182,7 @@ float sketchStroke_getCoverage(vec2 coordinates, float strokeLength, float seed)
|
|
|
182
182
|
// Keep the pigment opaque; grain changes the stroke edge so the paper does not show through as white flecks.
|
|
183
183
|
return coverage;
|
|
184
184
|
}
|
|
185
|
-
`,
|
|
185
|
+
`,as=`
|
|
186
186
|
struct sketchStrokeUniforms {
|
|
187
187
|
width: f32,
|
|
188
188
|
jitter: f32,
|
|
@@ -230,7 +230,7 @@ fn sketchStroke_getCoverage(coordinates: vec2<f32>, strokeLength: f32, seed: f32
|
|
|
230
230
|
// Keep the pigment opaque; grain changes the stroke edge so the paper does not show through as white flecks.
|
|
231
231
|
return coverage;
|
|
232
232
|
}
|
|
233
|
-
`,
|
|
233
|
+
`,On={name:"sketchStroke",bindingLayout:[{name:"sketchStroke",group:3}],source:as,vs:Dn,fs:Dn+os,uniformTypes:{width:"f32",jitter:"f32",variation:"f32",grain:"f32",offset:"f32",extension:"f32",sketch:"f32",minimumAntialias:"f32"},defaultUniforms:Fn,getUniforms(e={}){return{...Fn,...e}}};var Ht={dashLength:12,gapLength:8,offset:0},Bn={name:"pathDash",bindingLayout:[{name:"pathDash",group:3}],firstBindingSlot:0,uniformTypes:{dashLength:"f32",gapLength:"f32",offset:"f32"},defaultUniforms:Ht,getUniforms(e={},t=Ht){let i={...Ht,...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:`
|
|
234
234
|
layout(std140) uniform pathDashUniforms {
|
|
235
235
|
float dashLength;
|
|
236
236
|
float gapLength;
|
|
@@ -271,14 +271,14 @@ fn pathDash_getCoverage(distanceAlongPath: f32) -> f32 {
|
|
|
271
271
|
if (pathDash.dashLength <= 0.0) { return 0.0; }
|
|
272
272
|
return clamp(coverage, 0.0, 1.0);
|
|
273
273
|
}
|
|
274
|
-
`};var
|
|
274
|
+
`};var ss=`fn random(scale: vec3f, seed: f32) -> f32 {
|
|
275
275
|
return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);
|
|
276
276
|
}
|
|
277
|
-
`,
|
|
277
|
+
`,ls=`float random(vec3 scale, float seed) {
|
|
278
278
|
/* use the fragment position for a different seed per-pixel */
|
|
279
279
|
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
|
280
280
|
}
|
|
281
|
-
`,
|
|
281
|
+
`,Un={name:"random",source:ss,fs:ls};var cs=`fn volumeRaymarch_intersectBox(origin: vec3f, direction: vec3f, minimum: vec3f, maximum: vec3f) -> vec2f {
|
|
282
282
|
let safeDirection = select(vec3f(0.000001), direction, abs(direction) > vec3f(0.000001));
|
|
283
283
|
let first = (minimum - origin) / safeDirection;
|
|
284
284
|
let second = (maximum - origin) / safeDirection;
|
|
@@ -351,7 +351,7 @@ fn volumeRaymarch_composite(accumulated: vec4f, color: vec3f, alpha: f32) -> vec
|
|
|
351
351
|
let contribution = (1.0 - accumulated.a) * clamp(alpha, 0.0, 1.0);
|
|
352
352
|
return vec4f(accumulated.rgb + color * contribution, accumulated.a + contribution);
|
|
353
353
|
}
|
|
354
|
-
`,
|
|
354
|
+
`,kn={name:"volumeRaymarch",source:cs};var fs=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
355
355
|
|
|
356
356
|
// All these functions are for substituting tan() function from Intel GPU only
|
|
357
357
|
const float TWO_PI = 6.2831854820251465;
|
|
@@ -501,7 +501,7 @@ float tan_fp32(float a) {
|
|
|
501
501
|
return tan(a);
|
|
502
502
|
#endif
|
|
503
503
|
}
|
|
504
|
-
`,
|
|
504
|
+
`,us=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
505
505
|
const FP32_TWO_PI: f32 = 6.2831854820251465;
|
|
506
506
|
const FP32_PI_2: f32 = 1.5707963705062866;
|
|
507
507
|
const FP32_PI_16: f32 = 0.1963495463132858;
|
|
@@ -622,7 +622,7 @@ fn tan_fp32(a: f32) -> f32 {
|
|
|
622
622
|
return tan(a);
|
|
623
623
|
}
|
|
624
624
|
#endif
|
|
625
|
-
`,
|
|
625
|
+
`,Gn={name:"fp32",source:us,vs:fs};var Wt=`
|
|
626
626
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
627
627
|
uniform float ONE;
|
|
628
628
|
uniform float SPLIT;
|
|
@@ -821,7 +821,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
821
821
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
822
822
|
#endif
|
|
823
823
|
}
|
|
824
|
-
`;var
|
|
824
|
+
`;var qt=`struct Fp64F32Bits {
|
|
825
825
|
sign: u32,
|
|
826
826
|
baseExponent: i32,
|
|
827
827
|
significand: u32,
|
|
@@ -1100,7 +1100,7 @@ fn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 {
|
|
|
1100
1100
|
}
|
|
1101
1101
|
#endif
|
|
1102
1102
|
|
|
1103
|
-
`,
|
|
1103
|
+
`,zn=`${qt}
|
|
1104
1104
|
|
|
1105
1105
|
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
1106
1106
|
fn split(a: f32) -> vec2f {
|
|
@@ -1368,7 +1368,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
1368
1368
|
return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2);
|
|
1369
1369
|
}
|
|
1370
1370
|
#endif
|
|
1371
|
-
`;var
|
|
1371
|
+
`;var Vn=`${qt}
|
|
1372
1372
|
|
|
1373
1373
|
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
1374
1374
|
fn split(a: f32) -> vec2f {
|
|
@@ -1481,7 +1481,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
1481
1481
|
return sum_fp64(vec2f(estimate, 0.0), correction);
|
|
1482
1482
|
}
|
|
1483
1483
|
#endif
|
|
1484
|
-
`;var
|
|
1484
|
+
`;var Hn=`struct Fp64ArithmeticUniforms {
|
|
1485
1485
|
ONE: f32,
|
|
1486
1486
|
SPLIT: f32,
|
|
1487
1487
|
};
|
|
@@ -2114,10 +2114,10 @@ fn prevent_fp64_optimization(value: f32) -> f32 {
|
|
|
2114
2114
|
#endif
|
|
2115
2115
|
|
|
2116
2116
|
#ifdef LUMA_FP64_INTEGER_ARITHMETIC
|
|
2117
|
-
${
|
|
2117
|
+
${zn}
|
|
2118
2118
|
#else
|
|
2119
2119
|
#ifdef LUMA_FP64_HYBRID_ARITHMETIC
|
|
2120
|
-
${
|
|
2120
|
+
${Vn}
|
|
2121
2121
|
#else
|
|
2122
2122
|
fn split(a: f32) -> vec2f {
|
|
2123
2123
|
let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
|
|
@@ -2395,7 +2395,7 @@ fn fp64_scale_fp64(value: vec2f, exponent: i32) -> vec2f {
|
|
|
2395
2395
|
#endif
|
|
2396
2396
|
}
|
|
2397
2397
|
#endif
|
|
2398
|
-
`;var
|
|
2398
|
+
`;var Wn=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
2399
2399
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
2400
2400
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
2401
2401
|
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -3064,7 +3064,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
3064
3064
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
3065
3065
|
}
|
|
3066
3066
|
}
|
|
3067
|
-
`;var
|
|
3067
|
+
`;var qn=`const E_FP64 = vec2f(2.7182817459106445, 8.254840366817007e-8);
|
|
3068
3068
|
const LOG2_FP64 = vec2f(0.6931471824645996, -1.9046542121259336e-9);
|
|
3069
3069
|
const PI_FP64 = vec2f(3.1415927410125732, -8.742278012618954e-8);
|
|
3070
3070
|
const TWO_PI_FP64 = vec2f(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -3214,7 +3214,7 @@ fn mat4_vec4_mul_fp64(matrix: array<vec2f, 16>, a: array<vec2f, 4>) -> array<vec
|
|
|
3214
3214
|
}
|
|
3215
3215
|
return result;
|
|
3216
3216
|
}
|
|
3217
|
-
`;var
|
|
3217
|
+
`;var ps={ONE:1,SPLIT:4097},jt={name:"fp64arithmetic",source:Hn,fs:Wt,vs:Wt,defaultUniforms:ps,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:pe,fp64LowPart:Ie,fp64ifyMatrix4:Ce},jn={name:"fp64",source:qn,vs:Wn,dependencies:[jt],fp64ify:pe,fp64LowPart:Ie,fp64ifyMatrix4:Ce};var $n=`const DGGS_H3_CELL_MODE: u32 = 1u;
|
|
3218
3218
|
const DGGS_H3_MAX_RESOLUTION: u32 = 15u;
|
|
3219
3219
|
const DGGS_H3_MAX_BASE_CELL: u32 = 121u;
|
|
3220
3220
|
const DGGS_H3_UNUSED_DIGIT: u32 = 7u;
|
|
@@ -5488,7 +5488,7 @@ fn dggs_s2_get_boundary_point(index: vec2u, vertexIndex: u32) -> vec2f {
|
|
|
5488
5488
|
fn dggs_s2_get_boundary_point_fp64_split(index: vec2u, vertexIndex: u32) -> vec4f {
|
|
5489
5489
|
return dggs_boundary_point_to_fp64_split(dggs_s2_get_boundary_point(index, vertexIndex));
|
|
5490
5490
|
}
|
|
5491
|
-
`;var
|
|
5491
|
+
`;var Kn={name:"dggs",source:$n};var B={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},Qe={rgba8unorm:4,rgba16float:8,rgba32float:16},et={...Qe},$t={rgba8unorm:B.RGBA8UNORM,rgba16float:B.RGBA16FLOAT,rgba32float:B.RGBA32FLOAT},Jn={[B.RGBA8UNORM]:"rgba8unorm",[B.RGBA16FLOAT]:"rgba16float",[B.RGBA32FLOAT]:"rgba32float"},Qn={useByteColors:"f32"},er={useByteColors:!0},ds={format:"u32",wordStride:"u32",wordOffset:"u32",_padding:"u32"},gs={format:B.RGBA8UNORM,wordStride:et.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},Yn=tr("colors"),Zn=tr("floatColors"),ms=ir("colors"),hs=ir("floatColors"),_s=`struct storageColorsUniforms {
|
|
5492
5492
|
format: u32,
|
|
5493
5493
|
wordStride: u32,
|
|
5494
5494
|
wordOffset: u32,
|
|
@@ -5498,8 +5498,8 @@ fn dggs_s2_get_boundary_point_fp64_split(index: vec2u, vertexIndex: u32) -> vec4
|
|
|
5498
5498
|
@group(0) @binding(auto) var<uniform> storageColors : storageColorsUniforms;
|
|
5499
5499
|
@group(0) @binding(auto) var<storage, read> storageColorsBuffer : array<u32>;
|
|
5500
5500
|
|
|
5501
|
-
const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${
|
|
5502
|
-
const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${
|
|
5501
|
+
const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${B.RGBA8UNORM}u;
|
|
5502
|
+
const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${B.RGBA16FLOAT}u;
|
|
5503
5503
|
|
|
5504
5504
|
fn storageColors_getWordIndex(rowIndex: u32) -> u32 {
|
|
5505
5505
|
return storageColors.wordOffset + rowIndex * storageColors.wordStride;
|
|
@@ -5534,7 +5534,7 @@ fn storageColors_readColor(rowIndex: u32) -> vec4<f32> {
|
|
|
5534
5534
|
}
|
|
5535
5535
|
return storageColors_readRgba32FloatColor(wordIndex);
|
|
5536
5536
|
}
|
|
5537
|
-
`;function
|
|
5537
|
+
`;function tr(e){return`layout(std140) uniform ${e}Uniforms {
|
|
5538
5538
|
float useByteColors;
|
|
5539
5539
|
} ${e};
|
|
5540
5540
|
|
|
@@ -5561,7 +5561,7 @@ vec4 ${e}_premultiply_alpha(vec4 inputColor) {
|
|
|
5561
5561
|
vec4 ${e}_unpremultiply_alpha(vec4 inputColor) {
|
|
5562
5562
|
return ${e}_unpremultiplyAlpha(inputColor);
|
|
5563
5563
|
}
|
|
5564
|
-
`}function
|
|
5564
|
+
`}function ir(e){return`struct ${e}Uniforms {
|
|
5565
5565
|
useByteColors: f32
|
|
5566
5566
|
};
|
|
5567
5567
|
|
|
@@ -5594,7 +5594,7 @@ fn ${e}_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
|
5594
5594
|
fn ${e}_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
5595
5595
|
return ${e}_unpremultiplyAlpha(inputColor);
|
|
5596
5596
|
}
|
|
5597
|
-
`}function
|
|
5597
|
+
`}function vs(e={}){let t=bs(e.format),i=Jn[t],n=e.byteStride??et[i],r=e.byteOffset??0,o=Qe[i];if(Xn("byteStride",n),Xn("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 bs(e="rgba8unorm"){if(typeof e=="number"){if(e in Jn)return e}else if(e in $t)return $t[e];throw new Error(`storageColors format must be one of ${Object.keys($t).join(", ")}`)}function Xn(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 nr={name:"colors",props:{},uniforms:{},vs:Yn,fs:Yn,source:ms,uniformTypes:Qn,defaultUniforms:er},de={name:"floatColors",props:{},uniforms:{},vs:Zn,fs:Zn,source:hs,uniformTypes:Qn,defaultUniforms:er},rr={name:"storageColors",props:{},uniforms:{},bindings:{},source:_s,uniformTypes:ds,defaultUniforms:gs,bindingLayout:[{name:"storageColors",group:0},{name:"storageColorsBuffer",group:0}],getUniforms(e={}){return{...vs(e),...e.colorBuffer?{storageColorsBuffer:e.colorBuffer}:{}}}};var xs=[0,1,1,1],Ss=`layout(std140) uniform pickingUniforms {
|
|
5598
5598
|
float isActive;
|
|
5599
5599
|
float isAttribute;
|
|
5600
5600
|
float isHighlightActive;
|
|
@@ -5665,7 +5665,7 @@ void picking_setPickingAttribute(vec3 value) {
|
|
|
5665
5665
|
picking_vRGBcolor_Avalid.rgb = value;
|
|
5666
5666
|
}
|
|
5667
5667
|
}
|
|
5668
|
-
`,
|
|
5668
|
+
`,ys=`layout(std140) uniform pickingUniforms {
|
|
5669
5669
|
float isActive;
|
|
5670
5670
|
float isAttribute;
|
|
5671
5671
|
float isHighlightActive;
|
|
@@ -5721,7 +5721,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
5721
5721
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
5722
5722
|
return picking_filterPickingColor(highlightColor);
|
|
5723
5723
|
}
|
|
5724
|
-
`,
|
|
5724
|
+
`,or={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:xs},vs:Ss,fs:ys,getUniforms:Is};function Is(e={},t){let i={},n=ee(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=Je(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 Cs={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 {
|
|
5725
5725
|
int enabled;
|
|
5726
5726
|
float min;
|
|
5727
5727
|
float max;
|
|
@@ -5742,11 +5742,11 @@ fn filter_isVisible(value: f32) -> bool {
|
|
|
5742
5742
|
return filterUniforms.enabled == 0 ||
|
|
5743
5743
|
(value >= filterUniforms.min && value <= filterUniforms.max);
|
|
5744
5744
|
}
|
|
5745
|
-
`,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}},
|
|
5745
|
+
`,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}},ar={name:"filter",module:Cs,vertexInputs:{filterValues:"f32"},injections:[{stage:"vertex",target:"FILTER_POSITION",glsl:`if (!filter_isVisible(filterValues)) {
|
|
5746
5746
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
5747
5747
|
}`,wgsl:`if (!filter_isVisible(filterValues)) {
|
|
5748
5748
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
5749
|
-
}`}]};var
|
|
5749
|
+
}`}]};var Ls={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 {
|
|
5750
5750
|
highp int enabled;
|
|
5751
5751
|
highp int mode;
|
|
5752
5752
|
highp vec4 bounds;
|
|
@@ -5784,7 +5784,7 @@ fn clip_isInBounds(coordinates: vec2<f32>) -> bool {
|
|
|
5784
5784
|
coordinates.x < clipUniforms.bounds.z &&
|
|
5785
5785
|
coordinates.y < clipUniforms.bounds.w;
|
|
5786
5786
|
}
|
|
5787
|
-
`,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}},
|
|
5787
|
+
`,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}},sr={name:"clip",module:Ls,interStageVariables:{clipCoordinates:{type:"vec2<f32>",interpolation:"smooth"}},injections:[{stage:"vertex",target:"CLIP_POSITION",glsl:`clipCoordinates = geometryCoordinates;
|
|
5788
5788
|
if (clipState.enabled != 0 && clipState.mode == 1 &&
|
|
5789
5789
|
!clip_isInBounds(instanceCoordinates)) {
|
|
5790
5790
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
@@ -5792,13 +5792,13 @@ if (clipState.enabled != 0 && clipState.mode == 1 &&
|
|
|
5792
5792
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == 1 &&
|
|
5793
5793
|
!clip_isInBounds(instanceCoordinates)) {
|
|
5794
5794
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
5795
|
-
}`},{target:"
|
|
5795
|
+
}`},{stage:"fragment",target:"CLIP_COLOR",glsl:`if (clipState.enabled != 0 && clipState.mode == 0 &&
|
|
5796
5796
|
!clip_isInBounds(clipCoordinates)) {
|
|
5797
5797
|
discard;
|
|
5798
5798
|
}`,wgsl:`if (clipUniforms.enabled != 0 && clipUniforms.mode == 0 &&
|
|
5799
5799
|
!clip_isInBounds(clipCoordinates)) {
|
|
5800
5800
|
discard;
|
|
5801
|
-
}`}]};var q=64,
|
|
5801
|
+
}`}]};var q=64,As=`
|
|
5802
5802
|
struct skinUniforms {
|
|
5803
5803
|
jointMatrix: array<mat4x4<f32>, ${q}>,
|
|
5804
5804
|
};
|
|
@@ -5839,7 +5839,7 @@ fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {
|
|
|
5839
5839
|
+ (weights.w * skin.jointMatrix[joints.w]);
|
|
5840
5840
|
#endif
|
|
5841
5841
|
}
|
|
5842
|
-
`,
|
|
5842
|
+
`,Ms=`
|
|
5843
5843
|
layout(std140) uniform skinUniforms {
|
|
5844
5844
|
mat4 jointMatrix[SKIN_MAX_JOINTS];
|
|
5845
5845
|
} skin;
|
|
@@ -5899,7 +5899,7 @@ mat4 getSkinMatrix(vec4 weights, uvec4 joints) {
|
|
|
5899
5899
|
#endif
|
|
5900
5900
|
}
|
|
5901
5901
|
|
|
5902
|
-
`,
|
|
5902
|
+
`,Rs="",lr={props:{},uniforms:{},bindings:{},name:"skin",bindingLayout:[{name:"skin",group:0},{name:"skinJointMatrices",group:0,visibility:1}],dependencies:[],source:As,vs:Ms,fs:Rs,defines:{SKIN_MAX_JOINTS:q},getUniforms:(e={},t)=>{let{jointMatrices:i,skinJointMatrices:n,scenegraphsFromGLTF:r,skinIndex:o=0,meshWorldMatrix:a}=e,s=n?{skinJointMatrices:n}:{};if(i)return{jointMatrix:Es(i),...s};let l=r?.gltf?.skins?.[o];if(!l)return{jointMatrix:[],...s};let{inverseBindMatrices:c,joints:f,skeleton:u}=l,p=r.gltfNodeIndexToNodeMap,d=new Map,h=u===void 0?void 0:p?.get(u),m=h?[h]:r.scenes||[];for(let b of m)b.preorderTraversal((_,{worldMatrix:g})=>{d.set(_.id,g)});let x=a?new G(a).invert():null,y=new Float32Array(q*16),S=c?.value;for(let b=0;b<Math.min(f.length,q);b++){let _=p?.get(f[b]);if(!_)continue;let g=d.get(_.id)||_.matrix,v=x?new G(x).multiplyRight(g):new G(g);S&&S.length>=(b+1)*16&&v.multiplyRight(new G(Array.from(S.slice(b*16,(b+1)*16)))),y.set(v,b*16)}return{jointMatrix:y,...s}},uniformTypes:{jointMatrix:["mat4x4<f32>",q]}};function Es(e){let t=new Float32Array(q*16);return t.set(e instanceof Float32Array?e.subarray(0,t.length):e.slice(0,t.length)),t}var ws=`
|
|
5903
5903
|
#ifdef HAS_GPU_CROWD_ANIMATION
|
|
5904
5904
|
@group(0) @binding(auto) var<storage, read> gpuAnimationFrames: array<vec4f>;
|
|
5905
5905
|
|
|
@@ -6011,7 +6011,7 @@ fn getGPUCrowdMorphDelta(
|
|
|
6011
6011
|
return result;
|
|
6012
6012
|
}
|
|
6013
6013
|
#endif
|
|
6014
|
-
`,
|
|
6014
|
+
`,Ts=`
|
|
6015
6015
|
#ifdef HAS_GPU_CROWD_ANIMATION
|
|
6016
6016
|
uniform highp sampler2D gpuAnimationFrames;
|
|
6017
6017
|
|
|
@@ -6103,7 +6103,7 @@ vec3 getGPUCrowdMorphDelta(
|
|
|
6103
6103
|
return result;
|
|
6104
6104
|
}
|
|
6105
6105
|
#endif
|
|
6106
|
-
`,
|
|
6106
|
+
`,cr={name:"gpuAnimation",props:{},uniforms:{},bindings:{},source:ws,vs:Ts,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 j=4;function Kt(){return{color:[0,0,0],position:[0,0,0],halfAxisX:[0,0,0],halfAxisY:[0,0,0],normal:[0,0,-1],disk:0}}var tt={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:j},(i,n)=>{let r=e[n];if(!r)return Kt();let o=te(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 Yt=`precision highp int;
|
|
6107
6107
|
|
|
6108
6108
|
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6109
6109
|
struct AmbientLight {
|
|
@@ -6189,7 +6189,7 @@ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
|
|
6189
6189
|
}
|
|
6190
6190
|
|
|
6191
6191
|
// #endif
|
|
6192
|
-
`;var
|
|
6192
|
+
`;var fr=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6193
6193
|
const MAX_LIGHTS: i32 = 5;
|
|
6194
6194
|
|
|
6195
6195
|
struct AmbientLight {
|
|
@@ -6274,7 +6274,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
6274
6274
|
);
|
|
6275
6275
|
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
6276
6276
|
}
|
|
6277
|
-
`;var ie=5,
|
|
6277
|
+
`;var ie=5,Ps={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},D={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[Ps,ie],areaLightCount:"i32",areaLights:[tt,j]},defaultUniforms:nt(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:fr,vs:Yt,fs:Yt,getUniforms:Ns};function Ns(e,t={}){e=e&&{...e};let i=(e?.lights||[]).filter(f=>f.type==="rect"||f.type==="disk");if(!e)return nt();e.lights&&(e={...e,...Ds(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{...nt(),enabled:0};let c={...nt(),...Fs({useByteColors:n,ambientLight:r,pointLights:o,spotLights:a,directionalLights:s})};return c.areaLightCount=Math.min(i.length,j),c.areaLights=Le(i,ee(e.useByteColors,!0)),e.enabled!==void 0&&(c.enabled=e.enabled?1:0),c}function Fs({useByteColors:e,ambientLight:t,pointLights:i=[],spotLights:n=[],directionalLights:r=[]}){let o=ur(),a=0,s=0,l=0,c=0;for(let f of i){if(a>=ie)break;o[a]={...o[a],color:it(f,e),position:f.position,attenuation:f.attenuation||[1,0,0]},a++,s++}for(let f of n){if(a>=ie)break;o[a]={...o[a],color:it(f,e),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:Bs(f)},a++,l++}for(let f of r){if(a>=ie)break;o[a]={...o[a],color:it(f,e),direction:f.direction},a++,c++}return i.length+n.length+r.length>ie&&console.warn(`MAX_LIGHTS exceeded, truncating to ${ie}`),{ambientColor:it(t,e),directionalLightCount:c,pointLightCount:s,spotLightCount:l,lights:o}}function Ds(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 it(e={},t){let{color:i=[0,0,0],intensity:n=1}=e;return te(i,ee(t,!0)).map(o=>o*n)}function nt(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:ur(),areaLightCount:0,areaLights:Le([])}}function ur(){return Array.from({length:ie},()=>Os())}function Os(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function Bs(e){let t=e.innerConeAngle??0,i=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(i)]}var Us=`#ifdef USE_IBL
|
|
6278
6278
|
@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
|
|
6279
6279
|
@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
|
|
6280
6280
|
@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
|
|
@@ -6282,12 +6282,12 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
6282
6282
|
@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;
|
|
6283
6283
|
@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;
|
|
6284
6284
|
#endif
|
|
6285
|
-
`,
|
|
6285
|
+
`,pr=`#ifdef USE_IBL
|
|
6286
6286
|
uniform samplerCube pbr_diffuseEnvSampler;
|
|
6287
6287
|
uniform samplerCube pbr_specularEnvSampler;
|
|
6288
6288
|
uniform sampler2D pbr_brdfLUT;
|
|
6289
6289
|
#endif
|
|
6290
|
-
`,
|
|
6290
|
+
`,rt={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:Us,vs:pr,fs:pr};var ks=`struct dirlightUniforms {
|
|
6291
6291
|
lightDirection: vec3<f32>,
|
|
6292
6292
|
};
|
|
6293
6293
|
|
|
@@ -6312,12 +6312,12 @@ fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
|
|
|
6312
6312
|
let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
|
|
6313
6313
|
return vec4<f32>(color.rgb * d, color.a);
|
|
6314
6314
|
}
|
|
6315
|
-
`,
|
|
6315
|
+
`,Gs=`out vec3 dirlight_vNormal;
|
|
6316
6316
|
|
|
6317
6317
|
void dirlight_setNormal(vec3 normal) {
|
|
6318
6318
|
dirlight_vNormal = normalize(normal);
|
|
6319
6319
|
}
|
|
6320
|
-
`,
|
|
6320
|
+
`,zs=`layout(std140) uniform dirlightUniforms {
|
|
6321
6321
|
vec3 lightDirection;
|
|
6322
6322
|
} dirlight;
|
|
6323
6323
|
|
|
@@ -6328,7 +6328,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
6328
6328
|
float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
|
|
6329
6329
|
return vec4(color.rgb * d, color.a);
|
|
6330
6330
|
}
|
|
6331
|
-
`,
|
|
6331
|
+
`,Zt={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:ks,vs:Gs,fs:zs,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:Vs};function Vs(e=Zt.defaultUniforms){let t={};return e.lightDirection&&(t.lightDirection=e.lightDirection),t}var dr=`struct lambertMaterialUniforms {
|
|
6332
6332
|
unlit: u32,
|
|
6333
6333
|
ambient: f32,
|
|
6334
6334
|
diffuse: f32,
|
|
@@ -6395,12 +6395,12 @@ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, p
|
|
|
6395
6395
|
|
|
6396
6396
|
return lightColor;
|
|
6397
6397
|
}
|
|
6398
|
-
`;var
|
|
6398
|
+
`;var gr=`layout(std140) uniform lambertMaterialUniforms {
|
|
6399
6399
|
uniform bool unlit;
|
|
6400
6400
|
uniform float ambient;
|
|
6401
6401
|
uniform float diffuse;
|
|
6402
6402
|
} material;
|
|
6403
|
-
`,
|
|
6403
|
+
`,mr=`layout(std140) uniform lambertMaterialUniforms {
|
|
6404
6404
|
uniform bool unlit;
|
|
6405
6405
|
uniform float ambient;
|
|
6406
6406
|
uniform float diffuse;
|
|
@@ -6447,14 +6447,14 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
6447
6447
|
|
|
6448
6448
|
return lightColor;
|
|
6449
6449
|
}
|
|
6450
|
-
`;var
|
|
6450
|
+
`;var Xt={name:"lambertMaterial",firstBindingSlot:0,bindingLayout:[{name:"lambertMaterial",group:3}],dependencies:[D],source:dr,vs:gr,fs:mr,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6},getUniforms(e){return{...Xt.defaultUniforms,...e}}};var ot=`layout(std140) uniform phongMaterialUniforms {
|
|
6451
6451
|
uniform bool unlit;
|
|
6452
6452
|
uniform float ambient;
|
|
6453
6453
|
uniform float diffuse;
|
|
6454
6454
|
uniform float shininess;
|
|
6455
6455
|
uniform vec3 specularColor;
|
|
6456
6456
|
} material;
|
|
6457
|
-
`,
|
|
6457
|
+
`,at=`layout(std140) uniform phongMaterialUniforms {
|
|
6458
6458
|
uniform bool unlit;
|
|
6459
6459
|
uniform float ambient;
|
|
6460
6460
|
uniform float diffuse;
|
|
@@ -6511,7 +6511,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
6511
6511
|
|
|
6512
6512
|
return lightColor;
|
|
6513
6513
|
}
|
|
6514
|
-
`;var
|
|
6514
|
+
`;var st=`struct phongMaterialUniforms {
|
|
6515
6515
|
unlit: u32,
|
|
6516
6516
|
ambient: f32,
|
|
6517
6517
|
diffuse: f32,
|
|
@@ -6634,7 +6634,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
6634
6634
|
}
|
|
6635
6635
|
return lightColor;
|
|
6636
6636
|
}
|
|
6637
|
-
`;var
|
|
6637
|
+
`;var Hs=[38.25,38.25,38.25],Jt={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:at.replace("phongMaterial","gouraudMaterial"),fs:ot.replace("phongMaterial","gouraudMaterial"),source:st.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[D,de],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:Hs},getUniforms(e){return{...Jt.defaultUniforms,...e}}};var Ws=[38.25,38.25,38.25],Qt={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[D,de],source:st,vs:ot,fs:at,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:Ws},getUniforms(e){return{...Qt.defaultUniforms,...e}}};var hr=`layout(std140) uniform waterMaterialUniforms {
|
|
6638
6638
|
uniform float time;
|
|
6639
6639
|
uniform vec3 baseColor;
|
|
6640
6640
|
uniform float opacity;
|
|
@@ -6654,7 +6654,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
6654
6654
|
uniform float waveBFrequency;
|
|
6655
6655
|
uniform float waveBAmplitude;
|
|
6656
6656
|
} waterMaterial;
|
|
6657
|
-
`,
|
|
6657
|
+
`,_r=`layout(std140) uniform waterMaterialUniforms {
|
|
6658
6658
|
uniform float time;
|
|
6659
6659
|
uniform vec3 baseColor;
|
|
6660
6660
|
uniform float opacity;
|
|
@@ -6858,7 +6858,7 @@ vec4 water_getColor(
|
|
|
6858
6858
|
uv
|
|
6859
6859
|
);
|
|
6860
6860
|
}
|
|
6861
|
-
`;var
|
|
6861
|
+
`;var vr=`struct waterMaterialUniforms {
|
|
6862
6862
|
time: f32,
|
|
6863
6863
|
baseColor: vec3<f32>,
|
|
6864
6864
|
opacity: f32,
|
|
@@ -7082,7 +7082,7 @@ fn water_getColor(
|
|
|
7082
7082
|
uv
|
|
7083
7083
|
);
|
|
7084
7084
|
}
|
|
7085
|
-
`;var T={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},
|
|
7085
|
+
`;var T={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},ft={name:"waterMaterial",firstBindingSlot:0,bindingLayout:[{name:"waterMaterial",group:3}],dependencies:[D],source:vr,vs:hr,fs:_r,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:T,getUniforms(e,t=T){let{mapping:i,...n}=e||{},r=qs(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=lt(n.baseColor)),n.fresnelColor&&(r.fresnelColor=lt(n.fresnelColor)),n.waveADirection&&(r.waveADirection=ct(n.waveADirection)),n.waveBDirection&&(r.waveBDirection=ct(n.waveBDirection)),i!==void 0&&(r.mappingMode=i==="world"?1:i==="object"?2:0),r}};function qs(e){return{time:e.time??T.time,baseColor:e.baseColor?lt(e.baseColor):T.baseColor,opacity:e.opacity??T.opacity,fresnelColor:e.fresnelColor?lt(e.fresnelColor):T.fresnelColor,fresnelPower:e.fresnelPower??T.fresnelPower,specularIntensity:e.specularIntensity??T.specularIntensity,normalStrength:e.normalStrength??T.normalStrength,mappingMode:e.mappingMode??T.mappingMode,coordinateScale:e.coordinateScale?[Number(e.coordinateScale[0]),Number(e.coordinateScale[1])]:T.coordinateScale,coordinateOffset:e.coordinateOffset?[Number(e.coordinateOffset[0]),Number(e.coordinateOffset[1])]:T.coordinateOffset,waveADirection:e.waveADirection?ct(e.waveADirection):T.waveADirection,waveASpeed:e.waveASpeed??T.waveASpeed,waveAFrequency:e.waveAFrequency??T.waveAFrequency,waveAAmplitude:e.waveAAmplitude??T.waveAAmplitude,waveBDirection:e.waveBDirection?ct(e.waveBDirection):T.waveBDirection,waveBSpeed:e.waveBSpeed??T.waveBSpeed,waveBFrequency:e.waveBFrequency??T.waveBFrequency,waveBAmplitude:e.waveBAmplitude??T.waveBAmplitude}}function lt(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 ct(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 br=`struct riverWaterMaterialUniforms {
|
|
7086
7086
|
enabled: i32,
|
|
7087
7087
|
flowDirection: vec2<f32>,
|
|
7088
7088
|
skyZenithColor: vec3<f32>,
|
|
@@ -7198,7 +7198,7 @@ fn riverWater_getColorMapped(
|
|
|
7198
7198
|
color = mix(color, reflectedColor, clamp(fresnel * 0.3, 0.0, 0.3));
|
|
7199
7199
|
return vec4<f32>(color, waterMaterial.opacity);
|
|
7200
7200
|
}
|
|
7201
|
-
`,
|
|
7201
|
+
`,xr=`layout(std140) uniform riverWaterMaterialUniforms {
|
|
7202
7202
|
uniform int enabled;
|
|
7203
7203
|
uniform vec2 flowDirection;
|
|
7204
7204
|
uniform vec3 skyZenithColor;
|
|
@@ -7307,7 +7307,7 @@ vec4 riverWater_getColorMapped(
|
|
|
7307
7307
|
color = mix(color, reflectedColor, clamp(fresnel * 0.3, 0.0, 0.3));
|
|
7308
7308
|
return vec4(color, waterMaterial.opacity);
|
|
7309
7309
|
}
|
|
7310
|
-
`;var
|
|
7310
|
+
`;var Sr={name:"riverWaterMaterial",firstBindingSlot:1,bindingLayout:[{name:"riverWaterMaterial",group:3}],dependencies:[ft],source:br,fs:xr,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 ei=`
|
|
7311
7311
|
#ifdef USE_AREA_LIGHT_LTC
|
|
7312
7312
|
uniform sampler2D areaLTCMatrix;
|
|
7313
7313
|
uniform sampler2D areaLTCAmplitude;
|
|
@@ -7387,7 +7387,7 @@ vec3 areaLTC_evaluate(int index, vec3 receiver, vec3 normal, vec3 view, float ro
|
|
|
7387
7387
|
areaLTC_specular(light, receiver, normal, view, roughness, reflectance0, reflectance90);
|
|
7388
7388
|
}
|
|
7389
7389
|
#endif
|
|
7390
|
-
`,
|
|
7390
|
+
`,yr=`
|
|
7391
7391
|
#ifdef USE_AREA_LIGHT_LTC
|
|
7392
7392
|
@group(2) @binding(auto) var areaLTCMatrix: texture_2d<f32>;
|
|
7393
7393
|
@group(2) @binding(auto) var areaLTCAmplitude: texture_2d<f32>;
|
|
@@ -7463,7 +7463,7 @@ fn areaLTC_evaluate(index: i32, receiver: vec3f, normal: vec3f, view: vec3f, rou
|
|
|
7463
7463
|
areaLTC_specular(light, receiver, normal, view, roughness, reflectance0, reflectance90);
|
|
7464
7464
|
}
|
|
7465
7465
|
#endif
|
|
7466
|
-
`;var
|
|
7466
|
+
`;var ti=`
|
|
7467
7467
|
layout(std140) uniform areaLightingUniforms {
|
|
7468
7468
|
int lightCount;
|
|
7469
7469
|
int sampleCount;
|
|
@@ -7495,7 +7495,7 @@ PointLight areaLighting_getSample(int lightIndex, int sampleIndex, vec3 receiver
|
|
|
7495
7495
|
float emissionCosine = max(dot(light.normal, displacement * inversesqrt(distanceSquared)), 0.0);
|
|
7496
7496
|
return PointLight(light.color * (area * emissionCosine / (float(areaLighting.sampleCount) * distanceSquared)), position, vec3(1.0, 0.0, 0.0));
|
|
7497
7497
|
}
|
|
7498
|
-
`,
|
|
7498
|
+
`,Ir=`
|
|
7499
7499
|
struct AreaLightingUniforms {
|
|
7500
7500
|
lightCount: i32,
|
|
7501
7501
|
sampleCount: i32,
|
|
@@ -7528,7 +7528,7 @@ fn areaLighting_getSample(lightIndex: i32, sampleIndex: i32, receiver: vec3f) ->
|
|
|
7528
7528
|
let emissionCosine = max(dot(light.normal, displacement * inverseSqrt(distanceSquared)), 0.0);
|
|
7529
7529
|
return PointLight(light.color * (area * emissionCosine / (f32(areaLighting.sampleCount) * distanceSquared)), position, vec3f(1.0, 0.0, 0.0));
|
|
7530
7530
|
}
|
|
7531
|
-
`;var
|
|
7531
|
+
`;var ut={name:"areaLighting",props:{},uniforms:{},dependencies:[D],defaultUniforms:{lightCount:0,sampleCount:64,lights:Array.from({length:j},Kt)},uniformTypes:{lightCount:"i32",sampleCount:"i32",lights:[tt,j]},bindingLayout:[{name:"areaLighting",group:2},{name:"areaLTCMatrix",group:2},{name:"areaLTCAmplitude",group:2}],source:Ir+yr,vs:ti+ei,fs:ti+ei,getUniforms(e={}){let t=e.lights||[];return{lightCount:Math.min(t.length,j),sampleCount:e.sampleCount||64,lights:Le(t,e.useByteColors)}}};var Cr=`out vec3 pbr_vPosition;
|
|
7532
7532
|
out vec2 pbr_vUV0;
|
|
7533
7533
|
out vec2 pbr_vUV1;
|
|
7534
7534
|
|
|
@@ -7570,7 +7570,7 @@ void pbr_setPositionNormalTangentUV(
|
|
|
7570
7570
|
|
|
7571
7571
|
pbr_vUV1 = uv1;
|
|
7572
7572
|
}
|
|
7573
|
-
`,
|
|
7573
|
+
`,Lr=`precision highp float;
|
|
7574
7574
|
|
|
7575
7575
|
layout(std140) uniform pbrMaterialUniforms {
|
|
7576
7576
|
// Material is unlit
|
|
@@ -8763,7 +8763,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
8763
8763
|
|
|
8764
8764
|
for(int i = 0; i < lighting.directionalLightCount; i++) {
|
|
8765
8765
|
if (i < lighting.directionalLightCount) {
|
|
8766
|
-
PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
|
|
8766
|
+
PBRInfo_setDirectionalLight(pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
8767
8767
|
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
|
|
8768
8768
|
}
|
|
8769
8769
|
}
|
|
@@ -9051,7 +9051,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
9051
9051
|
// Apply directional light
|
|
9052
9052
|
for(int i = 0; i < lighting.directionalLightCount; i++) {
|
|
9053
9053
|
if (i < lighting.directionalLightCount) {
|
|
9054
|
-
PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
|
|
9054
|
+
PBRInfo_setDirectionalLight(pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
9055
9055
|
color += calculateMaterialLightColor(
|
|
9056
9056
|
pbrInfo,
|
|
9057
9057
|
lighting_getDirectionalLight(i).color,
|
|
@@ -9259,7 +9259,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
9259
9259
|
vec4 pbr_filterColor(vec4 vertexColor) {
|
|
9260
9260
|
return pbr_filterColorWithSpotShadows(vertexColor, vec4(1.0));
|
|
9261
9261
|
}
|
|
9262
|
-
`;var
|
|
9262
|
+
`;var Ar=`#ifdef DOUBLE_SIDED
|
|
9263
9263
|
var<private> pbr_frontFacing: bool = true;
|
|
9264
9264
|
#endif
|
|
9265
9265
|
struct PBRFragmentInputs {
|
|
@@ -10574,7 +10574,7 @@ fn pbr_filterColorWithSpotShadows(vertexColor: vec4<f32>, spotVisibility: vec4f)
|
|
|
10574
10574
|
|
|
10575
10575
|
for (var i = 0; i < lighting.directionalLightCount; i++) {
|
|
10576
10576
|
if (i < lighting.directionalLightCount) {
|
|
10577
|
-
PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
|
|
10577
|
+
PBRInfo_setDirectionalLight(&pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
10578
10578
|
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
|
|
10579
10579
|
}
|
|
10580
10580
|
}
|
|
@@ -10934,7 +10934,7 @@ fn pbr_filterColorWithSpotShadows(vertexColor: vec4<f32>, spotVisibility: vec4f)
|
|
|
10934
10934
|
// Apply directional light
|
|
10935
10935
|
for (var i = 0; i < lighting.directionalLightCount; i++) {
|
|
10936
10936
|
if (i < lighting.directionalLightCount) {
|
|
10937
|
-
PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
|
|
10937
|
+
PBRInfo_setDirectionalLight(&pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
10938
10938
|
color += calculateMaterialLightColor(
|
|
10939
10939
|
pbrInfo,
|
|
10940
10940
|
lighting_getDirectionalLight(i).color,
|
|
@@ -11146,13 +11146,13 @@ fn pbr_filterColorWithSpotShadows(vertexColor: vec4<f32>, spotVisibility: vec4f)
|
|
|
11146
11146
|
fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
11147
11147
|
return pbr_filterColorWithSpotShadows(vertexColor, vec4f(1.0));
|
|
11148
11148
|
}
|
|
11149
|
-
`;var
|
|
11149
|
+
`;var Mr=`layout(std140) uniform pbrProjectionUniforms {
|
|
11150
11150
|
mat4 modelViewProjectionMatrix;
|
|
11151
11151
|
mat4 modelMatrix;
|
|
11152
11152
|
mat4 normalMatrix;
|
|
11153
11153
|
vec3 camera;
|
|
11154
11154
|
} pbrProjection;
|
|
11155
|
-
`,
|
|
11155
|
+
`,js=`struct pbrProjectionUniforms {
|
|
11156
11156
|
modelViewProjectionMatrix: mat4x4<f32>,
|
|
11157
11157
|
modelMatrix: mat4x4<f32>,
|
|
11158
11158
|
normalMatrix: mat4x4<f32>,
|
|
@@ -11160,7 +11160,7 @@ fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
|
11160
11160
|
};
|
|
11161
11161
|
|
|
11162
11162
|
@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
|
|
11163
|
-
`,
|
|
11163
|
+
`,Rr={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:js,vs:Mr,fs:Mr,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var ii={NONE:0,REINHARD:1,KHRONOS_PBR_NEUTRAL:2,ACES:3},Er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],wr=`layout(std140) uniform pbrSceneUniforms {
|
|
11164
11164
|
float exposure;
|
|
11165
11165
|
highp int toneMapMode;
|
|
11166
11166
|
float environmentIntensity;
|
|
@@ -11175,7 +11175,7 @@ fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
|
11175
11175
|
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
11176
11176
|
uniform sampler2D pbr_transmissionFramebufferSampler;
|
|
11177
11177
|
#endif
|
|
11178
|
-
|
|
11178
|
+
`,$s=`struct pbrSceneUniforms {
|
|
11179
11179
|
exposure: f32,
|
|
11180
11180
|
toneMapMode: i32,
|
|
11181
11181
|
environmentIntensity: f32,
|
|
@@ -11193,7 +11193,7 @@ uniform sampler2D pbr_transmissionFramebufferSampler;
|
|
|
11193
11193
|
@group(1) @binding(auto) var pbr_transmissionFramebufferSampler: texture_2d<f32>;
|
|
11194
11194
|
@group(1) @binding(auto) var pbr_transmissionFramebufferSamplerSampler: sampler;
|
|
11195
11195
|
#endif
|
|
11196
|
-
`,
|
|
11196
|
+
`,pt={name:"pbrScene",bindingLayout:[{name:"pbrScene",group:1},{name:"pbr_transmissionFramebufferSampler",group:1}],source:$s,vs:wr,fs:wr,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:ii.KHRONOS_PBR_NEUTRAL,environmentIntensity:1,environmentRotation:Math.PI*.5,environmentMipCount:1,outputEncoding:1,framebufferSize:[1,1],viewMatrix:Er,projectionMatrix:Er}};var Tr={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:[D,ut,rt,Rr,pt],source:Ar,vs:Cr,fs:Lr,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 $={name:"valueNoise",fs:`
|
|
11197
11197
|
float valueNoise_hash(vec2 cell) {
|
|
11198
11198
|
vec3 value = fract(vec3(cell.x, cell.y, cell.x) * 0.1031);
|
|
11199
11199
|
value += dot(value, value.yzx + 33.33);
|
|
@@ -11251,7 +11251,7 @@ fn valueNoise_noise3(position: vec3f) -> f32 {
|
|
|
11251
11251
|
mix(valueNoise_hash3(cell + vec3f(0.0, 1.0, 1.0)), valueNoise_hash3(cell + vec3f(1.0)), blend.x), blend.y);
|
|
11252
11252
|
return mix(bottom, top, blend.z);
|
|
11253
11253
|
}
|
|
11254
|
-
`};var
|
|
11254
|
+
`};var dt={name:"heightFogFunctions",dependencies:[$],fs:`
|
|
11255
11255
|
float heightFog_getRayTransmittance(float rayLength, float cameraHeight, float fragmentHeight, float density, float baseHeight, float heightFalloff) {
|
|
11256
11256
|
float startHeight = (cameraHeight - baseHeight) * max(heightFalloff, 0.0);
|
|
11257
11257
|
float endHeight = (fragmentHeight - baseHeight) * max(heightFalloff, 0.0);
|
|
@@ -11351,7 +11351,7 @@ fn heightFog_getSpatialTransmittance(camera: vec3f, position: vec3f, upDirection
|
|
|
11351
11351
|
return transmittance;
|
|
11352
11352
|
}
|
|
11353
11353
|
|
|
11354
|
-
`};var
|
|
11354
|
+
`};var Pr={name:"heightFog",dependencies:[dt],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:`
|
|
11355
11355
|
layout(std140) uniform heightFogUniforms {
|
|
11356
11356
|
vec3 color;
|
|
11357
11357
|
float density;
|
|
@@ -11390,7 +11390,7 @@ fn heightFog_getTransmittance(position: vec3<f32>, cameraPosition: vec3<f32>) ->
|
|
|
11390
11390
|
fn heightFog_getColor(color: vec4<f32>, position: vec3<f32>, cameraPosition: vec3<f32>) -> vec4<f32> {
|
|
11391
11391
|
return vec4<f32>(mix(heightFog.color, color.rgb, heightFog_getTransmittance(position, cameraPosition)), color.a);
|
|
11392
11392
|
}
|
|
11393
|
-
`};var
|
|
11393
|
+
`};var Nr=`
|
|
11394
11394
|
layout(std140) uniform patternFillUniforms {
|
|
11395
11395
|
int patternType;
|
|
11396
11396
|
float spacing;
|
|
@@ -11431,7 +11431,7 @@ float patternFill_getCoverage(vec2 coordinates) {
|
|
|
11431
11431
|
if (patternFill.patternType == 1) return first + second - first * second;
|
|
11432
11432
|
return first;
|
|
11433
11433
|
}
|
|
11434
|
-
`,
|
|
11434
|
+
`,Fr=`
|
|
11435
11435
|
struct patternFillUniforms {
|
|
11436
11436
|
patternType: i32,
|
|
11437
11437
|
spacing: f32,
|
|
@@ -11471,7 +11471,7 @@ fn patternFill_getCoverage(coordinates: vec2<f32>) -> f32 {
|
|
|
11471
11471
|
if (patternFill.patternType == 1) { return first + second - first * second; }
|
|
11472
11472
|
return first;
|
|
11473
11473
|
}
|
|
11474
|
-
`;var
|
|
11474
|
+
`;var ni={patternType:0,spacing:8,width:.12,angle:Math.PI/4,offset:[0,0]},Dr={name:"patternFill",firstBindingSlot:0,bindingLayout:[{name:"patternFill",group:3}],source:Fr,fs:Nr,uniformTypes:{patternType:"i32",spacing:"f32",width:"f32",angle:"f32",offset:"vec2<f32>"},defaultUniforms:ni,getUniforms(e={},t=ni){let i={...ni,...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 ri={coreRadius:.12,coreIntensity:1,haloIntensity:.6,falloff:5},Or={name:"pointGlow",firstBindingSlot:0,bindingLayout:[{name:"pointGlow",group:3}],uniformTypes:{coreRadius:"f32",coreIntensity:"f32",haloIntensity:"f32",falloff:"f32"},defaultUniforms:ri,getUniforms(e={},t=ri){let i={...ri,...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:`
|
|
11475
11475
|
layout(std140) uniform pointGlowUniforms {
|
|
11476
11476
|
float coreRadius;
|
|
11477
11477
|
float coreIntensity;
|
|
@@ -11511,7 +11511,7 @@ fn pointGlow_getColor(coordinates: vec2<f32>, tint: vec3<f32>) -> vec3<f32> {
|
|
|
11511
11511
|
let halo = max(0.0, (exp(-pointGlow.falloff * radius * radius) - outer) / (1.0 - outer));
|
|
11512
11512
|
return (vec3<f32>(core * pointGlow.coreIntensity) + tint * halo * pointGlow.haloIntensity) * envelope;
|
|
11513
11513
|
}
|
|
11514
|
-
`};var
|
|
11514
|
+
`};var Br={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:`
|
|
11515
11515
|
layout(std140) uniform precipitationUniforms {
|
|
11516
11516
|
float time;
|
|
11517
11517
|
float fallSpeed;
|
|
@@ -11574,7 +11574,7 @@ fn precipitation_getFade(position: vec3<f32>) -> f32 {
|
|
|
11574
11574
|
let edge = 0.5 - abs((position - precipitation.volumeCenter) / max(precipitation.volumeSize, vec3<f32>(0.001)));
|
|
11575
11575
|
return smoothstep(0.0, 0.08, min(edge.x, min(edge.y, edge.z)));
|
|
11576
11576
|
}
|
|
11577
|
-
`};var
|
|
11577
|
+
`};var oi={cover:.45,altitude:1e3,thickness:1200,scale:1400,density:.005,time:0,velocity:[14,4],sunDirection:[0,.8,.6],sunColor:[1,.95,.85]},gt={name:"clouds",dependencies:[$],uniformTypes:{cover:"f32",altitude:"f32",thickness:"f32",scale:"f32",density:"f32",time:"f32",velocity:"vec2<f32>",sunDirection:"vec3<f32>",sunColor:"vec3<f32>"},defaultUniforms:oi,getUniforms(e={},t=oi){return{...oi,...t,...e}},fs:`
|
|
11578
11578
|
layout(std140) uniform cloudsUniforms {
|
|
11579
11579
|
float cover;
|
|
11580
11580
|
float altitude;
|
|
@@ -11725,7 +11725,7 @@ fn clouds_getColor(camera: vec3f, rayDirection: vec3f) -> vec4f {
|
|
|
11725
11725
|
let distanceFade = 1.0 - smoothstep(10000.0, 20000.0, start);
|
|
11726
11726
|
return vec4f(radiance, 1.0 - transmittance) * distanceFade;
|
|
11727
11727
|
}
|
|
11728
|
-
`};var
|
|
11728
|
+
`};var ai={enabled:1,sunDirection:[0,.8,.6],sunIntensity:20,haze:1,rayleigh:1,planetRadius:6371e3,exposure:1,groundColor:[.18,.17,.14]},Ur={name:"atmosphere",uniformTypes:{enabled:"f32",sunDirection:"vec3<f32>",sunIntensity:"f32",haze:"f32",rayleigh:"f32",planetRadius:"f32",exposure:"f32",groundColor:"vec3<f32>"},defaultUniforms:ai,getUniforms(e={},t=ai){return{...ai,...t,...e}},fs:`
|
|
11729
11729
|
layout(std140) uniform atmosphereUniforms {
|
|
11730
11730
|
float enabled;
|
|
11731
11731
|
vec3 sunDirection;
|
|
@@ -11917,7 +11917,7 @@ fn atmosphere_getColor(color: vec4f,
|
|
|
11917
11917
|
var scattering: vec3f = vec3f(1.0) - exp(-scatteringSample.radiance * atmosphere.exposure);
|
|
11918
11918
|
return vec4f(color.rgb * scatteringSample.transmittance + scattering, color.a);
|
|
11919
11919
|
}
|
|
11920
|
-
`};function
|
|
11920
|
+
`};function kr(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 si={wetness:0,snow:0,puddles:.8,scale:20,snowColor:[.9,.94,.98],skyColor:[.48,.6,.72]},Gr={name:"surfaceWeather",dependencies:[$],uniformTypes:{wetness:"f32",snow:"f32",puddles:"f32",scale:"f32",snowColor:"vec3<f32>",skyColor:"vec3<f32>"},defaultUniforms:si,getUniforms(e={},t=si){return{...si,...t,...e}},fs:`
|
|
11921
11921
|
layout(std140) uniform surfaceWeatherUniforms {
|
|
11922
11922
|
float wetness;
|
|
11923
11923
|
float snow;
|
|
@@ -12041,7 +12041,7 @@ fn surfaceWeather_getReflection(position: vec3f,
|
|
|
12041
12041
|
var highlight: f32 = pow(max(dot(surfaceNormal, halfway), 0.0), mix(36.0, 160.0, puddle)) * max(dot(surfaceNormal, normalize(lightDirection)), 0.0);
|
|
12042
12042
|
return wetness * (surfaceWeather.skyColor * fresnel * (0.15 + puddle * 0.85) + lightColor * highlight * 0.6);
|
|
12043
12043
|
}
|
|
12044
|
-
`};var
|
|
12044
|
+
`};var li={enabled:0,time:0,radius:8,speed:.6,pulse:.85},zr={name:"firefly",uniformTypes:{enabled:"f32",time:"f32",radius:"f32",speed:"f32",pulse:"f32"},defaultUniforms:li,getUniforms(e={},t=li){return{...li,...t,...e}},source:`struct FireflyUniforms {enabled: f32, time: f32, radius: f32, speed: f32, pulse: f32};
|
|
12045
12045
|
@group(3) @binding(auto) var<uniform> firefly: FireflyUniforms;
|
|
12046
12046
|
fn firefly_getPosition(position: vec3f, seed: f32, time: f32) -> vec3f {
|
|
12047
12047
|
if (firefly.enabled <= 0.0) { return position; }
|
|
@@ -12078,7 +12078,7 @@ fn surfaceWeather_getReflection(position: vec3f,
|
|
|
12078
12078
|
float phase = seed * 2.399963;
|
|
12079
12079
|
float pulse = pow(0.5 + 0.5 * sin(time * firefly.speed * (1.6 + fract(seed * 0.37)) + phase), 3.0);
|
|
12080
12080
|
return mix(1.0, mix(0.08, 1.0, pulse), firefly.pulse * firefly.enabled);
|
|
12081
|
-
}`};var
|
|
12081
|
+
}`};var Vr={name:"globeClouds",dependencies:[gt],uniformTypes:{planetRadius:"f32"},defaultUniforms:{planetRadius:6370972},fs:`
|
|
12082
12082
|
layout(std140) uniform globeCloudsUniforms { float planetRadius; } globeClouds;
|
|
12083
12083
|
vec2 globeClouds_intersectSphere(vec3 camera, vec3 direction, float radius) {
|
|
12084
12084
|
float projected = dot(camera, direction);
|
|
@@ -12180,6 +12180,6 @@ fn globeClouds_getColor(camera: vec3f, direction: vec3f) -> vec4f {
|
|
|
12180
12180
|
}
|
|
12181
12181
|
return vec4f(radiance, 1.0 - transmittance);
|
|
12182
12182
|
}
|
|
12183
|
-
`};return Zr(
|
|
12183
|
+
`};return Zr(Ks);})();
|
|
12184
12184
|
return __exports__;
|
|
12185
12185
|
});
|