@luma.gl/shaders 10.0.0-alpha.7 → 10.0.0-alpha.8
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 +80 -17
- package/dist/dist.min.js +110 -110
- package/dist/glsl.cjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +1 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts +4 -0
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.cjs +19 -3
- package/dist/lib/shader-assembly/shader-hooks.d.ts +1 -1
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.js +23 -3
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -1
- package/dist/lib/shader-plugin.cjs +51 -5
- package/dist/lib/shader-plugin.d.ts +22 -5
- package/dist/lib/shader-plugin.d.ts.map +1 -1
- package/dist/lib/shader-plugin.js +55 -5
- 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 +1 -1
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/lib/shader-assembly/assemble-glsl-shaders.ts +2 -1
- package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +1 -1
- package/src/lib/shader-assembly/shader-assembly-types.ts +4 -0
- package/src/lib/shader-assembly/shader-hooks.ts +27 -3
- package/src/lib/shader-plugin.ts +80 -10
- 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,9 +4,9 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var mt=Object.defineProperty;var
|
|
7
|
+
"use strict";var __exports__=(()=>{var mt=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Yr=Object.prototype.hasOwnProperty;var Zr=(e,t)=>{for(var i in t)mt(e,i,{get:t[i],enumerable:!0})},Xr=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Kr(t))!Yr.call(e,r)&&r!==i&&mt(e,r,{get:()=>t[r],enumerable:!(n=$r(t,r))||n.enumerable});return e};var Jr=e=>Xr(mt({},"__esModule",{value:!0}),e);var Qs={};Zr(Qs,{GLSLShaderAssembler:()=>ve,PBR_TONE_MAP_MODE:()=>ni,SKIN_MAX_JOINTS:()=>q,STORAGE_COLOR_DEFAULT_BYTE_STRIDES:()=>Qe,STORAGE_COLOR_FORMAT:()=>U,STORAGE_COLOR_FORMAT_BYTE_LENGTHS:()=>Je,ShaderAssembler:()=>V,WGSLShaderAssembler:()=>be,_resolveModules:()=>Mi,areaLighting:()=>ft,assembleGLSLShaderPair:()=>_e,atmosphere:()=>Vr,capitalize:()=>J,checkShaderModuleDeprecations:()=>oe,clipShaderPlugin:()=>ur,clouds:()=>dt,colors:()=>sr,combineInjects:()=>Li,convertToVec4:()=>Ot,dggs:()=>Jn,dirlight:()=>Xt,filterShaderPlugin:()=>fr,firefly:()=>qr,floatColors:()=>fe,fp32:()=>Wn,fp64:()=>Zn,fp64LowPart:()=>xe,fp64arithmetic:()=>$t,fp64ify:()=>ce,fp64ifyMatrix4:()=>Se,fromHalfFloat:()=>On,generateShaderForModule:()=>fn,getGLSLUniformBlocks:()=>Ne,getPassthroughFS:()=>on,getQualifierDetails:()=>rn,getShaderInfo:()=>We,getShaderModuleDependencies:()=>k,getShaderModuleSource:()=>Z,getShaderModuleUniformBlockFields:()=>At,getShaderModuleUniformBlockName:()=>Te,getShaderModuleUniformLayoutValidationResult:()=>Mt,getShaderModuleUniforms:()=>Ai,globeClouds:()=>jr,gouraudMaterial:()=>Qt,gpuAnimation:()=>dr,heightFog:()=>Or,heightFogFunctions:()=>pt,ibl:()=>nt,initializeShaderModule:()=>Ee,initializeShaderModules:()=>Y,integrateSurfaceWeather:()=>Hr,lambertMaterial:()=>Jt,lighting:()=>O,mergeShaderPluginModules:()=>Bi,normalizeByteColor3:()=>te,normalizeByteColor4:()=>Xe,pathDash:()=>zn,patternFill:()=>kr,pbrMaterial:()=>Fr,pbrScene:()=>ut,phongMaterial:()=>ei,picking:()=>cr,pointGlow:()=>Gr,precipitation:()=>zr,preprocess:()=>W,random:()=>Vn,resolveShaderPlugins:()=>Oi,resolveUseByteColors:()=>ee,riverWaterMaterial:()=>Lr,scanWGSLInterface:()=>Ae,sketchStroke:()=>Gn,skin:()=>pr,storageColors:()=>lr,surfaceWeather:()=>Wr,toHalfFloat:()=>Fn,typeToChannelCount:()=>sn,typeToChannelSuffix:()=>an,validateShaderModuleUniformLayout:()=>Pe,valueNoise:()=>$,volumeRaymarch:()=>Hn,warnIfGLSLUniformBlocksAreNotStd140:()=>De,waterMaterial:()=>ct});var B="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";var ne=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${B}`,"g")],Ce=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto|\\d+)\\s*\\)\\s*${B}`,"g")],fi=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g")],Qr=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${B}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${B}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${B}`,"g")];function 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===
|
|
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===Ce?Qr:t).find(n=>n.bindingToken==="auto")}function Ae(e,t={}){let i=pi(e),n=eo(i);if(!n)return null;let r=to(i,n);if(!r)return null;let o=no(i,n,r);if(!o)return null;if(t.scanVertexAttributes===!1)return{attributes:[],bindings:o};let a=io(i,n);if(!a)return null;let s=lo(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 eo(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 to(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,Le(e.slice(n+3,o))),n=o}return i}function io(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 no(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=Me(e.slice(u+1,S),",");if(!b)return null;p=b.map(Le),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(Le(e.slice(u+2,v)),i);if(!m)return null;let x=ro({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 so(n),n.sort((a,s)=>a.group-s.group||a.location-s.location||a.name.localeCompare(s.name))}function ro(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"}:oo(a,o)||ao(a,o)}function oo(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 ao(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 so(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 lo(e,t,i,n,r){let o=co(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=Me(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 co(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=po(t,":");if(l<1||l===t.length-1)return!1;let c=go(t.slice(0,l)),f=vt(t.slice(0,l),"location"),u=gi(t.slice(0,l),"builtin"),p=xt(Le(t.slice(l+1)),i);if(!c||f===null||!p||f!==void 0&&u)return!1;if(f!==void 0){let m=uo(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=Me(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+=fo(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 fo(e){let t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;let i={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${i}>`}function uo(e){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(e)?e:null}function 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 Me(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 po(e,t){let i=Me(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 go(e){for(let t=e.length-1;t>=0;t--)if(ue(e[t].value))return e[t].value;return null}function Le(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]=mo(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 mo(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
|
|
10
10
|
logdepth_adjustPosition(gl_Position);
|
|
11
11
|
#endif
|
|
12
12
|
`,Si=`#ifdef MODULE_MATERIAL
|
|
@@ -29,53 +29,53 @@
|
|
|
29
29
|
#ifdef MODULE_LOGDEPTH
|
|
30
30
|
logdepth_setFragDepth();
|
|
31
31
|
#endif
|
|
32
|
-
`;var
|
|
32
|
+
`;var ho={vertex:xi,fragment:Si},Ii=/void\s+main\s*\([^)]*\)\s*\{\n?/,yi=/}\n?[^{}]*$/,yt=[],pe="__LUMA_INJECT_DECLARATIONS__";function Ci(e){let t={vertex:{},fragment:{}};for(let i in e){let n=e[i],r=_o(i);typeof n=="string"&&(n={order:0,injection:n}),t[r][i]=n}return t}function _o(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function re(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),yt.length=l.length;for(let f=0,u=l.length;f<u;++f)yt[f]=l[f].injection;let c=`${yt.join(`
|
|
33
33
|
`)}
|
|
34
|
-
`;switch(s){case"vs:#decl":(r==="wgsl"||a)&&(e=e.replace(pe,c));break;case"vs:#main-start":(r==="wgsl"||a)&&(e=r==="wgsl"?
|
|
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(pe,c));break;case"vs:#main-start":(r==="wgsl"||a)&&(e=r==="wgsl"?Re(e,"vertex",c,"start",o.vertex):e.replace(Ii,f=>f+c));break;case"vs:#main-end":(r==="wgsl"||a)&&(e=r==="wgsl"?Re(e,"vertex",c,"end",o.vertex):e.replace(yi,f=>c+f));break;case"fs:#decl":(r==="wgsl"||!a)&&(e=e.replace(pe,c));break;case"fs:#main-start":(r==="wgsl"||!a)&&(e=r==="wgsl"?Re(e,"fragment",c,"start",o.fragment):e.replace(Ii,f=>f+c));break;case"fs:#main-end":(r==="wgsl"||!a)&&(e=r==="wgsl"?Re(e,"fragment",c,"end",o.fragment):e.replace(yi,f=>c+f));break;default:e=e.replace(s,f=>f+c)}}return e=e.replace(pe,""),n&&(e=e.replace(/\}\s*$/,s=>s+ho[t])),e}function Li(e){let t={};return P(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 Re(e,t,i,n,r){let o=vo(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 vo(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+${bo(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 bo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y(e){e.map(t=>Ee(t))}function Ee(e){if(e.instance)return;Y(e.dependencies||[]);let{propTypes:t={},deprecations:i=[],inject:n={}}=e,r={normalizedInjections:Ci(n),parsedDeprecations:xo(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){Ee(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 xo(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 So(e){return k(e)}function Mi(e){return So(e)}function Ri(e){let t=Lt(e),i=Co[t];if(!i)throw new Error(`Unsupported variable shader type: ${e}`);return i}function Ei(e){let t=Ct(e),i=yo[t];if(!i)throw new Error(`Unsupported attribute shader type: ${e}`);let[n,r]=i,o=n==="i32"||n==="u32",a=n!=="u32",s=Io[n]*r;return{primitiveType:n,components:r,byteLength:s,integer:o,signed:a}}var we=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 we,Io={f32:4,f16:2,i32:4,u32:4},yo={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]},Co={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 Lo=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;function Oi(e=[],t){let i={modules:[],hooks:[],defines:{},injections:{},vertexInputs:{},interStageVariables:{}};for(let o of e)Ao(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 Bi(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 Ao(e,t,i){t.module&&e.modules.push(t.module),t.defines&&Object.assign(e.defines,t.defines);for(let[r,o]of Object.entries(t.vertexInputs||{})){Ni(r,"vertex input");let a=e.vertexInputs[r];if(a&&a!==o)throw new Error(`ShaderPlugin vertex input "${r}" has conflicting types "${a}" and "${o}"`);e.vertexInputs[r]=o}for(let[r,o]of Object.entries(t.interStageVariables||{})){Ni(r,"varying");let a=Mo(r,o),s=e.interStageVariables[r];if(s&&(s.type!==a.type||s.interpolation!==a.interpolation))throw new Error(`ShaderPlugin varying "${r}" has conflicting declarations "${s.type}/${s.interpolation}" and "${a.type}/${a.interpolation}"`);e.interStageVariables[r]=a}for(let r of t.hooks||[]){let o=typeof r=="string"?Fi(r,i):void 0;if(typeof r=="string"&&o===void 0)continue;let a=typeof r=="string"?o.slice(o.indexOf("(")):r[i];if(a===void 0)continue;let s=typeof r=="string"?o.split("(")[0]:Di(r);if(!/^(vs|fs):[A-Za-z_][A-Za-z0-9_]*$/.test(s)||!/^\([^]*\)$/.test(a.trim()))throw new Error(`Invalid ShaderPlugin hook ${s}`);let l={hook:`${s}${a.trim()}`},c=e.hooks.find(f=>f.hook.split("(")[0]===s);if(c&&c.hook!==l.hook)throw new Error(`Conflicting ShaderPlugin hook ${s}`);c||e.hooks.push(l)}let n=Array.isArray(t.injections)?t.injections:Object.entries(t.injections||{}).flatMap(([r,o])=>{let a=Fi(r,i);if(a===void 0)return[];let[s,...l]=a.split(":");if(s!=="vs"&&s!=="fs")throw new Error(`Invalid ShaderPlugin injection ${r}`);return[{stage:s==="vs"?"vertex":"fragment",target:l.join(":"),[i]:o}]});for(let r of n){let o=r[i];if(o===void 0)continue;let a=Di(r);Ro(a),e.injections[a]||(e.injections[a]=[]),e.injections[a].push({pluginName:t.name,injection:o,order:r.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 Mo(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 Ro(e){if(!Lo.test(e))throw new Error(`ShaderPlugin injection target "${e}" must be a named shader anchor or hook`)}function Di(e){if(e.stage!=="vertex"&&e.stage!=="fragment"||e.target.includes(":"))throw new Error("ShaderPlugin object targets require an explicit stage and unqualified target");return`${e.stage==="vertex"?"vs":"fs"}:${e.target}`}function Fi(e,t){let i=/^(glsl|wgsl):([\s\S]+)$/.exec(e);return i?i[1]===t?i[2]:void 0:e}var Eo=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,wo=/((?: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 Te(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=Te(e);return To(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:Te(e),stage:t,expectedUniformNames:i,actualUniformNames:n,matches:Do(i,n)}:null}function Pe(e,t,i={}){let n=Mt(e,t);if(!n||n.matches)return n;let r=Fo(n);return i.log?.error?.(r,n)(),i.throwOnError!==!1&&P(!1,r),n}function Ne(e){let t=[],i=Oo(e);for(let n of i.matchAll(wo)){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 De(e,t,i,n){let r=Ne(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 ${Bo(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 To(e,t,i){let n=t==="wgsl"?Po(e,i):No(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(Eo);s&&r.push(s[1])}return r}function Po(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 No(e,t){return Ne(e).find(n=>n.blockName===t)?.body||null}function Do(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 Fo(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=Uo(t,i);return a&&o.push(a),n.length&&o.push(`Missing from shader block (${n.length}): ${Ui(n)}.`),r.length&&o.push(`Unexpected in shader block (${r.length}): ${Ui(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 Oo(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function Bo(e){return e.replace(/\s+/g," ").trim()}function Uo(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 Ui(e,t=8){if(e.length<=t)return e.join(", ");let i=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${i} more)`}var ki=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${B}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${B}\\s*:\\s*([^;]+);`,"g")];function Vi(e,t=[]){let i=z(e),n=new Map;for(let o of t)n.set(Gi(o.name,o.group,o.location),o.moduleName);let r=[];for(let o of ki){o.lastIndex=0;let a;for(a=o.exec(i);a;){let s=o===ki[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(Gi(u,c,l));r.push(ko({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 ko(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:zo(e.resourceType),viewDimension:zi(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:zi(e.resourceType),sampleType:Go(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function Gi(e,t,i){return`${t}:${i}:${e}`}function zi(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 Go(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 zo(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var de=`
|
|
38
38
|
|
|
39
39
|
${pe}
|
|
40
|
-
`;function
|
|
40
|
+
`;function Fe(e){return function(i){let n={};for(let r of e){let o=r.getUniforms?.(i,n);Object.assign(n,o)}return n}}function Oe(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:P(!1)}if(!e.name)throw new Error("Shader module must have a name");Pe(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_]*)",Vo=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,Ho=new RegExp(`^\\s*\\#\\s*ifdef\\s*${X}\\s*$`),Wo=new RegExp(`^\\s*\\#\\s*ifndef\\s*${X}\\s*(?:\\/\\/.*)?$`),qo=/^\s*\#\s*else\s*(?:\/\/.*)?$/,jo=/^\s*\#\s*endif\s*$/,$o=new RegExp(`^\\s*\\#\\s*ifdef\\s*${X}\\s*(?:\\/\\/.*)?$`),Ko=/^\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(Vo),l=a.match($o)||a.match(Ho),c=a.match(Wo),f=a.match(qo),u=a.match(Ko)||a.match(jo);if(s){let p=Yo(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],v=l?d:!d,m=o&&v;r.push({parentActive:o,branchTaken:v,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 Yo(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 qi(e,t){let i=[];for(let[n,r]of Object.entries(t))Zo(e,n),i.push(`in ${Be(r)} ${n};`);return i.join(`
|
|
47
|
+
`)}function ji(e,t,i){let n=Object.entries(i);if(n.length===0)return{source:e,declarations:"",initialization:""};let r=Xo(e,t),o=e.slice(r.openParenthesis+1,r.closeParenthesis),a=Jo(e,o),s=new Set(a.locations),l=[],c=[],f=[];for(let[m,x]of n){if(a.names.has(m)||ta(e,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let I=ia(s);s.add(I);let S=`_luma_${m}`;l.push(`@location(${I}) ${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 Be(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 Zo(e,t){let i=Ue(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 Xo(e,t){let n=new RegExp(`\\bfn\\s+${Ue(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=$i(e,r,"(",")");if(o<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:r,closeParenthesis:o}}function Jo(e,t){let i=Hi(t),n=new Set(Wi(t)),r=Qo(t);for(let o of r){let a=ea(e,o);if(a!==null){i.push(...Hi(a));for(let s of Wi(a))n.add(s)}}return{locations:i,names:n}}function Hi(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 Wi(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 Qo(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 ea(e,t){let n=new RegExp(`\\bstruct\\s+${Ue(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=$i(e,r,"{","}");return o<0?null:e.slice(r+1,o)}function ta(e,t){let i=Ue(t),n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${i}\\b`,"g"),r=n.exec(e);for(;r;){if(na(e,r.index)===0)return!0;r=n.exec(e)}return!1}function ia(e){let t=0;for(;e.has(t);)t++;return t}function $i(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 na(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 Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ki(e,t,i){let n=[],r=[];for(let[o,a]of Object.entries(i)){ha(e,o);let s=a.interpolation==="flat"?"flat ":"",l=t==="vertex"?"out":"in";n.push(`${s}${l} ${Be(a.type)} ${o};`),t==="vertex"&&r.push(`${o} = ${ga(a.type)};`)}return{declarations:n.join(`
|
|
56
56
|
`),initialization:r.join(`
|
|
57
|
-
`)}}function
|
|
57
|
+
`)}}function Yi(e,t,i,n){let r=Object.entries(n);if(r.length===0)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let o=e,a=ke(o,t,"vertex"),s=ra(o,a),l=ke(o,i,"fragment"),c=oa(o,l),f=Rt(o,s),u=c?Rt(o,c.type):null,p=new Set([...Ge(a.parameters),...Ge(f.body),...Ge(l.parameters),...Ge(u?.body||"")]),d=new Set([...Et(f.body),...Et(u?.body||""),...Et(l.parameters)]),v=[],m=[],x=[],I=[],S=[];for(let[g,_]of r){if(p.has(g)||pa(o,g))throw new Error(`ShaderPlugin varying "${g}" conflicts with existing WGSL stage I/O or a module variable`);let M=da(d);d.add(M);let A=_.interpolation==="flat"?" @interpolate(flat)":"";if(v.push(` @location(${M})${A} ${g}: ${_.type},`),x.push(`var<private> ${g}: ${_.type};`),I.push(`${g} = ${ma(_.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(${M})${A} ${R}: ${_.type}`),S.push(`${g} = ${R};`)}}aa(o,s,a.openBrace,a.closeBrace),o=sa(o,s,a,r.map(([g])=>g)),a=ke(o,t,"vertex"),o=la(o,a,r.map(([g])=>g));let h=(!c||s===c.type?[s]:[s,c.type]).map(g=>Rt(o,g).closeBrace).sort((g,_)=>_-g);for(let g of h)o=o.slice(0,g)+`${v.join(`
|
|
58
58
|
`)}
|
|
59
|
-
`+o.slice(g);if(l=
|
|
59
|
+
`+o.slice(g);if(l=ke(o,i,"fragment"),m.length){let g=l.parameters,_=z(g).trimEnd();if(_.trim()&&!_.endsWith(",")){let M=_.length;g=`${g.slice(0,M)},${g.slice(M)}`}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
63
|
`),vertexInitialization:I.join(`
|
|
64
64
|
`),fragmentInitialization:S.join(`
|
|
65
|
-
`)}}function
|
|
65
|
+
`)}}function ke(e,t,i){let r=new RegExp(`\\bfn\\s+${ae(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=ze(e,o,"(",")"),s=e.indexOf("{",a),l=ze(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 ra(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 oa(e,t){let i=[];for(let n of ua(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+${ae(t)}\\s*\\{`,"g").exec(e);if(!n)return null;let r=e.indexOf("{",n.index),o=ze(e,r,"{","}");return o<0?null:{openBrace:r,closeBrace:o,body:e.slice(r+1,o)}}function aa(e,t,i,n){let r=new RegExp(`\\b${ae(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 sa(e,t,i,n){let r=new RegExp(`\\b${ae(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=ze(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 la(e,t,i){let n=ca(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
|
|
70
|
+
}`;e=e.slice(0,o.start)+c+e.slice(o.semicolon+1)}return e}function ca(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=fa(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 fa(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 ua(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 Ge(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 pa(e,t){let i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${ae(t)}\\b`,"g"),n=i.exec(e);for(;n;){if(_a(e,n.index)===0)return!0;n=i.exec(e)}return!1}function da(e){let t=0;for(;e.has(t);)t++;return t}function ga(e){let{primitiveType:t,components:i}=H.getAttributeShaderTypeInfo(e),n=t==="u32"?"0u":t==="i32"?"0":"0.0";return i===1?n:`${Be(e)}(${n})`}function ma(e){let{primitiveType:t,components:i}=H.getAttributeShaderTypeInfo(e),n=`${t}(0)`;return i===1?n:`${e}(${n})`}function ha(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+${ae(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function ze(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 _a(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 ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,i="glsl"){let n="";for(let r in e){let o=e[r];if(n+=`${i==="wgsl"?"fn":"void"} ${o.signature} {
|
|
73
73
|
`,o.header&&(n+=` ${o.header}`),t[r]){let s=t[r];s.sort((l,c)=>l.order-c.order);for(let l of s)n+=` ${l.injection}
|
|
74
74
|
`}o.footer&&(n+=` ${o.footer}`),n+=`}
|
|
75
|
-
`}return n}function
|
|
75
|
+
`}return n}function me(e,t=[],i){let n={vertex:{},fragment:{}};for(let r of e){let o=typeof r=="string"?r:r.hook,a=/^(glsl|wgsl):([\s\S]+)$/.exec(o);a&&a[1]!==i||va(n,a?typeof r=="string"?a[2]:{...r,hook:a[2]}:r)}for(let r of t){let o=me([r]);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)throw new Error(`Conflicting ShaderPlugin hook ${s}`);n[a][s]=c||l}}return n}function Pt(e,t){return!!(t.startsWith("vs:")?e.vertex:e.fragment)[t]}function Ve(e,t,i){let n=i==="vertex"?"vs:":i==="fragment"?"fs:":null;for(let r in t)if(!(n&&!r.startsWith(n))&&!Pt(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(", ")})`:""}`)}}function va(e,t){let i=typeof t=="string"?{}:t,n=(typeof t=="string"?t:t.hook).trim(),r=n.indexOf(":"),o=n.slice(0,r),a=n.slice(r+1),s=n.split("(")[0].trim(),l={hook:s,signature:a,header:i.header||"",footer:i.footer||""};switch(o){case"vs":e.vertex[s]=l;break;case"fs":e.fragment[s]=l;break;default:throw new Error(o)}}var he=100;function Xi(e){let t=k(e.modules||[]),{source:i,bindingAssignments:n}=ba(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:i,getUniforms:Fe(t),bindingAssignments:n}}function ba(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;P(typeof i=="string","shader source must be a string");let v=W(i,{defines:o}),m=ji(v,u,c),x=Yi(m.source,u,p,f),I=x.source,S="",b=me(a,t.pluginHooks,"wgsl"),h={},g={},_={};Oe(l,h,g,_);for(let y in s){let C=typeof s[y]=="string"?{injection:s[y],order:0}:s[y],N=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(N){let D=N[2],ye=N[3];D?ye==="decl"?g[y]=[...g[y]||[],C]:_[y]=[..._[y]||[],C]:h[y]=[...h[y]||[],C]}else _[y]=[..._[y]||[],C]}xa(m.declarations,m.initialization,g,_),Sa(x,g,_),Ve(b,h);let M=r.map(y=>({module:y,source:W(Z(y,"wgsl",d),{defines:o})})),A=Aa(I),R=La(A.source),L=wa(M,t._bindingRegistry,R),E=[],w=M.map(({module:y,source:C})=>{let N=Ma(C,y,{usedBindingsByGroup:R,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:L});return E.push(...N.bindingAssignments),{module:y,source:N.source}});for(let{module:y,source:C}of w){d&&oe(y,I,d),S+=C;let N=Ia(y);for(let D in N){let ye=/^(v|f)s:#([\w-]+)$/.exec(D);if(ye){let gt=ye[2]==="decl"?g:_;gt[D]=gt[D]||[],gt[D].push(N[D])}else Pt(b,D)&&(h[D]=h[D]||[],h[D].push(N[D]))}}return S+=de,S=re(S,n,ya(g),!1,"wgsl",{vertex:u,fragment:p}),S+=Ca(b,h),S+=Da(E),S+=A.source,S=re(S,n,_,!1,"wgsl",{vertex:u,fragment:p}),Na(S),{source:S,bindingAssignments:E}}function xa(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 Sa(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 Ia(e){return{...e.instance?.normalizedInjections.vertex||{},...e.instance?.normalizedInjections.fragment||{}}}function ya(e){let t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}function Ca(e,t){return ge(e.vertex,t,"wgsl")+ge(e.fragment,t,"wgsl")}function La(e){let t=new Map;for(let i of K(e,fi)){let n=Number(i.bindingToken),r=Number(i.groupToken);Dt(r,n,i.name),se(t,r,n,`application binding "${i.name}"`)}return t}function Aa(e){let t=K(e,Ce),i=new Map;for(let o of t){if(o.bindingToken==="auto")continue;let a=Number(o.bindingToken),s=Number(o.groupToken);Dt(s,a,o.name),se(i,s,a,`application binding "${o.name}"`)}let n={sawSupportedBindingDeclaration:t.length>0},r=ht(e,Ce,o=>Ea(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 Ma(e,t,i){let n=[],o={sawSupportedBindingDeclaration:K(e,ne).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},a=ht(e,ne,s=>Ra(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 Ra(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=He(f,i.name,c),v=n.bindingRegistry?.get(d),m=v!==void 0?v:Ta(f,n.usedBindingsByGroup,i.name,o.nextHintedBindingLocation??void 0,n.bindingRegistry);return Nt(i.name,f,m,c),v!==void 0&&Zi(n.reservedBindingKeysByGroup,f,m,d)?(r.push({moduleName:i.name,name:c,group:f,location:m}),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(se(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&&v===void 0&&(o.nextHintedBindingLocation=m+1),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}let u=Number(s);Nt(i.name,f,u,c);let p=He(f,i.name,c);return Zi(n.reservedBindingKeysByGroup,f,u,p)||se(n.usedBindingsByGroup,f,u,`module "${i.name}" binding "${c}"`),r.push({moduleName:i.name,name:c,group:f,location:u}),a}function Ea(e,t,i){let{match:n,bindingToken:r,groupToken:o,name:a}=e,s=Number(o);if(r==="auto"){let l=Pa(s,t);return Dt(s,l,a),se(t,s,l,`application binding "${a}"`),n.replace(/@binding\(\s*auto\s*\)/,`@binding(${l})`)}return i.sawSupportedBindingDeclaration=!0,n}function wa(e,t,i){let n=new Map,r=[];function o(a,s,l,c){se(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,ne)){let c=Number(l.groupToken);if(l.bindingToken==="auto"){r.push({module:a,name:l.name,group:c});continue}let f=Number(l.bindingToken);Nt(a.name,c,f,l.name),o(c,f,He(c,a.name,l.name),`module "${a.name}" binding "${l.name}"`)}for(let{module:a,name:s,group:l}of r){let c=He(l,a.name,s),f=t?.get(c);f!==void 0&&o(l,f,c,`registered module binding "${c}"`)}return n}function Zi(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 Dt(e,t,i){if(e===0&&t>=he)throw new Error(`Application binding "${i}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${he}.`)}function Nt(e,t,i,n){if(t===0&&i<he)throw new Error(`Module "${e}" binding "${n}" in group 0 uses reserved application binding ${i}. Module-owned explicit group-0 bindings must be ${he} or higher.`)}function se(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 Ta(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?he: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 Pa(e,t){let i=t.get(e)||new Set,n=0;for(;i.has(n);)n++;return n}function Na(e){let t=ui(e,ne);if(!t)return;let i=Fa(e,t.index);throw i?new Error(`Unresolved @binding(auto) for module "${i}" binding "${t.name}" remained in assembled WGSL source.`):Oa(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 "${Ba(t.match)}".`)}function Da(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 He(e,t,i){return`${e}:${t}:${i}`}function
|
|
78
|
+
`,t}function He(e,t,i){return`${e}:${t}:${i}`}function Fa(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 Oa(e,t){let i=e.indexOf(de);return i>=0?t>i:!0}function Ba(e){return e.replace(/\s+/g," ").trim()}function We(e,t){return{name:Ua(e,t),language:"glsl",version:ka(e)}}function Ua(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 ka(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 Ji(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 en(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=Qi(e,Ga),e;case"fragment":return e=Qi(e,za),e;default:throw new Error(t)}}var tn=[[/^(#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("]],Ga=[...tn,[Ft("attribute"),"in $1"],[Ft("varying"),"out $1"]],za=[...tn,[Ft("varying"),"in $1"]];function Qi(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 Va=`precision highp float;
|
|
104
|
+
`;function _e(e){let{vs:t,fs:i}=e,n=k(e.modules||[]);return{vs:nn(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:nn(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:Fe(n)}}function nn(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;P(typeof i=="string","shader source must be a string");let v=r==="glsl"?We(i).version:-1,m=e.shaderLanguageVersion,x=v===100?"#version 100":"#version 300 es",S=i.split(`
|
|
105
105
|
`).slice(1).join(`
|
|
106
106
|
`),b={};o.forEach(L=>{Object.assign(b,L.defines)}),Object.assign(b,a);let h="";switch(r){case"wgsl":break;case"glsl":h=p?`${x}
|
|
107
107
|
|
|
108
108
|
// ----- PROLOGUE -------------------------
|
|
109
109
|
${`#define SHADER_TYPE_${n.toUpperCase()}`}
|
|
110
110
|
|
|
111
|
-
${
|
|
112
|
-
${n==="fragment"?
|
|
111
|
+
${Ji(e)}
|
|
112
|
+
${n==="fragment"?Va:""}
|
|
113
113
|
|
|
114
114
|
// ----- APPLICATION DEFINES -------------------------
|
|
115
115
|
|
|
116
|
-
${
|
|
116
|
+
${Ha(b)}
|
|
117
117
|
|
|
118
118
|
`:`${x}
|
|
119
|
-
`;break}let g=
|
|
120
|
-
`)}let R=
|
|
121
|
-
`),R.initialization&&(A["vs:#main-start"]=A["vs:#main-start"]||[],A["vs:#main-start"].push({injection:R.initialization,order:Number.MIN_SAFE_INTEGER}));for(let L of o){d&&oe(L,S,d);let E=Z(L,n,d);h+=E;let w=L.instance?.normalizedInjections[n]||{};for(let y in w){let C=/^(v|f)s:#([\w-]+)$/.exec(y);if(C){let D=C[2]==="decl"?M:A;D[y]=D[y]||[],D[y].push(w[y])}else _[y]=_[y]||[],_[y].push(w[y])}}return Ve(g,_,n),h+="// ----- MAIN SHADER SOURCE -------------------------",h+=de,h=re(h,n,M),h+=ge(g[n],_),h+=S,h=re(h,n,A),r==="glsl"&&v!==m&&(h=
|
|
119
|
+
`;break}let g=me(s,t.pluginHooks,"glsl"),_={},M={},A={};Oe(c,_,M,A);for(let L in l){let E=typeof l[L]=="string"?{injection:l[L],order:0}:l[L],w=/^(v|f)s:(#)?([\w-]+)$/.exec(L);if(w){let y=w[2],C=w[3];y?C==="decl"?M[L]=[...M[L]||[],E]:A[L]=[...A[L]||[],E]:_[L]=[..._[L]||[],E]}else A[L]=[...A[L]||[],E]}if(n==="vertex"){let L=qi(S,f);L&&(h+=`${L}
|
|
120
|
+
`)}let R=Ki(S,n,u);R.declarations&&(h+=`${R.declarations}
|
|
121
|
+
`),R.initialization&&(A["vs:#main-start"]=A["vs:#main-start"]||[],A["vs:#main-start"].push({injection:R.initialization,order:Number.MIN_SAFE_INTEGER}));for(let L of o){d&&oe(L,S,d);let E=Z(L,n,d);h+=E;let w=L.instance?.normalizedInjections[n]||{};for(let y in w){let C=/^(v|f)s:#([\w-]+)$/.exec(y);if(C){let D=C[2]==="decl"?M:A;D[y]=D[y]||[],D[y].push(w[y])}else _[y]=_[y]||[],_[y].push(w[y])}}return Ve(g,_,n),h+="// ----- MAIN SHADER SOURCE -------------------------",h+=de,h=re(h,n,M),h+=ge(g[n],_),h+=S,h=re(h,n,A),r==="glsl"&&v!==m&&(h=en(h,n)),r==="glsl"&&De(h,n,d),h.trim()}function Ha(e={}){let t="";for(let i in e){let n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}
|
|
122
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 P(!k(i).some(p=>p.sourceLanguage&&p.sourceLanguage!==this.shaderLanguage)),{code:n||"",modules:i};let a=this._shaderTranspilers.get(o);P(a);let s=k(i);P(!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,i){this._hookFunctions.push(i?{...i,hook:t}: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
|
|
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,i){this._hookFunctions.push(i?{...i,hook:t}: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 ve=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{..._e({...t,vs:r.code,fs:t.fs==null?void 0:o.code,modules:r.modules,hookFunctions:n}),modules:i}}};var be=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}=Xi({...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:Vi(u,f),shaderLayout:Ae(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 Wa=`out vec4 transform_output;
|
|
125
125
|
void main() {
|
|
126
126
|
transform_output = vec4(0);
|
|
127
|
-
}`,
|
|
128
|
-
${
|
|
127
|
+
}`,qa=`#version 300 es
|
|
128
|
+
${Wa}`;function rn(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 on(e){let{input:t,inputChannels:i,output:n}=e||{};if(!t)return qa;if(!i)throw new Error("inputChannels");let r=ja(i),o=Ot(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 an(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 sn(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 ja(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 Ot(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 ln(e,t){return $a(e,t)}function $a(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=Ka(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 Ka(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 cn(e,t){return Ya(e,t)}function Ya(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 fn(e,t){switch(t.shaderLanguage){case"glsl":return ln(e,t);case"wgsl":return cn(e,t)}}var zc=1/Math.PI*180,Vc=1/180*Math.PI,Za={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Za}};var F=globalThis.mathgl.config;function Bt(e,{precision:t=F.precision}={}){return e=Xa(e),`${parseFloat(e.toPrecision(t))}`}function le(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ut(e,t,i){return Qa(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 Xa(e){return Math.round(e/F.EPSILON)*F.EPSILON}function Ja(e){return e.clone?e.clone():new Array(e.length)}function Qa(e,t,i){if(le(e)){let n=e;i=i||Ja(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 es(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 un(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function $e(e,t,i=""){if(F.debug&&!es(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]=un(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 pn(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 dn(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 gn(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 mn(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 ts(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 hn(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 _n(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 vn(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 bn(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 xn(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 Sn(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 In(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 yn(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 Cn(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 Ln(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 An(e,t,i,n,r,o,a){let s=1/(i-t),l=1/(r-n),c=1/(o-a);return e[0]=o*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*l,e[6]=0,e[7]=0,e[8]=(i+t)*s,e[9]=(r+n)*l,e[10]=(a+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*c,e[15]=0,e}function is(e,t,i,n,r){let o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,r!=null&&r!==1/0){let a=1/(n-r);e[10]=(r+n)*a,e[14]=2*r*n*a}else e[10]=-1,e[14]=-2*n;return e}var Mn=is;function ns(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 Rn=ns;function En(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?ts(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 wn(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 rs=45*Math.PI/180,os=1,zt=.1,Vt=500,as=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 ls()}static get ZERO(){return ss()}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(as)}fromObject(t){return this.check()}fromQuaternion(t){return Ln(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?cs(this,i,n,r,o,a):An(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 En(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 Rn(this,i,n,r,o,a,s),this.check()}orthographic(t){let{fovy:i=rs,aspect:n=os,focalDistance:r=1,near:o=zt,far:a=Vt}=t;Tn(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 Tn(i),Mn(this,i,n,r,o),this.check()}determinant(){return vn(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 hn(this,this),this.check()}invert(){return _n(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 In(this,this,t),this.check()}rotateY(t){return yn(this,this,t),this.check()}rotateZ(t){return Cn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return Sn(this,this,t,i),this.check()}scale(t){return xn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return bn(this,this,t),this.check()}transform(t,i){return t.length===4?(i=wn(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=pn(i||[-0,-0],t,this);break;case 3:r=mn(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=dn(i||[-0,-0],t,this);break;case 3:n=gn(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 ss(){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 ls(){return Ze||(Ze=new G,Object.freeze(Ze)),Ze}function Tn(e){if(e>Math.PI*2)throw Error("expected radians")}function cs(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,Pn=new ArrayBuffer(4),Nn=new Float32Array(Pn),Dn=new Uint32Array(Pn);function Fn(e){Q||=Bn(),e=Ut(e,-65504,65504),Nn[0]=e;let t=Dn[0],i=t>>23&511;return Q.baseTable[i]+((t&8388607)>>Q.shiftTable[i])}function On(e){Q||=Bn();let t=e>>10;return Dn[0]=Q.mantissaTable[Q.offsetTable[t]+(e&1023)]+Q.exponentTable[t],Nn[0]}function Bn(){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 xe(e){return e-Math.fround(e)}function Se(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 Un={width:2,jitter:.7,variation:.35,grain:.45,offset:0,extension:3,sketch:1,minimumAntialias:.7},kn=`
|
|
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
|
+
`,fs=`
|
|
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
|
+
`,us=`
|
|
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
|
+
`,Gn={name:"sketchStroke",bindingLayout:[{name:"sketchStroke",group:3}],source:us,vs:kn,fs:kn+fs,uniformTypes:{width:"f32",jitter:"f32",variation:"f32",grain:"f32",offset:"f32",extension:"f32",sketch:"f32",minimumAntialias:"f32"},defaultUniforms:Un,getUniforms(e={}){return{...Un,...e}}};var Wt={dashLength:12,gapLength:8,offset:0},zn={name:"pathDash",bindingLayout:[{name:"pathDash",group:3}],firstBindingSlot:0,uniformTypes:{dashLength:"f32",gapLength:"f32",offset:"f32"},defaultUniforms:Wt,getUniforms(e={},t=Wt){let i={...Wt,...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 ps=`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
|
+
`,ds=`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
|
+
`,Vn={name:"random",source:ps,fs:ds};var gs=`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
|
+
`,Hn={name:"volumeRaymarch",source:gs};var ms=`#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
|
+
`,hs=`#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
|
+
`,Wn={name:"fp32",source:hs,vs:ms};var qt=`
|
|
626
626
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
627
627
|
uniform float ONE;
|
|
628
628
|
uniform float SPLIT;
|
|
@@ -1100,7 +1100,7 @@ fn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 {
|
|
|
1100
1100
|
}
|
|
1101
1101
|
#endif
|
|
1102
1102
|
|
|
1103
|
-
`,
|
|
1103
|
+
`,qn=`${jt}
|
|
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 jn=`${jt}
|
|
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 $n=`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
|
+
${qn}
|
|
2118
2118
|
#else
|
|
2119
2119
|
#ifdef LUMA_FP64_HYBRID_ARITHMETIC
|
|
2120
|
-
${
|
|
2120
|
+
${jn}
|
|
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 Kn=`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 Yn=`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 _s={ONE:1,SPLIT:4097},$t={name:"fp64arithmetic",source:$n,fs:qt,vs:qt,defaultUniforms:_s,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:ce,fp64LowPart:xe,fp64ifyMatrix4:Se},Zn={name:"fp64",source:Yn,vs:Kn,dependencies:[$t],fp64ify:ce,fp64LowPart:xe,fp64ifyMatrix4:Se};var Xn=`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 Jn={name:"dggs",source:Xn};var U={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},Je={rgba8unorm:4,rgba16float:8,rgba32float:16},Qe={...Je},Kt={rgba8unorm:U.RGBA8UNORM,rgba16float:U.RGBA16FLOAT,rgba32float:U.RGBA32FLOAT},ir={[U.RGBA8UNORM]:"rgba8unorm",[U.RGBA16FLOAT]:"rgba16float",[U.RGBA32FLOAT]:"rgba32float"},nr={useByteColors:"f32"},rr={useByteColors:!0},vs={format:"u32",wordStride:"u32",wordOffset:"u32",_padding:"u32"},bs={format:U.RGBA8UNORM,wordStride:Qe.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},Qn=or("colors"),er=or("floatColors"),xs=ar("colors"),Ss=ar("floatColors"),Is=`struct storageColorsUniforms {
|
|
5492
5492
|
format: u32,
|
|
5493
5493
|
wordStride: u32,
|
|
5494
5494
|
wordOffset: u32,
|
|
@@ -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 or(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 ar(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 ys(e={}){let t=Cs(e.format),i=ir[t],n=e.byteStride??Qe[i],r=e.byteOffset??0,o=Je[i];if(tr("byteStride",n),tr("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 Cs(e="rgba8unorm"){if(typeof e=="number"){if(e in ir)return e}else if(e in Kt)return Kt[e];throw new Error(`storageColors format must be one of ${Object.keys(Kt).join(", ")}`)}function tr(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 sr={name:"colors",props:{},uniforms:{},vs:Qn,fs:Qn,source:xs,uniformTypes:nr,defaultUniforms:rr},fe={name:"floatColors",props:{},uniforms:{},vs:er,fs:er,source:Ss,uniformTypes:nr,defaultUniforms:rr},lr={name:"storageColors",props:{},uniforms:{},bindings:{},source:Is,uniformTypes:vs,defaultUniforms:bs,bindingLayout:[{name:"storageColors",group:0},{name:"storageColorsBuffer",group:0}],getUniforms(e={}){return{...ys(e),...e.colorBuffer?{storageColorsBuffer:e.colorBuffer}:{}}}};var Ls=[0,1,1,1],As=`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
|
+
`,Ms=`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
|
+
`,cr={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:Ls},vs:As,fs:Ms,getUniforms:Rs};function Rs(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=Xe(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 Es={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}},fr={name:"filter",module:Es,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 ws={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}},ur={name:"clip",module:ws,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,Ts=`
|
|
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
|
+
`,Ps=`
|
|
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
|
+
`,Ns="",pr={props:{},uniforms:{},bindings:{},name:"skin",bindingLayout:[{name:"skin",group:0},{name:"skinJointMatrices",group:0,visibility:1}],dependencies:[],source:Ts,vs:Ps,fs:Ns,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:Ds(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,v=u===void 0?void 0:p?.get(u),m=v?[v]:r.scenes||[];for(let b of m)b.preorderTraversal((h,{worldMatrix:g})=>{d.set(h.id,g)});let x=a?new G(a).invert():null,I=new Float32Array(q*16),S=c?.value;for(let b=0;b<Math.min(f.length,q);b++){let h=p?.get(f[b]);if(!h)continue;let g=d.get(h.id)||h.matrix,_=x?new G(x).multiplyRight(g):new G(g);S&&S.length>=(b+1)*16&&_.multiplyRight(new G(Array.from(S.slice(b*16,(b+1)*16)))),I.set(_,b*16)}return{jointMatrix:I,...s}},uniformTypes:{jointMatrix:["mat4x4<f32>",q]}};function Ds(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 Fs=`
|
|
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
|
+
`,Os=`
|
|
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
|
+
`,dr={name:"gpuAnimation",props:{},uniforms:{},bindings:{},source:Fs,vs:Os,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 Yt(){return{color:[0,0,0],position:[0,0,0],halfAxisX:[0,0,0],halfAxisY:[0,0,0],normal:[0,0,-1],disk:0}}var et={color:"vec3<f32>",position:"vec3<f32>",halfAxisX:"vec3<f32>",halfAxisY:"vec3<f32>",normal:"vec3<f32>",disk:"i32"};function Ie(e,t=!1){return Array.from({length:j},(i,n)=>{let r=e[n];if(!r)return Yt();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 Zt=`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 gr=`// #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,Bs={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},O={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[Bs,ie],areaLightCount:"i32",areaLights:[et,j]},defaultUniforms:it(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:gr,vs:Zt,fs:Zt,getUniforms:Us};function Us(e,t={}){e=e&&{...e};let i=(e?.lights||[]).filter(f=>f.type==="rect"||f.type==="disk");if(!e)return it();e.lights&&(e={...e,...Gs(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{...it(),enabled:0};let c={...it(),...ks({useByteColors:n,ambientLight:r,pointLights:o,spotLights:a,directionalLights:s})};return c.areaLightCount=Math.min(i.length,j),c.areaLights=Ie(i,ee(e.useByteColors,!0)),e.enabled!==void 0&&(c.enabled=e.enabled?1:0),c}function ks({useByteColors:e,ambientLight:t,pointLights:i=[],spotLights:n=[],directionalLights:r=[]}){let o=mr(),a=0,s=0,l=0,c=0;for(let f of i){if(a>=ie)break;o[a]={...o[a],color:tt(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:tt(f,e),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:Vs(f)},a++,l++}for(let f of r){if(a>=ie)break;o[a]={...o[a],color:tt(f,e),direction:f.direction},a++,c++}return i.length+n.length+r.length>ie&&console.warn(`MAX_LIGHTS exceeded, truncating to ${ie}`),{ambientColor:tt(t,e),directionalLightCount:c,pointLightCount:s,spotLightCount:l,lights:o}}function Gs(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 tt(e={},t){let{color:i=[0,0,0],intensity:n=1}=e;return te(i,ee(t,!0)).map(o=>o*n)}function it(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:mr(),areaLightCount:0,areaLights:Ie([])}}function mr(){return Array.from({length:ie},()=>zs())}function zs(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function Vs(e){let t=e.innerConeAngle??0,i=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(i)]}var Hs=`#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
|
+
`,hr=`#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
|
-
`,nt={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:
|
|
6290
|
+
`,nt={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:Hs,vs:hr,fs:hr};var Ws=`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
|
+
`,qs=`out vec3 dirlight_vNormal;
|
|
6316
6316
|
|
|
6317
6317
|
void dirlight_setNormal(vec3 normal) {
|
|
6318
6318
|
dirlight_vNormal = normalize(normal);
|
|
6319
6319
|
}
|
|
6320
|
-
`,
|
|
6320
|
+
`,js=`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
|
-
`,Xt={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:
|
|
6331
|
+
`,Xt={props:{},uniforms:{},name:"dirlight",bindingLayout:[{name:"dirlight",group:2}],firstBindingSlot:16,dependencies:[],source:Ws,vs:qs,fs:js,uniformTypes:{lightDirection:"vec3<f32>"},defaultUniforms:{lightDirection:[1,1,2]},getUniforms:$s};function $s(e=Xt.defaultUniforms){let t={};return e.lightDirection&&(t.lightDirection=e.lightDirection),t}var _r=`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 vr=`layout(std140) uniform lambertMaterialUniforms {
|
|
6399
6399
|
uniform bool unlit;
|
|
6400
6400
|
uniform float ambient;
|
|
6401
6401
|
uniform float diffuse;
|
|
6402
6402
|
} material;
|
|
6403
|
-
`,
|
|
6403
|
+
`,br=`layout(std140) uniform lambertMaterialUniforms {
|
|
6404
6404
|
uniform bool unlit;
|
|
6405
6405
|
uniform float ambient;
|
|
6406
6406
|
uniform float diffuse;
|
|
@@ -6447,7 +6447,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
6447
6447
|
|
|
6448
6448
|
return lightColor;
|
|
6449
6449
|
}
|
|
6450
|
-
`;var Jt={name:"lambertMaterial",firstBindingSlot:0,bindingLayout:[{name:"lambertMaterial",group:3}],dependencies:[O],source:
|
|
6450
|
+
`;var Jt={name:"lambertMaterial",firstBindingSlot:0,bindingLayout:[{name:"lambertMaterial",group:3}],dependencies:[O],source:_r,vs:vr,fs:br,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6},getUniforms(e){return{...Jt.defaultUniforms,...e}}};var rt=`layout(std140) uniform phongMaterialUniforms {
|
|
6451
6451
|
uniform bool unlit;
|
|
6452
6452
|
uniform float ambient;
|
|
6453
6453
|
uniform float diffuse;
|
|
@@ -6634,7 +6634,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
6634
6634
|
}
|
|
6635
6635
|
return lightColor;
|
|
6636
6636
|
}
|
|
6637
|
-
`;var
|
|
6637
|
+
`;var Ks=[38.25,38.25,38.25],Qt={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:ot.replace("phongMaterial","gouraudMaterial"),fs:rt.replace("phongMaterial","gouraudMaterial"),source:at.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[O,fe],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:Ks},getUniforms(e){return{...Qt.defaultUniforms,...e}}};var Ys=[38.25,38.25,38.25],ei={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[O,fe],source:at,vs:rt,fs:ot,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:Ys},getUniforms(e){return{...ei.defaultUniforms,...e}}};var xr=`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
|
+
`,Sr=`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 Ir=`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},ct={name:"waterMaterial",firstBindingSlot:0,bindingLayout:[{name:"waterMaterial",group:3}],dependencies:[O],source:
|
|
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},ct={name:"waterMaterial",firstBindingSlot:0,bindingLayout:[{name:"waterMaterial",group:3}],dependencies:[O],source:Ir,vs:xr,fs:Sr,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=Zs(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=st(n.baseColor)),n.fresnelColor&&(r.fresnelColor=st(n.fresnelColor)),n.waveADirection&&(r.waveADirection=lt(n.waveADirection)),n.waveBDirection&&(r.waveBDirection=lt(n.waveBDirection)),i!==void 0&&(r.mappingMode=i==="world"?1:i==="object"?2:0),r}};function Zs(e){return{time:e.time??T.time,baseColor:e.baseColor?st(e.baseColor):T.baseColor,opacity:e.opacity??T.opacity,fresnelColor:e.fresnelColor?st(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?lt(e.waveADirection):T.waveADirection,waveASpeed:e.waveASpeed??T.waveASpeed,waveAFrequency:e.waveAFrequency??T.waveAFrequency,waveAAmplitude:e.waveAAmplitude??T.waveAAmplitude,waveBDirection:e.waveBDirection?lt(e.waveBDirection):T.waveBDirection,waveBSpeed:e.waveBSpeed??T.waveBSpeed,waveBFrequency:e.waveBFrequency??T.waveBFrequency,waveBAmplitude:e.waveBAmplitude??T.waveBAmplitude}}function st(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 lt(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 yr=`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
|
+
`,Cr=`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 Lr={name:"riverWaterMaterial",firstBindingSlot:1,bindingLayout:[{name:"riverWaterMaterial",group:3}],dependencies:[ct],source:yr,fs:Cr,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 ti=`
|
|
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
|
+
`,Ar=`
|
|
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>;
|
|
@@ -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
|
+
`,Mr=`
|
|
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 ft={name:"areaLighting",props:{},uniforms:{},dependencies:[O],defaultUniforms:{lightCount:0,sampleCount:64,lights:Array.from({length:j},Yt)},uniformTypes:{lightCount:"i32",sampleCount:"i32",lights:[et,j]},bindingLayout:[{name:"areaLighting",group:2},{name:"areaLTCMatrix",group:2},{name:"areaLTCAmplitude",group:2}],source:
|
|
7531
|
+
`;var ft={name:"areaLighting",props:{},uniforms:{},dependencies:[O],defaultUniforms:{lightCount:0,sampleCount:64,lights:Array.from({length:j},Yt)},uniformTypes:{lightCount:"i32",sampleCount:"i32",lights:[et,j]},bindingLayout:[{name:"areaLighting",group:2},{name:"areaLTCMatrix",group:2},{name:"areaLTCAmplitude",group:2}],source:Mr+Ar,vs:ii+ti,fs:ii+ti,getUniforms(e={}){let t=e.lights||[];return{lightCount:Math.min(t.length,j),sampleCount:e.sampleCount||64,lights:Ie(t,e.useByteColors)}}};var Rr=`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
|
+
`,Er=`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 wr=`#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 Tr=`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
|
+
`,Xs=`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
|
+
`,Pr={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:Xs,vs:Tr,fs:Tr,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var ni={NONE:0,REINHARD:1,KHRONOS_PBR_NEUTRAL:2,ACES:3},Nr=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Dr=`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
|
+
`,Js=`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
|
-
`,ut={name:"pbrScene",bindingLayout:[{name:"pbrScene",group:1},{name:"pbr_transmissionFramebufferSampler",group:1}],source:
|
|
11196
|
+
`,ut={name:"pbrScene",bindingLayout:[{name:"pbrScene",group:1},{name:"pbr_transmissionFramebufferSampler",group:1}],source:Js,vs:Dr,fs:Dr,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:ni.KHRONOS_PBR_NEUTRAL,environmentIntensity:1,environmentRotation:Math.PI*.5,environmentMipCount:1,outputEncoding:1,framebufferSize:[1,1],viewMatrix:Nr,projectionMatrix:Nr}};var Fr={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:[O,ft,nt,Pr,ut],source:wr,vs:Rr,fs:Er,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);
|
|
@@ -11351,7 +11351,7 @@ fn heightFog_getSpatialTransmittance(camera: vec3f, position: vec3f, upDirection
|
|
|
11351
11351
|
return transmittance;
|
|
11352
11352
|
}
|
|
11353
11353
|
|
|
11354
|
-
`};var
|
|
11354
|
+
`};var Or={name:"heightFog",dependencies:[pt],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 Br=`
|
|
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
|
+
`,Ur=`
|
|
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 ri={patternType:0,spacing:8,width:.12,angle:Math.PI/4,offset:[0,0]},
|
|
11474
|
+
`;var ri={patternType:0,spacing:8,width:.12,angle:Math.PI/4,offset:[0,0]},kr={name:"patternFill",firstBindingSlot:0,bindingLayout:[{name:"patternFill",group:3}],source:Ur,fs:Br,uniformTypes:{patternType:"i32",spacing:"f32",width:"f32",angle:"f32",offset:"vec2<f32>"},defaultUniforms:ri,getUniforms(e={},t=ri){let i={...ri,...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 oi={coreRadius:.12,coreIntensity:1,haloIntensity:.6,falloff:5},Gr={name:"pointGlow",firstBindingSlot:0,bindingLayout:[{name:"pointGlow",group:3}],uniformTypes:{coreRadius:"f32",coreIntensity:"f32",haloIntensity:"f32",falloff:"f32"},defaultUniforms:oi,getUniforms(e={},t=oi){let i={...oi,...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 zr={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;
|
|
@@ -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 si={enabled:1,sunDirection:[0,.8,.6],sunIntensity:20,haze:1,rayleigh:1,planetRadius:6371e3,exposure:1,groundColor:[.18,.17,.14]},
|
|
11728
|
+
`};var si={enabled:1,sunDirection:[0,.8,.6],sunIntensity:20,haze:1,rayleigh:1,planetRadius:6371e3,exposure:1,groundColor:[.18,.17,.14]},Vr={name:"atmosphere",uniformTypes:{enabled:"f32",sunDirection:"vec3<f32>",sunIntensity:"f32",haze:"f32",rayleigh:"f32",planetRadius:"f32",exposure:"f32",groundColor:"vec3<f32>"},defaultUniforms:si,getUniforms(e={},t=si){return{...si,...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 Hr(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 li={wetness:0,snow:0,puddles:.8,scale:20,snowColor:[.9,.94,.98],skyColor:[.48,.6,.72]},Wr={name:"surfaceWeather",dependencies:[$],uniformTypes:{wetness:"f32",snow:"f32",puddles:"f32",scale:"f32",snowColor:"vec3<f32>",skyColor:"vec3<f32>"},defaultUniforms:li,getUniforms(e={},t=li){return{...li,...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 ci={enabled:0,time:0,radius:8,speed:.6,pulse:.85},
|
|
12044
|
+
`};var ci={enabled:0,time:0,radius:8,speed:.6,pulse:.85},qr={name:"firefly",uniformTypes:{enabled:"f32",time:"f32",radius:"f32",speed:"f32",pulse:"f32"},defaultUniforms:ci,getUniforms(e={},t=ci){return{...ci,...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 jr={name:"globeClouds",dependencies:[dt],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
|
|
12183
|
+
`};return Jr(Qs);})();
|
|
12184
12184
|
return __exports__;
|
|
12185
12185
|
});
|