@luma.gl/shadertools 9.0.11 → 9.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +34 -0
- package/dist/dist.dev.js +201 -75
- package/dist/dist.min.js +9 -9
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +2 -2
- package/dist/lib/shader-module/shader-module-instance.d.ts +2 -1
- package/dist/lib/shader-module/shader-module-instance.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module-instance.js +2 -1
- package/dist.min.js +3758 -0
- package/package.json +2 -2
- package/src/lib/shader-assembly/.assemble-shaders.ts.swp +0 -0
- package/src/lib/shader-module/shader-module-instance.ts +4 -1
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var jn=Object.create;var ue=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var eo=(t,e,r)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var to=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ro=(t,e)=>{for(var r in e)ue(t,r,{get:e[r],enumerable:!0})},ve=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Kn(e))!Jn.call(t,o)&&o!==r&&ue(t,o,{get:()=>e[o],enumerable:!(n=$n(e,o))||n.enumerable});return t},Ae=(t,e,r)=>(ve(t,e,"default"),r&&ve(r,e,"default")),or=(t,e,r)=>(r=t!=null?jn(Zn(t)):{},ve(e||!t||!t.__esModule?ue(r,"default",{value:t,enumerable:!0}):r,t)),no=t=>ve(ue({},"__esModule",{value:!0}),t);var ir=(t,e,r)=>(eo(t,typeof e!="symbol"?e+"":e,r),r);var $e=to((
|
|
7
|
+
"use strict";var __exports__=(()=>{var jn=Object.create;var ue=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var eo=(t,e,r)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var to=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ro=(t,e)=>{for(var r in e)ue(t,r,{get:e[r],enumerable:!0})},ve=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Kn(e))!Jn.call(t,o)&&o!==r&&ue(t,o,{get:()=>e[o],enumerable:!(n=$n(e,o))||n.enumerable});return t},Ae=(t,e,r)=>(ve(t,e,"default"),r&&ve(r,e,"default")),or=(t,e,r)=>(r=t!=null?jn(Zn(t)):{},ve(e||!t||!t.__esModule?ue(r,"default",{value:t,enumerable:!0}):r,t)),no=t=>ve(ue({},"__esModule",{value:!0}),t);var ir=(t,e,r)=>(eo(t,typeof e!="symbol"?e+"":e,r),r);var $e=to((Ri,sr)=>{sr.exports=globalThis.luma});var xe={};ro(xe,{ShaderAssembler:()=>pe,ShaderModuleInstance:()=>C,_ShaderModuleInstance:()=>C,_getDependencyGraph:()=>be,_resolveModules:()=>re,_warp:()=>ce,assembleShaderPairGLSL:()=>Pe,brightnessContrast:()=>Gr,bulgePinch:()=>ln,capitalize:()=>K,colorHalftone:()=>rn,combineInjects:()=>mr,convertToVec4:()=>it,denoise:()=>Hr,dirlight:()=>Qt,dirlight1:()=>Qn,dotScreen:()=>nn,edgeWork:()=>on,fp32:()=>Ur,fp64:()=>pn,fp64arithmetic:()=>Ht,fxaa:()=>un,generateShaderForModule:()=>Ir,geometry1:()=>dn,getPassthroughFS:()=>Nr,getQualifierDetails:()=>kr,getShaderInfo:()=>ye,getShaderLayoutFromWGSL:()=>Or,glsl:()=>ar,gouraudLighting:()=>Vn,gouraudMaterial:()=>Bt,hexagonalPixelate:()=>sn,hueSaturation:()=>Wr,ink:()=>an,lighting:()=>Q,lights1:()=>te,magnify:()=>cn,noise:()=>jr,normalizeShaderModule:()=>Sr,pbr:()=>Wn,pbrMaterial:()=>qr,phongLighting:()=>qn,phongMaterial:()=>Vt,picking:()=>zr,project1:()=>je,random:()=>B,sepia:()=>$r,swirl:()=>fn,tiltShift:()=>Jr,triangleBlur:()=>en,typeToChannelCount:()=>Tr,typeToChannelSuffix:()=>Er,vibrance:()=>Kr,vignette:()=>Zr,zoomBlur:()=>tn});Ae(xe,or($e(),1));var ar=t=>`${t}`;function z(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var Ke={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function lr(t){let e={};for(let[r,n]of Object.entries(t))e[r]=oo(n);return e}function fr(t,e,r){let n={};for(let[o,i]of Object.entries(e))t&&o in t&&!i.private?(i.validate&&z(i.validate(t[o],i),`${r}: invalid ${o}`),n[o]=t[o]):n[o]=i.value;return n}function oo(t){let e=cr(t);if(e!=="object")return{value:t,...Ke[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Ke[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=cr(t.value),{...t,...Ke[e],type:e}):{type:"object",value:null};throw new Error("props")}function cr(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var ur=`#ifdef MODULE_LOGDEPTH
|
|
8
8
|
logdepth_adjustPosition(gl_Position);
|
|
9
9
|
#endif
|
|
10
10
|
`,_r=`#ifdef MODULE_MATERIAL
|
|
@@ -26,7 +26,7 @@ logdepth_setFragDepth();
|
|
|
26
26
|
`;var io={vertex:ur,fragment:_r},hr=/void\s+main\s*\([^)]*\)\s*\{\n?/,pr=/}\n?[^{}]*$/,Ze=[],_e="__LUMA_INJECT_DECLARATIONS__";function dr(t){let e={vertex:{},fragment:{}};for(let r in t){let n=t[r],o=so(r);typeof n=="string"&&(n={order:0,injection:n}),e[o][r]=n}return e}function so(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function he(t,e,r,n=!1){let o=e==="vertex";for(let i in r){let a=r[i];a.sort((u,h)=>u.order-h.order),Ze.length=a.length;for(let u=0,h=a.length;u<h;++u)Ze[u]=a[u].injection;let f=`${Ze.join(`
|
|
27
27
|
`)}
|
|
28
28
|
`;switch(i){case"vs:#decl":o&&(t=t.replace(_e,f));break;case"vs:#main-start":o&&(t=t.replace(hr,u=>u+f));break;case"vs:#main-end":o&&(t=t.replace(pr,u=>f+u));break;case"fs:#decl":o||(t=t.replace(_e,f));break;case"fs:#main-start":o||(t=t.replace(hr,u=>u+f));break;case"fs:#main-end":o||(t=t.replace(pr,u=>f+u));break;default:t=t.replace(i,u=>u+f)}}return t=t.replace(_e,""),n&&(t=t.replace(/\}\s*$/,i=>i+io[e])),t}function mr(t){let e={};return z(Array.isArray(t)&&t.length>1),t.forEach(r=>{for(let n in r)e[n]=e[n]?`${e[n]}
|
|
29
|
-
${r[n]}`:r[n]}),e}var ao=1,C=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof C)return r;z(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${ao++}`);let n=new C(r);return n.dependencies=C.instantiateModules(r.dependencies||[]),n})}constructor(e){let{name:r,vs:n,fs:o,dependencies:i=[],
|
|
29
|
+
${r[n]}`:r[n]}),e}var ao=1,C=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof C)return r;z(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${ao++}`);let n=new C(r);return n.dependencies=C.instantiateModules(r.dependencies||[]),n})}constructor(e){let{name:r,vs:n,fs:o,dependencies:i=[],uniformTypes:a={},uniformPropTypes:f={},getUniforms:u,deprecations:h=[],defines:p={},inject:d={}}=e;z(typeof r=="string"),this.name=r,this.vs=n,this.fs=o,this.getModuleUniforms=u,this.dependencies=C.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(h),this.defines=p,this.injections=dr(d),this.uniformTypes=a,f&&(this.uniforms=lr(f))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:z(!1)}let n=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
|
|
30
30
|
|
|
31
31
|
#define MODULE_${n}
|
|
32
32
|
${r}
|
|
@@ -2461,7 +2461,7 @@ return geometry_vPosition;
|
|
|
2461
2461
|
vec3 geometry_getNormal() {
|
|
2462
2462
|
return geometry_vNormal;
|
|
2463
2463
|
}
|
|
2464
|
-
`,dn={name:"geometry",vs:si,fs:ai};var Ta=1/Math.PI*180,Ma=1/180*Math.PI,ci={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ci}};var O=globalThis.mathgl.config;function mn(t,{precision:e=O.precision}={}){return t=li(t),"".concat(parseFloat(t.toPrecision(e)))}function Be(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wt(t,e,r){let n=O.EPSILON;r&&(O.EPSILON=r);try{if(t===e)return!0;if(Be(t)&&Be(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Wt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=n}}function li(t){return Math.round(t/O.EPSILON)*O.EPSILON}function fi(t){function e(){var r=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}var Ve=class extends fi(Array){clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Be(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mn(this[n],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(r,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Wt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof r=="number"?r:r[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function ui(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function gn(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(JSON.stringify(t)));return t}function qe(t,e,r=""){if(O.debug&&!ui(t,e))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return t}var H=typeof Float32Array<"u"?Float32Array:Array;var Ua=Math.PI/180;function _i(){let t=new H(2);return H!=Float32Array&&(t[0]=0,t[1]=0),t}function An(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var za=function(){let t=_i();return function(e,r,n,o,i,a){let f,u;for(r||(r=2),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],i(t,t,a),e[f]=t[0],e[f+1]=t[1];return e}}();function bn(t,e,r){let n=e[0],o=e[1],i=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/i,t[1]=(r[1]*n+r[5]*o)/i,t}function yn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i||1;return t[0]=(r[0]*n+r[4]*o+r[8]*i)/a,t[1]=(r[1]*n+r[5]*o+r[9]*i)/a,t[2]=(r[2]*n+r[6]*o+r[10]*i)/a,t}function hi(){let t=new H(3);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Pn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/a,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}var Xa=function(){let t=hi();return function(e,r,n,o,i,a){let f,u;for(r||(r=3),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2];return e}}();var Ge=class extends Ve{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=" ".concat(this[n*this.RANK+r])}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=" ".concat(this[r])}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=gn(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function pi(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wn(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],i=e[6],a=e[7],f=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=f}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ln(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],f=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=r*f-n*a,y=r*u-o*a,P=r*h-i*a,b=n*u-o*f,S=n*h-i*f,k=o*h-i*u,F=p*g-d*w,M=p*A-m*w,N=p*L-x*w,I=d*A-m*g,U=d*L-x*g,R=m*L-x*A,E=v*R-y*U+P*I+b*N-S*M+k*F;return E?(E=1/E,t[0]=(f*R-u*U+h*I)*E,t[1]=(o*U-n*R-i*I)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*R-h*M)*E,t[5]=(r*R-o*N+i*M)*E,t[6]=(A*P-w*k-L*y)*E,t[7]=(p*k-m*P+x*y)*E,t[8]=(a*U-f*N+h*F)*E,t[9]=(n*N-r*U-i*F)*E,t[10]=(w*S-g*P+L*v)*E,t[11]=(d*P-p*S-x*v)*E,t[12]=(f*M-a*I-u*F)*E,t[13]=(r*I-n*M+o*F)*E,t[14]=(g*y-w*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function Sn(t){let e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],f=t[6],u=t[7],h=t[8],p=t[9],d=t[10],m=t[11],x=t[12],w=t[13],g=t[14],A=t[15],L=e*a-r*i,v=e*f-n*i,y=r*f-n*a,P=h*w-p*x,b=h*g-d*x,S=p*g-d*w,k=e*S-r*b+n*P,F=i*S-a*b+f*P,M=h*y-p*v+d*L,N=x*y-w*v+g*L;return u*k-o*F+A*M-m*N}function $t(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=r[0],P=r[1],b=r[2],S=r[3];return t[0]=y*n+P*f+b*d+S*g,t[1]=y*o+P*u+b*m+S*A,t[2]=y*i+P*h+b*x+S*L,t[3]=y*a+P*p+b*w+S*v,y=r[4],P=r[5],b=r[6],S=r[7],t[4]=y*n+P*f+b*d+S*g,t[5]=y*o+P*u+b*m+S*A,t[6]=y*i+P*h+b*x+S*L,t[7]=y*a+P*p+b*w+S*v,y=r[8],P=r[9],b=r[10],S=r[11],t[8]=y*n+P*f+b*d+S*g,t[9]=y*o+P*u+b*m+S*A,t[10]=y*i+P*h+b*x+S*L,t[11]=y*a+P*p+b*w+S*v,y=r[12],P=r[13],b=r[14],S=r[15],t[12]=y*n+P*f+b*d+S*g,t[13]=y*o+P*u+b*m+S*A,t[14]=y*i+P*h+b*x+S*L,t[15]=y*a+P*p+b*w+S*v,t}function kn(t,e,r){let n=r[0],o=r[1],i=r[2],a,f,u,h,p,d,m,x,w,g,A,L;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],f=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=f,t[2]=u,t[3]=h,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=w,t[9]=g,t[10]=A,t[11]=L,t[12]=a*n+p*o+w*i+e[12],t[13]=f*n+d*o+g*i+e[13],t[14]=u*n+m*o+A*i+e[14],t[15]=h*n+x*o+L*i+e[15]),t}function Nn(t,e,r){let n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function En(t,e,r,n){let o=n[0],i=n[1],a=n[2],f=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,S,k,F,M,N,I,U,R,E,fe;return f<1e-6?null:(f=1/f,o*=f,i*=f,a*=f,h=Math.sin(r),u=Math.cos(r),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],S=e[11],k=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,N=o*i*p-a*h,I=i*i*p+u,U=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,fe=a*a*p+u,t[0]=d*k+g*F+y*M,t[1]=m*k+A*F+P*M,t[2]=x*k+L*F+b*M,t[3]=w*k+v*F+S*M,t[4]=d*N+g*I+y*U,t[5]=m*N+A*I+P*U,t[6]=x*N+L*I+b*U,t[7]=w*N+v*I+S*U,t[8]=d*R+g*E+y*fe,t[9]=m*R+A*E+P*fe,t[10]=x*R+L*E+b*fe,t[11]=w*R+v*E+S*fe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Tn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[4],a=e[5],f=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+h*n,t[5]=a*o+p*n,t[6]=f*o+d*n,t[7]=u*o+m*n,t[8]=h*o-i*n,t[9]=p*o-a*n,t[10]=d*o-f*n,t[11]=m*o-u*n,t}function Mn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-h*n,t[1]=a*o-p*n,t[2]=f*o-d*n,t[3]=u*o-m*n,t[8]=i*n+h*o,t[9]=a*n+p*o,t[10]=f*n+d*o,t[11]=u*n+m*o,t}function Fn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+h*n,t[1]=a*o+p*n,t[2]=f*o+d*n,t[3]=u*o+m*n,t[4]=h*o-i*n,t[5]=p*o-a*n,t[6]=d*o-f*n,t[7]=m*o-u*n,t}function In(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=r+r,f=n+n,u=o+o,h=r*a,p=n*a,d=n*f,m=o*a,x=o*f,w=o*u,g=i*a,A=i*f,L=i*u;return t[0]=1-d-w,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-h-w,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-h-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cn(t,e,r,n,o,i,a){let f=1/(r-e),u=1/(o-n),h=1/(i-a);return t[0]=i*2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(r+e)*f,t[9]=(o+n)*u,t[10]=(a+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*h,t[15]=0,t}function di(t,e,r,n,o){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(n-o);t[10]=(o+n)*a,t[14]=2*o*n*a}else t[10]=-1,t[14]=-2*n;return t}var Rn=di;function mi(t,e,r,n,o,i,a){let f=1/(e-r),u=1/(n-o),h=1/(i-a);return t[0]=-2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*f,t[13]=(o+n)*u,t[14]=(a+i)*h,t[15]=1,t}var On=mi;function Un(t,e,r,n){let o,i,a,f,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],y=n[2],P=r[0],b=r[1],S=r[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?pi(t):(d=w-P,m=g-b,x=A-S,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,f=L*m-v*d,o=Math.sqrt(i*i+a*a+f*f),o?(o=1/o,i*=o,a*=o,f*=o):(i=0,a=0,f=0),u=m*f-x*a,h=x*i-d*f,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=h,t[6]=m,t[7]=0,t[8]=f,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*w+a*g+f*A),t[13]=-(u*w+h*g+p*A),t[14]=-(d*w+m*g+x*A),t[15]=1,t)}function gi(){let t=new H(4);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zn(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*i+r[12]*a,t[1]=r[1]*n+r[5]*o+r[9]*i+r[13]*a,t[2]=r[2]*n+r[6]*o+r[10]*i+r[14]*a,t[3]=r[3]*n+r[7]*o+r[11]*i+r[15]*a,t}var Wa=function(){let t=gi();return function(e,r,n,o,i,a){let f,u;for(r||(r=4),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],t[3]=e[f+3],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2],e[f+3]=t[3];return e}}();var Jt;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Jt||(Jt={}));var xi=45*Math.PI/180,vi=1,Kt=.1,Zt=500,Ai=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Ge{static get IDENTITY(){return yi()}static get ZERO(){return bi()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jt}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=f,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=r,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=f,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Ai)}fromObject(e){return this.check()}fromQuaternion(e){return In(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return f===1/0?Pi(this,r,n,o,i,a):Cn(this,r,n,o,i,a,f),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Un(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return On(this,r,n,o,i,a,f),this.check()}orthographic(e){let{fovy:r=xi,aspect:n=vi,focalDistance:o=1,near:i=Kt,far:a=Zt}=e;Dn(r);let f=r/2,u=o*Math.tan(f),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Dn(r),Rn(this,r,n,o,i),this.check()}determinant(){return Sn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return wn(this,this),this.check()}invert(){return Ln(this,this),this.check()}multiplyLeft(e){return $t(this,e,this),this.check()}multiplyRight(e){return $t(this,this,e),this.check()}rotateX(e){return Tn(this,this,e),this.check()}rotateY(e){return Mn(this,this,e),this.check()}rotateZ(e){return Fn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return En(this,this,e,r),this.check()}scale(e){return Nn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kn(this,this,e),this.check()}transform(e,r){return e.length===4?(r=zn(r||[-0,-0,-0,-0],e,this),qe(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=An(r||[-0,-0],e,this);break;case 3:o=Pn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=bn(r||[-0,-0],e,this);break;case 3:n=yn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},He,We;function bi(){return He||(He=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(He)),He}function yi(){return We||(We=new ee,Object.freeze(We)),We}function Dn(t){if(t>Math.PI*2)throw Error("expected radians")}function Pi(t,e,r,n,o,i){let a=2*i/(r-e),f=2*i/(o-n),u=(r+e)/(r-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=f,t[6]=0,t[7]=0,t[8]=u,t[9]=h,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],wi={modelMatrix:er,viewMatrix:er,projectionMatrix:er,cameraPositionWorld:[0,0,0]};function Li(t=wi,e={}){let r={};return t.modelMatrix!==void 0&&(r.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(r.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(r.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(r.cameraPositionWorld=t.cameraPositionWorld),(t.projectionMatrix!==void 0||t.viewMatrix!==void 0)&&(r.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),r}var Yn=`varying vec4 project_vPositionWorld;
|
|
2464
|
+
`,dn={name:"geometry",vs:si,fs:ai};var Ea=1/Math.PI*180,Ta=1/180*Math.PI,ci={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ci}};var O=globalThis.mathgl.config;function mn(t,{precision:e=O.precision}={}){return t=li(t),`${parseFloat(t.toPrecision(e))}`}function Be(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wt(t,e,r){let n=O.EPSILON;r&&(O.EPSILON=r);try{if(t===e)return!0;if(Be(t)&&Be(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Wt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=n}}function li(t){return Math.round(t/O.EPSILON)*O.EPSILON}var Ve=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Be(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mn(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Wt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof r=="number"?r:r[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function fi(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function gn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function qe(t,e,r=""){if(O.debug&&!fi(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}var H=typeof Float32Array<"u"?Float32Array:Array;var Oa=Math.PI/180;function ui(){let t=new H(2);return H!=Float32Array&&(t[0]=0,t[1]=0),t}function An(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var Ua=function(){let t=ui();return function(e,r,n,o,i,a){let f,u;for(r||(r=2),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],i(t,t,a),e[f]=t[0],e[f+1]=t[1];return e}}();function bn(t,e,r){let n=e[0],o=e[1],i=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/i,t[1]=(r[1]*n+r[5]*o)/i,t}function yn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i||1;return t[0]=(r[0]*n+r[4]*o+r[8]*i)/a,t[1]=(r[1]*n+r[5]*o+r[9]*i)/a,t[2]=(r[2]*n+r[6]*o+r[10]*i)/a,t}function _i(){let t=new H(3);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Pn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/a,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}var Ya=function(){let t=_i();return function(e,r,n,o,i,a){let f,u;for(r||(r=3),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2];return e}}();var Ge=class extends Ve{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=gn(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function hi(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wn(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],i=e[6],a=e[7],f=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=f}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ln(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],f=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=r*f-n*a,y=r*u-o*a,P=r*h-i*a,b=n*u-o*f,S=n*h-i*f,k=o*h-i*u,F=p*g-d*w,M=p*A-m*w,N=p*L-x*w,I=d*A-m*g,U=d*L-x*g,R=m*L-x*A,E=v*R-y*U+P*I+b*N-S*M+k*F;return E?(E=1/E,t[0]=(f*R-u*U+h*I)*E,t[1]=(o*U-n*R-i*I)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*R-h*M)*E,t[5]=(r*R-o*N+i*M)*E,t[6]=(A*P-w*k-L*y)*E,t[7]=(p*k-m*P+x*y)*E,t[8]=(a*U-f*N+h*F)*E,t[9]=(n*N-r*U-i*F)*E,t[10]=(w*S-g*P+L*v)*E,t[11]=(d*P-p*S-x*v)*E,t[12]=(f*M-a*I-u*F)*E,t[13]=(r*I-n*M+o*F)*E,t[14]=(g*y-w*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function Sn(t){let e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],f=t[6],u=t[7],h=t[8],p=t[9],d=t[10],m=t[11],x=t[12],w=t[13],g=t[14],A=t[15],L=e*a-r*i,v=e*f-n*i,y=r*f-n*a,P=h*w-p*x,b=h*g-d*x,S=p*g-d*w,k=e*S-r*b+n*P,F=i*S-a*b+f*P,M=h*y-p*v+d*L,N=x*y-w*v+g*L;return u*k-o*F+A*M-m*N}function $t(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=r[0],P=r[1],b=r[2],S=r[3];return t[0]=y*n+P*f+b*d+S*g,t[1]=y*o+P*u+b*m+S*A,t[2]=y*i+P*h+b*x+S*L,t[3]=y*a+P*p+b*w+S*v,y=r[4],P=r[5],b=r[6],S=r[7],t[4]=y*n+P*f+b*d+S*g,t[5]=y*o+P*u+b*m+S*A,t[6]=y*i+P*h+b*x+S*L,t[7]=y*a+P*p+b*w+S*v,y=r[8],P=r[9],b=r[10],S=r[11],t[8]=y*n+P*f+b*d+S*g,t[9]=y*o+P*u+b*m+S*A,t[10]=y*i+P*h+b*x+S*L,t[11]=y*a+P*p+b*w+S*v,y=r[12],P=r[13],b=r[14],S=r[15],t[12]=y*n+P*f+b*d+S*g,t[13]=y*o+P*u+b*m+S*A,t[14]=y*i+P*h+b*x+S*L,t[15]=y*a+P*p+b*w+S*v,t}function kn(t,e,r){let n=r[0],o=r[1],i=r[2],a,f,u,h,p,d,m,x,w,g,A,L;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],f=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=f,t[2]=u,t[3]=h,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=w,t[9]=g,t[10]=A,t[11]=L,t[12]=a*n+p*o+w*i+e[12],t[13]=f*n+d*o+g*i+e[13],t[14]=u*n+m*o+A*i+e[14],t[15]=h*n+x*o+L*i+e[15]),t}function Nn(t,e,r){let n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function En(t,e,r,n){let o=n[0],i=n[1],a=n[2],f=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,S,k,F,M,N,I,U,R,E,fe;return f<1e-6?null:(f=1/f,o*=f,i*=f,a*=f,h=Math.sin(r),u=Math.cos(r),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],S=e[11],k=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,N=o*i*p-a*h,I=i*i*p+u,U=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,fe=a*a*p+u,t[0]=d*k+g*F+y*M,t[1]=m*k+A*F+P*M,t[2]=x*k+L*F+b*M,t[3]=w*k+v*F+S*M,t[4]=d*N+g*I+y*U,t[5]=m*N+A*I+P*U,t[6]=x*N+L*I+b*U,t[7]=w*N+v*I+S*U,t[8]=d*R+g*E+y*fe,t[9]=m*R+A*E+P*fe,t[10]=x*R+L*E+b*fe,t[11]=w*R+v*E+S*fe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Tn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[4],a=e[5],f=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+h*n,t[5]=a*o+p*n,t[6]=f*o+d*n,t[7]=u*o+m*n,t[8]=h*o-i*n,t[9]=p*o-a*n,t[10]=d*o-f*n,t[11]=m*o-u*n,t}function Mn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-h*n,t[1]=a*o-p*n,t[2]=f*o-d*n,t[3]=u*o-m*n,t[8]=i*n+h*o,t[9]=a*n+p*o,t[10]=f*n+d*o,t[11]=u*n+m*o,t}function Fn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+h*n,t[1]=a*o+p*n,t[2]=f*o+d*n,t[3]=u*o+m*n,t[4]=h*o-i*n,t[5]=p*o-a*n,t[6]=d*o-f*n,t[7]=m*o-u*n,t}function In(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=r+r,f=n+n,u=o+o,h=r*a,p=n*a,d=n*f,m=o*a,x=o*f,w=o*u,g=i*a,A=i*f,L=i*u;return t[0]=1-d-w,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-h-w,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-h-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cn(t,e,r,n,o,i,a){let f=1/(r-e),u=1/(o-n),h=1/(i-a);return t[0]=i*2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(r+e)*f,t[9]=(o+n)*u,t[10]=(a+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*h,t[15]=0,t}function pi(t,e,r,n,o){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(n-o);t[10]=(o+n)*a,t[14]=2*o*n*a}else t[10]=-1,t[14]=-2*n;return t}var Rn=pi;function di(t,e,r,n,o,i,a){let f=1/(e-r),u=1/(n-o),h=1/(i-a);return t[0]=-2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*f,t[13]=(o+n)*u,t[14]=(a+i)*h,t[15]=1,t}var On=di;function Un(t,e,r,n){let o,i,a,f,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],y=n[2],P=r[0],b=r[1],S=r[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?hi(t):(d=w-P,m=g-b,x=A-S,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,f=L*m-v*d,o=Math.sqrt(i*i+a*a+f*f),o?(o=1/o,i*=o,a*=o,f*=o):(i=0,a=0,f=0),u=m*f-x*a,h=x*i-d*f,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=h,t[6]=m,t[7]=0,t[8]=f,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*w+a*g+f*A),t[13]=-(u*w+h*g+p*A),t[14]=-(d*w+m*g+x*A),t[15]=1,t)}function mi(){let t=new H(4);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zn(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*i+r[12]*a,t[1]=r[1]*n+r[5]*o+r[9]*i+r[13]*a,t[2]=r[2]*n+r[6]*o+r[10]*i+r[14]*a,t[3]=r[3]*n+r[7]*o+r[11]*i+r[15]*a,t}var Ha=function(){let t=mi();return function(e,r,n,o,i,a){let f,u;for(r||(r=4),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],t[3]=e[f+3],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2],e[f+3]=t[3];return e}}();var Jt;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Jt||(Jt={}));var gi=45*Math.PI/180,xi=1,Kt=.1,Zt=500,vi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Ge{static get IDENTITY(){return bi()}static get ZERO(){return Ai()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jt}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=f,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=r,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=f,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(vi)}fromObject(e){return this.check()}fromQuaternion(e){return In(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return f===1/0?yi(this,r,n,o,i,a):Cn(this,r,n,o,i,a,f),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Un(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return On(this,r,n,o,i,a,f),this.check()}orthographic(e){let{fovy:r=gi,aspect:n=xi,focalDistance:o=1,near:i=Kt,far:a=Zt}=e;Dn(r);let f=r/2,u=o*Math.tan(f),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Dn(r),Rn(this,r,n,o,i),this.check()}determinant(){return Sn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return wn(this,this),this.check()}invert(){return Ln(this,this),this.check()}multiplyLeft(e){return $t(this,e,this),this.check()}multiplyRight(e){return $t(this,this,e),this.check()}rotateX(e){return Tn(this,this,e),this.check()}rotateY(e){return Mn(this,this,e),this.check()}rotateZ(e){return Fn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return En(this,this,e,r),this.check()}scale(e){return Nn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kn(this,this,e),this.check()}transform(e,r){return e.length===4?(r=zn(r||[-0,-0,-0,-0],e,this),qe(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=An(r||[-0,-0],e,this);break;case 3:o=Pn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=bn(r||[-0,-0],e,this);break;case 3:n=yn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},He,We;function Ai(){return He||(He=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(He)),He}function bi(){return We||(We=new ee,Object.freeze(We)),We}function Dn(t){if(t>Math.PI*2)throw Error("expected radians")}function yi(t,e,r,n,o,i){let a=2*i/(r-e),f=2*i/(o-n),u=(r+e)/(r-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=f,t[6]=0,t[7]=0,t[8]=u,t[9]=h,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Pi={modelMatrix:er,viewMatrix:er,projectionMatrix:er,cameraPositionWorld:[0,0,0]};function wi(t=Pi,e={}){let r={};return t.modelMatrix!==void 0&&(r.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(r.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(r.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(r.cameraPositionWorld=t.cameraPositionWorld),(t.projectionMatrix!==void 0||t.viewMatrix!==void 0)&&(r.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),r}var Yn=`varying vec4 project_vPositionWorld;
|
|
2465
2465
|
varying vec3 project_vNormalWorld;
|
|
2466
2466
|
vec4 project_getPosition_World() {
|
|
2467
2467
|
return project_vPositionWorld;
|
|
@@ -2469,7 +2469,7 @@ return project_vPositionWorld;
|
|
|
2469
2469
|
vec3 project_getNormal_World() {
|
|
2470
2470
|
return project_vNormalWorld;
|
|
2471
2471
|
}
|
|
2472
|
-
`,
|
|
2472
|
+
`,Li=`${Yn}
|
|
2473
2473
|
|
|
2474
2474
|
// Unprefixed uniforms
|
|
2475
2475
|
uniform mat4 modelMatrix;
|
|
@@ -2522,8 +2522,8 @@ vec4 project_view_to_clipspace(vec3 position) {
|
|
|
2522
2522
|
vec4 project_to_clipspace(vec3 position) {
|
|
2523
2523
|
return viewProjectionMatrix * vec4(position, 1.);
|
|
2524
2524
|
}
|
|
2525
|
-
`,
|
|
2526
|
-
${Yn}`,je={name:"project",getUniforms:
|
|
2525
|
+
`,Si=`
|
|
2526
|
+
${Yn}`,je={name:"project",getUniforms:wi,vs:Li,fs:Si};var tr=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
2527
2527
|
struct AmbientLight {
|
|
2528
2528
|
vec3 color;
|
|
2529
2529
|
};
|
|
@@ -2548,13 +2548,13 @@ return pointLight.attenuation.x
|
|
|
2548
2548
|
+ pointLight.attenuation.z * distance * distance;
|
|
2549
2549
|
}
|
|
2550
2550
|
#endif
|
|
2551
|
-
`;var
|
|
2551
|
+
`;var ki={lightSources:{}};function rr(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(n=>n*r/255)}function Ni({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let n={};return t?n["lighting_uAmbientLight.color"]=rr(t):n["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{n[`lighting_uPointLight[${i}].color`]=rr(o),n[`lighting_uPointLight[${i}].position`]=o.position,n[`lighting_uPointLight[${i}].attenuation`]=o.attenuation||[1,0,0]}),n.lighting_uPointLightCount=e.length,r.forEach((o,i)=>{n[`lighting_uDirectionalLight[${i}].color`]=rr(o),n[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),n.lighting_uDirectionalLightCount=r.length,n}function Xn(t=ki){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:n}=t.lightSources||{};return e||r&&r.length>0||n&&n.length>0?Object.assign({},Ni({ambientLight:e,pointLights:r,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return Xn({lightSources:e})}return{}}var te={name:"lights",vs:tr,fs:tr,getUniforms:Xn,defines:{MAX_LIGHTS:3}};var Ei={lightDirection:new Float32Array([1,1,2])};function Ti(t=Ei){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var Mi=`uniform vec3 dirlight_uLightDirection;
|
|
2552
2552
|
vec4 dirlight_filterColor(vec4 color) {
|
|
2553
2553
|
vec3 normal = project_getNormal_World();
|
|
2554
2554
|
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
2555
2555
|
return vec4(color.rgb * d, color.a);
|
|
2556
2556
|
}
|
|
2557
|
-
`,Qn={name:"dirlight",fs:
|
|
2557
|
+
`,Qn={name:"dirlight",fs:Mi,getUniforms:Ti,dependencies:[je]};var nr=`uniform float lighting_uAmbient;
|
|
2558
2558
|
uniform float lighting_uDiffuse;
|
|
2559
2559
|
uniform float lighting_uShininess;
|
|
2560
2560
|
uniform vec3 lighting_uSpecularColor;
|
|
@@ -2617,7 +2617,7 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
|
|
|
2617
2617
|
}
|
|
2618
2618
|
return lightColor;
|
|
2619
2619
|
}
|
|
2620
|
-
`;var
|
|
2620
|
+
`;var Fi={};function Ii(t){let{ambient:e=.35,diffuse:r=.6,shininess:n=32,specularColor:o=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:n,lighting_uSpecularColor:o.map(i=>i/255)}}function Bn(t=Fi){if(!("material"in t))return{};let{material:e}=t;return e?Ii(e):{lighting_uEnabled:!1}}var Vn={name:"gouraud-lighting",dependencies:[te],vs:nr,defines:{LIGHTING_VERTEX:1},getUniforms:Bn},qn={name:"phong-lighting",dependencies:[te],fs:nr,defines:{LIGHTING_FRAGMENT:1},getUniforms:Bn};var Gn=`uniform mat4 u_MVPMatrix;
|
|
2621
2621
|
uniform mat4 u_ModelMatrix;
|
|
2622
2622
|
uniform mat4 u_NormalMatrix;
|
|
2623
2623
|
out vec3 pbr_vPosition;
|
package/dist/index.cjs
CHANGED
|
@@ -307,7 +307,7 @@ var ShaderModuleInstance = class {
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
constructor(props) {
|
|
310
|
-
const { name, vs: vs6, fs: fs28, dependencies = [], uniformPropTypes = {}, getUniforms: getUniforms9, deprecations = [], defines = {}, inject = {} } = props;
|
|
310
|
+
const { name, vs: vs6, fs: fs28, dependencies = [], uniformTypes = {}, uniformPropTypes = {}, getUniforms: getUniforms9, deprecations = [], defines = {}, inject = {} } = props;
|
|
311
311
|
assert(typeof name === "string");
|
|
312
312
|
this.name = name;
|
|
313
313
|
this.vs = vs6;
|
|
@@ -317,6 +317,7 @@ var ShaderModuleInstance = class {
|
|
|
317
317
|
this.deprecations = this._parseDeprecationDefinitions(deprecations);
|
|
318
318
|
this.defines = defines;
|
|
319
319
|
this.injections = normalizeInjections(inject);
|
|
320
|
+
this.uniformTypes = uniformTypes;
|
|
320
321
|
if (uniformPropTypes) {
|
|
321
322
|
this.uniforms = makePropValidators(uniformPropTypes);
|
|
322
323
|
}
|