@openglobus/og
Version: 
[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely fr
1 lines • 958 kB
JavaScript
const Wi=2*Math.PI,go=Math.PI/2,sr=Number.MAX_VALUE||17976931348623157e292,_n=Math.log(2),Ee=2147483647,yt=549755748352,Tt=-549755748352,U=Math.PI/180,Q=180/Math.PI,Hr=2*Q,ie=.5*U,po=Math.sqrt(.5),mo=1e-5,re=1e-10,rr=1e-12,nr=1e-14;function $i(e,t,i){return Math.max(t,Math.min(e,i))}function Xi(e){return!(e&e-1)}function Ye(e,t=4096){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1>t?t:e+1}function Oi(e=0,t=1){return Math.floor(Math.random()*(t-e))+e}function vo(e,t){return(e%t+t)%t}function Ve(e){const t=vo(e,Wi);return Math.abs(t)<nr&&Math.abs(e)>nr?Wi:t}function ei(e){const t=Math.abs(e);return t-Math.floor(t)}function yo(e,t,i){return i+e*(t-i)}function Os(e){return e*e*e}function Ns(e){return e*e}function or(e){return e-360*Math.floor(e/360)}const Mc=Object.freeze(Object.defineProperty({__proto__:null,ARCSECONDS_TO_RADIANS:484813681109536e-20,DEG2RAD:function(e){return e*U},DEGREES:Q,DEGREES_DOUBLE:Hr,DEGREES_TO_HOURS:1/15,EPS1:.1,EPS10:re,EPS11:1e-11,EPS12:rr,EPS13:1e-13,EPS14:nr,EPS15:1e-15,EPS16:1e-16,EPS17:1e-17,EPS18:1e-18,EPS19:1e-19,EPS2:.01,EPS20:1e-20,EPS3:.001,EPS4:1e-4,EPS5:mo,EPS6:1e-6,EPS7:1e-7,EPS8:1e-8,EPS9:1e-9,HOURS_TO_DEGREES:15,HOURS_TO_RADIANS:.26179938779914946,LOG2:_n,MAX:yt,MAX32:Ee,MAX_FLOAT:sr,MIN:Tt,PI_TWO:go,RAD2DEG:function(e){return e*Q},RADIANS:U,RADIANS_HALF:ie,RADIANS_TO_HOURS:3.819718634205488,SQRT_HALF:po,TWO_PI:Wi,W:3,X:0,Y:1,Z:2,bezier1v:function(e,t,i,s,r){return Os(1-e)*t+3*Ns(1-e)*e*i+3*(1-e)*Ns(e)*s+Os(e)*r},bezier3v:function(e,t,i,s,r){let n=1-e,o=e*e,a=n*n,l=a*n,h=o*e;return t.scaleTo(l).addA(i.scaleTo(3*a*e)).addA(s.scaleTo(3*n*o)).addA(r.scaleTo(h))},clamp:$i,cube:Os,degToDec:function(e,t,i,s){return s?e+t/60+i/3600:-e-t/60-i/3600},exp2:function(e){return Math.pow(2,e)},frac:ei,getAngleBetweenAzimuths:function(e,t){return(((e=Ve(e))-(t=Ve(t)))%360+360+180)%360-180},isPowerOfTwo:Xi,lerp:yo,log:function(e,t){return Math.log(e)/Math.log(t)},log2:function(e){return Math.log(e)/_n},mod:vo,negativePItoPI:function(e){return Ve(e+Math.PI)-Math.PI},nextHighestPowerOfTwo:Ye,norm_lon:function(e){return e>180?(e+180)%360-180:e<-180?(e-180)%360+180:e},pow2i:function(e){return 2<<e-1},random:function(e=0,t=1){return Math.random()*(t-e)+e},randomi:Oi,rev:or,slice:function(e,t,i){return e*(t-i)},solve_iteration:function(e,t,i,s=50){let r=0,n=t;for(let t=0;t<s;t++)if(r=n,n=e(r),Math.abs(n-r)<i)return n;return n},solve_iteration_fixed:function(e,t,i){let s=0,r=t;for(let t=0;t<i;t++)s=r,r=e(s);return r},square:Ns,step:function(e,t){return t<e?0:1},zeroTwoPI:Ve},Symbol.toStringTag,{value:"Module"})),Ra=.5*Math.PI,xo=180/Math.PI,Ma=2*xo,Hs=Math.PI/360,Ba=xo*Ra;class A{constructor(e=0,t=0,i=0){this.lon=0,this.lat=0,this.height=0,this.lon=e,this.lat=t,this.height=i}isZero(){return 0===this.lon&&0===this.lat&&0===this.height}static join(e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];t[i]=new A(s[0],s[1],s[2])}return t}static createFromArray(e){return new A(e[0],e[1],e[2])}static toArray(e){return[e.lon,e.lat,e.height]}toArray(){return A.toArray(this)}static forwardMercator(e,t,i){return new A(e*Ni,Math.log(Math.tan((90+t)*Hs))*qe,i)}static forwardMercatorRes(e,t){return t.lon=e.lon*Ni,t.lat=Math.log(Math.tan((90+e.lat)*Hs))*qe,t.height=e.height,t}static inverseMercator(e,t,i=0){return new A(e*bo,Ma*Math.atan(Math.exp(t*Vr))-Ba,i)}set(e=0,t=0,i=0){return this.lon=e,this.lat=t,this.height=i,this}copy(e){return this.lon=e.lon,this.lat=e.lat,this.height=e.height,this}clone(){return new A(this.lon,this.lat,this.height)}forwardMercator(){return A.forwardMercator(this.lon,this.lat,this.height)}forwardMercatorEPS01(){let e=this.lat;return e>89.9?e=89.9:e<-89.9&&(e=-89.9),new A(this.lon*Ni,Math.log(Math.tan((90+e)*Hs))*qe)}inverseMercator(){return A.inverseMercator(this.lon,this.lat,this.height)}equal(e){return e.height?this.lon===e.lon&&this.lat===e.lat&&this.height===e.height:this.lon===e.lon&&this.lat===e.lat}}const At=20037508.34,Zi=2*At,Vr=Math.PI/At,qe=At/Math.PI,ka=.5*Math.PI,Ni=At/180,bo=180/At,wo=Math.PI/360,fn=Math.PI/180,Ia=180/Math.PI,To=2*At,ii=1/To;function Ki(e){return new A(e.lon*At/180,Math.log(Math.tan((90+e.lat)*wo))*qe,e.height)}function si(e){return e*At/180}function ri(e){return Math.log(Math.tan((90+e)*wo))*qe}function Co(e){return Ia*(2*Math.atan(Math.exp(e*Vr))-ka)}function $e(e,t,i){let s=Zi/(1<<i),r=new A(e*s-20037508.34,At-t*s-s);return new H(r,new A(r.lon+s,r.lat+s))}const ht=Co(At),Ft=-ht,Bc=Object.freeze(Object.defineProperty({__proto__:null,INV_POLE_BY_180:bo,MAX_LAT:ht,MIN_LAT:Ft,ONE_BY_POLE_DOUBLE:ii,PI_BY_POLE:Vr,POLE:At,POLE2:Zi,POLE_BY_180:Ni,POLE_BY_PI:qe,POLE_DOUBLE:To,forward:Ki,forwardArray:function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].forwardMercator());return t},forward_lat:ri,forward_lon:si,getTileExtent:$e,getTileX:function(e,t){return Math.floor((e+180)/360*Math.pow(2,t))},getTileY:function(e,t){return Math.floor(.5*(1-Math.log(Math.tan(e*fn)+1/Math.cos(e*fn))/Math.PI)*Math.pow(2,t))},inverse_lat:Co,inverse_lon:function(e){return 180*e/At}},Symbol.toStringTag,{value:"Module"}));class H{constructor(e=new A,t=new A){this.southWest=e,this.northEast=t}static createFromArray(e){return new H(new A(e[0],e[1]),new A(e[2],e[3]))}static createByCoordinates(e){let t=yt,i=Tt,s=yt,r=Tt;for(let n=0;n<e.length;n++){const o=e[n];o.lon<t&&(t=o.lon),o.lon>i&&(i=o.lon),o.lat<s&&(s=o.lat),o.lat>r&&(r=o.lat)}return new H(new A(t,s),new A(i,r))}static createByCoordinatesArr(e){let t=yt,i=Tt,s=yt,r=Tt;for(let n=0;n<e.length;n++){const o=e[n];o[0]<t&&(t=o[0]),o[0]>i&&(i=o[0]),o[1]<s&&(s=o[1]),o[1]>r&&(r=o[1])}return new H(new A(t,s),new A(i,r))}static fromTile(e,t,i,s=40075016.68,r=40075016.68){const n=1<<i,o=s/n,a=r/n,l=.5*-s+e*o,h=.5*r-t*a,c=l+o;return new H(new A(l,h-a),new A(c,h))}setByCoordinates(e){let t=yt,i=Tt,s=yt,r=Tt;for(let n=0;n<e.length;n++){const o=e[n];o.lon<t&&(t=o.lon),o.lon>i&&(i=o.lon),o.lat<s&&(s=o.lat),o.lat>r&&(r=o.lat)}return this.southWest.lon=t,this.southWest.lat=s,this.northEast.lon=i,this.northEast.lat=r,this}isInside(e){const t=this.southWest,i=this.northEast;return e.lon>=t.lon&&e.lon<=i.lon&&e.lat>=t.lat&&e.lat<=i.lat}overlaps(e){const t=this.southWest,i=this.northEast;return t.lon<=e.northEast.lon&&i.lon>=e.southWest.lon&&t.lat<=e.northEast.lat&&i.lat>=e.southWest.lat}getWidth(){return this.northEast.lon-this.southWest.lon}getHeight(){return this.northEast.lat-this.southWest.lat}clone(){return new H(this.southWest.clone(),this.northEast.clone())}getCenter(){const e=this.southWest,t=this.northEast;return new A(e.lon+.5*(t.lon-e.lon),e.lat+.5*(t.lat-e.lat))}getNorthWest(){return new A(this.southWest.lon,this.northEast.lat)}getNorthEast(){return new A(this.northEast.lon,this.northEast.lat)}getSouthWest(){return new A(this.southWest.lon,this.southWest.lat)}getSouthEast(){return new A(this.northEast.lon,this.southWest.lat)}getNorth(){return this.northEast.lat}getEast(){return this.northEast.lon}getWest(){return this.southWest.lon}getSouth(){return this.southWest.lat}equals(e){return this.southWest.lon===e.southWest.lon&&this.southWest.lat===e.southWest.lat&&this.northEast.lon===e.northEast.lon&&this.northEast.lat===e.northEast.lat}forwardMercator(){return new H(this.southWest.forwardMercator(),this.northEast.forwardMercator())}inverseMercator(){return new H(this.southWest.inverseMercator(),this.northEast.inverseMercator())}getCartesianBounds(e){let t=yt,i=Tt,s=yt,r=Tt,n=yt,o=Tt;const a=[new A(this.southWest.lon,this.southWest.lat),new A(this.southWest.lon,this.northEast.lat),new A(this.northEast.lon,this.northEast.lat),new A(this.northEast.lon,this.southWest.lat)];for(let l=0;l<a.length;l++){const h=e.lonLatToCartesian(a[l]),c=h.x,d=h.y,_=h.z;c<t&&(t=c),c>i&&(i=c),d<s&&(s=d),d>r&&(r=d),_<n&&(n=_),_>o&&(o=_)}return[t,s,n,i,r,o]}toString(){return`[${this.southWest.lon.toFixed(5)}, ${this.southWest.lat.toFixed(5)}, ${this.northEast.lon.toFixed(5)}, ${this.northEast.lat.toFixed(5)}]`}}class Pe{constructor(){this._m=[0,0,0,0,0,0,0,0,0]}set(e){return this._m[0]=e[0],this._m[1]=e[1],this._m[2]=e[2],this._m[3]=e[3],this._m[4]=e[4],this._m[5]=e[5],this._m[6]=e[6],this._m[7]=e[7],this._m[8]=e[8],this}clone(){let e=new Pe;return e.set(this._m),e}copy(e){return this.set(e._m)}transposeTo(){let e=new Pe,t=this._m;return e._m[0]=t[0],e._m[1]=t[3],e._m[2]=t[6],e._m[3]=t[1],e._m[4]=t[4],e._m[5]=t[7],e._m[6]=t[2],e._m[7]=t[5],e._m[8]=t[8],e}setIdentity(){return this._m[0]=1,this._m[1]=0,this._m[2]=0,this._m[3]=0,this._m[4]=1,this._m[5]=0,this._m[6]=0,this._m[7]=0,this._m[8]=1,this}mulVec(e){let t=e.x,i=e.y,s=e.z,r=this._m;return new m(r[0]*t+r[3]*i+r[6]*s,r[1]*t+r[4]*i+r[7]*s,r[2]*t+r[5]*i+r[8]*s)}getMat4(){let e=new st,t=e._m,i=this._m;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=0,t[4]=i[3],t[5]=i[4],t[6]=i[5],t[7]=0,t[8]=i[6],t[9]=i[7],t[10]=i[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,e}}class J{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}static get identity(){return new J(0,0,0,1)}static fromVec(e){return new J(e[0],e[1],e[2],e[3])}toVec3(){return new m(this.x,this.y,this.z)}clone(){return new J(this.x,this.y,this.z,this.w)}equal(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toArray(){return[this.x,this.y,this.z,this.w]}toArray3(){return[this.x,this.y,this.z]}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}addA(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}subA(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}scale(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}affinity(){let e=1/this.w;return this.x*=e,this.y*=e,this.z*=e,this.w=1,this}scaleTo(e){return new J(this.x*e,this.y*e,this.z*e,this.w*e)}getStep(e){return new J(this.x<e?0:1,this.y<e?0:1,this.z<e?0:1,this.w<e?0:1)}getFrac(e){return new J(ei(e.x),ei(e.y),ei(e.z),ei(e.w))}dot(e){return e.x*this.x+e.y*this.y+e.z*this.z+e.w*this.w}isZero(){return!(this.x||this.y||this.z||this.w)}}class st{constructor(){this._m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}static identity(){let e=new st;return e._m[0]=1,e._m[1]=0,e._m[2]=0,e._m[3]=0,e._m[4]=0,e._m[5]=1,e._m[6]=0,e._m[7]=0,e._m[8]=0,e._m[9]=0,e._m[10]=1,e._m[11]=0,e._m[12]=0,e._m[13]=0,e._m[14]=0,e._m[15]=1,e}static getRotationAroundPoint(e,t=m.ZERO,i=m.UP){let s=st.getRotation(e,i),r=(new st).setIdentity().translate(t),n=(new st).setIdentity().translate(t.negateTo());return r.mul(s).mul(n)}static getRotation(e,t=m.UP){return(new st).setRotation(t,e)}getPosition(){return new m(this._m[12],this._m[13],this._m[14])}getScaling(){let e=this._m[0],t=this._m[1],i=this._m[2],s=this._m[4],r=this._m[5],n=this._m[6],o=this._m[8],a=this._m[9],l=this._m[10];return new m(Math.sqrt(e*e+t*t+i*i),Math.sqrt(s*s+r*r+n*n),Math.sqrt(o*o+a*a+l*l))}getQuat(){let e=this.getScaling();const t=[0,0,0,1];let i=1/e.x,s=1/e.y,r=1/e.z,n=this._m[0]*i,o=this._m[1]*s,a=this._m[2]*r,l=this._m[4]*i,h=this._m[5]*s,c=this._m[6]*r,d=this._m[8]*i,_=this._m[9]*s,u=this._m[10]*r,f=n+h+u,g=0;return f>0?(g=2*Math.sqrt(f+1),t[3]=.25*g,t[0]=(c-_)/g,t[1]=(d-a)/g,t[2]=(o-l)/g):n>h&&n>u?(g=2*Math.sqrt(1+n-h-u),t[3]=(c-_)/g,t[0]=.25*g,t[1]=(o+l)/g,t[2]=(d+a)/g):h>u?(g=2*Math.sqrt(1+h-n-u),t[3]=(d-a)/g,t[0]=(o+l)/g,t[1]=.25*g,t[2]=(c+_)/g):(g=2*Math.sqrt(1+u-n-h),t[3]=(o-l)/g,t[0]=(d+a)/g,t[1]=(c+_)/g,t[2]=.25*g),new F(...t)}set(e){return this._m[0]=e[0],this._m[1]=e[1],this._m[2]=e[2],this._m[3]=e[3],this._m[4]=e[4],this._m[5]=e[5],this._m[6]=e[6],this._m[7]=e[7],this._m[8]=e[8],this._m[9]=e[9],this._m[10]=e[10],this._m[11]=e[11],this._m[12]=e[12],this._m[13]=e[13],this._m[14]=e[14],this._m[15]=e[15],this}clone(){let e=new st;return e.set(this._m),e}copy(e){return this.set(e._m)}getMat3(){let e=new Pe,t=this._m,i=e._m;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[4],i[4]=t[5],i[5]=t[6],i[6]=t[8],i[7]=t[9],i[8]=t[10],e}mulVec3(e){let t=e.x,i=e.y,s=e.z;return new m(this._m[0]*t+this._m[4]*i+this._m[8]*s+this._m[12],this._m[1]*t+this._m[5]*i+this._m[9]*s+this._m[13],this._m[2]*t+this._m[6]*i+this._m[10]*s+this._m[14])}mulVec4(e){let t=e.x,i=e.y,s=e.z,r=e.w;return new J(this._m[0]*t+this._m[4]*i+this._m[8]*s+this._m[12]*r,this._m[1]*t+this._m[5]*i+this._m[9]*s+this._m[13]*r,this._m[2]*t+this._m[6]*i+this._m[10]*s+this._m[14]*r,this._m[3]*t+this._m[7]*i+this._m[11]*s+this._m[15]*r)}toInverseMatrix3(){let e=this._m,t=e[0],i=e[1],s=e[2],r=e[4],n=e[5],o=e[6],a=e[8],l=e[9],h=e[10],c=h*n-o*l,d=-h*r+o*a,_=l*r-n*a,u=t*c+i*d+s*_;if(!u)return;u=1/u;let f=new Pe;return f._m[0]=c*u,f._m[1]=(-h*i+s*l)*u,f._m[2]=(o*i-s*n)*u,f._m[3]=d*u,f._m[4]=(h*t-s*a)*u,f._m[5]=(-o*t+s*r)*u,f._m[6]=_*u,f._m[7]=(-l*t+i*a)*u,f._m[8]=(n*t-i*r)*u,f}inverseTo(e=new st){let t=this._m[0],i=this._m[1],s=this._m[2],r=this._m[3],n=this._m[4],o=this._m[5],a=this._m[6],l=this._m[7],h=this._m[8],c=this._m[9],d=this._m[10],_=this._m[11],u=this._m[12],f=this._m[13],g=this._m[14],p=this._m[15],m=t*o-i*n,v=t*a-s*n,y=t*l-r*n,x=i*a-s*o,b=i*l-r*o,w=s*l-r*a,T=h*f-c*u,C=h*g-d*u,A=h*p-_*u,E=c*g-d*f,L=c*p-_*f,P=d*p-_*g,S=1/(m*P-v*L+y*E+x*A-b*C+w*T);return e._m[0]=(o*P-a*L+l*E)*S,e._m[1]=(-i*P+s*L-r*E)*S,e._m[2]=(f*w-g*b+p*x)*S,e._m[3]=(-c*w+d*b-_*x)*S,e._m[4]=(-n*P+a*A-l*C)*S,e._m[5]=(t*P-s*A+r*C)*S,e._m[6]=(-u*w+g*y-p*v)*S,e._m[7]=(h*w-d*y+_*v)*S,e._m[8]=(n*L-o*A+l*T)*S,e._m[9]=(-t*L+i*A-r*T)*S,e._m[10]=(u*b-f*y+p*m)*S,e._m[11]=(-h*b+c*y-_*m)*S,e._m[12]=(-n*E+o*C-a*T)*S,e._m[13]=(t*E-i*C+s*T)*S,e._m[14]=(-u*x+f*v-g*m)*S,e._m[15]=(h*x-c*v+d*m)*S,e}transposeTo(){let e=new st;return e._m[0]=this._m[0],e._m[1]=this._m[4],e._m[2]=this._m[8],e._m[3]=this._m[12],e._m[4]=this._m[1],e._m[5]=this._m[5],e._m[6]=this._m[9],e._m[7]=this._m[13],e._m[8]=this._m[2],e._m[9]=this._m[6],e._m[10]=this._m[10],e._m[11]=this._m[14],e._m[12]=this._m[3],e._m[13]=this._m[7],e._m[14]=this._m[11],e._m[15]=this._m[15],e}setIdentity(){return this._m[0]=1,this._m[1]=0,this._m[2]=0,this._m[3]=0,this._m[4]=0,this._m[5]=1,this._m[6]=0,this._m[7]=0,this._m[8]=0,this._m[9]=0,this._m[10]=1,this._m[11]=0,this._m[12]=0,this._m[13]=0,this._m[14]=0,this._m[15]=1,this}mul(e){let t=this._m[0],i=this._m[1],s=this._m[2],r=this._m[3],n=this._m[4],o=this._m[5],a=this._m[6],l=this._m[7],h=this._m[8],c=this._m[9],d=this._m[10],_=this._m[11],u=this._m[12],f=this._m[13],g=this._m[14],p=this._m[15],m=e._m[0],v=e._m[1],y=e._m[2],x=e._m[3],b=e._m[4],w=e._m[5],T=e._m[6],C=e._m[7],A=e._m[8],E=e._m[9],L=e._m[10],P=e._m[11],S=e._m[12],R=e._m[13],M=e._m[14],B=e._m[15],k=new st;return k._m[0]=m*t+v*n+y*h+x*u,k._m[1]=m*i+v*o+y*c+x*f,k._m[2]=m*s+v*a+y*d+x*g,k._m[3]=m*r+v*l+y*_+x*p,k._m[4]=b*t+w*n+T*h+C*u,k._m[5]=b*i+w*o+T*c+C*f,k._m[6]=b*s+w*a+T*d+C*g,k._m[7]=b*r+w*l+T*_+C*p,k._m[8]=A*t+E*n+L*h+P*u,k._m[9]=A*i+E*o+L*c+P*f,k._m[10]=A*s+E*a+L*d+P*g,k._m[11]=A*r+E*l+L*_+P*p,k._m[12]=S*t+R*n+M*h+B*u,k._m[13]=S*i+R*o+M*c+B*f,k._m[14]=S*s+R*a+M*d+B*g,k._m[15]=S*r+R*l+M*_+B*p,k}translate(e){let t=e.x,i=e.y,s=e.z,r=this._m;return r[12]=r[0]*t+r[4]*i+r[8]*s+r[12],r[13]=r[1]*t+r[5]*i+r[9]*s+r[13],r[14]=r[2]*t+r[6]*i+r[10]*s+r[14],r[15]=r[3]*t+r[7]*i+r[11]*s+r[15],this}translateToPosition(e){let t=this._m;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this}rotate(e,t){let i=Math.cos(t),s=Math.sin(t),r=new st,n=r._m;return n[0]=i+(1-i)*e.x*e.x,n[1]=(1-i)*e.y*e.x-s*e.z,n[2]=(1-i)*e.z*e.x+s*e.y,n[3]=0,n[4]=(1-i)*e.x*e.y+s*e.z,n[5]=i+(1-i)*e.y*e.y,n[6]=(1-i)*e.z*e.y-s*e.x,n[7]=0,n[8]=(1-i)*e.x*e.z-s*e.y,n[9]=(1-i)*e.y*e.z+s*e.x,n[10]=i+(1-i)*e.z*e.z,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this.mul(r)}setRotation(e,t){let i=Math.cos(t),s=Math.sin(t),r=this._m;return r[0]=i+(1-i)*e.x*e.x,r[1]=(1-i)*e.y*e.x-s*e.z,r[2]=(1-i)*e.z*e.x+s*e.y,r[3]=0,r[4]=(1-i)*e.x*e.y+s*e.z,r[5]=i+(1-i)*e.y*e.y,r[6]=(1-i)*e.z*e.y-s*e.x,r[7]=0,r[8]=(1-i)*e.x*e.z-s*e.y,r[9]=(1-i)*e.y*e.z+s*e.x,r[10]=i+(1-i)*e.z*e.z,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}rotateBetweenVectors(e,t){return F.getRotationBetweenVectors(e,t).getMat4()}scale(e){let t=this._m;return t[0]=t[0]*e.x,t[1]=t[1]*e.x,t[2]=t[2]*e.x,t[3]=t[3]*e.x,t[4]=t[4]*e.y,t[5]=t[5]*e.y,t[6]=t[6]*e.y,t[7]=t[7]*e.y,t[8]=t[8]*e.z,t[9]=t[9]*e.z,t[10]=t[10]*e.z,t[11]=t[11]*e.z,this}setPerspective(e,t,i,s,r,n){let o=t-e,a=s-i,l=r-n,h=2*r,c=this._m;return c[0]=h/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=h/a,c[6]=0,c[7]=0,c[8]=(t+e)/o,c[9]=(s+i)/a,c[10]=(n+r)/l,c[11]=-1,c[12]=0,c[13]=0,c[14]=h*n/l,c[15]=0,this}setOrthographic(e,t,i,s,r,n){let o=1/(e-t),a=1/(i-s),l=1/(r-n),h=this._m;return h[0]=-2*o,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=-2*a,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=2*l,h[11]=0,h[12]=(e+t)*o,h[13]=(s+i)*a,h[14]=(n+r)*l,h[15]=1,this}eulerToMatrix(e,t,i){let s=Math.cos(e),r=Math.sin(e),n=Math.cos(t),o=Math.sin(t),a=Math.cos(i),l=Math.sin(i),h=s*o,c=r*o,d=this._m;return d[0]=n*a,d[1]=-n*l,d[2]=-o,d[4]=-c*a+s*l,d[5]=c*l+s*a,d[6]=-r*n,d[8]=h*a+r*l,d[9]=-h*l+r*a,d[10]=s*n,d[3]=d[7]=d[11]=d[12]=d[13]=d[14]=0,d[15]=1,this}}class F{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}static get IDENTITY(){return new F(0,0,0,1)}static xRotation(e){return e*=.5,new F(Math.sin(e),0,0,Math.cos(e))}static yRotation(e){return e*=.5,new F(0,Math.sin(e),0,Math.cos(e))}static zRotation(e){return e*=.5,new F(0,0,Math.sin(e),Math.cos(e))}static axisAngleToQuat(e,t=0){let i=e.getNormal(),s=.5*t,r=Math.sin(s);return new F(i.x*r,i.y*r,i.z*r,Math.cos(s))}static getLookRotation(e,t){let i=e.getNormal().negate(),s=t.cross(i).normalize(),r=i.cross(s),n=1+s.x+r.y+i.z;if(n>1e-6){let e=1/(2*Math.sqrt(n));return new F((i.y-r.z)*e,(s.z-i.x)*e,(r.x-s.y)*e,.25/e)}if(s.x>r.y&&s.x>i.z){let e=1/(2*Math.sqrt(1+s.x-r.y-i.z));return new F(.25/e,(r.x+s.y)*e,(s.z+i.x)*e,(i.y-r.z)*e)}if(r.y>i.z){let e=1/(2*Math.sqrt(1+r.y-s.x-i.z));return new F((r.x+s.y)*e,.25/e,(i.y+r.z)*e,(s.z-i.x)*e)}let o=1/(2*Math.sqrt(1+i.z-s.x-r.y));return new F((s.z+i.x)*o,(i.y+r.z)*o,.25/o,(r.x-s.y)*o)}static getLookAtSourceDest(e,t){let i=t.subA(e).normalize(),s=m.FORWARD.dot(i);if(Math.abs(s- -1)<1e-6)return F.axisAngleToQuat(m.UP,Math.PI);if(Math.abs(s-1)<1e-6)return new F(0,0,0,1);let r=Math.acos(s),n=m.FORWARD.cross(i).normalize();return F.axisAngleToQuat(n,r)}static getRotationBetweenVectors(e,t){let i=e.cross(t);return new F(i.x,i.y,i.z,1+e.dot(t)).normalize()}static getRotationBetweenVectorsRes(e,t,i){let s=e.cross(t);return i.set(s.x,s.y,s.z,1+e.dot(t)),i.normalize()}static getRotationBetweenVectorsUp(e,t,i){let s=e.dot(t);if(Math.abs(s+1)<1e-6)return F.axisAngleToQuat(i,Math.PI);if(Math.abs(s-1)<1e-6)return new F(0,0,0,1);let r=Math.acos(s),n=e.cross(t).normalize();return F.axisAngleToQuat(n,r)}isZero(){return 0===this.x&&0===this.y&&0===this.z&&0===this.w}isNaN(){return isNaN(this.x)||isNaN(this.y)||isNaN(this.z)||isNaN(this.w)}clear(){return this.x=this.y=this.z=this.w=0,this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}setIdentity(){return this.x=0,this.y=0,this.z=0,this.w=1,this}clone(){return new F(this.x,this.y,this.z,this.w)}add(e){return new F(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)}addRes(e,t){return t.set(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)}sub(e){return new F(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}scaleTo(e){return new F(this.x*e,this.y*e,this.z*e,this.w*e)}scale(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}toVec(){return[this.x,this.y,this.z,this.w]}get xyz(){return new m(this.x,this.y,this.z)}setLookRotation(e,t){let i=e.getNormal().negate(),s=t.cross(i).normalize(),r=i.cross(s),n=1+s.x+r.y+i.z;if(n>1e-6){let e=1/(2*Math.sqrt(n));this.x=(i.y-r.z)*e,this.y=(s.z-i.x)*e,this.z=(r.x-s.y)*e,this.w=.25/e}else if(s.x>r.y&&s.x>i.z){let e=1/(2*Math.sqrt(1+s.x-r.y-i.z));this.x=.25/e,this.y=(r.x+s.y)*e,this.z=(s.z+i.x)*e,this.w=(i.y-r.z)*e}else if(r.y>i.z){let e=1/(2*Math.sqrt(1+r.y-s.x-i.z));this.x=(r.x+s.y)*e,this.y=.25/e,this.z=(i.y+r.z)*e,this.w=(s.z-i.x)*e}else{let e=1/(2*Math.sqrt(1+i.z-s.x-r.y));this.x=(s.z+i.x)*e,this.y=(i.y+r.z)*e,this.z=.25/e,this.w=(r.x-s.y)*e}return this}setFromSphericalCoords(e,t,i){let s=Math.sin(i/2),r=Math.cos(i/2),n=Math.sin(e),o=Math.cos(e),a=Math.sin(t),l=Math.cos(t);return this.x=s*o*a,this.y=s*n,this.z=s*n*l,this.w=r,this}getSphericalCoords(){let e=this.w,t=Math.sqrt(1-e*e);Math.abs(t)<5e-4&&(t=1);let i,s=this.x/t,r=this.y/t,n=this.z/t,o=-Math.asin(r);return i=s*s+n*n<5e-4?0:Math.atan2(s,n),i<0&&(i+=360),{lat:o,lon:i,alpha:Math.acos(e)}}setFromAxisAngle(e,t){let i=e.getNormal(),s=.5*t,r=Math.sin(s);return this.set(i.x*r,i.y*r,i.z*r,Math.cos(s)),this}getAxisAngle(){let e,t,i=this.x,s=this.y,r=this.z,n=this.w,o=Math.sqrt(i*i+s*s+r*r);if(o>1e-7){let a=1/o;e=new m(i*a,s*a,r*a),t=n<0?2*Math.atan2(-o,-n):2*Math.atan2(o,n)}else e=new m(0,0,0),t=0;return{axis:e,angle:t}}getPitch(){let e=-2*(this.y*this.z-this.w*this.x);return Math.abs(e)>=1?Math.sign(e)*go:Math.asin(e)}getYaw(){return-Math.atan2(2*(this.x*this.z+this.w*this.y),1-2*(this.y*this.y+this.x*this.x))}getRoll(){return Math.atan2(2*(this.x*this.y+this.w*this.z),1-2*(this.z*this.z+this.x*this.x))}setPitchYawRoll(e,t,i,s=F.IDENTITY){let r=F.xRotation(-e),n=F.yRotation(t),o=F.zRotation(-i);return this.copy(o.mul(r).mul(n).mul(s).conjugate())}setFromEulerAngles(e,t,i){let s=e*ie,r=t*ie,n=i*ie,o=Math.cos(s),a=Math.cos(r),l=Math.cos(n),h=Math.sin(s),c=Math.sin(r),d=Math.sin(n),_=a*l,u=c*d;return this.w=o*_+h*u,this.x=h*_-o*u,this.y=o*c*l+h*a*d,this.z=o*a*d-h*c*l,this.normalize()}getEulerAngles(){let e=this.x,t=this.y,i=this.z,s=this.w,r=t*t,n=s*t-i*e;return n<-1?n=-1:n>1&&(n=1),{roll:Math.atan2(2*(s*e+t*i),1-2*(e*e+r)),pitch:Math.asin(2*n),yaw:Math.atan2(2*(s*i+e*t),1-2*(r+i*i))}}setFromMatrix4(e){let t,i,s,r,n,o=[],a=e._m,l=[1,2,0];return t=a[0]+a[5]+a[10],t>0?(i=Math.sqrt(t+1),this.w=i/2,i=.5/i,this.x=(a[6]-a[9])*i,this.y=(a[8]-a[2])*i,this.z=(a[1]-a[4])*i):(s=0,a[5]>a[0]&&(s=1),a[10]>a[5*s]&&(s=2),r=l[s],n=l[r],i=Math.sqrt(a[5*s]-(a[5*r]+a[5*n])+1),o[s]=.5*i,0!==i&&(i=.5/i),o[3]=(a[4*r+n]-a[4*n+r])*i,o[r]=(a[4*s+r]+a[4*r+s])*i,o[n]=(a[4*s+n]+a[4*n+s])*i,this.x=o[0],this.y=o[1],this.z=o[2],this.w=o[3]),this}getMat4(e=new st){let t=this.x+this.x,i=this.y+this.y,s=this.z+this.z,r=this.w*t,n=this.w*i,o=this.w*s,a=this.x*t,l=this.x*i,h=this.x*s,c=this.y*i,d=this.y*s,_=this.z*s;return e.set([1-(c+_),l-o,h+n,0,l+o,1-(a+_),d-r,0,h-n,d+r,1-(a+c),0,0,0,0,1])}getMat3(){let e=new Pe,t=e._m,i=this.x,s=this.y,r=this.z,n=this.w,o=i+i,a=s+s,l=r+r,h=i*o,c=i*a;i*=l;let d=s*a;return s*=l,r*=l,o*=n,a*=n,n*=l,t[0]=1-(d+r),t[1]=c-n,t[2]=i+a,t[3]=c+n,t[4]=1-(h+r),t[5]=s-o,t[6]=i-a,t[7]=s+o,t[8]=1-(h+d),e}mulVec3(e){let t=e.x,i=e.y,s=e.z,r=this.x,n=this.y,o=this.z,a=this.w,l=a*t+n*s-o*i,h=a*i+o*t-r*s,c=a*s+r*i-n*t;return t=-r*t-n*i-o*s,new m(l*a+t*-r+h*-o-c*-n,h*a+t*-n+c*-r-l*-o,c*a+t*-o+l*-n-h*-r)}mulVec3Res(e,t){let i=e.x,s=e.y,r=e.z,n=this.x,o=this.y,a=this.z,l=this.w,h=l*i+o*r-a*s,c=l*s+a*i-n*r,d=l*r+n*s-o*i;return i=-n*i-o*s-a*r,t.set(h*l+i*-n+c*-a-d*-o,c*l+i*-o+d*-n-h*-a,d*l+i*-a+h*-o-c*-n)}mul(e){let t=this.x,i=this.y,s=this.z,r=this.w,n=e.x,o=e.y,a=e.z,l=e.w;return new F(t*l+r*n+i*a-s*o,i*l+r*o+s*n-t*a,s*l+r*a+t*o-i*n,r*l-t*n-i*o-s*a)}mulRes(e,t){let i=this.x,s=this.y,r=this.z,n=this.w,o=e.x,a=e.y,l=e.z,h=e.w;return t.set(i*h+n*o+s*l-r*a,s*h+n*a+r*o-i*l,r*h+n*l+i*a-s*o,n*h-i*o-s*a-r*l)}mulA(e){let t=this.x,i=this.y,s=this.z,r=this.w,n=e.x,o=e.y,a=e.z,l=e.w;return this.x=t*l+r*n+i*a-s*o,this.y=i*l+r*o+s*n-t*a,this.z=s*l+r*a+t*o-i*n,this.w=r*l-t*n-i*o-s*a,this}conjugate(){return new F(-this.x,-this.y,-this.z,this.w)}inverse(){let e=1/this.magnitude2();return new F(-this.x*e,-this.y*e,-this.z*e,this.w*e)}magnitude(){let e=this.x,t=this.y,i=this.z,s=this.w;return Math.sqrt(e*e+t*t+i*i+s*s)}magnitude2(){let e=this.x,t=this.y,i=this.z,s=this.w;return e*e+t*t+i*i+s*s}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}normalize(){let e=this.x,t=this.y,i=this.z,s=this.w,r=Math.sqrt(e*e+t*t+i*i+s*s);return 0===r?(this.x=0,this.y=0,this.z=0,this.w=0,this):(r=1/r,this.x=e*r,this.y=t*r,this.z=i*r,this.w=s*r,this)}isEqual(e){let t=this.dot(e);return Math.abs(t-1)<.001}slerp(e,t){let i,s,r,n,o,a=this.x,l=this.y,h=this.z,c=this.w,d=e.x,_=e.y,u=e.z,f=e.w;return s=a*d+l*_+h*u+c*f,s<0&&(s=-s,d=-d,_=-_,u=-u,f=-f),1-s>1e-6?(i=Math.acos(s),r=Math.sin(i),n=Math.sin((1-t)*i)/r,o=Math.sin(t*i)/r):(n=1-t,o=t),new F(n*a+o*d,n*l+o*_,n*h+o*u,n*c+o*f)}}class m{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}static get UP(){return new m(0,1,0)}static get DOWN(){return new m(0,-1,0)}static get RIGHT(){return new m(1,0,0)}static get LEFT(){return new m(-1,0,0)}static get FORWARD(){return new m(0,0,-1)}static get BACKWARD(){return new m(0,0,1)}static get ZERO(){return new m}static get UNIT_X(){return new m(1,0,0)}static get UNIT_Y(){return new m(0,1,0)}static get UNIT_Z(){return new m(0,0,1)}static get NORTH(){return m.UNIT_Z}static doubleToTwoFloats(e,t,i){let s=e.x,r=e.y,n=e.z;if(s>=0){let e=65536*Math.floor(s/65536);t.x=Math.fround(e),i.x=Math.fround(s-e)}else{let e=65536*Math.floor(-s/65536);t.x=Math.fround(-e),i.x=Math.fround(s+e)}if(r>=0){let e=65536*Math.floor(r/65536);t.y=Math.fround(e),i.y=Math.fround(r-e)}else{let e=65536*Math.floor(-r/65536);t.y=Math.fround(-e),i.y=Math.fround(r+e)}if(n>=0){let e=65536*Math.floor(n/65536);t.z=Math.fround(e),i.z=Math.fround(n-e)}else{let e=65536*Math.floor(-n/65536);t.z=Math.fround(-e),i.z=Math.fround(n+e)}}static doubleToTwoFloat32Array(e,t,i){let s=e.x,r=e.y,n=e.z;if(s>=0){let e=65536*Math.floor(s/65536);t[0]=Math.fround(e),i[0]=Math.fround(s-e)}else{let e=65536*Math.floor(-s/65536);t[0]=Math.fround(-e),i[0]=Math.fround(s+e)}if(r>=0){let e=65536*Math.floor(r/65536);t[1]=Math.fround(e),i[1]=Math.fround(r-e)}else{let e=65536*Math.floor(-r/65536);t[1]=Math.fround(-e),i[1]=Math.fround(r+e)}if(n>=0){let e=65536*Math.floor(n/65536);t[2]=Math.fround(e),i[2]=Math.fround(n-e)}else{let e=65536*Math.floor(-n/65536);t[2]=Math.fround(-e),i[2]=Math.fround(n+e)}}static fromVec(e){return new m(e[0],e[1],e[2])}static angle(e,t){let i=e.dot(t),s=e.cross(t).length();return Math.atan2(s,i)}static lerp(e,t,i){return new m(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i,e.z+(t.z-e.z)*i)}static add(e,t){let i=new m(e.x,e.y,e.z);return i.addA(t),i}static sub(e,t){let i=new m(e.x,e.y,e.z);return i.subA(t),i}static scale(e,t){return e.scaleTo(t)}static mul(e,t){let i=new m(e.x,e.y,e.z);return i.mulA(t),i}static noncollinear(e,t){return!!(e.y*t.z-e.z*t.y||e.z*t.x-e.x*t.z||e.x*t.y-e.y*t.z)}static proj_b_to_plane(e,t,i){let s=e.sub(t.scaleTo(t.dot(e)/t.dot(t)));return i&&s.isZero()?new m(i.x,i.y,i.z):s}static proj_b_to_a(e,t){return t.scaleTo(t.dot(e)/t.dot(t))}static orthoNormalize(e,t){return(e=e.getNormal()).scale(t.dot(e)),t.subA(e).normalize()}static isOrthogonal(e,t,i=1e-6){const s=e.x*t.x+e.y*t.y+e.z*t.z;return Math.abs(s)<i}isOrthogonal(e,t=1e-6){const i=this.x*e.x+this.y*e.y+this.z*e.z;return Math.abs(i)<t}static div(e,t){let i=new m(e.x,e.y,e.z);return i.divA(t),i}static length2(e){return e.length2()}static dot(e,t){return e.dot(t)}toVec4(){return new J(this.x,this.y,this.z,1)}clone(){return new m(this.x,this.y,this.z)}toString(){return`(${this.x},${this.y},${this.z})`}isZero(){return!(this.x||this.y||this.z)}projToVec(e){return e.scaleTo(e.dot(this)/e.dot(e))}equal(e){return this.x===e.x&&this.y===e.y&&this.z===e.z}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}length2(){return this.x*this.x+this.y*this.y+this.z*this.z}getQuat(){return new F(this.x,this.y,this.z)}addA(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}add(e){return new m(this.x+e.x,this.y+e.y,this.z+e.z)}addRes(e,t){return t.set(this.x+e.x,this.y+e.y,this.z+e.z)}subA(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}sub(e){return new m(this.x-e.x,this.y-e.y,this.z-e.z)}scale(e){return this.x*=e,this.y*=e,this.z*=e,this}scaleTo(e){return new m(this.x*e,this.y*e,this.z*e)}mulA(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}mul(e){return new m(this.x*e.x,this.y*e.y,this.z*e.z)}mulRes(e,t){return t.set(this.x*e.x,this.y*e.y,this.z*e.z)}divA(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}div(e){return new m(this.x/e.x,this.y/e.y,this.z/e.z)}dot(e){return e.x*this.x+e.y*this.y+e.z*this.z}dotArr(e){return e[0]*this.x+e[1]*this.y+e[2]*this.z}cross(e){return new m(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}clear(){return this.x=this.y=this.z=0,this}getNormal(){let e=new m;e.copy(this);let t=1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normal(){let e=new m;e.copy(this);let t=1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normalNegate(){let e=new m;e.copy(this);let t=-1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normalNegateScale(e){let t=new m;t.copy(this);let i=-e/t.length();return t.x*=i,t.y*=i,t.z*=i,t}normalScale(e){let t=new m;t.copy(this);let i=e/t.length();return t.x*=i,t.y*=i,t.z*=i,t}normalize(){let e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this}toVec(){return[this.x,this.y,this.z]}toArray(){return[this.x,this.y,this.z]}distance(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return Math.sqrt(t*t+i*i+s*s)}distance2(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}negateTo(){return new m(-this.x,-this.y,-this.z)}projToRay(e,t){let i=m.proj_b_to_a(m.sub(this,e),t);return i.addA(e),i}angle(e){return m.angle(this,e)}lerp(e,t){return new m(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t,this.z+(e.z-this.z)*t)}smerp(e,t){let i=1-t;return new m(this.x*t+e.x*i,this.y*t+e.y*i,this.z*t+e.z*i)}static get LERP_DELTA(){return 1e-6}slerp(e,t){let i,s,r,n,o=new m;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let a=this.dot(e);return 1-a>m.LERP_DELTA?(i=Math.acos(a),s=Math.sin(i),r=Math.sin((1-t)*i)/s,n=Math.sin(t*i)/s):(r=1-t,n=t),m.add(this.scaleTo(r),e.scale(n))}mulVecA(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}getRotationTo(e,t){let i=this.clone(),s=e.clone();i.normalize(),s.normalize();let r=i.dot(s);if(r>=1)return F.IDENTITY.clone();if(r<-.999999){if(t.equal(m.ZERO)){let e=m.UNIT_X.cross(i);return e.isZero()&&(e=m.UNIT_Y.cross(i)),e.normalize(),F.axisAngleToQuat(e,Math.PI)}return F.axisAngleToQuat(t,Math.PI)}{let e=Math.sqrt(2*(1+r)),t=1/e,n=i.cross(s),o=new F(n.x*t,n.y*t,n.z*t,.5*e);return o.normalize(),o}}}class O{constructor(e=0,t=0){this.x=e,this.y=t}static get UP(){return new O(0,1)}static get DOWN(){return new O(0,-1)}static get RIGHT(){return new O(1,0)}static get LEFT(){return new O(-1,0)}static get ZERO(){return new O}static add(e,t){const i=new O(e.x,e.y);return i.addA(t),i}static sub(e,t){var i=new O(e.x,e.y);return i.subA(t),i}static scale(e,t){let i=new O(e.x,e.y);return i.scale(t),i}static mul(e,t){let i=new O(e.x,e.y);return i.mulA(t),i}static div(e,t){let i=new O(e.x,e.y);return i.divA(t),i}static proj_b_to_a(e,t){return t.scaleTo(t.dot(e)/t.dot(t))}static angle(e,t){return Math.acos(e.dot(t)/Math.sqrt(e.length2()*t.length2()))}static orthoNormalize(e,t){return(e=e.normal()).scale(t.dot(e)),t.sub(e).normalize()}static proj_b_to_plane(e,t,i){let s=e.sub(t.scaleTo(t.dot(e)/t.dot(t)));return i&&s.isZero()?new O(i.x,i.y):s}toVector3(){return new m(this.x,this.y,0)}clone(){return new O(this.x,this.y)}equal(e){return this.x===e.x&&this.y===e.y}copy(e){return this.x=e.x,this.y=e.y,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}length2(){return this.x*this.x+this.y*this.y}addA(e){return this.x+=e.x,this.y+=e.y,this}add(e){return new O(this.x+e.x,this.y+e.y)}subA(e){return this.x-=e.x,this.y-=e.y,this}sub(e){return new O(this.x-e.x,this.y-e.y)}scale(e){return this.x*=e,this.y*=e,this}scaleTo(e){return new O(this.x*e,this.y*e)}mulA(e){return this.x*=e.x,this.y*=e.y,this}mul(e){return new O(this.x*e.x,this.y*e.y)}divA(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return e.x*this.x+e.y*this.y}dotArr(e){return e[0]*this.x+e[1]*this.y}cross(e){return this.x*e.y-this.y*e.x}clear(){return this.x=this.y=0,this}normal(){return this.getNormal()}getNormal(){let e=new O;e.copy(this);let t=1/e.length();return e.x*=t,e.y*=t,e}normalize(){let e=1/this.length();return this.x*=e,this.y*=e,this}toVec(){return[this.x,this.y]}distance(e){return O.sub(this,e).length()}set(e,t){return this.x=e,this.y=t,this}negate(){return this.x=-this.x,this.y=-this.y,this}negateTo(){return new O(-this.x,-this.y)}projToRay(e,t){let i=O.proj_b_to_a(O.sub(this,e),t);return i.add(e),i}angle(e){return O.angle(this,e)}lerp(e,t,i){let s=this.clone();return i<=0?s.copy(e):i>=1?s.copy(t):s=O.add(e,O.sub(t,e).scale(i)),s}static get LERP_DELTA(){return 1e-6}slerp(e,t){let i,s,r,n,o=new O;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let a=this.dot(e);return 1-a>O.LERP_DELTA?(i=Math.acos(a),s=Math.sin(i),r=Math.sin((1-t)*i)/s,n=Math.sin(t*i)/s):(r=1-t,n=t),O.add(this.scale(r),e.scale(n))}isZero(){return!(this.x||this.y)}}const Eo={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};class Ur{constructor(e=1,t=1){this._a=e,this._b=t,this._flattening=(e-t)/e,this._f=1/this._flattening,this._a2=e*e,this._b2=t*t;const i=Math.sqrt(this._a2-this._b2);this._e=i/e,this._e2=this._e*this._e,this._e22=this._e2*this._e2,this._k=i/t,this._k2=this._k*this._k,this._radii=new m(e,e,t),this._radii2=new m(this._a2,this._a2,this._b2),this._invRadii=new m(1/e,1/e,1/t),this._invRadii2=new m(1/this._a2,1/this._a2,1/this._b2)}rhumbDistanceTo(e,t){const i=e.lat*U,s=t.lat*U,r=s-i;let n=Math.abs(t.lon-e.lon)*U;Math.abs(n)>Math.PI&&(n=n>0?-(2*Math.PI-n):2*Math.PI+n);const o=Math.log(Math.tan(s/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),a=Math.abs(o)>1e-11?r/o:Math.cos(i);return Math.sqrt(r*r+a*a*n*n)*this._a}getIntermediatePointOnGreatCircle(e,t,i){if(0==i)return e.clone();if(1==i)return t.clone();const s=this.inverse(e,t),r=s.distance,n=s.initialAzimuth;return isNaN(n)?e:this.getGreatCircleDestination(e,n,r*i)}static getBearing(e,t){let i=e.lat*U,s=e.lon*U,r=t.lat*U,n=t.lon*U,o=Math.sin(n-s)*Math.cos(r),a=Math.cos(i)*Math.sin(r)-Math.sin(i)*Math.cos(r)*Math.cos(n-s);return Math.atan2(o,a)*Q}getFlattening(){return this._flattening}getEquatorialSize(){return this._a}get equatorialSize(){return this._a}get equatorialSizeSqr(){return this._a2}getPolarSize(){return this._b}get polarSize(){return this._b}get polarSizeSqr(){return this._b2}lonLatToCartesian(e){return this.geodeticToCartesian(e.lon,e.lat,e.height)}lonLatToCartesianRes(e,t){return this.geodeticToCartesian(e.lon,e.lat,e.height,t)}geodeticToCartesian(e,t,i=0,s=new m){let r=U*t,n=U*e,o=Math.sin(r),a=this._a/Math.sqrt(1-this._e2*o*o),l=(a+i)*Math.cos(r);return s.x=l*Math.cos(n),s.y=l*Math.sin(n),s.z=(a*(1-this._e2)+i)*o,s}projToSurface(e){let t=e.x||0,i=e.y||0,s=e.z||0,r=Math.sqrt(t*t+i*i+s*s);if(0===r)return this.lonLatToCartesian(new A);let n=this._invRadii2.x,o=this._invRadii2.y,a=this._invRadii2.z,l=t*t*n,h=i*i*o,c=s*s*a,d=l+h+c,_=Math.sqrt(1/d),u=e.scaleTo(_);if(d<.1)return Number.isFinite(_)?u:new m;let f=(1-_)*r/u.mulA(this._invRadii2).length(),g=0,p=0,v=0;for(;;){g=1/(1+f*n),p=1/(1+f*o),v=1/(1+f*a);let e=g*g,t=p*p,i=v*v,s=l*e+h*t+c*i-1;if(Math.abs(s)<rr)break;f+=.5*s/(l*(e*g)*n+h*(t*p)*o+c*(i*v)*a)}return new m(t*g,i*p,s*v)}cartesianToLonLat(e){return this.cartesianToLonLatRes(e)}cartesianToLonLatRes(e,t=new A){let i=this.projToSurface(e),s=this.getSurfaceNormal3v(i),r=e.sub(i);return t.lon=Math.atan2(s.y,s.x)*Q,t.lat=Math.asin(s.z)*Q,t.height=Math.sign(r.dot(e))*r.length(),t}getSurfaceNormal3v(e){let t=this._invRadii2,i=e.x*t.x,s=e.y*t.y,r=e.z*t.z,n=1/Math.sqrt(i*i+s*s+r*r);return new m(i*n,s*n,r*n)}getGreatCircleDistance(e,t){return this.inverse(e,t).distance}getGreatCircleDestination(e,t,i){return this.direct(e,t,i).destination}inverse(e,t){let i=this._a,s=this._b,r=this._flattening;const n=e.lat*U,o=e.lon*U,a=t.lat*U,l=t.lon*U-o,h=(1-r)*Math.tan(n),c=1/Math.sqrt(1+h*h),d=h*c,_=(1-r)*Math.tan(a),u=1/Math.sqrt(1+_*_),f=_*u,g=Math.abs(l)>Math.PI/2||Math.abs(a-n)>Math.PI/2;let p=l,m=null,v=null,y=g?Math.PI:0,x=0,b=g?-1:1,w=null,T=1,C=1,A=null,E=0;do{if(m=Math.sin(p),v=Math.cos(p),w=(u*m)**2+(c*f-d*u*v)**2,Math.abs(w)<1e-24)break;x=Math.sqrt(w),b=d*f+c*u*v,y=Math.atan2(x,b);const e=c*u*m/x;C=1-e*e,T=0!=C?b-2*d*f/C:0;const t=r/16*C*(4+r*(4-3*C));A=p,p=l+(1-t)*r*e*(y+t*x*(T+t*b*(2*T*T-1)))}while(Math.abs(p-A)>rr&&++E<1e3);const L=C*(i*i-s*s)/(s*s),P=L/1024*(256+L*(L*(74-47*L)-128)),S=s*(1+L/16384*(4096+L*(L*(320-175*L)-768)))*(y-P*x*(T+P/4*(b*(2*T*T-1)-P/6*T*(4*x*x-3)*(4*T*T-3)))),R=Math.abs(w)<Number.EPSILON?0:Math.atan2(u*m,c*f-d*u*v),M=Math.abs(w)<Number.EPSILON?Math.PI:Math.atan2(c*m,-d*u+c*f*v);return{distance:S,initialAzimuth:Math.abs(S)<Number.EPSILON?NaN:Ve(R)*Q,finalAzimuth:Math.abs(S)<Number.EPSILON?NaN:Ve(M)*Q}}direct(e,t,i){let s=e.lon,r=e.lat,n=this._a,o=this._b,a=this._flattening,l=i,h=t*U,c=Math.sin(h),d=Math.cos(h),_=(1-a)*Math.tan(r*U),u=1/Math.sqrt(1+_*_),f=_*u,g=Math.atan2(_,d),p=u*c,m=1-p*p,v=m*(n*n-o*o)/(o*o),y=1+v/16384*(4096+v*(v*(320-175*v)-768)),x=v/1024*(256+v*(v*(74-47*v)-128)),b=l/(o*y),w=2*Math.PI,T=0,C=0,E=0,L=0;for(;Math.abs(b-w)>1e-12;)T=Math.cos(2*g+b),C=Math.sin(b),E=Math.cos(b),L=x*C*(T+x/4*(E*(2*T*T-1)-x/6*T*(4*C*C-3)*(4*T*T-3))),w=b,b=l/(o*y)+L;let P=f*C-u*E*d,S=Math.atan2(f*E+u*C*d,(1-a)*Math.sqrt(p*p+P*P)),R=a/16*m*(4+a*(4-3*m)),M=Math.atan2(C*c,u*E-f*C*d)-(1-R)*a*p*(b+R*C*(T+R*E*(2*T*T-1))),B=Math.atan2(p,-P);return{destination:new A(s+M*Q,S*Q),finalAzimuth:B*Q}}hitRay(e,t){let i,s,r,n,o,a=this._invRadii.mul(e),l=this._invRadii.mul(t),h=a.dot(a),c=a.dot(l);if(h>1){if(c>=0)return;var d=c*c;if(i=h-1,s=l.dot(l),r=s*i,Math.abs(d-r)>1e-15&&d<r)return;if(d>r){n=c*c-r,o=-c+Math.sqrt(n);var _=o/s,u=i/o;return _<u?e.add(t.scaleTo(_)):e.add(t.scaleTo(u))}var f=Math.sqrt(i/s);return e.add(t.scaleTo(f))}return h<1?(i=h-1,s=l.dot(l),r=s*i,n=c*c-r,o=-c+Math.sqrt(n),e.add(t.scaleTo(o/s))):c<0?(s=l.dot(l),e.add(t.scaleTo(-c/s))):void 0}getNorthFrameRotation(e){let t=this.getSurfaceNormal3v(e),i=m.proj_b_to_plane(m.NORTH,t);return F.getLookRotation(i,t)}getBearingDestination(e,t=0,i=0){t*=U;var s=(e.lon+540)%360-180,r=e.lat*U,n=s*U,o=i/this._a,a=Math.asin(Math.sin(r)*Math.cos(o)+Math.cos(r)*Math.sin(o)*Math.cos(t));return new A((n+Math.atan2(Math.sin(t)*Math.sin(o)*Math.cos(r),Math.cos(o)-Math.sin(r)*Math.sin(a)))*Q,a*Q)}static getIntermediatePointOnGreatCircle(e,t,i){var s=e.lat*U,r=e.lon*U,n=t.lat*U,o=t.lon*U,a=Math.sin(s),l=Math.cos(s),h=Math.sin(r),c=Math.cos(r),d=Math.sin(n),_=Math.cos(n),u=Math.sin(o),f=Math.cos(o),g=n-s,p=o-r,m=Math.sin(g/2)*Math.sin(g/2)+Math.cos(s)*Math.cos(n)*Math.sin(p/2)*Math.sin(p/2),v=2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m)),y=Math.sin((1-i)*v)/Math.sin(v),x=Math.sin(i*v)/Math.sin(v),b=y*l*c+x*_*f,w=y*l*h+x*_*u,T=y*a+x*d,C=Math.atan2(T,Math.sqrt(b*b+w*w)),E=Math.atan2(w,b);return new A((E*Q+540)%360-180,C*Q)}static getRhumbBearing(e,t){var i=(t.lon-e.lon)*U,s=Math.log(Math.tan(t.lat*U/2+Math.PI/4)/Math.tan(e.lat*U/2+Math.PI/4));return Math.abs(i)>Math.PI&&(i=i>0?-1*(2*Math.PI-i):2*Math.PI+i),(Math.atan2(i,s)*Q+360)%360}getLonLatVisibilitySimple(e,t,i){const s=this.lonLatToCartesian(t),r=t.height,n=this.polarSize+r,o=Math.max(e.length()-this.polarSize,0),a=s.sub(e);let l;return l=o>0?Math.sqrt((n+o)**2-n**2):n,l>a.length()&&(!i||i.dot(a.normalize())>0)}}const Ao=new Ur(6378137,6356752.314245179);function Hi(e,t){return e??t}function Ut(e){return null==e}function gn(e){return void 0===e}let za=0;function Gr(e){let t=e._openglobus_id;return t||(t=e._openglobus_id=++za),t}function Ms(e){return"string"==typeof e||e instanceof String}function Be(e){return e.toString(16).padStart(2,"0")}function ar(e){let t,i,s;return e instanceof Array?(t=Be(e[0]),i=Be(e[1]),s=Be(e[2])):(t=Be(e.x),i=Be(e.y),s=Be(e.z)),`#${t}${i}${s}`}function le(e,t){let i=Eo[e];if(i&&(e=i),"#"===e[0]){let i=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,s=e.replace(i,(function(e,t,i,s){return t+t+i+i+s+s})),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return r?new J(parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255,Ut(t)?1:t):new J}{Ut(t)&&(t=1);let i=e.split(",");return new J(parseInt(i[0].split("(")[1])/255,parseInt(i[1])/255,parseInt(i[2])/255,Ut(i[3])?t:parseFloat(i[3]))}}function me(e,t){let i=le(e,t);return new Float32Array([i.x,i.y,i.z,i.w])}function Qi(e){let t=Eo[e];if(t&&(e=t),"#"===e[0]){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,(function(e,t,i,s){return t+t+i+i+s+s})),s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return s?new m(parseInt(s[1],16)/255,parseInt(s[2],16)/255,parseInt(s[3],16)/255):new m}{let t=e.split(",");return new m(parseInt(t[0].split("(")[1])/255,parseInt(t[1])/255,parseInt(t[2])/255)}}function zt(e,t){return e.replace(/{[^{}]+}/g,(function(e){return t[e.replace(/[{}]+/g,"")]||""}))}function hi(e,t){return e.replace(/\$\{([^}]+)\}/g,((e,i)=>(null==t?void 0:t[i.trim()])??""))}function jr(e){let t=document.createElement("div");t.innerHTML=e;let i=[];for(let e=0;e<t.childNodes.length;e++)i.push(t.childNodes[e]),t.removeChild(t.childNodes[e]);return i}function Lo(e,t,i,s){let r=document.getElementById(e);r||(r=document.createElement("div"),r.id=e,r.classList.add("defaultText"),document.body.appendChild(r)),r.innerHTML=t,r.style.left=`${i}px`,r.style.top=`${s}px`}function Po(e){return"number"==typeof e}function So(e,t=""){return e?e.trim():t}function qt(e,t){if(e){if(Po(e))return new m(e,e,e);if(e instanceof m)return e.clone();if(e instanceof Array)return m.fromVec(e);if(e instanceof O)return new m(e.x,e.y,0)}else if(t)return t;return new m}function ae(e,t){if(e){if(Ms(e))return le(e);if(e instanceof Array)return J.fromVec(e);if(e instanceof J)return e.clone()}else if(t)return t;return new J(1,1,1,1)}function Gt(e,t){if(e){if(Ms(e))return Qi(e);if(e instanceof Array)return m.fromVec(e);if(e instanceof m)return e.clone()}else if(t)return t;return new m(1,1,1)}function qr(e,t){if(e){if(e instanceof Array)return new H(mi(e[0]),mi(e[1]));if(e instanceof H)return e.clone()}else if(t)return t;return new H}function mi(e,t){if(e){if(e instanceof Array)return new A(e[0],e[1],e[2]);if(e instanceof A)return e.clone()}else if(t)return t;return new A}function Yr(e,t){let i=0,s=e.length-1;for(;i<=s;){let r=Math.floor(.5*(i+s));if(Math.abs(e[r]-t)<.001)return r;e[r]<t?i=r+1:s=r-1}return-1}function Se(e,t,i){let s=0,r=e.length-1;for(;s<=r;){let n=r+s>>1,o=i(t,e[n],n);if(o>0)s=n+1;else{if(!(o<0))return n;r=n-1}}return-s-1}function Wr(e,t,i){let s=Se(e,t,i);return s<0&&(s=~s),e.splice(s,0,t),s}function Ro(e,t,i,s,r=!1){let n=new A(t.lon-e.lon,t.lat-e.lat),o=new A(s.lon-i.lon,s.lat-i.lat),a=-n.lat,l=+n.lon,h=-(a*e.lon+l*e.lat),c=-o.lat,d=+o.lon,_=-(c*i.lon+d*i.lat),u=c*e.lon+d*e.lat+_,f=c*t.lon+d*t.lat+_,g=a*i.lon+l*i.lat+h,p=a*s.lon+l*s.lat+h;if(r&&(u*f>0||g*p>0))return;let m=u/(u-f);return new A(e.lon+m*n.lon,e.lat+m*n.lat)}const Da={string:function(e){return Ut(e)?e:e.toString()},date:function(e){return Ut(e)?e:new Date(1e3*e)},datetime:function(e){return Ut(e)?e:new Date(1e3*e)},time:function(e){return Ut(e)?e:parseInt(e)},integer:function(e){return Ut(e)?e:parseInt(e)},float:function(e){return Ut(e)?e:parseFloat(e)},boolean:function(e){if(null===e)return e;if("boolean"==typeof e)return!0===e;if("string"==typeof e){if(""===e)return!1;if("true"===(e=e.replace(/^\s+|\s+$/g,"")).toLowerCase()||"yes"===e.toLowerCase())return!0;e=(e=e.replace(/,/g,".")).replace(/^\s*\-\s*/g,"-")}return!isNaN(e)&&0!==parseFloat(e)}};function pn(e,t=""){let i=1024,s=atob(e),r=s.length,n=Math.ceil(r/i),o=new Array(n);for(let e=0;e<n;++e){let t=e*i,n=Math.min(t+i,r),a=new Array(n-t);for(let e=t,i=0;e<n;++i,++e)a[i]=s[e].charCodeAt(0);o[e]=new Uint8Array(a)}return new Blob(o,{type:t})}function vi(e,t,i=!1){let s,r=0;return function(){const n=arguments;r?(i&&clearTimeout(s),s=setTimeout((()=>{Date.now()-r>=t&&(e.apply(null,n),r=Date.now())}),t-(Date.now()-r))):(e.apply(null,n),r=Date.now())}}function nt(e,t){let i=new e.constructor(e.length+t.length);return i.set(e,0),i.set(t,e.length),i}function xt(e=[],t=[]){if(ArrayBuffer.isView(e))return nt(e,t);for(let i=0;i<t.length;i++)e.push(t[i]);return e}function it(e,t=Float32Array){if(ArrayBuffer.isView(e))return e;{const i=new t(e.length);return i.set(e,0),i}}function He(e){return ArrayBuffer.isView(e)?Array.from(e):e}function Ct(e,t,i,s){if(ArrayBuffer.isView(e))return t<0&&(i=Math.abs(t),t+=e.length),at(e,t,i,s);{let r;return r=t<0?e.splice(t):e.splice(t,i),s&&(s.result=r),e}}function at(e,t,i,s){if(0===e.length)return e;const r=e.length-i,n=new e.constructor(r);return n.set(e.subarray(0,t)),n.set(e.subarray(t+i),t),s&&(s.result=e.subarray(t,t+i)),n}function $r(e,t,i,s,r){const n=r+1,o=i+n,a=s+n;let l=new Float64Array(n*n*3),h=0;for(let r=i;r<o;r++)for(let i=s;i<a;i++){let s=3*(r*(t+1)+i);l[h++]=e[s],l[h++]=e[s+1],l[h++]=e[s+2]}return l}function Mo(e,t,i,s,r){const n=r+1,o=i+n,a=s+n;let l=new Float32Array(n*n*3),h=0;for(let r=i;r<o;r++)for(let i=s;i<a;i++){let s=3*(r*(t+1)+i);l[h++]=e[s],l[h++]=e[s+1],l[h++]=e[s+2]}return l}function lr(e,t,i,s,r,n,o,a,l,h,c,d,_){const u=n+a+1,f=o+a+1;r+=1;let g=0,p=0;for(let a=n;a<u;a++)for(let n=o;n<f;n++){let o=a*r+n,u=3*o,f=e[u],m=e[u+1],v=e[u+2];s&&0!==s[o]?_[p]=1:(f<d.xmin&&(d.xmin=f),f>d.xmax&&(d.xmax=f),m<d.ymin&&(d.ymin=m),m>d.ymax&&(d.ymax=m),v<d.zmin&&(d.zmin=v),v>d.zmax&&(d.zmax=v)),p++,l[g]=f,c[g]=i[u],h[g++]=t[u],l[g]=m,c[g]=i[u+1],h[g++]=t[u+1],l[g]=v,c[g]=i[u+2],h[g++]=t[u+2]}}function Xr(e){return e.map((e=>Array.isArray(e)?Xr(e):e))}async function Vi(e){return new Promise((t=>{const i=new Image;return i.addEventListener("load",(()=>{t(i)})),i.src=e,i.crossOrigin="",i}))}function hr(e){return e.complete&&0!==e.naturalHeight}function Ue(e){return e>1e3?e-Math.floor(e)!=0?[(e/1e3).toFixed(2),"km"]:[(e/1e3).toFixed(0),"km"]:e>9?[Math.round(e).toString(),"m"]:e<=.01?["0","m"]:[e.toFixed(1),"m"]}function Bo(e){let t=new URLSearchParams(location.search).get(e);if(t)return Number(t)}function cr(e,t=-1){if(t<0)return e.toString();const i=Math.pow(10,t);return(Math.round(e*i)/i).toString()}const kc=Object.freeze(Object.defineProperty({__proto__:null,base64StringToBlog:function(e){let t=e.split(";"),i=t[0].split(":")[1];return pn(t[1].split(",")[1],i)},base64toBlob:pn,binaryInsert:Wr,binarySearch:Se,binarySearchFast:Yr,blerp:function(e,t,i,s,r,n,o=0,a=1,l=0,h=1){return(i*(a-e)*(h-t)+s*(e-o)*(h-t)+r*(a-e)*(t-l)+n*(e-o)*(t-l))/((a-o)*(h-l))},blerp2:function(e,t,i,s,r,n){return i*(1-e)*(1-t)+s*e*(1-t)+r*(1-e)*t+n*e*t},castType:Da,cloneArray:Xr,concatArrays:xt,concatTypedArrays:nt,createColorRGB:Gt,createColorRGBA:ae,createExtent:qr,createLonLat:mi,createVector3:qt,createVector4:function(e,t){if(e){if(e instanceof J)return e.clone();if(e instanceof Array)return J.fromVec(e)}else if(t)return t;return new J},defaultString:So,distanceFormat:function(e){return e>1e3?`${(e/1e3).toFixed(2)} km`:e>9?`${Math.round(e)} m`:`${e.toFixed(1)} m`},distanceFormatExt:Ue,extractElevationTiles:function(e,t,i){let s=Math.sqrt(t.length)-1,r=s+1,n=Math.sqrt(e.length/4),o=n/s,a=0,l=0;for(let h=0,c=0,d=e.length/4;h<d;h++){let d=e[4*h],_=Math.floor(h/n),u=h%n,f=Math.floor(u/s),g=Math.floor(_/s),p=i[g][f],m=_%s,v=u%s,y=(m+g)*r+v+f;if(p[y]=d,(_+g)%o==0&&(u+f)%o==0&&(t[c++]=d),(u+1)%s==0&&u!==n-1){a=e[4*(h+1)];let n=.5*(d+a);y=(m+g)*r+v+1,p[y]=n,(_+g)%o==0&&(t[c++]=n);let l=(m+g)*r+(v+1)%s;i[g][f+1][l]=n}if((_+1)%s==0&&_!==n-1){l=e[4*(h+n)];let a=.5*(d+l);y=(m+1)*r+v+f,p[y]=a,(u+f)%o==0&&(t[c++]=a);let _=(m+1)%s*r+v+f;i[g+1][f][_]=a}if((u+1)%s==0&&u!==n-1&&(_