@openglobus/openglobus-react 0.3.1 → 0.4.0

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.
@@ -1,7 +1,7 @@
1
- (function(de,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],S):(de=typeof globalThis<"u"?globalThis:de||self,S(de["@openglobus/openglobus-react"]={},de.React))})(this,function(de,S){"use strict";function Qa(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const Oe=Qa(S),vr=S.createContext({globe:null,setGlobe:()=>{}}),Ka=({children:a})=>{const[e,t]=S.useState(null);return Oe.createElement(vr.Provider,{value:{globe:e,setGlobe:t}},a)},dt=()=>S.useContext(vr),Pi=2*Math.PI,yr=Math.PI/2,Ja=Number.MAX_VALUE||17976931348623157e292,xr=Math.log(2),mt=2147483647,ye=549755748352,Te=-549755748352,j=Math.PI/180,J=180/Math.PI,ts=2*J,et=.5*j,br=Math.sqrt(.5),wr=1e-5,tt=1e-10,is=1e-12,ss=1e-14;function Si(a,e,t){return Math.max(e,Math.min(a,t))}function Mi(a){return!(a&a-1)}function Mt(a,e=4096){--a;for(let t=1;t<32;t<<=1)a|=a>>t;return a+1>e?e:a+1}function Ri(a=0,e=1){return Math.floor(Math.random()*(e-a))+a}function Cr(a,e){return(a%e+e)%e}function Rt(a){const e=Cr(a,Pi);return Math.abs(e)<ss&&Math.abs(a)>ss?Pi:e}function Wt(a){const e=Math.abs(a);return e-Math.floor(e)}function Tr(a,e,t){return t+a*(e-t)}function rs(a){return a*a*a}function ns(a){return a*a}function os(a){return a-360*Math.floor(a/360)}Object.freeze(Object.defineProperty({__proto__:null,ARCSECONDS_TO_RADIANS:484813681109536e-20,DEG2RAD:function(a){return a*j},DEGREES:J,DEGREES_DOUBLE:ts,DEGREES_TO_HOURS:1/15,EPS1:.1,EPS10:tt,EPS11:1e-11,EPS12:is,EPS13:1e-13,EPS14:ss,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:wr,EPS6:1e-6,EPS7:1e-7,EPS8:1e-8,EPS9:1e-9,HOURS_TO_DEGREES:15,HOURS_TO_RADIANS:.26179938779914946,LOG2:xr,MAX:ye,MAX32:mt,MAX_FLOAT:Ja,MIN:Te,PI_TWO:yr,RAD2DEG:function(a){return a*J},RADIANS:j,RADIANS_HALF:et,RADIANS_TO_HOURS:3.819718634205488,SQRT_HALF:br,TWO_PI:Pi,W:3,X:0,Y:1,Z:2,bezier1v:function(a,e,t,i,s){return rs(1-a)*e+3*ns(1-a)*a*t+3*(1-a)*ns(a)*i+rs(a)*s},bezier3v:function(a,e,t,i,s){let r=1-a,n=a*a,o=r*r,l=o*r,h=n*a;return e.scaleTo(l).addA(t.scaleTo(3*o*a)).addA(i.scaleTo(3*r*n)).addA(s.scaleTo(h))},clamp:Si,cube:rs,degToDec:function(a,e,t,i){return i?a+e/60+t/3600:-a-e/60-t/3600},exp2:function(a){return Math.pow(2,a)},frac:Wt,getAngleBetweenAzimuths:function(a,e){return(((a=Rt(a))-(e=Rt(e)))%360+360+180)%360-180},isPowerOfTwo:Mi,lerp:Tr,log:function(a,e){return Math.log(a)/Math.log(e)},log2:function(a){return Math.log(a)/xr},mod:Cr,negativePItoPI:function(a){return Rt(a+Math.PI)-Math.PI},nextHighestPowerOfTwo:Mt,norm_lon:function(a){return a>180?(a+180)%360-180:a<-180?(a-180)%360+180:a},pow2i:function(a){return 2<<a-1},random:function(a=0,e=1){return Math.random()*(e-a)+a},randomi:Ri,rev:os,slice:function(a,e,t){return a*(e-t)},solve_iteration:function(a,e,t,i=50){let s=0,r=e;for(let n=0;n<i;n++)if(s=r,r=a(s),Math.abs(r-s)<t)return r;return r},solve_iteration_fixed:function(a,e,t){let i=0,s=e;for(let r=0;r<t;r++)i=s,s=a(i);return s},square:ns,step:function(a,e){return e<a?0:1},zeroTwoPI:Rt},Symbol.toStringTag,{value:"Module"}));const el=.5*Math.PI,Er=180/Math.PI,tl=2*Er,as=Math.PI/360,il=Er*el;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 this.lon===0&&this.lat===0&&this.height===0}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*ki,Math.log(Math.tan((90+t)*as))*Bt,i)}static forwardMercatorRes(e,t){return t.lon=e.lon*ki,t.lat=Math.log(Math.tan((90+e.lat)*as))*Bt,t.height=e.height,t}static inverseMercator(e,t,i=0){return new A(e*Ar,tl*Math.atan(Math.exp(t*ls))-il,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*ki,Math.log(Math.tan((90+e)*as))*Bt)}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 Ee=2003750834e-2,Bi=2*Ee,ls=Math.PI/Ee,Bt=Ee/Math.PI,sl=.5*Math.PI,ki=Ee/180,Ar=180/Ee,Lr=Math.PI/360,Pr=Math.PI/180,rl=180/Math.PI,Sr=2*Ee,$t=1/Sr;function Ii(a){return new A(a.lon*Ee/180,Math.log(Math.tan((90+a.lat)*Lr))*Bt,a.height)}function Xt(a){return a*Ee/180}function Zt(a){return Math.log(Math.tan((90+a)*Lr))*Bt}function Mr(a){return rl*(2*Math.atan(Math.exp(a*ls))-sl)}function kt(a,e,t){let i=Bi/(1<<t),s=new A(a*i-2003750834e-2,Ee-e*i-i);return new G(s,new A(s.lon+i,s.lat+i))}const ue=Mr(Ee),Ne=-ue;Object.freeze(Object.defineProperty({__proto__:null,INV_POLE_BY_180:Ar,MAX_LAT:ue,MIN_LAT:Ne,ONE_BY_POLE_DOUBLE:$t,PI_BY_POLE:ls,POLE:Ee,POLE2:Bi,POLE_BY_180:ki,POLE_BY_PI:Bt,POLE_DOUBLE:Sr,forward:Ii,forwardArray:function(a){let e=[];for(let t=0;t<a.length;t++)e.push(a[t].forwardMercator());return e},forward_lat:Zt,forward_lon:Xt,getTileExtent:kt,getTileX:function(a,e){return Math.floor((a+180)/360*Math.pow(2,e))},getTileY:function(a,e){return Math.floor(.5*(1-Math.log(Math.tan(a*Pr)+1/Math.cos(a*Pr))/Math.PI)*Math.pow(2,e))},inverse_lat:Mr,inverse_lon:function(a){return 180*a/Ee}},Symbol.toStringTag,{value:"Module"}));class G{constructor(e=new A,t=new A){this.southWest=e,this.northEast=t}static createFromArray(e){return new G(new A(e[0],e[1]),new A(e[2],e[3]))}static createByCoordinates(e){let t=ye,i=Te,s=ye,r=Te;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 G(new A(t,s),new A(i,r))}static createByCoordinatesArr(e){let t=ye,i=Te,s=ye,r=Te;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 G(new A(t,s),new A(i,r))}static fromTile(e,t,i,s=4007501668e-2,r=4007501668e-2){const n=1<<i,o=s/n,l=r/n,h=.5*-s+e*o,c=.5*r-t*l,d=h+o;return new G(new A(h,c-l),new A(d,c))}setByCoordinates(e){let t=ye,i=Te,s=ye,r=Te;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 G(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 G(this.southWest.forwardMercator(),this.northEast.forwardMercator())}inverseMercator(){return new G(this.southWest.inverseMercator(),this.northEast.inverseMercator())}getCartesianBounds(e){let t=ye,i=Te,s=ye,r=Te,n=ye,o=Te;const l=[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 h=0;h<l.length;h++){const c=e.lonLatToCartesian(l[h]),d=c.x,u=c.y,g=c.z;d<t&&(t=d),d>i&&(i=d),u<s&&(s=u),u>r&&(r=u),g<n&&(n=g),g>o&&(o=g)}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 vt{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 vt;return e.set(this._m),e}copy(e){return this.set(e._m)}transposeTo(){let e=new vt,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 v(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 ne,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 ee{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 ee(0,0,0,1)}static fromVec(e){return new ee(e[0],e[1],e[2],e[3])}toVec3(){return new v(this.x,this.y,this.z)}clone(){return new ee(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 ee(this.x*e,this.y*e,this.z*e,this.w*e)}getStep(e){return new ee(this.x<e?0:1,this.y<e?0:1,this.z<e?0:1,this.w<e?0:1)}getFrac(e){return new ee(Wt(e.x),Wt(e.y),Wt(e.z),Wt(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 ne{constructor(){this._m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}static identity(){let e=new ne;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=v.ZERO,i=v.UP){let s=ne.getRotation(e,i),r=new ne().setIdentity().translate(t),n=new ne().setIdentity().translate(t.negateTo());return r.mul(s).mul(n)}static getRotation(e,t=v.UP){return new ne().setRotation(t,e)}getPosition(){return new v(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],l=this._m[9],h=this._m[10];return new v(Math.sqrt(e*e+t*t+i*i),Math.sqrt(s*s+r*r+n*n),Math.sqrt(o*o+l*l+h*h))}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,l=this._m[2]*r,h=this._m[4]*i,c=this._m[5]*s,d=this._m[6]*r,u=this._m[8]*i,g=this._m[9]*s,f=this._m[10]*r,p=n+c+f,_=0;return p>0?(_=2*Math.sqrt(p+1),t[3]=.25*_,t[0]=(d-g)/_,t[1]=(u-l)/_,t[2]=(o-h)/_):n>c&&n>f?(_=2*Math.sqrt(1+n-c-f),t[3]=(d-g)/_,t[0]=.25*_,t[1]=(o+h)/_,t[2]=(u+l)/_):c>f?(_=2*Math.sqrt(1+c-n-f),t[3]=(u-l)/_,t[0]=(o+h)/_,t[1]=.25*_,t[2]=(d+g)/_):(_=2*Math.sqrt(1+f-n-c),t[3]=(o-h)/_,t[0]=(u+l)/_,t[1]=(d+g)/_,t[2]=.25*_),new O(...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 ne;return e.set(this._m),e}copy(e){return this.set(e._m)}getMat3(){let e=new vt,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 v(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 ee(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],l=e[8],h=e[9],c=e[10],d=c*n-o*h,u=-c*r+o*l,g=h*r-n*l,f=t*d+i*u+s*g;if(!f)return;f=1/f;let p=new vt;return p._m[0]=d*f,p._m[1]=(-c*i+s*h)*f,p._m[2]=(o*i-s*n)*f,p._m[3]=u*f,p._m[4]=(c*t-s*l)*f,p._m[5]=(-o*t+s*r)*f,p._m[6]=g*f,p._m[7]=(-h*t+i*l)*f,p._m[8]=(n*t-i*r)*f,p}inverseTo(e=new ne){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],l=this._m[6],h=this._m[7],c=this._m[8],d=this._m[9],u=this._m[10],g=this._m[11],f=this._m[12],p=this._m[13],_=this._m[14],m=this._m[15],y=t*o-i*n,x=t*l-s*n,w=t*h-r*n,b=i*l-s*o,E=i*h-r*o,C=s*h-r*l,T=c*p-d*f,L=c*_-u*f,M=c*m-g*f,R=d*_-u*p,z=d*m-g*p,F=u*m-g*_,P=1/(y*F-x*z+w*R+b*M-E*L+C*T);return e._m[0]=(o*F-l*z+h*R)*P,e._m[1]=(-i*F+s*z-r*R)*P,e._m[2]=(p*C-_*E+m*b)*P,e._m[3]=(-d*C+u*E-g*b)*P,e._m[4]=(-n*F+l*M-h*L)*P,e._m[5]=(t*F-s*M+r*L)*P,e._m[6]=(-f*C+_*w-m*x)*P,e._m[7]=(c*C-u*w+g*x)*P,e._m[8]=(n*z-o*M+h*T)*P,e._m[9]=(-t*z+i*M-r*T)*P,e._m[10]=(f*E-p*w+m*y)*P,e._m[11]=(-c*E+d*w-g*y)*P,e._m[12]=(-n*R+o*L-l*T)*P,e._m[13]=(t*R-i*L+s*T)*P,e._m[14]=(-f*b+p*x-_*y)*P,e._m[15]=(c*b-d*x+u*y)*P,e}transposeTo(){let e=new ne;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],l=this._m[6],h=this._m[7],c=this._m[8],d=this._m[9],u=this._m[10],g=this._m[11],f=this._m[12],p=this._m[13],_=this._m[14],m=this._m[15],y=e._m[0],x=e._m[1],w=e._m[2],b=e._m[3],E=e._m[4],C=e._m[5],T=e._m[6],L=e._m[7],M=e._m[8],R=e._m[9],z=e._m[10],F=e._m[11],P=e._m[12],D=e._m[13],I=e._m[14],k=e._m[15],B=new ne;return B._m[0]=y*t+x*n+w*c+b*f,B._m[1]=y*i+x*o+w*d+b*p,B._m[2]=y*s+x*l+w*u+b*_,B._m[3]=y*r+x*h+w*g+b*m,B._m[4]=E*t+C*n+T*c+L*f,B._m[5]=E*i+C*o+T*d+L*p,B._m[6]=E*s+C*l+T*u+L*_,B._m[7]=E*r+C*h+T*g+L*m,B._m[8]=M*t+R*n+z*c+F*f,B._m[9]=M*i+R*o+z*d+F*p,B._m[10]=M*s+R*l+z*u+F*_,B._m[11]=M*r+R*h+z*g+F*m,B._m[12]=P*t+D*n+I*c+k*f,B._m[13]=P*i+D*o+I*d+k*p,B._m[14]=P*s+D*l+I*u+k*_,B._m[15]=P*r+D*h+I*g+k*m,B}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 ne,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 O.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,l=s-i,h=r-n,c=2*r,d=this._m;return d[0]=c/o,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=c/l,d[6]=0,d[7]=0,d[8]=(t+e)/o,d[9]=(s+i)/l,d[10]=(n+r)/h,d[11]=-1,d[12]=0,d[13]=0,d[14]=c*n/h,d[15]=0,this}setOrtho(e,t,i,s,r,n){let o=1/(e-t),l=1/(i-s),h=1/(r-n),c=this._m;return c[0]=-2*o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=-2*l,c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=2*h,c[11]=0,c[12]=(e+t)*o,c[13]=(s+i)*l,c[14]=(n+r)*h,c[15]=1,this}eulerToMatrix(e,t,i){let s=Math.cos(e),r=Math.sin(e),n=Math.cos(t),o=Math.sin(t),l=Math.cos(i),h=Math.sin(i),c=s*o,d=r*o,u=this._m;return u[0]=n*l,u[1]=-n*h,u[2]=-o,u[4]=-d*l+s*h,u[5]=d*h+s*l,u[6]=-r*n,u[8]=c*l+r*h,u[9]=-c*h+r*l,u[10]=s*n,u[3]=u[7]=u[11]=u[12]=u[13]=u[14]=0,u[15]=1,this}}class O{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 O(0,0,0,1)}static xRotation(e){return e*=.5,new O(Math.sin(e),0,0,Math.cos(e))}static yRotation(e){return e*=.5,new O(0,Math.sin(e),0,Math.cos(e))}static zRotation(e){return e*=.5,new O(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 O(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 l=1/(2*Math.sqrt(n));return new O((i.y-r.z)*l,(s.z-i.x)*l,(r.x-s.y)*l,.25/l)}if(s.x>r.y&&s.x>i.z){let l=1/(2*Math.sqrt(1+s.x-r.y-i.z));return new O(.25/l,(r.x+s.y)*l,(s.z+i.x)*l,(i.y-r.z)*l)}if(r.y>i.z){let l=1/(2*Math.sqrt(1+r.y-s.x-i.z));return new O((r.x+s.y)*l,.25/l,(i.y+r.z)*l,(s.z-i.x)*l)}let o=1/(2*Math.sqrt(1+i.z-s.x-r.y));return new O((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=v.FORWARD.dot(i);if(Math.abs(s- -1)<1e-6)return O.axisAngleToQuat(v.UP,Math.PI);if(Math.abs(s-1)<1e-6)return new O(0,0,0,1);let r=Math.acos(s),n=v.FORWARD.cross(i).normalize();return O.axisAngleToQuat(n,r)}static getRotationBetweenVectors(e,t){let i=e.cross(t);return new O(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 O.axisAngleToQuat(i,Math.PI);if(Math.abs(s-1)<1e-6)return new O(0,0,0,1);let r=Math.acos(s),n=e.cross(t).normalize();return O.axisAngleToQuat(n,r)}isZero(){return this.x===0&&this.y===0&&this.z===0&&this.w===0}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 O(this.x,this.y,this.z,this.w)}add(e){return new O(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 O(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}scaleTo(e){return new O(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 v(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 o=1/(2*Math.sqrt(n));this.x=(i.y-r.z)*o,this.y=(s.z-i.x)*o,this.z=(r.x-s.y)*o,this.w=.25/o}else if(s.x>r.y&&s.x>i.z){let o=1/(2*Math.sqrt(1+s.x-r.y-i.z));this.x=.25/o,this.y=(r.x+s.y)*o,this.z=(s.z+i.x)*o,this.w=(i.y-r.z)*o}else if(r.y>i.z){let o=1/(2*Math.sqrt(1+r.y-s.x-i.z));this.x=(r.x+s.y)*o,this.y=.25/o,this.z=(i.y+r.z)*o,this.w=(s.z-i.x)*o}else{let o=1/(2*Math.sqrt(1+i.z-s.x-r.y));this.x=(s.z+i.x)*o,this.y=(i.y+r.z)*o,this.z=.25/o,this.w=(r.x-s.y)*o}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),l=Math.sin(t),h=Math.cos(t);return this.x=s*o*l,this.y=s*n,this.z=s*n*h,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 l=1/o;e=new v(i*l,s*l,r*l),t=n<0?2*Math.atan2(-o,-n):2*Math.atan2(o,n)}else e=new v(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)*yr: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=O.IDENTITY){let r=O.xRotation(-e),n=O.yRotation(t),o=O.zRotation(-i);return this.copy(o.mul(r).mul(n).mul(s).conjugate())}setFromEulerAngles(e,t,i){let s=e*et,r=t*et,n=i*et,o=Math.cos(s),l=Math.cos(r),h=Math.cos(n),c=Math.sin(s),d=Math.sin(r),u=Math.sin(n),g=l*h,f=d*u;return this.w=o*g+c*f,this.x=c*g-o*f,this.y=o*d*h+c*l*u,this.z=o*l*u-c*d*h,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=[],l=e._m,h=[1,2,0];return t=l[0]+l[5]+l[10],t>0?(i=Math.sqrt(t+1),this.w=i/2,i=.5/i,this.x=(l[6]-l[9])*i,this.y=(l[8]-l[2])*i,this.z=(l[1]-l[4])*i):(s=0,l[5]>l[0]&&(s=1),l[10]>l[5*s]&&(s=2),r=h[s],n=h[r],i=Math.sqrt(l[5*s]-(l[5*r]+l[5*n])+1),o[s]=.5*i,i!==0&&(i=.5/i),o[3]=(l[4*r+n]-l[4*n+r])*i,o[r]=(l[4*s+r]+l[4*r+s])*i,o[n]=(l[4*s+n]+l[4*n+s])*i,this.x=o[0],this.y=o[1],this.z=o[2],this.w=o[3]),this}getMat4(e=new ne){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,l=this.x*t,h=this.x*i,c=this.x*s,d=this.y*i,u=this.y*s,g=this.z*s;return e.set([1-(d+g),h-o,c+n,0,h+o,1-(l+g),u-r,0,c-n,u+r,1-(l+d),0,0,0,0,1])}getMat3(){let e=new vt,t=e._m,i=this.x,s=this.y,r=this.z,n=this.w,o=i+i,l=s+s,h=r+r,c=i*o,d=i*l;i*=h;let u=s*l;return s*=h,r*=h,o*=n,l*=n,n*=h,t[0]=1-(u+r),t[1]=d-n,t[2]=i+l,t[3]=d+n,t[4]=1-(c+r),t[5]=s-o,t[6]=i-l,t[7]=s+o,t[8]=1-(c+u),e}mulVec3(e){let t=e.x,i=e.y,s=e.z,r=this.x,n=this.y,o=this.z,l=this.w,h=l*t+n*s-o*i,c=l*i+o*t-r*s,d=l*s+r*i-n*t;return t=-r*t-n*i-o*s,new v(h*l+t*-r+c*-o-d*-n,c*l+t*-n+d*-r-h*-o,d*l+t*-o+h*-n-c*-r)}mulVec3Res(e,t){let i=e.x,s=e.y,r=e.z,n=this.x,o=this.y,l=this.z,h=this.w,c=h*i+o*r-l*s,d=h*s+l*i-n*r,u=h*r+n*s-o*i;return i=-n*i-o*s-l*r,t.set(c*h+i*-n+d*-l-u*-o,d*h+i*-o+u*-n-c*-l,u*h+i*-l+c*-o-d*-n)}mul(e){let t=this.x,i=this.y,s=this.z,r=this.w,n=e.x,o=e.y,l=e.z,h=e.w;return new O(t*h+r*n+i*l-s*o,i*h+r*o+s*n-t*l,s*h+r*l+t*o-i*n,r*h-t*n-i*o-s*l)}mulRes(e,t){let i=this.x,s=this.y,r=this.z,n=this.w,o=e.x,l=e.y,h=e.z,c=e.w;return t.set(i*c+n*o+s*h-r*l,s*c+n*l+r*o-i*h,r*c+n*h+i*l-s*o,n*c-i*o-s*l-r*h)}mulA(e){let t=this.x,i=this.y,s=this.z,r=this.w,n=e.x,o=e.y,l=e.z,h=e.w;return this.x=t*h+r*n+i*l-s*o,this.y=i*h+r*o+s*n-t*l,this.z=s*h+r*l+t*o-i*n,this.w=r*h-t*n-i*o-s*l,this}conjugate(){return new O(-this.x,-this.y,-this.z,this.w)}inverse(){let e=1/this.magnitude2();return new O(-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 r===0?(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,l=this.x,h=this.y,c=this.z,d=this.w,u=e.x,g=e.y,f=e.z,p=e.w;return s=l*u+h*g+c*f+d*p,s<0&&(s=-s,u=-u,g=-g,f=-f,p=-p),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 O(n*l+o*u,n*h+o*g,n*c+o*f,n*d+o*p)}}class v{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}static get UP(){return new v(0,1,0)}static get DOWN(){return new v(0,-1,0)}static get RIGHT(){return new v(1,0,0)}static get LEFT(){return new v(-1,0,0)}static get FORWARD(){return new v(0,0,-1)}static get BACKWARD(){return new v(0,0,1)}static get ZERO(){return new v}static get UNIT_X(){return new v(1,0,0)}static get UNIT_Y(){return new v(0,1,0)}static get UNIT_Z(){return new v(0,0,1)}static get NORTH(){return v.UNIT_Z}static doubleToTwoFloats(e,t,i){let s=e.x,r=e.y,n=e.z;if(s>=0){let o=65536*Math.floor(s/65536);t.x=Math.fround(o),i.x=Math.fround(s-o)}else{let o=65536*Math.floor(-s/65536);t.x=Math.fround(-o),i.x=Math.fround(s+o)}if(r>=0){let o=65536*Math.floor(r/65536);t.y=Math.fround(o),i.y=Math.fround(r-o)}else{let o=65536*Math.floor(-r/65536);t.y=Math.fround(-o),i.y=Math.fround(r+o)}if(n>=0){let o=65536*Math.floor(n/65536);t.z=Math.fround(o),i.z=Math.fround(n-o)}else{let o=65536*Math.floor(-n/65536);t.z=Math.fround(-o),i.z=Math.fround(n+o)}}static doubleToTwoFloat32Array(e,t,i){let s=e.x,r=e.y,n=e.z;if(s>=0){let o=65536*Math.floor(s/65536);t[0]=Math.fround(o),i[0]=Math.fround(s-o)}else{let o=65536*Math.floor(-s/65536);t[0]=Math.fround(-o),i[0]=Math.fround(s+o)}if(r>=0){let o=65536*Math.floor(r/65536);t[1]=Math.fround(o),i[1]=Math.fround(r-o)}else{let o=65536*Math.floor(-r/65536);t[1]=Math.fround(-o),i[1]=Math.fround(r+o)}if(n>=0){let o=65536*Math.floor(n/65536);t[2]=Math.fround(o),i[2]=Math.fround(n-o)}else{let o=65536*Math.floor(-n/65536);t[2]=Math.fround(-o),i[2]=Math.fround(n+o)}}static fromVec(e){return new v(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 v(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 v(e.x,e.y,e.z);return i.addA(t),i}static sub(e,t){let i=new v(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 v(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 v(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 div(e,t){let i=new v(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 ee(this.x,this.y,this.z,1)}clone(){return new v(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 O(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 v(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 v(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 v(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 v(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 v(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 v(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 v;e.copy(this);let t=1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normal(){let e=new v;e.copy(this);let t=1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normalNegate(){let e=new v;e.copy(this);let t=-1/e.length();return e.x*=t,e.y*=t,e.z*=t,e}normalNegateScale(e){let t=new v;t.copy(this);let i=-e/t.length();return t.x*=i,t.y*=i,t.z*=i,t}normalScale(e){let t=new v;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 v(-this.x,-this.y,-this.z)}projToRay(e,t){let i=v.proj_b_to_a(v.sub(this,e),t);return i.addA(e),i}angle(e){return v.angle(this,e)}lerp(e,t){return new v(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 v(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 v;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let l=this.dot(e);return 1-l>v.LERP_DELTA?(i=Math.acos(l),s=Math.sin(i),r=Math.sin((1-t)*i)/s,n=Math.sin(t*i)/s):(r=1-t,n=t),v.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 O.IDENTITY.clone();if(r<-.999999){if(t.equal(v.ZERO)){let n=v.UNIT_X.cross(i);return n.isZero()&&(n=v.UNIT_Y.cross(i)),n.normalize(),O.axisAngleToQuat(n,Math.PI)}return O.axisAngleToQuat(t,Math.PI)}{let n=Math.sqrt(2*(1+r)),o=1/n,l=i.cross(s),h=new O(l.x*o,l.y*o,l.z*o,.5*n);return h.normalize(),h}}}class N{constructor(e=0,t=0){this.x=e,this.y=t}static get UP(){return new N(0,1)}static get DOWN(){return new N(0,-1)}static get RIGHT(){return new N(1,0)}static get LEFT(){return new N(-1,0)}static get ZERO(){return new N}static add(e,t){const i=new N(e.x,e.y);return i.addA(t),i}static sub(e,t){var i=new N(e.x,e.y);return i.subA(t),i}static scale(e,t){let i=new N(e.x,e.y);return i.scale(t),i}static mul(e,t){let i=new N(e.x,e.y);return i.mulA(t),i}static div(e,t){let i=new N(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 N(i.x,i.y):s}toVector3(){return new v(this.x,this.y,0)}clone(){return new N(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 N(this.x+e.x,this.y+e.y)}subA(e){return this.x-=e.x,this.y-=e.y,this}sub(e){return new N(this.x-e.x,this.y-e.y)}scale(e){return this.x*=e,this.y*=e,this}scaleTo(e){return new N(this.x*e,this.y*e)}mulA(e){return this.x*=e.x,this.y*=e.y,this}mul(e){return new N(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 N;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 N.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 N(-this.x,-this.y)}projToRay(e,t){let i=N.proj_b_to_a(N.sub(this,e),t);return i.add(e),i}angle(e){return N.angle(this,e)}lerp(e,t,i){let s=this.clone();return i<=0?s.copy(e):i>=1?s.copy(t):s=N.add(e,N.sub(t,e).scale(i)),s}static get LERP_DELTA(){return 1e-6}slerp(e,t){let i,s,r,n,o=new N;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let l=this.dot(e);return 1-l>N.LERP_DELTA?(i=Math.acos(l),s=Math.sin(i),r=Math.sin((1-t)*i)/s,n=Math.sin(t*i)/s):(r=1-t,n=t),N.add(this.scale(r),e.scale(n))}isZero(){return!(this.x||this.y)}}const Rr={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 hs{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 v(e,e,t),this._radii2=new v(this._a2,this._a2,this._b2),this._invRadii=new v(1/e,1/e,1/t),this._invRadii2=new v(1/this._a2,1/this._a2,1/this._b2)}rhumbDistanceTo(e,t){const i=e.lat*j,s=t.lat*j,r=s-i;let n=Math.abs(t.lon-e.lon)*j;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)),l=Math.abs(o)>1e-11?r/o:Math.cos(i);return Math.sqrt(r*r+l*l*n*n)*this._a}getIntermediatePointOnGreatCircle(e,t,i){if(i==0)return e.clone();if(i==1)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*j,s=e.lon*j,r=t.lat*j,n=t.lon*j,o=Math.sin(n-s)*Math.cos(r),l=Math.cos(i)*Math.sin(r)-Math.sin(i)*Math.cos(r)*Math.cos(n-s);return Math.atan2(o,l)*J}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 v){let r=j*t,n=j*e,o=Math.sin(r),l=this._a/Math.sqrt(1-this._e2*o*o),h=(l+i)*Math.cos(r);return s.x=h*Math.cos(n),s.y=h*Math.sin(n),s.z=(l*(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(r===0)return this.lonLatToCartesian(new A);let n=this._invRadii2.x,o=this._invRadii2.y,l=this._invRadii2.z,h=t*t*n,c=i*i*o,d=s*s*l,u=h+c+d,g=Math.sqrt(1/u),f=e.scaleTo(g);if(u<.1)return Number.isFinite(g)?f:new v;let p=(1-g)*r/f.mulA(this._invRadii2).length(),_=0,m=0,y=0;for(;;){_=1/(1+p*n),m=1/(1+p*o),y=1/(1+p*l);let x=_*_,w=m*m,b=y*y,E=h*x+c*w+d*b-1;if(Math.abs(E)<is)break;p+=.5*E/(h*(x*_)*n+c*(w*m)*o+d*(b*y)*l)}return new v(t*_,i*m,s*y)}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)*J,t.lat=Math.asin(s.z)*J,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 v(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*j,o=e.lon*j,l=t.lat*j,h=t.lon*j-o,c=(1-r)*Math.tan(n),d=1/Math.sqrt(1+c*c),u=c*d,g=(1-r)*Math.tan(l),f=1/Math.sqrt(1+g*g),p=g*f,_=Math.abs(h)>Math.PI/2||Math.abs(l-n)>Math.PI/2;let m=h,y=null,x=null,w=_?Math.PI:0,b=0,E=_?-1:1,C=null,T=1,L=1,M=null,R=0;do{if(y=Math.sin(m),x=Math.cos(m),C=(f*y)**2+(d*p-u*f*x)**2,Math.abs(C)<1e-24)break;b=Math.sqrt(C),E=u*p+d*f*x,w=Math.atan2(b,E);const k=d*f*y/b;L=1-k*k,T=L!=0?E-2*u*p/L:0;const B=r/16*L*(4+r*(4-3*L));M=m,m=h+(1-B)*r*k*(w+B*b*(T+B*E*(2*T*T-1)))}while(Math.abs(m-M)>is&&++R<1e3);const z=L*(i*i-s*s)/(s*s),F=z/1024*(256+z*(z*(74-47*z)-128)),P=s*(1+z/16384*(4096+z*(z*(320-175*z)-768)))*(w-F*b*(T+F/4*(E*(2*T*T-1)-F/6*T*(4*b*b-3)*(4*T*T-3)))),D=Math.abs(C)<Number.EPSILON?0:Math.atan2(f*y,d*p-u*f*x),I=Math.abs(C)<Number.EPSILON?Math.PI:Math.atan2(d*y,-u*f+d*p*x);return{distance:P,initialAzimuth:Math.abs(P)<Number.EPSILON?NaN:Rt(D)*J,finalAzimuth:Math.abs(P)<Number.EPSILON?NaN:Rt(I)*J}}direct(e,t,i){let s=e.lon,r=e.lat,n=this._a,o=this._b,l=this._flattening,h=i,c=t*j,d=Math.sin(c),u=Math.cos(c),g=(1-l)*Math.tan(r*j),f=1/Math.sqrt(1+g*g),p=g*f,_=Math.atan2(g,u),m=f*d,y=1-m*m,x=y*(n*n-o*o)/(o*o),w=1+x/16384*(4096+x*(x*(320-175*x)-768)),b=x/1024*(256+x*(x*(74-47*x)-128)),E=h/(o*w),C=2*Math.PI,T=0,L=0,M=0,R=0;for(;Math.abs(E-C)>1e-12;)T=Math.cos(2*_+E),L=Math.sin(E),M=Math.cos(E),R=b*L*(T+b/4*(M*(2*T*T-1)-b/6*T*(4*L*L-3)*(4*T*T-3))),C=E,E=h/(o*w)+R;let z=p*L-f*M*u,F=Math.atan2(p*M+f*L*u,(1-l)*Math.sqrt(m*m+z*z)),P=l/16*y*(4+l*(4-3*y)),D=Math.atan2(L*d,f*M-p*L*u)-(1-P)*l*m*(E+P*L*(T+P*M*(2*T*T-1))),I=Math.atan2(m,-z);return{destination:new A(s+D*J,F*J),finalAzimuth:I*J}}hitRay(e,t){let i,s,r,n,o,l=this._invRadii.mul(e),h=this._invRadii.mul(t),c=l.dot(l),d=l.dot(h);if(c>1){if(d>=0)return;var u=d*d;if(i=c-1,s=h.dot(h),r=s*i,Math.abs(u-r)>1e-15&&u<r)return;if(u>r){n=d*d-r,o=-d+Math.sqrt(n);var g=o/s,f=i/o;return g<f?e.add(t.scaleTo(g)):e.add(t.scaleTo(f))}var p=Math.sqrt(i/s);return e.add(t.scaleTo(p))}return c<1?(i=c-1,s=h.dot(h),r=s*i,n=d*d-r,o=-d+Math.sqrt(n),e.add(t.scaleTo(o/s))):d<0?(s=h.dot(h),e.add(t.scaleTo(-d/s))):void 0}getNorthFrameRotation(e){let t=this.getSurfaceNormal3v(e),i=v.proj_b_to_plane(v.NORTH,t);return O.getLookRotation(i,t)}getBearingDestination(e,t=0,i=0){t*=j;var s=(e.lon+540)%360-180,r=e.lat*j,n=s*j,o=i/this._a,l=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(l)))*J,l*J)}static getIntermediatePointOnGreatCircle(e,t,i){var s=e.lat*j,r=e.lon*j,n=t.lat*j,o=t.lon*j,l=Math.sin(s),h=Math.cos(s),c=Math.sin(r),d=Math.cos(r),u=Math.sin(n),g=Math.cos(n),f=Math.sin(o),p=Math.cos(o),_=n-s,m=o-r,y=Math.sin(_/2)*Math.sin(_/2)+Math.cos(s)*Math.cos(n)*Math.sin(m/2)*Math.sin(m/2),x=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),w=Math.sin((1-i)*x)/Math.sin(x),b=Math.sin(i*x)/Math.sin(x),E=w*h*d+b*g*p,C=w*h*c+b*g*f,T=w*l+b*u,L=Math.atan2(T,Math.sqrt(E*E+C*C)),M=Math.atan2(C,E);return new A((M*J+540)%360-180,L*J)}static getRhumbBearing(e,t){var i=(t.lon-e.lon)*j,s=Math.log(Math.tan(t.lat*j/2+Math.PI/4)/Math.tan(e.lat*j/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)*J+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),l=s.sub(e);let h;return h=o>0?Math.sqrt((n+o)**2-n**2):n,h>l.length()&&(!i||i.dot(l.normalize())>0)}}const Br=new hs(6378137,6356752314245179e-9);function zi(a,e){return a??e}function Ge(a){return a==null}function kr(a){return a===void 0}let nl=0;function cs(a){let e=a._openglobus_id;return e||(e=a._openglobus_id=++nl),e}function Di(a){return typeof a=="string"||a instanceof String}function It(a){return a.toString(16).padStart(2,"0")}function ds(a){let e,t,i;return a instanceof Array?(e=It(a[0]),t=It(a[1]),i=It(a[2])):(e=It(a.x),t=It(a.y),i=It(a.z)),`#${e}${t}${i}`}function it(a,e){let t=Rr[a];if(t&&(a=t),a[0]==="#"){let i=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,s=a.replace(i,function(n,o,l,h){return o+o+l+l+h+h}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return r?new ee(parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255,Ge(e)?1:e):new ee}{Ge(e)&&(e=1);let i=a.split(",");return new ee(parseInt(i[0].split("(")[1])/255,parseInt(i[1])/255,parseInt(i[2])/255,Ge(i[3])?e:parseFloat(i[3]))}}function _t(a,e){let t=it(a,e);return new Float32Array([t.x,t.y,t.z,t.w])}function Fi(a){let e=Rr[a];if(e&&(a=e),a[0]==="#"){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=a.replace(t,function(r,n,o,l){return n+n+o+o+l+l}),s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return s?new v(parseInt(s[1],16)/255,parseInt(s[2],16)/255,parseInt(s[3],16)/255):new v}{let t=a.split(",");return new v(parseInt(t[0].split("(")[1])/255,parseInt(t[1])/255,parseInt(t[2])/255)}}function He(a,e){return a.replace(/{[^{}]+}/g,function(t){return e[t.replace(/[{}]+/g,"")]||""})}function Qt(a,e){return a.replace(/\$\{([^}]+)\}/g,(t,i)=>(e==null?void 0:e[i.trim()])??"")}function us(a){let e=document.createElement("div");e.innerHTML=a;let t=[];for(let i=0;i<e.childNodes.length;i++)t.push(e.childNodes[i]),e.removeChild(e.childNodes[i]);return t}function Ir(a,e,t,i){let s=document.getElementById(a);s||(s=document.createElement("div"),s.id=a,s.classList.add("defaultText"),document.body.appendChild(s)),s.innerHTML=e,s.style.left=`${t}px`,s.style.top=`${i}px`}function zr(a){return typeof a=="number"}function Dr(a,e=""){return a?a.trim():e}function je(a,e){if(a){if(zr(a))return new v(a,a,a);if(a instanceof v)return a.clone();if(a instanceof Array)return v.fromVec(a);if(a instanceof N)return new v(a.x,a.y,0)}else if(e)return e;return new v}function st(a,e){if(a){if(Di(a))return it(a);if(a instanceof Array)return ee.fromVec(a);if(a instanceof ee)return a.clone()}else if(e)return e;return new ee(1,1,1,1)}function Ye(a,e){if(a){if(Di(a))return Fi(a);if(a instanceof Array)return v.fromVec(a);if(a instanceof v)return a.clone()}else if(e)return e;return new v(1,1,1)}function _s(a,e){if(a){if(a instanceof Array)return new G(Oi(a[0]),Oi(a[1]));if(a instanceof G)return a.clone()}else if(e)return e;return new G}function Oi(a,e){if(a){if(a instanceof Array)return new A(a[0],a[1],a[2]);if(a instanceof A)return a.clone()}else if(e)return e;return new A}function fs(a,e){let t=0,i=a.length-1;for(;t<=i;){let s=Math.floor(.5*(t+i));if(Math.abs(a[s]-e)<.001)return s;a[s]<e?t=s+1:i=s-1}return-1}function yt(a,e,t){let i=0,s=a.length-1;for(;i<=s;){let r=s+i>>1,n=t(e,a[r],r);if(n>0)i=r+1;else{if(!(n<0))return r;s=r-1}}return-i-1}function gs(a,e,t){let i=yt(a,e,t);return i<0&&(i=~i),a.splice(i,0,e),i}function Fr(a,e,t,i,s=!1){let r=new A(e.lon-a.lon,e.lat-a.lat),n=new A(i.lon-t.lon,i.lat-t.lat),o=-r.lat,l=+r.lon,h=-(o*a.lon+l*a.lat),c=-n.lat,d=+n.lon,u=-(c*t.lon+d*t.lat),g=c*a.lon+d*a.lat+u,f=c*e.lon+d*e.lat+u,p=o*t.lon+l*t.lat+h,_=o*i.lon+l*i.lat+h;if(s&&(g*f>0||p*_>0))return;let m=g/(g-f);return new A(a.lon+m*r.lon,a.lat+m*r.lat)}const ol={string:function(a){return Ge(a)?a:a.toString()},date:function(a){return Ge(a)?a:new Date(1e3*a)},datetime:function(a){return Ge(a)?a:new Date(1e3*a)},time:function(a){return Ge(a)?a:parseInt(a)},integer:function(a){return Ge(a)?a:parseInt(a)},float:function(a){return Ge(a)?a:parseFloat(a)},boolean:function(a){if(a===null)return a;if(typeof a=="boolean")return a===!0;if(typeof a=="string"){if(a==="")return!1;if((a=a.replace(/^\s+|\s+$/g,"")).toLowerCase()==="true"||a.toLowerCase()==="yes")return!0;a=(a=a.replace(/,/g,".")).replace(/^\s*\-\s*/g,"-")}return!isNaN(a)&&parseFloat(a)!==0}};function Or(a,e=""){let t=1024,i=atob(a),s=i.length,r=Math.ceil(s/t),n=new Array(r);for(let o=0;o<r;++o){let l=o*t,h=Math.min(l+t,s),c=new Array(h-l);for(let d=l,u=0;d<h;++u,++d)c[u]=i[d].charCodeAt(0);n[o]=new Uint8Array(c)}return new Blob(n,{type:e})}function Kt(a,e,t=!1){let i,s=0;return function(){const r=arguments;s?(t&&clearTimeout(i),i=setTimeout(()=>{Date.now()-s>=e&&(a.apply(null,r),s=Date.now())},e-(Date.now()-s))):(a.apply(null,r),s=Date.now())}}function ae(a,e){let t=new a.constructor(a.length+e.length);return t.set(a,0),t.set(e,a.length),t}function xe(a=[],e=[]){if(ArrayBuffer.isView(a))return ae(a,e);for(let t=0;t<e.length;t++)a.push(e[t]);return a}function se(a,e=Float32Array){if(ArrayBuffer.isView(a))return a;{const t=new e(a.length);return t.set(a,0),t}}function zt(a){return ArrayBuffer.isView(a)?Array.from(a):a}function Ae(a,e,t,i){if(ArrayBuffer.isView(a))return e<0&&(t=Math.abs(e),e+=a.length),le(a,e,t,i);{let s;return s=e<0?a.splice(e):a.splice(e,t),i&&(i.result=s),a}}function le(a,e,t,i){if(a.length===0)return a;const s=a.length-t,r=new a.constructor(s);return r.set(a.subarray(0,e)),r.set(a.subarray(e+t),e),i&&(i.result=a.subarray(e,e+t)),r}function ps(a,e,t,i,s){const r=s+1,n=t+r,o=i+r;let l=new Float64Array(r*r*3),h=0;for(let c=t;c<n;c++)for(let d=i;d<o;d++){let u=3*(c*(e+1)+d);l[h++]=a[u],l[h++]=a[u+1],l[h++]=a[u+2]}return l}function Nr(a,e,t,i,s){const r=s+1,n=t+r,o=i+r;let l=new Float32Array(r*r*3),h=0;for(let c=t;c<n;c++)for(let d=i;d<o;d++){let u=3*(c*(e+1)+d);l[h++]=a[u],l[h++]=a[u+1],l[h++]=a[u+2]}return l}function ms(a,e,t,i,s,r,n,o,l,h,c,d,u){const g=r+o+1,f=n+o+1;s+=1;let p=0,_=0;for(let m=r;m<g;m++)for(let y=n;y<f;y++){let x=m*s+y,w=3*x,b=a[w],E=a[w+1],C=a[w+2];i&&i[x]!==0?u[_]=1:(b<d.xmin&&(d.xmin=b),b>d.xmax&&(d.xmax=b),E<d.ymin&&(d.ymin=E),E>d.ymax&&(d.ymax=E),C<d.zmin&&(d.zmin=C),C>d.zmax&&(d.zmax=C)),_++,l[p]=b,c[p]=t[w],h[p++]=e[w],l[p]=E,c[p]=t[w+1],h[p++]=e[w+1],l[p]=C,c[p]=t[w+2],h[p++]=e[w+2]}}function vs(a){return a.map(e=>Array.isArray(e)?vs(e):e)}async function Ni(a){return new Promise(e=>{const t=new Image;return t.addEventListener("load",()=>{e(t)}),t.src=a,t.crossOrigin="",t})}function ys(a){return a.complete&&a.naturalHeight!==0}function Dt(a){return a>1e3?a-Math.floor(a)!=0?[(a/1e3).toFixed(2),"km"]:[(a/1e3).toFixed(0),"km"]:a>9?[Math.round(a).toString(),"m"]:a<=.01?["0","m"]:[a.toFixed(1),"m"]}function Hr(a){let e=new URLSearchParams(location.search).get(a);if(e)return Number(e)}function xs(a,e=-1){if(e<0)return a.toString();const t=Math.pow(10,e);return(Math.round(a*t)/t).toString()}const Hi=Object.freeze(Object.defineProperty({__proto__:null,base64StringToBlog:function(a){let e=a.split(";"),t=e[0].split(":")[1];return Or(e[1].split(",")[1],t)},base64toBlob:Or,binaryInsert:gs,binarySearch:yt,binarySearchFast:fs,blerp:function(a,e,t,i,s,r,n=0,o=1,l=0,h=1){return(t*(o-a)*(h-e)+i*(a-n)*(h-e)+s*(o-a)*(e-l)+r*(a-n)*(e-l))/((o-n)*(h-l))},blerp2:function(a,e,t,i,s,r){return t*(1-a)*(1-e)+i*a*(1-e)+s*(1-a)*e+r*a*e},castType:ol,cloneArray:vs,concatArrays:xe,concatTypedArrays:ae,createColorRGB:Ye,createColorRGBA:st,createExtent:_s,createLonLat:Oi,createVector3:je,createVector4:function(a,e){if(a){if(a instanceof ee)return a.clone();if(a instanceof Array)return ee.fromVec(a)}else if(e)return e;return new ee},defaultString:Dr,distanceFormat:function(a){return a>1e3?`${(a/1e3).toFixed(2)} km`:a>9?`${Math.round(a)} m`:`${a.toFixed(1)} m`},distanceFormatExt:Dt,extractElevationTiles:function(a,e,t){let i=Math.sqrt(e.length)-1,s=i+1,r=Math.sqrt(a.length/4),n=r/i,o=0,l=0;for(let h=0,c=0,d=a.length/4;h<d;h++){let u=a[4*h],g=Math.floor(h/r),f=h%r,p=Math.floor(f/i),_=Math.floor(g/i),m=t[_][p],y=g%i,x=f%i,w=(y+_)*s+x+p;if(m[w]=u,(g+_)%n==0&&(f+p)%n==0&&(e[c++]=u),(f+1)%i==0&&f!==r-1){o=a[4*(h+1)];let b=.5*(u+o);w=(y+_)*s+x+1,m[w]=b,(g+_)%n==0&&(e[c++]=b);let E=(y+_)*s+(x+1)%i;t[_][p+1][E]=b}if((g+1)%i==0&&g!==r-1){l=a[4*(h+r)];let b=.5*(u+l);w=(y+1)*s+x+p,m[w]=b,(f+p)%n==0&&(e[c++]=b);let E=(y+1)%i*s+x+p;t[_+1][p][E]=b}if((f+1)%i==0&&f!==r-1&&(g+1)%i==0&&g!==r-1){let b=.25*(u+o+l+a[4*(h+r+1)]);w=(y+1)*s+(x+1),m[w]=b,e[c++]=b;let E=(y+1)*s;t[_][p+1][E]=b;let C=i;t[_+1][p][C]=b;let T=0;t[_+1][p+1][T]=b}}},getDefault:zi,getHTML:function(a,e){return He(a,e)},getLinesIntersection2v:function(a,e,t,i,s){let r=e.sub(a),n=i.sub(t),o=-r.y,l=+r.x,h=-(o*a.x+l*a.y),c=-n.y,d=+n.x,u=-(c*t.x+d*t.y),g=c*a.x+d*a.y+u,f=c*e.x+d*e.y+u,p=o*t.x+l*t.y+h,_=o*i.x+l*i.y+h;if(s&&(g*f>0||p*_>0))return;let m=g/(g-f);return new N(a.x+m*r.x,a.y+m*r.y)},getLinesIntersectionLonLat:Fr,getMatrixSubArray32:Nr,getMatrixSubArray64:ps,getMatrixSubArrayBoundsExt:ms,getTileImageResolution:function(a,e,t,i=256,s=Br){let r=kt(a,e,t),n=r.getSouthWest().inverseMercator(),o=r.getNorthEast().inverseMercator();return[s.getGreatCircleDistance(n,new A(o.lon,n.lat))/i,s.getGreatCircleDistance(n,new A(n.lon,o.lat))/i]},getUrlParam:Hr,htmlColorToFloat32Array:_t,htmlColorToRgb:Fi,htmlColorToRgba:it,isEmpty:Ge,isImageLoaded:ys,isNumber:zr,isString:Di,isUndef:kr,isUndefExt:function(a,e){return kr(a)?e:a},loadImage:Ni,makeArray:zt,makeArrayTyped:se,parseHTML:us,print2d:Ir,rgbToStringHTML:ds,spliceArray:Ae,spliceTypedArray:le,stamp:cs,stringTemplate:He,stringTemplate2:Qt,throttle:Kt,toFixedMax:xs,xmlToJson:function a(e){let t={};if(e.nodeType===1){if(e.attributes.length>0){t["@attributes"]={};for(let i=0;i<e.attributes.length;i++){let s=e.attributes.item(i);t["@attributes"][s.nodeName]=s.nodeValue}}}else e.nodeType===3&&(t=e.nodeValue);if(e.hasChildNodes())for(let i=0;i<e.childNodes.length;i++){let s=e.childNodes.item(i),r=s.nodeName;if(t[r]===void 0)t[r]=a(s);else{if(t[r].push===void 0){let n=t[r];t[r]=[],t[r].push(n)}t[r].push(a(s))}}return t}},Symbol.toStringTag,{value:"Module"})),Vi=1e3,bs=1/60,Vr=1/24,Jt=3600,ws=1/Jt,Cs=43200,Ui=1440,al=1/Ui,Xe=86400,ll=864e5,Ts=11574074074074074e-24,rt=1/Xe,Gi=2451545;function Ur(a,e,t){let i=(e-14)/12|0,s=a+4800+i;return(1461*s/4|0)+(367*(e-2-12*i)/12|0)-(3*((s+100)/100|0)/4|0)+t-32075}function ji(a){let e=Ur(a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate()),t=a.getUTCHours()-12;t<0&&(t+=24);let i=a.getUTCSeconds()+t*Jt+60*a.getUTCMinutes()+.001*a.getUTCMilliseconds();i>=Cs&&e--;let s=i*rt|0;return e+=s,i-=Xe*s,i<0&&(e--,i+=Xe),e+i*rt}function Es(a){let e=Yr,t=yt(e,a,function(s,r){return s-r.jd});t<0&&(t=~t),t>=e.length&&(t=e.length-1);let i=e[t].leapSeconds;return t!==0&&(e[t].jd-a)*Xe>i&&(i=e[t-1].leapSeconds),a+i*rt}function As(a){let e=Yr,t=yt(e,a,function(s,r){return s-r.jd});if(t<0&&(t=~t),t>=e.length)return a-e[t-1].leapSeconds*rt;if(t===0)return a-e[0].leapSeconds*rt;let i=(e[t].jd-a)*Xe;return i===0?a-e[t].leapSeconds*rt:i<=1?void 0:a-e[t-1].leapSeconds*rt}function Ls(a){let e=0|a,t=(a-e)*Xe;t>=Cs&&e++;let i=e+68569|0,s=4*i/146097|0;i=i-((146097*s+3)/4|0)|0;let r=4e3*(i+1)/1461001|0;i=i-(1461*r/4|0)+31|0;let n=80*i/2447|0,o=i-(2447*n/80|0)|0;i=n/11|0;let l=n+2-12*i|0,h=100*(s-49)+r+i|0,c=t*ws|0,d=t-c*Jt,u=d*bs|0;d-=60*u;let g=0|d,f=(d-g)*Vi|0;return c+=12,c>23&&(c-=24),new Date(Date.UTC(h,l-1,o,c,u,g,f))}function Gr(a,e){return a+e*Ts}function jr(a,e){return a+e*rt}function re(a,e){return{jd:a,leapSeconds:e}}const Yr=[re(24413175e-1,10),re(24414995e-1,11),re(24416835e-1,12),re(24420485e-1,13),re(24424135e-1,14),re(24427785e-1,15),re(24431445e-1,16),re(24435095e-1,17),re(24438745e-1,18),re(24442395e-1,19),re(24447865e-1,20),re(24451515e-1,21),re(24455165e-1,22),re(24462475e-1,23),re(24471615e-1,24),re(24478925e-1,25),re(24482575e-1,26),re(24488045e-1,27),re(24491695e-1,28),re(24495345e-1,29),re(24500835e-1,30),re(24506305e-1,31),re(24511795e-1,32),re(24537365e-1,33),re(24548325e-1,34),re(24561095e-1,35),re(24572045e-1,36)],hl=Es(Gi);Object.freeze(Object.defineProperty({__proto__:null,DAYS_PER_JULIAN_CENTURY:36525,DAYS_PER_JULIAN_YEAR:365.25,DateToTAI:function(a){return Es(ji(a))},DateToUTC:ji,HOURS_PER_DAY:24,J2000:Gi,J2000TAI:hl,MILLISECONDS_PER_DAY:ll,MILLISECONDS_PER_SECOND:Vi,MINUTES_PER_DAY:Ui,MINUTES_PER_HOUR:60,MODIFIED_JULIAN_DATE_DIFFERENCE:24000005e-1,ONE_BY_HOURS_PER_DAY:Vr,ONE_BY_MILLISECONDS_PER_DAY:Ts,ONE_BY_MINUTES_PER_DAY:al,ONE_BY_SECONDS_PER_DAY:rt,ONE_BY_SECONDS_PER_HOUR:ws,ONE_BY_SECONDS_PER_MINUTE:bs,PICOSECOND:1e-9,SECONDS_PER_12_HOURS:Cs,SECONDS_PER_DAY:Xe,SECONDS_PER_HOUR:Jt,SECONDS_PER_MILLISECOND:.001,SECONDS_PER_MINUTE:60,T:function(a){return(a-Gi)/36525},TAItoDate:function(a){let e=As(a);return e||(e=As(jr(a,-1)),console.trace(`TAItoDate - can't convert ${a.toString()} to utc.`)),Ls(e)},TAItoUTC:As,UTCtoDate:Ls,UTCtoTAI:Es,addDays:function(a,e){return a+e},addHours:function(a,e){return a+e*Vr},addMilliseconds:Gr,addMinutes:function(a,e){return a+e*Ui},addSeconds:jr,daysToSeconds:function(a){return a*Xe},getDayNumber:Ur,getDays:function(a){return 0|a},getHours:function(a){let e=(a-(0|a))*Xe,t=e*ws|0,i=e-t*Jt,s=i*bs|0;i-=60*s;let r=0|i;return t+=12+s/60+r/3600+((i-r)*Vi|0)/1e3,t>23&&(t-=24),t},getMilliseconds:function(a){let e=a-(0|a);return e*=Xe,(e-(0|e))*Vi|0},getMinutes:function(a){return(a-(0|a))*Ui|0},getSeconds:function(a){return(a-(0|a))*Xe},secondsToDays:function(a){return a*rt}},Symbol.toStringTag,{value:"Module"}));class qr{constructor(e){this.vertices=[new v,new v,new v,new v,new v,new v,new v,new v],e&&this.setFromBoundsArr(e)}copy(e){for(let t=0,i=this.vertices.length;t<i;t++)this.vertices[t].copy(e.vertices[t])}setFromBoundsArr(e){let t=e[0],i=e[3],s=e[1],r=e[4],n=e[2],o=e[5],l=this.vertices;l[0].set(t,s,n),l[1].set(i,s,n),l[2].set(i,s,o),l[3].set(t,s,o),l[4].set(t,r,n),l[5].set(i,r,n),l[6].set(i,r,o),l[7].set(t,r,o)}setFromExtent(e,t){this.setFromBoundsArr(t.getCartesianBounds(e))}}class Ve{constructor(e=0,t){this.radius=e,this.center=t?t.clone():new v}setFromBounds(e){let t=new v(e[0],e[1],e[2]);this.center.set(t.x+.5*(e[3]-t.x),t.y+.5*(e[3]-t.y),t.z+.5*(e[5]-t.z)),this.radius=this.center.distance(t)}setFromExtent(e,t){this.setFromBounds(t.getCartesianBounds(e))}}Object.freeze(Object.defineProperty({__proto__:null,Box:qr,Sphere:Ve},Symbol.toStringTag,{value:"Module"}));function he(a,e){return new Ps(a,e)}const Wr=class Pa{constructor(e,t){this.__id=Pa.__counter__++,this._eventNames=[],e&&this.registerNames(e),this._sender=t||this,this._stopPropagation=!1,this._stampCache={}}bindSender(e){this._sender=e||this}registerNames(e){for(let t=0;t<e.length;t++)this[e[t]]={active:!0,handlers:[]},this._eventNames.push(e[t]);return this}_getStamp(e,t,i){return`${e}_${t}_${i}`}_stamp(e,t){let i=cs(t),s=this._getStamp(e,this.__id,i);return!this._stampCache[s]&&(this._stampCache[s]=i,!0)}on(e,t,i,s=0){if(this._stamp(e,t)&&this[e]){let r=t.bind(i||this._sender);r._openglobus_id=t._openglobus_id,r._openglobus_priority=s,gs(this[e].handlers,r,(n,o)=>(o._openglobus_priority||0)-(n._openglobus_priority||0))}}off(e,t){if(t){let i=this._getStamp(e,this.__id,t._openglobus_id);if(t._openglobus_id&&this._stampCache[i]){let s=this[e].handlers,r=s.length,n=-1;for(;r--;)if(s[r]._openglobus_id===t._openglobus_id){n=r;break}n!==-1&&(s.splice(n,1),this._stampCache[i]=void 0,delete this._stampCache[i])}}}dispatch(e,...t){let i=!0;if(e&&e.active&&!this._stopPropagation){let s=e.handlers.slice(0),r=s.length;for(;r--;)s[r](...t)===!1&&(i=!1)}return this._stopPropagation=!1,i}stopPropagation(){this._stopPropagation=!0}clear(){for(let e=0;e<this._eventNames.length;e++){let t=this[this._eventNames[e]];t.handlers.length=0,t.handlers=[]}this._eventNames.length=0,this._eventNames=[]}};Wr.__counter__=0;let Ps=Wr;const cl=["render"],$r=class Je{constructor(e={}){this.__id=Je.__counter__++,this.events=he(cl),this.model=e.model||null,this.template=e.template||"",this.parent=e.parent||null,this._classList=e.classList||[],this.el=null,e.initRender&&this.render()}on(e,t,i,s){this.events.on(e,t,i,s)}off(e,t){this.events.off(e,t)}static getHTML(e,t){return He(e,t)}static parseHTML(e){return us(e)}static insertAfter(e,t){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)t.parentNode&&t.parentNode.insertBefore(e[i],t.nextSibling);return e}static insertBefore(e,t){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)t.parentNode&&t.parentNode.insertBefore(e[i],t);return e}insertBefore(e){this.el||this.render(),this.el&&(e instanceof HTMLElement&&e.parentNode&&Je.insertBefore(this.el,e),e instanceof Je&&e.el&&e.el.parentNode&&Je.insertBefore(this.el,e.el))}insertAfter(e){this.el||this.render(),this.el&&(e instanceof HTMLElement&&e.parentNode&&Je.insertAfter(this.el,e),e instanceof Je&&e.el&&e.el.parentNode&&Je.insertAfter(this.el,e.el))}isEqual(e){return e.__id===this.__id}appendTo(e,t=!1,i=!1){return e&&(this.el||(this.beforeRender(e),this.render()),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),t&&(e.innerHTML=""),this.el&&(i&&e.childNodes[0]?Je.insertBefore(this.el,e.childNodes[0]):e.appendChild(this.el)),this.afterRender(e)),this}afterRender(e){}beforeRender(e){}stopPropagation(){this.events.stopPropagation()}renderTemplate(e){return Je.parseHTML(Je.getHTML(this.template,e||{}))[0]}render(e){this.el=this.renderTemplate(e);for(let t=0,i=this._classList.length;t<i;t++)this.el.classList.add(this._classList[t]);return this.events.dispatch(this.events.render,this),this}select(e){return this.el?this.el.querySelector(e):null}selectRemove(e){if(this.el){let t=this.select(e);if(t&&t.parentNode)return t.parentNode.removeChild(t),t}}selectAll(e,t){if(this.el){const i=this.el.querySelectorAll(e);if(t)for(let s=0,r=i.length;s<r;s++)t(i[s],s);return i}}remove(){this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}};$r.__counter__=0;let be=$r;const dl=["click","mousedown","mouseup","touchstart","touchend","touchcancel"];class nt extends be{constructor(e={}){super({template:He(`<div class="og-button" title="{title}">
1
+ (function(ce,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],S):(ce=typeof globalThis<"u"?globalThis:ce||self,S(ce["@openglobus/openglobus-react"]={},ce.React))})(this,function(ce,S){"use strict";function Ko(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const Fe=Ko(S),ys=S.createContext({globe:null,setGlobe:()=>{}}),Jo=({children:a})=>{const[e,t]=S.useState(null);return Fe.createElement(ys.Provider,{value:{globe:e,setGlobe:t}},a)},dt=()=>S.useContext(ys),Pi=2*Math.PI,xs=Math.PI/2,tr=Number.MAX_VALUE||17976931348623157e292,bs=Math.log(2),mt=2147483647,ye=549755748352,Te=-549755748352,U=Math.PI/180,J=180/Math.PI,ir=2*J,Xe=.5*U,ws=Math.sqrt(.5),Cs=1e-5,tt=1e-10,rr=1e-12,sr=1e-14;function Si(a,e,t){return Math.max(e,Math.min(a,t))}function Mi(a){return!(a&a-1)}function St(a,e=4096){--a;for(let t=1;t<32;t<<=1)a|=a>>t;return a+1>e?e:a+1}function Ri(a=0,e=1){return Math.floor(Math.random()*(e-a))+a}function Ts(a,e){return(a%e+e)%e}function Mt(a){const e=Ts(a,Pi);return Math.abs(e)<sr&&Math.abs(a)>sr?Pi:e}function Yt(a){const e=Math.abs(a);return e-Math.floor(e)}function Es(a,e,t){return t+a*(e-t)}function nr(a){return a*a*a}function ar(a){return a*a}function or(a){return a-360*Math.floor(a/360)}Object.freeze(Object.defineProperty({__proto__:null,ARCSECONDS_TO_RADIANS:484813681109536e-20,DEG2RAD:function(a){return a*U},DEGREES:J,DEGREES_DOUBLE:ir,DEGREES_TO_HOURS:1/15,EPS1:.1,EPS10:tt,EPS11:1e-11,EPS12:rr,EPS13:1e-13,EPS14:sr,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:Cs,EPS6:1e-6,EPS7:1e-7,EPS8:1e-8,EPS9:1e-9,HOURS_TO_DEGREES:15,HOURS_TO_RADIANS:.26179938779914946,LOG2:bs,MAX:ye,MAX32:mt,MAX_FLOAT:tr,MIN:Te,PI_TWO:xs,RAD2DEG:function(a){return a*J},RADIANS:U,RADIANS_HALF:Xe,RADIANS_TO_HOURS:3.819718634205488,SQRT_HALF:ws,TWO_PI:Pi,W:3,X:0,Y:1,Z:2,bezier1v:function(a,e,t,i,r){return nr(1-a)*e+3*ar(1-a)*a*t+3*(1-a)*ar(a)*i+nr(a)*r},bezier3v:function(a,e,t,i,r){let s=1-a,n=a*a,o=s*s,l=o*s,h=n*a;return e.scaleTo(l).addA(t.scaleTo(3*o*a)).addA(i.scaleTo(3*s*n)).addA(r.scaleTo(h))},clamp:Si,cube:nr,degToDec:function(a,e,t,i){return i?a+e/60+t/3600:-a-e/60-t/3600},exp2:function(a){return Math.pow(2,a)},frac:Yt,getAngleBetweenAzimuths:function(a,e){return(((a=Mt(a))-(e=Mt(e)))%360+360+180)%360-180},isPowerOfTwo:Mi,lerp:Es,log:function(a,e){return Math.log(a)/Math.log(e)},log2:function(a){return Math.log(a)/bs},mod:Ts,negativePItoPI:function(a){return Mt(a+Math.PI)-Math.PI},nextHighestPowerOfTwo:St,norm_lon:function(a){return a>180?(a+180)%360-180:a<-180?(a-180)%360+180:a},pow2i:function(a){return 2<<a-1},random:function(a=0,e=1){return Math.random()*(e-a)+a},randomi:Ri,rev:or,slice:function(a,e,t){return a*(e-t)},solve_iteration:function(a,e,t,i=50){let r=0,s=e;for(let n=0;n<i;n++)if(r=s,s=a(r),Math.abs(s-r)<t)return s;return s},solve_iteration_fixed:function(a,e,t){let i=0,r=e;for(let s=0;s<t;s++)i=r,r=a(i);return r},square:ar,step:function(a,e){return e<a?0:1},zeroTwoPI:Mt},Symbol.toStringTag,{value:"Module"}));const el=.5*Math.PI,As=180/Math.PI,tl=2*As,lr=Math.PI/360,il=As*el;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 this.lon===0&&this.lat===0&&this.height===0}static join(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];t[i]=new A(r[0],r[1],r[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*ki,Math.log(Math.tan((90+t)*lr))*Rt,i)}static forwardMercatorRes(e,t){return t.lon=e.lon*ki,t.lat=Math.log(Math.tan((90+e.lat)*lr))*Rt,t.height=e.height,t}static inverseMercator(e,t,i=0){return new A(e*Ls,tl*Math.atan(Math.exp(t*hr))-il,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*ki,Math.log(Math.tan((90+e)*lr))*Rt)}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 Ee=2003750834e-2,Bi=2*Ee,hr=Math.PI/Ee,Rt=Ee/Math.PI,rl=.5*Math.PI,ki=Ee/180,Ls=180/Ee,Ps=Math.PI/360,Ss=Math.PI/180,sl=180/Math.PI,Ms=2*Ee,Wt=1/Ms;function Ii(a){return new A(a.lon*Ee/180,Math.log(Math.tan((90+a.lat)*Ps))*Rt,a.height)}function $t(a){return a*Ee/180}function Xt(a){return Math.log(Math.tan((90+a)*Ps))*Rt}function Rs(a){return sl*(2*Math.atan(Math.exp(a*hr))-rl)}function Bt(a,e,t){let i=Bi/(1<<t),r=new A(a*i-2003750834e-2,Ee-e*i-i);return new j(r,new A(r.lon+i,r.lat+i))}const de=Rs(Ee),Oe=-de;Object.freeze(Object.defineProperty({__proto__:null,INV_POLE_BY_180:Ls,MAX_LAT:de,MIN_LAT:Oe,ONE_BY_POLE_DOUBLE:Wt,PI_BY_POLE:hr,POLE:Ee,POLE2:Bi,POLE_BY_180:ki,POLE_BY_PI:Rt,POLE_DOUBLE:Ms,forward:Ii,forwardArray:function(a){let e=[];for(let t=0;t<a.length;t++)e.push(a[t].forwardMercator());return e},forward_lat:Xt,forward_lon:$t,getTileExtent:Bt,getTileX:function(a,e){return Math.floor((a+180)/360*Math.pow(2,e))},getTileY:function(a,e){return Math.floor(.5*(1-Math.log(Math.tan(a*Ss)+1/Math.cos(a*Ss))/Math.PI)*Math.pow(2,e))},inverse_lat:Rs,inverse_lon:function(a){return 180*a/Ee}},Symbol.toStringTag,{value:"Module"}));class j{constructor(e=new A,t=new A){this.southWest=e,this.northEast=t}static createFromArray(e){return new j(new A(e[0],e[1]),new A(e[2],e[3]))}static createByCoordinates(e){let t=ye,i=Te,r=ye,s=Te;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<r&&(r=o.lat),o.lat>s&&(s=o.lat)}return new j(new A(t,r),new A(i,s))}static createByCoordinatesArr(e){let t=ye,i=Te,r=ye,s=Te;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]<r&&(r=o[1]),o[1]>s&&(s=o[1])}return new j(new A(t,r),new A(i,s))}static fromTile(e,t,i,r=4007501668e-2,s=4007501668e-2){const n=1<<i,o=r/n,l=s/n,h=.5*-r+e*o,c=.5*s-t*l,d=h+o;return new j(new A(h,c-l),new A(d,c))}setByCoordinates(e){let t=ye,i=Te,r=ye,s=Te;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<r&&(r=o.lat),o.lat>s&&(s=o.lat)}return this.southWest.lon=t,this.southWest.lat=r,this.northEast.lon=i,this.northEast.lat=s,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 j(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 j(this.southWest.forwardMercator(),this.northEast.forwardMercator())}inverseMercator(){return new j(this.southWest.inverseMercator(),this.northEast.inverseMercator())}getCartesianBounds(e){let t=ye,i=Te,r=ye,s=Te,n=ye,o=Te;const l=[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 h=0;h<l.length;h++){const c=e.lonLatToCartesian(l[h]),d=c.x,u=c.y,g=c.z;d<t&&(t=d),d>i&&(i=d),u<r&&(r=u),u>s&&(s=u),g<n&&(n=g),g>o&&(o=g)}return[t,r,n,i,s,o]}toString(){return`[${this.southWest.lon.toFixed(5)}, ${this.southWest.lat.toFixed(5)}, ${this.northEast.lon.toFixed(5)}, ${this.northEast.lat.toFixed(5)}]`}}class vt{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 vt;return e.set(this._m),e}copy(e){return this.set(e._m)}transposeTo(){let e=new vt,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,r=e.z,s=this._m;return new m(s[0]*t+s[3]*i+s[6]*r,s[1]*t+s[4]*i+s[7]*r,s[2]*t+s[5]*i+s[8]*r)}getMat4(){let e=new ne,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 te{constructor(e=0,t=0,i=0,r=0){this.x=e,this.y=t,this.z=i,this.w=r}static get identity(){return new te(0,0,0,1)}static fromVec(e){return new te(e[0],e[1],e[2],e[3])}toVec3(){return new m(this.x,this.y,this.z)}clone(){return new te(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,r){return this.x=e,this.y=t,this.z=i,this.w=r,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 te(this.x*e,this.y*e,this.z*e,this.w*e)}getStep(e){return new te(this.x<e?0:1,this.y<e?0:1,this.z<e?0:1,this.w<e?0:1)}getFrac(e){return new te(Yt(e.x),Yt(e.y),Yt(e.z),Yt(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 ne{constructor(){this._m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}static identity(){let e=new ne;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 r=ne.getRotation(e,i),s=new ne().setIdentity().translate(t),n=new ne().setIdentity().translate(t.negateTo());return s.mul(r).mul(n)}static getRotation(e,t=m.UP){return new ne().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],r=this._m[4],s=this._m[5],n=this._m[6],o=this._m[8],l=this._m[9],h=this._m[10];return new m(Math.sqrt(e*e+t*t+i*i),Math.sqrt(r*r+s*s+n*n),Math.sqrt(o*o+l*l+h*h))}getQuat(){let e=this.getScaling();const t=[0,0,0,1];let i=1/e.x,r=1/e.y,s=1/e.z,n=this._m[0]*i,o=this._m[1]*r,l=this._m[2]*s,h=this._m[4]*i,c=this._m[5]*r,d=this._m[6]*s,u=this._m[8]*i,g=this._m[9]*r,f=this._m[10]*s,p=n+c+f,_=0;return p>0?(_=2*Math.sqrt(p+1),t[3]=.25*_,t[0]=(d-g)/_,t[1]=(u-l)/_,t[2]=(o-h)/_):n>c&&n>f?(_=2*Math.sqrt(1+n-c-f),t[3]=(d-g)/_,t[0]=.25*_,t[1]=(o+h)/_,t[2]=(u+l)/_):c>f?(_=2*Math.sqrt(1+c-n-f),t[3]=(u-l)/_,t[0]=(o+h)/_,t[1]=.25*_,t[2]=(d+g)/_):(_=2*Math.sqrt(1+f-n-c),t[3]=(o-h)/_,t[0]=(u+l)/_,t[1]=(d+g)/_,t[2]=.25*_),new O(...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 ne;return e.set(this._m),e}copy(e){return this.set(e._m)}getMat3(){let e=new vt,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,r=e.z;return new m(this._m[0]*t+this._m[4]*i+this._m[8]*r+this._m[12],this._m[1]*t+this._m[5]*i+this._m[9]*r+this._m[13],this._m[2]*t+this._m[6]*i+this._m[10]*r+this._m[14])}mulVec4(e){let t=e.x,i=e.y,r=e.z,s=e.w;return new te(this._m[0]*t+this._m[4]*i+this._m[8]*r+this._m[12]*s,this._m[1]*t+this._m[5]*i+this._m[9]*r+this._m[13]*s,this._m[2]*t+this._m[6]*i+this._m[10]*r+this._m[14]*s,this._m[3]*t+this._m[7]*i+this._m[11]*r+this._m[15]*s)}toInverseMatrix3(){let e=this._m,t=e[0],i=e[1],r=e[2],s=e[4],n=e[5],o=e[6],l=e[8],h=e[9],c=e[10],d=c*n-o*h,u=-c*s+o*l,g=h*s-n*l,f=t*d+i*u+r*g;if(!f)return;f=1/f;let p=new vt;return p._m[0]=d*f,p._m[1]=(-c*i+r*h)*f,p._m[2]=(o*i-r*n)*f,p._m[3]=u*f,p._m[4]=(c*t-r*l)*f,p._m[5]=(-o*t+r*s)*f,p._m[6]=g*f,p._m[7]=(-h*t+i*l)*f,p._m[8]=(n*t-i*s)*f,p}inverseTo(e=new ne){let t=this._m[0],i=this._m[1],r=this._m[2],s=this._m[3],n=this._m[4],o=this._m[5],l=this._m[6],h=this._m[7],c=this._m[8],d=this._m[9],u=this._m[10],g=this._m[11],f=this._m[12],p=this._m[13],_=this._m[14],v=this._m[15],x=t*o-i*n,y=t*l-r*n,w=t*h-s*n,b=i*l-r*o,E=i*h-s*o,C=r*h-s*l,T=c*p-d*f,L=c*_-u*f,M=c*v-g*f,R=d*_-u*p,z=d*v-g*p,F=u*v-g*_,P=1/(x*F-y*z+w*R+b*M-E*L+C*T);return e._m[0]=(o*F-l*z+h*R)*P,e._m[1]=(-i*F+r*z-s*R)*P,e._m[2]=(p*C-_*E+v*b)*P,e._m[3]=(-d*C+u*E-g*b)*P,e._m[4]=(-n*F+l*M-h*L)*P,e._m[5]=(t*F-r*M+s*L)*P,e._m[6]=(-f*C+_*w-v*y)*P,e._m[7]=(c*C-u*w+g*y)*P,e._m[8]=(n*z-o*M+h*T)*P,e._m[9]=(-t*z+i*M-s*T)*P,e._m[10]=(f*E-p*w+v*x)*P,e._m[11]=(-c*E+d*w-g*x)*P,e._m[12]=(-n*R+o*L-l*T)*P,e._m[13]=(t*R-i*L+r*T)*P,e._m[14]=(-f*b+p*y-_*x)*P,e._m[15]=(c*b-d*y+u*x)*P,e}transposeTo(){let e=new ne;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],r=this._m[2],s=this._m[3],n=this._m[4],o=this._m[5],l=this._m[6],h=this._m[7],c=this._m[8],d=this._m[9],u=this._m[10],g=this._m[11],f=this._m[12],p=this._m[13],_=this._m[14],v=this._m[15],x=e._m[0],y=e._m[1],w=e._m[2],b=e._m[3],E=e._m[4],C=e._m[5],T=e._m[6],L=e._m[7],M=e._m[8],R=e._m[9],z=e._m[10],F=e._m[11],P=e._m[12],D=e._m[13],k=e._m[14],I=e._m[15],B=new ne;return B._m[0]=x*t+y*n+w*c+b*f,B._m[1]=x*i+y*o+w*d+b*p,B._m[2]=x*r+y*l+w*u+b*_,B._m[3]=x*s+y*h+w*g+b*v,B._m[4]=E*t+C*n+T*c+L*f,B._m[5]=E*i+C*o+T*d+L*p,B._m[6]=E*r+C*l+T*u+L*_,B._m[7]=E*s+C*h+T*g+L*v,B._m[8]=M*t+R*n+z*c+F*f,B._m[9]=M*i+R*o+z*d+F*p,B._m[10]=M*r+R*l+z*u+F*_,B._m[11]=M*s+R*h+z*g+F*v,B._m[12]=P*t+D*n+k*c+I*f,B._m[13]=P*i+D*o+k*d+I*p,B._m[14]=P*r+D*l+k*u+I*_,B._m[15]=P*s+D*h+k*g+I*v,B}translate(e){let t=e.x,i=e.y,r=e.z,s=this._m;return s[12]=s[0]*t+s[4]*i+s[8]*r+s[12],s[13]=s[1]*t+s[5]*i+s[9]*r+s[13],s[14]=s[2]*t+s[6]*i+s[10]*r+s[14],s[15]=s[3]*t+s[7]*i+s[11]*r+s[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),r=Math.sin(t),s=new ne,n=s._m;return n[0]=i+(1-i)*e.x*e.x,n[1]=(1-i)*e.y*e.x-r*e.z,n[2]=(1-i)*e.z*e.x+r*e.y,n[3]=0,n[4]=(1-i)*e.x*e.y+r*e.z,n[5]=i+(1-i)*e.y*e.y,n[6]=(1-i)*e.z*e.y-r*e.x,n[7]=0,n[8]=(1-i)*e.x*e.z-r*e.y,n[9]=(1-i)*e.y*e.z+r*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(s)}setRotation(e,t){let i=Math.cos(t),r=Math.sin(t),s=this._m;return s[0]=i+(1-i)*e.x*e.x,s[1]=(1-i)*e.y*e.x-r*e.z,s[2]=(1-i)*e.z*e.x+r*e.y,s[3]=0,s[4]=(1-i)*e.x*e.y+r*e.z,s[5]=i+(1-i)*e.y*e.y,s[6]=(1-i)*e.z*e.y-r*e.x,s[7]=0,s[8]=(1-i)*e.x*e.z-r*e.y,s[9]=(1-i)*e.y*e.z+r*e.x,s[10]=i+(1-i)*e.z*e.z,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}rotateBetweenVectors(e,t){return O.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,r,s,n){let o=t-e,l=r-i,h=s-n,c=2*s,d=this._m;return d[0]=c/o,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=c/l,d[6]=0,d[7]=0,d[8]=(t+e)/o,d[9]=(r+i)/l,d[10]=(n+s)/h,d[11]=-1,d[12]=0,d[13]=0,d[14]=c*n/h,d[15]=0,this}setOrthographic(e,t,i,r,s,n){let o=1/(e-t),l=1/(i-r),h=1/(s-n),c=this._m;return c[0]=-2*o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=-2*l,c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=2*h,c[11]=0,c[12]=(e+t)*o,c[13]=(r+i)*l,c[14]=(n+s)*h,c[15]=1,this}eulerToMatrix(e,t,i){let r=Math.cos(e),s=Math.sin(e),n=Math.cos(t),o=Math.sin(t),l=Math.cos(i),h=Math.sin(i),c=r*o,d=s*o,u=this._m;return u[0]=n*l,u[1]=-n*h,u[2]=-o,u[4]=-d*l+r*h,u[5]=d*h+r*l,u[6]=-s*n,u[8]=c*l+s*h,u[9]=-c*h+s*l,u[10]=r*n,u[3]=u[7]=u[11]=u[12]=u[13]=u[14]=0,u[15]=1,this}}class O{constructor(e=0,t=0,i=0,r=0){this.x=e,this.y=t,this.z=i,this.w=r}static get IDENTITY(){return new O(0,0,0,1)}static xRotation(e){return e*=.5,new O(Math.sin(e),0,0,Math.cos(e))}static yRotation(e){return e*=.5,new O(0,Math.sin(e),0,Math.cos(e))}static zRotation(e){return e*=.5,new O(0,0,Math.sin(e),Math.cos(e))}static axisAngleToQuat(e,t=0){let i=e.getNormal(),r=.5*t,s=Math.sin(r);return new O(i.x*s,i.y*s,i.z*s,Math.cos(r))}static getLookRotation(e,t){let i=e.getNormal().negate(),r=t.cross(i).normalize(),s=i.cross(r),n=1+r.x+s.y+i.z;if(n>1e-6){let l=1/(2*Math.sqrt(n));return new O((i.y-s.z)*l,(r.z-i.x)*l,(s.x-r.y)*l,.25/l)}if(r.x>s.y&&r.x>i.z){let l=1/(2*Math.sqrt(1+r.x-s.y-i.z));return new O(.25/l,(s.x+r.y)*l,(r.z+i.x)*l,(i.y-s.z)*l)}if(s.y>i.z){let l=1/(2*Math.sqrt(1+s.y-r.x-i.z));return new O((s.x+r.y)*l,.25/l,(i.y+s.z)*l,(r.z-i.x)*l)}let o=1/(2*Math.sqrt(1+i.z-r.x-s.y));return new O((r.z+i.x)*o,(i.y+s.z)*o,.25/o,(s.x-r.y)*o)}static getLookAtSourceDest(e,t){let i=t.subA(e).normalize(),r=m.FORWARD.dot(i);if(Math.abs(r- -1)<1e-6)return O.axisAngleToQuat(m.UP,Math.PI);if(Math.abs(r-1)<1e-6)return new O(0,0,0,1);let s=Math.acos(r),n=m.FORWARD.cross(i).normalize();return O.axisAngleToQuat(n,s)}static getRotationBetweenVectors(e,t){let i=e.cross(t);return new O(i.x,i.y,i.z,1+e.dot(t)).normalize()}static getRotationBetweenVectorsRes(e,t,i){let r=e.cross(t);return i.set(r.x,r.y,r.z,1+e.dot(t)),i.normalize()}static getRotationBetweenVectorsUp(e,t,i){let r=e.dot(t);if(Math.abs(r+1)<1e-6)return O.axisAngleToQuat(i,Math.PI);if(Math.abs(r-1)<1e-6)return new O(0,0,0,1);let s=Math.acos(r),n=e.cross(t).normalize();return O.axisAngleToQuat(n,s)}isZero(){return this.x===0&&this.y===0&&this.z===0&&this.w===0}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,r){return this.x=e,this.y=t,this.z=i,this.w=r,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 O(this.x,this.y,this.z,this.w)}add(e){return new O(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 O(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}scaleTo(e){return new O(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(),r=t.cross(i).normalize(),s=i.cross(r),n=1+r.x+s.y+i.z;if(n>1e-6){let o=1/(2*Math.sqrt(n));this.x=(i.y-s.z)*o,this.y=(r.z-i.x)*o,this.z=(s.x-r.y)*o,this.w=.25/o}else if(r.x>s.y&&r.x>i.z){let o=1/(2*Math.sqrt(1+r.x-s.y-i.z));this.x=.25/o,this.y=(s.x+r.y)*o,this.z=(r.z+i.x)*o,this.w=(i.y-s.z)*o}else if(s.y>i.z){let o=1/(2*Math.sqrt(1+s.y-r.x-i.z));this.x=(s.x+r.y)*o,this.y=.25/o,this.z=(i.y+s.z)*o,this.w=(r.z-i.x)*o}else{let o=1/(2*Math.sqrt(1+i.z-r.x-s.y));this.x=(r.z+i.x)*o,this.y=(i.y+s.z)*o,this.z=.25/o,this.w=(s.x-r.y)*o}return this}setFromSphericalCoords(e,t,i){let r=Math.sin(i/2),s=Math.cos(i/2),n=Math.sin(e),o=Math.cos(e),l=Math.sin(t),h=Math.cos(t);return this.x=r*o*l,this.y=r*n,this.z=r*n*h,this.w=s,this}getSphericalCoords(){let e=this.w,t=Math.sqrt(1-e*e);Math.abs(t)<5e-4&&(t=1);let i,r=this.x/t,s=this.y/t,n=this.z/t,o=-Math.asin(s);return i=r*r+n*n<5e-4?0:Math.atan2(r,n),i<0&&(i+=360),{lat:o,lon:i,alpha:Math.acos(e)}}setFromAxisAngle(e,t){let i=e.getNormal(),r=.5*t,s=Math.sin(r);return this.set(i.x*s,i.y*s,i.z*s,Math.cos(r)),this}getAxisAngle(){let e,t,i=this.x,r=this.y,s=this.z,n=this.w,o=Math.sqrt(i*i+r*r+s*s);if(o>1e-7){let l=1/o;e=new m(i*l,r*l,s*l),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)*xs: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,r=O.IDENTITY){let s=O.xRotation(-e),n=O.yRotation(t),o=O.zRotation(-i);return this.copy(o.mul(s).mul(n).mul(r).conjugate())}setFromEulerAngles(e,t,i){let r=e*Xe,s=t*Xe,n=i*Xe,o=Math.cos(r),l=Math.cos(s),h=Math.cos(n),c=Math.sin(r),d=Math.sin(s),u=Math.sin(n),g=l*h,f=d*u;return this.w=o*g+c*f,this.x=c*g-o*f,this.y=o*d*h+c*l*u,this.z=o*l*u-c*d*h,this.normalize()}getEulerAngles(){let e=this.x,t=this.y,i=this.z,r=this.w,s=t*t,n=r*t-i*e;return n<-1?n=-1:n>1&&(n=1),{roll:Math.atan2(2*(r*e+t*i),1-2*(e*e+s)),pitch:Math.asin(2*n),yaw:Math.atan2(2*(r*i+e*t),1-2*(s+i*i))}}setFromMatrix4(e){let t,i,r,s,n,o=[],l=e._m,h=[1,2,0];return t=l[0]+l[5]+l[10],t>0?(i=Math.sqrt(t+1),this.w=i/2,i=.5/i,this.x=(l[6]-l[9])*i,this.y=(l[8]-l[2])*i,this.z=(l[1]-l[4])*i):(r=0,l[5]>l[0]&&(r=1),l[10]>l[5*r]&&(r=2),s=h[r],n=h[s],i=Math.sqrt(l[5*r]-(l[5*s]+l[5*n])+1),o[r]=.5*i,i!==0&&(i=.5/i),o[3]=(l[4*s+n]-l[4*n+s])*i,o[s]=(l[4*r+s]+l[4*s+r])*i,o[n]=(l[4*r+n]+l[4*n+r])*i,this.x=o[0],this.y=o[1],this.z=o[2],this.w=o[3]),this}getMat4(e=new ne){let t=this.x+this.x,i=this.y+this.y,r=this.z+this.z,s=this.w*t,n=this.w*i,o=this.w*r,l=this.x*t,h=this.x*i,c=this.x*r,d=this.y*i,u=this.y*r,g=this.z*r;return e.set([1-(d+g),h-o,c+n,0,h+o,1-(l+g),u-s,0,c-n,u+s,1-(l+d),0,0,0,0,1])}getMat3(){let e=new vt,t=e._m,i=this.x,r=this.y,s=this.z,n=this.w,o=i+i,l=r+r,h=s+s,c=i*o,d=i*l;i*=h;let u=r*l;return r*=h,s*=h,o*=n,l*=n,n*=h,t[0]=1-(u+s),t[1]=d-n,t[2]=i+l,t[3]=d+n,t[4]=1-(c+s),t[5]=r-o,t[6]=i-l,t[7]=r+o,t[8]=1-(c+u),e}mulVec3(e){let t=e.x,i=e.y,r=e.z,s=this.x,n=this.y,o=this.z,l=this.w,h=l*t+n*r-o*i,c=l*i+o*t-s*r,d=l*r+s*i-n*t;return t=-s*t-n*i-o*r,new m(h*l+t*-s+c*-o-d*-n,c*l+t*-n+d*-s-h*-o,d*l+t*-o+h*-n-c*-s)}mulVec3Res(e,t){let i=e.x,r=e.y,s=e.z,n=this.x,o=this.y,l=this.z,h=this.w,c=h*i+o*s-l*r,d=h*r+l*i-n*s,u=h*s+n*r-o*i;return i=-n*i-o*r-l*s,t.set(c*h+i*-n+d*-l-u*-o,d*h+i*-o+u*-n-c*-l,u*h+i*-l+c*-o-d*-n)}mul(e){let t=this.x,i=this.y,r=this.z,s=this.w,n=e.x,o=e.y,l=e.z,h=e.w;return new O(t*h+s*n+i*l-r*o,i*h+s*o+r*n-t*l,r*h+s*l+t*o-i*n,s*h-t*n-i*o-r*l)}mulRes(e,t){let i=this.x,r=this.y,s=this.z,n=this.w,o=e.x,l=e.y,h=e.z,c=e.w;return t.set(i*c+n*o+r*h-s*l,r*c+n*l+s*o-i*h,s*c+n*h+i*l-r*o,n*c-i*o-r*l-s*h)}mulA(e){let t=this.x,i=this.y,r=this.z,s=this.w,n=e.x,o=e.y,l=e.z,h=e.w;return this.x=t*h+s*n+i*l-r*o,this.y=i*h+s*o+r*n-t*l,this.z=r*h+s*l+t*o-i*n,this.w=s*h-t*n-i*o-r*l,this}conjugate(){return new O(-this.x,-this.y,-this.z,this.w)}inverse(){let e=1/this.magnitude2();return new O(-this.x*e,-this.y*e,-this.z*e,this.w*e)}magnitude(){let e=this.x,t=this.y,i=this.z,r=this.w;return Math.sqrt(e*e+t*t+i*i+r*r)}magnitude2(){let e=this.x,t=this.y,i=this.z,r=this.w;return e*e+t*t+i*i+r*r}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,r=this.w,s=Math.sqrt(e*e+t*t+i*i+r*r);return s===0?(this.x=0,this.y=0,this.z=0,this.w=0,this):(s=1/s,this.x=e*s,this.y=t*s,this.z=i*s,this.w=r*s,this)}isEqual(e){let t=this.dot(e);return Math.abs(t-1)<.001}slerp(e,t){let i,r,s,n,o,l=this.x,h=this.y,c=this.z,d=this.w,u=e.x,g=e.y,f=e.z,p=e.w;return r=l*u+h*g+c*f+d*p,r<0&&(r=-r,u=-u,g=-g,f=-f,p=-p),1-r>1e-6?(i=Math.acos(r),s=Math.sin(i),n=Math.sin((1-t)*i)/s,o=Math.sin(t*i)/s):(n=1-t,o=t),new O(n*l+o*u,n*h+o*g,n*c+o*f,n*d+o*p)}}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 r=e.x,s=e.y,n=e.z;if(r>=0){let o=65536*Math.floor(r/65536);t.x=Math.fround(o),i.x=Math.fround(r-o)}else{let o=65536*Math.floor(-r/65536);t.x=Math.fround(-o),i.x=Math.fround(r+o)}if(s>=0){let o=65536*Math.floor(s/65536);t.y=Math.fround(o),i.y=Math.fround(s-o)}else{let o=65536*Math.floor(-s/65536);t.y=Math.fround(-o),i.y=Math.fround(s+o)}if(n>=0){let o=65536*Math.floor(n/65536);t.z=Math.fround(o),i.z=Math.fround(n-o)}else{let o=65536*Math.floor(-n/65536);t.z=Math.fround(-o),i.z=Math.fround(n+o)}}static doubleToTwoFloat32Array(e,t,i){let r=e.x,s=e.y,n=e.z;if(r>=0){let o=65536*Math.floor(r/65536);t[0]=Math.fround(o),i[0]=Math.fround(r-o)}else{let o=65536*Math.floor(-r/65536);t[0]=Math.fround(-o),i[0]=Math.fround(r+o)}if(s>=0){let o=65536*Math.floor(s/65536);t[1]=Math.fround(o),i[1]=Math.fround(s-o)}else{let o=65536*Math.floor(-s/65536);t[1]=Math.fround(-o),i[1]=Math.fround(s+o)}if(n>=0){let o=65536*Math.floor(n/65536);t[2]=Math.fround(o),i[2]=Math.fround(n-o)}else{let o=65536*Math.floor(-n/65536);t[2]=Math.fround(-o),i[2]=Math.fround(n+o)}}static fromVec(e){return new m(e[0],e[1],e[2])}static angle(e,t){let i=e.dot(t),r=e.cross(t).length();return Math.atan2(r,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 r=e.sub(t.scaleTo(t.dot(e)/t.dot(t)));return i&&r.isZero()?new m(i.x,i.y,i.z):r}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 r=e.x*t.x+e.y*t.y+e.z*t.z;return Math.abs(r)<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 te(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 O(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,r=this.z-e.z;return Math.sqrt(t*t+i*i+r*r)}distance2(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}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,r,s,n,o=new m;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let l=this.dot(e);return 1-l>m.LERP_DELTA?(i=Math.acos(l),r=Math.sin(i),s=Math.sin((1-t)*i)/r,n=Math.sin(t*i)/r):(s=1-t,n=t),m.add(this.scaleTo(s),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(),r=e.clone();i.normalize(),r.normalize();let s=i.dot(r);if(s>=1)return O.IDENTITY.clone();if(s<-.999999){if(t.equal(m.ZERO)){let n=m.UNIT_X.cross(i);return n.isZero()&&(n=m.UNIT_Y.cross(i)),n.normalize(),O.axisAngleToQuat(n,Math.PI)}return O.axisAngleToQuat(t,Math.PI)}{let n=Math.sqrt(2*(1+s)),o=1/n,l=i.cross(r),h=new O(l.x*o,l.y*o,l.z*o,.5*n);return h.normalize(),h}}}class N{constructor(e=0,t=0){this.x=e,this.y=t}static get UP(){return new N(0,1)}static get DOWN(){return new N(0,-1)}static get RIGHT(){return new N(1,0)}static get LEFT(){return new N(-1,0)}static get ZERO(){return new N}static add(e,t){const i=new N(e.x,e.y);return i.addA(t),i}static sub(e,t){var i=new N(e.x,e.y);return i.subA(t),i}static scale(e,t){let i=new N(e.x,e.y);return i.scale(t),i}static mul(e,t){let i=new N(e.x,e.y);return i.mulA(t),i}static div(e,t){let i=new N(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 r=e.sub(t.scaleTo(t.dot(e)/t.dot(t)));return i&&r.isZero()?new N(i.x,i.y):r}toVector3(){return new m(this.x,this.y,0)}clone(){return new N(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 N(this.x+e.x,this.y+e.y)}subA(e){return this.x-=e.x,this.y-=e.y,this}sub(e){return new N(this.x-e.x,this.y-e.y)}scale(e){return this.x*=e,this.y*=e,this}scaleTo(e){return new N(this.x*e,this.y*e)}mulA(e){return this.x*=e.x,this.y*=e.y,this}mul(e){return new N(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 N;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 N.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 N(-this.x,-this.y)}projToRay(e,t){let i=N.proj_b_to_a(N.sub(this,e),t);return i.add(e),i}angle(e){return N.angle(this,e)}lerp(e,t,i){let r=this.clone();return i<=0?r.copy(e):i>=1?r.copy(t):r=N.add(e,N.sub(t,e).scale(i)),r}static get LERP_DELTA(){return 1e-6}slerp(e,t){let i,r,s,n,o=new N;if(t<=0)return o.copy(this),o;if(t>=1)return o.copy(e),o;let l=this.dot(e);return 1-l>N.LERP_DELTA?(i=Math.acos(l),r=Math.sin(i),s=Math.sin((1-t)*i)/r,n=Math.sin(t*i)/r):(s=1-t,n=t),N.add(this.scale(s),e.scale(n))}isZero(){return!(this.x||this.y)}}const Bs={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 cr{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,r=t.lat*U,s=r-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(r/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),l=Math.abs(o)>1e-11?s/o:Math.cos(i);return Math.sqrt(s*s+l*l*n*n)*this._a}getIntermediatePointOnGreatCircle(e,t,i){if(i==0)return e.clone();if(i==1)return t.clone();const r=this.inverse(e,t),s=r.distance,n=r.initialAzimuth;return isNaN(n)?e:this.getGreatCircleDestination(e,n,s*i)}static getBearing(e,t){let i=e.lat*U,r=e.lon*U,s=t.lat*U,n=t.lon*U,o=Math.sin(n-r)*Math.cos(s),l=Math.cos(i)*Math.sin(s)-Math.sin(i)*Math.cos(s)*Math.cos(n-r);return Math.atan2(o,l)*J}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,r=new m){let s=U*t,n=U*e,o=Math.sin(s),l=this._a/Math.sqrt(1-this._e2*o*o),h=(l+i)*Math.cos(s);return r.x=h*Math.cos(n),r.y=h*Math.sin(n),r.z=(l*(1-this._e2)+i)*o,r}projToSurface(e){let t=e.x||0,i=e.y||0,r=e.z||0,s=Math.sqrt(t*t+i*i+r*r);if(s===0)return this.lonLatToCartesian(new A);let n=this._invRadii2.x,o=this._invRadii2.y,l=this._invRadii2.z,h=t*t*n,c=i*i*o,d=r*r*l,u=h+c+d,g=Math.sqrt(1/u),f=e.scaleTo(g);if(u<.1)return Number.isFinite(g)?f:new m;let p=(1-g)*s/f.mulA(this._invRadii2).length(),_=0,v=0,x=0;for(;;){_=1/(1+p*n),v=1/(1+p*o),x=1/(1+p*l);let y=_*_,w=v*v,b=x*x,E=h*y+c*w+d*b-1;if(Math.abs(E)<rr)break;p+=.5*E/(h*(y*_)*n+c*(w*v)*o+d*(b*x)*l)}return new m(t*_,i*v,r*x)}cartesianToLonLat(e){return this.cartesianToLonLatRes(e)}cartesianToLonLatRes(e,t=new A){let i=this.projToSurface(e),r=this.getSurfaceNormal3v(i),s=e.sub(i);return t.lon=Math.atan2(r.y,r.x)*J,t.lat=Math.asin(r.z)*J,t.height=Math.sign(s.dot(e))*s.length(),t}getSurfaceNormal3v(e){let t=this._invRadii2,i=e.x*t.x,r=e.y*t.y,s=e.z*t.z,n=1/Math.sqrt(i*i+r*r+s*s);return new m(i*n,r*n,s*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,r=this._b,s=this._flattening;const n=e.lat*U,o=e.lon*U,l=t.lat*U,h=t.lon*U-o,c=(1-s)*Math.tan(n),d=1/Math.sqrt(1+c*c),u=c*d,g=(1-s)*Math.tan(l),f=1/Math.sqrt(1+g*g),p=g*f,_=Math.abs(h)>Math.PI/2||Math.abs(l-n)>Math.PI/2;let v=h,x=null,y=null,w=_?Math.PI:0,b=0,E=_?-1:1,C=null,T=1,L=1,M=null,R=0;do{if(x=Math.sin(v),y=Math.cos(v),C=(f*x)**2+(d*p-u*f*y)**2,Math.abs(C)<1e-24)break;b=Math.sqrt(C),E=u*p+d*f*y,w=Math.atan2(b,E);const I=d*f*x/b;L=1-I*I,T=L!=0?E-2*u*p/L:0;const B=s/16*L*(4+s*(4-3*L));M=v,v=h+(1-B)*s*I*(w+B*b*(T+B*E*(2*T*T-1)))}while(Math.abs(v-M)>rr&&++R<1e3);const z=L*(i*i-r*r)/(r*r),F=z/1024*(256+z*(z*(74-47*z)-128)),P=r*(1+z/16384*(4096+z*(z*(320-175*z)-768)))*(w-F*b*(T+F/4*(E*(2*T*T-1)-F/6*T*(4*b*b-3)*(4*T*T-3)))),D=Math.abs(C)<Number.EPSILON?0:Math.atan2(f*x,d*p-u*f*y),k=Math.abs(C)<Number.EPSILON?Math.PI:Math.atan2(d*x,-u*f+d*p*y);return{distance:P,initialAzimuth:Math.abs(P)<Number.EPSILON?NaN:Mt(D)*J,finalAzimuth:Math.abs(P)<Number.EPSILON?NaN:Mt(k)*J}}direct(e,t,i){let r=e.lon,s=e.lat,n=this._a,o=this._b,l=this._flattening,h=i,c=t*U,d=Math.sin(c),u=Math.cos(c),g=(1-l)*Math.tan(s*U),f=1/Math.sqrt(1+g*g),p=g*f,_=Math.atan2(g,u),v=f*d,x=1-v*v,y=x*(n*n-o*o)/(o*o),w=1+y/16384*(4096+y*(y*(320-175*y)-768)),b=y/1024*(256+y*(y*(74-47*y)-128)),E=h/(o*w),C=2*Math.PI,T=0,L=0,M=0,R=0;for(;Math.abs(E-C)>1e-12;)T=Math.cos(2*_+E),L=Math.sin(E),M=Math.cos(E),R=b*L*(T+b/4*(M*(2*T*T-1)-b/6*T*(4*L*L-3)*(4*T*T-3))),C=E,E=h/(o*w)+R;let z=p*L-f*M*u,F=Math.atan2(p*M+f*L*u,(1-l)*Math.sqrt(v*v+z*z)),P=l/16*x*(4+l*(4-3*x)),D=Math.atan2(L*d,f*M-p*L*u)-(1-P)*l*v*(E+P*L*(T+P*M*(2*T*T-1))),k=Math.atan2(v,-z);return{destination:new A(r+D*J,F*J),finalAzimuth:k*J}}hitRay(e,t){let i,r,s,n,o,l=this._invRadii.mul(e),h=this._invRadii.mul(t),c=l.dot(l),d=l.dot(h);if(c>1){if(d>=0)return;var u=d*d;if(i=c-1,r=h.dot(h),s=r*i,Math.abs(u-s)>1e-15&&u<s)return;if(u>s){n=d*d-s,o=-d+Math.sqrt(n);var g=o/r,f=i/o;return g<f?e.add(t.scaleTo(g)):e.add(t.scaleTo(f))}var p=Math.sqrt(i/r);return e.add(t.scaleTo(p))}return c<1?(i=c-1,r=h.dot(h),s=r*i,n=d*d-s,o=-d+Math.sqrt(n),e.add(t.scaleTo(o/r))):d<0?(r=h.dot(h),e.add(t.scaleTo(-d/r))):void 0}getNorthFrameRotation(e){let t=this.getSurfaceNormal3v(e),i=m.proj_b_to_plane(m.NORTH,t);return O.getLookRotation(i,t)}getBearingDestination(e,t=0,i=0){t*=U;var r=(e.lon+540)%360-180,s=e.lat*U,n=r*U,o=i/this._a,l=Math.asin(Math.sin(s)*Math.cos(o)+Math.cos(s)*Math.sin(o)*Math.cos(t));return new A((n+Math.atan2(Math.sin(t)*Math.sin(o)*Math.cos(s),Math.cos(o)-Math.sin(s)*Math.sin(l)))*J,l*J)}static getIntermediatePointOnGreatCircle(e,t,i){var r=e.lat*U,s=e.lon*U,n=t.lat*U,o=t.lon*U,l=Math.sin(r),h=Math.cos(r),c=Math.sin(s),d=Math.cos(s),u=Math.sin(n),g=Math.cos(n),f=Math.sin(o),p=Math.cos(o),_=n-r,v=o-s,x=Math.sin(_/2)*Math.sin(_/2)+Math.cos(r)*Math.cos(n)*Math.sin(v/2)*Math.sin(v/2),y=2*Math.atan2(Math.sqrt(x),Math.sqrt(1-x)),w=Math.sin((1-i)*y)/Math.sin(y),b=Math.sin(i*y)/Math.sin(y),E=w*h*d+b*g*p,C=w*h*c+b*g*f,T=w*l+b*u,L=Math.atan2(T,Math.sqrt(E*E+C*C)),M=Math.atan2(C,E);return new A((M*J+540)%360-180,L*J)}static getRhumbBearing(e,t){var i=(t.lon-e.lon)*U,r=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,r)*J+360)%360}getLonLatVisibilitySimple(e,t,i){const r=this.lonLatToCartesian(t),s=t.height,n=this.polarSize+s,o=Math.max(e.length()-this.polarSize,0),l=r.sub(e);let h;return h=o>0?Math.sqrt((n+o)**2-n**2):n,h>l.length()&&(!i||i.dot(l.normalize())>0)}}const ks=new cr(6378137,6356752314245179e-9);function zi(a,e){return a??e}function Ge(a){return a==null}function Is(a){return a===void 0}let nl=0;function dr(a){let e=a._openglobus_id;return e||(e=a._openglobus_id=++nl),e}function Di(a){return typeof a=="string"||a instanceof String}function kt(a){return a.toString(16).padStart(2,"0")}function ur(a){let e,t,i;return a instanceof Array?(e=kt(a[0]),t=kt(a[1]),i=kt(a[2])):(e=kt(a.x),t=kt(a.y),i=kt(a.z)),`#${e}${t}${i}`}function it(a,e){let t=Bs[a];if(t&&(a=t),a[0]==="#"){let i=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,r=a.replace(i,function(n,o,l,h){return o+o+l+l+h+h}),s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return s?new te(parseInt(s[1],16)/255,parseInt(s[2],16)/255,parseInt(s[3],16)/255,Ge(e)?1:e):new te}{Ge(e)&&(e=1);let i=a.split(",");return new te(parseInt(i[0].split("(")[1])/255,parseInt(i[1])/255,parseInt(i[2])/255,Ge(i[3])?e:parseFloat(i[3]))}}function _t(a,e){let t=it(a,e);return new Float32Array([t.x,t.y,t.z,t.w])}function Fi(a){let e=Bs[a];if(e&&(a=e),a[0]==="#"){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=a.replace(t,function(s,n,o,l){return n+n+o+o+l+l}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return r?new m(parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255):new m}{let t=a.split(",");return new m(parseInt(t[0].split("(")[1])/255,parseInt(t[1])/255,parseInt(t[2])/255)}}function Ne(a,e){return a.replace(/{[^{}]+}/g,function(t){return e[t.replace(/[{}]+/g,"")]||""})}function Zt(a,e){return a.replace(/\$\{([^}]+)\}/g,(t,i)=>(e==null?void 0:e[i.trim()])??"")}function _r(a){let e=document.createElement("div");e.innerHTML=a;let t=[];for(let i=0;i<e.childNodes.length;i++)t.push(e.childNodes[i]),e.removeChild(e.childNodes[i]);return t}function zs(a,e,t,i){let r=document.getElementById(a);r||(r=document.createElement("div"),r.id=a,r.classList.add("defaultText"),document.body.appendChild(r)),r.innerHTML=e,r.style.left=`${t}px`,r.style.top=`${i}px`}function Ds(a){return typeof a=="number"}function Fs(a,e=""){return a?a.trim():e}function je(a,e){if(a){if(Ds(a))return new m(a,a,a);if(a instanceof m)return a.clone();if(a instanceof Array)return m.fromVec(a);if(a instanceof N)return new m(a.x,a.y,0)}else if(e)return e;return new m}function rt(a,e){if(a){if(Di(a))return it(a);if(a instanceof Array)return te.fromVec(a);if(a instanceof te)return a.clone()}else if(e)return e;return new te(1,1,1,1)}function qe(a,e){if(a){if(Di(a))return Fi(a);if(a instanceof Array)return m.fromVec(a);if(a instanceof m)return a.clone()}else if(e)return e;return new m(1,1,1)}function fr(a,e){if(a){if(a instanceof Array)return new j(Oi(a[0]),Oi(a[1]));if(a instanceof j)return a.clone()}else if(e)return e;return new j}function Oi(a,e){if(a){if(a instanceof Array)return new A(a[0],a[1],a[2]);if(a instanceof A)return a.clone()}else if(e)return e;return new A}function gr(a,e){let t=0,i=a.length-1;for(;t<=i;){let r=Math.floor(.5*(t+i));if(Math.abs(a[r]-e)<.001)return r;a[r]<e?t=r+1:i=r-1}return-1}function yt(a,e,t){let i=0,r=a.length-1;for(;i<=r;){let s=r+i>>1,n=t(e,a[s],s);if(n>0)i=s+1;else{if(!(n<0))return s;r=s-1}}return-i-1}function pr(a,e,t){let i=yt(a,e,t);return i<0&&(i=~i),a.splice(i,0,e),i}function Os(a,e,t,i,r=!1){let s=new A(e.lon-a.lon,e.lat-a.lat),n=new A(i.lon-t.lon,i.lat-t.lat),o=-s.lat,l=+s.lon,h=-(o*a.lon+l*a.lat),c=-n.lat,d=+n.lon,u=-(c*t.lon+d*t.lat),g=c*a.lon+d*a.lat+u,f=c*e.lon+d*e.lat+u,p=o*t.lon+l*t.lat+h,_=o*i.lon+l*i.lat+h;if(r&&(g*f>0||p*_>0))return;let v=g/(g-f);return new A(a.lon+v*s.lon,a.lat+v*s.lat)}const al={string:function(a){return Ge(a)?a:a.toString()},date:function(a){return Ge(a)?a:new Date(1e3*a)},datetime:function(a){return Ge(a)?a:new Date(1e3*a)},time:function(a){return Ge(a)?a:parseInt(a)},integer:function(a){return Ge(a)?a:parseInt(a)},float:function(a){return Ge(a)?a:parseFloat(a)},boolean:function(a){if(a===null)return a;if(typeof a=="boolean")return a===!0;if(typeof a=="string"){if(a==="")return!1;if((a=a.replace(/^\s+|\s+$/g,"")).toLowerCase()==="true"||a.toLowerCase()==="yes")return!0;a=(a=a.replace(/,/g,".")).replace(/^\s*\-\s*/g,"-")}return!isNaN(a)&&parseFloat(a)!==0}};function Ns(a,e=""){let t=1024,i=atob(a),r=i.length,s=Math.ceil(r/t),n=new Array(s);for(let o=0;o<s;++o){let l=o*t,h=Math.min(l+t,r),c=new Array(h-l);for(let d=l,u=0;d<h;++u,++d)c[u]=i[d].charCodeAt(0);n[o]=new Uint8Array(c)}return new Blob(n,{type:e})}function Qt(a,e,t=!1){let i,r=0;return function(){const s=arguments;r?(t&&clearTimeout(i),i=setTimeout(()=>{Date.now()-r>=e&&(a.apply(null,s),r=Date.now())},e-(Date.now()-r))):(a.apply(null,s),r=Date.now())}}function oe(a,e){let t=new a.constructor(a.length+e.length);return t.set(a,0),t.set(e,a.length),t}function xe(a=[],e=[]){if(ArrayBuffer.isView(a))return oe(a,e);for(let t=0;t<e.length;t++)a.push(e[t]);return a}function re(a,e=Float32Array){if(ArrayBuffer.isView(a))return a;{const t=new e(a.length);return t.set(a,0),t}}function It(a){return ArrayBuffer.isView(a)?Array.from(a):a}function Ae(a,e,t,i){if(ArrayBuffer.isView(a))return e<0&&(t=Math.abs(e),e+=a.length),he(a,e,t,i);{let r;return r=e<0?a.splice(e):a.splice(e,t),i&&(i.result=r),a}}function he(a,e,t,i){if(a.length===0)return a;const r=a.length-t,s=new a.constructor(r);return s.set(a.subarray(0,e)),s.set(a.subarray(e+t),e),i&&(i.result=a.subarray(e,e+t)),s}function mr(a,e,t,i,r){const s=r+1,n=t+s,o=i+s;let l=new Float64Array(s*s*3),h=0;for(let c=t;c<n;c++)for(let d=i;d<o;d++){let u=3*(c*(e+1)+d);l[h++]=a[u],l[h++]=a[u+1],l[h++]=a[u+2]}return l}function Hs(a,e,t,i,r){const s=r+1,n=t+s,o=i+s;let l=new Float32Array(s*s*3),h=0;for(let c=t;c<n;c++)for(let d=i;d<o;d++){let u=3*(c*(e+1)+d);l[h++]=a[u],l[h++]=a[u+1],l[h++]=a[u+2]}return l}function vr(a,e,t,i,r,s,n,o,l,h,c,d,u){const g=s+o+1,f=n+o+1;r+=1;let p=0,_=0;for(let v=s;v<g;v++)for(let x=n;x<f;x++){let y=v*r+x,w=3*y,b=a[w],E=a[w+1],C=a[w+2];i&&i[y]!==0?u[_]=1:(b<d.xmin&&(d.xmin=b),b>d.xmax&&(d.xmax=b),E<d.ymin&&(d.ymin=E),E>d.ymax&&(d.ymax=E),C<d.zmin&&(d.zmin=C),C>d.zmax&&(d.zmax=C)),_++,l[p]=b,c[p]=t[w],h[p++]=e[w],l[p]=E,c[p]=t[w+1],h[p++]=e[w+1],l[p]=C,c[p]=t[w+2],h[p++]=e[w+2]}}function yr(a){return a.map(e=>Array.isArray(e)?yr(e):e)}async function Ni(a){return new Promise(e=>{const t=new Image;return t.addEventListener("load",()=>{e(t)}),t.src=a,t.crossOrigin="",t})}function xr(a){return a.complete&&a.naturalHeight!==0}function zt(a){return a>1e3?a-Math.floor(a)!=0?[(a/1e3).toFixed(2),"km"]:[(a/1e3).toFixed(0),"km"]:a>9?[Math.round(a).toString(),"m"]:a<=.01?["0","m"]:[a.toFixed(1),"m"]}function Vs(a){let e=new URLSearchParams(location.search).get(a);if(e)return Number(e)}function br(a,e=-1){if(e<0)return a.toString();const t=Math.pow(10,e);return(Math.round(a*t)/t).toString()}const Hi=Object.freeze(Object.defineProperty({__proto__:null,base64StringToBlog:function(a){let e=a.split(";"),t=e[0].split(":")[1];return Ns(e[1].split(",")[1],t)},base64toBlob:Ns,binaryInsert:pr,binarySearch:yt,binarySearchFast:gr,blerp:function(a,e,t,i,r,s,n=0,o=1,l=0,h=1){return(t*(o-a)*(h-e)+i*(a-n)*(h-e)+r*(o-a)*(e-l)+s*(a-n)*(e-l))/((o-n)*(h-l))},blerp2:function(a,e,t,i,r,s){return t*(1-a)*(1-e)+i*a*(1-e)+r*(1-a)*e+s*a*e},castType:al,cloneArray:yr,concatArrays:xe,concatTypedArrays:oe,createColorRGB:qe,createColorRGBA:rt,createExtent:fr,createLonLat:Oi,createVector3:je,createVector4:function(a,e){if(a){if(a instanceof te)return a.clone();if(a instanceof Array)return te.fromVec(a)}else if(e)return e;return new te},defaultString:Fs,distanceFormat:function(a){return a>1e3?`${(a/1e3).toFixed(2)} km`:a>9?`${Math.round(a)} m`:`${a.toFixed(1)} m`},distanceFormatExt:zt,extractElevationTiles:function(a,e,t){let i=Math.sqrt(e.length)-1,r=i+1,s=Math.sqrt(a.length/4),n=s/i,o=0,l=0;for(let h=0,c=0,d=a.length/4;h<d;h++){let u=a[4*h],g=Math.floor(h/s),f=h%s,p=Math.floor(f/i),_=Math.floor(g/i),v=t[_][p],x=g%i,y=f%i,w=(x+_)*r+y+p;if(v[w]=u,(g+_)%n==0&&(f+p)%n==0&&(e[c++]=u),(f+1)%i==0&&f!==s-1){o=a[4*(h+1)];let b=.5*(u+o);w=(x+_)*r+y+1,v[w]=b,(g+_)%n==0&&(e[c++]=b);let E=(x+_)*r+(y+1)%i;t[_][p+1][E]=b}if((g+1)%i==0&&g!==s-1){l=a[4*(h+s)];let b=.5*(u+l);w=(x+1)*r+y+p,v[w]=b,(f+p)%n==0&&(e[c++]=b);let E=(x+1)%i*r+y+p;t[_+1][p][E]=b}if((f+1)%i==0&&f!==s-1&&(g+1)%i==0&&g!==s-1){let b=.25*(u+o+l+a[4*(h+s+1)]);w=(x+1)*r+(y+1),v[w]=b,e[c++]=b;let E=(x+1)*r;t[_][p+1][E]=b;let C=i;t[_+1][p][C]=b;let T=0;t[_+1][p+1][T]=b}}},getDefault:zi,getHTML:function(a,e){return Ne(a,e)},getLinesIntersection2v:function(a,e,t,i,r){let s=e.sub(a),n=i.sub(t),o=-s.y,l=+s.x,h=-(o*a.x+l*a.y),c=-n.y,d=+n.x,u=-(c*t.x+d*t.y),g=c*a.x+d*a.y+u,f=c*e.x+d*e.y+u,p=o*t.x+l*t.y+h,_=o*i.x+l*i.y+h;if(r&&(g*f>0||p*_>0))return;let v=g/(g-f);return new N(a.x+v*s.x,a.y+v*s.y)},getLinesIntersectionLonLat:Os,getMatrixSubArray32:Hs,getMatrixSubArray64:mr,getMatrixSubArrayBoundsExt:vr,getTileImageResolution:function(a,e,t,i=256,r=ks){let s=Bt(a,e,t),n=s.getSouthWest().inverseMercator(),o=s.getNorthEast().inverseMercator();return[r.getGreatCircleDistance(n,new A(o.lon,n.lat))/i,r.getGreatCircleDistance(n,new A(n.lon,o.lat))/i]},getUrlParam:Vs,htmlColorToFloat32Array:_t,htmlColorToRgb:Fi,htmlColorToRgba:it,isEmpty:Ge,isImageLoaded:xr,isNumber:Ds,isString:Di,isUndef:Is,isUndefExt:function(a,e){return Is(a)?e:a},loadImage:Ni,makeArray:It,makeArrayTyped:re,parseHTML:_r,print2d:zs,rgbToStringHTML:ur,spliceArray:Ae,spliceTypedArray:he,stamp:dr,stringTemplate:Ne,stringTemplate2:Zt,throttle:Qt,toFixedMax:br,xmlToJson:function a(e){let t={};if(e.nodeType===1){if(e.attributes.length>0){t["@attributes"]={};for(let i=0;i<e.attributes.length;i++){let r=e.attributes.item(i);t["@attributes"][r.nodeName]=r.nodeValue}}}else e.nodeType===3&&(t=e.nodeValue);if(e.hasChildNodes())for(let i=0;i<e.childNodes.length;i++){let r=e.childNodes.item(i),s=r.nodeName;if(t[s]===void 0)t[s]=a(r);else{if(t[s].push===void 0){let n=t[s];t[s]=[],t[s].push(n)}t[s].push(a(r))}}return t}},Symbol.toStringTag,{value:"Module"})),Vi=1e3,wr=1/60,Us=1/24,Kt=3600,Cr=1/Kt,Tr=43200,Ui=1440,ol=1/Ui,Ze=86400,ll=864e5,Er=11574074074074074e-24,st=1/Ze,Gi=2451545;function Gs(a,e,t){let i=(e-14)/12|0,r=a+4800+i;return(1461*r/4|0)+(367*(e-2-12*i)/12|0)-(3*((r+100)/100|0)/4|0)+t-32075}function ji(a){let e=Gs(a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate()),t=a.getUTCHours()-12;t<0&&(t+=24);let i=a.getUTCSeconds()+t*Kt+60*a.getUTCMinutes()+.001*a.getUTCMilliseconds();i>=Tr&&e--;let r=i*st|0;return e+=r,i-=Ze*r,i<0&&(e--,i+=Ze),e+i*st}function Ar(a){let e=Ys,t=yt(e,a,function(r,s){return r-s.jd});t<0&&(t=~t),t>=e.length&&(t=e.length-1);let i=e[t].leapSeconds;return t!==0&&(e[t].jd-a)*Ze>i&&(i=e[t-1].leapSeconds),a+i*st}function Lr(a){let e=Ys,t=yt(e,a,function(r,s){return r-s.jd});if(t<0&&(t=~t),t>=e.length)return a-e[t-1].leapSeconds*st;if(t===0)return a-e[0].leapSeconds*st;let i=(e[t].jd-a)*Ze;return i===0?a-e[t].leapSeconds*st:i<=1?void 0:a-e[t-1].leapSeconds*st}function Pr(a){let e=0|a,t=(a-e)*Ze;t>=Tr&&e++;let i=e+68569|0,r=4*i/146097|0;i=i-((146097*r+3)/4|0)|0;let s=4e3*(i+1)/1461001|0;i=i-(1461*s/4|0)+31|0;let n=80*i/2447|0,o=i-(2447*n/80|0)|0;i=n/11|0;let l=n+2-12*i|0,h=100*(r-49)+s+i|0,c=t*Cr|0,d=t-c*Kt,u=d*wr|0;d-=60*u;let g=0|d,f=(d-g)*Vi|0;return c+=12,c>23&&(c-=24),new Date(Date.UTC(h,l-1,o,c,u,g,f))}function js(a,e){return a+e*Er}function qs(a,e){return a+e*st}function se(a,e){return{jd:a,leapSeconds:e}}const Ys=[se(24413175e-1,10),se(24414995e-1,11),se(24416835e-1,12),se(24420485e-1,13),se(24424135e-1,14),se(24427785e-1,15),se(24431445e-1,16),se(24435095e-1,17),se(24438745e-1,18),se(24442395e-1,19),se(24447865e-1,20),se(24451515e-1,21),se(24455165e-1,22),se(24462475e-1,23),se(24471615e-1,24),se(24478925e-1,25),se(24482575e-1,26),se(24488045e-1,27),se(24491695e-1,28),se(24495345e-1,29),se(24500835e-1,30),se(24506305e-1,31),se(24511795e-1,32),se(24537365e-1,33),se(24548325e-1,34),se(24561095e-1,35),se(24572045e-1,36)],hl=Ar(Gi);Object.freeze(Object.defineProperty({__proto__:null,DAYS_PER_JULIAN_CENTURY:36525,DAYS_PER_JULIAN_YEAR:365.25,DateToTAI:function(a){return Ar(ji(a))},DateToUTC:ji,HOURS_PER_DAY:24,J2000:Gi,J2000TAI:hl,MILLISECONDS_PER_DAY:ll,MILLISECONDS_PER_SECOND:Vi,MINUTES_PER_DAY:Ui,MINUTES_PER_HOUR:60,MODIFIED_JULIAN_DATE_DIFFERENCE:24000005e-1,ONE_BY_HOURS_PER_DAY:Us,ONE_BY_MILLISECONDS_PER_DAY:Er,ONE_BY_MINUTES_PER_DAY:ol,ONE_BY_SECONDS_PER_DAY:st,ONE_BY_SECONDS_PER_HOUR:Cr,ONE_BY_SECONDS_PER_MINUTE:wr,PICOSECOND:1e-9,SECONDS_PER_12_HOURS:Tr,SECONDS_PER_DAY:Ze,SECONDS_PER_HOUR:Kt,SECONDS_PER_MILLISECOND:.001,SECONDS_PER_MINUTE:60,T:function(a){return(a-Gi)/36525},TAItoDate:function(a){let e=Lr(a);return e||(e=Lr(qs(a,-1)),console.trace(`TAItoDate - can't convert ${a.toString()} to utc.`)),Pr(e)},TAItoUTC:Lr,UTCtoDate:Pr,UTCtoTAI:Ar,addDays:function(a,e){return a+e},addHours:function(a,e){return a+e*Us},addMilliseconds:js,addMinutes:function(a,e){return a+e*Ui},addSeconds:qs,daysToSeconds:function(a){return a*Ze},getDayNumber:Gs,getDays:function(a){return 0|a},getHours:function(a){let e=(a-(0|a))*Ze,t=e*Cr|0,i=e-t*Kt,r=i*wr|0;i-=60*r;let s=0|i;return t+=12+r/60+s/3600+((i-s)*Vi|0)/1e3,t>23&&(t-=24),t},getMilliseconds:function(a){let e=a-(0|a);return e*=Ze,(e-(0|e))*Vi|0},getMinutes:function(a){return(a-(0|a))*Ui|0},getSeconds:function(a){return(a-(0|a))*Ze},secondsToDays:function(a){return a*st}},Symbol.toStringTag,{value:"Module"}));class Ws{constructor(e){this.vertices=[new m,new m,new m,new m,new m,new m,new m,new m],e&&this.setFromBoundsArr(e)}copy(e){for(let t=0,i=this.vertices.length;t<i;t++)this.vertices[t].copy(e.vertices[t])}setFromBoundsArr(e){let t=e[0],i=e[3],r=e[1],s=e[4],n=e[2],o=e[5],l=this.vertices;l[0].set(t,r,n),l[1].set(i,r,n),l[2].set(i,r,o),l[3].set(t,r,o),l[4].set(t,s,n),l[5].set(i,s,n),l[6].set(i,s,o),l[7].set(t,s,o)}setFromExtent(e,t){this.setFromBoundsArr(t.getCartesianBounds(e))}}class He{constructor(e=0,t){this.radius=e,this.center=t?t.clone():new m}setFromBounds(e){let t=new m(e[0],e[1],e[2]);this.center.set(t.x+.5*(e[3]-t.x),t.y+.5*(e[3]-t.y),t.z+.5*(e[5]-t.z)),this.radius=this.center.distance(t)}setFromExtent(e,t){this.setFromBounds(t.getCartesianBounds(e))}}Object.freeze(Object.defineProperty({__proto__:null,Box:Ws,Sphere:He},Symbol.toStringTag,{value:"Module"}));function le(a,e){return new Sr(a,e)}const $s=class So{constructor(e,t){this.__id=So.__counter__++,this._eventNames=[],e&&this.registerNames(e),this._sender=t||this,this._stopPropagation=!1,this._stampCache={}}bindSender(e){this._sender=e||this}registerNames(e){for(let t=0;t<e.length;t++)this[e[t]]={active:!0,handlers:[]},this._eventNames.push(e[t]);return this}_getStamp(e,t,i){return`${e}_${t}_${i}`}_stamp(e,t){let i=dr(t),r=this._getStamp(e,this.__id,i);return!this._stampCache[r]&&(this._stampCache[r]=i,!0)}on(e,t,i,r=0){if(this._stamp(e,t)&&this[e]){let s=t.bind(i||this._sender);s._openglobus_id=t._openglobus_id,s._openglobus_priority=r,pr(this[e].handlers,s,(n,o)=>(o._openglobus_priority||0)-(n._openglobus_priority||0))}}off(e,t){if(t){let i=this._getStamp(e,this.__id,t._openglobus_id);if(t._openglobus_id&&this._stampCache[i]){let r=this[e].handlers,s=r.length,n=-1;for(;s--;)if(r[s]._openglobus_id===t._openglobus_id){n=s;break}n!==-1&&(r.splice(n,1),this._stampCache[i]=void 0,delete this._stampCache[i])}}}dispatch(e,...t){let i=!0;if(e&&e.active&&!this._stopPropagation){let r=e.handlers.slice(0),s=r.length;for(;s--;)r[s](...t)===!1&&(i=!1)}return this._stopPropagation=!1,i}stopPropagation(){this._stopPropagation=!0}clear(){for(let e=0;e<this._eventNames.length;e++){let t=this[this._eventNames[e]];t.handlers.length=0,t.handlers=[]}this._eventNames.length=0,this._eventNames=[]}};$s.__counter__=0;let Sr=$s;const cl=["render"],Xs=class et{constructor(e={}){this.__id=et.__counter__++,this.events=le(cl),this.model=e.model||null,this.template=e.template||"",this.parent=e.parent||null,this._classList=e.classList||[],this.el=null,e.initRender&&this.render()}on(e,t,i,r){this.events.on(e,t,i,r)}off(e,t){this.events.off(e,t)}static getHTML(e,t){return Ne(e,t)}static parseHTML(e){return _r(e)}static insertAfter(e,t){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)t.parentNode&&t.parentNode.insertBefore(e[i],t.nextSibling);return e}static insertBefore(e,t){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)t.parentNode&&t.parentNode.insertBefore(e[i],t);return e}insertBefore(e){this.el||this.render(),this.el&&(e instanceof HTMLElement&&e.parentNode&&et.insertBefore(this.el,e),e instanceof et&&e.el&&e.el.parentNode&&et.insertBefore(this.el,e.el))}insertAfter(e){this.el||this.render(),this.el&&(e instanceof HTMLElement&&e.parentNode&&et.insertAfter(this.el,e),e instanceof et&&e.el&&e.el.parentNode&&et.insertAfter(this.el,e.el))}isEqual(e){return e.__id===this.__id}appendTo(e,t=!1,i=!1){return e&&(this.el||(this.beforeRender(e),this.render()),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),t&&(e.innerHTML=""),this.el&&(i&&e.childNodes[0]?et.insertBefore(this.el,e.childNodes[0]):e.appendChild(this.el)),this.afterRender(e)),this}afterRender(e){}beforeRender(e){}stopPropagation(){this.events.stopPropagation()}renderTemplate(e){return et.parseHTML(et.getHTML(this.template,e||{}))[0]}render(e){this.el=this.renderTemplate(e);for(let t=0,i=this._classList.length;t<i;t++)this.el.classList.add(this._classList[t]);return this.events.dispatch(this.events.render,this),this}select(e){return this.el?this.el.querySelector(e):null}selectRemove(e){if(this.el){let t=this.select(e);if(t&&t.parentNode)return t.parentNode.removeChild(t),t}}selectAll(e,t){if(this.el){const i=this.el.querySelectorAll(e);if(t)for(let r=0,s=i.length;r<s;r++)t(i[r],r);return i}}remove(){this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}};Xs.__counter__=0;let be=Xs;const dl=["click","mousedown","mouseup","touchstart","touchend","touchcancel"];class nt extends be{constructor(e={}){super({template:Ne(`<div class="og-button" title="{title}">
2
2
  <div class="og-button-icon">{icon}</div>
3
3
  <div class="og-button-text">{text}</div>
4
- </div>`,{icon:e.icon||"",text:e.text||"",title:e.title||""}),...e}),this._onMouseDown=t=>{t.preventDefault(),this.events.dispatch(this.events.mousedown,this,t)},this._onMouseUp=t=>{t.preventDefault(),this.events.dispatch(this.events.mouseup,this,t)},this._onTouchStart=t=>{t.preventDefault(),this.events.dispatch(this.events.touchstart,this,t)},this._onTouchEnd=t=>{t.preventDefault(),this.events.dispatch(this.events.touchend,this,t)},this._onTouchCancel=t=>{t.preventDefault(),this.events.dispatch(this.events.touchcancel,this,t)},this._onMouseClick=t=>{this._mouseClickHandler(t)},this.events=this.events.registerNames(dl),this.el=null,this.name=e.name||"",this.$icon=null,this.$text=null}render(e){return super.render(e),this.$icon=this.select(".og-button-icon"),this.$text=this.select(".og-button-text"),this.el.__og_button__=this,this._initEvents(),this}_initEvents(){this.el&&(this.el.addEventListener("click",this._onMouseClick),this.el.addEventListener("mousedown",this._onMouseDown),this.el.addEventListener("mouseup",this._onMouseUp),this.el.addEventListener("touchstart",this._onTouchStart),this.el.addEventListener("touchend",this._onTouchEnd),this.el.addEventListener("touchcancel",this._onTouchCancel))}_mouseClickHandler(e){e.preventDefault(),this.events.dispatch(this.events.click,this,e)}remove(){this._clearEvents(),super.remove()}_clearEvents(){this.el&&this.el.removeEventListener("click",this._onMouseClick)}}const Xr=class Sa{constructor(e={}){this.__id=Sa.__counter__++,this._name=e.name||`_control_${this.__id.toString()}`,this.planet=null,this._initialized=!1,this.renderer=null,this.autoActivate=e.autoActivate||!1,this._active=!1,this._deferredActive=!0}get name(){return this._name}oninit(){}onadd(){}onremove(){}onactivate(){}ondeactivate(){}addTo(e){e&&(this.renderer=e,e.controls[this.name]=this,this.onadd&&this.onadd(),e.isInitialized()&&!this._initialized&&(this._initialized=!0,this.oninit&&this.oninit(),this.autoActivate&&this.activate()))}remove(){this.deactivate(),this.onremove&&this.onremove();let e=this.renderer,t=this.name;if(!e)return;let i=e.controls[t];i&&this.isEqual(i)&&delete e.controls[t],this.renderer=null,this._active=!1,this._initialized=!1}activate(){this._active||(this._initialized||(this._initialized=!0,this.oninit&&this.oninit()),this._deferredActive?(this._active=!0,this.onactivate&&this.onactivate()):this._deferredActive=!0)}deactivate(){this._active?(this._active=!1,this.ondeactivate&&this.ondeactivate()):this._initialized||(this._deferredActive=!1)}isActive(){return this._active}isEqual(e){return e.__id===this.__id}};Xr.__counter__=0;let te=Xr;class Zr extends te{constructor(e={}){super(e),this._heading=0,this._svg=null}oninit(){let e=new nt({classList:["og-map-button","og-compass-button"],icon:`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
4
+ </div>`,{icon:e.icon||"",text:e.text||"",title:e.title||""}),...e}),this._onMouseDown=t=>{t.preventDefault(),this.events.dispatch(this.events.mousedown,this,t)},this._onMouseUp=t=>{t.preventDefault(),this.events.dispatch(this.events.mouseup,this,t)},this._onTouchStart=t=>{t.preventDefault(),this.events.dispatch(this.events.touchstart,this,t)},this._onTouchEnd=t=>{t.preventDefault(),this.events.dispatch(this.events.touchend,this,t)},this._onTouchCancel=t=>{t.preventDefault(),this.events.dispatch(this.events.touchcancel,this,t)},this._onMouseClick=t=>{this._mouseClickHandler(t)},this.events=this.events.registerNames(dl),this.el=null,this.name=e.name||"",this.$icon=null,this.$text=null}render(e){return super.render(e),this.$icon=this.select(".og-button-icon"),this.$text=this.select(".og-button-text"),this.el.__og_button__=this,this._initEvents(),this}_initEvents(){this.el&&(this.el.addEventListener("click",this._onMouseClick),this.el.addEventListener("mousedown",this._onMouseDown),this.el.addEventListener("mouseup",this._onMouseUp),this.el.addEventListener("touchstart",this._onTouchStart),this.el.addEventListener("touchend",this._onTouchEnd),this.el.addEventListener("touchcancel",this._onTouchCancel))}_mouseClickHandler(e){e.preventDefault(),this.events.dispatch(this.events.click,this,e)}remove(){this._clearEvents(),super.remove()}_clearEvents(){this.el&&this.el.removeEventListener("click",this._onMouseClick)}}const Zs=class Mo{constructor(e={}){this.__id=Mo.__counter__++,this._name=e.name||`_control_${this.__id.toString()}`,this.planet=null,this._initialized=!1,this.renderer=null,this.autoActivate=e.autoActivate||!1,this._active=!1,this._deferredActive=!0}get name(){return this._name}oninit(){}onadd(){}onremove(){}onactivate(){}ondeactivate(){}addTo(e){e&&(this.renderer=e,e.controls[this.name]=this,this.onadd&&this.onadd(),e.isInitialized()&&!this._initialized&&(this._initialized=!0,this.oninit&&this.oninit(),this.autoActivate&&this.activate()))}remove(){this.deactivate(),this.onremove&&this.onremove();let e=this.renderer,t=this.name;if(!e)return;let i=e.controls[t];i&&this.isEqual(i)&&delete e.controls[t],this.renderer=null,this._active=!1,this._initialized=!1}activate(){this._active||(this._initialized||(this._initialized=!0,this.oninit&&this.oninit()),this._deferredActive?(this._active=!0,this.onactivate&&this.onactivate()):this._deferredActive=!0)}deactivate(){this._active?(this._active=!1,this.ondeactivate&&this.ondeactivate()):this._initialized||(this._deferredActive=!1)}isActive(){return this._active}isEqual(e){return e.__id===this.__id}};Zs.__counter__=0;let ee=Zs;class Qs extends ee{constructor(e={}){super(e),this._heading=0,this._svg=null}oninit(){let e=new nt({classList:["og-map-button","og-compass-button"],icon:`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
5
5
  <svg
6
6
  xmlns:dc="http://purl.org/dc/elements/1.1/"
7
7
  xmlns:cc="http://creativecommons.org/ns#"
@@ -75,31 +75,31 @@
75
75
  </g>
76
76
  </g>
77
77
  </g>
78
- </svg>`});e.appendTo(this.renderer.div),e.events.on("click",this._onClick,this),this._svg=e.select("svg"),this.renderer.events.on("draw",this._draw,this)}_onClick(){const e=this.planet;let t=e.getCartesianFromPixelTerrain(this.renderer.handler.getCenter());t?e.flyCartesian(t.normal().scaleTo(t.length()+t.distance(e.camera.eye)),null,null,0,void 0,void 0,null,null,()=>{e.camera.look(t)}):e.flyCartesian(e.camera.eye)}_draw(){this.setHeading(this.planet.camera.getHeading())}setHeading(e){this._heading!==e&&(this._heading=e,this._svg.style.transform=`rotateZ(${-e}deg)`)}}const ul=`<svg className="svg-icon" style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor; overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
78
+ </svg>`});e.appendTo(this.renderer.div),e.events.on("click",this._onClick,this),this._svg=e.select("svg"),this.renderer.events.on("draw",this._draw,this)}_onClick(){const e=this.planet;let t=e.getCartesianFromPixelTerrain(this.renderer.handler.getCenter());t?e.flyCartesian(t.normal().scaleTo(t.length()+t.distance(e.camera.eye)),{amplitude:0,completeCallback:()=>{e.camera.look(t)}}):e.flyCartesian(e.camera.eye)}_draw(){this.setHeading(this.planet.camera.getHeading())}setHeading(e){this._heading!==e&&(this._heading=e,this._svg.style.transform=`rotateZ(${-e}deg)`)}}const ul=`<svg className="svg-icon" style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor; overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
79
79
  <path d="M777.856 280.192l-33.92-33.952-231.872 231.872-231.84-231.872-33.984 33.888 231.872 231.904-231.84 231.84 33.888 33.984 231.904-231.904 231.84 231.872 33.952-33.888-231.872-231.904z"/>
80
- </svg>`,_l=["resize","focus","visibility","dragstart","dragend"],Qr=class Ma extends be{constructor(e={}){super({template:He(`<div class="og-ddialog"
80
+ </svg>`,_l=["resize","focus","visibility","dragstart","dragend"],Ks=class Ro extends be{constructor(e={}){super({template:Ne(`<div class="og-ddialog"
81
81
  style="display:{display}; resize:{resize}; width: {width}px; {height}; top: {top}px; left: {left}px; min-height: {minHeight}; max-height: {maxHeight}; min-width: {minWidth}; max-width: {maxWidth};">
82
82
  <div class="og-ddialog-header">
83
83
  <div class="og-ddialog-header__title">{title}</div>
84
84
  <div class="og-ddialog-header__buttons"></div>
85
85
  </div>
86
86
  <div class="og-ddialog-container"></div>
87
- </div>>`,{title:e.title||"",display:zi(e.visible,!0)?"flex":"none",resize:zi(e.resizable,!0)?"both":"none",width:e.width||300,height:e.height?`height: ${e.height||200}px`:"",left:e.left||0,top:e.top||0,minHeight:e.minHeight?`${e.minHeight}px`:"unset",maxHeight:e.maxHeight?`${e.maxHeight}px`:"unset",minWidth:e.minWidth?`${e.minWidth}px`:"unset",maxWidth:e.maxWidth?`${e.maxWidth}px`:"unset"}),...e}),this._onCloseBtnClick=()=>{this.close()},this._onMouseDownAll=()=>{this.bringToFront()},this._onMouseDown=t=>{t.preventDefault(),this._startDragging(),this._startPosX=t.clientX,this._startPosY=t.clientY,document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp)},this._onMouseMove=t=>{t.preventDefault();let i=this._startPosX-t.clientX,s=this._startPosY-t.clientY;this._startPosX=t.clientX,this._startPosY=t.clientY,this.setPosition(this.el.offsetLeft-i,this.el.offsetTop-s)},this._onMouseUp=()=>{this._clearDragging(),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove)},this.events=this.events.registerNames(_l),this._width=e.width||300,this._height=e.height||200,this._startPosX=0,this._startPosY=0,this.$header=null,this.$title=null,this.$container=null,this.$buttons=null,this._closeBtn=new nt({icon:ul,classList:["og-button-size__20"]}),this.useHide=e.useHide||!1,this._visibility=zi(e.visible,!0),this._right=e.right!=null?e.right:null}setContainer(e){this.$container.innerHTML=e}get container(){return this.$container}get width(){return this.el?parseFloat(this.el.style.width):this._width}get height(){return this.el?parseFloat(this.el.style.height):this._height}bringToFront(){this.el.style.zIndex=String(Ma.__zIndex__++)}render(e){return super.render(e),this.bringToFront(),this.$header=this.select(".og-ddialog-header"),this.$title=this.select(".og-ddialog-header__title"),this.$container=this.select(".og-ddialog-container"),this.$buttons=this.select(".og-ddialog-header__buttons"),this._initEvents(),this._initButtons(),this._right!=null&&(this.el.style.visibility="hidden",new IntersectionObserver((t,i)=>{t.forEach(s=>{s.isIntersecting&&(this.el.style.visibility="visible",this.el.parentNode&&(this.setPosition(this.el.parentNode.clientWidth-this.el.clientWidth-this._right),i.disconnect()))})}).observe(this.el)),this}show(){this._visibility||(this._visibility=!0,this.el.style.display="flex",this.bringToFront(),this.events.dispatch(this.events.visibility,!0,this))}hide(){this._visibility&&(this._visibility=!1,this.el.style.display="none",this.events.dispatch(this.events.visibility,!1,this))}close(){this.useHide?this.hide():this.remove()}setVisibility(e){e?this.show():this.hide()}getVisibility(){return this._visibility}_initButtons(){this._closeBtn.events.on("click",this._onCloseBtnClick),this._closeBtn.appendTo(this.$buttons)}_initEvents(){this.$header.addEventListener("mousedown",this._onMouseDown),this.el.addEventListener("mousedown",this._onMouseDownAll)}setPosition(e,t){e!=null&&(this.el.style.left=`${e}px`),t!=null&&(this.el.style.top=`${t}px`)}_startDragging(){this.el.classList.contains("dragging")||(this.el.classList.add("dragging"),this.events.dispatch(this.events.dragstart,this))}_clearDragging(){this.el.classList.contains("dragging")&&(this.events.dispatch(this.events.dragend,this),this.el.classList.remove("dragging"))}remove(){this._clearDragging(),this._clearEvents(),super.remove()}_clearEvents(){this._closeBtn.events.off("click",this._onCloseBtnClick),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove),this.$header.removeEventListener("mousedown",this._onMouseDown),this.el.removeEventListener("mousedown",this._onMouseDownAll)}};Qr.__zIndex__=0;let ot=Qr;const fl=["change"];class fe extends nt{constructor(e){super({...e}),this._onMouseClick=t=>{this.preventClick||(this._mouseClickHandler(t),this.setActive(!this.isActive))},this.events=this.events.registerNames(fl),this._isActive=e.isActive||!1,this.preventClick=e.preventClick||!1}setActive(e,t=!1){e!==this._isActive&&(this._isActive=e,this._toggle(),t||this.events.dispatch(this.events.change,e,this))}_toggle(){this.el&&this.el.classList.toggle("og-button__active")}get isActive(){return this._isActive}render(e){return super.render(e),this._isActive&&this._toggle(),this}}const ei=[2,3,0,1],Kr=[[-1,-1,0,1],[1,-1,3,-1],[2,3,-1,-1],[-1,0,-1,2]],gl=[[2,3,0,1],[1,0,3,2],[2,3,0,1],[1,0,3,2]],pl=[[0,1,0,0],[1,0,0,0],[0,1,0,1],[1,1,1,1]];class Jr{constructor(e,t){this.segment=e,this.layer=t,this.isReady=!1,this.isLoading=!1,this.texture=null,this.pickingMask=null,this.textureExists=!1,this.appliedNodeId=0,this.appliedNode=null,this.texOffset=[0,0,1,1],this.loadingAttempts=0,this._updateTexture=null,this._updatePickingMask=null,this.pickingReady=!1}abortLoading(){this.layer.abortMaterialLoading(this)}_createTexture(e){return this.layer._planet&&this.layer.createTexture(e,this.layer._internalFormat,this.isReady?this.texture:null)}applyImage(e){this.segment.initialized&&(this._updateTexture=null,this.texture=this._createTexture(e),this.isReady=!0,this.pickingReady=!0,this.textureExists=!0,this.isLoading=!1,this.appliedNodeId=this.segment.node.nodeId,this.texOffset=[0,0,1,1])}applyTexture(e,t){this.segment.initialized&&(this.texture=e,this._updateTexture=null,this.pickingMask=t||null,this._updatePickingMask=null,this.isReady=!0,this.pickingReady=!0,this.textureExists=!0,this.isLoading=!1,this.appliedNodeId=this.segment.node.nodeId,this.texOffset=[0,0,1,1])}textureNotExists(){this.segment.initialized&&(this.pickingReady=!0,this.isLoading=!1,this.isReady=!0,this.textureExists=!1)}clear(){this.loadingAttempts=0,this.layer.clearMaterial(this)}}const en=class Ra{constructor(e,t={}){if(this.isVector=!1,this.__id=Ra.__counter__++,this._iconSrc=t.iconSrc||null,this.events=he(tn,this),this.name=e||"noname",this.properties=t.properties||{},this.hideInLayerSwitcher=t.hideInLayerSwitcher||!1,this._hasImageryTiles=!0,this._opacity=t.opacity!=null?t.opacity:1,this.minZoom=t.minZoom||0,this.maxZoom=t.maxZoom!=null?t.maxZoom:50,this._planet=null,this.isVector=!1,this._attribution=t.attribution||"",this._zIndex=t.zIndex||0,this._isBaseLayer=t.isBaseLayer||!1,this._defaultTextures=t.defaultTextures||[null,null],this._visibility=t.visibility===void 0||t.visibility,this._fading=t.fading||!1,this._fadingFactor=this._opacity/30,this._fading?this._fadingOpacity=0:this._fadingOpacity=this._opacity,this._height=t.height||0,this._extent=new G,this.createTexture=null,this._textureFilter=t.textureFilter?t.textureFilter.trim().toUpperCase():"MIPMAP",this._isSRGB=t.isSRGB!=null&&t.isSRGB,this._internalFormat=null,this._extentMerc=new G,this.setExtent(_s(t.extent,new G(new A(-180,-90),new A(180,90)))),this._pickingColor=new v,this._pickingEnabled=t.pickingEnabled===void 0||t.pickingEnabled,this._isPreloadDone=!1,this._preLoadZoomLevels=t.preLoadZoomLevels||[0,1],this._ambient=null,this._diffuse=null,this._specular=null,t.ambient){let i=Ye(t.ambient,new v(.2,.2,.2));this._ambient=new Float32Array([i.x,i.y,i.z])}if(t.diffuse){let i=Ye(t.diffuse,new v(.8,.8,.8));this._diffuse=new Float32Array([i.x,i.y,i.z])}if(t.specular){let i=Ye(t.specular,new v(3e-4,3e-4,3e-4)),s=t.shininess||20;this._specular=new Float32Array([i.x,i.y,i.z,s])}this.nightTextureCoefficient=t.nightTextureCoefficient||1}get iconSrc(){return this._iconSrc}set iconSrc(e){this._iconSrc=e}set diffuse(e){if(e){let t=Ye(e);this._diffuse=new Float32Array(t.toArray())}else this._diffuse=null}set ambient(e){if(e){let t=Ye(e);this._ambient=new Float32Array(t.toArray())}else this._ambient=null}set specular(e){if(e){let t=Ye(e);this._specular=new Float32Array([t.x,t.y,t.y,this._specular?this._specular[3]:0])}else this._specular=null}set shininess(e){this._specular&&(this._specular[3]=e)}static getTMS(e,t,i){return{x:e,y:(1<<i)-t-1,z:i}}static getTileIndex(e,t,i,s){return`${s}::${e}_${t}_${i}`}get instanceName(){return"Layer"}get rendererEvents(){return this.events}set opacity(e){e!==this._opacity&&(this._fading?e>this._opacity?this._fadingFactor=(e-this._opacity)/30:e<this._opacity&&(this._fadingFactor=(this._opacity-e)/30):this._fadingOpacity=e,this._opacity=e)}set pickingEnabled(e){this._pickingEnabled=e}get pickingEnabled(){return this._pickingEnabled}hasImageryTiles(){return this._hasImageryTiles}getID(){return this.__id}get id(){return this.__id}get _id(){return this.__id}isEqual(e){return e.__id===this.__id}_assignPlanet(e){this._planet=e,e._layers.push(this),e.renderer&&e.renderer.isInitialized()&&(this._isSRGB?this._internalFormat=e.renderer.handler.gl.SRGB8_ALPHA8:this._internalFormat=e.renderer.handler.gl.RGBA8,this.createTexture=e.renderer.handler.createTexture[this._textureFilter],this.events.on("visibilitychange",e._onLayerVisibilityChanged,e),this._isBaseLayer&&this._visibility&&e.setBaseLayer(this),e.events.dispatch(e.events.layeradd,this),this.events.dispatch(this.events.add,e),e.updateVisibleLayers(),this._bindPicking(),this._visibility&&this.hasImageryTiles()&&this._preLoad())}get isIdle(){return this._planet&&this._planet._terrainCompletedActivated||!1}_bindPicking(){this._planet&&this._planet.renderer&&this._planet.renderer.assignPickingColor(this)}addTo(e){this._planet||this._assignPlanet(e)}remove(){let e=this._planet;if(e){for(let t=0;t<e._layers.length;t++)if(this.isEqual(e._layers[t]))return e.renderer&&e.renderer.clearPickingColor(this),e._layers.splice(t,1),e.updateVisibleLayers(),this.clear(),e.events.dispatch(e.events.layerremove,this),this.events.dispatch(this.events.remove,e),this._planet=null,this._internalFormat=null,this.createTexture=null,this}return this}clear(){this._planet&&this._planet._clearLayerMaterial(this)}get planet(){return this._planet}setAttribution(e){this._attribution!==e&&(this._attribution=e,this._planet&&this._planet.updateAttributionsList())}getAttribution(){return this._attribution}setHeight(e){this._height=e,this._planet&&this._planet.updateVisibleLayers()}getHeight(){return this._height}setZIndex(e){this._zIndex=e,this._planet&&this._planet.updateVisibleLayers()}getZIndex(){return this._zIndex}bringToFront(){if(this._planet){let e=this._planet.visibleTileLayers,t=e[e.length-1];t.isEqual(this)||this.setZIndex(t.getZIndex()+1)}}isBaseLayer(){return this._isBaseLayer}setBaseLayer(e){this._isBaseLayer=e,this._planet&&(!e&&this._planet.baseLayer&&this.isEqual(this._planet.baseLayer)&&(this._planet.baseLayer=null),this._planet.updateVisibleLayers())}setVisibility(e){e!==this._visibility&&(this._visibility=e,this._planet&&(this._isBaseLayer&&e&&this._planet.setBaseLayer(this),this._planet.updateVisibleLayers(),!e||this._isPreloadDone||this.isVector||(this._isPreloadDone=!0,this._preLoad())),this.events.dispatch(this.events.visibilitychange,this))}_forceMaterialApply(e){let t=e.materials,i=t[this.__id];i||(i=t[this.__id]=this.createMaterial(e)),i.isReady||(this._planet._renderCompleted=!1),this.applyMaterial(i,!0)}clearMaterial(e){}loadMaterial(e,t=!1){}applyMaterial(e,t=!1){return[0,0,1,1]}_preLoadRecursive(e,t){if(!(e.segment.tileZoom>t)){this._preLoadZoomLevels.includes(e.segment.tileZoom)&&this._forceMaterialApply(e.segment);for(let i=0,s=e.nodes.length;i<s;i++)e.nodes[i]&&this._preLoadRecursive(e.nodes[i],t)}}_preLoad(){if(this._planet&&this._preLoadZoomLevels.length){let e=this._planet,t=Math.max(...this._preLoadZoomLevels);for(let i=0,s=e.quadTreeStrategy.quadTreeList.length;i<s;i++)this._preLoadRecursive(e.quadTreeStrategy.quadTreeList[i],t)}}getVisibility(){return this._visibility}setExtent(e){let t=e.southWest.clone(),i=e.northEast.clone();t.lat<Ne&&(t.lat=Ne),i.lat>ue&&(i.lat=ue),this._extent=e.clone(),this._extentMerc=new G(t.forwardMercator(),i.forwardMercator()),this._correctFullExtent()}getExtent(){return this._extent}getExtentMerc(){return this._extentMerc}flyExtent(){var e;(e=this._planet)==null||e.flyExtent(this.getExtent())}viewExtent(){var e;(e=this._planet)==null||e.viewExtent(this.getExtent())}_correctFullExtent(){}get opacity(){return this._opacity}get screenOpacity(){return this._fading?this._fadingOpacity:this._opacity}_refreshFadingOpacity(){let e=this._planet;return this._visibility&&e.getViewExtent().overlaps(this._extent)&&e.maxCurrZoom>=this.minZoom&&e.minCurrZoom<=this.maxZoom?(this._fadingOpacity+=this._fadingFactor,(this._fadingFactor>0&&this._fadingOpacity>this._opacity||this._fadingFactor<0&&this._fadingOpacity<this._opacity)&&(this._fadingOpacity=this._opacity),!1):(this._fadingOpacity-=this._fadingFactor,this._fadingOpacity<=0&&(this._fadingOpacity=0),!1)}createMaterial(e){return new Jr(e,this)}redraw(){var e;(e=this._planet)==null||e.quadTreeStrategy.clearLayerMaterial(this)}abortMaterialLoading(e){}abortLoading(){}};en.__counter__=0;let qe=en;const tn=["visibilitychange","add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"],ml=["load","loadend"],Ss=class ht extends qe{constructor(e,t){super(e,t),this.events=this.events.registerNames(ml),this.animated=t.animated||!1,this.minNativeZoom=t.minNativeZoom||0,this.maxNativeZoom=t.maxNativeZoom||100,this._counter=0,this._pendingsQueue=[],this.drawTile=t.drawTile,this._onLoadend_=null}addTo(e){return this._onLoadend_=this._onLoadend.bind(this),this.events.on("loadend",this._onLoadend_,this),super.addTo(e)}remove(){return this.events.off("loadend",this._onLoadend_),this._onLoadend_=null,super.remove()}_onLoadend(){this._planet&&this._planet._terrainCompletedActivated&&this._planet.events.dispatch(this._planet.events.layerloadend,this)}get instanceName(){return"CanvasTiles"}get isIdle(){return super.isIdle&&this._counter===0}abortLoading(){this._pendingsQueue.forEach(e=>{this.abortMaterialLoading(e)}),this._pendingsQueue=[]}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),e||this.abortLoading())}loadMaterial(e){let t=e.segment;this._isBaseLayer?e.texture=t.getDefaultTexture():e.texture=t.planet.transparentTexture,(this._planet.layerLock.isFree()||e.segment.tileZoom<2)&&(e.isReady=!1,e.isLoading=!0,ht.__requestsCounter>=ht.MAX_REQUESTS&&this._counter?this._pendingsQueue.push(e):this._exec(e))}_exec(e){ht.__requestsCounter++,this._counter++;const t=this.events.load;t.handlers.length&&this.events.dispatch(t,e),requestAnimationFrame(()=>{this.drawTile(e,i=>{this._counter--,ht.__requestsCounter--,this._correctCounter(),e.isLoading&&e.applyImage(i),this._dequeueRequest()})})}_correctCounter(){this._counter<0&&(this._counter=0),ht.__requestsCounter<0&&(ht.__requestsCounter=0)}abortMaterialLoading(e){e.isLoading&&(this._counter--,ht.__requestsCounter--,this._correctCounter(),this._dequeueRequest()),e.isLoading=!1,e.isReady=!1}_dequeueRequest(){if(this._pendingsQueue.length){if(ht.__requestsCounter<ht.MAX_REQUESTS){const e=this._whilePendings();e&&this._exec(e)}}else this._counter===0&&this._planet&&this._planet._terrainCompletedActivated&&this.events.dispatch(this.events.loadend)}_whilePendings(){for(;this._pendingsQueue.length;){const e=this._pendingsQueue.pop();if(e&&e.segment&&e.segment.node){if(e.segment.initialized&&e.segment.node.getState()===1)return e;e.isLoading=!1}}return null}applyMaterial(e){if(e.isReady)return e.layer.animated&&requestAnimationFrame(()=>{this.drawTile(e,function(t){e.applyImage(t)})}),e.texOffset;if(e.segment.tileZoom<this.minNativeZoom)e.textureNotExists();else{let t=e.segment,i=t.node,s=!1,r=e.layer.maxNativeZoom;t.passReady&&!e.isLoading&&t.tileZoom<=r&&this.loadMaterial(e);let n=this._id,o=e;for(;i.parentNode;)if(i=i.parentNode,o=i.segment.materials[n],o&&o.textureExists){s=!0;break}if(t.passReady){if(i.segment.tileZoom===r)t.tileZoom>r&&e.textureNotExists();else if(i.segment.tileZoom<r){let l=t.node;for(;l.segment.tileZoom>r;)l=l.parentNode;let h=l.segment.materials[n];h?!h.isLoading&&!h.isReady&&this.loadMaterial(h):(h=l.segment.materials[e.layer._id]=e.layer.createMaterial(l.segment),this.loadMaterial(h))}}if(s){e.layer.animated&&requestAnimationFrame(()=>{this.drawTile(e,function(h){e.applyImage(h)})}),e.appliedNodeId=i.nodeId,e.texture=o.texture;let l=1/(2<<t.tileZoom-i.segment.tileZoom-1);e.texOffset[0]=t.tileX*l-i.segment.tileX,e.texOffset[1]=t.tileY*l-i.segment.tileY,e.texOffset[2]=l,e.texOffset[3]=l}else e.texture=t.planet.transparentTexture,e.texOffset[0]=0,e.texOffset[1]=0,e.texOffset[2]=1,e.texOffset[3]=1}return e.texOffset}clearMaterial(e){e.isReady&&(e.isReady=!1,e.textureExists&&e.texture&&!e.texture.default&&(e.segment.handler.gl.deleteTexture(e.texture),e.texture=null)),this.abortMaterialLoading(e),e.isLoading=!1,e.textureExists=!1,e.layer=null,e.segment=null}};Ss.MAX_REQUESTS=20,Ss.__requestsCounter=0;let sn=Ss;const vl=["change"];class rn{constructor(e={}){this._onChange=(t,i)=>{if(t){i.preventClick=!0;for(let s=0;s<this._buttons.length;s++){let r=this._buttons[s];r.isEqual(i)||(r.setActive(!1),r.preventClick=!1)}this.events.dispatch(this.events.change,i)}},this.events=he(vl),this._buttons=e.buttons||[];for(let t=0;t<this._buttons.length;t++)this._bindButton(this._buttons[t])}_bindButton(e){e.events.on("change",this._onChange)}add(e){this._buttons.push(e),this._bindButton(e)}remove(e){for(let t=0;t<this._buttons.length;t++)if(this._buttons[t].isEqual(e))return this._buttons.splice(t),void e.events.off("change",this._onChange)}}class Ms{constructor(e=2,t){this._sourceId=0,this._source=new Map,this._pendingQueue=[],this._numWorkers=e,this._workerQueue=[],t&&this.setProgram(t)}check(){this._pendingQueue.length&&this.make(this._pendingQueue.pop())}setProgram(e){if(Di(e)){let t=new Blob([e],{type:"application/javascript"});for(let i=0;i<this._numWorkers;i++){let s=new Worker(URL.createObjectURL(t));s.onmessage=r=>{this._onMessage(r),this._workerQueue&&this._workerQueue.unshift(r.target),this.check()},this._workerQueue.push(s)}}else for(let t=0;t<this._numWorkers;t++){let i=new e;i.onmessage=s=>{this._onMessage(s),this._workerQueue&&this._workerQueue.unshift(s.target),this.check()},this._workerQueue.push(i)}}make(e){}_onMessage(e){}destroy(){for(let e=0;e<this._workerQueue.length;e++){const t=this._workerQueue[e];t.onmessage=null,t.terminate()}this._pendingQueue=null,this._workerQueue=null}get pendingQueue(){return this._pendingQueue}}const nn=`(function(){"use strict";function n(i,f,u){let o=u.length,b=f*o;for(let A=0;A<o;A++)i[b+A]=u[A]}self.onmessage=function(i){var f=i.data.labelData,u=f[0],o=f[1],b=f[2],A=f[3],z=f[4],D=f[5],H=f[6],I=f[7],L=f[8],M=f[9],P=f[10],j=f[11],q=f[12],B=f[13],E=f[14],G=f[15],J=f[16],K=f[17],N=f[18],O=f[19],Q=f[20],R=f[21],S=f[22],T=f[23],U=f[24],Z=f[25],_=f[26],$=f[27],V=f[28],X=f[29];let w=new Float32Array(12*o),s=new Float32Array(24*o),y=new Float32Array(24*o),F=new Float32Array(18*o),g=new Float32Array(18*o),c=new Float32Array(6*o),d=new Float32Array(18*o),p=new Float32Array(24*o),x=new Float32Array(6*o),h=new Float32Array(18*o),v=new Float32Array(6*o),C=new Float32Array(6*o),m=new Float32Array(24*o),k=new Float32Array(18*o);for(let t=0;t<o;t++){n(w,t,b!==0?[0,0,0,-1,1,-1,1,-1,1,0,0,0]:[0,0,0,0,0,0,0,0,0,0,0,0]),n(s,t,[0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0]),n(y,t,[1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0]);var l,r=A,e=z,a=D;n(F,t,[r,e,a,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(g,t,[r=H,e=I,a=L,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(c,t,[r=M,r,r,r,r,r]),n(d,t,[r=P,e=j,a=q,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(p,t,[r=B,e=E,a=G,l=J,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l]),n(x,t,[r=K,r,r,r,r,r]),n(h,t,[r=N,e=O,a=Q,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(v,t,[r=R,r,r,r,r,r]),n(C,t,[r=S,r,r,r,r,r]),n(m,t,[r=T,e=U,a=Z,l=_,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l]),n(k,t,[r=$/255,e=V/255,a=X/255,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a])}self.postMessage({id:u,vertexArr:w,texCoordArr:s,gliphParamArr:y,positionHighArr:F,positionLowArr:g,sizeArr:c,offsetArr:d,rgbaArr:p,rotationArr:x,alignedAxisArr:h,fontIndexArr:v,outlineArr:C,outlineColorArr:m,pickingColorArr:k},[w.buffer,s.buffer,y.buffer,F.buffer,g.buffer,c.buffer,d.buffer,p.buffer,x.buffer,h.buffer,v.buffer,C.buffer,m.buffer,k.buffer])}})();
87
+ </div>>`,{title:e.title||"",display:zi(e.visible,!0)?"flex":"none",resize:zi(e.resizable,!0)?"both":"none",width:e.width||300,height:e.height?`height: ${e.height||200}px`:"",left:e.left||0,top:e.top||0,minHeight:e.minHeight?`${e.minHeight}px`:"unset",maxHeight:e.maxHeight?`${e.maxHeight}px`:"unset",minWidth:e.minWidth?`${e.minWidth}px`:"unset",maxWidth:e.maxWidth?`${e.maxWidth}px`:"unset"}),...e}),this._onCloseBtnClick=()=>{this.close()},this._onMouseDownAll=()=>{this.bringToFront()},this._onMouseDown=t=>{t.preventDefault(),this._startDragging(),this._startPosX=t.clientX,this._startPosY=t.clientY,document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp)},this._onMouseMove=t=>{t.preventDefault();let i=this._startPosX-t.clientX,r=this._startPosY-t.clientY;this._startPosX=t.clientX,this._startPosY=t.clientY,this.setPosition(this.el.offsetLeft-i,this.el.offsetTop-r)},this._onMouseUp=()=>{this._clearDragging(),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove)},this.events=this.events.registerNames(_l),this._width=e.width||300,this._height=e.height||200,this._startPosX=0,this._startPosY=0,this.$header=null,this.$title=null,this.$container=null,this.$buttons=null,this._closeBtn=new nt({icon:ul,classList:["og-button-size__20"]}),this.useHide=e.useHide||!1,this._visibility=zi(e.visible,!0),this._right=e.right!=null?e.right:null}setContainer(e){this.$container.innerHTML=e}get container(){return this.$container}get width(){return this.el?parseFloat(this.el.style.width):this._width}get height(){return this.el?parseFloat(this.el.style.height):this._height}bringToFront(){this.el.style.zIndex=String(Ro.__zIndex__++)}render(e){return super.render(e),this.bringToFront(),this.$header=this.select(".og-ddialog-header"),this.$title=this.select(".og-ddialog-header__title"),this.$container=this.select(".og-ddialog-container"),this.$buttons=this.select(".og-ddialog-header__buttons"),this._initEvents(),this._initButtons(),this._right!=null&&(this.el.style.visibility="hidden",new IntersectionObserver((t,i)=>{t.forEach(r=>{r.isIntersecting&&(this.el.style.visibility="visible",this.el.parentNode&&(this.setPosition(this.el.parentNode.clientWidth-this.el.clientWidth-this._right),i.disconnect()))})}).observe(this.el)),this}show(){this._visibility||(this._visibility=!0,this.el.style.display="flex",this.bringToFront(),this.events.dispatch(this.events.visibility,!0,this))}hide(){this._visibility&&(this._visibility=!1,this.el.style.display="none",this.events.dispatch(this.events.visibility,!1,this))}close(){this.useHide?this.hide():this.remove()}setVisibility(e){e?this.show():this.hide()}getVisibility(){return this._visibility}_initButtons(){this._closeBtn.events.on("click",this._onCloseBtnClick),this._closeBtn.appendTo(this.$buttons)}_initEvents(){this.$header.addEventListener("mousedown",this._onMouseDown),this.el.addEventListener("mousedown",this._onMouseDownAll)}setPosition(e,t){e!=null&&(this.el.style.left=`${e}px`),t!=null&&(this.el.style.top=`${t}px`)}_startDragging(){this.el.classList.contains("dragging")||(this.el.classList.add("dragging"),this.events.dispatch(this.events.dragstart,this))}_clearDragging(){this.el.classList.contains("dragging")&&(this.events.dispatch(this.events.dragend,this),this.el.classList.remove("dragging"))}remove(){this._clearDragging(),this._clearEvents(),super.remove()}_clearEvents(){this._closeBtn.events.off("click",this._onCloseBtnClick),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove),this.$header.removeEventListener("mousedown",this._onMouseDown),this.el.removeEventListener("mousedown",this._onMouseDownAll)}};Ks.__zIndex__=0;let at=Ks;const fl=["change"];class _e extends nt{constructor(e){super({...e}),this._onMouseClick=t=>{this.preventClick||(this._mouseClickHandler(t),this.setActive(!this.isActive))},this.events=this.events.registerNames(fl),this._isActive=e.isActive||!1,this.preventClick=e.preventClick||!1}setActive(e,t=!1){e!==this._isActive&&(this._isActive=e,this._toggle(),t||this.events.dispatch(this.events.change,e,this))}_toggle(){this.el&&this.el.classList.toggle("og-button__active")}get isActive(){return this._isActive}render(e){return super.render(e),this._isActive&&this._toggle(),this}}const Jt=[2,3,0,1],Js=[[-1,-1,0,1],[1,-1,3,-1],[2,3,-1,-1],[-1,0,-1,2]],gl=[[2,3,0,1],[1,0,3,2],[2,3,0,1],[1,0,3,2]],pl=[[0,1,0,0],[1,0,0,0],[0,1,0,1],[1,1,1,1]];class en{constructor(e,t){this.segment=e,this.layer=t,this.isReady=!1,this.isLoading=!1,this.texture=null,this.pickingMask=null,this.textureExists=!1,this.appliedNodeId=0,this.appliedNode=null,this.texOffset=[0,0,1,1],this.loadingAttempts=0,this._updateTexture=null,this._updatePickingMask=null,this.pickingReady=!1}abortLoading(){this.layer.abortMaterialLoading(this)}_createTexture(e){return this.layer._planet&&this.layer.createTexture(e,this.layer._internalFormat,this.isReady?this.texture:null)}applyImage(e){this.segment.initialized&&(this._updateTexture=null,this.texture=this._createTexture(e),this.isReady=!0,this.pickingReady=!0,this.textureExists=!0,this.isLoading=!1,this.appliedNodeId=this.segment.node.nodeId,this.texOffset=[0,0,1,1])}applyTexture(e,t){this.segment.initialized&&(this.texture=e,this._updateTexture=null,this.pickingMask=t||null,this._updatePickingMask=null,this.isReady=!0,this.pickingReady=!0,this.textureExists=!0,this.isLoading=!1,this.appliedNodeId=this.segment.node.nodeId,this.texOffset=[0,0,1,1])}textureNotExists(){this.segment.initialized&&(this.pickingReady=!0,this.isLoading=!1,this.isReady=!0,this.textureExists=!1)}clear(){this.loadingAttempts=0,this.layer.clearMaterial(this)}}const tn=class Bo{constructor(e,t={}){if(this.isVector=!1,this.__id=Bo.__counter__++,this._iconSrc=t.iconSrc||null,this.events=le(rn,this),this.name=e||"noname",this.properties=t.properties||{},this.hideInLayerSwitcher=t.hideInLayerSwitcher||!1,this._hasImageryTiles=!0,this._opacity=t.opacity!=null?t.opacity:1,this.minZoom=t.minZoom||0,this.maxZoom=t.maxZoom!=null?t.maxZoom:50,this._planet=null,this.isVector=!1,this._attribution=t.attribution||"",this._zIndex=t.zIndex||0,this._isBaseLayer=t.isBaseLayer||!1,this._defaultTextures=t.defaultTextures||[null,null],this._visibility=t.visibility===void 0||t.visibility,this._fading=t.fading||!1,this._fadingFactor=this._opacity/30,this._fading?this._fadingOpacity=0:this._fadingOpacity=this._opacity,this._height=t.height||0,this._extent=new j,this.createTexture=null,this._textureFilter=t.textureFilter?t.textureFilter.trim().toUpperCase():"MIPMAP",this._isSRGB=t.isSRGB!=null&&t.isSRGB,this._internalFormat=null,this._extentMerc=new j,this.setExtent(fr(t.extent,new j(new A(-180,-90),new A(180,90)))),this._pickingColor=new m,this._pickingEnabled=t.pickingEnabled===void 0||t.pickingEnabled,this._isPreloadDone=!1,this._preLoadZoomLevels=t.preLoadZoomLevels||[0,1],this._ambient=null,this._diffuse=null,this._specular=null,t.ambient){let i=qe(t.ambient,new m(.2,.2,.2));this._ambient=new Float32Array([i.x,i.y,i.z])}if(t.diffuse){let i=qe(t.diffuse,new m(.8,.8,.8));this._diffuse=new Float32Array([i.x,i.y,i.z])}if(t.specular){let i=qe(t.specular,new m(3e-4,3e-4,3e-4)),r=t.shininess||20;this._specular=new Float32Array([i.x,i.y,i.z,r])}this.nightTextureCoefficient=t.nightTextureCoefficient||1}get iconSrc(){return this._iconSrc}set iconSrc(e){this._iconSrc=e}set diffuse(e){if(e){let t=qe(e);this._diffuse=new Float32Array(t.toArray())}else this._diffuse=null}set ambient(e){if(e){let t=qe(e);this._ambient=new Float32Array(t.toArray())}else this._ambient=null}set specular(e){if(e){let t=qe(e);this._specular=new Float32Array([t.x,t.y,t.y,this._specular?this._specular[3]:0])}else this._specular=null}set shininess(e){this._specular&&(this._specular[3]=e)}static getTMS(e,t,i){return{x:e,y:(1<<i)-t-1,z:i}}static getTileIndex(e,t,i,r){return`${r}::${e}_${t}_${i}`}get instanceName(){return"Layer"}get rendererEvents(){return this.events}set opacity(e){e!==this._opacity&&(this._fading?e>this._opacity?this._fadingFactor=(e-this._opacity)/30:e<this._opacity&&(this._fadingFactor=(this._opacity-e)/30):this._fadingOpacity=e,this._opacity=e)}set pickingEnabled(e){this._pickingEnabled=e}get pickingEnabled(){return this._pickingEnabled}hasImageryTiles(){return this._hasImageryTiles}getID(){return this.__id}get id(){return this.__id}get _id(){return this.__id}isEqual(e){return e.__id===this.__id}_assignPlanet(e){this._planet=e,e._layers.push(this),e.renderer&&e.renderer.isInitialized()&&(this._isSRGB?this._internalFormat=e.renderer.handler.gl.SRGB8_ALPHA8:this._internalFormat=e.renderer.handler.gl.RGBA8,this.createTexture=e.renderer.handler.createTexture[this._textureFilter],this.events.on("visibilitychange",e._onLayerVisibilityChanged,e),this._isBaseLayer&&this._visibility&&e.setBaseLayer(this),e.events.dispatch(e.events.layeradd,this),this.events.dispatch(this.events.add,e),e.updateVisibleLayers(),this._bindPicking(),this._visibility&&this.hasImageryTiles()&&this._preLoad())}get isIdle(){return this._planet&&this._planet.quadTreeStrategy._terrainCompletedActivated||!1}_bindPicking(){this._planet&&this._planet.renderer&&this._planet.renderer.assignPickingColor(this)}addTo(e){this._planet||this._assignPlanet(e)}remove(){let e=this._planet;if(e){for(let t=0;t<e._layers.length;t++)if(this.isEqual(e._layers[t]))return e.renderer&&e.renderer.clearPickingColor(this),e._layers.splice(t,1),e.updateVisibleLayers(),this.clear(),e.events.dispatch(e.events.layerremove,this),this.events.dispatch(this.events.remove,e),this._planet=null,this._internalFormat=null,this.createTexture=null,this}return this}clear(){this._planet&&this._planet._clearLayerMaterial(this)}get planet(){return this._planet}setAttribution(e){this._attribution!==e&&(this._attribution=e,this._planet&&this._planet.updateAttributionsList())}getAttribution(){return this._attribution}setHeight(e){this._height=e,this._planet&&this._planet.updateVisibleLayers()}getHeight(){return this._height}setZIndex(e){this._zIndex=e,this._planet&&this._planet.updateVisibleLayers()}getZIndex(){return this._zIndex}bringToFront(){if(this._planet){let e=this._planet.visibleTileLayers,t=e[e.length-1];t.isEqual(this)||this.setZIndex(t.getZIndex()+1)}}isBaseLayer(){return this._isBaseLayer}setBaseLayer(e){this._isBaseLayer=e,this._planet&&(!e&&this._planet.baseLayer&&this.isEqual(this._planet.baseLayer)&&(this._planet.baseLayer=null),this._planet.updateVisibleLayers())}setVisibility(e){e!==this._visibility&&(this._visibility=e,this._planet&&(this._isBaseLayer&&e&&this._planet.setBaseLayer(this),this._planet.updateVisibleLayers(),!e||this._isPreloadDone||this.isVector||(this._isPreloadDone=!0,this._preLoad())),this.events.dispatch(this.events.visibilitychange,this))}_forceMaterialApply(e){let t=e.materials,i=t[this.__id];i||(i=t[this.__id]=this.createMaterial(e)),i.isReady||(e.quadTreeStrategy._renderCompleted=!1),this.applyMaterial(i,!0)}clearMaterial(e){}loadMaterial(e,t=!1){}applyMaterial(e,t=!1){return[0,0,1,1]}_preLoadRecursive(e,t){if(!(e.segment.tileZoom>t)){this._preLoadZoomLevels.includes(e.segment.tileZoom)&&this._forceMaterialApply(e.segment);for(let i=0,r=e.nodes.length;i<r;i++)e.nodes[i]&&this._preLoadRecursive(e.nodes[i],t)}}_preLoad(){if(this._planet&&this._preLoadZoomLevels.length){let e=this._planet,t=Math.max(...this._preLoadZoomLevels);for(let i=0,r=e.quadTreeStrategy.quadTreeList.length;i<r;i++)this._preLoadRecursive(e.quadTreeStrategy.quadTreeList[i],t)}}getVisibility(){return this._visibility}setExtent(e){let t=e.southWest.clone(),i=e.northEast.clone();t.lat<Oe&&(t.lat=Oe),i.lat>de&&(i.lat=de),this._extent=e.clone(),this._extentMerc=new j(t.forwardMercator(),i.forwardMercator()),this._correctFullExtent()}getExtent(){return this._extent}getExtentMerc(){return this._extentMerc}flyExtent(){var e;(e=this._planet)==null||e.flyExtent(this.getExtent())}viewExtent(){var e;(e=this._planet)==null||e.viewExtent(this.getExtent())}_correctFullExtent(){}get opacity(){return this._opacity}get screenOpacity(){return this._fading?this._fadingOpacity:this._opacity}_refreshFadingOpacity(e,t){let i=this._planet;return this._visibility&&i.getViewExtent().overlaps(this._extent)&&t>=this.minZoom&&e<=this.maxZoom?(this._fadingOpacity+=this._fadingFactor,(this._fadingFactor>0&&this._fadingOpacity>this._opacity||this._fadingFactor<0&&this._fadingOpacity<this._opacity)&&(this._fadingOpacity=this._opacity),!1):(this._fadingOpacity-=this._fadingFactor,this._fadingOpacity<=0&&(this._fadingOpacity=0),!1)}createMaterial(e){return new en(e,this)}redraw(){var e;(e=this._planet)==null||e.quadTreeStrategy.clearLayerMaterial(this)}abortMaterialLoading(e){}abortLoading(){}};tn.__counter__=0;let Ye=tn;const rn=["visibilitychange","add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"],ml=["load","loadend"],Mr=class ht extends Ye{constructor(e,t){super(e,t),this.events=this.events.registerNames(ml),this.animated=t.animated||!1,this.minNativeZoom=t.minNativeZoom||0,this.maxNativeZoom=t.maxNativeZoom||100,this._counter=0,this._pendingsQueue=[],this.drawTile=t.drawTile,this._onLoadend_=null}addTo(e){return this._onLoadend_=this._onLoadend.bind(this),this.events.on("loadend",this._onLoadend_,this),super.addTo(e)}remove(){return this.events.off("loadend",this._onLoadend_),this._onLoadend_=null,super.remove()}_onLoadend(){this._planet&&this._planet.quadTreeStrategy._terrainCompletedActivated&&this._planet.events.dispatch(this._planet.events.layerloadend,this)}get instanceName(){return"CanvasTiles"}get isIdle(){return super.isIdle&&this._counter===0}abortLoading(){this._pendingsQueue.forEach(e=>{this.abortMaterialLoading(e)}),this._pendingsQueue=[]}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),e||this.abortLoading())}loadMaterial(e){let t=e.segment;this._isBaseLayer?e.texture=t.getDefaultTexture():e.texture=t.planet.transparentTexture,(this._planet.layerLock.isFree()||e.segment.tileZoom<2)&&(e.isReady=!1,e.isLoading=!0,ht.__requestsCounter>=ht.MAX_REQUESTS&&this._counter?this._pendingsQueue.push(e):this._exec(e))}_exec(e){ht.__requestsCounter++,this._counter++;const t=this.events.load;t.handlers.length&&this.events.dispatch(t,e),requestAnimationFrame(()=>{this.drawTile(e,i=>{this._counter--,ht.__requestsCounter--,this._correctCounter(),e.isLoading&&e.applyImage(i),this._dequeueRequest()})})}_correctCounter(){this._counter<0&&(this._counter=0),ht.__requestsCounter<0&&(ht.__requestsCounter=0)}abortMaterialLoading(e){e.isLoading&&(this._counter--,ht.__requestsCounter--,this._correctCounter(),this._dequeueRequest()),e.isLoading=!1,e.isReady=!1}_dequeueRequest(){if(this._pendingsQueue.length){if(ht.__requestsCounter<ht.MAX_REQUESTS){const e=this._whilePendings();e&&this._exec(e)}}else this._counter===0&&this._planet&&this._planet.quadTreeStrategy._terrainCompletedActivated&&this.events.dispatch(this.events.loadend)}_whilePendings(){for(;this._pendingsQueue.length;){const e=this._pendingsQueue.pop();if(e&&e.segment&&e.segment.node){if(e.segment.initialized&&e.segment.node.getState()===1)return e;e.isLoading=!1}}return null}applyMaterial(e){if(e.isReady)return e.layer.animated&&requestAnimationFrame(()=>{this.drawTile(e,function(t){e.applyImage(t)})}),e.texOffset;if(e.segment.tileZoom<this.minNativeZoom)e.textureNotExists();else{let t=e.segment,i=t.node,r=!1,s=e.layer.maxNativeZoom;t.passReady&&!e.isLoading&&t.tileZoom<=s&&this.loadMaterial(e);let n=this._id,o=e;for(;i.parentNode;)if(i=i.parentNode,o=i.segment.materials[n],o&&o.textureExists){r=!0;break}if(t.passReady){if(i.segment.tileZoom===s)t.tileZoom>s&&e.textureNotExists();else if(i.segment.tileZoom<s){let l=t.node;for(;l.segment.tileZoom>s;)l=l.parentNode;let h=l.segment.materials[n];h?!h.isLoading&&!h.isReady&&this.loadMaterial(h):(h=l.segment.materials[e.layer._id]=e.layer.createMaterial(l.segment),this.loadMaterial(h))}}if(r){e.layer.animated&&requestAnimationFrame(()=>{this.drawTile(e,function(h){e.applyImage(h)})}),e.appliedNodeId=i.nodeId,e.texture=o.texture;let l=1/(2<<t.tileZoom-i.segment.tileZoom-1);e.texOffset[0]=t.tileX*l-i.segment.tileX,e.texOffset[1]=t.tileY*l-i.segment.tileY,e.texOffset[2]=l,e.texOffset[3]=l}else e.texture=t.planet.transparentTexture,e.texOffset[0]=0,e.texOffset[1]=0,e.texOffset[2]=1,e.texOffset[3]=1}return e.texOffset}clearMaterial(e){e.isReady&&(e.isReady=!1,e.textureExists&&e.texture&&!e.texture.default&&(e.segment.handler.gl.deleteTexture(e.texture),e.texture=null)),this.abortMaterialLoading(e),e.isLoading=!1,e.textureExists=!1,e.layer=null,e.segment=null}};Mr.MAX_REQUESTS=20,Mr.__requestsCounter=0;let sn=Mr;const vl=["change"];class nn{constructor(e={}){this._onChange=(t,i)=>{if(t){i.preventClick=!0;for(let r=0;r<this._buttons.length;r++){let s=this._buttons[r];s.isEqual(i)||(s.setActive(!1),s.preventClick=!1)}this.events.dispatch(this.events.change,i)}},this.events=le(vl),this._buttons=e.buttons||[];for(let t=0;t<this._buttons.length;t++)this._bindButton(this._buttons[t])}_bindButton(e){e.events.on("change",this._onChange)}add(e){this._buttons.push(e),this._bindButton(e)}remove(e){for(let t=0;t<this._buttons.length;t++)if(this._buttons[t].isEqual(e))return this._buttons.splice(t),void e.events.off("change",this._onChange)}}class Rr{constructor(e=2,t){this._sourceId=0,this._source=new Map,this._pendingQueue=[],this._numWorkers=e,this._workerQueue=[],t&&this.setProgram(t)}check(){this._pendingQueue.length&&this.make(this._pendingQueue.pop())}setProgram(e){if(Di(e)){let t=new Blob([e],{type:"application/javascript"});for(let i=0;i<this._numWorkers;i++){let r=new Worker(URL.createObjectURL(t));r.onmessage=s=>{this._onMessage(s),this._workerQueue&&this._workerQueue.unshift(s.target),this.check()},this._workerQueue.push(r)}}else for(let t=0;t<this._numWorkers;t++){let i=new e;i.onmessage=r=>{this._onMessage(r),this._workerQueue&&this._workerQueue.unshift(r.target),this.check()},this._workerQueue.push(i)}}make(e){}_onMessage(e){}destroy(){for(let e=0;e<this._workerQueue.length;e++){const t=this._workerQueue[e];t.onmessage=null,t.terminate()}this._pendingQueue=null,this._workerQueue=null}get pendingQueue(){return this._pendingQueue}}const an=`(function(){"use strict";function n(i,f,u){let o=u.length,b=f*o;for(let A=0;A<o;A++)i[b+A]=u[A]}self.onmessage=function(i){var f=i.data.labelData,u=f[0],o=f[1],b=f[2],A=f[3],z=f[4],D=f[5],H=f[6],I=f[7],L=f[8],M=f[9],P=f[10],j=f[11],q=f[12],B=f[13],E=f[14],G=f[15],J=f[16],K=f[17],N=f[18],O=f[19],Q=f[20],R=f[21],S=f[22],T=f[23],U=f[24],Z=f[25],_=f[26],$=f[27],V=f[28],X=f[29];let w=new Float32Array(12*o),s=new Float32Array(24*o),y=new Float32Array(24*o),F=new Float32Array(18*o),g=new Float32Array(18*o),c=new Float32Array(6*o),d=new Float32Array(18*o),p=new Float32Array(24*o),x=new Float32Array(6*o),h=new Float32Array(18*o),v=new Float32Array(6*o),C=new Float32Array(6*o),m=new Float32Array(24*o),k=new Float32Array(18*o);for(let t=0;t<o;t++){n(w,t,b!==0?[0,0,0,-1,1,-1,1,-1,1,0,0,0]:[0,0,0,0,0,0,0,0,0,0,0,0]),n(s,t,[0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0]),n(y,t,[1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0]);var l,r=A,e=z,a=D;n(F,t,[r,e,a,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(g,t,[r=H,e=I,a=L,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(c,t,[r=M,r,r,r,r,r]),n(d,t,[r=P,e=j,a=q,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(p,t,[r=B,e=E,a=G,l=J,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l]),n(x,t,[r=K,r,r,r,r,r]),n(h,t,[r=N,e=O,a=Q,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a]),n(v,t,[r=R,r,r,r,r,r]),n(C,t,[r=S,r,r,r,r,r]),n(m,t,[r=T,e=U,a=Z,l=_,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l,r,e,a,l]),n(k,t,[r=$/255,e=V/255,a=X/255,r,e,a,r,e,a,r,e,a,r,e,a,r,e,a])}self.postMessage({id:u,vertexArr:w,texCoordArr:s,gliphParamArr:y,positionHighArr:F,positionLowArr:g,sizeArr:c,offsetArr:d,rgbaArr:p,rotationArr:x,alignedAxisArr:h,fontIndexArr:v,outlineArr:C,outlineColorArr:m,pickingColorArr:k},[w.buffer,s.buffer,y.buffer,F.buffer,g.buffer,c.buffer,d.buffer,p.buffer,x.buffer,h.buffer,v.buffer,C.buffer,m.buffer,k.buffer])}})();
88
88
  //# sourceMappingURL=LabelWorker.worker-BT1uJgYn.js.map
89
- `,on=typeof self<"u"&&self.Blob&&new Blob([nn],{type:"text/javascript;charset=utf-8"});function yl(a){let e;try{if(e=on&&(self.URL||self.webkitURL).createObjectURL(on),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(nn),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class xl extends Ms{constructor(e=4){super(e,yl)}_onMessage(e){let t=this._source.get(e.data.id);t.label._lockId===-2?requestAnimationFrame(()=>{this.make({handler:t.handler,label:t.label})}):t.handler.workerCallback(e.data,t.label),this._source.delete(e.data.id)}make(e){let t=e.label;if(e.handler._entityCollection){let i=t.serializeWorkerData(this._sourceId);if(i)if(this._workerQueue.length){let s=this._workerQueue.pop();this._source.set(this._sourceId,e),t._lockId=this._sourceId,this._sourceId++,s.postMessage({labelData:i},[i.buffer])}else this._pendingQueue.push(e)}}}const an=class Ba{constructor(e={}){this.__id=Ba.__counter__++,this._position=je(e.position),this._positionHigh=new v,this._positionLow=new v,v.doubleToTwoFloats(this._position,this._positionHigh,this._positionLow),this._rotation=e.rotation||0,this._color=st(e.color),this._alignedAxis=je(e.alignedAxis),this._offset=je(e.offset),this._visibility=e.visibility==null||e.visibility,this._entity=null,this._handler=null,this._handlerIndex=-1,this._isReady=!1,this._lockId=-1}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,v.doubleToTwoFloats(this._position,this._positionHigh,this._positionLow),this._isReady&&this._handler?this._handler.setPositionArr(this._handlerIndex,this._positionHigh,this._positionLow):this._lockId!==-1&&(this._lockId=-2)}setPosition3v(e){this._position.x=e.x,this._position.y=e.y,this._position.z=e.z,v.doubleToTwoFloats(e,this._positionHigh,this._positionLow),this._isReady&&this._handler?this._handler.setPositionArr(this._handlerIndex,this._positionHigh,this._positionLow):this._lockId!==-1&&(this._lockId=-2)}getPosition(){return this._position}setOffset(e,t,i){this._offset.x=e,this._offset.y=t,i!=null&&(this._offset.z=i),this._isReady&&this._handler?this._handler.setOffsetArr(this._handlerIndex,this._offset):this._lockId!==-1&&(this._lockId=-2)}setOffset3v(e){this.setOffset(e.x,e.y,e.z)}getOffset(){return this._offset}setRotation(e){e!==this._rotation&&(this._rotation=e,this._isReady&&this._handler?this._handler.setRotationArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getRotation(){return this._rotation}setOpacity(e){e!==this._color.w&&(e!=null&&(this._color.w=e),this._isReady&&this._handler?this._handler.setRgbaArr(this._handlerIndex,this._color):this._lockId!==-1&&(this._lockId=-2))}setColor(e,t,i,s){s===this._color.w&&e===this._color.x&&t===this._color.y&&this._color.z===i||(this._color.x=e,this._color.y=t,this._color.z=i,s!=null&&(this._color.w=s),this._isReady&&this._handler?this._handler.setRgbaArr(this._handlerIndex,this._color):this._lockId!==-1&&(this._lockId=-2))}setColor4v(e){this.setColor(e.x,e.y,e.z,e.w)}setColorHTML(e){this.setColor4v(it(e))}getColor(){return this._color}setVisibility(e){e!==this._visibility&&(this._visibility=e,this._isReady&&this._handler?this._handler.setVisibility(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getVisibility(){return this._visibility}setAlignedAxis(e,t,i){this._alignedAxis.x=e,this._alignedAxis.y=t,this._alignedAxis.z=i,this._isReady&&this._handler?this._handler.setAlignedAxisArr(this._handlerIndex,this._alignedAxis):this._lockId!==-1&&(this._lockId=-2)}setAlignedAxis3v(e){this.setAlignedAxis(e.x,e.y,e.z)}getAlignedAxis(){return this._alignedAxis}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._isReady&&this._handler?this._handler.setPickingColorArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2)}serializeWorkerData(e){return this._handler?new Float32Array([]):null}};an.__counter__=0;let ln=an;class hn extends ln{constructor(e={}){super(e),this._handler=null,this._src=e.src||null,this._image=e.image||null,this._scale=1,this._width=e.width||(e.size?e.size[0]:30),this._height=e.height||(e.size?e.size[1]:30)}setSrc(e){this._src=e;let t=this._handler;if(t&&e&&e.length){let i=t._entityCollection.renderNode;if(i&&i.renderer){let s=i.renderer.billboardsTextureAtlas,r=this;s.loadImage(e,function(n){n.__nodeIndex!=null&&s.get(n.__nodeIndex)?(r._image=n,t.setTexCoordArr(r._handlerIndex,s.get(r._image.__nodeIndex).texCoords)):(s.addImage(n),s.createTexture(),r._image=n,i.updateBillboardsTexCoords())})}}}getSrc(){return this._src}setImage(e){this.setSrc(e.src)}getImage(){return this._image}setSize(e,t){this._width=e,this._height=t,this._handler&&this._handler.setSizeArr(this._handlerIndex,e*this._scale,t*this._scale)}getSize(){return{width:this._width,height:this._height}}setWidth(e){this.setSize(e,this._height)}getWidth(){return this._width}setHeight(e){this.setSize(this._width,e)}getHeight(){return this._height}}var ti=(a=>(a[a.POINT=1]="POINT",a[a.LINESTRING=2]="LINESTRING",a[a.POLYGON=3]="POLYGON",a[a.MULTIPOLYGON=4]="MULTIPOLYGON",a[a.MULTILINESTRING=5]="MULTILINESTRING",a))(ti||{});const bl={POINT:1,LINESTRING:2,POLYGON:3,MULTIPOLYGON:4,MULTILINESTRING:5},cn=class St{constructor(e={}){this.__id=St.__counter__++,this._entity=null,this._handler=null,this._handlerIndex=-1,this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyVerticesLength=-1,this._polyIndexesLength=-1,this._polyVerticesHandlerIndex=-1,this._polyIndexesHandlerIndex=-1,this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineVerticesLength=-1,this._lineOrdersLength=-1,this._lineIndexesLength=-1,this._lineColorsLength=-1,this._lineThicknessLength=-1,this._lineVerticesHandlerIndex=-1,this._lineOrdersHandlerIndex=-1,this._lineIndexesHandlerIndex=-1,this._lineThicknessHandlerIndex=-1,this._lineColorsHandlerIndex=-1,this._type=e.type&&St.getType(e.type)||1,this._coordinates=e.coordinates||[],this._extent=St.getExtent({type:e.type||"POINT",coordinates:e.coordinates||[]},this._coordinates),e.style=e.style||{},this._style={fillColor:st(e.style.fillColor,new ee(.19,.62,.85,.4)),lineColor:st(e.style.lineColor,new ee(.19,.62,.85,1)),strokeColor:st(e.style.strokeColor,new ee(1,1,1,.95)),lineWidth:e.style.lineWidth||3,strokeWidth:e.style.strokeWidth||0},this._visibility=e.visibility||!0,this._pickingReady=!1}get id(){return this.__id}get type(){return this._type}static getType(e){return bl[e.toUpperCase()]}static getExtent(e,t){let i=new G(new A(180,90),new A(-180,-90)),s=St.getType(e.type);if(s===1){let r=e.coordinates[0],n=e.coordinates[1];i.southWest.lon=r,i.southWest.lat=n,i.northEast.lon=r,i.northEast.lat=n,t&&(t[0]=r)&&(t[1]=n)}else if(s===2){let r=e.coordinates;for(let n=0;n<r.length;n++){let o=r[n][0],l=r[n][1];o<i.southWest.lon&&(i.southWest.lon=o),l<i.southWest.lat&&(i.southWest.lat=l),o>i.northEast.lon&&(i.northEast.lon=o),l>i.northEast.lat&&(i.northEast.lat=l),t&&(t[n]=[o,l])}}else if(s===3){let r=e.coordinates;for(let n=0;n<r.length;n++){let o=r[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l],c=h[0],d=h[1];c<i.southWest.lon&&(i.southWest.lon=c),d<i.southWest.lat&&(i.southWest.lat=d),c>i.northEast.lon&&(i.northEast.lon=c),d>i.northEast.lat&&(i.northEast.lat=d),t&&(t[n][l]=[c,d])}}}else if(s===4){let r=e.coordinates;for(let n=0;n<r.length;n++){let o=r[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l];t&&(t[n][l]=[]);for(let c=0;c<h.length;c++){let d=h[c],u=d[0],g=d[1];u<i.southWest.lon&&(i.southWest.lon=u),g<i.southWest.lat&&(i.southWest.lat=g),u>i.northEast.lon&&(i.northEast.lon=u),g>i.northEast.lat&&(i.northEast.lat=g),t&&(t[n][l][c]=[u,g])}}}}else if(s===5){let r=e.coordinates;for(let n=0;n<r.length;n++){let o=r[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l],c=h[0],d=h[1];c<i.southWest.lon&&(i.southWest.lon=c),d<i.southWest.lat&&(i.southWest.lat=d),c>i.northEast.lon&&(i.northEast.lon=c),d>i.northEast.lat&&(i.northEast.lat=d),t&&(t[n][l]=[c,d])}}}else i.southWest.lon=i.southWest.lat=i.northEast.lon=i.northEast.lat=0,t&&(t[0]=0)&&(t[1]=0);return i}setGeometry(e){let t=this._handler;return t&&(this.remove(),this._type=St.getType(e.type||"Point"),this._extent=St.getExtent(e,this._coordinates),t.add(this)),this}setFillColor(e,t,i,s=1){let r=this._style.fillColor;return(r.w===0&&s!==0||r.w!==0&&s===0)&&(this._pickingReady=!1),r.x=e,r.y=t,r.z=i,r.w=s,this._handler&&this._handler.setPolyColorArr(this,r),this}overlaps(e){return this._extent.overlaps(e)}setFillColor4v(e){return this.setFillColor(e.x,e.y,e.z,e.w)}setStrokeColor(e,t,i,s=1){let r=this._style.strokeColor;return(r.w===0&&s!==0||r.w!==0&&s===0)&&(this._pickingReady=!1),r.x=e,r.y=t,r.z=i,r.w=s,this._handler&&this._handler.setLineStrokeColorArr(this,r),this}setLineColor(e,t,i,s=1){let r=this._style.lineColor;return(r.w===0&&s!==0||r.w!==0&&s===0)&&(this._pickingReady=!1),r.x=e,r.y=t,r.z=i,r.w=s,this._handler&&this._handler.setLineColorArr(this,r),this}setStrokeColor4v(e){return this.setStrokeColor(e.x,e.y,e.z,e.w)}setLineColor4v(e){return this.setLineColor(e.x,e.y,e.z,e.w)}setStrokeOpacity(e){let t=this._style.strokeColor;return t.w=e,this.setStrokeColor(t.x,t.y,t.z,e)}setLineOpacity(e){let t=this._style.lineColor;return t.w=e,this.setLineColor(t.x,t.y,t.z,e)}setStrokeWidth(e){return this._style.strokeWidth=e,this._pickingReady=!1,this._handler&&this._handler.setLineStrokeArr(this,e),this}bringToFront(){return this._handler&&this._handler.bringToFront(this),this}setLineWidth(e){return this._style.lineWidth=e,this._pickingReady=!1,this._handler&&this._handler.setLineThicknessArr(this,e),this}setFillOpacity(e){let t=this._style.fillColor;return(t.w===0&&e!==0||t.w!==0&&e===0)&&(this._pickingReady=!1),t.w=e,this._handler&&this._handler.setPolyColorArr(this,t),this}setVisibility(e){return this._visibility=e,this._handler&&this._handler.setGeometryVisibility(this),this}getVisibility(){return this._visibility}remove(){this._handler&&this._handler.remove(this)}getExtent(){return this._extent.clone()}getType(){return this._type}};cn.__counter__=0;let dn=cn;class Ze{constructor(e,t){this.p0=e||new v,this.p1=t||new v}getMagnitude(){return this.p0.distance(this.p1)}getSphereIntersection(e){let t=this.p0,i=this.p1,s=e.center.x,r=e.center.y,n=e.center.z,o=t.x,l=t.y,h=t.z,c=i.x-o,d=i.y-l,u=i.z-h,g=c*c+d*d+u*u,f=2*(o*c+l*d+h*u-c*s-d*r-u*n),p=f*f-4*g*(o*o-2*o*s+s*s+l*l-2*l*r+r*r+h*h-2*h*n+n*n-e.radius*e.radius);if(p<0)return[];let _=(-f-Math.sqrt(p))/(2*g),m=new v(t.x*(1-_)+_*i.x,t.y*(1-_)+_*i.y,t.z*(1-_)+_*i.z);if(p==0)return[m];let y=(-f+Math.sqrt(p))/(2*g),x=new v(t.x*(1-y)+y*i.x,t.y*(1-y)+y*i.y,t.z*(1-y)+y*i.z);return Math.abs(_-.5)<Math.abs(y-.5)?[m,x]:[x,m]}intersects(e,t,i){let s=this.p0.sub(e.p0),r=e.p1.sub(e.p0);if(Math.abs(r.x)<tt&&Math.abs(r.y)<tt&&Math.abs(r.z)<tt)return!1;let n=this.p1.sub(this.p0);if(Math.abs(n.x)<tt&&Math.abs(n.y)<tt&&Math.abs(n.z)<tt)return!1;let o=s.x*r.x+s.y*r.y+s.z*r.z,l=r.x*n.x+r.y*n.y+r.z*n.z,h=s.x*n.x+s.y*n.y+s.z*n.z,c=r.x*r.x+r.y*r.y+r.z*r.z,d=(n.x*n.x+n.y*n.y+n.z*n.z)*c-l*l;if(Math.abs(d)<tt)return!1;let u=(o*l-h*c)/d;if(t.x=this.p0.x+u*n.x,t.y=this.p0.y+u*n.y,t.z=this.p0.z+u*n.z,i){let g=(o+l*u)/c;i.x=e.p0.x+g*r.x,i.y=e.p0.y+g*r.y,i.z=e.p0.z+g*r.z}return!0}getNearestDistancePoint(e,t){let i=this.p0,s=this.p1,r=this.getMagnitude(),n=((e.x-i.x)*(s.x-i.x)+(e.y-i.y)*(s.y-i.y)+(e.z-i.z)*(s.z-i.z))/(r*r);return t.x=i.x+n*(s.x-i.x),t.y=i.y+n*(s.y-i.y),t.z=i.z+n*(s.z-i.z),!(n<0||n>1)}}class Pe{constructor(e,t){this.p=e?e.clone():new v,this.n=t?t.clone():this.p.isZero()?v.UP:this.p.getNormal()}setByPoints(e,t,i){let s=v.sub(t,e),r=v.sub(i,e);return this.n=s.cross(r),this.p.copy(e),this}static fromPoints(e,t,i){return new Pe().setByPoints(e,t,i)}set(e,t){this.p.copy(e),this.n.copy(t)}getNormal(){return this.n.clone()}distance(e){let t=this.getProjection(e);return e.distance(t)}getProjection(e,t){return v.proj_b_to_plane(e,this.n,t)}getProjectionPoint(e,t){let i=e.sub(this.p),s=this.n,r=i.dot(s);return t?t.copy(s.scale(r)):t=s.scale(r),e.sub(t)}getIntersection(e,t,i){let s,r=e.n.cross(t.n),n=r.x>=0?r.x:-r.x,o=r.y>=0?r.y:-r.y,l=r.z>=0?r.z:-r.z;if(n+o+l<wr){let u=t.p.sub(e.p);return e.n.dot(u)==0?1:0}s=n>o?n>l?1:3:o>l?2:3;let h,c,d=new v;return h=-e.n.dot(e.p),c=-t.n.dot(t.p),s===1?(d.x=0,d.y=(c*e.n.z-h*t.n.z)/r.x,d.z=(h*t.n.y-c*e.n.y)/r.x):s===2?(d.x=(h*t.n.z-c*e.n.z)/r.y,d.y=0,d.z=(c*e.n.x-h*t.n.x)/r.y):s===3&&(d.x=(c*e.n.y-h*t.n.y)/r.z,d.y=(h*t.n.x-c*e.n.x)/r.z,d.z=0),i.p0.copy(d),i.p1.copy(d.add(r)),2}}let U=class ct{constructor(e=v.ZERO,t=v.ZERO){this.origin=e,this.direction=t}static get OUTSIDE(){return 0}static get INSIDE(){return 1}static get INPLANE(){return 2}static get AWAY(){return 3}set(e,t){return this.origin=e,this.direction=t,this}getPoint(e){return v.add(this.origin,this.direction.scaleTo(e))}hitTriangleRes(e,t,i,s){let r=t.sub(e),n=i.sub(e),o=r.cross(n),l=this.origin.sub(e),h=-o.dot(l),c=o.dot(this.direction);if(Math.abs(c)<tt)return h===0?(s.copy(this.origin),ct.INPLANE):ct.OUTSIDE;let d=h/c;if(s.copy(this.origin.add(this.direction.scaleTo(d))),d<0)return ct.AWAY;let u=r.dot(r),g=r.dot(n),f=n.dot(n),p=s.sub(e),_=p.dot(r),m=p.dot(n),y=g*g-u*f,x=(g*m-f*_)/y;if(x<0||x>1)return ct.OUTSIDE;let w=(g*_-u*m)/y;return w<0||x+w>1?ct.OUTSIDE:ct.INSIDE}hitPlaneRes(e,t){const i=this.direction.dot(e.n);if(Math.abs(i)<tt)return ct.OUTSIDE;const s=e.p.sub(this.origin).dot(e.n)/i;return s<0?ct.AWAY:(t.copy(this.getPoint(s)),ct.INSIDE)}hitSphere(e){const t=v.sub(this.origin,e.center),i=this.direction.dot(this.direction),s=2*t.dot(this.direction),r=s*s-4*i*(t.dot(t)-e.radius*e.radius);if(r<0)return null;const n=Math.sqrt(r);let o=(-s-n)/(2*i);return o<0&&(o=(-s+n)/(2*i)),o<0?null:v.add(this.origin,this.direction.scaleTo(o))}hitBox(e){}};function Rs(a){let e=a.split("/"),t=e[e.length-1],i=e[e.length-2];return`${i?i+"/":""}${t}`}class un{constructor(){this.objPositions=[],this.objTexcoords=[],this.objNormals=[],this.objVertexData=[this.objPositions,this.objTexcoords,this.objNormals],this.vertexData=[[],[],[]],this._materialLibs=[],this.geometries=[],this.geometry=null,this.materials={},this.material={},this.object="default",this.groups=["default"],this._path="",this.keywords={v:e=>{this.objPositions.push(e.map(parseFloat))},vn:e=>{this.objNormals.push(e.map(parseFloat))},vt:e=>{this.objTexcoords.push([parseFloat(e[0]),1-parseFloat(e[1])])},f:e=>{this.setGeometry();const t=e.length-2;for(let i=0;i<t;++i)this.addVertex(e[0]),this.addVertex(e[i+1]),this.addVertex(e[i+2])},s:()=>{},mtllib:(e,t)=>{this._materialLibs.push(t)},usemtl:(e,t)=>{this.newGeometry(),this.setGeometry(),this.geometry&&(this.geometry.material=t)},g:e=>{this.groups=e,this.newGeometry()},o:(e,t)=>{this.object=t,this.newGeometry()},newmtl:(e,t)=>{const i={};this.material=i,this.materials[t]=i},Ns:(e,t)=>{this.material.shininess=parseFloat(t)},Ni:(e,t)=>{},Ka:(e,t)=>{this.material.ambient=e.map(i=>parseFloat(i))},Kd:(e,t)=>{this.material.diffuse=e.map(i=>parseFloat(i))},Ks:(e,t)=>{this.material.specular=e.map(i=>parseFloat(i))},Ke:(e,t)=>{this.material.color=e.map(i=>parseFloat(i))},illum:(e,t)=>{this.material.illum=parseFloat(t)},d:(e,t)=>{this.material.opacity=parseFloat(t)},Tr:(e,t)=>{this.material.opacity=parseFloat(t)},Tf:(e,t)=>{},map_Ka:(e,t)=>{},map_Kd:(e,t)=>{this.material.colorTexture=`${this._path}/${Rs(t)}`},map_Bump:(e,t)=>{this.material.normalTexture=`${this._path}/${Rs(t)}`},map_Ns:(e,t)=>{this.material.metallicRoughnessTexture=`${this._path}/${Rs(t)}`}}}newGeometry(){this.geometry&&this.geometry.data.vertices.length&&(this.geometry=null)}setGeometry(){if(!this.geometry){const e=[],t=[],i=[];this.vertexData=[e,t,i],this.geometry={object:this.object,groups:this.groups,material:"",data:{vertices:e,texCoords:t,normals:i}},this.geometries.push(this.geometry)}}addVertex(e){let t=e.split("/");for(let i=0;i<t.length;i++){let s=t[i];if(!s)continue;let r=parseInt(s)-1,n=this.vertexData[i],o=n.length,l=this.objVertexData[i][r],h=l.length;this.vertexData[i].length=o+h;for(let c=0;c<h;c++)n[o+c]=l[c]}}_innerParser(e,t){const i=/(\w*)(?: )*(.*)/,s=e.split(`
90
- `);for(let r=0;r<s.length;++r){const n=s[r].trim();if(n===""||n.startsWith("#"))continue;const o=i.exec(n);if(!o)continue;const[,l,h]=o,c=n.split(/\s+/).slice(1),d=this.keywords[l];d?d(c,h):console.warn(`Unknown keyword '${l}' in '${t}:${r}'`)}}get data(){return{geometries:this.geometries,materials:this.materials}}async load(e){this._path=e.substring(0,e.lastIndexOf("/"));const t=await fetch(e);if(!t.ok)throw new Error(`Unable to load '${e}'`);const i=t.body.getReader(),s=new TextDecoder;let{value:r,done:n}=await i.read(),o="";for(;!n;){const h=(o+s.decode(r,{stream:!0})).split(`
91
- `);o=h.pop();for(const c of h)this._innerParser(c,e);({value:r,done:n}=await i.read())}o&&this._innerParser(o,e),this._cleanupGeometryArrays();let l=this._materialLibs.map(h=>(h=`${this._path}/${h}`,fetch(h).then(c=>c.text()).then(c=>({text:c,filename:h}))));return await Promise.all(l).then(h=>{h.forEach(c=>this._innerParser(c.text,c.filename))}),this.data}async _readAndParse(e){const t=e.stream().getReader(),i=new TextDecoder;let{value:s,done:r}=await t.read(),n="";for(;!r;){const o=(n+i.decode(s,{stream:!0})).split(`
92
- `);n=o.pop();for(const l of o)this._innerParser(l,e.name);({value:s,done:r}=await t.read())}n&&this._innerParser(n,e.name)}async readFile(e,t){return this._path="",await this._readAndParse(e),this._cleanupGeometryArrays(),t&&await this._readAndParse(t),this.data}_cleanupGeometryArrays(){for(const e of this.geometries)e.data=Object.fromEntries(Object.entries(e.data).filter(([t,i])=>i.length>0))}}function Ft(a){let e=new Float32Array([1,1,1]);if(a instanceof Array)e[0]=a[0],e[1]=a[1],e[2]=a[2];else if(typeof a=="string"){let t=_t(a);e[0]=t[0],e[1]=t[1],e[2]=t[2]}return e}class Z{constructor(e={}){var t;if(this._name=e.name||"noname",this._vertices=e.vertices||[],this._numVertices=this._vertices.length/3,this._texCoords=e.texCoords||new Array(2*this._numVertices),this.color=(t=e.color)instanceof Array?new Float32Array(t):typeof t=="string"?_t(t):new Float32Array([.5,.5,.5,1]),this.ambient=Ft(e.ambient),this.diffuse=Ft(e.diffuse),this.specular=Ft(e.specular),this.shininess=e.shininess||100,this.colorTextureSrc=e.colorTextureSrc||null,this.colorTextureImage=e.colorTextureImage||null,this.normalTextureSrc=e.normalTextureSrc||null,this.normalTextureImage=e.normalTextureImage||null,this.metallicRoughnessTextureSrc=e.metallicRoughnessTextureSrc||null,this.metallicRoughnessTextureImage=e.metallicRoughnessTextureImage||null,e.scale){let i,s=e.scale;i=typeof s=="number"?new v(s,s,s):s,Z.scale(this._vertices,i)}if(e.center&&Z.centering(this._vertices),this.center=Z.getCenter(this._vertices),e.indices)this._indices=e.indices,this._normals=e.normals||[];else{this._normals=e.normals||Z.getNormals(this._vertices),this._indices=new Array(this._vertices.length/3);for(let i=0,s=this._indices.length;i<s;i++)this._indices[i]=i}}static getCenter(e){let t=ye,i=ye,s=ye,r=Te,n=Te,o=Te;for(let l=0,h=e.length;l<h;l+=3){let c=e[l],d=e[l+1],u=e[l+2];c<t&&(t=c),d<i&&(i=d),u<s&&(s=u),c>r&&(r=c),d>n&&(n=d),u>o&&(o=u)}return new v(t+.5*(r-t),i+.5*(n-i),s+.5*(o-s))}static centering(e){let t=Z.getCenter(e);for(let i=0,s=e.length;i<s;i+=3)e[i]-=t.x,e[i+1]-=t.y,e[i+2]-=t.z}setMaterial(e){return e.ambient&&(this.ambient=Ft(e.ambient)),e.diffuse&&(this.diffuse=Ft(e.diffuse)),e.specular&&(this.specular=Ft(e.specular)),e.shininess!==void 0&&(this.shininess=e.shininess),this}centering(){return Z.centering(this._vertices),this}applyMat4(e){for(let t=0,i=this._vertices.length;t<i;t+=3){let s=new v(this._vertices[t],this._vertices[t+1],this._vertices[t+2]),r=new v(this._normals[t],this._normals[t+1],this._normals[t+2]);s=e.mulVec3(s),r=e.mulVec3(r),this._vertices[t]=s.x,this._vertices[t+1]=s.y,this._vertices[t+2]=s.z,this._normals[t]=r.x,this._normals[t+1]=r.y,this._normals[t+2]=r.z}return this}scale(e){return Z.scale(this._vertices,e),this}translate(e){for(let t=0,i=this._vertices.length;t<i;t+=3)this._vertices[t]+=e.x,this._vertices[t+1]+=e.y,this._vertices[t+2]+=e.z;return this}get name(){return this._name}get vertices(){return this._vertices}get normals(){return this._normals}get indices(){return this._indices}get texCoords(){return this._texCoords}get numVertices(){return this._numVertices}static scale(e,t){for(let i=0;i<e.length;i+=3)e[i]*=t.x,e[i+1]*=t.y,e[i+2]*=t.z}static centroid(e){let t=1e3,i=1e3,s=1e3,r=-1e3,n=-1e3,o=-1e3;for(let l=0;l<e.length;l+=3){let h=e[l],c=e[l+1],d=e[l+2];h<t&&(t=h),c<i&&(i=c),d<s&&(s=d),h>r&&(r=h),c>n&&(n=c),d>o&&(o=d)}return[t+.5*(r-t),i+.5*(n-i),s+.5*(o-s)]}static translate(e,t){for(let i=0;i<e.length;i+=3)e[i]+=t[0],e[i+1]+=t[1],e[i+2]+=t[2]}static getNormals(e){let t=new Array(e.length);for(let i=0;i<e.length;i+=9){let s=i,r=i+3,n=i+6,o=e[s],l=e[s+1],h=e[s+2],c=e[r]-o,d=e[r+1]-l,u=e[r+2]-h,g=e[n]-o,f=e[n+1]-l,p=e[n+2]-h,_=d*p-u*f,m=u*g-c*p,y=c*f-d*g,x=Math.sqrt(_*_+m*m+y*y);_/=x,m/=x,y/=x,t[s]=_,t[s+1]=m,t[s+2]=y,t[r]=_,t[r+1]=m,t[r+2]=y,t[n]=_,t[n+1]=m,t[n+2]=y}return t}static createSphere(e=16,t=16,i=1,s=0,r=0,n=0){let o=[],l=[],h=[];for(let c=0;c<=t;c++){let d=c*Math.PI/t,u=Math.sin(d),g=Math.cos(d);for(let f=0;f<=e;f++){let p=2*f*Math.PI/e,_=Math.sin(p),m=Math.cos(p)*u+s,y=g+r,x=_*u+n;h.push(m),h.push(y),h.push(x),o.push(i*m),o.push(i*y),o.push(i*x)}}for(let c=0;c<t;c++)for(let d=0;d<e;d++){let u=c*(e+1)+d,g=u+e+1;l.push(u),l.push(u+1),l.push(g),l.push(g),l.push(u+1),l.push(g+1)}return new Z({vertices:o,normals:h,indices:l})}static createDisc(e=1,t=0,i=8,s=!0,r=0,n=0,o=0,l=0){let h=[],c=[],d=[],u=2*Math.PI,g=s?1:-1,f=r;for(let _=1;_<=i;_++)h.push(n,t*g+o,l),d.push(0,g,0),r++;let p=r;for(let _=0;_<=i;_++){let m=_/i*u+0,y=Math.cos(m),x=Math.sin(m);h.push(e*x+n,t*g+o,e*y+l),d.push(0,g,0),r++}for(let _=0;_<i;_++){let m=f+_,y=p+_;s?c.push(y,y+1,m):c.push(y+1,y,m)}return new Z({vertices:h,normals:d,indices:c})}static getFrustumScaleByCameraAngles(e,t,i){return new v(2*e*Math.tan(et*t),2*e*Math.tan(et*i),e)}static getFrustumScaleByCameraAspectRatio(e,t,i){let s=ts*Math.atan(Math.tan(et*t)/i);return Z.getFrustumScaleByCameraAngles(e,t,s)}static createFrustum(e=1,t=1,i=1,s=0,r=0,n=0){return new Z({vertices:[0+s,0+r,0+n,-1*(t*=.5)+s,1*(i*=.5)+r,-1*e+n,1*t+s,1*i+r,-1*e+n,0+s,0+r,0+n,1*t+s,-1*i+r,-1*e+n,-1*t+s,-1*i+r,-1*e+n,0+s,0+r,0+n,1*t+s,1*i+r,-1*e+n,1*t+s,-1*i+r,-1*e+n,0+s,0+r,0+n,-1*t+s,-1*i+r,-1*e+n,-1*t+s,1*i+r,-1*e+n,0+s,0+r,0+n,1*t+s,1*i+r,-1*e+n,-1*t+s,1*i+r,-1*e+n,0+s,0+r,0+n,-1*t+s,-1*i+r,-1*e+n,1*t+s,-1*i+r,-1*e+n,0+s,0+r,0+n,1*t+s,-1*i+r,-1*e+n,1*t+s,1*i+r,-1*e+n,0+s,0+r,0+n,-1*t+s,1*i+r,-1*e+n,-1*t+s,-1*i+r,-1*e+n]})}static createCylinder(e=1,t=1,i=1,s=32,r=1,n=!0,o=!0,l=0,h=0,c=0){let d=[],u=[],g=[],f=2*Math.PI,p=0,_=[],m=new v,y=(t-e)/i;for(let x=0;x<=r;x++){let w=[],b=x/r,E=b*(t-e)+e;for(let C=0;C<=s;C++){let T=C/s*f+0,L=Math.sin(T),M=Math.cos(T);d.push(E*L+l,-b*i+i+h,E*M+c),m.set(L,y,M).normalize(),g.push(m.x,m.y,m.z),w.push(p++)}_.push(w)}for(let x=0;x<s;x++)for(let w=0;w<r;w++){let b=_[w][x],E=_[w+1][x],C=_[w+1][x+1],T=_[w][x+1];u.push(b,E,T),u.push(E,C,T)}if(e!==0&&n){let x=Z.createDisc(e,i,s,!0,p,l,h,c);d.push(...x.vertices),g.push(...x.normals),u.push(...x.indices)}if(t!==0&&o){let x=Z.createDisc(t,0,s,!1,p+(n?1+2*s:0),l,h,c);d.push(...x.vertices),g.push(...x.normals),u.push(...x.indices)}return new Z({vertices:d,normals:g,indices:u})}static createCube(e=1,t=1,i=1,s=0,r=0,n=0){let o=.5*e+s,l=.5*t+r,h=.5*i+n;return new Z({vertices:[-o,-l,h,o,-l,-h,o,-l,h,-o,-l,h,-o,-l,-h,o,-l,-h,-o,l,h,o,l,h,o,l,-h,-o,l,h,o,l,-h,-o,l,-h,-o,-l,h,o,-l,h,-o,l,h,-o,l,h,o,-l,h,o,l,h,-o,-l,-h,-o,l,-h,o,-l,-h,-o,l,-h,o,l,-h,o,-l,-h,o,-l,h,o,-l,-h,o,l,h,o,l,h,o,-l,-h,o,l,-h,-o,-l,h,-o,l,h,-o,-l,-h,-o,l,h,-o,l,-h,-o,-l,-h]})}static createPlane(e=1,t=1,i=0,s=0,r=0){let n=.5*e,o=.5*t;return new Z({vertices:[-n+i,s,o+r,n+i,s,-o+r,n+i,s,o+r,-n+i,s,o+r,-n+i,s,-o+r,n+i,s,-o+r,-n+i,s,o+r,n+i,s,o+r,n+i,s,-o+r,-n+i,s,o+r,n+i,s,-o+r,-n+i,s,-o+r]})}static createArrow(e=0,t=2.1,i=-15){return new Z({vertices:[0,t,0,7,0,6,0,0,i,0,0,e,7,0,6,0,t,0,-7,0,6,0,0,e,0,t,0,-7,0,6,0,t,0,0,0,i,-7,0,6,0,0,i,0,0,e,0,0,e,0,0,i,7,0,6]})}static async readFileObj(e,t,i){const s=await new un().readFile(e,t);let r=s.materials;return s.geometries.map(n=>{let o=r[n.material]||{};return new Z({name:n.object,vertices:n.data.vertices,normals:n.data.normals,texCoords:n.data.texCoords,ambient:o.ambient,diffuse:o.diffuse,specular:o.specular,shininess:o.shininess,color:o.color,colorTextureSrc:i?`${i}/${o.colorTexture}`:o.colorTexture,normalTextureSrc:i?`${i}/${o.normalTexture}`:o.normalTexture,metallicRoughnessTextureSrc:i?`${i}/${o.metallicRoughnessTexture}`:o.metallicRoughnessTexture})})}static async loadObj(e){const t=await new un().load(e);let i=t.materials;return t.geometries.map(s=>{let r=i[s.material]||{};return new Z({name:s.object,vertices:s.data.vertices,normals:s.data.normals,texCoords:s.data.texCoords,ambient:r.ambient,diffuse:r.diffuse,specular:r.specular,shininess:r.shininess,color:r.color,colorTextureSrc:r.colorTexture,normalTextureSrc:r.normalTexture,metallicRoughnessTextureSrc:r.metallicRoughnessTexture})})}merge(e){const t=this._vertices.length/3;let i=this._vertices.length;this._vertices.length=i+e._vertices.length;for(let s=0;s<e._vertices.length;s++)this._vertices[i+s]=e._vertices[s];i=this._normals.length,this._normals.length=i+e._normals.length;for(let s=0;s<e._normals.length;s++)this._normals[i+s]=e._normals[s];i=this._texCoords.length,this._texCoords.length=i+e._texCoords.length;for(let s=0;s<e._texCoords.length;s++)this._texCoords[i+s]=e._texCoords[s];i=this._indices.length,this._indices.length=i+e._indices.length;for(let s=0;s<e._indices.length;s++)this._indices[i+s]=e._indices[s]+t;return this._numVertices=this._vertices.length/3,this}static merge(e,t){let i=new Z,s=t||e.length;for(let r=0;r<s;r++)i.merge(e[r]);return i}}const wl=new v(0,0,-1),_n=class ka{constructor(e){var t,i;this._handlerIndex=-1,this._tag=e.tag||"tag_"+ka.__counter__++,this._entity=null,this._position=je(e.position),this._rtcPositionHigh=new v,this._rtcPositionLow=new v,this._scale=je(e.scale,new v(1,1,1)),this._translate=je(e.translate,new v),this._localPosition=new v,this._color=st(e.color,(t=e.object3d)!=null&&t.color?new ee(...Array.from(e.object3d.color)):new ee(.15,.15,.15,1)),this._handler=null,this._handlerIndex=-1,this._tagData=null,this._tagDataIndex=-1;let s=e.object3d;e.object3d&&((i=e.object3d)==null?void 0:i.vertices.length)!==0||(s=new Z),e.objSrc&&(this.setObjectSrc(e.objSrc),this._objectSrc=e.objSrc),this._object3d=s,this._visibility=e.visibility==null||e.visibility,this._children=[],this._direction=new v,this._qFrame=new O,this._qRot=O.IDENTITY}get tag(){return this._tag}getPosition(){return this._position}get object3d(){return this._object3d}get vertices(){return this._object3d.vertices}get normals(){return this._object3d.normals}get texCoords(){return this._object3d.texCoords}get indices(){return this._object3d.indices}setOpacity(e){this._color.w=e,this.setColor(this._color.x,this._color.y,this._color.z,e)}getOpacity(){return this._color.w}setColor(e,t,i,s){this._color.x=e,this._color.y=t,this._color.z=i,s!=null&&(this._color.w=s),this._handler&&this._handler.setRgbaArr(this._tagData,this._tagDataIndex,this._color)}setColor4v(e){this._color.x=e.x,this._color.y=e.y,this._color.z=e.z,e.w!=null&&(this._color.w=e.w),this._handler&&this._handler.setRgbaArr(this._tagData,this._tagDataIndex,this._color)}setVisibility(e){this._visibility=e,this._handler&&this._handler.setVisibility(this._tagData,this._tagDataIndex,e)}getVisibility(){return this._visibility}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,this.updateRTCPosition(),this.updateRotation()}updateRTCPosition(){this._handler&&(this._handler.getRTCPosition(this._position,this._rtcPositionHigh,this._rtcPositionLow),this._handler.setRTCPositionArr(this._tagData,this._tagDataIndex,this._rtcPositionHigh,this._rtcPositionLow))}setPosition3v(e){this.setPosition(e.x,e.y,e.z)}setObject(e){this._object3d=e}setObjectSrc(e){this._objectSrc=e,this._handler&&this._handler.setObjectSrc(e,this.tag)}setColorHTML(e){this.setColor4v(it(e))}setScale(e){this._scale.x=this._scale.y=this._scale.z=e,this._handler&&this._handler.setScaleArr(this._tagData,this._tagDataIndex,this._scale)}setScale3v(e){this._scale.copy(e),this._handler&&this._handler.setScaleArr(this._tagData,this._tagDataIndex,e)}getScale(){return this._scale}setTranslate3v(e){this._translate.copy(e),this._handler&&this._handler.setTranslateArr(this._tagData,this._tagDataIndex,e)}getTranslate(){return this._translate.clone()}setLocalPosition3v(e){this._localPosition.copy(e),this._handler&&this._handler.setLocalPositionArr(this._tagData,this._tagDataIndex,e)}getLocalPosition(){return this._localPosition.clone()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._handler&&this._handler.setPickingColorArr(this._tagData,this._tagDataIndex,e)}setRotation(e){this._qRot.copy(e),this._qRot.mulVec3Res(wl,this._direction).normalize(),this.updateRotation()}getRotation(){return this._qRot}updateRotation(){this._handler&&this._handler.setQRotArr(this._tagData,this._tagDataIndex,this._qRot)}getDirection(){return this._direction.clone()}};_n.__counter__=0;let fn=_n;const ii={RIGHT:0,LEFT:1,CENTER:2},gn={left:ii.LEFT,right:ii.RIGHT,center:ii.CENTER};class pn extends ln{constructor(e={}){super(e),this._handler=null,this._text=e.text||"",this._face=Dr(e.face,"arial"),this._size=e.size||24,this._outline=e.outline!=null?e.outline:0,this._outlineColor=st(e.outlineColor,new ee(0,0,0,1)),this._align=e.align&&gn[e.align.trim().toLowerCase()]||ii.RIGHT,this._fontIndex=0,this._fontAtlas=null,this._isRTL=e.isRTL||!1,this._letterSpacing=e.letterSpacing||0}setText(e){this._text=e.toString(),this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,e,this._fontIndex,this._align,this._letterSpacing,this._isRTL)}setLetterSpacing(e){this._letterSpacing=e,this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,e,this._isRTL)}getLetterSpacing(){return this._letterSpacing}setRtl(e){this._isRTL=e,this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL)}getText(){return this._text}setAlign(e){this._align=gn[e.trim().toLowerCase()],this._isReady&&this._handler?this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL):this._lockId!==-1&&(this._lockId=-2)}getAlign(){return this._align}setFace(e){this._face=e.trim(),this.update()}getFace(){return this._face}setSize(e){e!==this._size&&(this._size=e,this._isReady&&this._handler?this._handler.setSizeArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getSize(){return this._size}setOutline(e){this._outline=e,this._isReady&&this._handler?this._handler.setOutlineArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2)}getOutline(){return this._outline}setOpacity(e){super.setOpacity(e),this.setOutlineOpacity(e)}setOutlineColor(e,t,i,s){s===this._outlineColor.w&&e===this._outlineColor.x&&t===this._outlineColor.y&&i===this._outlineColor.z||(this._outlineColor.x=e,this._outlineColor.y=t,this._outlineColor.z=i,this._outlineColor.w=s,this._isReady&&this._handler?this._handler.setOutlineColorArr(this._handlerIndex,this._outlineColor):this._lockId!==-1&&(this._lockId=-2))}setOutlineColor4v(e){this.setOutlineColor(e.x,e.y,e.z,e.w)}setOutlineColorHTML(e){this.setOutlineColor4v(it(e))}getOutlineColor(){return this._outlineColor}setOutlineOpacity(e){e!==this._outlineColor.w&&(this._outlineColor.w=e,this._isReady&&this._handler?this._handler.setOutlineColorArr(this._handlerIndex,this._outlineColor):this._lockId!==-1&&(this._lockId=-2))}getOutlineOpacity(){return this._outlineColor.w}async update(){if(this._fontAtlas){const e=await this._fontAtlas.getFontIndex(this._face);this._applyFontIndex(e)}}_applyFontIndex(e){this._fontIndex=e,this._isReady&&this._handler?(this._handler.setFontIndexArr(this._handlerIndex,this._fontIndex),this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL)):this._lockId!==-1&&(this._lockId=-2)}assignFontAtlas(e){this._fontAtlas||(this._fontAtlas=e),this.update()}serializeWorkerData(e){return this._handler?new Float32Array([e,this._handler._maxLetters,this.getVisibility()?1:0,this._positionHigh.x,this._positionHigh.y,this._positionHigh.z,this._positionLow.x,this._positionLow.y,this._positionLow.z,this._size,this._offset.x,this._offset.y,this._offset.z,this._color.x,this._color.y,this._color.z,this._color.w,this._rotation,this._alignedAxis.x,this._alignedAxis.y,this._alignedAxis.z,this._fontIndex,this._outline,this._outlineColor.x,this._outlineColor.y,this._outlineColor.z,this._outlineColor.w,this._entity._pickingColor.x,this._entity._pickingColor.y,this._entity._pickingColor.z]):null}}const mn=class Ia{constructor(e={}){this.__id=Ia.__counter__++,this.visibility=e.visibility==null||e.visibility,this.pointSize=e.pointSize||3,this.pickingScale=e.pickingScale||0,this._renderNode=null,this._entity=null,this._points=[],this._coordinatesData=[],this._colorData=[],this._pickingColorData=[],this._coordinatesBuffer=null,this._colorBuffer=null,this._pickingColorBuffer=null,this._handler=null,this._handlerIndex=-1,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this._createCoordinatesBuffer,this._buffersUpdateCallbacks[1]=this._createColorBuffer,this._buffersUpdateCallbacks[2]=this._createPickingColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length),e.points&&this.setPoints(e.points)}clear(){this._points.length=0,this._points=[],this._coordinatesData.length=0,this._coordinatesData=[],this._colorData.length=0,this._colorData=[],this._pickingColorData.length=0,this._pickingColorData=[],this._deleteBuffers()}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){this._renderNode=e,this._setPickingColors()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPoints(e){this.clear();for(let t=0;t<e.length;t++){let i=e[t],s=new v(i[0],i[1],i[2]),r=new ee(i[3],i[4],i[5],i[6]==null?255:i[6]);this._coordinatesData.push(s.x,s.y,s.z),this._colorData.push(r.x/255,r.y/255,r.z/255,r.w/255);let n={_entity:this._entity,_pickingColor:new v,_entityCollection:this._entity?this._entity._entityCollection:null,index:t,position:s,color:r,pointCloud:this,properties:i[7]||{}};this._points.push(n),this._renderNode&&this._renderNode.renderer&&(this._renderNode.renderer.assignPickingColor(n),this._pickingColorData.push(n._pickingColor.x/255,n._pickingColor.y/255,n._pickingColor.z/255,1))}this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}setPointPosition(e,t,i,s){this._changedBuffers[0]=!0}setPointColor(e,t,i,s,r){this._changedBuffers[1]=!0}addPoints(e){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}addPoint(e,t){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}getPoint(e){return this._points[e]}removePoint(e){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}insertPoint(e,t){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}draw(){if(this.visibility&&this._coordinatesData.length){this._update();let e=this._renderNode.renderer,t=e.handler.programs.pointCloud,i=t._program,s=e.handler.gl,r=i.attributes,n=i.uniforms;t.activate(),s.uniformMatrix4fv(n.projectionViewMatrix,!1,e.activeCamera.getProjectionViewMatrix()),s.uniform1f(n.opacity,this._handler._entityCollection._fadingOpacity),s.uniform1f(n.pointSize,this.pointSize),s.bindBuffer(s.ARRAY_BUFFER,this._coordinatesBuffer),s.vertexAttribPointer(r.coordinates,this._coordinatesBuffer.itemSize,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this._colorBuffer),s.vertexAttribPointer(r.colors,this._colorBuffer.itemSize,s.FLOAT,!1,0,0),s.drawArrays(s.POINTS,0,this._coordinatesBuffer.numItems)}}drawPicking(){if(this.visibility&&this._coordinatesData.length){let e=this._renderNode.renderer,t=e.handler.programs.pointCloud,i=t._program,s=e.handler.gl,r=i.attributes,n=i.uniforms;t.activate(),s.uniformMatrix4fv(n.projectionViewMatrix,!1,e.activeCamera.getProjectionViewMatrix()),s.uniform1f(n.opacity,this._handler._entityCollection._fadingOpacity),s.uniform1f(n.pointSize,this.pointSize+this.pickingScale),s.bindBuffer(s.ARRAY_BUFFER,this._coordinatesBuffer),s.vertexAttribPointer(r.coordinates,this._coordinatesBuffer.itemSize,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this._pickingColorBuffer),s.vertexAttribPointer(r.colors,this._pickingColorBuffer.itemSize,s.FLOAT,!1,0,0),s.drawArrays(s.POINTS,0,this._coordinatesBuffer.numItems)}}_update(){if(this._renderNode){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}_deleteBuffers(){if(this._renderNode){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._coordinatesBuffer),e.deleteBuffer(this._colorBuffer),e.deleteBuffer(this._pickingColorBuffer)}this._coordinatesBuffer=null,this._colorBuffer=null,this._pickingColorBuffer=null}_createCoordinatesBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._coordinatesBuffer),this._coordinatesBuffer=e.createArrayBuffer(new Float32Array(this._coordinatesData),3,this._coordinatesData.length/3)}_createColorBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._colorBuffer),this._colorBuffer=e.createArrayBuffer(new Float32Array(this._colorData),4,this._colorData.length/4)}_createPickingColorBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorBuffer=e.createArrayBuffer(new Float32Array(this._pickingColorData),4,this._pickingColorData.length/4)}_setPickingColors(){if(this._renderNode&&this._renderNode.renderer){for(let e=0;e<this._points.length;e++){let t=this._points[e];t._entity=this._entity,t._entityCollection=this._entity._entityCollection,this._renderNode.renderer.assignPickingColor(t),this._pickingColorData.push(t._pickingColor.x/255,t._pickingColor.y/255,t._pickingColor.z/255,1)}this._changedBuffers[2]=!0}}};mn.__counter__=0;let Cl=mn;const vn=class mr{constructor(e={}){this.__id=mr.__counter__++,this.__doubleToTwoFloats=v.doubleToTwoFloats,this.altitude=e.altitude||0,this.thickness=e.thickness||1.5,this._opacity=e.opacity!=null?e.opacity:1,this._defaultColor=_t(e.color||"#0000FF",e.opacity),this.visibility=e.visibility==null||e.visibility,this._closedLine=e.isClosed||!1,this._path3v=[],this._pathLengths=[],this._pathLonLat=[],this._pathLonLatMerc=[],this._pathColors=e.pathColors?vs(e.pathColors):[],this._extent=new G,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._ordersBuffer=null,this._indexesBuffer=null,this._colorsBuffer=null,this._pickingColor=[0,0,0],this._renderNode=null,this._entity=null,this._handler=null,this._handlerIndex=-1,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this._createVerticesBuffer,this._buffersUpdateCallbacks[1]=this._createIndexBuffer,this._buffersUpdateCallbacks[2]=this._createColorsBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length);let t=je(e.visibleSpherePosition).toArray(),i=e.visibleSphereRadius||0;this._visibleSphere=new Float32Array([...t,i]),e.pathLonLat?this.setPathLonLat(e.pathLonLat):e.path3v&&this.setPath3v(e.path3v),this._refresh()}__appendLineData3v(e,t,i,s,r,n,o,l,h,c,d,u,g,f){var p=0,_=new v,m=new v;g&&(g.southWest.set(180,90),g.northEast.set(-180,-90)),l.length>0?(p=l[l.length-5]+9,l.push(p,p)):l.push(0,0);for(let R=0,z=e.length;R<z;R++){var y=e[R],x=t[R];if(c[R]=[],u[R]=[],d[R]=[],y.length===0)continue;var w,b=p;if(s)(w=y[y.length-1])instanceof Array&&(w=new v(w[0],w[1],w[2]));else{var E=y[0],C=y[1]||E;E instanceof Array&&(E=new v(E[0],E[1],E[2])),C instanceof Array&&(C=new v(C[0],C[1],C[2])),w=new v(E.x+E.x-C.x,E.y+E.y-C.y,E.z+E.z-C.z)}let F=i;x&&x[0]&&(F=x[0]),this.__doubleToTwoFloats(w,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z);let P=F[0],D=F[1],I=F[2],k=F[3]!=null?F[3]:1;R>0&&f.push(P,D,I,k,P,D,I,k,P,D,I,k,P,D,I,k),o.push(1,-1,2,-2);for(let B=0,H=y.length;B<H;B++){var T=y[B];if(T instanceof Array&&(T=new v(T[0],T[1],T[2])),d[R].push(T),h){var L=h.cartesianToLonLat(T);c[R].push(L),u[R].push(L.forwardMercator()),L.lon<g.southWest.lon&&(g.southWest.lon=L.lon),L.lat<g.southWest.lat&&(g.southWest.lat=L.lat),L.lon>g.northEast.lon&&(g.northEast.lon=L.lon),L.lat>g.northEast.lat&&(g.northEast.lat=L.lat)}x&&x[B]&&(F=x[B]),P=F[0],D=F[1],I=F[2],k=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(T,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z),f.push(P,D,I,k,P,D,I,k,P,D,I,k,P,D,I,k),o.push(1,-1,2,-2),l.push(p++,p++,p++,p++)}var M;if(s)(M=y[0])instanceof Array&&(M=new v(M[0],M[1],M[2])),l.push(b,b+1,b+1,b+1);else{let B=y[y.length-1],H=y[y.length-2]||B;B instanceof Array&&(B=new v(B[0],B[1],B[2])),H instanceof Array&&(H=new v(H[0],H[1],H[2])),M=new v(B.x+B.x-H.x,B.y+B.y-H.y,B.z+B.z-H.z),l.push(p-1,p-1,p-1,p-1)}x&&x[y.length-1]&&(F=x[y.length-1]),P=F[0],D=F[1],I=F[2],k=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(M,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z),f.push(P,D,I,k,P,D,I,k,P,D,I,k,P,D,I,k),o.push(1,-1,2,-2),R<e.length-1&&e[R+1].length!==0&&(p+=8,l.push(p,p))}}__appendPoint3v(e,t,i,s,r,n,o,l,h,c,d,u,g,f){var p=new v,_=new v,m=c.length-4,y=c[m-1]+1;e.length===0?(e.push([]),i[0]||(i[0]=[])):i[e.length-1]||(i[e.length-1]=[]);var x=e[e.length-1],w=x.length;x.push(t);let b=s[0],E=s[1],C=s[2],T=s[3]!=null?s[3]:1,L=i[e.length-1];if(L[w]?(L[w][0]=b,L[w][1]=E,L[w][2]=C,L[w][3]=T):L.push(s),w===1){var M;if(r)(M=x[w-1])instanceof Array&&(M=new v(M[0],M[1],M[2]));else{let B=x[0],H=x[1]||B;B instanceof Array&&(B=new v(B[0],B[1],B[2])),H instanceof Array&&(H=new v(H[0],H[1],H[2])),M=new v(B.x+B.x-H.x,B.y+B.y-H.y,B.z+B.z-H.z)}this.__doubleToTwoFloats(M,p,_);let k=n.length-36;n[k]=p.x,n[k+1]=p.y,n[k+2]=p.z,n[k+3]=p.x,n[k+4]=p.y,n[k+5]=p.z,n[k+6]=p.x,n[k+7]=p.y,n[k+8]=p.z,n[k+9]=p.x,n[k+10]=p.y,n[k+11]=p.z,o[k]=_.x,o[k+1]=_.y,o[k+2]=_.z,o[k+3]=_.x,o[k+4]=_.y,o[k+5]=_.z,o[k+6]=_.x,o[k+7]=_.y,o[k+8]=_.z,o[k+9]=_.x,o[k+10]=_.y,o[k+11]=_.z}var R=y;if(d){u.length===0&&u.push([]),g.length===0&&g.push([]);var z=u[u.length-1],F=g[g.length-1];let k=d.cartesianToLonLat(t);z.push(k),F.push(k.forwardMercator()),k.lon<f.southWest.lon&&(f.southWest.lon=k.lon),k.lat<f.southWest.lat&&(f.southWest.lat=k.lat),k.lon>f.northEast.lon&&(f.northEast.lon=k.lon),k.lat>f.northEast.lat&&(f.northEast.lat=k.lat)}this.__doubleToTwoFloats(t,p,_);let P=n.length-12;n[P]=p.x,n[P+1]=p.y,n[P+2]=p.z,n[P+3]=p.x,n[P+4]=p.y,n[P+5]=p.z,n[P+6]=p.x,n[P+7]=p.y,n[P+8]=p.z,n[P+9]=p.x,n[P+10]=p.y,n[P+11]=p.z,o[P]=_.x,o[P+1]=_.y,o[P+2]=_.z,o[P+3]=_.x,o[P+4]=_.y,o[P+5]=_.z,o[P+6]=_.x,o[P+7]=_.y,o[P+8]=_.z,o[P+9]=_.x,o[P+10]=_.y,o[P+11]=_.z;let D=l.length-16;var I;if(l[D]=b,l[D+1]=E,l[D+2]=C,l[D+3]=T,l[D+4]=b,l[D+5]=E,l[D+6]=C,l[D+7]=T,l[D+8]=b,l[D+9]=E,l[D+10]=C,l[D+11]=T,l[D+12]=b,l[D+13]=E,l[D+14]=C,l[D+15]=T,c[m]=y++,c[m+1]=y++,c[m+2]=y++,c[m+3]=y++,r)I=x[0],c.push(R,R+1,R+1,R+1);else{let k=x[x.length-1],B=x[x.length-2]||k;I=new v(k.x+k.x-B.x,k.y+k.y-B.y,k.z+k.z-B.z),c.push(y-1,y-1,y-1,y-1)}this.__doubleToTwoFloats(I,p,_),n.push(p.x,p.y,p.z,p.x,p.y,p.z,p.x,p.y,p.z,p.x,p.y,p.z),o.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),l.push(b,E,C,T,b,E,C,T,b,E,C,T,b,E,C,T),h.push(1,-1,2,-2)}static setPathColors(e,t,i,s){for(let l=0,h=e.length;l<h;l++){var r=e[l],n=t[l];if(r.length===0)continue;let c=i;n&&n[0]&&(c=n[0]);let d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1;l>0&&s.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f);for(let p=0,_=r.length;p<_;p++){var o=r[p];o instanceof Array&&(o=new A(o[0],o[1],o[2])),n&&n[p]&&(c=n[p]),d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1,s.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f)}n&&n[r.length-1]&&(c=n[r.length-1]),d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1,s.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f)}}__appendLineDataLonLat(e,t,i,s,r,n,o,l,h,c,d,u,g,f){var p=0,_=new v,m=new v;g&&(g.southWest.set(180,90),g.northEast.set(-180,-90)),l.length>0?(p=l[l.length-5]+9,l.push(p)):l.push(0);for(let L=0,M=e.length;L<M;L++){var y=e[L],x=t[L];if(c[L]=[],u[L]=[],d[L]=[],y.length===0)continue;var w,b=p;if(s){let I=y[y.length-1];w=I instanceof Array?h.lonLatToCartesian(new A(I[0],I[1],I[2])):h.lonLatToCartesian(I)}else{let I,k,B=y[0];I=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),B=y[1],B||(B=y[0]),k=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),w=new v(I.x+I.x-k.x,I.y+I.y-k.y,I.z+I.z-k.z)}let R=i;x&&x[0]&&(R=x[0]),this.__doubleToTwoFloats(w,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z);let z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1;L>0&&f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2);for(let I=0,k=y.length;I<k;I++){var E=y[I];E instanceof Array&&(E=new A(E[0],E[1],E[2])),x&&x[I]&&(R=x[I]),z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1;var C=h.lonLatToCartesian(E);c[L].push(C),d[L].push(E),u[L].push(E.forwardMercator()),this.__doubleToTwoFloats(C,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z),f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2),l.push(p++,p++,p++,p++),E.lon<g.southWest.lon&&(g.southWest.lon=E.lon),E.lat<g.southWest.lat&&(g.southWest.lat=E.lat),E.lon>g.northEast.lon&&(g.northEast.lon=E.lon),E.lat>g.northEast.lat&&(g.northEast.lat=E.lat)}var T;if(s){let I=y[0];T=I instanceof Array?h.lonLatToCartesian(new A(I[0],I[1],I[2])):h.lonLatToCartesian(I),l.push(b,b+1,b+1,b+1)}else{let I,k,B=y[y.length-1];I=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),B=y[y.length-2],B||(B=y[0]),k=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),T=new v(I.x+I.x-k.x,I.y+I.y-k.y,I.z+I.z-k.z),l.push(p-1,p-1,p-1,p-1)}x&&x[y.length-1]&&(R=x[y.length-1]),z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1,this.__doubleToTwoFloats(T,_,m),r.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z,m.x,m.y,m.z),f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2),L<e.length-1&&e[L+1].length!==0&&(p+=8,l.push(p,p))}}_setEqualPath3v(e){var t=this._extent;t.southWest.set(180,90),t.northEast.set(-180,-90);var i=new v,s=new v,r=this._verticesHigh,n=this._verticesLow,o=this._pathLonLat,l=this._pathLonLatMerc,h=0,c=this._renderNode.ellipsoid;for(let y=0;y<e.length;y++){var d,u,g=e[y];d=this._closedLine?g[g.length-1]:new v(g[0].x+g[0].x-g[1].x,g[0].y+g[0].y-g[1].y,g[0].z+g[0].z-g[1].z),this.__doubleToTwoFloats(d,i,s),r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z;for(let x=0;x<g.length;x++){var f=g[x],p=this._path3v[y][x];if(p.x=f.x,p.y=f.y,p.z=f.z,c){var _=c.cartesianToLonLat(f);this._pathLonLat[y][x]=_,o[y][x]=_,l[y][x]=_.forwardMercator(),_.lon<t.southWest.lon&&(t.southWest.lon=_.lon),_.lat<t.southWest.lat&&(t.southWest.lat=_.lat),_.lon>t.northEast.lon&&(t.northEast.lon=_.lon),_.lat>t.northEast.lat&&(t.northEast.lat=_.lat)}this.__doubleToTwoFloats(f,i,s),r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z}if(this._closedLine)u=g[0];else{var m=g.length-1;u=new v(g[m].x+g[m].x-g[m-1].x,g[m].y+g[m].y-g[m-1].y,g[m].z+g[m].z-g[m-1].z)}this.__doubleToTwoFloats(u,i,s),r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z,r[h]=i.x,n[h++]=s.x,r[h]=i.y,n[h++]=s.y,r[h]=i.z,n[h++]=s.z}}_setEqualPathLonLat(e){var t=this._extent;t.southWest.set(180,90),t.northEast.set(-180,-90);var i=new v,s=new v,r=this._verticesHigh,n=this._verticesLow,o=this._pathLonLat,l=this._pathLonLatMerc,h=this._path3v,c=0,d=this._renderNode.ellipsoid;for(let m=0;m<e.length;m++){var u,g,f=e[m];if(this._closedLine)u=d.lonLatToCartesian(f[f.length-1]);else{let y=d.lonLatToCartesian(f[0]),x=d.lonLatToCartesian(f[1]);u=new v(y.x+y.x-x.x,y.y+y.y-x.y,y.z+y.z-x.z)}this.__doubleToTwoFloats(u,i,s),r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z;for(let y=0;y<f.length;y++){var p=f[y],_=d.lonLatToCartesian(p);h[m][y]=_,l[m][y]=p.forwardMercator(),o[m][y]=p,this.__doubleToTwoFloats(_,i,s),r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,p.lon<t.southWest.lon&&(t.southWest.lon=p.lon),p.lat<t.southWest.lat&&(t.southWest.lat=p.lat),p.lon>t.northEast.lon&&(t.northEast.lon=p.lon),p.lat>t.northEast.lat&&(t.northEast.lat=p.lat)}if(this._closedLine)g=d.lonLatToCartesian(f[0]);else{let y=d.lonLatToCartesian(f[f.length-1]),x=d.lonLatToCartesian(f[f.length-2]);g=new v(y.x+y.x-x.x,y.y+y.y-x.y,y.z+y.z-x.z)}this.__doubleToTwoFloats(g,i,s),r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z,r[c]=i.x,n[c++]=s.x,r[c]=i.y,n[c++]=s.y,r[c]=i.z,n[c++]=s.z}}setPointLonLat(e,t,i){if(this._renderNode&&this._renderNode.ellipsoid){let l=this._pathLonLat,h=this._pathLonLatMerc;l[i][t]=e,h[i][t]=e.forwardMercator();var s=this._extent;s.southWest.set(180,90),s.northEast.set(-180,-90);for(let c=0;c<l.length;c++){var r=l[c];for(let d=0;d<r.length;d++){var n=r[d].lon,o=r[d].lat;n>s.northEast.lon&&(s.northEast.lon=n),o>s.northEast.lat&&(s.northEast.lat=o),n<s.southWest.lon&&(s.southWest.lon=n),o<s.southWest.lat&&(s.southWest.lat=o)}}this.setPoint3v(this._renderNode.ellipsoid.lonLatToCartesian(e),t,i,!0)}else{let l=this._pathLonLat[i];l[t].lon=e.lon,l[t].lat=e.lat,l[t].height=e.height}}setPoint3v(e,t=0,i=0,s=!1){if(this._renderNode){var r,n=new v,o=new v,l=this._verticesHigh,h=this._verticesLow,c=this._pathLonLat,d=this._pathLonLatMerc,u=0;r=12*this._pathLengths[i]+24*i;let b=this._path3v[i];b[t].x=e.x,b[t].y=e.y,b[t].z=e.z;let E=this._closedLine||b.length===1;var g;if((t===0||t===1)&&(g=E?b[b.length-1]:new v(b[0].x+b[0].x-b[1].x,b[0].y+b[0].y-b[1].y,b[0].z+b[0].z-b[1].z),u=r,this.__doubleToTwoFloats(g,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z),!s&&this._renderNode.ellipsoid){var f=this._renderNode.ellipsoid.cartesianToLonLat(e);c[i][t]=f,d[i][t]=f.forwardMercator();var p=this._extent;p.southWest.set(180,90),p.northEast.set(-180,-90);for(let C=0;C<c.length;C++){var _=c[C];for(let T=0;T<_.length;T++){var m=_[T].lon,y=_[T].lat;m>p.northEast.lon&&(p.northEast.lon=m),y>p.northEast.lat&&(p.northEast.lat=y),m<p.southWest.lon&&(p.southWest.lon=m),y<p.southWest.lat&&(p.southWest.lat=y)}}}if(u=r+12*t+12,this.__doubleToTwoFloats(e,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z,t===b.length-1||t===b.length-2){var x;if(E)x=b[0];else{var w=b.length-1;x=new v(b[w].x+b[w].x-b[w-1].x,b[w].y+b[w].y-b[w-1].y,b[w].z+b[w].z-b[w-1].z)}u=r+12*b.length+12,this.__doubleToTwoFloats(x,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z}this._changedBuffers[0]=!0}else{let b=this._path3v[i];b[t].x=e.x,b[t].y=e.y,b[t].z=e.z}}_resizePathLengths(e=0){this._pathLengths[0]=0;for(let t=e+1,i=this._path3v.length;t<=i;t++)this._pathLengths[t]=this._pathLengths[t-1]+this._path3v[t-1].length}removeSegment(e){this._path3v.splice(e,1),this.setPath3v([].concat(this._path3v))}removePoint(e,t=0){this._path3v[t].splice(e,1),this._path3v[t].length===0&&this._path3v.splice(t,1),this.setPath3v([].concat(this._path3v))}insertPoint3v(e,t=0,i,s=0){let r=[].concat(this._path3v),n=r[s];if(n){let o=[].concat(this._pathColors);if(n.splice(t,0,e),i){let l=o[s];l||(l=new Array(n.length)),l.splice(t,0,i)}this.setPath3v(r,o)}else this.addPoint3v(e,s)}appendPoint3v(e,t,i){this._path3v.length!==0&&this._renderNode?(this._verticesHigh=zt(this._verticesHigh),this._verticesLow=zt(this._verticesLow),this._colors=zt(this._colors),this._orders=zt(this._orders),this._indexes=zt(this._indexes),this.__appendPoint3v(this._path3v,e,this._pathColors,t||this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._colors,this._orders,this._indexes,i?null:this._renderNode.ellipsoid,this._pathLonLat,this._pathLonLatMerc,this._extent),this._pathLengths[this._path3v.length]+=1,this._changedBuffers[0]=!0,this._changedBuffers[2]=!0,this._changedBuffers[1]=!0):(this._pathColors.push([t||this._defaultColor]),this.addPoint3v(e))}addPoint3v(e,t=0){t>=this._path3v.length&&this._path3v.push([]),this._path3v[t].push(e),this.setPath3v([].concat(this._path3v))}addPointLonLat(e,t=0){t>=this._pathLonLat.length&&this._pathLonLat.push([]),this._pathLonLat[t].push(e),this.setPathLonLat([].concat(this._pathLonLat))}clear(){this._clearData()}setPointColor(e,t=0,i=0){if(this._renderNode&&t<this._path3v[i].length){let s=this._pathColors[i];if(!s){if(!(this._path3v[i]&&t<this._path3v[i].length))return;this._pathColors[i]=new Array(this._path3v[i].length)}s[t]?(s[t][0]=e[0],s[t][1]=e[1],s[t][2]=e[2],s[t][3]=e[3]||1):s[t]=[e[0],e[1],e[2],e[3]||1];let r=this._colors,n=16*t+16*this._pathLengths[i]+32*i;r[n]=r[n+4]=r[n+8]=r[n+12]=e[0],r[n+1]=r[n+5]=r[n+9]=r[n+13]=e[1],r[n+2]=r[n+6]=r[n+10]=r[n+14]=e[2],r[n+3]=r[n+7]=r[n+11]=r[n+15]=e[3]||1,this._changedBuffers[2]=!0}else this._pathColors[i][t]=e}setOpacity(e){this._opacity=e}getOpacity(){return this._opacity}setAltitude(e){this.altitude=e}setThickness(e){this.thickness=e}getThickness(){return this.thickness}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){e&&(this._renderNode=e,this._pathLonLat.length?this._createDataLonLat([].concat(this._pathLonLat)):this._createData3v([].concat(this._path3v)),this._refresh(),e.renderer&&e.renderer.isInitialized()&&this._update())}_clearData(){this._verticesHigh=null,this._verticesLow=null,this._orders=null,this._indexes=null,this._colors=null,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._path3v.length=0,this._pathLonLat.length=0,this._pathLonLatMerc.length=0,this._path3v=[],this._pathLonLat=[],this._pathLonLatMerc=[]}_createData3v(e){this._clearData(),this.__appendLineData3v(e,this._pathColors,this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._orders,this._indexes,this._renderNode.ellipsoid,this._pathLonLat,this._path3v,this._pathLonLatMerc,this._extent,this._colors),this._resizePathLengths(0)}_createDataLonLat(e){this._clearData(),this.__appendLineDataLonLat(e,this._pathColors,this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._orders,this._indexes,this._renderNode.ellipsoid,this._path3v,this._pathLonLat,this._pathLonLatMerc,this._extent,this._colors),this._resizePathLengths(0)}remove(){this._entity=null,this._pathColors.length=0,this._pathColors=[],this._verticesHigh=null,this._verticesLow=null,this._orders=null,this._indexes=null,this._colors=null,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._deleteBuffers(),this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._pickingColor[0]=e.x/255,this._pickingColor[1]=e.y/255,this._pickingColor[2]=e.z/255}getExtent(){return this._extent.clone()}getPath3v(){return this._path3v}getPathLonLat(){return this._pathLonLat}getPathColors(){return this._pathColors}setPathColors(e){e&&(this._colors=[],this._pathColors=[].concat(e),mr.setPathColors(this._pathLonLat,e,this._defaultColor,this._colors),this._changedBuffers[2]=!0)}setColorHTML(e){this._defaultColor=_t(e);let t=it(e),i=this._pathColors;for(let r=0,n=i.length;r<n;r++){let o=i[r];for(let l=0,h=o.length;l<h;l++)o[l][0]=t.x,o[l][1]=t.y,o[l][2]=t.z,o[l][3]=t.w}let s=this._colors;for(let r=0,n=s.length;r<n;r+=4)s[r]=t.x,s[r+1]=t.y,s[r+2]=t.z,s[r+3]=t.w;this._changedBuffers[2]=!0}setPathLonLatFast(e,t){this.setPathLonLat(e,t,!0)}setPath3vFast(e,t){this.setPath3v(e,t,!0)}setPathLonLat(e,t,i=!1){t&&(this._pathColors=[].concat(t)),this._renderNode&&this._renderNode.ellipsoid?i?(this._setEqualPathLonLat(e),this._changedBuffers[0]=!0,this._changedBuffers[2]=!0):(this._createDataLonLat(e),this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0):this._pathLonLat=[].concat(e)}getSize(e=0){return this._path3v[e].length}setPath3v(e,t,i=!1){t&&(this._pathColors=[].concat(t)),this._renderNode?i?(this._setEqualPath3v(e),this._changedBuffers[0]=!0,this._changedBuffers[2]=!0):(this._createData3v(e),this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0):this._path3v=[].concat(e)}draw(){if(this.visibility&&this._path3v.length){this._update();let e=this._renderNode.renderer,t=e.handler.programs.polyline_screen,i=t._program,s=e.handler.gl,r=i.attributes,n=i.uniforms,o=this._handler._entityCollection;t.activate(),s.disable(s.CULL_FACE),s.uniform1f(n.depthOffset,o.polygonOffsetUnits),s.uniformMatrix4fv(n.proj,!1,e.activeCamera.getProjectionMatrix()),s.uniformMatrix4fv(n.view,!1,e.activeCamera.getViewMatrix()),s.uniform3fv(n.rtcEyePositionHigh,this._handler._rtcEyePositionHigh),s.uniform3fv(n.rtcEyePositionLow,this._handler._rtcEyePositionLow),s.uniform4fv(n.visibleSphere,this._visibleSphere),s.uniform2fv(n.viewport,[e.handler.canvas.width,e.handler.canvas.height]),s.uniform1f(n.thickness,.5*this.thickness),s.uniform1f(n.opacity,this._opacity*o._fadingOpacity),s.bindBuffer(s.ARRAY_BUFFER,this._colorsBuffer),s.vertexAttribPointer(r.color,this._colorsBuffer.itemSize,s.FLOAT,!1,0,0);let l=this._verticesHighBuffer;s.bindBuffer(s.ARRAY_BUFFER,l),s.vertexAttribPointer(r.prevHigh,l.itemSize,s.FLOAT,!1,12,0),s.vertexAttribPointer(r.currentHigh,l.itemSize,s.FLOAT,!1,12,48),s.vertexAttribPointer(r.nextHigh,l.itemSize,s.FLOAT,!1,12,96),l=this._verticesLowBuffer,s.bindBuffer(s.ARRAY_BUFFER,l),s.vertexAttribPointer(r.prevLow,l.itemSize,s.FLOAT,!1,12,0),s.vertexAttribPointer(r.currentLow,l.itemSize,s.FLOAT,!1,12,48),s.vertexAttribPointer(r.nextLow,l.itemSize,s.FLOAT,!1,12,96),s.bindBuffer(s.ARRAY_BUFFER,this._ordersBuffer),s.vertexAttribPointer(r.order,this._ordersBuffer.itemSize,s.FLOAT,!1,4,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this._indexesBuffer),s.drawElements(s.TRIANGLE_STRIP,this._indexesBuffer.numItems,s.UNSIGNED_INT,0),s.enable(s.CULL_FACE)}}drawPicking(){if(this.visibility&&this._path3v.length){let e=this._renderNode.renderer,t=e.handler.programs.polyline_picking,i=t._program,s=e.handler.gl,r=i.attributes,n=i.uniforms,o=this._handler._entityCollection;t.activate(),s.disable(s.CULL_FACE),s.uniform1f(n.depthOffset,o.polygonOffsetUnits),s.uniformMatrix4fv(n.proj,!1,e.activeCamera.getProjectionMatrix()),s.uniformMatrix4fv(n.view,!1,e.activeCamera.getViewMatrix()),s.uniform4fv(n.color,[this._pickingColor[0],this._pickingColor[1],this._pickingColor[2],1]),s.uniform3fv(n.rtcEyePositionHigh,this._handler._rtcEyePositionHigh),s.uniform3fv(n.rtcEyePositionLow,this._handler._rtcEyePositionLow),s.uniform4fv(n.visibleSphere,this._visibleSphere),s.uniform2fv(n.viewport,[e.handler.canvas.width,e.handler.canvas.height]),s.uniform1f(n.thickness,.5*this.thickness*o.pickingScale[0]);let l=this._verticesHighBuffer;s.bindBuffer(s.ARRAY_BUFFER,l),s.vertexAttribPointer(r.prevHigh,l.itemSize,s.FLOAT,!1,12,0),s.vertexAttribPointer(r.currentHigh,l.itemSize,s.FLOAT,!1,12,48),s.vertexAttribPointer(r.nextHigh,l.itemSize,s.FLOAT,!1,12,96),l=this._verticesLowBuffer,s.bindBuffer(s.ARRAY_BUFFER,l),s.vertexAttribPointer(r.prevLow,l.itemSize,s.FLOAT,!1,12,0),s.vertexAttribPointer(r.currentLow,l.itemSize,s.FLOAT,!1,12,48),s.vertexAttribPointer(r.nextLow,l.itemSize,s.FLOAT,!1,12,96),s.bindBuffer(s.ARRAY_BUFFER,this._ordersBuffer),s.vertexAttribPointer(r.order,this._ordersBuffer.itemSize,s.FLOAT,!1,4,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this._indexesBuffer),s.drawElements(s.TRIANGLE_STRIP,this._indexesBuffer.numItems,s.UNSIGNED_INT,0),s.enable(s.CULL_FACE)}}_refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_update(){if(this._renderNode){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}_deleteBuffers(){if(this._renderNode){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer),e.deleteBuffer(this._ordersBuffer),e.deleteBuffer(this._indexesBuffer),e.deleteBuffer(this._colorsBuffer),this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._ordersBuffer=null,this._indexesBuffer=null,this._colorsBuffer=null}}_createVerticesBuffer(){let e=this._renderNode.renderer.handler,t=this._verticesHigh.length/3;this._verticesHighBuffer&&this._verticesHighBuffer.numItems===t||(e.gl.deleteBuffer(this._verticesHighBuffer),e.gl.deleteBuffer(this._verticesLowBuffer),this._verticesHighBuffer=e.createStreamArrayBuffer(3,t),this._verticesLowBuffer=e.createStreamArrayBuffer(3,t)),this._verticesHigh=se(this._verticesHigh),this._verticesLow=se(this._verticesLow),e.setStreamArrayBuffer(this._verticesHighBuffer,this._verticesHigh),e.setStreamArrayBuffer(this._verticesLowBuffer,this._verticesLow)}_createIndexBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._ordersBuffer),e.gl.deleteBuffer(this._indexesBuffer),this._orders=se(this._orders),this._ordersBuffer=e.createArrayBuffer(this._orders,1,this._orders.length/2),this._indexes=se(this._indexes,Uint32Array),this._indexesBuffer=e.createElementArrayBuffer(this._indexes,1,this._indexes.length)}_createColorsBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._colorsBuffer),this._colors=se(this._colors),this._colorsBuffer=e.createArrayBuffer(new Float32Array(this._colors),4,this._colors.length/4)}setVisibleSphere(e,t){this._handler&&(this._visibleSphere[0]=e.x-this._handler._relativeCenter.x,this._visibleSphere[1]=e.y-this._handler._relativeCenter.y,this._visibleSphere[2]=e.z-this._handler._relativeCenter.z),this._visibleSphere[3]=t}updateRTCPosition(){this._handler&&this._renderNode&&(this._visibleSphere[0]=this._visibleSphere[0]-this._handler._relativeCenter.x,this._visibleSphere[1]=this._visibleSphere[1]-this._handler._relativeCenter.y,this._visibleSphere[2]=this._visibleSphere[2]-this._handler._relativeCenter.z,this._setEqualPath3v(this._path3v)),this._changedBuffers[0]=!0}};vn.__counter__=0;let yn=vn;const xn=class za{constructor(e={}){this.__id=za.__counter__++,this._thickness=e.thickness||2,this._startPosition=je(e.startPosition),this._startPositionHigh=new v,this._startPositionLow=new v,v.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._endPosition=je(e.endPosition),this._endPositionHigh=new v,this._endPositionLow=new v,v.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._startColor=st(e.startColor),this._endColor=st(e.endColor),this._visibility=e.visibility==null||e.visibility,this._entity=null,this._handler=null,this._handlerIndex=-1}setStartPosition(e,t,i){this._startPosition.x=e,this._startPosition.y=t,this._startPosition.z=i,v.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._handler&&this._handler.setStartPositionArr(this._handlerIndex,this._startPositionHigh,this._startPositionLow)}getLength(){return this._startPosition.distance(this._endPosition)}setStartPosition3v(e){this._startPosition.x=e.x,this._startPosition.y=e.y,this._startPosition.z=e.z,v.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._handler&&this._handler.setStartPositionArr(this._handlerIndex,this._startPositionHigh,this._startPositionLow)}setEndPosition(e,t,i){this._endPosition.x=e,this._endPosition.y=t,this._endPosition.z=i,v.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._handler&&this._handler.setEndPositionArr(this._handlerIndex,this._endPositionHigh,this._endPositionLow)}setEndPosition3v(e){this._endPosition.x=e.x,this._endPosition.y=e.y,this._endPosition.z=e.z,v.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._handler&&this._handler.setEndPositionArr(this._handlerIndex,this._endPositionHigh,this._endPositionLow)}setThickness(e){this._thickness=e,this._handler&&this._handler.setThicknessArr(this._handlerIndex,e)}setColors4v(e,t){e&&(this._startColor.x=e.x,this._startColor.y=e.y,this._startColor.z=e.z,this._startColor.w=e.w),t&&(this._endColor.x=t.x,this._endColor.y=t.y,this._endColor.z=t.z,this._endColor.w=t.w),this._handler&&this._handler.setRgbaArr(this._handlerIndex,this._startColor,this._endColor)}setColorsHTML(e,t){e&&(this._startColor=it(e)),t&&(this._endColor=it(t)),this._handler&&this._handler.setRgbaArr(this._handlerIndex,this._startColor,this._endColor)}getStartPosition(){return this._startPosition}getEndPosition(){return this._endPosition}setVisibility(e){this._visibility=e,this._handler&&this._handler.setVisibility(this._handlerIndex,e)}getVisibility(){return this._visibility}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._handler&&this._handler.setPickingColorArr(this._handlerIndex,e)}};xn.__counter__=0;let Tl=xn,pe=new v,me=new v;const bn=class Da{constructor(e={}){if(this.__id=Da.__counter__++,this.visibility=e.visibility==null||e.visibility,this.color=new Float32Array([1,1,1,.5]),e.color){let t=st(e.color);this.setColor(t.x,t.y,t.z,t.w)}e.opacity&&this.setOpacity(e.opacity),this._renderNode=null,this._entity=null,this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._indexBuffer=null,this._verticesHigh=[],this._verticesLow=[],this._indexes=[],this._path=[],this._pickingColor=new Float32Array(4),this._gridSize=1,this._handler=null,this._handlerIndex=-1,e.path&&this.setPath(e.path)}setPickingColor3v(e){this._pickingColor[0]=e.x/255,this._pickingColor[1]=e.y/255,this._pickingColor[2]=e.z/255,this._pickingColor[3]=1}clear(){this._path.length=0,this._path=[],this._verticesHigh.length=0,this._verticesHigh=[],this._verticesLow.length=0,this._verticesLow=[],this._indexes.length=0,this._indexes=[],this._deleteBuffers()}setColor4v(e){this.setColor(e.x,e.y,e.z,e.w)}setColorHTML(e){this.setColor4v(it(e))}setColor(e,t,i,s){s=s||this.color[3],this.color[0]=e,this.color[1]=t,this.color[2]=i,this.color[3]=s}setOpacity(e){this.color[3]=e||0}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){this._renderNode=e,this._createBuffers()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}draw(){if(this.visibility&&this._verticesHigh.length){let e=this._renderNode.renderer,t=e.handler.gl,i=e.handler.programs.strip,s=i._program,r=s.attributes,n=s.uniforms;i.activate(),t.disable(t.CULL_FACE),t.uniformMatrix4fv(n.viewMatrix,!1,e.activeCamera.getViewMatrix()),t.uniformMatrix4fv(n.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),t.uniform3fv(n.eyePositionHigh,e.activeCamera.eyeHigh),t.uniform3fv(n.eyePositionLow,e.activeCamera.eyeLow),t.uniform4fv(n.uColor,this.color),t.uniform1f(n.uOpacity,this._entity._entityCollection._fadingOpacity),t.bindBuffer(t.ARRAY_BUFFER,this._verticesHighBuffer),t.vertexAttribPointer(r.aVertexPositionHigh,this._verticesHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._verticesLowBuffer),t.vertexAttribPointer(r.aVertexPositionLow,this._verticesLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.drawElements(e.handler.gl.TRIANGLE_STRIP,this._indexBuffer.numItems,t.UNSIGNED_INT,0),t.enable(t.CULL_FACE)}}drawPicking(){if(this.visibility&&this._verticesHigh.length){let e=this._renderNode.renderer,t=e.handler.gl,i=e.handler.programs.strip,s=i._program,r=s.attributes,n=s.uniforms;i.activate(),t.disable(t.CULL_FACE),t.uniformMatrix4fv(n.viewMatrix,!1,e.activeCamera.getViewMatrix()),t.uniformMatrix4fv(n.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),t.uniform3fv(n.eyePositionHigh,e.activeCamera.eyeHigh),t.uniform3fv(n.eyePositionLow,e.activeCamera.eyeLow),t.uniform1f(n.uOpacity,this._entity._entityCollection._fadingOpacity!=0?1:0),t.uniform4fv(n.uColor,this._pickingColor),t.bindBuffer(t.ARRAY_BUFFER,this._verticesHighBuffer),t.vertexAttribPointer(r.aVertexPositionHigh,this._verticesHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._verticesLowBuffer),t.vertexAttribPointer(r.aVertexPositionLow,this._verticesLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.drawElements(e.handler.gl.TRIANGLE_STRIP,this._indexBuffer.numItems,t.UNSIGNED_INT,0),t.enable(t.CULL_FACE)}}_deleteBuffers(){if(this._renderNode&&this._renderNode.renderer){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._indexBuffer),e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer)}this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._indexBuffer=null}_createBuffers(){if(this._renderNode&&this._renderNode.renderer&&this._renderNode.renderer.isInitialized()){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._indexBuffer),e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer),this._verticesHighBuffer=this._renderNode.renderer.handler.createArrayBuffer(new Float32Array(this._verticesHigh),3,this._verticesHigh.length/3),this._verticesLowBuffer=this._renderNode.renderer.handler.createArrayBuffer(new Float32Array(this._verticesLow),3,this._verticesLow.length/3),this._indexBuffer=this._renderNode.renderer.handler.createElementArrayBuffer(new Uint32Array(this._indexes),1,this._indexes.length)}}addEdge3v(e,t){let i=this._path.length;if(i===0)this._path.push([e.clone(),t.clone()]);else{let s=this._path[i-1][0],r=this._path[i-1][1];this._path.push([e.clone(),t.clone()]);let n=this._verticesHigh,o=this._verticesLow,l=this._gridSize,h=l+1,c=new v,d=this._verticesHigh.length/3,u=d,g=Math.abs(s.sub(r).normal().dot(e.sub(s).normal()));for(let f=0;f<h;f++){let p=f/l,_=s.lerp(e,p),m=r.lerp(t,p);for(let y=0;y<h;y++){let x=y/l,w=s.lerp(r,x),b=e.lerp(t,x);g!==1?new Ze(_,m).intersects(new Ze(w,b),c):c=b,u=d+f*h+y,v.doubleToTwoFloats(c,pe,me);let E=3*u;n[E]=pe.x,n[E+1]=pe.y,n[E+2]=pe.z,o[E]=me.x,o[E+1]=me.y,o[E+2]=me.z,f<l&&this._indexes.push(u,u+h)}f<l&&this._indexes.push(u+h,u+1)}this._createBuffers()}}setEdge3v(e,t,i){if(i!==this._path.length)if(this._path[i]){if(this._path[i][0]=e,this._path[i][1]=t,this._path.length>1){let s=this._gridSize,r=s+1,n=r*r,o=new v,l=this._verticesHigh,h=this._verticesLow;if(i===this._path.length-1){let c=this._path[i-1][0],d=this._path[i-1][1],u=this._verticesHigh.length/3-n,g=u,f=Math.abs(c.sub(d).normal().dot(e.sub(c).normal()));for(let p=0;p<r;p++){let _=p/s,m=c.lerp(e,_),y=d.lerp(t,_);for(let x=0;x<r;x++){let w=x/s,b=c.lerp(d,w),E=e.lerp(t,w);f!==1?new Ze(m,y).intersects(new Ze(b,E),o):o=E,g=u+p*r+x,v.doubleToTwoFloats(o,pe,me);let C=3*g;l[C]=pe.x,l[C+1]=pe.y,l[C+2]=pe.z,h[C]=me.x,h[C+1]=me.y,h[C+2]=me.z}}}else if(i===0){let c=0,d=e,u=t;e=this._path[1][0],t=this._path[1][1];for(let g=0;g<r;g++){let f=g/s,p=d.lerp(e,f),_=u.lerp(t,f);for(let m=0;m<r;m++){let y=m/s,x=d.lerp(u,y),w=e.lerp(t,y);new Ze(p,_).intersects(new Ze(x,w),o),c=g*r+m,v.doubleToTwoFloats(o,pe,me);let b=3*c;l[b]=pe.x,l[b+1]=pe.y,l[b+2]=pe.z,h[b]=me.x,h[b+1]=me.y,h[b+2]=me.z}}}else if(i>0&&i<this._path.length){let c=this._path[i-1][0],d=this._path[i-1][1],u=this._path[i+1][0],g=this._path[i+1][1],f=i*n,p=(i-1)*n,_=p;for(let m=0;m<r;m++){let y=m/s,x=c.lerp(e,y),w=t.lerp(g,y),b=e.lerp(u,y),E=d.lerp(t,y);for(let C=0;C<r;C++){let T=C/s,L=c.lerp(d,T),M=e.lerp(t,T);new Ze(x,E).intersects(new Ze(L,M),o);let R=m*r+C;_=p+R,v.doubleToTwoFloats(o,pe,me);let z=3*_;l[z]=pe.x,l[z+1]=pe.y,l[z+2]=pe.z,h[z]=me.x,h[z+1]=me.y,h[z+2]=me.z;let F=u.lerp(g,T);M=e.lerp(t,T),new Ze(b,w).intersects(new Ze(M,F),o),_=f+R,v.doubleToTwoFloats(o,pe,me),z=3*_,l[z]=pe.x,l[z+1]=pe.y,l[z+2]=pe.z,h[z]=me.x,h[z+1]=me.y,h[z+2]=me.z}}}this._createBuffers()}}else console.warn(`strip index ${i} is out of range`);else this.addEdge3v(e,t)}removeEdge(e){this._path.splice(e,1),this.setPath([].concat(this._path))}setGridSize(e){this._gridSize=e,this.setPath([].concat(this._path))}getPath(){return this._path}setPath(e){this._verticesHigh=[],this._verticesLow=[],this._indexes=[],this._path=[];for(let t=0;t<e.length;t++){let i=e[t][0],s=e[t][1];i instanceof Array&&(i=new v(i[0],i[1],i[2])),s instanceof Array&&(s=new v(s[0],s[1],s[2])),this.addEdge3v(i,s)}}insertEdge3v(e,t,i){if(i<this._path.length){let s=[].concat(this._path);s.splice(i,0,[e,t]),this.setPath(s)}else i===this._path.length&&this.addEdge3v(e,t)}};bn.__counter__=0;let wn=bn;const Cn=class Fa{constructor(e={}){e.properties=e.properties||{},this.__id=Fa.__counter__++,this.properties=e.properties||{},this.properties.name=this.properties.name!=null?this.properties.name:"",this.childEntities=[],this.parent=null,this.forceGlobalPosition=e.forceGlobalPosition||!1,this.forceGlobalRotation=e.forceGlobalRotation||!1,this.forceGlobalScale=e.forceGlobalScale||!1,this._cartesian=je(e.cartesian),this._rootCartesian=new v,this._localPosition=je(e.localPosition),this._absoluteLocalPosition=new v,this._lonLat=Oi(e.lonlat),this._lonLatMerc=new A,this._altitude=e.altitude||0,this._visibility=e.visibility==null||e.visibility,this._entityCollection=null,this._entityCollectionIndex=-1,this._layer=null,this._layerIndex=-1,this._pickingColor=new v(0,0,0),this._independentPicking=e.independentPicking||!1,this._relativePosition=e.relativePosition||!1,this._pitchRad=e.pitch||0,this._yawRad=e.yaw||0,this._rollRad=e.roll||0,this._scale=je(e.scale,new v(1,1,1)),this._absoluteScale=new v,this._qFrame=O.IDENTITY,this._qRot=O.IDENTITY,this._absoluteQRot=O.IDENTITY,this._useDirectQuaternion=!1,this._featureConstructorArray={billboard:[hn,this.setBillboard],label:[pn,this.setLabel],polyline:[yn,this.setPolyline],pointCloud:[Cl,this.setPointCloud],geometry:[dn,this.setGeometry],geoObject:[fn,this.setGeoObject],strip:[wn,this.setStrip],ray:[Tl,this.setRay]},this.billboard=this._createOptionFeature("billboard",e.billboard),this.label=this._createOptionFeature("label",e.label),this.polyline=this._createOptionFeature("polyline",e.polyline),this.ray=this._createOptionFeature("ray",e.ray),this.pointCloud=this._createOptionFeature("pointCloud",e.pointCloud),this.geometry=this._createOptionFeature("geometry",e.geometry),this.geoObject=this._createOptionFeature("geoObject",e.geoObject),this.strip=this._createOptionFeature("strip",e.strip)}get isEmpty(){return!(this.strip||this.polyline||this.ray||this.geoObject||this.geometry||this.billboard||this.label||this.pointCloud)}get rootEntity(){let e=this;for(;e;){if(!e.parent)return e;e=e.parent}return this}set relativePosition(e){if(e!==this._relativePosition){let t=this.getAbsoluteCartesian(),i=this.getAbsolutePitch(),s=this.getAbsoluteYaw(),r=this.getAbsoluteRoll();this._relativePosition=e,this.parent&&this._rootCartesian.copy(this.parent._rootCartesian),e?this.parent&&(this.setAbsoluteCartesian3v(t),this.setAbsolutePitch(i),this.setAbsoluteYaw(s),this.setAbsoluteRoll(r)):(this.setCartesian3v(t),this.setPitch(i),this.setYaw(s),this.setRoll(r))}}get relativePosition(){return this._relativePosition}get entityCollection(){return this._entityCollection}get id(){return this.__id}isEqual(e){return this.__id===e.__id}get layerIndex(){return this._layerIndex}get instanceName(){return"Entity"}_createOptionFeature(e,t){if(t){let i=this._featureConstructorArray[e];return i[1].call(this,new i[0](t))}return null}getCollectionIndex(){return this._entityCollectionIndex}addTo(e,t=!1){return e.add(this,t),this}remove(){this._layer&&this._layer.removeEntity(this),this._entityCollection&&this._entityCollection.removeEntity(this)}setVisibility(e){this._visibility=e,this.billboard&&this.billboard.setVisibility(e),this.geoObject&&this.geoObject.setVisibility(e),this.label&&this.label.setVisibility(e),this.polyline&&this.polyline.setVisibility(e),this.ray&&this.ray.setVisibility(e),this.geometry&&this.geometry.setVisibility(e);for(let t=0;t<this.childEntities.length;t++)this.childEntities[t].setVisibility(e)}getVisibility(){return this._visibility}setCartesian3v(e){this.setCartesian(e.x,e.y,e.z)}getScale(){return this._scale}setScale3v(e){this._scale.copy(e),this._updateAbsolutePosition();for(let t=0;t<this.childEntities.length;t++){let i=this.childEntities[t];i.forceGlobalScale?i.setScale3v(this._scale):i.setScale3v(this.childEntities[t].getScale())}}setScale(e){this.setScale3v(new v(e,e,e))}getAbsoluteRotation(){return this._absoluteQRot.clone()}getRotation(){return this._qRot}setLook3v(e){let t,i=new O,s=this.getAbsoluteCartesian();if(this._entityCollection){let r=this._entityCollection.renderNode.ellipsoid.getSurfaceNormal3v(s);t=i.setLookRotation(e.sub(s),r).conjugate()}else t=i.setLookRotation(e.sub(s),v.UP).conjugate();this.setAbsoluteRotation(t)}setLookLonLat(e){if(this._entityCollection){let t=this._entityCollection.renderNode.ellipsoid.lonLatToCartesian(e);this.setLook3v(t)}}setAbsoluteRotation(e){this._absoluteQRot.copy(e),this._updatePitchYawRoll()}setRotation(e){this._useDirectQuaternion=!1,this._pitchRad=e.getPitch(),this._yawRad=e.getYaw(),this._rollRad=e.getRoll(),this._updateAbsolutePosition()}setDirectQuaternionRotation(e){this._qRot.copy(e),this._useDirectQuaternion=!0,this._pitchRad=this._qRot.getPitch(),this._yawRad=this._qRot.getYaw(),this._rollRad=this._qRot.getRoll(),this._updateAbsolutePosition()}setPitch(e){this._useDirectQuaternion=!1,this._pitchRad=e,this._updateAbsolutePosition()}setYaw(e){this._useDirectQuaternion=!1,this._yawRad=e,this._updateAbsolutePosition()}setRoll(e){this._useDirectQuaternion=!1,this._rollRad=e,this._updateAbsolutePosition()}getPitch(){return this._pitchRad}getYaw(){return this._yawRad}getRoll(){return this._rollRad}setAbsolutePitch(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(e,this.getAbsoluteYaw(),this.getAbsoluteRoll(),this._qFrame),this._updatePitchYawRoll()):this.setPitch(e)}setAbsoluteYaw(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(),e,this.getAbsoluteRoll(),this._qFrame),this._updatePitchYawRoll()):this.setYaw(e)}setAbsoluteRoll(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(),this.getAbsoluteYaw(),e,this._qFrame),this._updatePitchYawRoll()):this.setRoll(e)}getAbsolutePitch(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getPitch():this._pitchRad}getAbsoluteYaw(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getYaw():this._yawRad}getAbsoluteRoll(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getRoll():this._rollRad}_getScaleByDistance(){let e=1;if(this._entityCollection){let t=this._entityCollection.scaleByDistance,i=1;this._entityCollection.renderNode&&this._entityCollection.renderNode.renderer&&(i=this._entityCollection.renderNode.renderer.activeCamera.eye.distance(this._rootCartesian)),e=t[2]*Si(i,t[0],t[1])/t[0]}return e}setAbsoluteCartesian(e,t,i){this.setAbsoluteCartesian3v(new v(e,t,i))}setAbsoluteCartesian3v(e){let t=e;if(this.parent&&this._relativePosition){let i=this._getScaleByDistance();t=e.sub(this.parent.getAbsoluteCartesian()).scale(1/i).divA(this.parent._absoluteScale),t=this.parent._absoluteQRot.conjugate().mulVec3(t)}this.setCartesian3v(t)}getAbsoluteCartesian(){if(this.parent&&this._relativePosition){let e=this._getScaleByDistance();return this._rootCartesian.add(this._absoluteLocalPosition.scaleTo(e))}return this._cartesian.clone()}setCartesian(e,t,i){this._cartesian.set(e,t,i),this._updateAbsolutePosition();for(let s=0;s<this.childEntities.length;s++){let r=this.childEntities[s];r._relativePosition?r.setCartesian3v(r.getCartesian()):r.forceGlobalPosition&&r.setCartesian(e,t,i)}this._updateLonLat()}_updatePitchYawRoll(){if(this.parent){this._qRot=this.parent._absoluteQRot.conjugate().mul(this._absoluteQRot),this._pitchRad=this._qRot.getPitch(),this._yawRad=this._qRot.getYaw(),this._rollRad=this._qRot.getRoll(),this.geoObject&&this.geoObject.setRotation(this._absoluteQRot);for(let e=0;e<this.childEntities.length;e++)this.childEntities[e]._updateAbsolutePosition()}}_updateAbsolutePosition(){let e=this.parent;if(e&&this._relativePosition){this._scale.mulRes(e._absoluteScale,this._absoluteScale),this._qFrame.copy(e._qFrame),this._rootCartesian.copy(e._rootCartesian),this._useDirectQuaternion||this._qRot.setPitchYawRoll(this._pitchRad,this._yawRad,this._rollRad),e._absoluteQRot.mulRes(this._qRot,this._absoluteQRot);let t=e._absoluteQRot.mulVec3(this._cartesian.add(this._localPosition)).mulA(e._absoluteScale);e._absoluteLocalPosition.addRes(t,this._absoluteLocalPosition)}else this._qFrame=O.IDENTITY,this._entityCollection&&this._entityCollection.renderNode&&(this._qFrame=this._entityCollection.renderNode.getFrameRotation(this._cartesian)),this._useDirectQuaternion?this._qFrame.isEqual(O.IDENTITY)||(this._qRot=this._qRot.mul(this._qFrame)):e&&this.forceGlobalRotation?this._qRot.setPitchYawRoll(e._pitchRad,e._yawRad,e._rollRad,this._qFrame):this._qRot.setPitchYawRoll(this._pitchRad,this._yawRad,this._rollRad,this._qFrame),this._absoluteScale.copy(this._scale),this._absoluteQRot.copy(this._qRot),this._rootCartesian.copy(this._cartesian),this._absoluteLocalPosition.copy(this._localPosition);this.geoObject&&(this.geoObject.setScale3v(this._absoluteScale),this.geoObject.setRotation(this._absoluteQRot),this.geoObject.setPosition3v(this._rootCartesian),this.geoObject.setLocalPosition3v(this._absoluteLocalPosition)),this.billboard&&this.billboard.setPosition3v(this._rootCartesian),this.label&&this.label.setPosition3v(this._rootCartesian);for(let t=0,i=this.childEntities.length;t<i;t++)this.childEntities[t]._updateAbsolutePosition();this._updateLonLat()}_setCartesian3vSilent(e,t=!1){this._cartesian.copy(e),this._updateAbsolutePosition();for(let i=0;i<this.childEntities.length;i++)this.childEntities[i].setCartesian(this._cartesian.x,this._cartesian.y,this._cartesian.z);t||this._updateLonLat()}_updateLonLat(){let e=this._entityCollection;e&&e.renderNode&&e.renderNode.ellipsoid&&(this._lonLat=e.renderNode.ellipsoid.cartesianToLonLat(this.getAbsoluteCartesian()),Math.abs(this._lonLat.lat)<ue?this._lonLatMerc=this._lonLat.forwardMercator():this._lonLatMerc.lon=this._lonLatMerc.lat=0)}getLonLat(){return this._lonLat.clone()}setLonLat(e){let t=this._lonLat;t.lon=e.lon,t.lat=e.lat,t.height=e.height;let i=this._entityCollection;if(i&&i.renderNode&&i.renderNode.ellipsoid){Math.abs(t.lat)<ue&&(this._lonLatMerc=t.forwardMercator());let s=new v;i.renderNode.ellipsoid.lonLatToCartesianRes(t,s),this.setAbsoluteCartesian3v(s)}}setLonLat2(e,t,i){let s=this._lonLat;s.lon=e,s.lat=t,s.height=i??s.height;let r=this._entityCollection;if(r&&r.renderNode&&r.renderNode.ellipsoid){Math.abs(s.lat)<ue?this._lonLatMerc=s.forwardMercator():this._lonLatMerc.lon=this._lonLatMerc.lat=this._lonLatMerc.height=0;let n=new v;r.renderNode.ellipsoid.lonLatToCartesianRes(s,n),this.setAbsoluteCartesian3v(n)}}setAltitude(e){this._altitude=e}getAltitude(){return this._altitude}getCartesian(){return this._cartesian.clone()}setBillboard(e){return this.billboard&&this.billboard.remove(),this.billboard=e,this.billboard._entity=this,this.billboard.setPosition3v(this._cartesian),this.billboard.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.billboardHandler.add(e),e}setLabel(e){return this.label&&this.label.remove(),this.label=e,this.label._entity=this,this.label.setPosition3v(this._cartesian),this.label.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.labelHandler.add(e),e}setRay(e){return this.ray&&this.ray.remove(),this.ray=e,this.ray._entity=this,this.ray.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.rayHandler.add(e),e}setPolyline(e){return this.polyline&&this.polyline.remove(),this.polyline=e,this.polyline._entity=this,this.polyline.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.polylineHandler.add(e),e}setPointCloud(e){return this.pointCloud&&this.pointCloud.remove(),this.pointCloud=e,this.pointCloud._entity=this,this.pointCloud.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.pointCloudHandler.add(e),e}setGeometry(e){this.geometry&&this.geometry.remove(),this.geometry=e,this.geometry._entity=this,this.geometry.setVisibility(this._visibility);let t=this._layer;return this._layer&&this._layer.removeEntity(this),t&&t.add(this),e}setGeoObject(e){return this.geoObject&&this.geoObject.remove(),this.geoObject=e,this.geoObject._entity=this,this.geoObject.setPosition3v(this._cartesian),this.geoObject.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.geoObjectHandler.add(e),e}setStrip(e){return this.strip&&this.strip.remove(),this.strip=e,this.strip._entity=this,this.strip.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.stripHandler.add(e),e}get layer(){return this._layer}get rendererEvents(){return this._layer?this._layer.events:this._entityCollection?this._entityCollection.events:null}appendChild(e){e._entityCollection=this._entityCollection,e._independentPicking||(e._pickingColor=this._pickingColor),e.parent=this,this.childEntities.push(e),this._entityCollection&&this._entityCollection.appendChildEntity(e)}setPickingColor(){let e=this._pickingColor;this.billboard&&this.billboard.setPickingColor3v(e),this.label&&this.label.setPickingColor3v(e),this.polyline&&this.polyline.setPickingColor3v(e),this.ray&&this.ray.setPickingColor3v(e),this.strip&&this.strip.setPickingColor3v(e),this.geoObject&&this.geoObject.setPickingColor3v(e);for(let t=0;t<this.childEntities.length;t++)this.childEntities[t].setPickingColor()}getExtent(){let e,t=this._lonLat;e=this.billboard||this.label?new G(new A(t.lon,t.lat),new A(t.lon,t.lat)):new G(new A(180,90),new A(-180,-90));let i=e.southWest,s=e.northEast;if(this.polyline){let r=this.polyline.getExtent();r.southWest.lon<i.lon&&(i.lon=r.southWest.lon),r.southWest.lat<i.lat&&(i.lat=r.southWest.lat),r.northEast.lon>s.lon&&(s.lon=r.northEast.lon),r.northEast.lat>s.lat&&(s.lat=r.northEast.lat)}if(this.geometry){let r=this.geometry.getExtent();r.southWest.lon<i.lon&&(i.lon=r.southWest.lon),r.southWest.lat<i.lat&&(i.lat=r.southWest.lat),r.northEast.lon>s.lon&&(s.lon=r.northEast.lon),r.northEast.lat>s.lat&&(s.lat=r.northEast.lat)}for(let r=0;r<this.childEntities.length;r++){let n=this.childEntities[r].getExtent();n.southWest.lon<i.lon&&(i.lon=n.southWest.lon),n.southWest.lat<i.lat&&(i.lat=n.southWest.lat),n.northEast.lon>s.lon&&(s.lon=n.northEast.lon),n.northEast.lat>s.lat&&(s.lat=n.northEast.lat)}return e}};Cn.__counter__=0;let V=Cn;const Tn=class Oa{constructor(e){this.__id=Oa.__counter__++,this._name=e||`nonameNode:${this.__id}`,this.topNode=this,this._dictionary={},this._dictionary[this._name]=this,this.childNodes=[],this.parentNode=null}get name(){return this._name}addNode(e){this.parentNode==null?e.topNode=this:e.topNode=this.topNode,e.parentNode=this,e._dictionary=this.topNode._dictionary,this.childNodes.push(e),this.topNode._dictionary[e.name]=e}destroy(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e].destroy();this._clear()}getNodeByName(e){return this._dictionary[e]}_clear(){this.parentNode=null,this.topNode=this,this.childNodes.length=0}isEqual(e){return e.__id===this.__id}};Tn.__counter__=0;let El=Tn;class at extends El{constructor(e){super(e),this.childNodes=[],this.renderer=null,this.drawMode=0,this.show=!0,this._isActive=!0,this.lightEnabled=!1,this._lightPosition=new Float32Array([100,100,100]),this._lightParams=new Float32Array(9),this._lightShininess=100,this.entityCollections=[],this._entityCollectionsByDepthOrder=[],this._pickingId=-1}getFrameRotation(e){return O.IDENTITY}addNode(e){super.addNode(e),this.renderer&&e.assign(this.renderer)}assign(e){this.renderer=e,this._pickingId=e.addPickingCallback(this,this._entityCollectionPickingCallback),this.initialize()}initialize(){if(this.renderer&&this.renderer.isInitialized()){for(let e=0;e<this.entityCollections.length;e++)this.entityCollections[e].bindRenderNode(this);this.init()}}init(){}onremove(){}remove(){let e=this.renderer,t=this.name;if(e){e.renderNodes[t]&&e.renderNodes[t].isEqual(this)&&(e.renderNodes[t]=null,delete e.renderNodes[t]);for(let i=0;i<e._renderNodesArr.length;i++)if(e._renderNodesArr[i].isEqual(this)){e._renderNodesArr.splice(i,1);break}e.removePickingCallback(this._pickingId),this._pickingId=-1,this.onremove&&this.onremove()}}addEntityCollection(e,t){e.renderNode||(e.renderNode=this,t||(this.entityCollections.push(e),this.updateEntityCollectionsDepthOrder()),this.ellipsoid&&e._updateGeodeticCoordinates(this.ellipsoid),e.bindRenderNode(this),e.events.dispatch(e.events.add,this))}removeEntityCollection(e){for(let t=0;t<this.entityCollections.length;t++)if(this.entityCollections[t].isEqual(e))return this.entityCollections.splice(t,1),void this.updateEntityCollectionsDepthOrder()}updateEntityCollectionsDepthOrder(){let e={0:[]};for(const t of this.entityCollections)t.getVisibility()&&(e[t.depthOrder]||(e[t.depthOrder]=[]),e[t.depthOrder].push(t));this._entityCollectionsByDepthOrder.length=0,this._entityCollectionsByDepthOrder=[],this._entityCollectionsByDepthOrder=Object.keys(e).sort((t,i)=>Number(t)-Number(i)).map(t=>e[Number(t)])}addLight(e){return e.addTo(this),this}preDrawNode(){this._isActive&&this._preDrawNodes()}drawNode(){this._isActive&&this._drawNodes()}isActive(){return this._isActive}setActive(e){this._isActive=e,this.renderer&&(this._isActive&&this._pickingId===-1?this._pickingId=this.renderer.addPickingCallback(this,this._entityCollectionPickingCallback):this._isActive||this._pickingId===-1||(this.renderer.removePickingCallback(this._pickingId),this._pickingId=-1));for(let t=0;t<this.childNodes.length;t++)this.childNodes[t].setActive(e)}setDrawMode(e){this.drawMode=e;for(let t=0;t<this.childNodes.length;t++)this.childNodes[t].setDrawMode(e)}updateBillboardsTexCoords(){for(let e=0;e<this.entityCollections.length;e++)this.entityCollections[e].billboardHandler.refreshTexCoordsArr()}frame(){}preFrame(){}_preDrawNodes(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e]._isActive&&this.childNodes[e]._preDrawNodes();if(this.show){this.preFrame();for(let e=0;e<this._entityCollectionsByDepthOrder.length;e++)this.drawEntityCollections(this._entityCollectionsByDepthOrder[e],e)}}_drawNodes(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e]._isActive&&this.childNodes[e]._drawNodes();this.show&&this.frame()}drawEntityCollections(e,t=0){this.renderer.enqueueEntityCollectionsToDraw(e,t)}drawPickingEntityCollections(e){if(e.length){let t=e.length;for(;t--;)e[t]._fadingOpacity&&e[t].billboardHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].geoObjectHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].labelHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].rayHandler.drawPicking();for(t=e.length;t--;)e[t]._visibility&&e[t].polylineHandler.drawPicking();for(t=e.length;t--;)e[t]._visibility&&e[t].stripHandler.drawPicking()}}_entityCollectionPickingCallback(){}}const Qe=new class{constructor(){this._container=document.createElement("div"),this._container.classList.add("ogConsole"),this._container.style.display="none",document.body&&document.body.appendChild(this._container),this._visibility=!1}getVisibility(){return this._visibility}setVisibility(a){this._visibility!=a&&(this._visibility=a,this._visibility?this.show():this.hide())}show(){this._container.parentNode||document.body&&document.body.appendChild(this._container),this._container.style.display="block",this._visibility=!0}hide(){this._container.style.display="none",this._visibility=!1}logErr(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-error"),e.innerHTML="error: "+a,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}logWrn(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-warning"),e.innerHTML="warning: "+a,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}log(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.innerHTML=a,console.trace(a),this._container.appendChild(e),this.show()}};let si=["FLOAT","DOUBLE","BOOL","INT","UINT","VEC2","VEC3","VEC4","DVEC2","DVEC3","DVEC4","BVEC2","BVEC3","BVEC4","IVEC2","IVEC3","IVEC4","UVEC2","UVEC3","UVEC4","MAT2","DMAT2","MAT3","DMAT3","MAT4","DMAT4","MAT2X3","MAT2X4","MAT3X2","MAT3X4","MAT4X2","MAT4X3","DMAT2X3","DMAT2X4","DMAT3X2","DMAT3X4","DMAT4X2","DMAT4X3","SAMPLER1D","SAMPLER2D","SAMPLER3D","SAMPLERCUBE","SAMPLER2DSHADOW","SAMPLER2DARRAY","INTXX","FLOATXX"];const _e={};for(let a=0;a<si.length;a++)_e[si[a]]=a;const Bs={};for(let a=0;a<si.length;a++)Bs[si[a].toLowerCase()]=_e[si[a]];const Se={u:[],a:[]};Se.u[_e.MAT4]=function(a,e){a.gl.uniformMatrix4fv(e._pName,!1,e.value)},Se.u[_e.MAT3]=function(a,e){a.gl.uniformMatrix3fv(e._pName,!1,e.value)},Se.u[_e.FLOAT]=function(a,e){a.gl.uniform1f(e._pName,e.value)},Se.u[_e.INT]=function(a,e){a.gl.uniform1i(e._pName,e.value)},Se.u[_e.VEC2]=function(a,e){a.gl.uniform2fv(e._pName,e.value)},Se.u[_e.VEC3]=function(a,e){a.gl.uniform3fv(e._pName,e.value)},Se.u[_e.VEC4]=function(a,e){a.gl.uniform4fv(e._pName,e.value)},Se.u[_e.SAMPLER2D]=function(a,e){let t=a.gl;t.activeTexture(t.TEXTURE0+a._textureID),t.bindTexture(t.TEXTURE_2D,e.value),t.uniform1i(e._pName,a._textureID),a._textureID++},Se.u[_e.SAMPLERCUBE]=function(a,e){let t=a.gl;t.activeTexture(t.TEXTURE0+a._textureID),t.bindTexture(t.TEXTURE_CUBE_MAP,e.value),t.uniform1i(e._pName,a._textureID),a._textureID++},Se.u[_e.SAMPLER2DARRAY]=function(a,e){let t=e.value,i=a.gl,s=t.length,r=new Int32Array(s);for(let n=0;n<s;n++)i.activeTexture(i.TEXTURE0+a._textureID+n),i.bindTexture(i.TEXTURE_2D,t[n]),r[n]=n;i.uniform1iv(e._pName,r)},Se.u[_e.INTXX]=function(a,e){a.gl.uniform1iv(e._pName,e.value)},Se.u[_e.FLOATXX]=function(a,e){a.gl.uniform1fv(e._pName,e.value)},Se.a[_e.FLOAT]=function(a,e){a.gl.vertexAttrib1f(e._pName,e.value)},Se.a[_e.VEC2]=function(a,e){a.gl.vertexAttrib2fv(e._pName,e.value)},Se.a[_e.VEC3]=function(a,e){a.gl.vertexAttrib3fv(e._pName,e.value)};const Al=["BYTE","SHORT","UNSIGNED_BYTE","UNSIGNED_SHORT","FLOAT","HALF_FLOAT"];class X{constructor(e,t){this.name=e,this._programController=null,this._attributes={};for(let i in t.attributes)typeof t.attributes[i]=="string"||typeof t.attributes[i]=="number"?this._attributes[i]={type:t.attributes[i]}:this._attributes[i]=t.attributes[i];this._uniforms={};for(let i in t.uniforms)typeof t.uniforms[i]=="string"||typeof t.uniforms[i]=="number"?this._uniforms[i]={type:t.uniforms[i]}:this._uniforms[i]=t.uniforms[i];this.vertexShader=t.vertexShader,this.fragmentShader=t.fragmentShader,this.gl=null,this._variables={},this._p=null,this._textureID=0,this._attribArrays=[],this._attribDivisor=[],this.attributes={},this.uniforms={},this.vertexAttribDivisor=null,this.drawElementsInstanced=null}static bindBuffer(e,t){let i=e.gl;i&&(i.bindBuffer(i.ARRAY_BUFFER,t.value),i.vertexAttribPointer(t._pName,t.value.itemSize,t.itemType,t.normalized,0,0))}use(){this.gl&&this.gl.useProgram(this._p)}set(e){this._textureID=0;for(let t in e)this._variables[t].value=e[t],this._variables[t].func(this,this._variables[t])}apply(){this._textureID=0;let e=this._variables;for(let t in e)e[t].func(this,e[t])}drawIndexBuffer(e,t){let i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t),i.drawElements(e,t.numItems,i.UNSIGNED_SHORT,0)}drawArrays(e,t){this.gl.drawArrays(e,0,t)}_getShaderCompileStatus(e,t){if(!this.gl)return!1;const i=this.gl instanceof WebGL2RenderingContext;return this.gl.shaderSource(e,function(s,r){if(!r)return s;const n=s.split(`
89
+ `,on=typeof self<"u"&&self.Blob&&new Blob([an],{type:"text/javascript;charset=utf-8"});function yl(a){let e;try{if(e=on&&(self.URL||self.webkitURL).createObjectURL(on),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(an),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class xl extends Rr{constructor(e=4){super(e,yl)}_onMessage(e){let t=this._source.get(e.data.id);t.label._lockId===-2?requestAnimationFrame(()=>{this.make({handler:t.handler,label:t.label})}):t.handler.workerCallback(e.data,t.label),this._source.delete(e.data.id)}make(e){let t=e.label;if(e.handler._entityCollection){let i=t.serializeWorkerData(this._sourceId);if(i)if(this._workerQueue.length){let r=this._workerQueue.pop();this._source.set(this._sourceId,e),t._lockId=this._sourceId,this._sourceId++,r.postMessage({labelData:i},[i.buffer])}else this._pendingQueue.push(e)}}}const ln=class ko{constructor(e={}){this.__id=ko.__counter__++,this._position=je(e.position),this._positionHigh=new m,this._positionLow=new m,m.doubleToTwoFloats(this._position,this._positionHigh,this._positionLow),this._rotation=e.rotation||0,this._color=rt(e.color),this._alignedAxis=je(e.alignedAxis),this._offset=je(e.offset),this._visibility=e.visibility==null||e.visibility,this._entity=null,this._handler=null,this._handlerIndex=-1,this._isReady=!1,this._lockId=-1}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,m.doubleToTwoFloats(this._position,this._positionHigh,this._positionLow),this._isReady&&this._handler?this._handler.setPositionArr(this._handlerIndex,this._positionHigh,this._positionLow):this._lockId!==-1&&(this._lockId=-2)}setPosition3v(e){this._position.x=e.x,this._position.y=e.y,this._position.z=e.z,m.doubleToTwoFloats(e,this._positionHigh,this._positionLow),this._isReady&&this._handler?this._handler.setPositionArr(this._handlerIndex,this._positionHigh,this._positionLow):this._lockId!==-1&&(this._lockId=-2)}getPosition(){return this._position}setOffset(e,t,i){this._offset.x=e,this._offset.y=t,i!=null&&(this._offset.z=i),this._isReady&&this._handler?this._handler.setOffsetArr(this._handlerIndex,this._offset):this._lockId!==-1&&(this._lockId=-2)}setOffset3v(e){this.setOffset(e.x,e.y,e.z)}getOffset(){return this._offset}setRotation(e){e!==this._rotation&&(this._rotation=e,this._isReady&&this._handler?this._handler.setRotationArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getRotation(){return this._rotation}setOpacity(e){e!==this._color.w&&(e!=null&&(this._color.w=e),this._isReady&&this._handler?this._handler.setRgbaArr(this._handlerIndex,this._color):this._lockId!==-1&&(this._lockId=-2))}setColor(e,t,i,r){r===this._color.w&&e===this._color.x&&t===this._color.y&&this._color.z===i||(this._color.x=e,this._color.y=t,this._color.z=i,r!=null&&(this._color.w=r),this._isReady&&this._handler?this._handler.setRgbaArr(this._handlerIndex,this._color):this._lockId!==-1&&(this._lockId=-2))}setColor4v(e){this.setColor(e.x,e.y,e.z,e.w)}setColorHTML(e){this.setColor4v(it(e))}getColor(){return this._color}setVisibility(e){e!==this._visibility&&(this._visibility=e,this._isReady&&this._handler?this._handler.setVisibility(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getVisibility(){return this._visibility}setAlignedAxis(e,t,i){this._alignedAxis.x=e,this._alignedAxis.y=t,this._alignedAxis.z=i,this._isReady&&this._handler?this._handler.setAlignedAxisArr(this._handlerIndex,this._alignedAxis):this._lockId!==-1&&(this._lockId=-2)}setAlignedAxis3v(e){this.setAlignedAxis(e.x,e.y,e.z)}getAlignedAxis(){return this._alignedAxis}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._isReady&&this._handler?this._handler.setPickingColorArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2)}serializeWorkerData(e){return this._handler?new Float32Array([]):null}};ln.__counter__=0;let hn=ln;class cn extends hn{constructor(e={}){super(e),this._handler=null,this._src=e.src||null,this._image=e.image||null,this._scale=1,this._width=e.width||(e.size?e.size[0]:30),this._height=e.height||(e.size?e.size[1]:30)}setSrc(e){this._src=e;let t=this._handler;if(t&&e&&e.length){let i=t._entityCollection.renderNode;if(i&&i.renderer){let r=i.renderer.billboardsTextureAtlas,s=this;r.loadImage(e,function(n){n.__nodeIndex!=null&&r.get(n.__nodeIndex)?(s._image=n,t.setTexCoordArr(s._handlerIndex,r.get(s._image.__nodeIndex).texCoords)):(r.addImage(n),r.createTexture(),s._image=n,i.updateBillboardsTexCoords())})}}}getSrc(){return this._src}setImage(e){this.setSrc(e.src)}getImage(){return this._image}setSize(e,t){this._width=e,this._height=t,this._handler&&this._handler.setSizeArr(this._handlerIndex,e*this._scale,t*this._scale)}getSize(){return{width:this._width,height:this._height}}setWidth(e){this.setSize(e,this._height)}getWidth(){return this._width}setHeight(e){this.setSize(this._width,e)}getHeight(){return this._height}}var ei=(a=>(a[a.POINT=1]="POINT",a[a.LINESTRING=2]="LINESTRING",a[a.POLYGON=3]="POLYGON",a[a.MULTIPOLYGON=4]="MULTIPOLYGON",a[a.MULTILINESTRING=5]="MULTILINESTRING",a))(ei||{});const bl={POINT:1,LINESTRING:2,POLYGON:3,MULTIPOLYGON:4,MULTILINESTRING:5},dn=class Pt{constructor(e={}){this.__id=Pt.__counter__++,this._entity=null,this._handler=null,this._handlerIndex=-1,this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyVerticesLength=-1,this._polyIndexesLength=-1,this._polyVerticesHandlerIndex=-1,this._polyIndexesHandlerIndex=-1,this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineVerticesLength=-1,this._lineOrdersLength=-1,this._lineIndexesLength=-1,this._lineColorsLength=-1,this._lineThicknessLength=-1,this._lineVerticesHandlerIndex=-1,this._lineOrdersHandlerIndex=-1,this._lineIndexesHandlerIndex=-1,this._lineThicknessHandlerIndex=-1,this._lineColorsHandlerIndex=-1,this._type=e.type&&Pt.getType(e.type)||1,this._coordinates=e.coordinates||[],this._extent=Pt.getExtent({type:e.type||"POINT",coordinates:e.coordinates||[]},this._coordinates),e.style=e.style||{},this._style={fillColor:rt(e.style.fillColor,new te(.19,.62,.85,.4)),lineColor:rt(e.style.lineColor,new te(.19,.62,.85,1)),strokeColor:rt(e.style.strokeColor,new te(1,1,1,.95)),lineWidth:e.style.lineWidth||3,strokeWidth:e.style.strokeWidth||0},this._visibility=e.visibility||!0,this._pickingReady=!1}get id(){return this.__id}get type(){return this._type}static getType(e){return bl[e.toUpperCase()]}static getExtent(e,t){let i=new j(new A(180,90),new A(-180,-90)),r=Pt.getType(e.type);if(r===1){let s=e.coordinates[0],n=e.coordinates[1];i.southWest.lon=s,i.southWest.lat=n,i.northEast.lon=s,i.northEast.lat=n,t&&(t[0]=s)&&(t[1]=n)}else if(r===2){let s=e.coordinates;for(let n=0;n<s.length;n++){let o=s[n][0],l=s[n][1];o<i.southWest.lon&&(i.southWest.lon=o),l<i.southWest.lat&&(i.southWest.lat=l),o>i.northEast.lon&&(i.northEast.lon=o),l>i.northEast.lat&&(i.northEast.lat=l),t&&(t[n]=[o,l])}}else if(r===3){let s=e.coordinates;for(let n=0;n<s.length;n++){let o=s[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l],c=h[0],d=h[1];c<i.southWest.lon&&(i.southWest.lon=c),d<i.southWest.lat&&(i.southWest.lat=d),c>i.northEast.lon&&(i.northEast.lon=c),d>i.northEast.lat&&(i.northEast.lat=d),t&&(t[n][l]=[c,d])}}}else if(r===4){let s=e.coordinates;for(let n=0;n<s.length;n++){let o=s[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l];t&&(t[n][l]=[]);for(let c=0;c<h.length;c++){let d=h[c],u=d[0],g=d[1];u<i.southWest.lon&&(i.southWest.lon=u),g<i.southWest.lat&&(i.southWest.lat=g),u>i.northEast.lon&&(i.northEast.lon=u),g>i.northEast.lat&&(i.northEast.lat=g),t&&(t[n][l][c]=[u,g])}}}}else if(r===5){let s=e.coordinates;for(let n=0;n<s.length;n++){let o=s[n];t&&(t[n]=[]);for(let l=0;l<o.length;l++){let h=o[l],c=h[0],d=h[1];c<i.southWest.lon&&(i.southWest.lon=c),d<i.southWest.lat&&(i.southWest.lat=d),c>i.northEast.lon&&(i.northEast.lon=c),d>i.northEast.lat&&(i.northEast.lat=d),t&&(t[n][l]=[c,d])}}}else i.southWest.lon=i.southWest.lat=i.northEast.lon=i.northEast.lat=0,t&&(t[0]=0)&&(t[1]=0);return i}setGeometry(e){let t=this._handler;return t&&(this.remove(),this._type=Pt.getType(e.type||"Point"),this._extent=Pt.getExtent(e,this._coordinates),t.add(this)),this}setFillColor(e,t,i,r=1){let s=this._style.fillColor;return(s.w===0&&r!==0||s.w!==0&&r===0)&&(this._pickingReady=!1),s.x=e,s.y=t,s.z=i,s.w=r,this._handler&&this._handler.setPolyColorArr(this,s),this}overlaps(e){return this._extent.overlaps(e)}setFillColor4v(e){return this.setFillColor(e.x,e.y,e.z,e.w)}setStrokeColor(e,t,i,r=1){let s=this._style.strokeColor;return(s.w===0&&r!==0||s.w!==0&&r===0)&&(this._pickingReady=!1),s.x=e,s.y=t,s.z=i,s.w=r,this._handler&&this._handler.setLineStrokeColorArr(this,s),this}setLineColor(e,t,i,r=1){let s=this._style.lineColor;return(s.w===0&&r!==0||s.w!==0&&r===0)&&(this._pickingReady=!1),s.x=e,s.y=t,s.z=i,s.w=r,this._handler&&this._handler.setLineColorArr(this,s),this}setStrokeColor4v(e){return this.setStrokeColor(e.x,e.y,e.z,e.w)}setLineColor4v(e){return this.setLineColor(e.x,e.y,e.z,e.w)}setStrokeOpacity(e){let t=this._style.strokeColor;return t.w=e,this.setStrokeColor(t.x,t.y,t.z,e)}setLineOpacity(e){let t=this._style.lineColor;return t.w=e,this.setLineColor(t.x,t.y,t.z,e)}setStrokeWidth(e){return this._style.strokeWidth=e,this._pickingReady=!1,this._handler&&this._handler.setLineStrokeArr(this,e),this}bringToFront(){return this._handler&&this._handler.bringToFront(this),this}setLineWidth(e){return this._style.lineWidth=e,this._pickingReady=!1,this._handler&&this._handler.setLineThicknessArr(this,e),this}setFillOpacity(e){let t=this._style.fillColor;return(t.w===0&&e!==0||t.w!==0&&e===0)&&(this._pickingReady=!1),t.w=e,this._handler&&this._handler.setPolyColorArr(this,t),this}setVisibility(e){return this._visibility=e,this._handler&&this._handler.setGeometryVisibility(this),this}getVisibility(){return this._visibility}remove(){this._handler&&this._handler.remove(this)}getExtent(){return this._extent.clone()}getType(){return this._type}};dn.__counter__=0;let un=dn;class Qe{constructor(e,t){this.p0=e||new m,this.p1=t||new m}getMagnitude(){return this.p0.distance(this.p1)}getSphereIntersection(e){let t=this.p0,i=this.p1,r=e.center.x,s=e.center.y,n=e.center.z,o=t.x,l=t.y,h=t.z,c=i.x-o,d=i.y-l,u=i.z-h,g=c*c+d*d+u*u,f=2*(o*c+l*d+h*u-c*r-d*s-u*n),p=f*f-4*g*(o*o-2*o*r+r*r+l*l-2*l*s+s*s+h*h-2*h*n+n*n-e.radius*e.radius);if(p<0)return[];let _=(-f-Math.sqrt(p))/(2*g),v=new m(t.x*(1-_)+_*i.x,t.y*(1-_)+_*i.y,t.z*(1-_)+_*i.z);if(p==0)return[v];let x=(-f+Math.sqrt(p))/(2*g),y=new m(t.x*(1-x)+x*i.x,t.y*(1-x)+x*i.y,t.z*(1-x)+x*i.z);return Math.abs(_-.5)<Math.abs(x-.5)?[v,y]:[y,v]}intersects(e,t,i){let r=this.p0.sub(e.p0),s=e.p1.sub(e.p0);if(Math.abs(s.x)<tt&&Math.abs(s.y)<tt&&Math.abs(s.z)<tt)return!1;let n=this.p1.sub(this.p0);if(Math.abs(n.x)<tt&&Math.abs(n.y)<tt&&Math.abs(n.z)<tt)return!1;let o=r.x*s.x+r.y*s.y+r.z*s.z,l=s.x*n.x+s.y*n.y+s.z*n.z,h=r.x*n.x+r.y*n.y+r.z*n.z,c=s.x*s.x+s.y*s.y+s.z*s.z,d=(n.x*n.x+n.y*n.y+n.z*n.z)*c-l*l;if(Math.abs(d)<tt)return!1;let u=(o*l-h*c)/d;if(t.x=this.p0.x+u*n.x,t.y=this.p0.y+u*n.y,t.z=this.p0.z+u*n.z,i){let g=(o+l*u)/c;i.x=e.p0.x+g*s.x,i.y=e.p0.y+g*s.y,i.z=e.p0.z+g*s.z}return!0}getNearestDistancePoint(e,t){let i=this.p0,r=this.p1,s=this.getMagnitude(),n=((e.x-i.x)*(r.x-i.x)+(e.y-i.y)*(r.y-i.y)+(e.z-i.z)*(r.z-i.z))/(s*s);return t.x=i.x+n*(r.x-i.x),t.y=i.y+n*(r.y-i.y),t.z=i.z+n*(r.z-i.z),!(n<0||n>1)}}class we{constructor(e,t){this.p=e?e.clone():new m,this.n=t?t.clone():this.p.isZero()?m.UP:this.p.getNormal()}setByPoints(e,t,i){let r=m.sub(t,e),s=m.sub(i,e);return this.n=r.cross(s),this.p.copy(e),this}static fromPoints(e,t,i){return new we().setByPoints(e,t,i)}set(e,t){this.p.copy(e),this.n.copy(t)}getNormal(){return this.n.clone()}distance(e){let t=this.getProjection(e);return e.distance(t)}getProjection(e,t){return m.proj_b_to_plane(e,this.n,t)}getProjectionPoint(e,t){let i=e.sub(this.p),r=this.n,s=i.dot(r);return t?t.copy(r.scale(s)):t=r.scale(s),e.sub(t)}getIntersection(e,t,i){let r,s=e.n.cross(t.n),n=s.x>=0?s.x:-s.x,o=s.y>=0?s.y:-s.y,l=s.z>=0?s.z:-s.z;if(n+o+l<Cs){let u=t.p.sub(e.p);return e.n.dot(u)==0?1:0}r=n>o?n>l?1:3:o>l?2:3;let h,c,d=new m;return h=-e.n.dot(e.p),c=-t.n.dot(t.p),r===1?(d.x=0,d.y=(c*e.n.z-h*t.n.z)/s.x,d.z=(h*t.n.y-c*e.n.y)/s.x):r===2?(d.x=(h*t.n.z-c*e.n.z)/s.y,d.y=0,d.z=(c*e.n.x-h*t.n.x)/s.y):r===3&&(d.x=(c*e.n.y-h*t.n.y)/s.z,d.y=(h*t.n.x-c*e.n.x)/s.z,d.z=0),i.p0.copy(d),i.p1.copy(d.add(s)),2}}let H=class ct{constructor(e=m.ZERO,t=m.ZERO){this.origin=e,this.direction=t}static get OUTSIDE(){return 0}static get INSIDE(){return 1}static get INPLANE(){return 2}static get AWAY(){return 3}set(e,t){return this.origin=e,this.direction=t,this}getPoint(e){return m.add(this.origin,this.direction.scaleTo(e))}hitTriangleRes(e,t,i,r){let s=t.sub(e),n=i.sub(e),o=s.cross(n),l=this.origin.sub(e),h=-o.dot(l),c=o.dot(this.direction);if(Math.abs(c)<tt)return h===0?(r.copy(this.origin),ct.INPLANE):ct.OUTSIDE;let d=h/c;if(r.copy(this.origin.add(this.direction.scaleTo(d))),d<0)return ct.AWAY;let u=s.dot(s),g=s.dot(n),f=n.dot(n),p=r.sub(e),_=p.dot(s),v=p.dot(n),x=g*g-u*f,y=(g*v-f*_)/x;if(y<0||y>1)return ct.OUTSIDE;let w=(g*_-u*v)/x;return w<0||y+w>1?ct.OUTSIDE:ct.INSIDE}hitPlaneRes(e,t){const i=this.direction.dot(e.n);if(Math.abs(i)<tt)return ct.OUTSIDE;const r=e.p.sub(this.origin).dot(e.n)/i;return r<0?ct.AWAY:(t.copy(this.getPoint(r)),ct.INSIDE)}hitSphere(e){const t=m.sub(this.origin,e.center),i=this.direction.dot(this.direction),r=2*t.dot(this.direction),s=r*r-4*i*(t.dot(t)-e.radius*e.radius);if(s<0)return null;const n=Math.sqrt(s);let o=(-r-n)/(2*i);return o<0&&(o=(-r+n)/(2*i)),o<0?null:m.add(this.origin,this.direction.scaleTo(o))}hitBox(e){}};function Br(a){let e=a.split("/"),t=e[e.length-1],i=e[e.length-2];return`${i?i+"/":""}${t}`}class _n{constructor(){this.objPositions=[],this.objTexcoords=[],this.objNormals=[],this.objVertexData=[this.objPositions,this.objTexcoords,this.objNormals],this.vertexData=[[],[],[]],this._materialLibs=[],this.geometries=[],this.geometry=null,this.materials={},this.material={},this.object="default",this.groups=["default"],this._path="",this.keywords={v:e=>{this.objPositions.push(e.map(parseFloat))},vn:e=>{this.objNormals.push(e.map(parseFloat))},vt:e=>{this.objTexcoords.push([parseFloat(e[0]),1-parseFloat(e[1])])},f:e=>{this.setGeometry();const t=e.length-2;for(let i=0;i<t;++i)this.addVertex(e[0]),this.addVertex(e[i+1]),this.addVertex(e[i+2])},s:()=>{},mtllib:(e,t)=>{this._materialLibs.push(t)},usemtl:(e,t)=>{this.newGeometry(),this.setGeometry(),this.geometry&&(this.geometry.material=t)},g:e=>{this.groups=e,this.newGeometry()},o:(e,t)=>{this.object=t,this.newGeometry()},newmtl:(e,t)=>{const i={};this.material=i,this.materials[t]=i},Ns:(e,t)=>{this.material.shininess=parseFloat(t)},Ni:(e,t)=>{},Ka:(e,t)=>{this.material.ambient=e.map(i=>parseFloat(i))},Kd:(e,t)=>{this.material.diffuse=e.map(i=>parseFloat(i))},Ks:(e,t)=>{this.material.specular=e.map(i=>parseFloat(i))},Ke:(e,t)=>{this.material.color=e.map(i=>parseFloat(i))},illum:(e,t)=>{this.material.illum=parseFloat(t)},d:(e,t)=>{this.material.opacity=parseFloat(t)},Tr:(e,t)=>{this.material.opacity=parseFloat(t)},Tf:(e,t)=>{},map_Ka:(e,t)=>{},map_Kd:(e,t)=>{this.material.colorTexture=`${this._path}/${Br(t)}`},map_Bump:(e,t)=>{this.material.normalTexture=`${this._path}/${Br(t)}`},map_Ns:(e,t)=>{this.material.metallicRoughnessTexture=`${this._path}/${Br(t)}`}}}newGeometry(){this.geometry&&this.geometry.data.vertices.length&&(this.geometry=null)}setGeometry(){if(!this.geometry){const e=[],t=[],i=[];this.vertexData=[e,t,i],this.geometry={object:this.object,groups:this.groups,material:"",data:{vertices:e,texCoords:t,normals:i}},this.geometries.push(this.geometry)}}addVertex(e){let t=e.split("/");for(let i=0;i<t.length;i++){let r=t[i];if(!r)continue;let s=parseInt(r)-1,n=this.vertexData[i],o=n.length,l=this.objVertexData[i][s],h=l.length;this.vertexData[i].length=o+h;for(let c=0;c<h;c++)n[o+c]=l[c]}}_innerParser(e,t){const i=/(\w*)(?: )*(.*)/,r=e.split(`
90
+ `);for(let s=0;s<r.length;++s){const n=r[s].trim();if(n===""||n.startsWith("#"))continue;const o=i.exec(n);if(!o)continue;const[,l,h]=o,c=n.split(/\s+/).slice(1),d=this.keywords[l];d?d(c,h):console.warn(`Unknown keyword '${l}' in '${t}:${s}'`)}}get data(){return{geometries:this.geometries,materials:this.materials}}async load(e){this._path=e.substring(0,e.lastIndexOf("/"));const t=await fetch(e);if(!t.ok)throw new Error(`Unable to load '${e}'`);const i=t.body.getReader(),r=new TextDecoder;let{value:s,done:n}=await i.read(),o="";for(;!n;){const h=(o+r.decode(s,{stream:!0})).split(`
91
+ `);o=h.pop();for(const c of h)this._innerParser(c,e);({value:s,done:n}=await i.read())}o&&this._innerParser(o,e),this._cleanupGeometryArrays();let l=this._materialLibs.map(h=>(h=`${this._path}/${h}`,fetch(h).then(c=>c.text()).then(c=>({text:c,filename:h}))));return await Promise.all(l).then(h=>{h.forEach(c=>this._innerParser(c.text,c.filename))}),this.data}async _readAndParse(e){const t=e.stream().getReader(),i=new TextDecoder;let{value:r,done:s}=await t.read(),n="";for(;!s;){const o=(n+i.decode(r,{stream:!0})).split(`
92
+ `);n=o.pop();for(const l of o)this._innerParser(l,e.name);({value:r,done:s}=await t.read())}n&&this._innerParser(n,e.name)}async readFile(e,t){return this._path="",await this._readAndParse(e),this._cleanupGeometryArrays(),t&&await this._readAndParse(t),this.data}_cleanupGeometryArrays(){for(const e of this.geometries)e.data=Object.fromEntries(Object.entries(e.data).filter(([t,i])=>i.length>0))}}function Dt(a){let e=new Float32Array([1,1,1]);if(a instanceof Array)e[0]=a[0],e[1]=a[1],e[2]=a[2];else if(typeof a=="string"){let t=_t(a);e[0]=t[0],e[1]=t[1],e[2]=t[2]}return e}class Z{constructor(e={}){var t;if(this._name=e.name||"noname",this._vertices=e.vertices||[],this._numVertices=this._vertices.length/3,this._texCoords=e.texCoords||new Array(2*this._numVertices),this.color=(t=e.color)instanceof Array?new Float32Array(t):typeof t=="string"?_t(t):new Float32Array([.5,.5,.5,1]),this.ambient=Dt(e.ambient),this.diffuse=Dt(e.diffuse),this.specular=Dt(e.specular),this.shininess=e.shininess||100,this.colorTextureSrc=e.colorTextureSrc||null,this.colorTextureImage=e.colorTextureImage||null,this.normalTextureSrc=e.normalTextureSrc||null,this.normalTextureImage=e.normalTextureImage||null,this.metallicRoughnessTextureSrc=e.metallicRoughnessTextureSrc||null,this.metallicRoughnessTextureImage=e.metallicRoughnessTextureImage||null,e.scale){let i,r=e.scale;i=typeof r=="number"?new m(r,r,r):r,Z.scale(this._vertices,i)}if(e.center&&Z.centering(this._vertices),this.center=Z.getCenter(this._vertices),e.indices)this._indices=e.indices,this._normals=e.normals||[];else{this._normals=e.normals||Z.getNormals(this._vertices),this._indices=new Array(this._vertices.length/3);for(let i=0,r=this._indices.length;i<r;i++)this._indices[i]=i}}static getCenter(e){let t=ye,i=ye,r=ye,s=Te,n=Te,o=Te;for(let l=0,h=e.length;l<h;l+=3){let c=e[l],d=e[l+1],u=e[l+2];c<t&&(t=c),d<i&&(i=d),u<r&&(r=u),c>s&&(s=c),d>n&&(n=d),u>o&&(o=u)}return new m(t+.5*(s-t),i+.5*(n-i),r+.5*(o-r))}static centering(e){let t=Z.getCenter(e);for(let i=0,r=e.length;i<r;i+=3)e[i]-=t.x,e[i+1]-=t.y,e[i+2]-=t.z}setMaterial(e){return e.ambient&&(this.ambient=Dt(e.ambient)),e.diffuse&&(this.diffuse=Dt(e.diffuse)),e.specular&&(this.specular=Dt(e.specular)),e.shininess!==void 0&&(this.shininess=e.shininess),this}centering(){return Z.centering(this._vertices),this}applyMat4(e){for(let t=0,i=this._vertices.length;t<i;t+=3){let r=new m(this._vertices[t],this._vertices[t+1],this._vertices[t+2]),s=new m(this._normals[t],this._normals[t+1],this._normals[t+2]);r=e.mulVec3(r),s=e.mulVec3(s),this._vertices[t]=r.x,this._vertices[t+1]=r.y,this._vertices[t+2]=r.z,this._normals[t]=s.x,this._normals[t+1]=s.y,this._normals[t+2]=s.z}return this}scale(e){return Z.scale(this._vertices,e),this}translate(e){for(let t=0,i=this._vertices.length;t<i;t+=3)this._vertices[t]+=e.x,this._vertices[t+1]+=e.y,this._vertices[t+2]+=e.z;return this}get name(){return this._name}get vertices(){return this._vertices}get normals(){return this._normals}get indices(){return this._indices}get texCoords(){return this._texCoords}get numVertices(){return this._numVertices}static scale(e,t){for(let i=0;i<e.length;i+=3)e[i]*=t.x,e[i+1]*=t.y,e[i+2]*=t.z}static centroid(e){let t=1e3,i=1e3,r=1e3,s=-1e3,n=-1e3,o=-1e3;for(let l=0;l<e.length;l+=3){let h=e[l],c=e[l+1],d=e[l+2];h<t&&(t=h),c<i&&(i=c),d<r&&(r=d),h>s&&(s=h),c>n&&(n=c),d>o&&(o=d)}return[t+.5*(s-t),i+.5*(n-i),r+.5*(o-r)]}static translate(e,t){for(let i=0;i<e.length;i+=3)e[i]+=t[0],e[i+1]+=t[1],e[i+2]+=t[2]}static getNormals(e){let t=new Array(e.length);for(let i=0;i<e.length;i+=9){let r=i,s=i+3,n=i+6,o=e[r],l=e[r+1],h=e[r+2],c=e[s]-o,d=e[s+1]-l,u=e[s+2]-h,g=e[n]-o,f=e[n+1]-l,p=e[n+2]-h,_=d*p-u*f,v=u*g-c*p,x=c*f-d*g,y=Math.sqrt(_*_+v*v+x*x);_/=y,v/=y,x/=y,t[r]=_,t[r+1]=v,t[r+2]=x,t[s]=_,t[s+1]=v,t[s+2]=x,t[n]=_,t[n+1]=v,t[n+2]=x}return t}static createSphere(e=16,t=16,i=1,r=0,s=0,n=0){let o=[],l=[],h=[];for(let c=0;c<=t;c++){let d=c*Math.PI/t,u=Math.sin(d),g=Math.cos(d);for(let f=0;f<=e;f++){let p=2*f*Math.PI/e,_=Math.sin(p),v=Math.cos(p)*u+r,x=g+s,y=_*u+n;h.push(v),h.push(x),h.push(y),o.push(i*v),o.push(i*x),o.push(i*y)}}for(let c=0;c<t;c++)for(let d=0;d<e;d++){let u=c*(e+1)+d,g=u+e+1;l.push(u),l.push(u+1),l.push(g),l.push(g),l.push(u+1),l.push(g+1)}return new Z({vertices:o,normals:h,indices:l})}static createDisc(e=1,t=0,i=8,r=!0,s=0,n=0,o=0,l=0){let h=[],c=[],d=[],u=2*Math.PI,g=r?1:-1,f=s;for(let _=1;_<=i;_++)h.push(n,t*g+o,l),d.push(0,g,0),s++;let p=s;for(let _=0;_<=i;_++){let v=_/i*u+0,x=Math.cos(v),y=Math.sin(v);h.push(e*y+n,t*g+o,e*x+l),d.push(0,g,0),s++}for(let _=0;_<i;_++){let v=f+_,x=p+_;r?c.push(x,x+1,v):c.push(x+1,x,v)}return new Z({vertices:h,normals:d,indices:c})}static getFrustumScaleByCameraAngles(e,t,i){return new m(2*e*Math.tan(Xe*t),2*e*Math.tan(Xe*i),e)}static getFrustumScaleByCameraAspectRatio(e,t,i){let r=ir*Math.atan(Math.tan(Xe*t)/i);return Z.getFrustumScaleByCameraAngles(e,t,r)}static createFrustum(e=1,t=1,i=1,r=0,s=0,n=0){return new Z({vertices:[0+r,0+s,0+n,-1*(t*=.5)+r,1*(i*=.5)+s,-1*e+n,1*t+r,1*i+s,-1*e+n,0+r,0+s,0+n,1*t+r,-1*i+s,-1*e+n,-1*t+r,-1*i+s,-1*e+n,0+r,0+s,0+n,1*t+r,1*i+s,-1*e+n,1*t+r,-1*i+s,-1*e+n,0+r,0+s,0+n,-1*t+r,-1*i+s,-1*e+n,-1*t+r,1*i+s,-1*e+n,0+r,0+s,0+n,1*t+r,1*i+s,-1*e+n,-1*t+r,1*i+s,-1*e+n,0+r,0+s,0+n,-1*t+r,-1*i+s,-1*e+n,1*t+r,-1*i+s,-1*e+n,0+r,0+s,0+n,1*t+r,-1*i+s,-1*e+n,1*t+r,1*i+s,-1*e+n,0+r,0+s,0+n,-1*t+r,1*i+s,-1*e+n,-1*t+r,-1*i+s,-1*e+n]})}static createCylinder(e=1,t=1,i=1,r=32,s=1,n=!0,o=!0,l=0,h=0,c=0){let d=[],u=[],g=[],f=2*Math.PI,p=0,_=[],v=new m,x=(t-e)/i;for(let y=0;y<=s;y++){let w=[],b=y/s,E=b*(t-e)+e;for(let C=0;C<=r;C++){let T=C/r*f+0,L=Math.sin(T),M=Math.cos(T);d.push(E*L+l,-b*i+i+h,E*M+c),v.set(L,x,M).normalize(),g.push(v.x,v.y,v.z),w.push(p++)}_.push(w)}for(let y=0;y<r;y++)for(let w=0;w<s;w++){let b=_[w][y],E=_[w+1][y],C=_[w+1][y+1],T=_[w][y+1];u.push(b,E,T),u.push(E,C,T)}if(e!==0&&n){let y=Z.createDisc(e,i,r,!0,p,l,h,c);d.push(...y.vertices),g.push(...y.normals),u.push(...y.indices)}if(t!==0&&o){let y=Z.createDisc(t,0,r,!1,p+(n?1+2*r:0),l,h,c);d.push(...y.vertices),g.push(...y.normals),u.push(...y.indices)}return new Z({vertices:d,normals:g,indices:u})}static createCube(e=1,t=1,i=1,r=0,s=0,n=0){let o=.5*e+r,l=.5*t+s,h=.5*i+n;return new Z({vertices:[-o,-l,h,o,-l,-h,o,-l,h,-o,-l,h,-o,-l,-h,o,-l,-h,-o,l,h,o,l,h,o,l,-h,-o,l,h,o,l,-h,-o,l,-h,-o,-l,h,o,-l,h,-o,l,h,-o,l,h,o,-l,h,o,l,h,-o,-l,-h,-o,l,-h,o,-l,-h,-o,l,-h,o,l,-h,o,-l,-h,o,-l,h,o,-l,-h,o,l,h,o,l,h,o,-l,-h,o,l,-h,-o,-l,h,-o,l,h,-o,-l,-h,-o,l,h,-o,l,-h,-o,-l,-h]})}static createPlane(e=1,t=1,i=0,r=0,s=0){let n=.5*e,o=.5*t;return new Z({vertices:[-n+i,r,o+s,n+i,r,-o+s,n+i,r,o+s,-n+i,r,o+s,-n+i,r,-o+s,n+i,r,-o+s,-n+i,r,o+s,n+i,r,o+s,n+i,r,-o+s,-n+i,r,o+s,n+i,r,-o+s,-n+i,r,-o+s]})}static createArrow(e=0,t=2.1,i=-15){return new Z({vertices:[0,t,0,7,0,6,0,0,i,0,0,e,7,0,6,0,t,0,-7,0,6,0,0,e,0,t,0,-7,0,6,0,t,0,0,0,i,-7,0,6,0,0,i,0,0,e,0,0,e,0,0,i,7,0,6]})}static async readFileObj(e,t,i){const r=await new _n().readFile(e,t);let s=r.materials;return r.geometries.map(n=>{let o=s[n.material]||{};return new Z({name:n.object,vertices:n.data.vertices,normals:n.data.normals,texCoords:n.data.texCoords,ambient:o.ambient,diffuse:o.diffuse,specular:o.specular,shininess:o.shininess,color:o.color,colorTextureSrc:i?`${i}/${o.colorTexture}`:o.colorTexture,normalTextureSrc:i?`${i}/${o.normalTexture}`:o.normalTexture,metallicRoughnessTextureSrc:i?`${i}/${o.metallicRoughnessTexture}`:o.metallicRoughnessTexture})})}static async loadObj(e){const t=await new _n().load(e);let i=t.materials;return t.geometries.map(r=>{let s=i[r.material]||{};return new Z({name:r.object,vertices:r.data.vertices,normals:r.data.normals,texCoords:r.data.texCoords,ambient:s.ambient,diffuse:s.diffuse,specular:s.specular,shininess:s.shininess,color:s.color,colorTextureSrc:s.colorTexture,normalTextureSrc:s.normalTexture,metallicRoughnessTextureSrc:s.metallicRoughnessTexture})})}merge(e){const t=this._vertices.length/3;let i=this._vertices.length;this._vertices.length=i+e._vertices.length;for(let r=0;r<e._vertices.length;r++)this._vertices[i+r]=e._vertices[r];i=this._normals.length,this._normals.length=i+e._normals.length;for(let r=0;r<e._normals.length;r++)this._normals[i+r]=e._normals[r];i=this._texCoords.length,this._texCoords.length=i+e._texCoords.length;for(let r=0;r<e._texCoords.length;r++)this._texCoords[i+r]=e._texCoords[r];i=this._indices.length,this._indices.length=i+e._indices.length;for(let r=0;r<e._indices.length;r++)this._indices[i+r]=e._indices[r]+t;return this._numVertices=this._vertices.length/3,this}static merge(e,t){let i=new Z,r=t||e.length;for(let s=0;s<r;s++)i.merge(e[s]);return i}}const wl=new m(0,0,-1),fn=class Io{constructor(e){var t,i;this._handlerIndex=-1,this._tag=e.tag||"tag_"+Io.__counter__++,this._entity=null,this._position=je(e.position),this._rtcPositionHigh=new m,this._rtcPositionLow=new m,this._scale=je(e.scale,new m(1,1,1)),this._translate=je(e.translate,new m),this._localPosition=new m;const[r=.15,s=.15,n=.15,o=1]=(t=e.object3d)!=null&&t.color?Array.from(e.object3d.color):[];this._color=rt(e.color,new te(r,s,n,o)),this._handler=null,this._handlerIndex=-1,this._tagData=null,this._tagDataIndex=-1;let l=e.object3d;e.object3d&&((i=e.object3d)==null?void 0:i.vertices.length)!==0||(l=new Z),e.objSrc&&(this.setObjectSrc(e.objSrc),this._objectSrc=e.objSrc),this._object3d=l,this._visibility=e.visibility==null||e.visibility,this._children=[],this._direction=new m,this._qFrame=new O,this._qRot=O.IDENTITY}get tag(){return this._tag}getPosition(){return this._position}get object3d(){return this._object3d}get vertices(){return this._object3d.vertices}get normals(){return this._object3d.normals}get texCoords(){return this._object3d.texCoords}get indices(){return this._object3d.indices}setOpacity(e){this._color.w=e,this.setColor(this._color.x,this._color.y,this._color.z,e)}getOpacity(){return this._color.w}setColor(e,t,i,r){this._color.x=e,this._color.y=t,this._color.z=i,r!=null&&(this._color.w=r),this._handler&&this._handler.setRgbaArr(this._tagData,this._tagDataIndex,this._color)}setColor4v(e){this._color.x=e.x,this._color.y=e.y,this._color.z=e.z,e.w!=null&&(this._color.w=e.w),this._handler&&this._handler.setRgbaArr(this._tagData,this._tagDataIndex,this._color)}setVisibility(e){this._visibility=e,this._handler&&this._handler.setVisibility(this._tagData,this._tagDataIndex,e)}getVisibility(){return this._visibility}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,this.updateRTCPosition(),this.updateRotation()}updateRTCPosition(){this._handler&&(this._handler.getRTCPosition(this._position,this._rtcPositionHigh,this._rtcPositionLow),this._handler.setRTCPositionArr(this._tagData,this._tagDataIndex,this._rtcPositionHigh,this._rtcPositionLow))}setPosition3v(e){this.setPosition(e.x,e.y,e.z)}setObject(e){this._object3d=e}setObjectSrc(e){this._objectSrc=e,this._handler&&this._handler.setObjectSrc(e,this.tag)}setColorHTML(e){this.setColor4v(it(e))}setScale(e){this._scale.x=this._scale.y=this._scale.z=e,this._handler&&this._handler.setScaleArr(this._tagData,this._tagDataIndex,this._scale)}setScale3v(e){this._scale.copy(e),this._handler&&this._handler.setScaleArr(this._tagData,this._tagDataIndex,e)}getScale(){return this._scale}setTranslate3v(e){this._translate.copy(e),this._handler&&this._handler.setTranslateArr(this._tagData,this._tagDataIndex,e)}getTranslate(){return this._translate.clone()}setLocalPosition3v(e){this._localPosition.copy(e),this._handler&&this._handler.setLocalPositionArr(this._tagData,this._tagDataIndex,e)}getLocalPosition(){return this._localPosition.clone()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._handler&&this._handler.setPickingColorArr(this._tagData,this._tagDataIndex,e)}setRotation(e){this._qRot.copy(e),this._qRot.mulVec3Res(wl,this._direction).normalize(),this.updateRotation()}getRotation(){return this._qRot}updateRotation(){this._handler&&this._handler.setQRotArr(this._tagData,this._tagDataIndex,this._qRot)}getDirection(){return this._direction.clone()}};fn.__counter__=0;let gn=fn;const ti={RIGHT:0,LEFT:1,CENTER:2},pn={left:ti.LEFT,right:ti.RIGHT,center:ti.CENTER};class mn extends hn{constructor(e={}){super(e),this._handler=null,this._text=e.text||"",this._face=Fs(e.face,"arial"),this._size=e.size||24,this._outline=e.outline!=null?e.outline:0,this._outlineColor=rt(e.outlineColor,new te(0,0,0,1)),this._align=e.align&&pn[e.align.trim().toLowerCase()]||ti.RIGHT,this._fontIndex=0,this._fontAtlas=null,this._isRTL=e.isRTL||!1,this._letterSpacing=e.letterSpacing||0}setText(e){this._text=e.toString(),this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,e,this._fontIndex,this._align,this._letterSpacing,this._isRTL)}setLetterSpacing(e){this._letterSpacing=e,this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,e,this._isRTL)}getLetterSpacing(){return this._letterSpacing}setRtl(e){this._isRTL=e,this._isReady&&this._handler&&this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL)}getText(){return this._text}setAlign(e){this._align=pn[e.trim().toLowerCase()],this._isReady&&this._handler?this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL):this._lockId!==-1&&(this._lockId=-2)}getAlign(){return this._align}setFace(e){this._face=e.trim(),this.update()}getFace(){return this._face}setSize(e){e!==this._size&&(this._size=e,this._isReady&&this._handler?this._handler.setSizeArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2))}getSize(){return this._size}setOutline(e){this._outline=e,this._isReady&&this._handler?this._handler.setOutlineArr(this._handlerIndex,e):this._lockId!==-1&&(this._lockId=-2)}getOutline(){return this._outline}setOpacity(e){super.setOpacity(e),this.setOutlineOpacity(e)}setOutlineColor(e,t,i,r){r===this._outlineColor.w&&e===this._outlineColor.x&&t===this._outlineColor.y&&i===this._outlineColor.z||(this._outlineColor.x=e,this._outlineColor.y=t,this._outlineColor.z=i,this._outlineColor.w=r,this._isReady&&this._handler?this._handler.setOutlineColorArr(this._handlerIndex,this._outlineColor):this._lockId!==-1&&(this._lockId=-2))}setOutlineColor4v(e){this.setOutlineColor(e.x,e.y,e.z,e.w)}setOutlineColorHTML(e){this.setOutlineColor4v(it(e))}getOutlineColor(){return this._outlineColor}setOutlineOpacity(e){e!==this._outlineColor.w&&(this._outlineColor.w=e,this._isReady&&this._handler?this._handler.setOutlineColorArr(this._handlerIndex,this._outlineColor):this._lockId!==-1&&(this._lockId=-2))}getOutlineOpacity(){return this._outlineColor.w}async update(){if(this._fontAtlas){const e=await this._fontAtlas.getFontIndex(this._face);this._applyFontIndex(e)}}_applyFontIndex(e){this._fontIndex=e,this._isReady&&this._handler?(this._handler.setFontIndexArr(this._handlerIndex,this._fontIndex),this._handler.setText(this._handlerIndex,this._text,this._fontIndex,this._align,this._letterSpacing,this._isRTL)):this._lockId!==-1&&(this._lockId=-2)}assignFontAtlas(e){this._fontAtlas||(this._fontAtlas=e),this.update()}serializeWorkerData(e){return this._handler?new Float32Array([e,this._handler._maxLetters,this.getVisibility()?1:0,this._positionHigh.x,this._positionHigh.y,this._positionHigh.z,this._positionLow.x,this._positionLow.y,this._positionLow.z,this._size,this._offset.x,this._offset.y,this._offset.z,this._color.x,this._color.y,this._color.z,this._color.w,this._rotation,this._alignedAxis.x,this._alignedAxis.y,this._alignedAxis.z,this._fontIndex,this._outline,this._outlineColor.x,this._outlineColor.y,this._outlineColor.z,this._outlineColor.w,this._entity._pickingColor.x,this._entity._pickingColor.y,this._entity._pickingColor.z]):null}}const vn=class zo{constructor(e={}){this.__id=zo.__counter__++,this.visibility=e.visibility==null||e.visibility,this.pointSize=e.pointSize||3,this.pickingScale=e.pickingScale||0,this._renderNode=null,this._entity=null,this._points=[],this._coordinatesData=[],this._colorData=[],this._pickingColorData=[],this._coordinatesBuffer=null,this._colorBuffer=null,this._pickingColorBuffer=null,this._handler=null,this._handlerIndex=-1,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this._createCoordinatesBuffer,this._buffersUpdateCallbacks[1]=this._createColorBuffer,this._buffersUpdateCallbacks[2]=this._createPickingColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length),e.points&&this.setPoints(e.points)}clear(){this._points.length=0,this._points=[],this._coordinatesData.length=0,this._coordinatesData=[],this._colorData.length=0,this._colorData=[],this._pickingColorData.length=0,this._pickingColorData=[],this._deleteBuffers()}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){this._renderNode=e,this._setPickingColors()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPoints(e){this.clear();for(let t=0;t<e.length;t++){let i=e[t],r=new m(i[0],i[1],i[2]),s=new te(i[3],i[4],i[5],i[6]==null?255:i[6]);this._coordinatesData.push(r.x,r.y,r.z),this._colorData.push(s.x/255,s.y/255,s.z/255,s.w/255);let n={_entity:this._entity,_pickingColor:new m,_entityCollection:this._entity?this._entity._entityCollection:null,index:t,position:r,color:s,pointCloud:this,properties:i[7]||{}};this._points.push(n),this._renderNode&&this._renderNode.renderer&&(this._renderNode.renderer.assignPickingColor(n),this._pickingColorData.push(n._pickingColor.x/255,n._pickingColor.y/255,n._pickingColor.z/255,1))}this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}setPointPosition(e,t,i,r){this._changedBuffers[0]=!0}setPointColor(e,t,i,r,s){this._changedBuffers[1]=!0}addPoints(e){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}addPoint(e,t){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}getPoint(e){return this._points[e]}removePoint(e){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}insertPoint(e,t){this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0}draw(){if(this.visibility&&this._coordinatesData.length){this._update();let e=this._renderNode.renderer,t=e.handler.programs.pointCloud,i=t._program,r=e.handler.gl,s=i.attributes,n=i.uniforms;t.activate(),r.uniformMatrix4fv(n.projectionViewMatrix,!1,e.activeCamera.getProjectionViewMatrix()),r.uniform1f(n.opacity,this._handler._entityCollection._fadingOpacity),r.uniform1f(n.pointSize,this.pointSize),r.bindBuffer(r.ARRAY_BUFFER,this._coordinatesBuffer),r.vertexAttribPointer(s.coordinates,this._coordinatesBuffer.itemSize,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this._colorBuffer),r.vertexAttribPointer(s.colors,this._colorBuffer.itemSize,r.FLOAT,!1,0,0),r.drawArrays(r.POINTS,0,this._coordinatesBuffer.numItems)}}drawPicking(){if(this.visibility&&this._coordinatesData.length){let e=this._renderNode.renderer,t=e.handler.programs.pointCloud,i=t._program,r=e.handler.gl,s=i.attributes,n=i.uniforms;t.activate(),r.uniformMatrix4fv(n.projectionViewMatrix,!1,e.activeCamera.getProjectionViewMatrix()),r.uniform1f(n.opacity,this._handler._entityCollection._fadingOpacity),r.uniform1f(n.pointSize,this.pointSize+this.pickingScale),r.bindBuffer(r.ARRAY_BUFFER,this._coordinatesBuffer),r.vertexAttribPointer(s.coordinates,this._coordinatesBuffer.itemSize,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this._pickingColorBuffer),r.vertexAttribPointer(s.colors,this._pickingColorBuffer.itemSize,r.FLOAT,!1,0,0),r.drawArrays(r.POINTS,0,this._coordinatesBuffer.numItems)}}_update(){if(this._renderNode){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}_deleteBuffers(){if(this._renderNode){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._coordinatesBuffer),e.deleteBuffer(this._colorBuffer),e.deleteBuffer(this._pickingColorBuffer)}this._coordinatesBuffer=null,this._colorBuffer=null,this._pickingColorBuffer=null}_createCoordinatesBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._coordinatesBuffer),this._coordinatesBuffer=e.createArrayBuffer(new Float32Array(this._coordinatesData),3,this._coordinatesData.length/3)}_createColorBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._colorBuffer),this._colorBuffer=e.createArrayBuffer(new Float32Array(this._colorData),4,this._colorData.length/4)}_createPickingColorBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorBuffer=e.createArrayBuffer(new Float32Array(this._pickingColorData),4,this._pickingColorData.length/4)}_setPickingColors(){if(this._renderNode&&this._renderNode.renderer){for(let e=0;e<this._points.length;e++){let t=this._points[e];t._entity=this._entity,t._entityCollection=this._entity._entityCollection,this._renderNode.renderer.assignPickingColor(t),this._pickingColorData.push(t._pickingColor.x/255,t._pickingColor.y/255,t._pickingColor.z/255,1)}this._changedBuffers[2]=!0}}};vn.__counter__=0;let Cl=vn;const yn=class vs{constructor(e={}){this.__id=vs.__counter__++,this.__doubleToTwoFloats=m.doubleToTwoFloats,this.altitude=e.altitude||0,this.thickness=e.thickness||1.5,this._opacity=e.opacity!=null?e.opacity:1,this._defaultColor=_t(e.color||"#0000FF",e.opacity),this.visibility=e.visibility==null||e.visibility,this._closedLine=e.isClosed||!1,this._path3v=[],this._pathLengths=[],this._pathLonLat=[],this._pathLonLatMerc=[],this._pathColors=e.pathColors?yr(e.pathColors):[],this._extent=new j,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._ordersBuffer=null,this._indexesBuffer=null,this._colorsBuffer=null,this._pickingColor=[0,0,0],this._renderNode=null,this._entity=null,this._handler=null,this._handlerIndex=-1,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this._createVerticesBuffer,this._buffersUpdateCallbacks[1]=this._createIndexBuffer,this._buffersUpdateCallbacks[2]=this._createColorsBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length);let t=je(e.visibleSpherePosition).toArray(),i=e.visibleSphereRadius||0;this._visibleSphere=new Float32Array([...t,i]),e.pathLonLat?this.setPathLonLat(e.pathLonLat):e.path3v&&this.setPath3v(e.path3v),this._refresh()}__appendLineData3v(e,t,i,r,s,n,o,l,h,c,d,u,g,f){var p=0,_=new m,v=new m;g&&(g.southWest.set(180,90),g.northEast.set(-180,-90)),l.length>0?(p=l[l.length-5]+9,l.push(p,p)):l.push(0,0);for(let R=0,z=e.length;R<z;R++){var x=e[R],y=t[R];if(c[R]=[],u[R]=[],d[R]=[],x.length===0)continue;var w,b=p;if(r)(w=x[x.length-1])instanceof Array&&(w=new m(w[0],w[1],w[2]));else{var E=x[0],C=x[1]||E;E instanceof Array&&(E=new m(E[0],E[1],E[2])),C instanceof Array&&(C=new m(C[0],C[1],C[2])),w=new m(E.x+E.x-C.x,E.y+E.y-C.y,E.z+E.z-C.z)}let F=i;y&&y[0]&&(F=y[0]),this.__doubleToTwoFloats(w,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z);let P=F[0],D=F[1],k=F[2],I=F[3]!=null?F[3]:1;R>0&&f.push(P,D,k,I,P,D,k,I,P,D,k,I,P,D,k,I),o.push(1,-1,2,-2);for(let B=0,G=x.length;B<G;B++){var T=x[B];if(T instanceof Array&&(T=new m(T[0],T[1],T[2])),d[R].push(T),h){var L=h.cartesianToLonLat(T);c[R].push(L),u[R].push(L.forwardMercator()),L.lon<g.southWest.lon&&(g.southWest.lon=L.lon),L.lat<g.southWest.lat&&(g.southWest.lat=L.lat),L.lon>g.northEast.lon&&(g.northEast.lon=L.lon),L.lat>g.northEast.lat&&(g.northEast.lat=L.lat)}y&&y[B]&&(F=y[B]),P=F[0],D=F[1],k=F[2],I=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(T,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z),f.push(P,D,k,I,P,D,k,I,P,D,k,I,P,D,k,I),o.push(1,-1,2,-2),l.push(p++,p++,p++,p++)}var M;if(r)(M=x[0])instanceof Array&&(M=new m(M[0],M[1],M[2])),l.push(b,b+1,b+1,b+1);else{let B=x[x.length-1],G=x[x.length-2]||B;B instanceof Array&&(B=new m(B[0],B[1],B[2])),G instanceof Array&&(G=new m(G[0],G[1],G[2])),M=new m(B.x+B.x-G.x,B.y+B.y-G.y,B.z+B.z-G.z),l.push(p-1,p-1,p-1,p-1)}y&&y[x.length-1]&&(F=y[x.length-1]),P=F[0],D=F[1],k=F[2],I=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(M,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z),f.push(P,D,k,I,P,D,k,I,P,D,k,I,P,D,k,I),o.push(1,-1,2,-2),R<e.length-1&&e[R+1].length!==0&&(p+=8,l.push(p,p))}}__appendPoint3v(e,t,i,r,s,n,o,l,h,c,d,u,g,f){var p=new m,_=new m,v=c.length-4,x=c[v-1]+1;e.length===0?(e.push([]),i[0]||(i[0]=[])):i[e.length-1]||(i[e.length-1]=[]);var y=e[e.length-1],w=y.length;y.push(t);let b=r[0],E=r[1],C=r[2],T=r[3]!=null?r[3]:1,L=i[e.length-1];if(L[w]?(L[w][0]=b,L[w][1]=E,L[w][2]=C,L[w][3]=T):L.push(r),w===1){var M;if(s)(M=y[w-1])instanceof Array&&(M=new m(M[0],M[1],M[2]));else{let B=y[0],G=y[1]||B;B instanceof Array&&(B=new m(B[0],B[1],B[2])),G instanceof Array&&(G=new m(G[0],G[1],G[2])),M=new m(B.x+B.x-G.x,B.y+B.y-G.y,B.z+B.z-G.z)}this.__doubleToTwoFloats(M,p,_);let I=n.length-36;n[I]=p.x,n[I+1]=p.y,n[I+2]=p.z,n[I+3]=p.x,n[I+4]=p.y,n[I+5]=p.z,n[I+6]=p.x,n[I+7]=p.y,n[I+8]=p.z,n[I+9]=p.x,n[I+10]=p.y,n[I+11]=p.z,o[I]=_.x,o[I+1]=_.y,o[I+2]=_.z,o[I+3]=_.x,o[I+4]=_.y,o[I+5]=_.z,o[I+6]=_.x,o[I+7]=_.y,o[I+8]=_.z,o[I+9]=_.x,o[I+10]=_.y,o[I+11]=_.z}var R=x;if(d){u.length===0&&u.push([]),g.length===0&&g.push([]);var z=u[u.length-1],F=g[g.length-1];let I=d.cartesianToLonLat(t);z.push(I),F.push(I.forwardMercator()),I.lon<f.southWest.lon&&(f.southWest.lon=I.lon),I.lat<f.southWest.lat&&(f.southWest.lat=I.lat),I.lon>f.northEast.lon&&(f.northEast.lon=I.lon),I.lat>f.northEast.lat&&(f.northEast.lat=I.lat)}this.__doubleToTwoFloats(t,p,_);let P=n.length-12;n[P]=p.x,n[P+1]=p.y,n[P+2]=p.z,n[P+3]=p.x,n[P+4]=p.y,n[P+5]=p.z,n[P+6]=p.x,n[P+7]=p.y,n[P+8]=p.z,n[P+9]=p.x,n[P+10]=p.y,n[P+11]=p.z,o[P]=_.x,o[P+1]=_.y,o[P+2]=_.z,o[P+3]=_.x,o[P+4]=_.y,o[P+5]=_.z,o[P+6]=_.x,o[P+7]=_.y,o[P+8]=_.z,o[P+9]=_.x,o[P+10]=_.y,o[P+11]=_.z;let D=l.length-16;var k;if(l[D]=b,l[D+1]=E,l[D+2]=C,l[D+3]=T,l[D+4]=b,l[D+5]=E,l[D+6]=C,l[D+7]=T,l[D+8]=b,l[D+9]=E,l[D+10]=C,l[D+11]=T,l[D+12]=b,l[D+13]=E,l[D+14]=C,l[D+15]=T,c[v]=x++,c[v+1]=x++,c[v+2]=x++,c[v+3]=x++,s)k=y[0],c.push(R,R+1,R+1,R+1);else{let I=y[y.length-1],B=y[y.length-2]||I;k=new m(I.x+I.x-B.x,I.y+I.y-B.y,I.z+I.z-B.z),c.push(x-1,x-1,x-1,x-1)}this.__doubleToTwoFloats(k,p,_),n.push(p.x,p.y,p.z,p.x,p.y,p.z,p.x,p.y,p.z,p.x,p.y,p.z),o.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),l.push(b,E,C,T,b,E,C,T,b,E,C,T,b,E,C,T),h.push(1,-1,2,-2)}static setPathColors(e,t,i,r){for(let l=0,h=e.length;l<h;l++){var s=e[l],n=t[l];if(s.length===0)continue;let c=i;n&&n[0]&&(c=n[0]);let d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1;l>0&&r.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f);for(let p=0,_=s.length;p<_;p++){var o=s[p];o instanceof Array&&(o=new A(o[0],o[1],o[2])),n&&n[p]&&(c=n[p]),d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1,r.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f)}n&&n[s.length-1]&&(c=n[s.length-1]),d=c[0],u=c[1],g=c[2],f=c[3]!=null?c[3]:1,r.push(d,u,g,f,d,u,g,f,d,u,g,f,d,u,g,f)}}__appendLineDataLonLat(e,t,i,r,s,n,o,l,h,c,d,u,g,f){var p=0,_=new m,v=new m;g&&(g.southWest.set(180,90),g.northEast.set(-180,-90)),l.length>0?(p=l[l.length-5]+9,l.push(p)):l.push(0);for(let L=0,M=e.length;L<M;L++){var x=e[L],y=t[L];if(c[L]=[],u[L]=[],d[L]=[],x.length===0)continue;var w,b=p;if(r){let k=x[x.length-1];w=k instanceof Array?h.lonLatToCartesian(new A(k[0],k[1],k[2])):h.lonLatToCartesian(k)}else{let k,I,B=x[0];k=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),B=x[1],B||(B=x[0]),I=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),w=new m(k.x+k.x-I.x,k.y+k.y-I.y,k.z+k.z-I.z)}let R=i;y&&y[0]&&(R=y[0]),this.__doubleToTwoFloats(w,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z);let z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1;L>0&&f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2);for(let k=0,I=x.length;k<I;k++){var E=x[k];E instanceof Array&&(E=new A(E[0],E[1],E[2])),y&&y[k]&&(R=y[k]),z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1;var C=h.lonLatToCartesian(E);c[L].push(C),d[L].push(E),u[L].push(E.forwardMercator()),this.__doubleToTwoFloats(C,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z),f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2),l.push(p++,p++,p++,p++),E.lon<g.southWest.lon&&(g.southWest.lon=E.lon),E.lat<g.southWest.lat&&(g.southWest.lat=E.lat),E.lon>g.northEast.lon&&(g.northEast.lon=E.lon),E.lat>g.northEast.lat&&(g.northEast.lat=E.lat)}var T;if(r){let k=x[0];T=k instanceof Array?h.lonLatToCartesian(new A(k[0],k[1],k[2])):h.lonLatToCartesian(k),l.push(b,b+1,b+1,b+1)}else{let k,I,B=x[x.length-1];k=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),B=x[x.length-2],B||(B=x[0]),I=B instanceof Array?h.lonLatToCartesian(new A(B[0],B[1],B[2])):h.lonLatToCartesian(B),T=new m(k.x+k.x-I.x,k.y+k.y-I.y,k.z+k.z-I.z),l.push(p-1,p-1,p-1,p-1)}y&&y[x.length-1]&&(R=y[x.length-1]),z=R[0],F=R[1],P=R[2],D=R[3]!=null?R[3]:1,this.__doubleToTwoFloats(T,_,v),s.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),n.push(v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z,v.x,v.y,v.z),f.push(z,F,P,D,z,F,P,D,z,F,P,D,z,F,P,D),o.push(1,-1,2,-2),L<e.length-1&&e[L+1].length!==0&&(p+=8,l.push(p,p))}}_setEqualPath3v(e){var t=this._extent;t.southWest.set(180,90),t.northEast.set(-180,-90);var i=new m,r=new m,s=this._verticesHigh,n=this._verticesLow,o=this._pathLonLat,l=this._pathLonLatMerc,h=0,c=this._renderNode.ellipsoid;for(let x=0;x<e.length;x++){var d,u,g=e[x];d=this._closedLine?g[g.length-1]:new m(g[0].x+g[0].x-g[1].x,g[0].y+g[0].y-g[1].y,g[0].z+g[0].z-g[1].z),this.__doubleToTwoFloats(d,i,r),s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z;for(let y=0;y<g.length;y++){var f=g[y],p=this._path3v[x][y];if(p.x=f.x,p.y=f.y,p.z=f.z,c){var _=c.cartesianToLonLat(f);this._pathLonLat[x][y]=_,o[x][y]=_,l[x][y]=_.forwardMercator(),_.lon<t.southWest.lon&&(t.southWest.lon=_.lon),_.lat<t.southWest.lat&&(t.southWest.lat=_.lat),_.lon>t.northEast.lon&&(t.northEast.lon=_.lon),_.lat>t.northEast.lat&&(t.northEast.lat=_.lat)}this.__doubleToTwoFloats(f,i,r),s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z}if(this._closedLine)u=g[0];else{var v=g.length-1;u=new m(g[v].x+g[v].x-g[v-1].x,g[v].y+g[v].y-g[v-1].y,g[v].z+g[v].z-g[v-1].z)}this.__doubleToTwoFloats(u,i,r),s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z,s[h]=i.x,n[h++]=r.x,s[h]=i.y,n[h++]=r.y,s[h]=i.z,n[h++]=r.z}}_setEqualPathLonLat(e){var t=this._extent;t.southWest.set(180,90),t.northEast.set(-180,-90);var i=new m,r=new m,s=this._verticesHigh,n=this._verticesLow,o=this._pathLonLat,l=this._pathLonLatMerc,h=this._path3v,c=0,d=this._renderNode.ellipsoid;for(let v=0;v<e.length;v++){var u,g,f=e[v];if(this._closedLine)u=d.lonLatToCartesian(f[f.length-1]);else{let x=d.lonLatToCartesian(f[0]),y=d.lonLatToCartesian(f[1]);u=new m(x.x+x.x-y.x,x.y+x.y-y.y,x.z+x.z-y.z)}this.__doubleToTwoFloats(u,i,r),s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z;for(let x=0;x<f.length;x++){var p=f[x],_=d.lonLatToCartesian(p);h[v][x]=_,l[v][x]=p.forwardMercator(),o[v][x]=p,this.__doubleToTwoFloats(_,i,r),s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,p.lon<t.southWest.lon&&(t.southWest.lon=p.lon),p.lat<t.southWest.lat&&(t.southWest.lat=p.lat),p.lon>t.northEast.lon&&(t.northEast.lon=p.lon),p.lat>t.northEast.lat&&(t.northEast.lat=p.lat)}if(this._closedLine)g=d.lonLatToCartesian(f[0]);else{let x=d.lonLatToCartesian(f[f.length-1]),y=d.lonLatToCartesian(f[f.length-2]);g=new m(x.x+x.x-y.x,x.y+x.y-y.y,x.z+x.z-y.z)}this.__doubleToTwoFloats(g,i,r),s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z,s[c]=i.x,n[c++]=r.x,s[c]=i.y,n[c++]=r.y,s[c]=i.z,n[c++]=r.z}}setPointLonLat(e,t,i){if(this._renderNode&&this._renderNode.ellipsoid){let l=this._pathLonLat,h=this._pathLonLatMerc;l[i][t]=e,h[i][t]=e.forwardMercator();var r=this._extent;r.southWest.set(180,90),r.northEast.set(-180,-90);for(let c=0;c<l.length;c++){var s=l[c];for(let d=0;d<s.length;d++){var n=s[d].lon,o=s[d].lat;n>r.northEast.lon&&(r.northEast.lon=n),o>r.northEast.lat&&(r.northEast.lat=o),n<r.southWest.lon&&(r.southWest.lon=n),o<r.southWest.lat&&(r.southWest.lat=o)}}this.setPoint3v(this._renderNode.ellipsoid.lonLatToCartesian(e),t,i,!0)}else{let l=this._pathLonLat[i];l[t].lon=e.lon,l[t].lat=e.lat,l[t].height=e.height}}setPoint3v(e,t=0,i=0,r=!1){if(this._renderNode){var s,n=new m,o=new m,l=this._verticesHigh,h=this._verticesLow,c=this._pathLonLat,d=this._pathLonLatMerc,u=0;s=12*this._pathLengths[i]+24*i;let b=this._path3v[i];b[t].x=e.x,b[t].y=e.y,b[t].z=e.z;let E=this._closedLine||b.length===1;var g;if((t===0||t===1)&&(g=E?b[b.length-1]:new m(b[0].x+b[0].x-b[1].x,b[0].y+b[0].y-b[1].y,b[0].z+b[0].z-b[1].z),u=s,this.__doubleToTwoFloats(g,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z),!r&&this._renderNode.ellipsoid){var f=this._renderNode.ellipsoid.cartesianToLonLat(e);c[i][t]=f,d[i][t]=f.forwardMercator();var p=this._extent;p.southWest.set(180,90),p.northEast.set(-180,-90);for(let C=0;C<c.length;C++){var _=c[C];for(let T=0;T<_.length;T++){var v=_[T].lon,x=_[T].lat;v>p.northEast.lon&&(p.northEast.lon=v),x>p.northEast.lat&&(p.northEast.lat=x),v<p.southWest.lon&&(p.southWest.lon=v),x<p.southWest.lat&&(p.southWest.lat=x)}}}if(u=s+12*t+12,this.__doubleToTwoFloats(e,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z,t===b.length-1||t===b.length-2){var y;if(E)y=b[0];else{var w=b.length-1;y=new m(b[w].x+b[w].x-b[w-1].x,b[w].y+b[w].y-b[w-1].y,b[w].z+b[w].z-b[w-1].z)}u=s+12*b.length+12,this.__doubleToTwoFloats(y,n,o),l[u]=n.x,l[u+1]=n.y,l[u+2]=n.z,l[u+3]=n.x,l[u+4]=n.y,l[u+5]=n.z,l[u+6]=n.x,l[u+7]=n.y,l[u+8]=n.z,l[u+9]=n.x,l[u+10]=n.y,l[u+11]=n.z,h[u]=o.x,h[u+1]=o.y,h[u+2]=o.z,h[u+3]=o.x,h[u+4]=o.y,h[u+5]=o.z,h[u+6]=o.x,h[u+7]=o.y,h[u+8]=o.z,h[u+9]=o.x,h[u+10]=o.y,h[u+11]=o.z}this._changedBuffers[0]=!0}else{let b=this._path3v[i];b[t].x=e.x,b[t].y=e.y,b[t].z=e.z}}_resizePathLengths(e=0){this._pathLengths[0]=0;for(let t=e+1,i=this._path3v.length;t<=i;t++)this._pathLengths[t]=this._pathLengths[t-1]+this._path3v[t-1].length}removeSegment(e){this._path3v.splice(e,1),this.setPath3v([].concat(this._path3v))}removePoint(e,t=0){this._path3v[t].splice(e,1),this._path3v[t].length===0&&this._path3v.splice(t,1),this.setPath3v([].concat(this._path3v))}insertPoint3v(e,t=0,i,r=0){let s=[].concat(this._path3v),n=s[r];if(n){let o=[].concat(this._pathColors);if(n.splice(t,0,e),i){let l=o[r];l||(l=new Array(n.length)),l.splice(t,0,i)}this.setPath3v(s,o)}else this.addPoint3v(e,r)}appendPoint3v(e,t,i){this._path3v.length!==0&&this._renderNode?(this._verticesHigh=It(this._verticesHigh),this._verticesLow=It(this._verticesLow),this._colors=It(this._colors),this._orders=It(this._orders),this._indexes=It(this._indexes),this.__appendPoint3v(this._path3v,e,this._pathColors,t||this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._colors,this._orders,this._indexes,i?null:this._renderNode.ellipsoid,this._pathLonLat,this._pathLonLatMerc,this._extent),this._pathLengths[this._path3v.length]+=1,this._changedBuffers[0]=!0,this._changedBuffers[2]=!0,this._changedBuffers[1]=!0):(this._pathColors.push([t||this._defaultColor]),this.addPoint3v(e))}addPoint3v(e,t=0){t>=this._path3v.length&&this._path3v.push([]),this._path3v[t].push(e),this.setPath3v([].concat(this._path3v))}addPointLonLat(e,t=0){t>=this._pathLonLat.length&&this._pathLonLat.push([]),this._pathLonLat[t].push(e),this.setPathLonLat([].concat(this._pathLonLat))}clear(){this._clearData()}setPointColor(e,t=0,i=0){if(this._renderNode&&t<this._path3v[i].length){let r=this._pathColors[i];if(!r){if(!(this._path3v[i]&&t<this._path3v[i].length))return;this._pathColors[i]=new Array(this._path3v[i].length)}r[t]?(r[t][0]=e[0],r[t][1]=e[1],r[t][2]=e[2],r[t][3]=e[3]||1):r[t]=[e[0],e[1],e[2],e[3]||1];let s=this._colors,n=16*t+16*this._pathLengths[i]+32*i;s[n]=s[n+4]=s[n+8]=s[n+12]=e[0],s[n+1]=s[n+5]=s[n+9]=s[n+13]=e[1],s[n+2]=s[n+6]=s[n+10]=s[n+14]=e[2],s[n+3]=s[n+7]=s[n+11]=s[n+15]=e[3]||1,this._changedBuffers[2]=!0}else this._pathColors[i][t]=e}setOpacity(e){this._opacity=e}getOpacity(){return this._opacity}setAltitude(e){this.altitude=e}setThickness(e){this.thickness=e}getThickness(){return this.thickness}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){e&&(this._renderNode=e,this._pathLonLat.length?this._createDataLonLat([].concat(this._pathLonLat)):this._createData3v([].concat(this._path3v)),this._refresh(),e.renderer&&e.renderer.isInitialized()&&this._update())}_clearData(){this._verticesHigh=null,this._verticesLow=null,this._orders=null,this._indexes=null,this._colors=null,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._path3v.length=0,this._pathLonLat.length=0,this._pathLonLatMerc.length=0,this._path3v=[],this._pathLonLat=[],this._pathLonLatMerc=[]}_createData3v(e){this._clearData(),this.__appendLineData3v(e,this._pathColors,this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._orders,this._indexes,this._renderNode.ellipsoid,this._pathLonLat,this._path3v,this._pathLonLatMerc,this._extent,this._colors),this._resizePathLengths(0)}_createDataLonLat(e){this._clearData(),this.__appendLineDataLonLat(e,this._pathColors,this._defaultColor,this._closedLine,this._verticesHigh,this._verticesLow,this._orders,this._indexes,this._renderNode.ellipsoid,this._path3v,this._pathLonLat,this._pathLonLatMerc,this._extent,this._colors),this._resizePathLengths(0)}remove(){this._entity=null,this._pathColors.length=0,this._pathColors=[],this._verticesHigh=null,this._verticesLow=null,this._orders=null,this._indexes=null,this._colors=null,this._verticesHigh=[],this._verticesLow=[],this._orders=[],this._indexes=[],this._colors=[],this._deleteBuffers(),this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._pickingColor[0]=e.x/255,this._pickingColor[1]=e.y/255,this._pickingColor[2]=e.z/255}getExtent(){return this._extent.clone()}getPath3v(){return this._path3v}getPathLonLat(){return this._pathLonLat}getPathColors(){return this._pathColors}setPathColors(e){e&&(this._colors=[],this._pathColors=[].concat(e),vs.setPathColors(this._pathLonLat,e,this._defaultColor,this._colors),this._changedBuffers[2]=!0)}setColorHTML(e){this._defaultColor=_t(e);let t=it(e),i=this._pathColors;for(let s=0,n=i.length;s<n;s++){let o=i[s];for(let l=0,h=o.length;l<h;l++)o[l][0]=t.x,o[l][1]=t.y,o[l][2]=t.z,o[l][3]=t.w}let r=this._colors;for(let s=0,n=r.length;s<n;s+=4)r[s]=t.x,r[s+1]=t.y,r[s+2]=t.z,r[s+3]=t.w;this._changedBuffers[2]=!0}setPathLonLatFast(e,t){this.setPathLonLat(e,t,!0)}setPath3vFast(e,t){this.setPath3v(e,t,!0)}setPathLonLat(e,t,i=!1){t&&(this._pathColors=[].concat(t)),this._renderNode&&this._renderNode.ellipsoid?i?(this._setEqualPathLonLat(e),this._changedBuffers[0]=!0,this._changedBuffers[2]=!0):(this._createDataLonLat(e),this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0):this._pathLonLat=[].concat(e)}getSize(e=0){return this._path3v[e].length}setPath3v(e,t,i=!1){t&&(this._pathColors=[].concat(t)),this._renderNode?i?(this._setEqualPath3v(e),this._changedBuffers[0]=!0,this._changedBuffers[2]=!0):(this._createData3v(e),this._changedBuffers[0]=!0,this._changedBuffers[1]=!0,this._changedBuffers[2]=!0):this._path3v=[].concat(e)}draw(){if(this.visibility&&this._path3v.length){this._update();let e=this._renderNode.renderer,t=e.handler.programs.polyline_screen,i=t._program,r=e.handler.gl,s=i.attributes,n=i.uniforms,o=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,o.polygonOffsetUnits),r.uniformMatrix4fv(n.proj,!1,e.activeCamera.getProjectionMatrix()),r.uniformMatrix4fv(n.view,!1,e.activeCamera.getViewMatrix()),r.uniform3fv(n.rtcEyePositionHigh,this._handler._rtcEyePositionHigh),r.uniform3fv(n.rtcEyePositionLow,this._handler._rtcEyePositionLow),r.uniform4fv(n.visibleSphere,this._visibleSphere),r.uniform2fv(n.viewport,[e.handler.canvas.width,e.handler.canvas.height]),r.uniform1f(n.thickness,.5*this.thickness),r.uniform1f(n.opacity,this._opacity*o._fadingOpacity),r.bindBuffer(r.ARRAY_BUFFER,this._colorsBuffer),r.vertexAttribPointer(s.color,this._colorsBuffer.itemSize,r.FLOAT,!1,0,0);let l=this._verticesHighBuffer;r.bindBuffer(r.ARRAY_BUFFER,l),r.vertexAttribPointer(s.prevHigh,l.itemSize,r.FLOAT,!1,12,0),r.vertexAttribPointer(s.currentHigh,l.itemSize,r.FLOAT,!1,12,48),r.vertexAttribPointer(s.nextHigh,l.itemSize,r.FLOAT,!1,12,96),l=this._verticesLowBuffer,r.bindBuffer(r.ARRAY_BUFFER,l),r.vertexAttribPointer(s.prevLow,l.itemSize,r.FLOAT,!1,12,0),r.vertexAttribPointer(s.currentLow,l.itemSize,r.FLOAT,!1,12,48),r.vertexAttribPointer(s.nextLow,l.itemSize,r.FLOAT,!1,12,96),r.bindBuffer(r.ARRAY_BUFFER,this._ordersBuffer),r.vertexAttribPointer(s.order,this._ordersBuffer.itemSize,r.FLOAT,!1,4,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this._indexesBuffer),r.drawElements(r.TRIANGLE_STRIP,this._indexesBuffer.numItems,r.UNSIGNED_INT,0),r.enable(r.CULL_FACE)}}drawPicking(){if(this.visibility&&this._path3v.length){let e=this._renderNode.renderer,t=e.handler.programs.polyline_picking,i=t._program,r=e.handler.gl,s=i.attributes,n=i.uniforms,o=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,o.polygonOffsetUnits),r.uniformMatrix4fv(n.proj,!1,e.activeCamera.getProjectionMatrix()),r.uniformMatrix4fv(n.view,!1,e.activeCamera.getViewMatrix()),r.uniform4fv(n.color,[this._pickingColor[0],this._pickingColor[1],this._pickingColor[2],1]),r.uniform3fv(n.rtcEyePositionHigh,this._handler._rtcEyePositionHigh),r.uniform3fv(n.rtcEyePositionLow,this._handler._rtcEyePositionLow),r.uniform4fv(n.visibleSphere,this._visibleSphere),r.uniform2fv(n.viewport,[e.handler.canvas.width,e.handler.canvas.height]),r.uniform1f(n.thickness,.5*this.thickness*o.pickingScale[0]);let l=this._verticesHighBuffer;r.bindBuffer(r.ARRAY_BUFFER,l),r.vertexAttribPointer(s.prevHigh,l.itemSize,r.FLOAT,!1,12,0),r.vertexAttribPointer(s.currentHigh,l.itemSize,r.FLOAT,!1,12,48),r.vertexAttribPointer(s.nextHigh,l.itemSize,r.FLOAT,!1,12,96),l=this._verticesLowBuffer,r.bindBuffer(r.ARRAY_BUFFER,l),r.vertexAttribPointer(s.prevLow,l.itemSize,r.FLOAT,!1,12,0),r.vertexAttribPointer(s.currentLow,l.itemSize,r.FLOAT,!1,12,48),r.vertexAttribPointer(s.nextLow,l.itemSize,r.FLOAT,!1,12,96),r.bindBuffer(r.ARRAY_BUFFER,this._ordersBuffer),r.vertexAttribPointer(s.order,this._ordersBuffer.itemSize,r.FLOAT,!1,4,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this._indexesBuffer),r.drawElements(r.TRIANGLE_STRIP,this._indexesBuffer.numItems,r.UNSIGNED_INT,0),r.enable(r.CULL_FACE)}}_refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_update(){if(this._renderNode){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}_deleteBuffers(){if(this._renderNode){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer),e.deleteBuffer(this._ordersBuffer),e.deleteBuffer(this._indexesBuffer),e.deleteBuffer(this._colorsBuffer),this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._ordersBuffer=null,this._indexesBuffer=null,this._colorsBuffer=null}}_createVerticesBuffer(){let e=this._renderNode.renderer.handler,t=this._verticesHigh.length/3;this._verticesHighBuffer&&this._verticesHighBuffer.numItems===t||(e.gl.deleteBuffer(this._verticesHighBuffer),e.gl.deleteBuffer(this._verticesLowBuffer),this._verticesHighBuffer=e.createStreamArrayBuffer(3,t),this._verticesLowBuffer=e.createStreamArrayBuffer(3,t)),this._verticesHigh=re(this._verticesHigh),this._verticesLow=re(this._verticesLow),e.setStreamArrayBuffer(this._verticesHighBuffer,this._verticesHigh),e.setStreamArrayBuffer(this._verticesLowBuffer,this._verticesLow)}_createIndexBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._ordersBuffer),e.gl.deleteBuffer(this._indexesBuffer),this._orders=re(this._orders),this._ordersBuffer=e.createArrayBuffer(this._orders,1,this._orders.length/2),this._indexes=re(this._indexes,Uint32Array),this._indexesBuffer=e.createElementArrayBuffer(this._indexes,1,this._indexes.length)}_createColorsBuffer(){let e=this._renderNode.renderer.handler;e.gl.deleteBuffer(this._colorsBuffer),this._colors=re(this._colors),this._colorsBuffer=e.createArrayBuffer(new Float32Array(this._colors),4,this._colors.length/4)}setVisibleSphere(e,t){this._handler&&(this._visibleSphere[0]=e.x-this._handler._relativeCenter.x,this._visibleSphere[1]=e.y-this._handler._relativeCenter.y,this._visibleSphere[2]=e.z-this._handler._relativeCenter.z),this._visibleSphere[3]=t}updateRTCPosition(){this._handler&&this._renderNode&&(this._visibleSphere[0]=this._visibleSphere[0]-this._handler._relativeCenter.x,this._visibleSphere[1]=this._visibleSphere[1]-this._handler._relativeCenter.y,this._visibleSphere[2]=this._visibleSphere[2]-this._handler._relativeCenter.z,this._setEqualPath3v(this._path3v)),this._changedBuffers[0]=!0}};yn.__counter__=0;let xn=yn;const bn=class Do{constructor(e={}){this.__id=Do.__counter__++,this._thickness=e.thickness||2,this._startPosition=je(e.startPosition),this._startPositionHigh=new m,this._startPositionLow=new m,m.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._endPosition=je(e.endPosition),this._endPositionHigh=new m,this._endPositionLow=new m,m.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._startColor=rt(e.startColor),this._endColor=rt(e.endColor),this._visibility=e.visibility==null||e.visibility,this._entity=null,this._handler=null,this._handlerIndex=-1}setStartPosition(e,t,i){this._startPosition.x=e,this._startPosition.y=t,this._startPosition.z=i,m.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._handler&&this._handler.setStartPositionArr(this._handlerIndex,this._startPositionHigh,this._startPositionLow)}getLength(){return this._startPosition.distance(this._endPosition)}setStartPosition3v(e){this._startPosition.x=e.x,this._startPosition.y=e.y,this._startPosition.z=e.z,m.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._handler&&this._handler.setStartPositionArr(this._handlerIndex,this._startPositionHigh,this._startPositionLow)}setEndPosition(e,t,i){this._endPosition.x=e,this._endPosition.y=t,this._endPosition.z=i,m.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._handler&&this._handler.setEndPositionArr(this._handlerIndex,this._endPositionHigh,this._endPositionLow)}setEndPosition3v(e){this._endPosition.x=e.x,this._endPosition.y=e.y,this._endPosition.z=e.z,m.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._handler&&this._handler.setEndPositionArr(this._handlerIndex,this._endPositionHigh,this._endPositionLow)}setThickness(e){this._thickness=e,this._handler&&this._handler.setThicknessArr(this._handlerIndex,e)}setColors4v(e,t){e&&(this._startColor.x=e.x,this._startColor.y=e.y,this._startColor.z=e.z,this._startColor.w=e.w),t&&(this._endColor.x=t.x,this._endColor.y=t.y,this._endColor.z=t.z,this._endColor.w=t.w),this._handler&&this._handler.setRgbaArr(this._handlerIndex,this._startColor,this._endColor)}setColorsHTML(e,t){e&&(this._startColor=it(e)),t&&(this._endColor=it(t)),this._handler&&this._handler.setRgbaArr(this._handlerIndex,this._startColor,this._endColor)}getStartPosition(){return this._startPosition}getEndPosition(){return this._endPosition}setVisibility(e){this._visibility=e,this._handler&&this._handler.setVisibility(this._handlerIndex,e)}getVisibility(){return this._visibility}remove(){this._entity=null,this._handler&&this._handler.remove(this)}setPickingColor3v(e){this._handler&&this._handler.setPickingColorArr(this._handlerIndex,e)}};bn.__counter__=0;let Tl=bn,ge=new m,pe=new m;const wn=class Fo{constructor(e={}){if(this.__id=Fo.__counter__++,this.visibility=e.visibility==null||e.visibility,this.color=new Float32Array([1,1,1,.5]),e.color){let t=rt(e.color);this.setColor(t.x,t.y,t.z,t.w)}e.opacity&&this.setOpacity(e.opacity),this._renderNode=null,this._entity=null,this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._indexBuffer=null,this._verticesHigh=[],this._verticesLow=[],this._indexes=[],this._path=[],this._pickingColor=new Float32Array(4),this._gridSize=1,this._handler=null,this._handlerIndex=-1,e.path&&this.setPath(e.path)}setPickingColor3v(e){this._pickingColor[0]=e.x/255,this._pickingColor[1]=e.y/255,this._pickingColor[2]=e.z/255,this._pickingColor[3]=1}clear(){this._path.length=0,this._path=[],this._verticesHigh.length=0,this._verticesHigh=[],this._verticesLow.length=0,this._verticesLow=[],this._indexes.length=0,this._indexes=[],this._deleteBuffers()}setColor4v(e){this.setColor(e.x,e.y,e.z,e.w)}setColorHTML(e){this.setColor4v(it(e))}setColor(e,t,i,r){r=r||this.color[3],this.color[0]=e,this.color[1]=t,this.color[2]=i,this.color[3]=r}setOpacity(e){this.color[3]=e||0}setVisibility(e){this.visibility=e}getVisibility(){return this.visibility}setRenderNode(e){this._renderNode=e,this._createBuffers()}remove(){this._entity=null,this._handler&&this._handler.remove(this)}draw(){if(this.visibility&&this._verticesHigh.length){let e=this._renderNode.renderer,t=e.handler.gl,i=e.handler.programs.strip,r=i._program,s=r.attributes,n=r.uniforms;i.activate(),t.disable(t.CULL_FACE),t.uniformMatrix4fv(n.viewMatrix,!1,e.activeCamera.getViewMatrix()),t.uniformMatrix4fv(n.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),t.uniform3fv(n.eyePositionHigh,e.activeCamera.eyeHigh),t.uniform3fv(n.eyePositionLow,e.activeCamera.eyeLow),t.uniform4fv(n.uColor,this.color),t.uniform1f(n.uOpacity,this._entity._entityCollection._fadingOpacity),t.bindBuffer(t.ARRAY_BUFFER,this._verticesHighBuffer),t.vertexAttribPointer(s.aVertexPositionHigh,this._verticesHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._verticesLowBuffer),t.vertexAttribPointer(s.aVertexPositionLow,this._verticesLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.drawElements(e.handler.gl.TRIANGLE_STRIP,this._indexBuffer.numItems,t.UNSIGNED_INT,0),t.enable(t.CULL_FACE)}}drawPicking(){if(this.visibility&&this._verticesHigh.length){let e=this._renderNode.renderer,t=e.handler.gl,i=e.handler.programs.strip,r=i._program,s=r.attributes,n=r.uniforms;i.activate(),t.disable(t.CULL_FACE),t.uniformMatrix4fv(n.viewMatrix,!1,e.activeCamera.getViewMatrix()),t.uniformMatrix4fv(n.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),t.uniform3fv(n.eyePositionHigh,e.activeCamera.eyeHigh),t.uniform3fv(n.eyePositionLow,e.activeCamera.eyeLow),t.uniform1f(n.uOpacity,this._entity._entityCollection._fadingOpacity!=0?1:0),t.uniform4fv(n.uColor,this._pickingColor),t.bindBuffer(t.ARRAY_BUFFER,this._verticesHighBuffer),t.vertexAttribPointer(s.aVertexPositionHigh,this._verticesHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._verticesLowBuffer),t.vertexAttribPointer(s.aVertexPositionLow,this._verticesLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.drawElements(e.handler.gl.TRIANGLE_STRIP,this._indexBuffer.numItems,t.UNSIGNED_INT,0),t.enable(t.CULL_FACE)}}_deleteBuffers(){if(this._renderNode&&this._renderNode.renderer){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._indexBuffer),e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer)}this._verticesHighBuffer=null,this._verticesLowBuffer=null,this._indexBuffer=null}_createBuffers(){if(this._renderNode&&this._renderNode.renderer&&this._renderNode.renderer.isInitialized()){let e=this._renderNode.renderer.handler.gl;e.deleteBuffer(this._indexBuffer),e.deleteBuffer(this._verticesHighBuffer),e.deleteBuffer(this._verticesLowBuffer),this._verticesHighBuffer=this._renderNode.renderer.handler.createArrayBuffer(new Float32Array(this._verticesHigh),3,this._verticesHigh.length/3),this._verticesLowBuffer=this._renderNode.renderer.handler.createArrayBuffer(new Float32Array(this._verticesLow),3,this._verticesLow.length/3),this._indexBuffer=this._renderNode.renderer.handler.createElementArrayBuffer(new Uint32Array(this._indexes),1,this._indexes.length)}}addEdge3v(e,t){let i=this._path.length;if(i===0)this._path.push([e.clone(),t.clone()]);else{let r=this._path[i-1][0],s=this._path[i-1][1];this._path.push([e.clone(),t.clone()]);let n=this._verticesHigh,o=this._verticesLow,l=this._gridSize,h=l+1,c=new m,d=this._verticesHigh.length/3,u=d,g=Math.abs(r.sub(s).normal().dot(e.sub(r).normal()));for(let f=0;f<h;f++){let p=f/l,_=r.lerp(e,p),v=s.lerp(t,p);for(let x=0;x<h;x++){let y=x/l,w=r.lerp(s,y),b=e.lerp(t,y);g!==1?new Qe(_,v).intersects(new Qe(w,b),c):c=b,u=d+f*h+x,m.doubleToTwoFloats(c,ge,pe);let E=3*u;n[E]=ge.x,n[E+1]=ge.y,n[E+2]=ge.z,o[E]=pe.x,o[E+1]=pe.y,o[E+2]=pe.z,f<l&&this._indexes.push(u,u+h)}f<l&&this._indexes.push(u+h,u+1)}this._createBuffers()}}setEdge3v(e,t,i){if(i!==this._path.length)if(this._path[i]){if(this._path[i][0]=e,this._path[i][1]=t,this._path.length>1){let r=this._gridSize,s=r+1,n=s*s,o=new m,l=this._verticesHigh,h=this._verticesLow;if(i===this._path.length-1){let c=this._path[i-1][0],d=this._path[i-1][1],u=this._verticesHigh.length/3-n,g=u,f=Math.abs(c.sub(d).normal().dot(e.sub(c).normal()));for(let p=0;p<s;p++){let _=p/r,v=c.lerp(e,_),x=d.lerp(t,_);for(let y=0;y<s;y++){let w=y/r,b=c.lerp(d,w),E=e.lerp(t,w);f!==1?new Qe(v,x).intersects(new Qe(b,E),o):o=E,g=u+p*s+y,m.doubleToTwoFloats(o,ge,pe);let C=3*g;l[C]=ge.x,l[C+1]=ge.y,l[C+2]=ge.z,h[C]=pe.x,h[C+1]=pe.y,h[C+2]=pe.z}}}else if(i===0){let c=0,d=e,u=t;e=this._path[1][0],t=this._path[1][1];for(let g=0;g<s;g++){let f=g/r,p=d.lerp(e,f),_=u.lerp(t,f);for(let v=0;v<s;v++){let x=v/r,y=d.lerp(u,x),w=e.lerp(t,x);new Qe(p,_).intersects(new Qe(y,w),o),c=g*s+v,m.doubleToTwoFloats(o,ge,pe);let b=3*c;l[b]=ge.x,l[b+1]=ge.y,l[b+2]=ge.z,h[b]=pe.x,h[b+1]=pe.y,h[b+2]=pe.z}}}else if(i>0&&i<this._path.length){let c=this._path[i-1][0],d=this._path[i-1][1],u=this._path[i+1][0],g=this._path[i+1][1],f=i*n,p=(i-1)*n,_=p;for(let v=0;v<s;v++){let x=v/r,y=c.lerp(e,x),w=t.lerp(g,x),b=e.lerp(u,x),E=d.lerp(t,x);for(let C=0;C<s;C++){let T=C/r,L=c.lerp(d,T),M=e.lerp(t,T);new Qe(y,E).intersects(new Qe(L,M),o);let R=v*s+C;_=p+R,m.doubleToTwoFloats(o,ge,pe);let z=3*_;l[z]=ge.x,l[z+1]=ge.y,l[z+2]=ge.z,h[z]=pe.x,h[z+1]=pe.y,h[z+2]=pe.z;let F=u.lerp(g,T);M=e.lerp(t,T),new Qe(b,w).intersects(new Qe(M,F),o),_=f+R,m.doubleToTwoFloats(o,ge,pe),z=3*_,l[z]=ge.x,l[z+1]=ge.y,l[z+2]=ge.z,h[z]=pe.x,h[z+1]=pe.y,h[z+2]=pe.z}}}this._createBuffers()}}else console.warn(`strip index ${i} is out of range`);else this.addEdge3v(e,t)}removeEdge(e){this._path.splice(e,1),this.setPath([].concat(this._path))}setGridSize(e){this._gridSize=e,this.setPath([].concat(this._path))}getPath(){return this._path}setPath(e){this._verticesHigh=[],this._verticesLow=[],this._indexes=[],this._path=[];for(let t=0;t<e.length;t++){let i=e[t][0],r=e[t][1];i instanceof Array&&(i=new m(i[0],i[1],i[2])),r instanceof Array&&(r=new m(r[0],r[1],r[2])),this.addEdge3v(i,r)}}insertEdge3v(e,t,i){if(i<this._path.length){let r=[].concat(this._path);r.splice(i,0,[e,t]),this.setPath(r)}else i===this._path.length&&this.addEdge3v(e,t)}};wn.__counter__=0;let Cn=wn;const Tn=class Oo{constructor(e={}){e.properties=e.properties||{},this.__id=Oo.__counter__++,this._name=e.name||`entity:${this.__id}`,this.properties=e.properties||{},this.childEntities=[],this.parent=null,this.forceGlobalPosition=e.forceGlobalPosition||!1,this.forceGlobalRotation=e.forceGlobalRotation||!1,this.forceGlobalScale=e.forceGlobalScale||!1,this._cartesian=je(e.cartesian),this._rootCartesian=new m,this._localPosition=je(e.localPosition),this._absoluteLocalPosition=new m,this._lonLat=Oi(e.lonlat),this._lonLatMerc=new A,this._altitude=e.altitude||0,this._visibility=e.visibility==null||e.visibility,this._entityCollection=null,this._entityCollectionIndex=-1,this._layer=null,this._layerIndex=-1,this._pickingColor=new m(0,0,0),this._independentPicking=e.independentPicking||!1,this._relativePosition=e.relativePosition||!1,this._pitchRad=e.pitch||0,this._yawRad=e.yaw||0,this._rollRad=e.roll||0,this._scale=je(e.scale,new m(1,1,1)),this._absoluteScale=new m,this._qFrame=O.IDENTITY,this._qRot=O.IDENTITY,this._absoluteQRot=O.IDENTITY,this._useDirectQuaternion=!1,this._featureConstructorArray={billboard:[cn,this.setBillboard],label:[mn,this.setLabel],polyline:[xn,this.setPolyline],pointCloud:[Cl,this.setPointCloud],geometry:[un,this.setGeometry],geoObject:[gn,this.setGeoObject],strip:[Cn,this.setStrip],ray:[Tl,this.setRay]},this.billboard=this._createOptionFeature("billboard",e.billboard),this.label=this._createOptionFeature("label",e.label),this.polyline=this._createOptionFeature("polyline",e.polyline),this.ray=this._createOptionFeature("ray",e.ray),this.pointCloud=this._createOptionFeature("pointCloud",e.pointCloud),this.geometry=this._createOptionFeature("geometry",e.geometry),this.geoObject=this._createOptionFeature("geoObject",e.geoObject),this.strip=this._createOptionFeature("strip",e.strip)}get name(){return this._name}set name(e){e!==this._name&&(this._name=e)}get isEmpty(){return!(this.strip||this.polyline||this.ray||this.geoObject||this.geometry||this.billboard||this.label||this.pointCloud)}get rootEntity(){let e=this;for(;e;){if(!e.parent)return e;e=e.parent}return this}set relativePosition(e){if(e!==this._relativePosition){let t=this.getAbsoluteCartesian(),i=this.getAbsolutePitch(),r=this.getAbsoluteYaw(),s=this.getAbsoluteRoll();this._relativePosition=e,this.parent&&this._rootCartesian.copy(this.parent._rootCartesian),e?this.parent&&(this.setAbsoluteCartesian3v(t),this.setAbsolutePitch(i),this.setAbsoluteYaw(r),this.setAbsoluteRoll(s)):(this.setCartesian3v(t),this.setPitch(i),this.setYaw(r),this.setRoll(s))}}get relativePosition(){return this._relativePosition}get entityCollection(){return this._entityCollection}get id(){return this.__id}isEqual(e){return this.__id===e.__id}get layerIndex(){return this._layerIndex}get instanceName(){return"Entity"}_createOptionFeature(e,t){if(t){let i=this._featureConstructorArray[e];return i[1].call(this,new i[0](t))}return null}getCollectionIndex(){return this._entityCollectionIndex}addTo(e){return e.add(this),this}remove(){this._layer&&this._layer.removeEntity(this),this._entityCollection&&this._entityCollection.removeEntity(this)}setVisibility(e){this._visibility=e,this.billboard&&this.billboard.setVisibility(e),this.geoObject&&this.geoObject.setVisibility(e),this.label&&this.label.setVisibility(e),this.polyline&&this.polyline.setVisibility(e),this.ray&&this.ray.setVisibility(e),this.geometry&&this.geometry.setVisibility(e);for(let t=0;t<this.childEntities.length;t++)this.childEntities[t].setVisibility(e)}getVisibility(){return this._visibility}setCartesian3v(e){this.setCartesian(e.x,e.y,e.z)}getScale(){return this._scale}setScale3v(e){this._scale.copy(e),this._updateAbsolutePosition();for(let t=0;t<this.childEntities.length;t++){let i=this.childEntities[t];i.forceGlobalScale?i.setScale3v(this._scale):i.setScale3v(this.childEntities[t].getScale())}}setScale(e){this.setScale3v(new m(e,e,e))}getAbsoluteRotation(){return this._absoluteQRot.clone()}getRotation(){return this._qRot}setLook3v(e){let t,i=new O,r=this.getAbsoluteCartesian();if(this._entityCollection){let s=this._entityCollection.renderNode.ellipsoid.getSurfaceNormal3v(r);t=i.setLookRotation(e.sub(r),s).conjugate()}else t=i.setLookRotation(e.sub(r),m.UP).conjugate();this.setAbsoluteRotation(t)}setLookLonLat(e){if(this._entityCollection){let t=this._entityCollection.renderNode.ellipsoid.lonLatToCartesian(e);this.setLook3v(t)}}setAbsoluteRotation(e){this._absoluteQRot.copy(e),this._updatePitchYawRoll()}setRotation(e){this._useDirectQuaternion=!1,this._pitchRad=e.getPitch(),this._yawRad=e.getYaw(),this._rollRad=e.getRoll(),this._updateAbsolutePosition()}setDirectQuaternionRotation(e){this._qRot.copy(e),this._useDirectQuaternion=!0,this._pitchRad=this._qRot.getPitch(),this._yawRad=this._qRot.getYaw(),this._rollRad=this._qRot.getRoll(),this._updateAbsolutePosition()}setPitch(e){this._useDirectQuaternion=!1,this._pitchRad=e,this._updateAbsolutePosition()}setYaw(e){this._useDirectQuaternion=!1,this._yawRad=e,this._updateAbsolutePosition()}setRoll(e){this._useDirectQuaternion=!1,this._rollRad=e,this._updateAbsolutePosition()}getPitch(){return this._pitchRad}getYaw(){return this._yawRad}getRoll(){return this._rollRad}setAbsolutePitch(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(e,this.getAbsoluteYaw(),this.getAbsoluteRoll(),this._qFrame),this._updatePitchYawRoll()):this.setPitch(e)}setAbsoluteYaw(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(),e,this.getAbsoluteRoll(),this._qFrame),this._updatePitchYawRoll()):this.setYaw(e)}setAbsoluteRoll(e){this._relativePosition?(this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(),this.getAbsoluteYaw(),e,this._qFrame),this._updatePitchYawRoll()):this.setRoll(e)}getAbsolutePitch(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getPitch():this._pitchRad}getAbsoluteYaw(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getYaw():this._yawRad}getAbsoluteRoll(){return this.parent&&this._relativePosition?this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getRoll():this._rollRad}_getScaleByDistance(){let e=1;if(this._entityCollection){let t=this._entityCollection.scaleByDistance,i=1;this._entityCollection.renderNode&&this._entityCollection.renderNode.renderer&&(i=this._entityCollection.renderNode.renderer.activeCamera.eye.distance(this._rootCartesian)),e=t[2]*Si(i,t[0],t[1])/t[0]}return e}setAbsoluteCartesian(e,t,i){this.setAbsoluteCartesian3v(new m(e,t,i))}setAbsoluteCartesian3v(e){let t=e;if(this.parent&&this._relativePosition){let i=this._getScaleByDistance();t=e.sub(this.parent.getAbsoluteCartesian()).scale(1/i).divA(this.parent._absoluteScale),t=this.parent._absoluteQRot.conjugate().mulVec3(t)}this.setCartesian3v(t)}getAbsoluteCartesian(){if(this.parent&&this._relativePosition){let e=this._getScaleByDistance();return this._rootCartesian.add(this._absoluteLocalPosition.scaleTo(e))}return this._cartesian.clone()}setCartesian(e,t,i){this._cartesian.set(e,t,i),this._updateAbsolutePosition();for(let r=0;r<this.childEntities.length;r++){let s=this.childEntities[r];s._relativePosition?s.setCartesian3v(s.getCartesian()):s.forceGlobalPosition&&s.setCartesian(e,t,i)}this._updateLonLat()}_updatePitchYawRoll(){if(this.parent){this._qRot=this.parent._absoluteQRot.conjugate().mul(this._absoluteQRot),this._pitchRad=this._qRot.getPitch(),this._yawRad=this._qRot.getYaw(),this._rollRad=this._qRot.getRoll(),this.geoObject&&this.geoObject.setRotation(this._absoluteQRot);for(let e=0;e<this.childEntities.length;e++)this.childEntities[e]._updateAbsolutePosition()}}_updateAbsolutePosition(){let e=this.parent;if(e&&this._relativePosition){this._scale.mulRes(e._absoluteScale,this._absoluteScale),this._qFrame.copy(e._qFrame),this._rootCartesian.copy(e._rootCartesian),this._useDirectQuaternion||(e&&this.forceGlobalRotation?this._qRot.setPitchYawRoll(e._pitchRad,e._yawRad,e._rollRad):this._qRot.setPitchYawRoll(this._pitchRad,this._yawRad,this._rollRad)),e._absoluteQRot.mulRes(this._qRot,this._absoluteQRot);let t=e._absoluteQRot.mulVec3(this._cartesian.add(this._localPosition)).mulA(e._absoluteScale);e._absoluteLocalPosition.addRes(t,this._absoluteLocalPosition)}else this._qFrame=O.IDENTITY,this._entityCollection&&this._entityCollection.renderNode&&(this._qFrame=this._entityCollection.renderNode.getFrameRotation(this._cartesian)),this._useDirectQuaternion?this._qFrame.isEqual(O.IDENTITY)||(this._qRot=this._qRot.mul(this._qFrame)):e&&this.forceGlobalRotation?this._qRot.setPitchYawRoll(e._pitchRad,e._yawRad,e._rollRad,this._qFrame):this._qRot.setPitchYawRoll(this._pitchRad,this._yawRad,this._rollRad,this._qFrame),this._absoluteScale.copy(this._scale),this._absoluteQRot.copy(this._qRot),this._rootCartesian.copy(this._cartesian),this._absoluteLocalPosition.copy(this._localPosition);this.geoObject&&(this.geoObject.setScale3v(this._absoluteScale),this.geoObject.setRotation(this._absoluteQRot),this.geoObject.setPosition3v(this._rootCartesian),this.geoObject.setLocalPosition3v(this._absoluteLocalPosition)),this.billboard&&this.billboard.setPosition3v(this._rootCartesian),this.label&&this.label.setPosition3v(this._rootCartesian);for(let t=0,i=this.childEntities.length;t<i;t++)this.childEntities[t]._updateAbsolutePosition();this._updateLonLat()}_setCartesian3vSilent(e,t=!1){this._cartesian.copy(e),this._updateAbsolutePosition();for(let i=0;i<this.childEntities.length;i++)this.childEntities[i].setCartesian(this._cartesian.x,this._cartesian.y,this._cartesian.z);t||this._updateLonLat()}_updateLonLat(){let e=this._entityCollection;e&&e.renderNode&&e.renderNode.ellipsoid&&(this._lonLat=e.renderNode.ellipsoid.cartesianToLonLat(this.getAbsoluteCartesian()),Math.abs(this._lonLat.lat)<de?this._lonLatMerc=this._lonLat.forwardMercator():this._lonLatMerc.lon=this._lonLatMerc.lat=0)}getLonLat(){return this._lonLat.clone()}setLonLat(e){let t=this._lonLat;t.lon=e.lon,t.lat=e.lat,t.height=e.height;let i=this._entityCollection;if(i&&i.renderNode&&i.renderNode.ellipsoid){Math.abs(t.lat)<de&&(this._lonLatMerc=t.forwardMercator());let r=new m;i.renderNode.ellipsoid.lonLatToCartesianRes(t,r),this.setAbsoluteCartesian3v(r)}}setLonLat2(e,t,i){let r=this._lonLat;r.lon=e,r.lat=t,r.height=i??r.height;let s=this._entityCollection;if(s&&s.renderNode&&s.renderNode.ellipsoid){Math.abs(r.lat)<de?this._lonLatMerc=r.forwardMercator():this._lonLatMerc.lon=this._lonLatMerc.lat=this._lonLatMerc.height=0;let n=new m;s.renderNode.ellipsoid.lonLatToCartesianRes(r,n),this.setAbsoluteCartesian3v(n)}}setAltitude(e){this._altitude=e}getAltitude(){return this._altitude}getCartesian(){return this._cartesian.clone()}setBillboard(e){return this.billboard&&this.billboard.remove(),this.billboard=e,this.billboard._entity=this,this.billboard.setPosition3v(this._cartesian),this.billboard.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.billboardHandler.add(e),e}setLabel(e){return this.label&&this.label.remove(),this.label=e,this.label._entity=this,this.label.setPosition3v(this._cartesian),this.label.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.labelHandler.add(e),e}setRay(e){return this.ray&&this.ray.remove(),this.ray=e,this.ray._entity=this,this.ray.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.rayHandler.add(e),e}setPolyline(e){return this.polyline&&this.polyline.remove(),this.polyline=e,this.polyline._entity=this,this.polyline.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.polylineHandler.add(e),e}setPointCloud(e){return this.pointCloud&&this.pointCloud.remove(),this.pointCloud=e,this.pointCloud._entity=this,this.pointCloud.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.pointCloudHandler.add(e),e}setGeometry(e){this.geometry&&this.geometry.remove(),this.geometry=e,this.geometry._entity=this,this.geometry.setVisibility(this._visibility);let t=this._layer;return this._layer&&this._layer.removeEntity(this),t&&t.add(this),e}setGeoObject(e){return this.geoObject&&this.geoObject.remove(),this.geoObject=e,this.geoObject._entity=this,this.geoObject.setPosition3v(this._cartesian),this.geoObject.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.geoObjectHandler.add(e),e}setStrip(e){return this.strip&&this.strip.remove(),this.strip=e,this.strip._entity=this,this.strip.setVisibility(this._visibility),this._entityCollection&&this._entityCollection.stripHandler.add(e),e}get layer(){return this._layer}get rendererEvents(){return this._layer?this._layer.events:this._entityCollection?this._entityCollection.events:null}appendChildren(e,t){for(let i=0;i<e.length;i++)t!==void 0&&(e[i].relativePosition=t),this.appendChild(e[i])}appendChild(e){e._entityCollection=this._entityCollection,e._independentPicking||(e._pickingColor=this._pickingColor),e.parent=this,this.childEntities.push(e),this._entityCollection&&this._entityCollection.appendChildEntity(e)}setPickingColor(){let e=this._pickingColor;this.billboard&&this.billboard.setPickingColor3v(e),this.label&&this.label.setPickingColor3v(e),this.polyline&&this.polyline.setPickingColor3v(e),this.ray&&this.ray.setPickingColor3v(e),this.strip&&this.strip.setPickingColor3v(e),this.geoObject&&this.geoObject.setPickingColor3v(e);for(let t=0;t<this.childEntities.length;t++)this.childEntities[t].setPickingColor()}getExtent(){let e,t=this._lonLat;e=this.billboard||this.label?new j(new A(t.lon,t.lat),new A(t.lon,t.lat)):new j(new A(180,90),new A(-180,-90));let i=e.southWest,r=e.northEast;if(this.polyline){let s=this.polyline.getExtent();s.southWest.lon<i.lon&&(i.lon=s.southWest.lon),s.southWest.lat<i.lat&&(i.lat=s.southWest.lat),s.northEast.lon>r.lon&&(r.lon=s.northEast.lon),s.northEast.lat>r.lat&&(r.lat=s.northEast.lat)}if(this.geometry){let s=this.geometry.getExtent();s.southWest.lon<i.lon&&(i.lon=s.southWest.lon),s.southWest.lat<i.lat&&(i.lat=s.southWest.lat),s.northEast.lon>r.lon&&(r.lon=s.northEast.lon),s.northEast.lat>r.lat&&(r.lat=s.northEast.lat)}for(let s=0;s<this.childEntities.length;s++){let n=this.childEntities[s].getExtent();n.southWest.lon<i.lon&&(i.lon=n.southWest.lon),n.southWest.lat<i.lat&&(i.lat=n.southWest.lat),n.northEast.lon>r.lon&&(r.lon=n.northEast.lon),n.northEast.lat>r.lat&&(r.lat=n.northEast.lat)}return e}};Tn.__counter__=0;let V=Tn;const En=class No{constructor(e){this.__id=No.__counter__++,this._name=e||`nonameNode:${this.__id}`,this.topNode=this,this._dictionary={},this._dictionary[this._name]=this,this.childNodes=[],this.parentNode=null}get name(){return this._name}addNode(e){this.parentNode==null?e.topNode=this:e.topNode=this.topNode,e.parentNode=this,e._dictionary=this.topNode._dictionary,this.childNodes.push(e),this.topNode._dictionary[e.name]=e}destroy(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e].destroy();this._clear()}getNodeByName(e){return this._dictionary[e]}_clear(){this.parentNode=null,this.topNode=this,this.childNodes.length=0}isEqual(e){return e.__id===this.__id}};En.__counter__=0;let El=En;class ot extends El{constructor(e){super(e),this.childNodes=[],this.renderer=null,this.drawMode=0,this.show=!0,this._isActive=!0,this.lightEnabled=!1,this._lightPosition=new Float32Array([100,100,100]),this._lightParams=new Float32Array(9),this._lightShininess=100,this.entityCollections=[],this._entityCollectionsByDepthOrder=[],this._pickingId=-1}getFrameRotation(e){return O.IDENTITY}addNode(e){super.addNode(e),this.renderer&&e.assign(this.renderer)}assign(e){this.renderer=e,this._pickingId=e.addPickingCallback(this,this._entityCollectionPickingCallback),this.initialize()}initialize(){if(this.renderer&&this.renderer.isInitialized()){for(let e=0;e<this.entityCollections.length;e++)this.entityCollections[e].bindRenderNode(this);this.init()}}init(){}onremove(){}remove(){let e=this.renderer,t=this.name;if(e){e.renderNodes[t]&&e.renderNodes[t].isEqual(this)&&(e.renderNodes[t]=null,delete e.renderNodes[t]);for(let i=0;i<e._renderNodesArr.length;i++)if(e._renderNodesArr[i].isEqual(this)){e._renderNodesArr.splice(i,1);break}e.removePickingCallback(this._pickingId),this._pickingId=-1,this.onremove&&this.onremove()}}addEntityCollection(e,t){e.renderNode||(e.renderNode=this,t||(this.entityCollections.push(e),this.updateEntityCollectionsDepthOrder()),this.ellipsoid&&e._updateGeodeticCoordinates(this.ellipsoid),e.bindRenderNode(this),e.events.dispatch(e.events.add,this))}removeEntityCollection(e){for(let t=0;t<this.entityCollections.length;t++)if(this.entityCollections[t].isEqual(e))return this.entityCollections.splice(t,1),void this.updateEntityCollectionsDepthOrder()}updateEntityCollectionsDepthOrder(){let e={0:[]};for(const t of this.entityCollections)t.getVisibility()&&(e[t.depthOrder]||(e[t.depthOrder]=[]),e[t.depthOrder].push(t));this._entityCollectionsByDepthOrder.length=0,this._entityCollectionsByDepthOrder=[],this._entityCollectionsByDepthOrder=Object.keys(e).sort((t,i)=>Number(t)-Number(i)).map(t=>e[Number(t)])}addLight(e){return e.addTo(this),this}preDrawNode(){this._isActive&&this._preDrawNodes()}drawNode(){this._isActive&&this._drawNodes()}isActive(){return this._isActive}setActive(e){this._isActive=e,this.renderer&&(this._isActive&&this._pickingId===-1?this._pickingId=this.renderer.addPickingCallback(this,this._entityCollectionPickingCallback):this._isActive||this._pickingId===-1||(this.renderer.removePickingCallback(this._pickingId),this._pickingId=-1));for(let t=0;t<this.childNodes.length;t++)this.childNodes[t].setActive(e)}setDrawMode(e){this.drawMode=e;for(let t=0;t<this.childNodes.length;t++)this.childNodes[t].setDrawMode(e)}updateBillboardsTexCoords(){for(let e=0;e<this.entityCollections.length;e++)this.entityCollections[e].billboardHandler.refreshTexCoordsArr()}frame(){}preFrame(){}_preDrawNodes(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e]._isActive&&this.childNodes[e]._preDrawNodes();if(this.show){this.preFrame();for(let e=0;e<this._entityCollectionsByDepthOrder.length;e++)this.drawEntityCollections(this._entityCollectionsByDepthOrder[e],e)}}_drawNodes(){for(let e=0;e<this.childNodes.length;e++)this.childNodes[e]._isActive&&this.childNodes[e]._drawNodes();this.show&&this.frame()}drawEntityCollections(e,t=0){this.renderer.enqueueEntityCollectionsToDraw(e,t)}drawPickingEntityCollections(e){if(e.length){let t=e.length;for(;t--;)e[t]._fadingOpacity&&e[t].billboardHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].geoObjectHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].labelHandler.drawPicking();for(t=e.length;t--;)e[t]._fadingOpacity&&e[t].rayHandler.drawPicking();for(t=e.length;t--;)e[t]._visibility&&e[t].polylineHandler.drawPicking();for(t=e.length;t--;)e[t]._visibility&&e[t].stripHandler.drawPicking()}}_entityCollectionPickingCallback(){}}const Ke=new class{constructor(){this._container=document.createElement("div"),this._container.classList.add("ogConsole"),this._container.style.display="none",document.body&&document.body.appendChild(this._container),this._visibility=!1}getVisibility(){return this._visibility}setVisibility(a){this._visibility!=a&&(this._visibility=a,this._visibility?this.show():this.hide())}show(){this._container.parentNode||document.body&&document.body.appendChild(this._container),this._container.style.display="block",this._visibility=!0}hide(){this._container.style.display="none",this._visibility=!1}logErr(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-error"),e.innerHTML="error: "+a,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}logWrn(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-warning"),e.innerHTML="warning: "+a,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}log(a){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.innerHTML=a,console.trace(a),this._container.appendChild(e),this.show()}};let ii=["FLOAT","DOUBLE","BOOL","INT","UINT","VEC2","VEC3","VEC4","DVEC2","DVEC3","DVEC4","BVEC2","BVEC3","BVEC4","IVEC2","IVEC3","IVEC4","UVEC2","UVEC3","UVEC4","MAT2","DMAT2","MAT3","DMAT3","MAT4","DMAT4","MAT2X3","MAT2X4","MAT3X2","MAT3X4","MAT4X2","MAT4X3","DMAT2X3","DMAT2X4","DMAT3X2","DMAT3X4","DMAT4X2","DMAT4X3","SAMPLER1D","SAMPLER2D","SAMPLER3D","SAMPLERCUBE","SAMPLER2DSHADOW","SAMPLER2DARRAY","INTXX","FLOATXX"];const ue={};for(let a=0;a<ii.length;a++)ue[ii[a]]=a;const kr={};for(let a=0;a<ii.length;a++)kr[ii[a].toLowerCase()]=ue[ii[a]];const Pe={u:[],a:[]};Pe.u[ue.MAT4]=function(a,e){a.gl.uniformMatrix4fv(e._pName,!1,e.value)},Pe.u[ue.MAT3]=function(a,e){a.gl.uniformMatrix3fv(e._pName,!1,e.value)},Pe.u[ue.FLOAT]=function(a,e){a.gl.uniform1f(e._pName,e.value)},Pe.u[ue.INT]=function(a,e){a.gl.uniform1i(e._pName,e.value)},Pe.u[ue.VEC2]=function(a,e){a.gl.uniform2fv(e._pName,e.value)},Pe.u[ue.VEC3]=function(a,e){a.gl.uniform3fv(e._pName,e.value)},Pe.u[ue.VEC4]=function(a,e){a.gl.uniform4fv(e._pName,e.value)},Pe.u[ue.SAMPLER2D]=function(a,e){let t=a.gl;t.activeTexture(t.TEXTURE0+a._textureID),t.bindTexture(t.TEXTURE_2D,e.value),t.uniform1i(e._pName,a._textureID),a._textureID++},Pe.u[ue.SAMPLERCUBE]=function(a,e){let t=a.gl;t.activeTexture(t.TEXTURE0+a._textureID),t.bindTexture(t.TEXTURE_CUBE_MAP,e.value),t.uniform1i(e._pName,a._textureID),a._textureID++},Pe.u[ue.SAMPLER2DARRAY]=function(a,e){let t=e.value,i=a.gl,r=t.length,s=new Int32Array(r);for(let n=0;n<r;n++)i.activeTexture(i.TEXTURE0+a._textureID+n),i.bindTexture(i.TEXTURE_2D,t[n]),s[n]=n;i.uniform1iv(e._pName,s)},Pe.u[ue.INTXX]=function(a,e){a.gl.uniform1iv(e._pName,e.value)},Pe.u[ue.FLOATXX]=function(a,e){a.gl.uniform1fv(e._pName,e.value)},Pe.a[ue.FLOAT]=function(a,e){a.gl.vertexAttrib1f(e._pName,e.value)},Pe.a[ue.VEC2]=function(a,e){a.gl.vertexAttrib2fv(e._pName,e.value)},Pe.a[ue.VEC3]=function(a,e){a.gl.vertexAttrib3fv(e._pName,e.value)};const Al=["BYTE","SHORT","UNSIGNED_BYTE","UNSIGNED_SHORT","FLOAT","HALF_FLOAT"];class X{constructor(e,t){this.name=e,this._programController=null,this._attributes={};for(let i in t.attributes)typeof t.attributes[i]=="string"||typeof t.attributes[i]=="number"?this._attributes[i]={type:t.attributes[i]}:this._attributes[i]=t.attributes[i];this._uniforms={};for(let i in t.uniforms)typeof t.uniforms[i]=="string"||typeof t.uniforms[i]=="number"?this._uniforms[i]={type:t.uniforms[i]}:this._uniforms[i]=t.uniforms[i];this.vertexShader=t.vertexShader,this.fragmentShader=t.fragmentShader,this.gl=null,this._variables={},this._p=null,this._textureID=0,this._attribArrays=[],this._attribDivisor=[],this.attributes={},this.uniforms={},this.vertexAttribDivisor=null,this.drawElementsInstanced=null}static bindBuffer(e,t){let i=e.gl;i&&(i.bindBuffer(i.ARRAY_BUFFER,t.value),i.vertexAttribPointer(t._pName,t.value.itemSize,t.itemType,t.normalized,0,0))}use(){this.gl&&this.gl.useProgram(this._p)}set(e){this._textureID=0;for(let t in e)this._variables[t].value=e[t],this._variables[t].func(this,this._variables[t])}apply(){this._textureID=0;let e=this._variables;for(let t in e)e[t].func(this,e[t])}drawIndexBuffer(e,t){let i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t),i.drawElements(e,t.numItems,i.UNSIGNED_SHORT,0)}drawArrays(e,t){this.gl.drawArrays(e,0,t)}_getShaderCompileStatus(e,t){if(!this.gl)return!1;const i=this.gl instanceof WebGL2RenderingContext;return this.gl.shaderSource(e,function(r,s){if(!s)return r;const n=r.split(`
93
93
  `),o=n.findIndex(l=>l.startsWith("#version"));return o!==-1?(n.splice(o+1,0,"#define WEBGL2"),n.join(`
94
- `)):s}(t,i)),this.gl.compileShader(e),!!this.gl.getShaderParameter(e,this.gl.COMPILE_STATUS)||(Qe.logErr(`Shader program "${this.name}":${this.gl.getShaderInfoLog(e)}.`),!1)}_createVertexShader(e){if(!this.gl)return;let t=this.gl.createShader(this.gl.VERTEX_SHADER);return t&&this._getShaderCompileStatus(t,e)?t:void 0}_createFragmentShader(e){if(!this.gl)return;let t=this.gl.createShader(this.gl.FRAGMENT_SHADER);return t&&this._getShaderCompileStatus(t,e)?t:void 0}disableAttribArrays(){let e=this.gl,t=this._attribArrays;for(let i=0,s=t.length;i<s;i++)e.disableVertexAttribArray(t[i]),this.vertexAttribDivisor(t[i],0)}enableAttribArrays(){let e=this.gl,t=this._attribArrays,i=this._attribDivisor;for(let s=0,r=t.length;s<r;s++)e.enableVertexAttribArray(t[s]),this.vertexAttribDivisor(t[s],i[s])}delete(){this.gl&&this.gl.deleteProgram(this._p)}createProgram(e){if(this.gl=e,this._p=this.gl.createProgram(),!this._p)return;let t=this._createFragmentShader(this.fragmentShader),i=this._createVertexShader(this.vertexShader);if(t&&i){if(e.attachShader(this._p,t),e.attachShader(this._p,i),e.linkProgram(this._p),!this.drawElementsInstanced)if(e.drawElementsInstanced)this.drawElementsInstanced=e.drawElementsInstanced.bind(e);else{let s=e.getExtension("ANGLE_instanced_arrays");s&&(this.drawElementsInstanced=s.drawElementsInstancedANGLE.bind(s))}if(!this.vertexAttribDivisor)if(e.vertexAttribDivisor)this.vertexAttribDivisor=e.vertexAttribDivisor.bind(e);else{let s=e.getExtension("ANGLE_instanced_arrays");s&&(this.vertexAttribDivisor=s.vertexAttribDivisorANGLE.bind(s))}if(!e.getProgramParameter(this._p,e.LINK_STATUS))return Qe.logErr(`Shader program "${this.name}": initialization failed. ${e.getProgramInfoLog(this._p)}.`),void e.deleteProgram(this._p);this.use();for(let s in this._attributes){this._variables[s]=this._attributes[s],this._attributes[s].func=X.bindBuffer;let r=this._attributes[s].itemType,n=r?r.trim().toUpperCase():"FLOAT";if(Al.indexOf(n)==-1?(Qe.logErr(`Shader program "${this.name}": attribute '${s}', item type '${this._attributes[s].itemType}' not exists.`),this._attributes[s].itemType=e.FLOAT):this._attributes[s].itemType=e[n],this._attributes[s].normalized=this._attributes[s].normalized||!1,this._attributes[s].divisor=this._attributes[s].divisor||0,this._p[s]=e.getAttribLocation(this._p,s),this._p[s]==null)return Qe.logErr(`Shader program "${this.name}": attribute '${s}' not exists.`),void e.deleteProgram(this._p);let o=this._attributes[s].type;typeof o=="string"&&(o=Bs[o.trim().toLowerCase()]);let l=this._attributes[s].divisor;if(o===_e.MAT4){let h=this._p[s];this._attribArrays.push(h,h+1,h+2,h+3),this._attribDivisor.push(l,l,l,l)}else this._attribArrays.push(this._p[s]),this._attribDivisor.push(l);e.enableVertexAttribArray(this._p[s]),this._attributes[s]._pName=this._p[s],this.attributes[s]=this._p[s]}for(let s in this._uniforms){if(typeof this._uniforms[s].type=="string"){let r=this._uniforms[s].type;this._uniforms[s].func=Se.u[Bs[r.trim().toLowerCase()]]}else this._uniforms[s].func=Se.u[this._uniforms[s].type];if(this._variables[s]=this._uniforms[s],this._p[s]=e.getUniformLocation(this._p,s),this._p[s]==null)return Qe.logErr(`Shader program "${this.name}": uniform '${s}' not exists.`),void e.deleteProgram(this._p);this._uniforms[s]._pName=this._p[s],this.uniforms[s]=this._p[s]}e.detachShader(this._p,t),e.detachShader(this._p,i),e.deleteShader(t),e.deleteShader(i)}}}const En=class Na{constructor(e){this.__id=Na.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._billboards=[],this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._texCoordBuffer=null,this._vertexBuffer=null,this._pickingColorBuffer=null,this._texCoordArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._pickingColorArr=new Float32Array([]),this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this.createPickingColorBuffer,this._buffersUpdateCallbacks[1]=this.createPositionBuffer,this._buffersUpdateCallbacks[2]=this.createSizeBuffer,this._buffersUpdateCallbacks[3]=this.createOffsetBuffer,this._buffersUpdateCallbacks[4]=this.createRgbaBuffer,this._buffersUpdateCallbacks[5]=this.createRotationBuffer,this._buffersUpdateCallbacks[6]=this.createTexCoordBuffer,this._buffersUpdateCallbacks[7]=this.createVertexBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}isEqual(e){return e&&e.__id===this.__id}static concArr(e,t){for(let i=0;i<t.length;i++)e.push(t[i])}initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.billboard||this._renderer.handler.addProgram(new X("billboard",{uniforms:{viewport:"vec2",u_texture:"sampler2d",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",uScaleByDistance:"vec3",opacity:"float",depthOffset:"float"},attributes:{a_vertices:"vec2",a_texCoord:"vec2",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_offset:"vec3",a_size:"vec2",a_rotation:"float",a_rgba:"vec4"},vertexShader:`precision highp float;
94
+ `)):r}(t,i)),this.gl.compileShader(e),!!this.gl.getShaderParameter(e,this.gl.COMPILE_STATUS)||(Ke.logErr(`Shader program "${this.name}":${this.gl.getShaderInfoLog(e)}.`),!1)}_createVertexShader(e){if(!this.gl)return;let t=this.gl.createShader(this.gl.VERTEX_SHADER);return t&&this._getShaderCompileStatus(t,e)?t:void 0}_createFragmentShader(e){if(!this.gl)return;let t=this.gl.createShader(this.gl.FRAGMENT_SHADER);return t&&this._getShaderCompileStatus(t,e)?t:void 0}disableAttribArrays(){let e=this.gl,t=this._attribArrays;for(let i=0,r=t.length;i<r;i++)e.disableVertexAttribArray(t[i]),this.vertexAttribDivisor(t[i],0)}enableAttribArrays(){let e=this.gl,t=this._attribArrays,i=this._attribDivisor;for(let r=0,s=t.length;r<s;r++)e.enableVertexAttribArray(t[r]),this.vertexAttribDivisor(t[r],i[r])}delete(){this.gl&&this.gl.deleteProgram(this._p)}createProgram(e){if(this.gl=e,this._p=this.gl.createProgram(),!this._p)return;let t=this._createFragmentShader(this.fragmentShader),i=this._createVertexShader(this.vertexShader);if(t&&i){if(e.attachShader(this._p,t),e.attachShader(this._p,i),e.linkProgram(this._p),!this.drawElementsInstanced)if(e.drawElementsInstanced)this.drawElementsInstanced=e.drawElementsInstanced.bind(e);else{let r=e.getExtension("ANGLE_instanced_arrays");r&&(this.drawElementsInstanced=r.drawElementsInstancedANGLE.bind(r))}if(!this.vertexAttribDivisor)if(e.vertexAttribDivisor)this.vertexAttribDivisor=e.vertexAttribDivisor.bind(e);else{let r=e.getExtension("ANGLE_instanced_arrays");r&&(this.vertexAttribDivisor=r.vertexAttribDivisorANGLE.bind(r))}if(!e.getProgramParameter(this._p,e.LINK_STATUS))return Ke.logErr(`Shader program "${this.name}": initialization failed. ${e.getProgramInfoLog(this._p)}.`),void e.deleteProgram(this._p);this.use();for(let r in this._attributes){this._variables[r]=this._attributes[r],this._attributes[r].func=X.bindBuffer;let s=this._attributes[r].itemType,n=s?s.trim().toUpperCase():"FLOAT";if(Al.indexOf(n)==-1?(Ke.logErr(`Shader program "${this.name}": attribute '${r}', item type '${this._attributes[r].itemType}' not exists.`),this._attributes[r].itemType=e.FLOAT):this._attributes[r].itemType=e[n],this._attributes[r].normalized=this._attributes[r].normalized||!1,this._attributes[r].divisor=this._attributes[r].divisor||0,this._p[r]=e.getAttribLocation(this._p,r),this._p[r]==null)return Ke.logErr(`Shader program "${this.name}": attribute '${r}' not exists.`),void e.deleteProgram(this._p);let o=this._attributes[r].type;typeof o=="string"&&(o=kr[o.trim().toLowerCase()]);let l=this._attributes[r].divisor;if(o===ue.MAT4){let h=this._p[r];this._attribArrays.push(h,h+1,h+2,h+3),this._attribDivisor.push(l,l,l,l)}else this._attribArrays.push(this._p[r]),this._attribDivisor.push(l);e.enableVertexAttribArray(this._p[r]),this._attributes[r]._pName=this._p[r],this.attributes[r]=this._p[r]}for(let r in this._uniforms){if(typeof this._uniforms[r].type=="string"){let s=this._uniforms[r].type;this._uniforms[r].func=Pe.u[kr[s.trim().toLowerCase()]]}else this._uniforms[r].func=Pe.u[this._uniforms[r].type];if(this._variables[r]=this._uniforms[r],this._p[r]=e.getUniformLocation(this._p,r),this._p[r]==null)return Ke.logErr(`Shader program "${this.name}": uniform '${r}' not exists.`),void e.deleteProgram(this._p);this._uniforms[r]._pName=this._p[r],this.uniforms[r]=this._p[r]}e.detachShader(this._p,t),e.detachShader(this._p,i),e.deleteShader(t),e.deleteShader(i)}}}const An=class Ho{constructor(e){this.__id=Ho.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._billboards=[],this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._texCoordBuffer=null,this._vertexBuffer=null,this._pickingColorBuffer=null,this._texCoordArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._pickingColorArr=new Float32Array([]),this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this.createPickingColorBuffer,this._buffersUpdateCallbacks[1]=this.createPositionBuffer,this._buffersUpdateCallbacks[2]=this.createSizeBuffer,this._buffersUpdateCallbacks[3]=this.createOffsetBuffer,this._buffersUpdateCallbacks[4]=this.createRgbaBuffer,this._buffersUpdateCallbacks[5]=this.createRotationBuffer,this._buffersUpdateCallbacks[6]=this.createTexCoordBuffer,this._buffersUpdateCallbacks[7]=this.createVertexBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}isEqual(e){return e&&e.__id===this.__id}static concArr(e,t){for(let i=0;i<t.length;i++)e.push(t[i])}initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.billboard||this._renderer.handler.addProgram(new X("billboard",{uniforms:{viewport:"vec2",u_texture:"sampler2d",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",uScaleByDistance:"vec3",opacity:"float",depthOffset:"float"},attributes:{a_vertices:"vec2",a_texCoord:"vec2",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_offset:"vec3",a_size:"vec2",a_rotation:"float",a_rgba:"vec4"},vertexShader:`precision highp float;
95
95
  #define EMPTY - 1.0
96
96
  #define RTL 1.0
97
97
  vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute vec2 a_vertices;attribute vec2 a_texCoord;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute vec2 a_size;attribute float a_rotation;attribute vec4 a_rgba;varying vec2 v_texCoords;varying vec4 v_rgba;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform vec3 uScaleByDistance;uniform float opacity;uniform float planetRadius;uniform vec2 viewport;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;v_texCoords=a_texCoord;vec3 look=a_positions-cameraPos;float lookDist=length(look);v_rgba=a_rgba;if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(uScaleByDistance[0],uScaleByDistance[1],lookDist))*(1.0-step(uScaleByDistance[2],lookDist));mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 v=screenPos+rotate2d(a_rotation)*(a_vertices*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:"precision highp float;uniform sampler2D u_texture;varying vec2 v_texCoords;varying vec4 v_rgba;void main(){vec4 color=texture2D(u_texture,v_texCoords);if(color.a<0.1)discard;gl_FragColor=color*v_rgba;}"})),this._renderer.handler.programs.billboardPicking||this._renderer.handler.addProgram(new X("billboardPicking",{uniforms:{viewport:"vec2",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",uScaleByDistance:"vec3",opacity:"float",depthOffset:"float"},attributes:{a_vertices:"vec2",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_offset:"vec3",a_size:"vec2",a_rotation:"float",a_rgba:"vec4"},vertexShader:`precision highp float;
98
98
  #define EMPTY - 1.0
99
99
  #define RTL 1.0
100
- vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute vec2 a_vertices;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute vec2 a_size;attribute float a_rotation;attribute vec4 a_rgba;varying vec3 v_rgb;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform vec3 uScaleByDistance;uniform float opacity;uniform float planetRadius;uniform vec2 viewport;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;vec3 look=a_positions-cameraPos;float lookDist=length(look);v_rgb=a_rgba.rgb;if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(uScaleByDistance[0],uScaleByDistance[1],lookDist))*(1.0-step(uScaleByDistance[2],lookDist));mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 v=screenPos+rotate2d(a_rotation)*(a_vertices*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:"precision highp float;varying vec3 v_rgb;void main(){gl_FragColor=vec4(v_rgb,1.0);}"})))}setRenderer(e){this._renderer=e,this.initProgram()}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_removeBillboards(){let e=this._billboards.length;for(;e--;){let t=this._billboards[e];t._handlerIndex=-1,t._handler=null,t._isReady=!1,t._lockId=-1}this._billboards.length=0,this._billboards=[]}clear(){this._texCoordArr=null,this._vertexArr=null,this._positionHighArr=null,this._positionLowArr=null,this._sizeArr=null,this._offsetArr=null,this._rgbaArr=null,this._rotationArr=null,this._pickingColorArr=null,this._texCoordArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._pickingColorArr=new Float32Array([]),this._removeBillboards(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e.deleteBuffer(this._positionHighBuffer),e.deleteBuffer(this._positionLowBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._offsetBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._rotationBuffer),e.deleteBuffer(this._vertexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._pickingColorBuffer)}this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._vertexBuffer=null,this._texCoordBuffer=null,this._pickingColorBuffer=null}update(){if(this._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}add(e){e._handlerIndex==-1&&(e._isReady=!0,e._handler=this,e._handlerIndex=this._billboards.length,this._billboards.push(e))}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.billboard.activate();let i=t.programs.billboard._program,s=i.attributes,r=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(r.depthOffset,o.polygonOffsetUnits),n.uniform1i(r.u_texture,0),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(r.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(r.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(r.uScaleByDistance,o.scaleByDistance),n.uniform1f(r.opacity,o._fadingOpacity),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(s.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(s.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(s.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(s.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(s.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(s.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(s.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(r.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(r.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(s.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_pickingPASS(){let e=this._renderer,t=e.handler;t.programs.billboardPicking.activate();let i=t.programs.billboardPicking._program,s=i.attributes,r=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(r.depthOffset,o.polygonOffsetUnits),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(r.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(r.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(r.uScaleByDistance,o.scaleByDistance),n.uniform1f(r.opacity,o._fadingOpacity),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(s.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(s.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(s.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._pickingColorBuffer),n.vertexAttribPointer(s.a_rgba,this._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(s.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(s.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(r.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(r.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(s.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}draw(){this._billboards.length&&(this.update(),this._displayPASS())}drawPicking(){this._billboards.length&&this.pickingEnabled&&this._pickingPASS()}reindexBillboardsArray(e){let t=this._billboards;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}_removeBillboard(e){let t=e._handlerIndex;this._billboards.splice(t,1);let i=24*t;this._rgbaArr=le(this._rgbaArr,i,24),i=18*t,this._positionHighArr=le(this._positionHighArr,i,18),this._positionLowArr=le(this._positionLowArr,i,18),this._offsetArr=le(this._offsetArr,i,18),this._pickingColorArr=le(this._pickingColorArr,i,18),i=12*t,this._vertexArr=le(this._vertexArr,i,12),this._sizeArr=le(this._sizeArr,i,12),this._texCoordArr=le(this._texCoordArr,i,12),i=6*t,this._rotationArr=le(this._rotationArr,i,6),this.reindexBillboardsArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null,e._isReady=!1,e._lockId=-1}setAlignedAxisArr(e,t){}remove(e){e._handler&&(e._isReady&&this.__id===e._handler.__id?this._removeBillboard(e):e._handler=null)}setPositionArr(e,t,i){let s=18*e,r=this._positionHighArr,n=t.x,o=t.y,l=t.z;r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,r=this._positionLowArr,n=i.x,o=i.y,l=i.z,r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,this._changedBuffers[1]=!0}setPickingColorArr(e,t){let i=18*e,s=this._pickingColorArr,r=t.x/255,n=t.y/255,o=t.z/255;s[i]=r,s[i+1]=n,s[i+2]=o,s[i+3]=r,s[i+4]=n,s[i+5]=o,s[i+6]=r,s[i+7]=n,s[i+8]=o,s[i+9]=r,s[i+10]=n,s[i+11]=o,s[i+12]=r,s[i+13]=n,s[i+14]=o,s[i+15]=r,s[i+16]=n,s[i+17]=o,this._changedBuffers[0]=!0}setSizeArr(e,t,i){let s=12*e,r=this._sizeArr,n=t,o=i;r[s]=n,r[s+1]=o,r[s+2]=n,r[s+3]=o,r[s+4]=n,r[s+5]=o,r[s+6]=n,r[s+7]=o,r[s+8]=n,r[s+9]=o,r[s+10]=n,r[s+11]=o,this._changedBuffers[2]=!0}setOffsetArr(e,t){let i=18*e,s=this._offsetArr,r=t.x,n=t.y,o=t.z;s[i]=r,s[i+1]=n,s[i+2]=o,s[i+3]=r,s[i+4]=n,s[i+5]=o,s[i+6]=r,s[i+7]=n,s[i+8]=o,s[i+9]=r,s[i+10]=n,s[i+11]=o,s[i+12]=r,s[i+13]=n,s[i+14]=o,s[i+15]=r,s[i+16]=n,s[i+17]=o,this._changedBuffers[3]=!0}setRgbaArr(e,t){let i=24*e,s=this._rgbaArr,r=t.x,n=t.y,o=t.z,l=t.w;s[i]=r,s[i+1]=n,s[i+2]=o,s[i+3]=l,s[i+4]=r,s[i+5]=n,s[i+6]=o,s[i+7]=l,s[i+8]=r,s[i+9]=n,s[i+10]=o,s[i+11]=l,s[i+12]=r,s[i+13]=n,s[i+14]=o,s[i+15]=l,s[i+16]=r,s[i+17]=n,s[i+18]=o,s[i+19]=l,s[i+20]=r,s[i+21]=n,s[i+22]=o,s[i+23]=l,this._changedBuffers[4]=!0}setRotationArr(e,t){let i=6*e,s=this._rotationArr;s[i]=t,s[i+1]=t,s[i+2]=t,s[i+3]=t,s[i+4]=t,s[i+5]=t,this._changedBuffers[5]=!0}setTexCoordArr(e,t){let i=12*e,s=this._texCoordArr;s[i]=t[0],s[i+1]=t[1],s[i+2]=t[2],s[i+3]=t[3],s[i+4]=t[4],s[i+5]=t[5],s[i+6]=t[6],s[i+7]=t[7],s[i+8]=t[8],s[i+9]=t[9],s[i+10]=t[10],s[i+11]=t[11],this._changedBuffers[6]=!0}setVisibility(e,t){let i;i=t?[-.5,.5,-.5,-.5,.5,-.5,.5,-.5,.5,.5,-.5,.5]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e,s=this._vertexArr;s[i]=t[0],s[i+1]=t[1],s[i+2]=t[2],s[i+3]=t[3],s[i+4]=t[4],s[i+5]=t[5],s[i+6]=t[6],s[i+7]=t[7],s[i+8]=t[8],s[i+9]=t[9],s[i+10]=t[10],s[i+11]=t[11],this._changedBuffers[7]=!0}createPositionBuffer(){let e=this._renderer.handler,t=this._positionHighArr.length/3;this._positionHighBuffer&&this._positionHighBuffer.numItems===t||(e.gl.deleteBuffer(this._positionHighBuffer),e.gl.deleteBuffer(this._positionLowBuffer),this._positionHighBuffer=e.createStreamArrayBuffer(3,t),this._positionLowBuffer=e.createStreamArrayBuffer(3,t)),e.setStreamArrayBuffer(this._positionHighBuffer,this._positionHighArr),e.setStreamArrayBuffer(this._positionLowBuffer,this._positionLowArr)}createSizeBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createArrayBuffer(this._sizeArr,2,this._sizeArr.length/2)}createOffsetBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._offsetBuffer),this._offsetBuffer=e.createArrayBuffer(this._offsetArr,3,this._offsetArr.length/3)}createRgbaBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaBuffer=e.createArrayBuffer(this._rgbaArr,4,this._rgbaArr.length/4)}createRotationBuffer(){let e=this._renderer.handler;this._rotationBuffer&&this._rotationBuffer.numItems===this._rotationArr.length||(e.gl.deleteBuffer(this._rotationBuffer),this._rotationBuffer=e.createStreamArrayBuffer(1,this._rotationArr.length)),e.setStreamArrayBuffer(this._rotationBuffer,this._rotationArr)}createVertexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,2,this._vertexArr.length/2)}createTexCoordBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,2,this._texCoordArr.length/2)}createPickingColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}refreshTexCoordsArr(){}};En.__counter__=0;let An=En;class Ll extends An{constructor(e){super(e),this._billboards=[]}add(e){if(e._handlerIndex==-1){super.add(e),this._addBillboardToArrays(e),this.refresh();let t=e.getSrc()||e.getImage()&&e.getImage().src;t&&e.setSrc(t)}}_addBillboardToArrays(e){e.getVisibility()?this._vertexArr=ae(this._vertexArr,[-.5,.5,-.5,-.5,.5,-.5,.5,-.5,.5,.5,-.5,.5]):this._vertexArr=ae(this._vertexArr,[0,0,0,0,0,0,0,0,0,0,0,0]),this._texCoordArr=ae(this._texCoordArr,[0,0,0,0,0,0,0,0,0,0,0,0]);let t,i=e._positionHigh.x,s=e._positionHigh.y,r=e._positionHigh.z;this._positionHighArr=ae(this._positionHighArr,[i,s,r,i,s,r,i,s,r,i,s,r,i,s,r,i,s,r]),i=e._positionLow.x,s=e._positionLow.y,r=e._positionLow.z,this._positionLowArr=ae(this._positionLowArr,[i,s,r,i,s,r,i,s,r,i,s,r,i,s,r,i,s,r]),i=e._width,s=e._height,this._sizeArr=ae(this._sizeArr,[i,s,i,s,i,s,i,s,i,s,i,s]),i=e._offset.x,s=e._offset.y,r=e._offset.z,this._offsetArr=ae(this._offsetArr,[i,s,r,i,s,r,i,s,r,i,s,r,i,s,r,i,s,r]),i=e._color.x,s=e._color.y,r=e._color.z,t=e._color.w,this._rgbaArr=ae(this._rgbaArr,[i,s,r,t,i,s,r,t,i,s,r,t,i,s,r,t,i,s,r,t,i,s,r,t]),i=e._rotation,this._rotationArr=ae(this._rotationArr,[i,i,i,i,i,i]),i=e._entity._pickingColor.x/255,s=e._entity._pickingColor.y/255,r=e._entity._pickingColor.z/255,this._pickingColorArr=ae(this._pickingColorArr,[i,s,r,i,s,r,i,s,r,i,s,r,i,s,r,i,s,r])}get billboards(){return this._billboards}refreshTexCoordsArr(){if(this._entityCollection&&this._renderer){let e=this._renderer.billboardsTextureAtlas;for(let t=0;t<this._billboards.length;t++){let i=this._billboards[t],s=i.getImage();if(s){let r=e.get(s.__nodeIndex);r&&this.setTexCoordArr(i._handlerIndex,r.texCoords)}}}}}class Pl{constructor(e){this.isFree=!0,this._geoObjectHandler=e,this.geoObjects=[],this.numInstances=0,this._colorTexture=null,this._colorTextureSrc=null,this._colorTextureImage=null,this._normalTexture=null,this._normalTextureSrc=null,this._normalTextureImage=null,this._metallicRoughnessTexture=null,this._metallicRoughnessTextureSrc=null,this._metallicRoughnessTextureImage=null,this._sizeArr=[],this._translateArr=[],this._vertexArr=[],this._rtcPositionHighArr=[],this._rtcPositionLowArr=[],this._qRotArr=[],this._rgbaArr=[],this._normalsArr=[],this._indicesArr=[],this._pickingColorArr=[],this._visibleArr=[],this._texCoordArr=[],this._localPositionArr=[],this._sizeBuffer=null,this._translateBuffer=null,this._vertexBuffer=null,this._rtcPositionHighBuffer=null,this._rtcPositionLowBuffer=null,this._qRotBuffer=null,this._rgbaBuffer=null,this._normalsBuffer=null,this._indicesBuffer=null,this._pickingColorBuffer=null,this._visibleBuffer=null,this._texCoordBuffer=null,this._localPositionBuffer=null,this._materialParams=new Float32Array(9),this._materialShininess=0,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[In]=this.createPickingColorBuffer,this._buffersUpdateCallbacks[Mn]=this.createNormalsBuffer,this._buffersUpdateCallbacks[Sn]=this.createRgbaBuffer,this._buffersUpdateCallbacks[Rn]=this.createIndicesBuffer,this._buffersUpdateCallbacks[Ln]=this.createVertexBuffer,this._buffersUpdateCallbacks[kn]=this.createSizeBuffer,this._buffersUpdateCallbacks[zn]=this.createVisibleBuffer,this._buffersUpdateCallbacks[Dn]=this.createTexCoordBuffer,this._buffersUpdateCallbacks[Bn]=this.createQRotBuffer,this._buffersUpdateCallbacks[Fn]=this.createTranslateBuffer,this._buffersUpdateCallbacks[Pn]=this.createRTCPositionBuffer,this._buffersUpdateCallbacks[On]=this.createLocalPositionBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}setMaterialAmbient(e,t,i){this._materialParams[0]=e,this._materialParams[1]=t,this._materialParams[2]=i}setMaterialDiffuse(e,t,i){this._materialParams[3]=e,this._materialParams[4]=t,this._materialParams[5]=i}setMaterialSpecular(e,t,i){this._materialParams[6]=e,this._materialParams[7]=t,this._materialParams[8]=i}setMaterialShininess(e){this._materialShininess=e}setMaterialParams(e,t,i,s){this.setMaterialAmbient(e[0],e[1],e[2]),this.setMaterialDiffuse(t[0],t[1],t[2]),this.setMaterialSpecular(i[0],i[1],i[2]),this.setMaterialShininess(s)}drawOpaque(e){let t=e.gl,i=e.uniforms,s=e.attributes;t.bindBuffer(t.ARRAY_BUFFER,this._qRotBuffer),t.vertexAttribPointer(s.qRot,this._qRotBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._sizeBuffer),t.vertexAttribPointer(s.aScale,this._sizeBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._translateBuffer),t.vertexAttribPointer(s.aTranslate,this._translateBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._localPositionBuffer),t.vertexAttribPointer(s.aLocalPosition,this._localPositionBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._visibleBuffer),t.vertexAttribPointer(s.aDispose,this._visibleBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(i.uUseTexture,this._colorTexture?1:0),t.bindBuffer(t.ARRAY_BUFFER,this._rgbaBuffer),t.vertexAttribPointer(s.aColor,this._rgbaBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform3fv(i.materialParams,this._materialParams),t.uniform1f(i.materialShininess,this._materialShininess),this._drawElementsInstanced(e)}drawTransparent(e){let t=e.gl,i=e.uniforms,s=e.attributes;t.bindBuffer(t.ARRAY_BUFFER,this._qRotBuffer),t.vertexAttribPointer(s.qRot,this._qRotBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._sizeBuffer),t.vertexAttribPointer(s.aScale,this._sizeBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._translateBuffer),t.vertexAttribPointer(s.aTranslate,this._translateBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._localPositionBuffer),t.vertexAttribPointer(s.aLocalPosition,this._localPositionBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._visibleBuffer),t.vertexAttribPointer(s.aDispose,this._visibleBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(i.uUseTexture,this._colorTexture?1:0),t.uniform3fv(i.materialParams,this._materialParams),t.uniform1f(i.materialShininess,this._materialShininess),t.bindBuffer(t.ARRAY_BUFFER,this._rgbaBuffer),t.vertexAttribPointer(s.aColor,this._rgbaBuffer.itemSize,t.FLOAT,!1,0,0),this._drawElementsInstanced(e)}_drawElementsInstanced(e){let t=e.gl,i=e.uniforms,s=e.attributes,r=this._geoObjectHandler._renderer;t.bindBuffer(t.ARRAY_BUFFER,this._rtcPositionHighBuffer),t.vertexAttribPointer(s.aRTCPositionHigh,this._rtcPositionHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._rtcPositionLowBuffer),t.vertexAttribPointer(s.aRTCPositionLow,this._rtcPositionLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._normalsBuffer),t.vertexAttribPointer(s.aVertexNormal,this._normalsBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.vertexAttribPointer(s.aVertexPosition,this._vertexBuffer.itemSize,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._colorTexture||r.handler.defaultTexture),t.uniform1i(i.uTexture,0),t.bindBuffer(t.ARRAY_BUFFER,this._texCoordBuffer),t.vertexAttribPointer(s.aTexCoord,this._texCoordBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),e.drawElementsInstanced(t.TRIANGLES,this._indicesBuffer.numItems,t.UNSIGNED_INT,0,this.numInstances)}async loadColorTexture(){if(this._geoObjectHandler._renderer){if(!this._colorTextureSrc)return this._colorTextureImage?(await this._colorTextureImage.decode(),void this._createColorTexture(this._colorTextureImage)):void 0;{const e=await Ni(this._colorTextureSrc);this._createColorTexture(e)}}}async loadNormalTexture(){if(this._geoObjectHandler._renderer){if(!this._normalTextureSrc)return this._normalTextureImage?(await this._normalTextureImage.decode(),void this._createNormalTexture(this._normalTextureImage)):void 0;{const e=await Ni(this._normalTextureSrc);this._createNormalTexture(e)}}}async loadMetallicRoughnessTexture(){if(this._geoObjectHandler._renderer){if(!this._metallicRoughnessTextureSrc)return this._metallicRoughnessTextureImage?(await this._metallicRoughnessTextureImage.decode(),void this._createMetallicRoughnessTexture(this._metallicRoughnessTextureImage)):void 0;{const e=await Ni(this._metallicRoughnessTextureSrc);this._createMetallicRoughnessTexture(e)}}}clear(){this.numInstances=0,this.geoObjects=[],this._sizeArr=[],this._translateArr=[],this._vertexArr=[],this._rtcPositionHighArr=[],this._rtcPositionLowArr=[],this._qRotArr=[],this._rgbaArr=[],this._normalsArr=[],this._indicesArr=[],this._pickingColorArr=[],this._visibleArr=[],this._texCoordArr=[],this._localPositionArr=[],this._deleteBuffers(),this.isFree=!1}_deleteBuffers(){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let e=this._geoObjectHandler._renderer.handler,t=e.gl;e.deleteTexture(this._colorTexture),e.deleteTexture(this._normalTexture),e.deleteTexture(this._metallicRoughnessTexture),this._colorTexture=null,this._normalTexture=null,this._metallicRoughnessTexture=null,t.deleteBuffer(this._sizeBuffer),t.deleteBuffer(this._translateBuffer),t.deleteBuffer(this._vertexBuffer),t.deleteBuffer(this._rtcPositionHighBuffer),t.deleteBuffer(this._rtcPositionLowBuffer),t.deleteBuffer(this._qRotBuffer),t.deleteBuffer(this._rgbaBuffer),t.deleteBuffer(this._normalsBuffer),t.deleteBuffer(this._indicesBuffer),t.deleteBuffer(this._pickingColorBuffer),t.deleteBuffer(this._visibleBuffer),t.deleteBuffer(this._texCoordBuffer),t.deleteBuffer(this._localPositionBuffer)}this._sizeBuffer=null,this._translateBuffer=null,this._vertexBuffer=null,this._rtcPositionHighBuffer=null,this._rtcPositionLowBuffer=null,this._qRotBuffer=null,this._rgbaBuffer=null,this._normalsBuffer=null,this._indicesBuffer=null,this._pickingColorBuffer=null,this._visibleBuffer=null,this._texCoordBuffer=null,this._localPositionBuffer=null}createVertexBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexArr=se(this._vertexArr),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,3,this._vertexArr.length/3)}createVisibleBuffer(){const e=this._geoObjectHandler._renderer.handler,t=this._visibleArr.length;this._visibleBuffer&&this._visibleBuffer.numItems===t||(e.gl.deleteBuffer(this._visibleBuffer),this._visibleBuffer=e.createStreamArrayBuffer(1,t)),this._visibleArr=se(this._visibleArr),e.setStreamArrayBuffer(this._visibleBuffer,this._visibleArr)}createSizeBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._sizeArr.length/3;this._sizeBuffer&&this._sizeBuffer.numItems===t||(e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createStreamArrayBuffer(3,t)),this._sizeArr=se(this._sizeArr),e.setStreamArrayBuffer(this._sizeBuffer,this._sizeArr)}createTranslateBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._translateArr.length/3;this._translateBuffer&&this._translateBuffer.numItems===t||(e.gl.deleteBuffer(this._translateBuffer),this._translateBuffer=e.createStreamArrayBuffer(3,t)),this._translateArr=se(this._translateArr),e.setStreamArrayBuffer(this._translateBuffer,this._translateArr)}createLocalPositionBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._localPositionArr.length/3;this._localPositionBuffer&&this._localPositionBuffer.numItems===t||(e.gl.deleteBuffer(this._localPositionBuffer),this._localPositionBuffer=e.createStreamArrayBuffer(3,t)),this._localPositionArr=se(this._localPositionArr),e.setStreamArrayBuffer(this._localPositionBuffer,this._localPositionArr)}createTexCoordBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordArr=se(this._texCoordArr),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,2,this._texCoordArr.length/2)}createRTCPositionBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._rtcPositionHighArr.length/3;this._rtcPositionHighBuffer&&this._rtcPositionHighBuffer.numItems===t||(e.gl.deleteBuffer(this._rtcPositionHighBuffer),e.gl.deleteBuffer(this._rtcPositionLowBuffer),this._rtcPositionHighBuffer=e.createStreamArrayBuffer(3,t),this._rtcPositionLowBuffer=e.createStreamArrayBuffer(3,t)),this._rtcPositionHighArr=se(this._rtcPositionHighArr),this._rtcPositionLowArr=se(this._rtcPositionLowArr),e.setStreamArrayBuffer(this._rtcPositionHighBuffer,this._rtcPositionHighArr),e.setStreamArrayBuffer(this._rtcPositionLowBuffer,this._rtcPositionLowArr)}createRgbaBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._rgbaArr.length/4;this._rgbaBuffer&&this._rgbaBuffer.numItems===t||(e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaBuffer=e.createStreamArrayBuffer(4,t)),this._rgbaArr=se(this._rgbaArr),e.setStreamArrayBuffer(this._rgbaBuffer,this._rgbaArr)}createQRotBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._qRotArr.length/4;this._qRotBuffer&&this._qRotBuffer.numItems===t||(e.gl.deleteBuffer(this._qRotBuffer),this._qRotBuffer=e.createStreamArrayBuffer(4,t)),this._qRotArr=se(this._qRotArr),e.setStreamArrayBuffer(this._qRotBuffer,this._qRotArr)}createNormalsBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._normalsBuffer),this._normalsArr=se(this._normalsArr),this._normalsBuffer=e.createArrayBuffer(this._normalsArr,3,this._normalsArr.length/3)}createIndicesBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._indicesBuffer),this._indicesArr=se(this._indicesArr,Uint32Array),this._indicesBuffer=e.createElementArrayBuffer(this._indicesArr,1,this._indicesArr.length)}createPickingColorBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorArr=se(this._pickingColorArr),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}update(){if(this._geoObjectHandler._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1);this.isFree=!0}}_createColorTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._colorTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}_createNormalTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._normalTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}_createMetallicRoughnessTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._metallicRoughnessTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}}const Ln=0,Pn=1,Sn=2,Mn=3,Rn=4,Bn=5,kn=6,In=7,zn=8,Dn=9,Fn=10,On=11;function Le(a,e=0,t=0,i=1,...s){const r=e*t;for(let n=r,o=r+t;n<o;n++)a[n]=s[n%i];return a}const Nn=class Ha{constructor(e){this.__id=Ha.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderNode=null,this._renderer=null,this._geoObjects=[],this._instanceDataMap=new Map,this._instanceDataMapValues=[],this._dataTagUpdateQueue=[],this._relativeCenter=new v,this._rtcEyePositionHigh=new Float32Array([0,0,0]),this._rtcEyePositionLow=new Float32Array([0,0,0])}initProgram(){this._renderer&&(this._renderer.handler.programs.geo_object||this._renderer.handler.addProgram(new X("geo_object",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",eyePositionHigh:"vec3",eyePositionLow:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",sunPosition:"vec3",materialParams:"vec3",materialShininess:"float",uTexture:"sampler2d",uUseTexture:"float",useLighting:"float"},attributes:{aVertexPosition:"vec3",aVertexNormal:"vec3",aTexCoord:"vec2",aLocalPosition:{type:"vec3",divisor:1},aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aColor:{type:"vec4",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1}},vertexShader:"precision highp float;vec3 qRotate(vec4 q,vec3 v){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}attribute vec3 aVertexPosition;attribute vec3 aVertexNormal;attribute vec3 aRTCPositionHigh;attribute vec3 aRTCPositionLow;attribute vec4 aColor;attribute vec3 aScale;attribute vec3 aTranslate;attribute float aDispose;attribute float aUseTexture;attribute vec2 aTexCoord;attribute vec4 qRot;attribute vec3 aLocalPosition;uniform vec3 uScaleByDistance;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;varying vec3 cameraPosition;varying vec3 vNormal;varying vec3 v_vertex;varying vec4 vColor;varying float vDispose;varying vec2 vTexCoords;void main(void){if(aDispose==0.0){return;}vColor=aColor;vTexCoords=aTexCoord;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=aRTCPositionHigh-rtcEyePositionHigh;vec3 lowDiff=aRTCPositionLow-rtcEyePositionLow;cameraPosition=eyePositionHigh+eyePositionLow;highDiff=highDiff*step(1.0,length(highDiff));vec4 positionInViewSpace=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);float lookLength=length(positionInViewSpace.xyz);vNormal=normalize(qRotate(qRot,aVertexNormal));float scd=uScaleByDistance[2]*clamp(lookLength,uScaleByDistance[0],uScaleByDistance[1])/uScaleByDistance[0];vec3 vert=qRotate(qRot,scd*(aVertexPosition*aScale+aTranslate))+scd*aLocalPosition;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff+lowDiff+vert,1.0);v_vertex=positionInViewSpace.xyz+vert;}",fragmentShader:"precision highp float;uniform vec3 sunPosition;uniform vec3 materialParams[3];uniform float materialShininess;uniform sampler2D uTexture;uniform float uUseTexture;uniform float useLighting;varying vec3 cameraPosition;varying vec3 v_vertex;varying vec4 vColor;varying vec3 vNormal;varying vec2 vTexCoords;void main(void){vec3 lightWeighting=vec3(1.0);if(useLighting!=0.0){vec3 normal=normalize(vNormal);vec3 light_dir=normalize(sunPosition);vec3 look_dir=normalize(cameraPosition-v_vertex);float diffuse=max(dot(normal,light_dir),0.0);vec3 refl_dir=reflect(-light_dir,normal);float refl=max(dot(refl_dir,look_dir),0.0);float specular=pow(refl,materialShininess)*step(1e-4,diffuse);lightWeighting=vColor.rgb*materialParams[0]+materialParams[1]*diffuse+materialParams[2]*specular;}else{lightWeighting=vColor.rgb;}if(uUseTexture>0.0){vec4 texColor=texture2D(uTexture,vTexCoords);gl_FragColor=vec4(texColor.rgb*lightWeighting,texColor.a);}else{gl_FragColor=vec4(lightWeighting,vColor.a);}}"})),this._renderer.handler.programs.geo_object_picking||this._renderer.handler.addProgram(new X("geo_object_picking",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",pickingScale:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3"},attributes:{aVertexPosition:"vec3",aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aPickingColor:{type:"vec3",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aLocalPosition:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1}},vertexShader:"precision highp float;vec3 qRotate(vec4 q,vec3 v){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}attribute vec3 aVertexPosition;attribute vec3 aRTCPositionHigh;attribute vec3 aRTCPositionLow;attribute vec3 aPickingColor;attribute vec3 aScale;attribute vec3 aTranslate;attribute float aDispose;attribute vec4 qRot;attribute vec3 aLocalPosition;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform vec3 uScaleByDistance;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 pickingScale;varying vec3 vColor;void main(void){if(aDispose==0.0){return;}vColor=aPickingColor;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=aRTCPositionHigh-rtcEyePositionHigh;vec3 lowDiff=aRTCPositionLow-rtcEyePositionLow;highDiff=highDiff*step(1.0,length(highDiff));vec4 positionInViewSpace=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);float lookLength=length(positionInViewSpace.xyz);float scd=uScaleByDistance[2]*clamp(lookLength,uScaleByDistance[0],uScaleByDistance[1])/uScaleByDistance[0];vec3 vert=qRotate(qRot,scd*pickingScale*(aVertexPosition*aScale+aTranslate))+scd*aLocalPosition;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff+lowDiff+vert,1.0);}",fragmentShader:"precision highp float;varying vec3 vColor;void main(){gl_FragColor=vec4(vColor,1.0);}"})),this._renderer.handler.programs.geo_object_depth||this._renderer.handler.addProgram(new X("geo_object_depth",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",frustumPickingColor:"float"},attributes:{aVertexPosition:"vec3",aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1},aLocalPosition:{type:"vec3",divisor:1}},vertexShader:`#version 300 es
100
+ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute vec2 a_vertices;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute vec2 a_size;attribute float a_rotation;attribute vec4 a_rgba;varying vec3 v_rgb;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform vec3 uScaleByDistance;uniform float opacity;uniform float planetRadius;uniform vec2 viewport;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;vec3 look=a_positions-cameraPos;float lookDist=length(look);v_rgb=a_rgba.rgb;if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(uScaleByDistance[0],uScaleByDistance[1],lookDist))*(1.0-step(uScaleByDistance[2],lookDist));mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 v=screenPos+rotate2d(a_rotation)*(a_vertices*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:"precision highp float;varying vec3 v_rgb;void main(){gl_FragColor=vec4(v_rgb,1.0);}"})))}setRenderer(e){this._renderer=e,this.initProgram()}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_removeBillboards(){let e=this._billboards.length;for(;e--;){let t=this._billboards[e];t._handlerIndex=-1,t._handler=null,t._isReady=!1,t._lockId=-1}this._billboards.length=0,this._billboards=[]}clear(){this._texCoordArr=null,this._vertexArr=null,this._positionHighArr=null,this._positionLowArr=null,this._sizeArr=null,this._offsetArr=null,this._rgbaArr=null,this._rotationArr=null,this._pickingColorArr=null,this._texCoordArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._pickingColorArr=new Float32Array([]),this._removeBillboards(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e.deleteBuffer(this._positionHighBuffer),e.deleteBuffer(this._positionLowBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._offsetBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._rotationBuffer),e.deleteBuffer(this._vertexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._pickingColorBuffer)}this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._vertexBuffer=null,this._texCoordBuffer=null,this._pickingColorBuffer=null}update(){if(this._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}add(e){e._handlerIndex==-1&&(e._isReady=!0,e._handler=this,e._handlerIndex=this._billboards.length,this._billboards.push(e))}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.billboard.activate();let i=t.programs.billboard._program,r=i.attributes,s=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(s.depthOffset,o.polygonOffsetUnits),n.uniform1i(s.u_texture,0),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(s.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(s.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(s.uScaleByDistance,o.scaleByDistance),n.uniform1f(s.opacity,o._fadingOpacity),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(r.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(r.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(r.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(r.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(r.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(r.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(r.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(s.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(s.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(r.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_pickingPASS(){let e=this._renderer,t=e.handler;t.programs.billboardPicking.activate();let i=t.programs.billboardPicking._program,r=i.attributes,s=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(s.depthOffset,o.polygonOffsetUnits),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(s.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(s.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(s.uScaleByDistance,o.scaleByDistance),n.uniform1f(s.opacity,o._fadingOpacity),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(r.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(r.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(r.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._pickingColorBuffer),n.vertexAttribPointer(r.a_rgba,this._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(r.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(r.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(s.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(s.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(r.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}draw(){this._billboards.length&&(this.update(),this._displayPASS())}drawPicking(){this._billboards.length&&this.pickingEnabled&&this._pickingPASS()}reindexBillboardsArray(e){let t=this._billboards;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}_removeBillboard(e){let t=e._handlerIndex;this._billboards.splice(t,1);let i=24*t;this._rgbaArr=he(this._rgbaArr,i,24),i=18*t,this._positionHighArr=he(this._positionHighArr,i,18),this._positionLowArr=he(this._positionLowArr,i,18),this._offsetArr=he(this._offsetArr,i,18),this._pickingColorArr=he(this._pickingColorArr,i,18),i=12*t,this._vertexArr=he(this._vertexArr,i,12),this._sizeArr=he(this._sizeArr,i,12),this._texCoordArr=he(this._texCoordArr,i,12),i=6*t,this._rotationArr=he(this._rotationArr,i,6),this.reindexBillboardsArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null,e._isReady=!1,e._lockId=-1}setAlignedAxisArr(e,t){}remove(e){e._handler&&(e._isReady&&this.__id===e._handler.__id?this._removeBillboard(e):e._handler=null)}setPositionArr(e,t,i){let r=18*e,s=this._positionHighArr,n=t.x,o=t.y,l=t.z;s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,s=this._positionLowArr,n=i.x,o=i.y,l=i.z,s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,this._changedBuffers[1]=!0}setPickingColorArr(e,t){let i=18*e,r=this._pickingColorArr,s=t.x/255,n=t.y/255,o=t.z/255;r[i]=s,r[i+1]=n,r[i+2]=o,r[i+3]=s,r[i+4]=n,r[i+5]=o,r[i+6]=s,r[i+7]=n,r[i+8]=o,r[i+9]=s,r[i+10]=n,r[i+11]=o,r[i+12]=s,r[i+13]=n,r[i+14]=o,r[i+15]=s,r[i+16]=n,r[i+17]=o,this._changedBuffers[0]=!0}setSizeArr(e,t,i){let r=12*e,s=this._sizeArr,n=t,o=i;s[r]=n,s[r+1]=o,s[r+2]=n,s[r+3]=o,s[r+4]=n,s[r+5]=o,s[r+6]=n,s[r+7]=o,s[r+8]=n,s[r+9]=o,s[r+10]=n,s[r+11]=o,this._changedBuffers[2]=!0}setOffsetArr(e,t){let i=18*e,r=this._offsetArr,s=t.x,n=t.y,o=t.z;r[i]=s,r[i+1]=n,r[i+2]=o,r[i+3]=s,r[i+4]=n,r[i+5]=o,r[i+6]=s,r[i+7]=n,r[i+8]=o,r[i+9]=s,r[i+10]=n,r[i+11]=o,r[i+12]=s,r[i+13]=n,r[i+14]=o,r[i+15]=s,r[i+16]=n,r[i+17]=o,this._changedBuffers[3]=!0}setRgbaArr(e,t){let i=24*e,r=this._rgbaArr,s=t.x,n=t.y,o=t.z,l=t.w;r[i]=s,r[i+1]=n,r[i+2]=o,r[i+3]=l,r[i+4]=s,r[i+5]=n,r[i+6]=o,r[i+7]=l,r[i+8]=s,r[i+9]=n,r[i+10]=o,r[i+11]=l,r[i+12]=s,r[i+13]=n,r[i+14]=o,r[i+15]=l,r[i+16]=s,r[i+17]=n,r[i+18]=o,r[i+19]=l,r[i+20]=s,r[i+21]=n,r[i+22]=o,r[i+23]=l,this._changedBuffers[4]=!0}setRotationArr(e,t){let i=6*e,r=this._rotationArr;r[i]=t,r[i+1]=t,r[i+2]=t,r[i+3]=t,r[i+4]=t,r[i+5]=t,this._changedBuffers[5]=!0}setTexCoordArr(e,t){let i=12*e,r=this._texCoordArr;r[i]=t[0],r[i+1]=t[1],r[i+2]=t[2],r[i+3]=t[3],r[i+4]=t[4],r[i+5]=t[5],r[i+6]=t[6],r[i+7]=t[7],r[i+8]=t[8],r[i+9]=t[9],r[i+10]=t[10],r[i+11]=t[11],this._changedBuffers[6]=!0}setVisibility(e,t){let i;i=t?[-.5,.5,-.5,-.5,.5,-.5,.5,-.5,.5,.5,-.5,.5]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e,r=this._vertexArr;r[i]=t[0],r[i+1]=t[1],r[i+2]=t[2],r[i+3]=t[3],r[i+4]=t[4],r[i+5]=t[5],r[i+6]=t[6],r[i+7]=t[7],r[i+8]=t[8],r[i+9]=t[9],r[i+10]=t[10],r[i+11]=t[11],this._changedBuffers[7]=!0}createPositionBuffer(){let e=this._renderer.handler,t=this._positionHighArr.length/3;this._positionHighBuffer&&this._positionHighBuffer.numItems===t||(e.gl.deleteBuffer(this._positionHighBuffer),e.gl.deleteBuffer(this._positionLowBuffer),this._positionHighBuffer=e.createStreamArrayBuffer(3,t),this._positionLowBuffer=e.createStreamArrayBuffer(3,t)),e.setStreamArrayBuffer(this._positionHighBuffer,this._positionHighArr),e.setStreamArrayBuffer(this._positionLowBuffer,this._positionLowArr)}createSizeBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createArrayBuffer(this._sizeArr,2,this._sizeArr.length/2)}createOffsetBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._offsetBuffer),this._offsetBuffer=e.createArrayBuffer(this._offsetArr,3,this._offsetArr.length/3)}createRgbaBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaBuffer=e.createArrayBuffer(this._rgbaArr,4,this._rgbaArr.length/4)}createRotationBuffer(){let e=this._renderer.handler;this._rotationBuffer&&this._rotationBuffer.numItems===this._rotationArr.length||(e.gl.deleteBuffer(this._rotationBuffer),this._rotationBuffer=e.createStreamArrayBuffer(1,this._rotationArr.length)),e.setStreamArrayBuffer(this._rotationBuffer,this._rotationArr)}createVertexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,2,this._vertexArr.length/2)}createTexCoordBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,2,this._texCoordArr.length/2)}createPickingColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}refreshTexCoordsArr(){}};An.__counter__=0;let Ln=An;class Ll extends Ln{constructor(e){super(e),this._billboards=[]}add(e){if(e._handlerIndex==-1){super.add(e),this._addBillboardToArrays(e),this.refresh();let t=e.getSrc()||e.getImage()&&e.getImage().src;t&&e.setSrc(t)}}_addBillboardToArrays(e){e.getVisibility()?this._vertexArr=oe(this._vertexArr,[-.5,.5,-.5,-.5,.5,-.5,.5,-.5,.5,.5,-.5,.5]):this._vertexArr=oe(this._vertexArr,[0,0,0,0,0,0,0,0,0,0,0,0]),this._texCoordArr=oe(this._texCoordArr,[0,0,0,0,0,0,0,0,0,0,0,0]);let t,i=e._positionHigh.x,r=e._positionHigh.y,s=e._positionHigh.z;this._positionHighArr=oe(this._positionHighArr,[i,r,s,i,r,s,i,r,s,i,r,s,i,r,s,i,r,s]),i=e._positionLow.x,r=e._positionLow.y,s=e._positionLow.z,this._positionLowArr=oe(this._positionLowArr,[i,r,s,i,r,s,i,r,s,i,r,s,i,r,s,i,r,s]),i=e._width,r=e._height,this._sizeArr=oe(this._sizeArr,[i,r,i,r,i,r,i,r,i,r,i,r]),i=e._offset.x,r=e._offset.y,s=e._offset.z,this._offsetArr=oe(this._offsetArr,[i,r,s,i,r,s,i,r,s,i,r,s,i,r,s,i,r,s]),i=e._color.x,r=e._color.y,s=e._color.z,t=e._color.w,this._rgbaArr=oe(this._rgbaArr,[i,r,s,t,i,r,s,t,i,r,s,t,i,r,s,t,i,r,s,t,i,r,s,t]),i=e._rotation,this._rotationArr=oe(this._rotationArr,[i,i,i,i,i,i]),i=e._entity._pickingColor.x/255,r=e._entity._pickingColor.y/255,s=e._entity._pickingColor.z/255,this._pickingColorArr=oe(this._pickingColorArr,[i,r,s,i,r,s,i,r,s,i,r,s,i,r,s,i,r,s])}get billboards(){return this._billboards}refreshTexCoordsArr(){if(this._entityCollection&&this._renderer){let e=this._renderer.billboardsTextureAtlas;for(let t=0;t<this._billboards.length;t++){let i=this._billboards[t],r=i.getImage();if(r){let s=e.get(r.__nodeIndex);s&&this.setTexCoordArr(i._handlerIndex,s.texCoords)}}}}}class Pl{constructor(e){this.isFree=!0,this._geoObjectHandler=e,this.geoObjects=[],this.numInstances=0,this._colorTexture=null,this._colorTextureSrc=null,this._colorTextureImage=null,this._normalTexture=null,this._normalTextureSrc=null,this._normalTextureImage=null,this._metallicRoughnessTexture=null,this._metallicRoughnessTextureSrc=null,this._metallicRoughnessTextureImage=null,this._sizeArr=[],this._translateArr=[],this._vertexArr=[],this._rtcPositionHighArr=[],this._rtcPositionLowArr=[],this._qRotArr=[],this._rgbaArr=[],this._normalsArr=[],this._indicesArr=[],this._pickingColorArr=[],this._visibleArr=[],this._texCoordArr=[],this._localPositionArr=[],this._sizeBuffer=null,this._translateBuffer=null,this._vertexBuffer=null,this._rtcPositionHighBuffer=null,this._rtcPositionLowBuffer=null,this._qRotBuffer=null,this._rgbaBuffer=null,this._normalsBuffer=null,this._indicesBuffer=null,this._pickingColorBuffer=null,this._visibleBuffer=null,this._texCoordBuffer=null,this._localPositionBuffer=null,this._materialParams=new Float32Array(9),this._materialShininess=0,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[zn]=this.createPickingColorBuffer,this._buffersUpdateCallbacks[Rn]=this.createNormalsBuffer,this._buffersUpdateCallbacks[Mn]=this.createRgbaBuffer,this._buffersUpdateCallbacks[Bn]=this.createIndicesBuffer,this._buffersUpdateCallbacks[Pn]=this.createVertexBuffer,this._buffersUpdateCallbacks[In]=this.createSizeBuffer,this._buffersUpdateCallbacks[Dn]=this.createVisibleBuffer,this._buffersUpdateCallbacks[Fn]=this.createTexCoordBuffer,this._buffersUpdateCallbacks[kn]=this.createQRotBuffer,this._buffersUpdateCallbacks[On]=this.createTranslateBuffer,this._buffersUpdateCallbacks[Sn]=this.createRTCPositionBuffer,this._buffersUpdateCallbacks[Nn]=this.createLocalPositionBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}setMaterialAmbient(e,t,i){this._materialParams[0]=e,this._materialParams[1]=t,this._materialParams[2]=i}setMaterialDiffuse(e,t,i){this._materialParams[3]=e,this._materialParams[4]=t,this._materialParams[5]=i}setMaterialSpecular(e,t,i){this._materialParams[6]=e,this._materialParams[7]=t,this._materialParams[8]=i}setMaterialShininess(e){this._materialShininess=e}setMaterialParams(e,t,i,r){this.setMaterialAmbient(e[0],e[1],e[2]),this.setMaterialDiffuse(t[0],t[1],t[2]),this.setMaterialSpecular(i[0],i[1],i[2]),this.setMaterialShininess(r)}drawOpaque(e){let t=e.gl,i=e.uniforms,r=e.attributes;t.bindBuffer(t.ARRAY_BUFFER,this._qRotBuffer),t.vertexAttribPointer(r.qRot,this._qRotBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._sizeBuffer),t.vertexAttribPointer(r.aScale,this._sizeBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._translateBuffer),t.vertexAttribPointer(r.aTranslate,this._translateBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._localPositionBuffer),t.vertexAttribPointer(r.aLocalPosition,this._localPositionBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._visibleBuffer),t.vertexAttribPointer(r.aDispose,this._visibleBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(i.uUseTexture,this._colorTexture?1:0),t.bindBuffer(t.ARRAY_BUFFER,this._rgbaBuffer),t.vertexAttribPointer(r.aColor,this._rgbaBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform3fv(i.materialParams,this._materialParams),t.uniform1f(i.materialShininess,this._materialShininess),this._drawElementsInstanced(e)}drawTransparent(e){let t=e.gl,i=e.uniforms,r=e.attributes;t.bindBuffer(t.ARRAY_BUFFER,this._qRotBuffer),t.vertexAttribPointer(r.qRot,this._qRotBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._sizeBuffer),t.vertexAttribPointer(r.aScale,this._sizeBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._translateBuffer),t.vertexAttribPointer(r.aTranslate,this._translateBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._localPositionBuffer),t.vertexAttribPointer(r.aLocalPosition,this._localPositionBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._visibleBuffer),t.vertexAttribPointer(r.aDispose,this._visibleBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(i.uUseTexture,this._colorTexture?1:0),t.uniform3fv(i.materialParams,this._materialParams),t.uniform1f(i.materialShininess,this._materialShininess),t.bindBuffer(t.ARRAY_BUFFER,this._rgbaBuffer),t.vertexAttribPointer(r.aColor,this._rgbaBuffer.itemSize,t.FLOAT,!1,0,0),this._drawElementsInstanced(e)}_drawElementsInstanced(e){let t=e.gl,i=e.uniforms,r=e.attributes,s=this._geoObjectHandler._renderer;t.bindBuffer(t.ARRAY_BUFFER,this._rtcPositionHighBuffer),t.vertexAttribPointer(r.aRTCPositionHigh,this._rtcPositionHighBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._rtcPositionLowBuffer),t.vertexAttribPointer(r.aRTCPositionLow,this._rtcPositionLowBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._normalsBuffer),t.vertexAttribPointer(r.aVertexNormal,this._normalsBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.vertexAttribPointer(r.aVertexPosition,this._vertexBuffer.itemSize,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._colorTexture||s.handler.defaultTexture),t.uniform1i(i.uTexture,0),t.bindBuffer(t.ARRAY_BUFFER,this._texCoordBuffer),t.vertexAttribPointer(r.aTexCoord,this._texCoordBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),e.drawElementsInstanced(t.TRIANGLES,this._indicesBuffer.numItems,t.UNSIGNED_INT,0,this.numInstances)}async loadColorTexture(){if(this._geoObjectHandler._renderer){if(!this._colorTextureSrc)return this._colorTextureImage?(await this._colorTextureImage.decode(),void this._createColorTexture(this._colorTextureImage)):void 0;{const e=await Ni(this._colorTextureSrc);this._createColorTexture(e)}}}async loadNormalTexture(){if(this._geoObjectHandler._renderer){if(!this._normalTextureSrc)return this._normalTextureImage?(await this._normalTextureImage.decode(),void this._createNormalTexture(this._normalTextureImage)):void 0;{const e=await Ni(this._normalTextureSrc);this._createNormalTexture(e)}}}async loadMetallicRoughnessTexture(){if(this._geoObjectHandler._renderer){if(!this._metallicRoughnessTextureSrc)return this._metallicRoughnessTextureImage?(await this._metallicRoughnessTextureImage.decode(),void this._createMetallicRoughnessTexture(this._metallicRoughnessTextureImage)):void 0;{const e=await Ni(this._metallicRoughnessTextureSrc);this._createMetallicRoughnessTexture(e)}}}clear(){this.numInstances=0,this.geoObjects=[],this._sizeArr=[],this._translateArr=[],this._vertexArr=[],this._rtcPositionHighArr=[],this._rtcPositionLowArr=[],this._qRotArr=[],this._rgbaArr=[],this._normalsArr=[],this._indicesArr=[],this._pickingColorArr=[],this._visibleArr=[],this._texCoordArr=[],this._localPositionArr=[],this._deleteBuffers(),this.isFree=!1}_deleteBuffers(){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let e=this._geoObjectHandler._renderer.handler,t=e.gl;e.deleteTexture(this._colorTexture),e.deleteTexture(this._normalTexture),e.deleteTexture(this._metallicRoughnessTexture),this._colorTexture=null,this._normalTexture=null,this._metallicRoughnessTexture=null,t.deleteBuffer(this._sizeBuffer),t.deleteBuffer(this._translateBuffer),t.deleteBuffer(this._vertexBuffer),t.deleteBuffer(this._rtcPositionHighBuffer),t.deleteBuffer(this._rtcPositionLowBuffer),t.deleteBuffer(this._qRotBuffer),t.deleteBuffer(this._rgbaBuffer),t.deleteBuffer(this._normalsBuffer),t.deleteBuffer(this._indicesBuffer),t.deleteBuffer(this._pickingColorBuffer),t.deleteBuffer(this._visibleBuffer),t.deleteBuffer(this._texCoordBuffer),t.deleteBuffer(this._localPositionBuffer)}this._sizeBuffer=null,this._translateBuffer=null,this._vertexBuffer=null,this._rtcPositionHighBuffer=null,this._rtcPositionLowBuffer=null,this._qRotBuffer=null,this._rgbaBuffer=null,this._normalsBuffer=null,this._indicesBuffer=null,this._pickingColorBuffer=null,this._visibleBuffer=null,this._texCoordBuffer=null,this._localPositionBuffer=null}createVertexBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexArr=re(this._vertexArr),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,3,this._vertexArr.length/3)}createVisibleBuffer(){const e=this._geoObjectHandler._renderer.handler,t=this._visibleArr.length;this._visibleBuffer&&this._visibleBuffer.numItems===t||(e.gl.deleteBuffer(this._visibleBuffer),this._visibleBuffer=e.createStreamArrayBuffer(1,t)),this._visibleArr=re(this._visibleArr),e.setStreamArrayBuffer(this._visibleBuffer,this._visibleArr)}createSizeBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._sizeArr.length/3;this._sizeBuffer&&this._sizeBuffer.numItems===t||(e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createStreamArrayBuffer(3,t)),this._sizeArr=re(this._sizeArr),e.setStreamArrayBuffer(this._sizeBuffer,this._sizeArr)}createTranslateBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._translateArr.length/3;this._translateBuffer&&this._translateBuffer.numItems===t||(e.gl.deleteBuffer(this._translateBuffer),this._translateBuffer=e.createStreamArrayBuffer(3,t)),this._translateArr=re(this._translateArr),e.setStreamArrayBuffer(this._translateBuffer,this._translateArr)}createLocalPositionBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._localPositionArr.length/3;this._localPositionBuffer&&this._localPositionBuffer.numItems===t||(e.gl.deleteBuffer(this._localPositionBuffer),this._localPositionBuffer=e.createStreamArrayBuffer(3,t)),this._localPositionArr=re(this._localPositionArr),e.setStreamArrayBuffer(this._localPositionBuffer,this._localPositionArr)}createTexCoordBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordArr=re(this._texCoordArr),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,2,this._texCoordArr.length/2)}createRTCPositionBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._rtcPositionHighArr.length/3;this._rtcPositionHighBuffer&&this._rtcPositionHighBuffer.numItems===t||(e.gl.deleteBuffer(this._rtcPositionHighBuffer),e.gl.deleteBuffer(this._rtcPositionLowBuffer),this._rtcPositionHighBuffer=e.createStreamArrayBuffer(3,t),this._rtcPositionLowBuffer=e.createStreamArrayBuffer(3,t)),this._rtcPositionHighArr=re(this._rtcPositionHighArr),this._rtcPositionLowArr=re(this._rtcPositionLowArr),e.setStreamArrayBuffer(this._rtcPositionHighBuffer,this._rtcPositionHighArr),e.setStreamArrayBuffer(this._rtcPositionLowBuffer,this._rtcPositionLowArr)}createRgbaBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._rgbaArr.length/4;this._rgbaBuffer&&this._rgbaBuffer.numItems===t||(e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaBuffer=e.createStreamArrayBuffer(4,t)),this._rgbaArr=re(this._rgbaArr),e.setStreamArrayBuffer(this._rgbaBuffer,this._rgbaArr)}createQRotBuffer(){let e=this._geoObjectHandler._renderer.handler,t=this._qRotArr.length/4;this._qRotBuffer&&this._qRotBuffer.numItems===t||(e.gl.deleteBuffer(this._qRotBuffer),this._qRotBuffer=e.createStreamArrayBuffer(4,t)),this._qRotArr=re(this._qRotArr),e.setStreamArrayBuffer(this._qRotBuffer,this._qRotArr)}createNormalsBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._normalsBuffer),this._normalsArr=re(this._normalsArr),this._normalsBuffer=e.createArrayBuffer(this._normalsArr,3,this._normalsArr.length/3)}createIndicesBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._indicesBuffer),this._indicesArr=re(this._indicesArr,Uint32Array),this._indicesBuffer=e.createElementArrayBuffer(this._indicesArr,1,this._indicesArr.length)}createPickingColorBuffer(){const e=this._geoObjectHandler._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorArr=re(this._pickingColorArr),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}update(){if(this._geoObjectHandler._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1);this.isFree=!0}}_createColorTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._colorTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}_createNormalTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._normalTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}_createMetallicRoughnessTexture(e){if(this._geoObjectHandler&&this._geoObjectHandler._renderer){let t=this._geoObjectHandler._renderer.handler;this._metallicRoughnessTexture=t.createTextureDefault(e,null,t.gl.REPEAT)}}}const Pn=0,Sn=1,Mn=2,Rn=3,Bn=4,kn=5,In=6,zn=7,Dn=8,Fn=9,On=10,Nn=11;function Le(a,e=0,t=0,i=1,...r){const s=e*t;for(let n=s,o=s+t;n<o;n++)a[n]=r[n%i];return a}const Hn=class Vo{constructor(e){this.__id=Vo.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderNode=null,this._renderer=null,this._geoObjects=[],this._instanceDataMap=new Map,this._instanceDataMapValues=[],this._dataTagUpdateQueue=[],this._relativeCenter=new m,this._rtcEyePositionHigh=new Float32Array([0,0,0]),this._rtcEyePositionLow=new Float32Array([0,0,0])}initProgram(){this._renderer&&(this._renderer.handler.programs.geo_object||this._renderer.handler.addProgram(new X("geo_object",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",eyePositionHigh:"vec3",eyePositionLow:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",sunPosition:"vec3",materialParams:"vec3",materialShininess:"float",uTexture:"sampler2d",uUseTexture:"float",useLighting:"float"},attributes:{aVertexPosition:"vec3",aVertexNormal:"vec3",aTexCoord:"vec2",aLocalPosition:{type:"vec3",divisor:1},aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aColor:{type:"vec4",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1}},vertexShader:"precision highp float;vec3 qRotate(vec4 q,vec3 v){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}attribute vec3 aVertexPosition;attribute vec3 aVertexNormal;attribute vec3 aRTCPositionHigh;attribute vec3 aRTCPositionLow;attribute vec4 aColor;attribute vec3 aScale;attribute vec3 aTranslate;attribute float aDispose;attribute float aUseTexture;attribute vec2 aTexCoord;attribute vec4 qRot;attribute vec3 aLocalPosition;uniform vec3 uScaleByDistance;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;varying vec3 cameraPosition;varying vec3 vNormal;varying vec3 v_vertex;varying vec4 vColor;varying float vDispose;varying vec2 vTexCoords;void main(void){if(aDispose==0.0){return;}vColor=aColor;vTexCoords=aTexCoord;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=aRTCPositionHigh-rtcEyePositionHigh;vec3 lowDiff=aRTCPositionLow-rtcEyePositionLow;cameraPosition=eyePositionHigh+eyePositionLow;highDiff=highDiff*step(1.0,length(highDiff));vec4 positionInViewSpace=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);float lookLength=length(positionInViewSpace.xyz);vNormal=normalize(qRotate(qRot,aVertexNormal));float scd=uScaleByDistance[2]*clamp(lookLength,uScaleByDistance[0],uScaleByDistance[1])/uScaleByDistance[0];vec3 vert=qRotate(qRot,scd*(aVertexPosition*aScale+aTranslate))+scd*aLocalPosition;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff+lowDiff+vert,1.0);v_vertex=positionInViewSpace.xyz+vert;}",fragmentShader:"precision highp float;uniform vec3 sunPosition;uniform vec3 materialParams[3];uniform float materialShininess;uniform sampler2D uTexture;uniform float uUseTexture;uniform float useLighting;varying vec3 cameraPosition;varying vec3 v_vertex;varying vec4 vColor;varying vec3 vNormal;varying vec2 vTexCoords;void main(void){vec3 lightWeighting=vec3(1.0);if(useLighting!=0.0){vec3 normal=normalize(vNormal);vec3 light_dir=normalize(sunPosition);vec3 look_dir=normalize(cameraPosition-v_vertex);float diffuse=max(dot(normal,light_dir),0.0);vec3 refl_dir=reflect(-light_dir,normal);float refl=max(dot(refl_dir,look_dir),0.0);float specular=pow(refl,materialShininess)*step(1e-4,diffuse);lightWeighting=vColor.rgb*materialParams[0]+materialParams[1]*diffuse+materialParams[2]*specular;}else{lightWeighting=vColor.rgb;}if(uUseTexture>0.0){vec4 texColor=texture2D(uTexture,vTexCoords);gl_FragColor=vec4(texColor.rgb*lightWeighting,texColor.a);}else{gl_FragColor=vec4(lightWeighting,vColor.a);}}"})),this._renderer.handler.programs.geo_object_picking||this._renderer.handler.addProgram(new X("geo_object_picking",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",pickingScale:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3"},attributes:{aVertexPosition:"vec3",aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aPickingColor:{type:"vec3",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aLocalPosition:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1}},vertexShader:"precision highp float;vec3 qRotate(vec4 q,vec3 v){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}attribute vec3 aVertexPosition;attribute vec3 aRTCPositionHigh;attribute vec3 aRTCPositionLow;attribute vec3 aPickingColor;attribute vec3 aScale;attribute vec3 aTranslate;attribute float aDispose;attribute vec4 qRot;attribute vec3 aLocalPosition;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform vec3 uScaleByDistance;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 pickingScale;varying vec3 vColor;void main(void){if(aDispose==0.0){return;}vColor=aPickingColor;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=aRTCPositionHigh-rtcEyePositionHigh;vec3 lowDiff=aRTCPositionLow-rtcEyePositionLow;highDiff=highDiff*step(1.0,length(highDiff));vec4 positionInViewSpace=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);float lookLength=length(positionInViewSpace.xyz);float scd=uScaleByDistance[2]*clamp(lookLength,uScaleByDistance[0],uScaleByDistance[1])/uScaleByDistance[0];vec3 vert=qRotate(qRot,scd*pickingScale*(aVertexPosition*aScale+aTranslate))+scd*aLocalPosition;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff+lowDiff+vert,1.0);}",fragmentShader:"precision highp float;varying vec3 vColor;void main(){gl_FragColor=vec4(vColor,1.0);}"})),this._renderer.handler.programs.geo_object_depth||this._renderer.handler.addProgram(new X("geo_object_depth",{uniforms:{viewMatrix:"mat4",projectionMatrix:"mat4",uScaleByDistance:"vec3",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",frustumPickingColor:"float"},attributes:{aVertexPosition:"vec3",aRTCPositionHigh:{type:"vec3",divisor:1},aRTCPositionLow:{type:"vec3",divisor:1},aScale:{type:"vec3",divisor:1},aTranslate:{type:"vec3",divisor:1},aDispose:{type:"float",divisor:1},qRot:{type:"vec4",divisor:1},aLocalPosition:{type:"vec3",divisor:1}},vertexShader:`#version 300 es
101
101
  precision highp float;vec3 qRotate(vec4 q,vec3 v){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}in vec3 aVertexPosition;in vec3 aRTCPositionHigh;in vec3 aRTCPositionLow;in vec3 aScale;in vec3 aTranslate;in float aDispose;in vec4 qRot;in vec3 aLocalPosition;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform vec3 uScaleByDistance;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;void main(void){if(aDispose==0.0){return;}mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=aRTCPositionHigh-rtcEyePositionHigh;vec3 lowDiff=aRTCPositionLow-rtcEyePositionLow;highDiff=highDiff*step(1.0,length(highDiff));vec4 positionInViewSpace=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);float lookLength=length(positionInViewSpace.xyz);float scd=uScaleByDistance[2]*clamp(lookLength,uScaleByDistance[0],uScaleByDistance[1])/uScaleByDistance[0];vec3 vert=qRotate(qRot,scd*(aVertexPosition*aScale+aTranslate))+scd*aLocalPosition;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff+lowDiff+vert,1.0);}`,fragmentShader:`#version 300 es
102
- precision highp float;uniform float frustumPickingColor;layout(location=0)out vec4 frustumColor;layout(location=1)out vec4 depthColor;void main(){frustumColor=vec4(frustumPickingColor,frustumPickingColor,frustumPickingColor,1.0);depthColor=vec4(gl_FragCoord.z,gl_FragCoord.z,gl_FragCoord.z,1.0);}`})))}setRenderNode(e){this._renderNode=e,this._renderer=e.renderer,this.initProgram();for(let t=0;t<this._instanceDataMapValues.length;t++)this._instanceDataMapValues[t].loadColorTexture(),this._instanceDataMapValues[t].loadNormalTexture(),this._instanceDataMapValues[t].loadMetallicRoughnessTexture();for(let t=0;t<this._geoObjects.length;t++)this._geoObjects[t].updateRotation();this.update()}setColorTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._colorTextureSrc=e,i._colorTextureImage=null),e instanceof HTMLImageElement&&(i._colorTextureSrc=null,i._colorTextureImage=e),this._instanceDataMap.set(t,i),i.loadColorTexture())}setNormalTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._normalTextureSrc=e,i._normalTextureImage=null),e instanceof HTMLImageElement&&(i._normalTextureSrc=null,i._normalTextureImage=e),this._instanceDataMap.set(t,i),i.loadNormalTexture())}setMetallicRoughnessTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._metallicRoughnessTextureSrc=e,i._metallicRoughnessTextureImage=null),e instanceof HTMLImageElement&&(i._metallicRoughnessTextureSrc=null,i._metallicRoughnessTextureImage=e),this._instanceDataMap.set(t,i),i.loadMetallicRoughnessTexture())}setObjectSrc(e,t){const i=this._instanceDataMap.get(t);e&&i&&i._objectSrc!==e&&(i._objectSrc=e,Z.loadObj(e).then(s=>{this._updateInstanceData(s[0],t)}))}_updateInstanceData(e,t){const i=this._instanceDataMap.get(t);i&&(e.vertices.length!==i._vertexArr.length&&(i._vertexArr=e.vertices,i._changedBuffers[Ln]=!0),e.normals.length!==i._normalsArr.length&&(i._normalsArr=e.normals,i._changedBuffers[Mn]=!0),e.indices.length!==i._indicesArr.length&&(i._indicesArr=e.indices,i._changedBuffers[Rn]=!0),e.texCoords.length!==i._texCoordArr.length&&(i._texCoordArr=e.texCoords,i._changedBuffers[Dn]=!0),i._colorTextureSrc=e.colorTextureSrc,i._normalTextureSrc=e.normalTextureSrc,i._metallicRoughnessTexture=e.metallicRoughnessTextureSrc,i._colorTextureImage=e.colorTextureImage,i._normalTextureImage=e.normalTextureImage,i._metallicRoughnessTextureImage=e.metallicRoughnessTextureImage,i.loadColorTexture(),i.loadNormalTexture(),i.loadMetallicRoughnessTexture(),this._updateTag(i),this._instanceDataMapValues=Array.from(this._instanceDataMap.values()))}_addGeoObjectToArray(e){const t=e.tag;let i=this._instanceDataMap.get(t);i||(i=new Pl(this),this._instanceDataMap.set(t,i),this._instanceDataMapValues=Array.from(this._instanceDataMap.values()),i._vertexArr=e.vertices,i._normalsArr=e.normals,i._indicesArr=e.indices,i._texCoordArr=e.texCoords,i._colorTextureSrc=e.object3d.colorTextureSrc,i._normalTextureSrc=e.object3d.normalTextureSrc,i._metallicRoughnessTextureSrc=e.object3d.metallicRoughnessTextureSrc,i._colorTextureImage=e.object3d.colorTextureImage,i._normalTextureImage=e.object3d.normalTextureImage,i._metallicRoughnessTextureImage=e.object3d.metallicRoughnessTextureImage,i.setMaterialParams(e.object3d.ambient,e.object3d.diffuse,e.object3d.specular,e.object3d.shininess),i.loadColorTexture(),i.loadNormalTexture(),i.loadMetallicRoughnessTexture()),e._tagDataIndex=i.numInstances++,e._tagData=i,i.geoObjects.push(e);let s=3;i._visibleArr=xe(i._visibleArr,Le([],0,1,1,e.getVisibility()?1:0)),this.getRTCPosition(e.getPosition(),e._rtcPositionHigh,e._rtcPositionLow);let r,n=e._rtcPositionHigh.x,o=e._rtcPositionHigh.y,l=e._rtcPositionHigh.z;i._rtcPositionHighArr=xe(i._rtcPositionHighArr,Le([],0,s,s,n,o,l)),n=e._rtcPositionLow.x,o=e._rtcPositionLow.y,l=e._rtcPositionLow.z,i._rtcPositionLowArr=xe(i._rtcPositionLowArr,Le([],0,s,s,n,o,l)),n=e._entity._pickingColor.x/255,o=e._entity._pickingColor.y/255,l=e._entity._pickingColor.z/255,i._pickingColorArr=xe(i._pickingColorArr,Le([],0,s,s,n,o,l)),s=4,n=e._qRot.x,o=e._qRot.y,l=e._qRot.z,r=e._qRot.w,i._qRotArr=xe(i._qRotArr,Le([],0,s,s,n,o,l,r)),n=e._color.x,o=e._color.y,l=e._color.z,r=e._color.w,i._rgbaArr=xe(i._rgbaArr,Le([],0,s,s,n,o,l,r)),s=3;let h=e.getScale();n=h.x,o=h.y,l=h.z,i._sizeArr=xe(i._sizeArr,Le([],0,s,s,n,o,l));let c=e.getTranslate();n=c.x,o=c.y,l=c.z,i._translateArr=xe(i._translateArr,Le([],0,s,s,n,o,l));let d=e.getLocalPosition();n=d.x,o=d.y,l=d.z,i._localPositionArr=xe(i._localPositionArr,Le([],0,s,s,n,o,l))}_bindCommon(){let e=this._renderer,t=e.handler.programs.geo_object._program.uniforms,i=e.handler.gl,s=this._entityCollection;i.uniform3fv(t.uScaleByDistance,s.scaleByDistance),i.uniform1f(t.useLighting,s._useLighting),i.uniform3fv(t.eyePositionHigh,e.activeCamera.eyeHigh),i.uniform3fv(t.eyePositionLow,e.activeCamera.eyeLow),i.uniform3fv(t.rtcEyePositionHigh,this._rtcEyePositionHigh),i.uniform3fv(t.rtcEyePositionLow,this._rtcEyePositionLow),i.uniformMatrix4fv(t.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),i.uniformMatrix4fv(t.viewMatrix,!1,e.activeCamera.getViewMatrix()),i.uniform3fv(t.sunPosition,this._renderNode._lightPosition)}_displayOpaquePASS(){let e=this._renderer.handler.programs.geo_object,t=e._program;e.activate(),this._bindCommon();for(let i=0;i<this._instanceDataMapValues.length;i++)this._instanceDataMapValues[i].drawOpaque(t)}_displayTransparentPASS(){let e=this._renderer.handler.programs.geo_object,t=e._program;e.activate(),this._bindCommon();for(let i=0;i<this._instanceDataMapValues.length;i++)this._instanceDataMapValues[i].drawTransparent(t)}_depthPASS(){let e=this._renderer,t=e.handler.programs.geo_object_depth,i=t._program,s=i.uniforms,r=i.attributes,n=e.handler.gl,o=this._entityCollection,l=e.activeCamera;t.activate(),n.uniform3fv(s.uScaleByDistance,o.scaleByDistance),n.uniform3fv(s.rtcEyePositionHigh,this._rtcEyePositionHigh),n.uniform3fv(s.rtcEyePositionLow,this._rtcEyePositionLow),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniform1f(s.frustumPickingColor,l.frustumColorIndex);for(let h=0;h<this._instanceDataMapValues.length;h++){let c=this._instanceDataMapValues[h];n.bindBuffer(n.ARRAY_BUFFER,c._qRotBuffer),n.vertexAttribPointer(r.qRot,c._qRotBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._sizeBuffer),n.vertexAttribPointer(r.aScale,c._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._translateBuffer),n.vertexAttribPointer(r.aTranslate,c._translateBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._localPositionBuffer),n.vertexAttribPointer(r.aLocalPosition,c._localPositionBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._rtcPositionHighBuffer),n.vertexAttribPointer(r.aRTCPositionHigh,c._rtcPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._rtcPositionLowBuffer),n.vertexAttribPointer(r.aRTCPositionLow,c._rtcPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._visibleBuffer),n.vertexAttribPointer(r.aDispose,c._visibleBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._vertexBuffer),n.vertexAttribPointer(r.aVertexPosition,c._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,c._indicesBuffer),i.drawElementsInstanced(n.TRIANGLES,c._indicesBuffer.numItems,n.UNSIGNED_INT,0,c.numInstances)}}drawDepth(){this._geoObjects.length&&this._depthPASS()}drawPicking(){this._geoObjects.length&&this.pickingEnabled&&this._pickingPASS()}_pickingPASS(){let e=this._renderer,t=e.handler.programs.geo_object_picking,i=t._program,s=i.uniforms,r=i.attributes,n=e.handler.gl,o=this._entityCollection;t.activate(),n.uniform3fv(s.uScaleByDistance,o.scaleByDistance),n.uniform3fv(s.pickingScale,o.pickingScale),n.uniform3fv(s.rtcEyePositionHigh,this._rtcEyePositionHigh),n.uniform3fv(s.rtcEyePositionLow,this._rtcEyePositionLow),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix());for(let l=0;l<this._instanceDataMapValues.length;l++){let h=this._instanceDataMapValues[l];n.bindBuffer(n.ARRAY_BUFFER,h._qRotBuffer),n.vertexAttribPointer(r.qRot,h._qRotBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._sizeBuffer),n.vertexAttribPointer(r.aScale,h._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._translateBuffer),n.vertexAttribPointer(r.aTranslate,h._translateBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._localPositionBuffer),n.vertexAttribPointer(r.aLocalPosition,h._localPositionBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._pickingColorBuffer),n.vertexAttribPointer(r.aPickingColor,h._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._rtcPositionHighBuffer),n.vertexAttribPointer(r.aRTCPositionHigh,h._rtcPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._rtcPositionLowBuffer),n.vertexAttribPointer(r.aRTCPositionLow,h._rtcPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._visibleBuffer),n.vertexAttribPointer(r.aDispose,h._visibleBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._vertexBuffer),n.vertexAttribPointer(r.aVertexPosition,h._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h._indicesBuffer),i.drawElementsInstanced(n.TRIANGLES,h._indicesBuffer.numItems,n.UNSIGNED_INT,0,h.numInstances)}}setQRotArr(e,t,i){Le(e._qRotArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Bn]=!0,this._updateTag(e)}setVisibility(e,t,i){Le(e._visibleArr,t,1,1,i?1:0),e._changedBuffers[zn]=!0,this._updateTag(e)}setRTCPositionArr(e,t,i,s){Le(e._rtcPositionHighArr,t,3,3,i.x,i.y,i.z),Le(e._rtcPositionLowArr,t,3,3,s.x,s.y,s.z),e._changedBuffers[Pn]=!0,this._updateTag(e)}setRgbaArr(e,t,i){Le(e._rgbaArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Sn]=!0,this._updateTag(e)}setPickingColorArr(e,t,i){Le(e._pickingColorArr,t,3,3,i.x/255,i.y/255,i.z/255),e._changedBuffers[In]=!0,this._updateTag(e)}setScaleArr(e,t,i){Le(e._sizeArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[kn]=!0,this._updateTag(e)}setTranslateArr(e,t,i){Le(e._translateArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Fn]=!0,this._updateTag(e)}setLocalPositionArr(e,t,i){Le(e._localPositionArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[On]=!0,this._updateTag(e)}_updateTag(e){e.isFree&&(e.isFree=!1,this._dataTagUpdateQueue.push(e))}update(){for(let e=0,t=this._dataTagUpdateQueue.length;e<t;e++)this._dataTagUpdateQueue[e].update();this._dataTagUpdateQueue=[]}_removeAll(){let e=this._geoObjects.length;for(;e--;){const t=this._geoObjects[e];t._tagDataIndex=-1,t._tagData=null,t._handlerIndex=-1,t._handler=null}this._geoObjects.length=0,this._geoObjects=[];for(let t=0;t<this._instanceDataMapValues.length;t++)this._instanceDataMapValues[t].clear();this._instanceDataMap.clear(),this._instanceDataMapValues=[]}clear(){this._removeAll()}getRTCPosition(e,t,i){let s=e.sub(this._relativeCenter);v.doubleToTwoFloats(s,t,i)}setRelativeCenter(e){this._relativeCenter.copy(e);for(let t=0;t<this._instanceDataMapValues.length;t++){let i=this._instanceDataMapValues[t].geoObjects;for(let s=0;s<i.length;s++)i[s].updateRTCPosition()}}_updateRTCEyePosition(){let e=this._renderer;if(e.activeCamera.isFirstPass){let t=e.activeCamera.eye.sub(this._relativeCenter);v.doubleToTwoFloat32Array(t,this._rtcEyePositionHigh,this._rtcEyePositionLow)}}draw(){this._geoObjects.length&&(this._updateRTCEyePosition(),this.update(),this._displayOpaquePASS())}drawTransparent(){this._geoObjects.length&&this._displayTransparentPASS()}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._geoObjects.length,this._geoObjects.push(e),this._addGeoObjectToArray(e),e.updateRotation(),e._tagData.refresh(),this._updateTag(e._tagData),e.setObjectSrc(e._objectSrc))}remove(e){e._handler&&this.__id==e._handler.__id&&this._removeGeoObject(e)}_clearDataTagQueue(){this._dataTagUpdateQueue=[]}_removeGeoObject(e){let t=e._tagData,i=e.tag;t.numInstances--;let s=!1;t.numInstances===0&&(t.clear(),this._instanceDataMap.delete(i),this._instanceDataMapValues=[],this._clearDataTagQueue(),s=!0),this._geoObjects.splice(e._handlerIndex,1);for(let n=e._handlerIndex,o=this._geoObjects.length;n<o;n++){let l=this._geoObjects[n];l._handlerIndex=l._handlerIndex-1}let r=e._tagDataIndex;t.geoObjects.splice(r,1);for(let n=e._tagDataIndex,o=t.geoObjects.length;n<o;n++){let l=t.geoObjects[n];l._tagDataIndex=l._tagDataIndex-1}t._rgbaArr=Ae(t._rgbaArr,4*r,4),t._rtcPositionHighArr=Ae(t._rtcPositionHighArr,3*r,3),t._rtcPositionLowArr=Ae(t._rtcPositionLowArr,3*r,3),t._qRotArr=Ae(t._qRotArr,4*r,4),t._pickingColorArr=Ae(t._pickingColorArr,3*r,3),t._sizeArr=Ae(t._sizeArr,3*r,3),t._translateArr=Ae(t._translateArr,3*r,3),t._localPositionArr=Ae(t._localPositionArr,3*r,3),t._visibleArr=Ae(t._visibleArr,r,1),e._handlerIndex=-1,e._handler=null,e._tagDataIndex=-1,e._tagData=null,s||(t.refresh(),this._updateTag(t))}};Nn.__counter__=0;let Sl=Nn;class Ml extends An{constructor(e,t=21){super(e),this._billboards=[],this._gliphParamBuffer=null,this._fontIndexBuffer=null,this._outlineBuffer=null,this._outlineColorBuffer=null,this._gliphParamArr=new Float32Array([]),this._fontIndexArr=new Float32Array([]),this._outlineArr=new Float32Array([]),this._outlineColorArr=new Float32Array([]),this._buffersUpdateCallbacks[8]=this.createFontIndexBuffer,this._buffersUpdateCallbacks[9]=this.createOutlineBuffer,this._buffersUpdateCallbacks[10]=this.createOutlineColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length),this._maxLetters=t}initProgram(){this._renderer&&this._renderer.handler&&this._renderer.handler.gl&&(this._renderer.handler.programs.label||(this._renderer.handler.gl.type==="webgl2"?this._renderer.handler.addProgram(new X("label",{uniforms:{viewport:"vec2",fontTextureArr:"sampler2darray",sdfParamsArr:"vec4",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",scaleByDistance:"vec3",opacity:"float",isOutlinePass:"int",depthOffset:"float"},attributes:{a_outline:"float",a_gliphParam:"vec4",a_vertices:"vec2",a_texCoord:"vec4",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_size:"float",a_rotation:"float",a_rgba:"vec4",a_offset:"vec3",a_fontIndex:"float"},vertexShader:`#version 300 es
102
+ precision highp float;uniform float frustumPickingColor;layout(location=0)out vec4 frustumColor;layout(location=1)out vec4 depthColor;void main(){frustumColor=vec4(frustumPickingColor,frustumPickingColor,frustumPickingColor,1.0);depthColor=vec4(gl_FragCoord.z,gl_FragCoord.z,gl_FragCoord.z,1.0);}`})))}setRenderNode(e){this._renderNode=e,this._renderer=e.renderer,this.initProgram();for(let t=0;t<this._instanceDataMapValues.length;t++)this._instanceDataMapValues[t].loadColorTexture(),this._instanceDataMapValues[t].loadNormalTexture(),this._instanceDataMapValues[t].loadMetallicRoughnessTexture();for(let t=0;t<this._geoObjects.length;t++)this._geoObjects[t].updateRotation();this.update()}setColorTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._colorTextureSrc=e,i._colorTextureImage=null),e instanceof HTMLImageElement&&(i._colorTextureSrc=null,i._colorTextureImage=e),this._instanceDataMap.set(t,i),i.loadColorTexture())}setNormalTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._normalTextureSrc=e,i._normalTextureImage=null),e instanceof HTMLImageElement&&(i._normalTextureSrc=null,i._normalTextureImage=e),this._instanceDataMap.set(t,i),i.loadNormalTexture())}setMetallicRoughnessTextureTag(e,t){const i=this._instanceDataMap.get(t);i&&(typeof e=="string"&&(i._metallicRoughnessTextureSrc=e,i._metallicRoughnessTextureImage=null),e instanceof HTMLImageElement&&(i._metallicRoughnessTextureSrc=null,i._metallicRoughnessTextureImage=e),this._instanceDataMap.set(t,i),i.loadMetallicRoughnessTexture())}setObjectSrc(e,t){const i=this._instanceDataMap.get(t);e&&i&&i._objectSrc!==e&&(i._objectSrc=e,Z.loadObj(e).then(r=>{this._updateInstanceData(r[0],t)}))}_updateInstanceData(e,t){const i=this._instanceDataMap.get(t);i&&(e.vertices.length!==i._vertexArr.length&&(i._vertexArr=e.vertices,i._changedBuffers[Pn]=!0),e.normals.length!==i._normalsArr.length&&(i._normalsArr=e.normals,i._changedBuffers[Rn]=!0),e.indices.length!==i._indicesArr.length&&(i._indicesArr=e.indices,i._changedBuffers[Bn]=!0),e.texCoords.length!==i._texCoordArr.length&&(i._texCoordArr=e.texCoords,i._changedBuffers[Fn]=!0),i._colorTextureSrc=e.colorTextureSrc,i._normalTextureSrc=e.normalTextureSrc,i._metallicRoughnessTexture=e.metallicRoughnessTextureSrc,i._colorTextureImage=e.colorTextureImage,i._normalTextureImage=e.normalTextureImage,i._metallicRoughnessTextureImage=e.metallicRoughnessTextureImage,i.loadColorTexture(),i.loadNormalTexture(),i.loadMetallicRoughnessTexture(),this._updateTag(i),this._instanceDataMapValues=Array.from(this._instanceDataMap.values()))}_addGeoObjectToArray(e){const t=e.tag;let i=this._instanceDataMap.get(t);i||(i=new Pl(this),this._instanceDataMap.set(t,i),this._instanceDataMapValues=Array.from(this._instanceDataMap.values()),i._vertexArr=e.vertices,i._normalsArr=e.normals,i._indicesArr=e.indices,i._texCoordArr=e.texCoords,i._colorTextureSrc=e.object3d.colorTextureSrc,i._normalTextureSrc=e.object3d.normalTextureSrc,i._metallicRoughnessTextureSrc=e.object3d.metallicRoughnessTextureSrc,i._colorTextureImage=e.object3d.colorTextureImage,i._normalTextureImage=e.object3d.normalTextureImage,i._metallicRoughnessTextureImage=e.object3d.metallicRoughnessTextureImage,i.setMaterialParams(e.object3d.ambient,e.object3d.diffuse,e.object3d.specular,e.object3d.shininess),i.loadColorTexture(),i.loadNormalTexture(),i.loadMetallicRoughnessTexture()),e._tagDataIndex=i.numInstances++,e._tagData=i,i.geoObjects.push(e);let r=3;i._visibleArr=xe(i._visibleArr,Le([],0,1,1,e.getVisibility()?1:0)),this.getRTCPosition(e.getPosition(),e._rtcPositionHigh,e._rtcPositionLow);let s,n=e._rtcPositionHigh.x,o=e._rtcPositionHigh.y,l=e._rtcPositionHigh.z;i._rtcPositionHighArr=xe(i._rtcPositionHighArr,Le([],0,r,r,n,o,l)),n=e._rtcPositionLow.x,o=e._rtcPositionLow.y,l=e._rtcPositionLow.z,i._rtcPositionLowArr=xe(i._rtcPositionLowArr,Le([],0,r,r,n,o,l)),n=e._entity._pickingColor.x/255,o=e._entity._pickingColor.y/255,l=e._entity._pickingColor.z/255,i._pickingColorArr=xe(i._pickingColorArr,Le([],0,r,r,n,o,l)),r=4,n=e._qRot.x,o=e._qRot.y,l=e._qRot.z,s=e._qRot.w,i._qRotArr=xe(i._qRotArr,Le([],0,r,r,n,o,l,s)),n=e._color.x,o=e._color.y,l=e._color.z,s=e._color.w,i._rgbaArr=xe(i._rgbaArr,Le([],0,r,r,n,o,l,s)),r=3;let h=e.getScale();n=h.x,o=h.y,l=h.z,i._sizeArr=xe(i._sizeArr,Le([],0,r,r,n,o,l));let c=e.getTranslate();n=c.x,o=c.y,l=c.z,i._translateArr=xe(i._translateArr,Le([],0,r,r,n,o,l));let d=e.getLocalPosition();n=d.x,o=d.y,l=d.z,i._localPositionArr=xe(i._localPositionArr,Le([],0,r,r,n,o,l))}_bindCommon(){let e=this._renderer,t=e.handler.programs.geo_object._program.uniforms,i=e.handler.gl,r=this._entityCollection;i.uniform3fv(t.uScaleByDistance,r.scaleByDistance),i.uniform1f(t.useLighting,r._useLighting),i.uniform3fv(t.eyePositionHigh,e.activeCamera.eyeHigh),i.uniform3fv(t.eyePositionLow,e.activeCamera.eyeLow),i.uniform3fv(t.rtcEyePositionHigh,this._rtcEyePositionHigh),i.uniform3fv(t.rtcEyePositionLow,this._rtcEyePositionLow),i.uniformMatrix4fv(t.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),i.uniformMatrix4fv(t.viewMatrix,!1,e.activeCamera.getViewMatrix()),i.uniform3fv(t.sunPosition,this._renderNode._lightPosition)}_displayOpaquePASS(){let e=this._renderer.handler.programs.geo_object,t=e._program;e.activate(),this._bindCommon();for(let i=0;i<this._instanceDataMapValues.length;i++)this._instanceDataMapValues[i].drawOpaque(t)}_displayTransparentPASS(){let e=this._renderer.handler.programs.geo_object,t=e._program;e.activate(),this._bindCommon();for(let i=0;i<this._instanceDataMapValues.length;i++)this._instanceDataMapValues[i].drawTransparent(t)}_depthPASS(){let e=this._renderer,t=e.handler.programs.geo_object_depth,i=t._program,r=i.uniforms,s=i.attributes,n=e.handler.gl,o=this._entityCollection,l=e.activeCamera;t.activate(),n.uniform3fv(r.uScaleByDistance,o.scaleByDistance),n.uniform3fv(r.rtcEyePositionHigh,this._rtcEyePositionHigh),n.uniform3fv(r.rtcEyePositionLow,this._rtcEyePositionLow),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniform1f(r.frustumPickingColor,l.frustumColorIndex);for(let h=0;h<this._instanceDataMapValues.length;h++){let c=this._instanceDataMapValues[h];n.bindBuffer(n.ARRAY_BUFFER,c._qRotBuffer),n.vertexAttribPointer(s.qRot,c._qRotBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._sizeBuffer),n.vertexAttribPointer(s.aScale,c._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._translateBuffer),n.vertexAttribPointer(s.aTranslate,c._translateBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._localPositionBuffer),n.vertexAttribPointer(s.aLocalPosition,c._localPositionBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._rtcPositionHighBuffer),n.vertexAttribPointer(s.aRTCPositionHigh,c._rtcPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._rtcPositionLowBuffer),n.vertexAttribPointer(s.aRTCPositionLow,c._rtcPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._visibleBuffer),n.vertexAttribPointer(s.aDispose,c._visibleBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,c._vertexBuffer),n.vertexAttribPointer(s.aVertexPosition,c._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,c._indicesBuffer),i.drawElementsInstanced(n.TRIANGLES,c._indicesBuffer.numItems,n.UNSIGNED_INT,0,c.numInstances)}}drawDepth(){this._geoObjects.length&&this._depthPASS()}drawPicking(){this._geoObjects.length&&this.pickingEnabled&&this._pickingPASS()}_pickingPASS(){let e=this._renderer,t=e.handler.programs.geo_object_picking,i=t._program,r=i.uniforms,s=i.attributes,n=e.handler.gl,o=this._entityCollection;t.activate(),n.uniform3fv(r.uScaleByDistance,o.scaleByDistance),n.uniform3fv(r.pickingScale,o.pickingScale),n.uniform3fv(r.rtcEyePositionHigh,this._rtcEyePositionHigh),n.uniform3fv(r.rtcEyePositionLow,this._rtcEyePositionLow),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix());for(let l=0;l<this._instanceDataMapValues.length;l++){let h=this._instanceDataMapValues[l];n.bindBuffer(n.ARRAY_BUFFER,h._qRotBuffer),n.vertexAttribPointer(s.qRot,h._qRotBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._sizeBuffer),n.vertexAttribPointer(s.aScale,h._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._translateBuffer),n.vertexAttribPointer(s.aTranslate,h._translateBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._localPositionBuffer),n.vertexAttribPointer(s.aLocalPosition,h._localPositionBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._pickingColorBuffer),n.vertexAttribPointer(s.aPickingColor,h._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._rtcPositionHighBuffer),n.vertexAttribPointer(s.aRTCPositionHigh,h._rtcPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._rtcPositionLowBuffer),n.vertexAttribPointer(s.aRTCPositionLow,h._rtcPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._visibleBuffer),n.vertexAttribPointer(s.aDispose,h._visibleBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h._vertexBuffer),n.vertexAttribPointer(s.aVertexPosition,h._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h._indicesBuffer),i.drawElementsInstanced(n.TRIANGLES,h._indicesBuffer.numItems,n.UNSIGNED_INT,0,h.numInstances)}}setQRotArr(e,t,i){Le(e._qRotArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[kn]=!0,this._updateTag(e)}setVisibility(e,t,i){Le(e._visibleArr,t,1,1,i?1:0),e._changedBuffers[Dn]=!0,this._updateTag(e)}setRTCPositionArr(e,t,i,r){Le(e._rtcPositionHighArr,t,3,3,i.x,i.y,i.z),Le(e._rtcPositionLowArr,t,3,3,r.x,r.y,r.z),e._changedBuffers[Sn]=!0,this._updateTag(e)}setRgbaArr(e,t,i){Le(e._rgbaArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Mn]=!0,this._updateTag(e)}setPickingColorArr(e,t,i){Le(e._pickingColorArr,t,3,3,i.x/255,i.y/255,i.z/255),e._changedBuffers[zn]=!0,this._updateTag(e)}setScaleArr(e,t,i){Le(e._sizeArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[In]=!0,this._updateTag(e)}setTranslateArr(e,t,i){Le(e._translateArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[On]=!0,this._updateTag(e)}setLocalPositionArr(e,t,i){Le(e._localPositionArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Nn]=!0,this._updateTag(e)}_updateTag(e){e.isFree&&(e.isFree=!1,this._dataTagUpdateQueue.push(e))}update(){for(let e=0,t=this._dataTagUpdateQueue.length;e<t;e++)this._dataTagUpdateQueue[e].update();this._dataTagUpdateQueue=[]}_removeAll(){let e=this._geoObjects.length;for(;e--;){const t=this._geoObjects[e];t._tagDataIndex=-1,t._tagData=null,t._handlerIndex=-1,t._handler=null}this._geoObjects.length=0,this._geoObjects=[];for(let t=0;t<this._instanceDataMapValues.length;t++)this._instanceDataMapValues[t].clear();this._instanceDataMap.clear(),this._instanceDataMapValues=[]}clear(){this._removeAll()}getRTCPosition(e,t,i){let r=e.sub(this._relativeCenter);m.doubleToTwoFloats(r,t,i)}setRelativeCenter(e){this._relativeCenter.copy(e);for(let t=0;t<this._instanceDataMapValues.length;t++){let i=this._instanceDataMapValues[t].geoObjects;for(let r=0;r<i.length;r++)i[r].updateRTCPosition()}}_updateRTCEyePosition(){let e=this._renderer;if(e.activeCamera.isFirstPass){let t=e.activeCamera.eye.sub(this._relativeCenter);m.doubleToTwoFloat32Array(t,this._rtcEyePositionHigh,this._rtcEyePositionLow)}}draw(){this._geoObjects.length&&(this._updateRTCEyePosition(),this.update(),this._displayOpaquePASS())}drawTransparent(){this._geoObjects.length&&this._displayTransparentPASS()}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._geoObjects.length,this._geoObjects.push(e),this._addGeoObjectToArray(e),e.updateRotation(),e._tagData.refresh(),this._updateTag(e._tagData),e.setObjectSrc(e._objectSrc))}remove(e){e._handler&&this.__id==e._handler.__id&&this._removeGeoObject(e)}_clearDataTagQueue(){this._dataTagUpdateQueue=[]}_removeGeoObject(e){let t=e._tagData,i=e.tag;t.numInstances--;let r=!1;t.numInstances===0&&(t.clear(),this._instanceDataMap.delete(i),this._instanceDataMapValues=[],this._clearDataTagQueue(),r=!0),this._geoObjects.splice(e._handlerIndex,1);for(let n=e._handlerIndex,o=this._geoObjects.length;n<o;n++){let l=this._geoObjects[n];l._handlerIndex=l._handlerIndex-1}let s=e._tagDataIndex;t.geoObjects.splice(s,1);for(let n=e._tagDataIndex,o=t.geoObjects.length;n<o;n++){let l=t.geoObjects[n];l._tagDataIndex=l._tagDataIndex-1}t._rgbaArr=Ae(t._rgbaArr,4*s,4),t._rtcPositionHighArr=Ae(t._rtcPositionHighArr,3*s,3),t._rtcPositionLowArr=Ae(t._rtcPositionLowArr,3*s,3),t._qRotArr=Ae(t._qRotArr,4*s,4),t._pickingColorArr=Ae(t._pickingColorArr,3*s,3),t._sizeArr=Ae(t._sizeArr,3*s,3),t._translateArr=Ae(t._translateArr,3*s,3),t._localPositionArr=Ae(t._localPositionArr,3*s,3),t._visibleArr=Ae(t._visibleArr,s,1),e._handlerIndex=-1,e._handler=null,e._tagDataIndex=-1,e._tagData=null,r||(t.refresh(),this._updateTag(t))}};Hn.__counter__=0;let Sl=Hn;class Ml extends Ln{constructor(e,t=21){super(e),this._billboards=[],this._gliphParamBuffer=null,this._fontIndexBuffer=null,this._outlineBuffer=null,this._outlineColorBuffer=null,this._gliphParamArr=new Float32Array([]),this._fontIndexArr=new Float32Array([]),this._outlineArr=new Float32Array([]),this._outlineColorArr=new Float32Array([]),this._buffersUpdateCallbacks[8]=this.createFontIndexBuffer,this._buffersUpdateCallbacks[9]=this.createOutlineBuffer,this._buffersUpdateCallbacks[10]=this.createOutlineColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length),this._maxLetters=t}initProgram(){this._renderer&&this._renderer.handler&&this._renderer.handler.gl&&(this._renderer.handler.programs.label||(this._renderer.handler.gl.type==="webgl2"?this._renderer.handler.addProgram(new X("label",{uniforms:{viewport:"vec2",fontTextureArr:"sampler2darray",sdfParamsArr:"vec4",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",scaleByDistance:"vec3",opacity:"float",isOutlinePass:"int",depthOffset:"float"},attributes:{a_outline:"float",a_gliphParam:"vec4",a_vertices:"vec2",a_texCoord:"vec4",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_size:"float",a_rotation:"float",a_rgba:"vec4",a_offset:"vec3",a_fontIndex:"float"},vertexShader:`#version 300 es
103
103
  #define EMPTY - 1.0
104
104
  #define RTL 1.0
105
105
  vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}in float a_outline;in vec4 a_gliphParam;in vec2 a_vertices;in vec4 a_texCoord;in vec3 a_positionsHigh;in vec3 a_positionsLow;in vec3 a_offset;in float a_size;in float a_rotation;in vec4 a_rgba;in float a_fontIndex;out vec2 v_uv;out vec4 v_rgba;flat out int v_fontIndex;out vec4 v_outlineColor;flat out float v_outline;uniform vec2 viewport;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float planetRadius;uniform vec3 scaleByDistance;uniform float opacity;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){if(a_texCoord.w==EMPTY){gl_Position=vec4(0.0);v_fontIndex=-1;return;}vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;v_outline=a_outline;v_fontIndex=int(a_fontIndex);v_uv=a_texCoord.xy;vec3 look=a_positions-cameraPos;float lookDist=length(look);v_rgba=a_rgba;if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(scaleByDistance[0],scaleByDistance[1],lookDist))*(1.0-step(scaleByDistance[2],lookDist));v_rgba.a*=opacity;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 vert=a_vertices;vec4 gp=a_gliphParam;if(a_texCoord.w==RTL){vert.x=step(vert.x*0.5+1.0,1.0);gp.x=-a_gliphParam.x;gp.z=-(a_gliphParam.z+a_texCoord.z);}else{gp.z=a_gliphParam.z+a_texCoord.z;}vec2 v=screenPos+rotate2d(a_rotation)*((vert*gp.xy+gp.zw)*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:`#version 300 es
@@ -108,7 +108,7 @@ uniform int isOutlinePass;precision highp float;const int MAX_SIZE=11;uniform sa
108
108
  vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute float a_outline;attribute vec4 a_gliphParam;attribute vec2 a_vertices;attribute vec4 a_texCoord;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute float a_size;attribute float a_rotation;attribute vec4 a_rgba;attribute float a_fontIndex;varying float v_outline;varying vec2 v_uv;varying vec4 v_rgba;varying float v_fontIndex;uniform vec2 viewport;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float planetRadius;uniform vec3 scaleByDistance;uniform float opacity;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){if(a_texCoord.w==EMPTY){gl_Position=vec4(0.0);v_fontIndex=-1.0;return;}vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;v_outline=a_outline;v_uv=vec2(a_texCoord.xy);v_rgba=a_rgba;v_fontIndex=a_fontIndex;vec3 look=a_positions-cameraPos;float lookDist=length(look);if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(scaleByDistance[0],scaleByDistance[1],lookDist))*(1.0-step(scaleByDistance[2],lookDist));v_rgba.a*=opacity;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 vert=a_vertices;vec4 gp=a_gliphParam;if(a_texCoord.w==RTL){vert.x=step(vert.x*0.5+1.0,1.0);gp.x=-a_gliphParam.x;gp.z=-(a_gliphParam.z+a_texCoord.z);}else{gp.z=a_gliphParam.z+a_texCoord.z;}vec2 v=screenPos+rotate2d(a_rotation)*((vert*gp.xy+gp.zw)*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:`#extension GL_OES_standard_derivatives: enable
109
109
  precision highp float;precision highp int;const int MAX_SIZE=11;uniform sampler2D fontTextureArr[MAX_SIZE];uniform vec4 sdfParamsArr[MAX_SIZE];uniform int isOutlinePass;varying float v_outline;varying vec2 v_uv;varying vec4 v_rgba;varying float v_fontIndex;float fontIndex;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}float getDistance(){vec3 msdf;if(fontIndex>=0.0&&fontIndex<1.0){msdf=texture2D(fontTextureArr[0],v_uv).rgb;}else if(fontIndex>=1.0&&fontIndex<2.0){msdf=texture2D(fontTextureArr[1],v_uv).rgb;}else if(fontIndex>=2.0&&fontIndex<3.0){msdf=texture2D(fontTextureArr[2],v_uv).rgb;}else if(fontIndex>=3.0&&fontIndex<4.0){msdf=texture2D(fontTextureArr[3],v_uv).rgb;}else if(fontIndex>=4.0&&fontIndex<5.0){msdf=texture2D(fontTextureArr[4],v_uv).rgb;}else if(fontIndex>=5.0&&fontIndex<6.0){msdf=texture2D(fontTextureArr[5],v_uv).rgb;}else if(fontIndex>=6.0&&fontIndex<7.0){msdf=texture2D(fontTextureArr[6],v_uv).rgb;}else if(fontIndex>=7.0&&fontIndex<8.0){msdf=texture2D(fontTextureArr[7],v_uv).rgb;}else if(fontIndex>=8.0&&fontIndex<9.0){msdf=texture2D(fontTextureArr[8],v_uv).rgb;}else if(fontIndex>=9.0&&fontIndex<10.0){msdf=texture2D(fontTextureArr[9],v_uv).rgb;}else if(fontIndex>=10.0&&fontIndex<11.0){msdf=texture2D(fontTextureArr[10],v_uv).rgb;}return median(msdf.r,msdf.g,msdf.b);}vec4 getSDFParams(){if(fontIndex>=0.0&&fontIndex<1.0){return sdfParamsArr[0];}else if(fontIndex>=1.0&&fontIndex<2.0){return sdfParamsArr[1];}else if(fontIndex>=2.0&&fontIndex<3.0){return sdfParamsArr[2];}else if(fontIndex>=3.0&&fontIndex<4.0){return sdfParamsArr[3];}else if(fontIndex>=4.0&&fontIndex<5.0){return sdfParamsArr[4];}else if(fontIndex>=5.0&&fontIndex<6.0){return sdfParamsArr[5];}else if(fontIndex>=6.0&&fontIndex<7.0){return sdfParamsArr[6];}else if(fontIndex>=7.0&&fontIndex<8.0){return sdfParamsArr[7];}else if(fontIndex>=8.0&&fontIndex<9.0){return sdfParamsArr[8];}else if(fontIndex>=9.0&&fontIndex<10.0){return sdfParamsArr[9];}else if(fontIndex>=10.0&&fontIndex<11.0){return sdfParamsArr[10];}}void main(){fontIndex=v_fontIndex+0.1;if(v_fontIndex<0.0){return;}vec4 sdfParams=getSDFParams();float sd=getDistance();vec2 dxdy=fwidth(v_uv)*sdfParams.xy;float dist=sd+min(0.001,0.5-1.0/sdfParams.w)-0.5;float opacity=clamp(dist*sdfParams.w/length(dxdy)+0.5,0.0,1.0);if(isOutlinePass==0){}else{float strokeDist=sd+min(v_outline,0.5-1.0/sdfParams.w)-0.5;float strokeAlpha=v_rgba.a*clamp(strokeDist*sdfParams.w/length(dxdy)+0.5,0.0,1.0);if(strokeAlpha<0.1){discard;}}}`}))),this._renderer.handler.programs.labelPicking||this._renderer.handler.addProgram(new X("labelPicking",{uniforms:{viewport:"vec2",projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",planetRadius:"float",scaleByDistance:"vec3",opacity:"float",depthOffset:"float"},attributes:{a_gliphParam:"vec4",a_vertices:"vec2",a_texCoord:"vec4",a_positionsHigh:"vec3",a_positionsLow:"vec3",a_offset:"vec3",a_size:"float",a_rotation:"float",a_rgba:"vec4"},vertexShader:`#define EMPTY - 1.0
110
110
  #define RTL 1.0
111
- vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute vec4 a_gliphParam;attribute vec2 a_vertices;attribute vec4 a_texCoord;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute float a_size;attribute float a_rotation;attribute vec4 a_rgba;varying vec4 v_rgba;uniform vec2 viewport;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float planetRadius;uniform vec3 scaleByDistance;uniform float opacity;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;v_rgba=a_rgba;if(a_texCoord.w==EMPTY){v_rgba.a=0.0;gl_Position=vec4(0.0);return;}vec3 look=a_positions-cameraPos;float lookDist=length(look);if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(scaleByDistance[0],scaleByDistance[1],lookDist))*(1.0-step(scaleByDistance[2],lookDist));v_rgba.a*=opacity;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 vert=a_vertices;vec4 gp=a_gliphParam;if(a_texCoord.w==RTL){vert.x=step(vert.x*0.5+1.0,1.0);gp.x=-a_gliphParam.x;gp.z=-(a_gliphParam.z+a_texCoord.z);}else{gp.z=a_gliphParam.z+a_texCoord.z;}vec2 v=screenPos+rotate2d(a_rotation)*((vert*gp.xy+gp.zw)*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:"precision highp float;varying vec4 v_rgba;varying vec3 v_pickingColor;void main(){vec4 color=v_rgba;if(color.a<0.05){return;}gl_FragColor=vec4(v_rgba.rgb,v_rgba.a);}"})))}get labels(){return this._billboards}add(e){e._handler||(e._handler=this,this.assignFontAtlas(e),this.refresh())}updateFonts(){let e=[...this._billboards];this._billboards=[];for(let t=0;t<e.length;t++)this.assignFontAtlas(e[t])}_addLabelToArrays(e){this._renderer&&this._renderer.labelWorker.make({handler:this,label:e})}assignFontAtlas(e){this._entityCollection&&this._renderer?(e.assignFontAtlas(this._renderer.fontAtlas),this._addLabelToArrays(e)):this._billboards.push(e)}workerCallback(e,t){t._lockId!==-1&&t._handler&&this.isEqual(t._handler)&&(t._isReady=!0,t._lockId=-1,t._handlerIndex=this._billboards.length,this._billboards.push(t),this._vertexArr=ae(this._vertexArr,e.vertexArr),this._texCoordArr=ae(this._texCoordArr,e.texCoordArr),this._gliphParamArr=ae(this._gliphParamArr,e.gliphParamArr),this._positionHighArr=ae(this._positionHighArr,e.positionHighArr),this._positionLowArr=ae(this._positionLowArr,e.positionLowArr),this._sizeArr=ae(this._sizeArr,e.sizeArr),this._offsetArr=ae(this._offsetArr,e.offsetArr),this._rgbaArr=ae(this._rgbaArr,e.rgbaArr),this._rotationArr=ae(this._rotationArr,e.rotationArr),this._fontIndexArr=ae(this._fontIndexArr,e.fontIndexArr),this._outlineArr=ae(this._outlineArr,e.outlineArr),this._outlineColorArr=ae(this._outlineColorArr,e.outlineColorArr),this._pickingColorArr=ae(this._pickingColorArr,e.pickingColorArr),t.update(),this.refresh())}clear(){this._texCoordArr=null,this._gliphParamArr=null,this._vertexArr=null,this._positionHighArr=null,this._positionLowArr=null,this._sizeArr=null,this._offsetArr=null,this._rgbaArr=null,this._rotationArr=null,this._fontIndexArr=null,this._outlineArr=null,this._outlineColorArr=null,this._texCoordArr=new Float32Array([]),this._gliphParamArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._fontIndexArr=new Float32Array([]),this._outlineArr=new Float32Array([]),this._outlineColorArr=new Float32Array([]),this._removeBillboards(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e.deleteBuffer(this._gliphParamBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._fontIndexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._outlineBuffer),e.deleteBuffer(this._outlineColorBuffer),e.deleteBuffer(this._positionHighBuffer),e.deleteBuffer(this._positionLowBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._offsetBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._rotationBuffer),e.deleteBuffer(this._vertexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._pickingColorBuffer),this._gliphParamBuffer=null,this._sizeBuffer=null,this._fontIndexBuffer=null,this._texCoordBuffer=null,this._outlineBuffer=null,this._outlineColorBuffer=null,this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._vertexBuffer=null,this._texCoordBuffer=null,this._pickingColorBuffer=null}}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.label.activate();let i=t.programs.label._program,s=i.attributes,r=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1iv(r.fontTextureArr,e.fontAtlas.samplerArr),n.uniform4fv(r.sdfParamsArr,e.fontAtlas.sdfParamsArr),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(r.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(r.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(r.scaleByDistance,o.scaleByDistance),n.uniform1f(r.opacity,o._fadingOpacity),n.uniform1f(r.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(r.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(s.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._gliphParamBuffer),n.vertexAttribPointer(s.a_gliphParam,this._gliphParamBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(s.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(s.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(s.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(s.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(s.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(s.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._fontIndexBuffer),n.vertexAttribPointer(s.a_fontIndex,this._fontIndexBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1i(r.isOutlinePass,1),n.uniform1f(r.depthOffset,o.polygonOffsetUnits),n.bindBuffer(n.ARRAY_BUFFER,this._outlineColorBuffer),n.vertexAttribPointer(s.a_rgba,this._outlineColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._outlineBuffer),n.vertexAttribPointer(s.a_outline,this._outlineBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.depthFunc(n.EQUAL),n.uniform1i(r.isOutlinePass,0),n.uniform1f(r.depthOffset,o.polygonOffsetUnits),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(s.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.depthFunc(n.LESS),n.enable(n.CULL_FACE)}_pickingPASS(){let e=this._renderer,t=e.handler;t.programs.labelPicking.activate();let i=t.programs.labelPicking._program,s=i.attributes,r=i.uniforms,n=t.gl,o=this._entityCollection,l=o.renderNode;n.disable(n.CULL_FACE),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(r.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(r.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(r.scaleByDistance,o.scaleByDistance),n.uniform1f(r.opacity,o._fadingOpacity),n.uniform1f(r.planetRadius,l._planetRadius2||0),n.uniform2fv(r.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(s.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._gliphParamBuffer),n.vertexAttribPointer(s.a_gliphParam,this._gliphParamBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(s.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(s.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(s.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(s.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(s.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(s.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._pickingColorBuffer),n.vertexAttribPointer(s.a_rgba,this._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(r.depthOffset,o.polygonOffsetUnits),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_removeBillboard(e){let t=e._handlerIndex;this._billboards.splice(t,1);let i=24*this._maxLetters,s=t*i;this._rgbaArr=le(this._rgbaArr,s,i),this._outlineColorArr=le(this._outlineColorArr,s,i),this._texCoordArr=le(this._texCoordArr,s,i),this._gliphParamArr=le(this._gliphParamArr,s,i),i=18*this._maxLetters,s=t*i,this._positionHighArr=le(this._positionHighArr,s,i),this._positionLowArr=le(this._positionLowArr,s,i),this._offsetArr=le(this._offsetArr,s,i),this._pickingColorArr=le(this._pickingColorArr,s,i),i=12*this._maxLetters,s=t*i,this._vertexArr=le(this._vertexArr,s,i),i=6*this._maxLetters,s=t*i,this._sizeArr=le(this._sizeArr,s,i),this._rotationArr=le(this._rotationArr,s,i),this._fontIndexArr=le(this._fontIndexArr,s,i),this._outlineArr=le(this._outlineArr,s,i),this.reindexBillboardsArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null,e._isReady=!1}setText(e,t,i,s,r=0,n=!1){t=t.normalize("NFKC");let o=this._renderer.fontAtlas.atlasesArr[i];if(!o)return;let l=24*e*this._maxLetters,h=this._texCoordArr,c=this._gliphParamArr,d=0,u=Math.min(this._maxLetters,t.length),g=0;n&&(g=1);let f=0,p=o.kernings;for(d=0;d<u;d++){let _=l+24*d,m=t[d],y=o.get(m.charCodeAt(0))||o.get(32);if(!y)continue;let x=y.texCoords,w=y.metrics;h[_]=x[0],h[_+1]=x[1],h[_+2]=f,h[_+3]=g,h[_+4]=x[2],h[_+5]=x[3],h[_+6]=f,h[_+7]=g,h[_+8]=x[4],h[_+9]=x[5],h[_+10]=f,h[_+11]=g,h[_+12]=x[6],h[_+13]=x[7],h[_+14]=f,h[_+15]=g,h[_+16]=x[8],h[_+17]=x[9],h[_+18]=f,h[_+19]=g,h[_+20]=x[10],h[_+21]=x[11],h[_+22]=f,h[_+23]=g,c[_]=w.nWidth,c[_+1]=w.nHeight,c[_+2]=w.nXOffset,c[_+3]=w.nYOffset,c[_+4]=w.nWidth,c[_+5]=w.nHeight,c[_+6]=w.nXOffset,c[_+7]=w.nYOffset,c[_+8]=w.nWidth,c[_+9]=w.nHeight,c[_+10]=w.nXOffset,c[_+11]=w.nYOffset,c[_+12]=w.nWidth,c[_+13]=w.nHeight,c[_+14]=w.nXOffset,c[_+15]=w.nYOffset,c[_+16]=w.nWidth,c[_+17]=w.nHeight,c[_+18]=w.nXOffset,c[_+19]=w.nYOffset,c[_+20]=w.nWidth,c[_+21]=w.nHeight,c[_+22]=w.nXOffset,c[_+23]=w.nYOffset;let b=p[m.charCodeAt(0)];if(b&&t[d+1]){let E=b[t[d+1].charCodeAt(0)];f+=E?w.nAdvance+E+r:w.nAdvance+r}else f+=w.nAdvance+r}if(s===ii.CENTER)for(f*=-.5,d=0;d<u;d++){let _=l+24*d;h[_+2]+=f,h[_+6]+=f,h[_+10]+=f,h[_+14]+=f,h[_+18]+=f,h[_+22]+=f}for(;d<this._maxLetters;d++){let _=l+24*d;h[_+3]=-1,h[_+7]=-1,h[_+11]=-1,h[_+15]=-1,h[_+19]=-1,h[_+23]=-1}this._changedBuffers[6]=!0}setPositionArr(e,t,i){let s=18*e*this._maxLetters,r=this._positionHighArr,n=t.x,o=t.y,l=t.z,h=this._positionLowArr,c=i.x,d=i.y,u=i.z;for(let g=0;g<this._maxLetters;g++){let f=s+18*g;r[f]=n,r[f+1]=o,r[f+2]=l,r[f+3]=n,r[f+4]=o,r[f+5]=l,r[f+6]=n,r[f+7]=o,r[f+8]=l,r[f+9]=n,r[f+10]=o,r[f+11]=l,r[f+12]=n,r[f+13]=o,r[f+14]=l,r[f+15]=n,r[f+16]=o,r[f+17]=l,h[f]=c,h[f+1]=d,h[f+2]=u,h[f+3]=c,h[f+4]=d,h[f+5]=u,h[f+6]=c,h[f+7]=d,h[f+8]=u,h[f+9]=c,h[f+10]=d,h[f+11]=u,h[f+12]=c,h[f+13]=d,h[f+14]=u,h[f+15]=c,h[f+16]=d,h[f+17]=u}this._changedBuffers[1]=!0}setPickingColorArr(e,t){let i=18*e*this._maxLetters,s=this._pickingColorArr,r=t.x/255,n=t.y/255,o=t.z/255;for(let l=0;l<this._maxLetters;l++){let h=i+18*l;s[h]=r,s[h+1]=n,s[h+2]=o,s[h+3]=r,s[h+4]=n,s[h+5]=o,s[h+6]=r,s[h+7]=n,s[h+8]=o,s[h+9]=r,s[h+10]=n,s[h+11]=o,s[h+12]=r,s[h+13]=n,s[h+14]=o,s[h+15]=r,s[h+16]=n,s[h+17]=o}this._changedBuffers[0]=!0}setSizeArr(e,t){let i=6*e*this._maxLetters,s=this._sizeArr;for(let r=0;r<this._maxLetters;r++){let n=i+6*r;s[n]=t,s[n+1]=t,s[n+2]=t,s[n+3]=t,s[n+4]=t,s[n+5]=t}this._changedBuffers[2]=!0}setOffsetArr(e,t){let i=18*e*this._maxLetters,s=this._offsetArr,r=t.x,n=t.y,o=t.z;for(let l=0;l<this._maxLetters;l++){let h=i+18*l;s[h]=r,s[h+1]=n,s[h+2]=o,s[h+3]=r,s[h+4]=n,s[h+5]=o,s[h+6]=r,s[h+7]=n,s[h+8]=o,s[h+9]=r,s[h+10]=n,s[h+11]=o,s[h+12]=r,s[h+13]=n,s[h+14]=o,s[h+15]=r,s[h+16]=n,s[h+17]=o}this._changedBuffers[3]=!0}setRgbaArr(e,t){let i=24*e*this._maxLetters,s=this._rgbaArr,r=t.x,n=t.y,o=t.z,l=t.w;for(let h=0;h<this._maxLetters;h++){let c=i+24*h;s[c]=r,s[c+1]=n,s[c+2]=o,s[c+3]=l,s[c+4]=r,s[c+5]=n,s[c+6]=o,s[c+7]=l,s[c+8]=r,s[c+9]=n,s[c+10]=o,s[c+11]=l,s[c+12]=r,s[c+13]=n,s[c+14]=o,s[c+15]=l,s[c+16]=r,s[c+17]=n,s[c+18]=o,s[c+19]=l,s[c+20]=r,s[c+21]=n,s[c+22]=o,s[c+23]=l}this._changedBuffers[4]=!0}setOutlineColorArr(e,t){let i=24*e*this._maxLetters,s=this._outlineColorArr,r=t.x,n=t.y,o=t.z,l=t.w;for(let h=0;h<this._maxLetters;h++){let c=i+24*h;s[c]=r,s[c+1]=n,s[c+2]=o,s[c+3]=l,s[c+4]=r,s[c+5]=n,s[c+6]=o,s[c+7]=l,s[c+8]=r,s[c+9]=n,s[c+10]=o,s[c+11]=l,s[c+12]=r,s[c+13]=n,s[c+14]=o,s[c+15]=l,s[c+16]=r,s[c+17]=n,s[c+18]=o,s[c+19]=l,s[c+20]=r,s[c+21]=n,s[c+22]=o,s[c+23]=l}this._changedBuffers[10]=!0}setOutlineArr(e,t){let i=6*e*this._maxLetters,s=this._outlineArr;for(let r=0;r<this._maxLetters;r++){let n=i+6*r;s[n]=t,s[n+1]=t,s[n+2]=t,s[n+3]=t,s[n+4]=t,s[n+5]=t}this._changedBuffers[9]=!0}setRotationArr(e,t){let i=6*e*this._maxLetters,s=this._rotationArr;for(let r=0;r<this._maxLetters;r++){let n=i+6*r;s[n]=t,s[n+1]=t,s[n+2]=t,s[n+3]=t,s[n+4]=t,s[n+5]=t}this._changedBuffers[5]=!0}setVisibility(e,t){let i;i=t?[0,0,0,-1,1,-1,1,-1,1,0,0,0]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e*this._maxLetters,s=this._vertexArr;for(let r=0;r<this._maxLetters;r++){let n=i+12*r;s[n]=t[0],s[n+1]=t[1],s[n+2]=t[2],s[n+3]=t[3],s[n+4]=t[4],s[n+5]=t[5],s[n+6]=t[6],s[n+7]=t[7],s[n+8]=t[8],s[n+9]=t[9],s[n+10]=t[10],s[n+11]=t[11]}this._changedBuffers[7]=!0}setFontIndexArr(e,t){let i=6*e*this._maxLetters,s=this._fontIndexArr;for(let r=0;r<this._maxLetters;r++){let n=i+6*r;s[n]=t,s[n+1]=t,s[n+2]=t,s[n+3]=t,s[n+4]=t,s[n+5]=t}this._changedBuffers[8]=!0}createSizeBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createArrayBuffer(this._sizeArr,1,this._sizeArr.length)}createFontIndexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._fontIndexBuffer),this._fontIndexBuffer=e.createArrayBuffer(this._fontIndexArr,1,this._fontIndexArr.length)}createTexCoordBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,4,this._texCoordArr.length/4),e.gl.deleteBuffer(this._gliphParamBuffer),this._gliphParamBuffer=e.createArrayBuffer(this._gliphParamArr,4,this._gliphParamArr.length/4)}createOutlineBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._outlineBuffer),this._outlineBuffer=e.createArrayBuffer(this._outlineArr,1,this._outlineArr.length)}createOutlineColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._outlineColorBuffer),this._outlineColorBuffer=e.createArrayBuffer(this._outlineColorArr,4,this._outlineColorArr.length/4)}setMaxLetters(e){this._maxLetters=e}}const Hn=class Va{constructor(e){this.pickingEnabled=!0,this.__id=Va.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._pointClouds=[]}_initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.pointCloud||this._renderer.handler.addProgram(new X("pointCloud",{uniforms:{projectionViewMatrix:"mat4",opacity:"float",pointSize:"float"},attributes:{coordinates:"vec3",colors:"vec3"},vertexShader:`attribute vec3 coordinates;
111
+ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 rotate2d(float angle){return mat2(cos(angle),-sin(angle),sin(angle),cos(angle));}attribute vec4 a_gliphParam;attribute vec2 a_vertices;attribute vec4 a_texCoord;attribute vec3 a_positionsHigh;attribute vec3 a_positionsLow;attribute vec3 a_offset;attribute float a_size;attribute float a_rotation;attribute vec4 a_rgba;varying vec4 v_rgba;uniform vec2 viewport;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float planetRadius;uniform vec3 scaleByDistance;uniform float opacity;uniform float depthOffset;const vec3 ZERO3=vec3(0.0);void main(){vec3 a_positions=a_positionsHigh+a_positionsLow;vec3 cameraPos=eyePositionHigh+eyePositionLow;v_rgba=a_rgba;if(a_texCoord.w==EMPTY){v_rgba.a=0.0;gl_Position=vec4(0.0);return;}vec3 look=a_positions-cameraPos;float lookDist=length(look);if(opacity*step(lookDist,sqrt(dot(cameraPos,cameraPos)-planetRadius)+sqrt(dot(a_positions,a_positions)-planetRadius))==0.0){return;}float scd=(1.0-smoothstep(scaleByDistance[0],scaleByDistance[1],lookDist))*(1.0-step(scaleByDistance[2],lookDist));v_rgba.a*=opacity;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff=a_positionsHigh-eyePositionHigh;vec3 lowDiff=a_positionsLow-eyePositionLow;vec4 posRTE=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);vec4 projPos=projectionMatrix*posRTE;float camSlope=dot(vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]),normalize(cameraPos));if(camSlope>0.5){float dist=dot(look,normalize(cameraPos));projPos.z+=dist*0.02;}else{projPos.z+=-(abs(projPos.z))*0.002;}projPos.z+=depthOffset+a_offset.z;vec2 screenPos=project(projPos,viewport);vec2 vert=a_vertices;vec4 gp=a_gliphParam;if(a_texCoord.w==RTL){vert.x=step(vert.x*0.5+1.0,1.0);gp.x=-a_gliphParam.x;gp.z=-(a_gliphParam.z+a_texCoord.z);}else{gp.z=a_gliphParam.z+a_texCoord.z;}vec2 v=screenPos+rotate2d(a_rotation)*((vert*gp.xy+gp.zw)*a_size*scd+a_offset.xy);gl_Position=vec4((2.0*v/viewport-1.0)*projPos.w,projPos.z,projPos.w);}`,fragmentShader:"precision highp float;varying vec4 v_rgba;varying vec3 v_pickingColor;void main(){vec4 color=v_rgba;if(color.a<0.05){return;}gl_FragColor=vec4(v_rgba.rgb,v_rgba.a);}"})))}get labels(){return this._billboards}add(e){e._handler||(e._handler=this,this.assignFontAtlas(e),this.refresh())}updateFonts(){let e=[...this._billboards];this._billboards=[];for(let t=0;t<e.length;t++)this.assignFontAtlas(e[t])}_addLabelToArrays(e){this._renderer&&this._renderer.labelWorker.make({handler:this,label:e})}assignFontAtlas(e){this._entityCollection&&this._renderer?(e.assignFontAtlas(this._renderer.fontAtlas),this._addLabelToArrays(e)):this._billboards.push(e)}workerCallback(e,t){t._lockId!==-1&&t._handler&&this.isEqual(t._handler)&&(t._isReady=!0,t._lockId=-1,t._handlerIndex=this._billboards.length,this._billboards.push(t),this._vertexArr=oe(this._vertexArr,e.vertexArr),this._texCoordArr=oe(this._texCoordArr,e.texCoordArr),this._gliphParamArr=oe(this._gliphParamArr,e.gliphParamArr),this._positionHighArr=oe(this._positionHighArr,e.positionHighArr),this._positionLowArr=oe(this._positionLowArr,e.positionLowArr),this._sizeArr=oe(this._sizeArr,e.sizeArr),this._offsetArr=oe(this._offsetArr,e.offsetArr),this._rgbaArr=oe(this._rgbaArr,e.rgbaArr),this._rotationArr=oe(this._rotationArr,e.rotationArr),this._fontIndexArr=oe(this._fontIndexArr,e.fontIndexArr),this._outlineArr=oe(this._outlineArr,e.outlineArr),this._outlineColorArr=oe(this._outlineColorArr,e.outlineColorArr),this._pickingColorArr=oe(this._pickingColorArr,e.pickingColorArr),t.update(),this.refresh())}clear(){this._texCoordArr=null,this._gliphParamArr=null,this._vertexArr=null,this._positionHighArr=null,this._positionLowArr=null,this._sizeArr=null,this._offsetArr=null,this._rgbaArr=null,this._rotationArr=null,this._fontIndexArr=null,this._outlineArr=null,this._outlineColorArr=null,this._texCoordArr=new Float32Array([]),this._gliphParamArr=new Float32Array([]),this._vertexArr=new Float32Array([]),this._positionHighArr=new Float32Array([]),this._positionLowArr=new Float32Array([]),this._sizeArr=new Float32Array([]),this._offsetArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._rotationArr=new Float32Array([]),this._fontIndexArr=new Float32Array([]),this._outlineArr=new Float32Array([]),this._outlineColorArr=new Float32Array([]),this._removeBillboards(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e.deleteBuffer(this._gliphParamBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._fontIndexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._outlineBuffer),e.deleteBuffer(this._outlineColorBuffer),e.deleteBuffer(this._positionHighBuffer),e.deleteBuffer(this._positionLowBuffer),e.deleteBuffer(this._sizeBuffer),e.deleteBuffer(this._offsetBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._rotationBuffer),e.deleteBuffer(this._vertexBuffer),e.deleteBuffer(this._texCoordBuffer),e.deleteBuffer(this._pickingColorBuffer),this._gliphParamBuffer=null,this._sizeBuffer=null,this._fontIndexBuffer=null,this._texCoordBuffer=null,this._outlineBuffer=null,this._outlineColorBuffer=null,this._positionHighBuffer=null,this._positionLowBuffer=null,this._sizeBuffer=null,this._offsetBuffer=null,this._rgbaBuffer=null,this._rotationBuffer=null,this._vertexBuffer=null,this._texCoordBuffer=null,this._pickingColorBuffer=null}}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.label.activate();let i=t.programs.label._program,r=i.attributes,s=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1iv(s.fontTextureArr,e.fontAtlas.samplerArr),n.uniform4fv(s.sdfParamsArr,e.fontAtlas.sdfParamsArr),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(s.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(s.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(s.scaleByDistance,o.scaleByDistance),n.uniform1f(s.opacity,o._fadingOpacity),n.uniform1f(s.planetRadius,o.renderNode._planetRadius2||0),n.uniform2fv(s.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(r.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._gliphParamBuffer),n.vertexAttribPointer(r.a_gliphParam,this._gliphParamBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(r.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(r.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(r.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(r.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(r.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(r.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._fontIndexBuffer),n.vertexAttribPointer(r.a_fontIndex,this._fontIndexBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1i(s.isOutlinePass,1),n.uniform1f(s.depthOffset,o.polygonOffsetUnits),n.bindBuffer(n.ARRAY_BUFFER,this._outlineColorBuffer),n.vertexAttribPointer(r.a_rgba,this._outlineColorBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._outlineBuffer),n.vertexAttribPointer(r.a_outline,this._outlineBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.depthFunc(n.EQUAL),n.uniform1i(s.isOutlinePass,0),n.uniform1f(s.depthOffset,o.polygonOffsetUnits),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(r.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.depthFunc(n.LESS),n.enable(n.CULL_FACE)}_pickingPASS(){let e=this._renderer,t=e.handler;t.programs.labelPicking.activate();let i=t.programs.labelPicking._program,r=i.attributes,s=i.uniforms,n=t.gl,o=this._entityCollection,l=o.renderNode;n.disable(n.CULL_FACE),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(s.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(s.eyePositionLow,e.activeCamera.eyeLow),n.uniform3fv(s.scaleByDistance,o.scaleByDistance),n.uniform1f(s.opacity,o._fadingOpacity),n.uniform1f(s.planetRadius,l._planetRadius2||0),n.uniform2fv(s.viewport,[t.canvas.clientWidth,t.canvas.clientHeight]),n.bindBuffer(n.ARRAY_BUFFER,this._texCoordBuffer),n.vertexAttribPointer(r.a_texCoord,this._texCoordBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._gliphParamBuffer),n.vertexAttribPointer(r.a_gliphParam,this._gliphParamBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(r.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionHighBuffer),n.vertexAttribPointer(r.a_positionsHigh,this._positionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._positionLowBuffer),n.vertexAttribPointer(r.a_positionsLow,this._positionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._sizeBuffer),n.vertexAttribPointer(r.a_size,this._sizeBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rotationBuffer),n.vertexAttribPointer(r.a_rotation,this._rotationBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._offsetBuffer),n.vertexAttribPointer(r.a_offset,this._offsetBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._pickingColorBuffer),n.vertexAttribPointer(r.a_rgba,this._pickingColorBuffer.itemSize,n.FLOAT,!1,0,0),n.uniform1f(s.depthOffset,o.polygonOffsetUnits),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_removeBillboard(e){let t=e._handlerIndex;this._billboards.splice(t,1);let i=24*this._maxLetters,r=t*i;this._rgbaArr=he(this._rgbaArr,r,i),this._outlineColorArr=he(this._outlineColorArr,r,i),this._texCoordArr=he(this._texCoordArr,r,i),this._gliphParamArr=he(this._gliphParamArr,r,i),i=18*this._maxLetters,r=t*i,this._positionHighArr=he(this._positionHighArr,r,i),this._positionLowArr=he(this._positionLowArr,r,i),this._offsetArr=he(this._offsetArr,r,i),this._pickingColorArr=he(this._pickingColorArr,r,i),i=12*this._maxLetters,r=t*i,this._vertexArr=he(this._vertexArr,r,i),i=6*this._maxLetters,r=t*i,this._sizeArr=he(this._sizeArr,r,i),this._rotationArr=he(this._rotationArr,r,i),this._fontIndexArr=he(this._fontIndexArr,r,i),this._outlineArr=he(this._outlineArr,r,i),this.reindexBillboardsArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null,e._isReady=!1}setText(e,t,i,r,s=0,n=!1){t=t.normalize("NFKC");let o=this._renderer.fontAtlas.atlasesArr[i];if(!o)return;let l=24*e*this._maxLetters,h=this._texCoordArr,c=this._gliphParamArr,d=0,u=Math.min(this._maxLetters,t.length),g=0;n&&(g=1);let f=0,p=o.kernings;for(d=0;d<u;d++){let _=l+24*d,v=t[d],x=o.get(v.charCodeAt(0))||o.get(32);if(!x)continue;let y=x.texCoords,w=x.metrics;h[_]=y[0],h[_+1]=y[1],h[_+2]=f,h[_+3]=g,h[_+4]=y[2],h[_+5]=y[3],h[_+6]=f,h[_+7]=g,h[_+8]=y[4],h[_+9]=y[5],h[_+10]=f,h[_+11]=g,h[_+12]=y[6],h[_+13]=y[7],h[_+14]=f,h[_+15]=g,h[_+16]=y[8],h[_+17]=y[9],h[_+18]=f,h[_+19]=g,h[_+20]=y[10],h[_+21]=y[11],h[_+22]=f,h[_+23]=g,c[_]=w.nWidth,c[_+1]=w.nHeight,c[_+2]=w.nXOffset,c[_+3]=w.nYOffset,c[_+4]=w.nWidth,c[_+5]=w.nHeight,c[_+6]=w.nXOffset,c[_+7]=w.nYOffset,c[_+8]=w.nWidth,c[_+9]=w.nHeight,c[_+10]=w.nXOffset,c[_+11]=w.nYOffset,c[_+12]=w.nWidth,c[_+13]=w.nHeight,c[_+14]=w.nXOffset,c[_+15]=w.nYOffset,c[_+16]=w.nWidth,c[_+17]=w.nHeight,c[_+18]=w.nXOffset,c[_+19]=w.nYOffset,c[_+20]=w.nWidth,c[_+21]=w.nHeight,c[_+22]=w.nXOffset,c[_+23]=w.nYOffset;let b=p[v.charCodeAt(0)];if(b&&t[d+1]){let E=b[t[d+1].charCodeAt(0)];f+=E?w.nAdvance+E+s:w.nAdvance+s}else f+=w.nAdvance+s}if(r===ti.CENTER)for(f*=-.5,d=0;d<u;d++){let _=l+24*d;h[_+2]+=f,h[_+6]+=f,h[_+10]+=f,h[_+14]+=f,h[_+18]+=f,h[_+22]+=f}for(;d<this._maxLetters;d++){let _=l+24*d;h[_+3]=-1,h[_+7]=-1,h[_+11]=-1,h[_+15]=-1,h[_+19]=-1,h[_+23]=-1}this._changedBuffers[6]=!0}setPositionArr(e,t,i){let r=18*e*this._maxLetters,s=this._positionHighArr,n=t.x,o=t.y,l=t.z,h=this._positionLowArr,c=i.x,d=i.y,u=i.z;for(let g=0;g<this._maxLetters;g++){let f=r+18*g;s[f]=n,s[f+1]=o,s[f+2]=l,s[f+3]=n,s[f+4]=o,s[f+5]=l,s[f+6]=n,s[f+7]=o,s[f+8]=l,s[f+9]=n,s[f+10]=o,s[f+11]=l,s[f+12]=n,s[f+13]=o,s[f+14]=l,s[f+15]=n,s[f+16]=o,s[f+17]=l,h[f]=c,h[f+1]=d,h[f+2]=u,h[f+3]=c,h[f+4]=d,h[f+5]=u,h[f+6]=c,h[f+7]=d,h[f+8]=u,h[f+9]=c,h[f+10]=d,h[f+11]=u,h[f+12]=c,h[f+13]=d,h[f+14]=u,h[f+15]=c,h[f+16]=d,h[f+17]=u}this._changedBuffers[1]=!0}setPickingColorArr(e,t){let i=18*e*this._maxLetters,r=this._pickingColorArr,s=t.x/255,n=t.y/255,o=t.z/255;for(let l=0;l<this._maxLetters;l++){let h=i+18*l;r[h]=s,r[h+1]=n,r[h+2]=o,r[h+3]=s,r[h+4]=n,r[h+5]=o,r[h+6]=s,r[h+7]=n,r[h+8]=o,r[h+9]=s,r[h+10]=n,r[h+11]=o,r[h+12]=s,r[h+13]=n,r[h+14]=o,r[h+15]=s,r[h+16]=n,r[h+17]=o}this._changedBuffers[0]=!0}setSizeArr(e,t){let i=6*e*this._maxLetters,r=this._sizeArr;for(let s=0;s<this._maxLetters;s++){let n=i+6*s;r[n]=t,r[n+1]=t,r[n+2]=t,r[n+3]=t,r[n+4]=t,r[n+5]=t}this._changedBuffers[2]=!0}setOffsetArr(e,t){let i=18*e*this._maxLetters,r=this._offsetArr,s=t.x,n=t.y,o=t.z;for(let l=0;l<this._maxLetters;l++){let h=i+18*l;r[h]=s,r[h+1]=n,r[h+2]=o,r[h+3]=s,r[h+4]=n,r[h+5]=o,r[h+6]=s,r[h+7]=n,r[h+8]=o,r[h+9]=s,r[h+10]=n,r[h+11]=o,r[h+12]=s,r[h+13]=n,r[h+14]=o,r[h+15]=s,r[h+16]=n,r[h+17]=o}this._changedBuffers[3]=!0}setRgbaArr(e,t){let i=24*e*this._maxLetters,r=this._rgbaArr,s=t.x,n=t.y,o=t.z,l=t.w;for(let h=0;h<this._maxLetters;h++){let c=i+24*h;r[c]=s,r[c+1]=n,r[c+2]=o,r[c+3]=l,r[c+4]=s,r[c+5]=n,r[c+6]=o,r[c+7]=l,r[c+8]=s,r[c+9]=n,r[c+10]=o,r[c+11]=l,r[c+12]=s,r[c+13]=n,r[c+14]=o,r[c+15]=l,r[c+16]=s,r[c+17]=n,r[c+18]=o,r[c+19]=l,r[c+20]=s,r[c+21]=n,r[c+22]=o,r[c+23]=l}this._changedBuffers[4]=!0}setOutlineColorArr(e,t){let i=24*e*this._maxLetters,r=this._outlineColorArr,s=t.x,n=t.y,o=t.z,l=t.w;for(let h=0;h<this._maxLetters;h++){let c=i+24*h;r[c]=s,r[c+1]=n,r[c+2]=o,r[c+3]=l,r[c+4]=s,r[c+5]=n,r[c+6]=o,r[c+7]=l,r[c+8]=s,r[c+9]=n,r[c+10]=o,r[c+11]=l,r[c+12]=s,r[c+13]=n,r[c+14]=o,r[c+15]=l,r[c+16]=s,r[c+17]=n,r[c+18]=o,r[c+19]=l,r[c+20]=s,r[c+21]=n,r[c+22]=o,r[c+23]=l}this._changedBuffers[10]=!0}setOutlineArr(e,t){let i=6*e*this._maxLetters,r=this._outlineArr;for(let s=0;s<this._maxLetters;s++){let n=i+6*s;r[n]=t,r[n+1]=t,r[n+2]=t,r[n+3]=t,r[n+4]=t,r[n+5]=t}this._changedBuffers[9]=!0}setRotationArr(e,t){let i=6*e*this._maxLetters,r=this._rotationArr;for(let s=0;s<this._maxLetters;s++){let n=i+6*s;r[n]=t,r[n+1]=t,r[n+2]=t,r[n+3]=t,r[n+4]=t,r[n+5]=t}this._changedBuffers[5]=!0}setVisibility(e,t){let i;i=t?[0,0,0,-1,1,-1,1,-1,1,0,0,0]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e*this._maxLetters,r=this._vertexArr;for(let s=0;s<this._maxLetters;s++){let n=i+12*s;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2],r[n+3]=t[3],r[n+4]=t[4],r[n+5]=t[5],r[n+6]=t[6],r[n+7]=t[7],r[n+8]=t[8],r[n+9]=t[9],r[n+10]=t[10],r[n+11]=t[11]}this._changedBuffers[7]=!0}setFontIndexArr(e,t){let i=6*e*this._maxLetters,r=this._fontIndexArr;for(let s=0;s<this._maxLetters;s++){let n=i+6*s;r[n]=t,r[n+1]=t,r[n+2]=t,r[n+3]=t,r[n+4]=t,r[n+5]=t}this._changedBuffers[8]=!0}createSizeBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._sizeBuffer),this._sizeBuffer=e.createArrayBuffer(this._sizeArr,1,this._sizeArr.length)}createFontIndexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._fontIndexBuffer),this._fontIndexBuffer=e.createArrayBuffer(this._fontIndexArr,1,this._fontIndexArr.length)}createTexCoordBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._texCoordBuffer),this._texCoordBuffer=e.createArrayBuffer(this._texCoordArr,4,this._texCoordArr.length/4),e.gl.deleteBuffer(this._gliphParamBuffer),this._gliphParamBuffer=e.createArrayBuffer(this._gliphParamArr,4,this._gliphParamArr.length/4)}createOutlineBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._outlineBuffer),this._outlineBuffer=e.createArrayBuffer(this._outlineArr,1,this._outlineArr.length)}createOutlineColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._outlineColorBuffer),this._outlineColorBuffer=e.createArrayBuffer(this._outlineColorArr,4,this._outlineColorArr.length/4)}setMaxLetters(e){this._maxLetters=e}}const Vn=class Uo{constructor(e){this.pickingEnabled=!0,this.__id=Uo.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._pointClouds=[]}_initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.pointCloud||this._renderer.handler.addProgram(new X("pointCloud",{uniforms:{projectionViewMatrix:"mat4",opacity:"float",pointSize:"float"},attributes:{coordinates:"vec3",colors:"vec3"},vertexShader:`attribute vec3 coordinates;
112
112
  attribute vec4 colors;
113
113
  uniform mat4 projectionViewMatrix;
114
114
  uniform float opacity;
@@ -123,7 +123,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
123
123
  varying vec4 color;
124
124
  void main(void) {
125
125
  gl_FragColor = color;
126
- }`})))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._pointClouds.length;t++)this._pointClouds[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._pointClouds.length,this._pointClouds.push(e),this._entityCollection&&this._entityCollection.renderNode&&e.setRenderNode(this._entityCollection.renderNode))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._pointClouds.splice(t,1),this._reindexPointCloudArray(t))}_reindexPointCloudArray(e){let t=this._pointClouds;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e].drawPicking()}}clear(){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e]._deleteBuffers(),this._pointClouds[e]._handler=null,this._pointClouds[e]._handlerIndex=-1;this._pointClouds.length=0,this._pointClouds=[]}};Hn.__counter__=0;let Rl=Hn;const Vn=class Ua{constructor(e){this.__id=Ua.__counter__++,this._entityCollection=e,this._renderer=null,this._polylines=[],this.pickingEnabled=!0,this._relativeCenter=new v,this._rtcEyePositionHigh=new Float32Array([0,0,0]),this._rtcEyePositionLow=new Float32Array([0,0,0])}_initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.polyline_screen||this._renderer.handler.addProgram(new X("polyline_screen",{uniforms:{viewport:"vec2",proj:"mat4",view:"mat4",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",thickness:"float",opacity:"float",depthOffset:"float",visibleSphere:"vec4"},attributes:{prevHigh:"vec3",currentHigh:"vec3",nextHigh:"vec3",prevLow:"vec3",currentLow:"vec3",nextLow:"vec3",order:"float",color:"vec4"},vertexShader:"precision highp float;attribute vec3 prevHigh;attribute vec3 currentHigh;attribute vec3 nextHigh;attribute vec3 prevLow;attribute vec3 currentLow;attribute vec3 nextLow;attribute float order;attribute vec4 color;uniform float thickness;uniform mat4 proj;uniform mat4 view;uniform vec2 viewport;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform float opacity;uniform float depthOffset;varying vec4 vColor;varying vec3 vPos;varying vec3 uCamPos;const float NEAR=-1.0;vec2 getIntersection(vec2 start1,vec2 end1,vec2 start2,vec2 end2){vec2 dir=end2-start2;vec2 perp=vec2(-dir.y,dir.x);float d2=dot(perp,start2);float seg=dot(perp,start1)-d2;float prl=seg-dot(perp,end1)+d2;if(prl>-1.0&&prl<1.0){return start1;}float u=seg/prl;return start1+u*(end1-start1);}vec2 project(vec4 p){return(0.5*p.xyz/p.w+0.5).xy*viewport;}void main(){uCamPos=rtcEyePositionHigh+rtcEyePositionLow;vPos=currentHigh+currentLow;vColor=vec4(color.rgb,color.a*opacity);mat4 viewMatrixRTE=view;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff,lowDiff;highDiff=currentHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=currentLow-rtcEyePositionLow;vec4 vCurrent=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=prevHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=prevLow-rtcEyePositionLow;vec4 vPrev=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=nextHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=nextLow-rtcEyePositionLow;vec4 vNext=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);if(vCurrent.z>NEAR){if(vPrev.z<NEAR&&abs(order)==1.0){vCurrent=vPrev+(vCurrent-vPrev)*(NEAR-vPrev.z)/(vCurrent.z-vPrev.z);}else if(vNext.z<NEAR&&abs(order)==2.0){vCurrent=vNext+(vCurrent-vNext)*(NEAR-vNext.z)/(vCurrent.z-vNext.z);}}vec4 dCurrent=proj*vCurrent;vec2 _next=project(proj*vNext);vec2 _prev=project(proj*vPrev);vec2 _current=project(dCurrent);if(_prev==_current){if(_next==_current){_next=_current+vec2(1.0,0.0);_prev=_current-_next;}else{_prev=_current+normalize(_current-_next);}}if(_next==_current){_next=_current+normalize(_current-_prev);}vec2 sNext=_next,sCurrent=_current,sPrev=_prev;vec2 dirNext=normalize(sNext-sCurrent);vec2 dirPrev=normalize(sPrev-sCurrent);float dotNP=dot(dirNext,dirPrev);vec2 normalNext=normalize(vec2(-dirNext.y,dirNext.x));vec2 normalPrev=normalize(vec2(dirPrev.y,-dirPrev.x));float d=thickness*sign(order);vec2 m;if(dotNP>=0.99991){m=sCurrent-normalPrev*d;}else{m=getIntersection(sCurrent+normalPrev*d,sPrev+normalPrev*d,sCurrent+normalNext*d,sNext+normalNext*d);if(dotNP>0.5&&dot(dirNext+dirPrev,m-sCurrent)<0.0){float occw=order*sign(dirNext.x*dirPrev.y-dirNext.y*dirPrev.x);if(occw==-1.0){m=sCurrent+normalPrev*d;}else if(occw==1.0){m=sCurrent+normalNext*d;}else if(occw==-2.0){m=sCurrent+normalNext*d;}else if(occw==2.0){m=sCurrent+normalPrev*d;}}else if(distance(sCurrent,m)>min(distance(sCurrent,sNext),distance(sCurrent,sPrev))){m=sCurrent+normalNext*d;}}gl_Position=vec4((2.0*m/viewport-1.0)*dCurrent.w,dCurrent.z+depthOffset,dCurrent.w);}",fragmentShader:"precision highp float;uniform vec4 visibleSphere;varying vec3 uCamPos;varying vec4 vColor;varying vec3 vPos;void main(){if(visibleSphere.w!=0.0){vec3 cam_dir=normalize(vPos-uCamPos);vec3 sph_dir=normalize(vPos-visibleSphere.xyz);if(dot(cam_dir,sph_dir)>0.11){discard;}}gl_FragColor=vec4(vColor.rgb,vColor.a);}"})),this._renderer.handler.programs.polyline_picking||this._renderer.handler.addProgram(new X("polyline_picking",{uniforms:{viewport:"vec2",proj:"mat4",view:"mat4",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",color:"vec4",thickness:"float",depthOffset:"float",visibleSphere:"vec4"},attributes:{prevHigh:"vec3",currentHigh:"vec3",nextHigh:"vec3",prevLow:"vec3",currentLow:"vec3",nextLow:"vec3",order:"float"},vertexShader:"precision highp float;attribute vec3 prevHigh;attribute vec3 currentHigh;attribute vec3 nextHigh;attribute vec3 prevLow;attribute vec3 currentLow;attribute vec3 nextLow;attribute float order;uniform float thickness;uniform vec4 color;uniform mat4 proj;uniform mat4 view;uniform vec2 viewport;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform float depthOffset;varying vec4 vColor;varying vec3 vPos;varying vec3 uCamPos;const float NEAR=-1.0;vec2 getIntersection(vec2 start1,vec2 end1,vec2 start2,vec2 end2){vec2 dir=end2-start2;vec2 perp=vec2(-dir.y,dir.x);float d2=dot(perp,start2);float seg=dot(perp,start1)-d2;float prl=seg-dot(perp,end1)+d2;if(prl>-1.0&&prl<1.0){return start1;}float u=seg/prl;return start1+u*(end1-start1);}vec2 project(vec4 p){return(0.5*p.xyz/p.w+0.5).xy*viewport;}void main(){uCamPos=rtcEyePositionHigh+rtcEyePositionLow;vPos=currentHigh+currentLow;vColor=color;vec3 highDiff,lowDiff;mat4 viewMatrixRTE=view;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);highDiff=currentHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=currentLow-rtcEyePositionLow;vec4 vCurrent=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=prevHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=prevLow-rtcEyePositionLow;vec4 vPrev=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=nextHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=nextLow-rtcEyePositionLow;vec4 vNext=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);if(vCurrent.z>NEAR){if(vPrev.z<NEAR&&abs(order)==1.0){vCurrent=vPrev+(vCurrent-vPrev)*(NEAR-vPrev.z)/(vCurrent.z-vPrev.z);}else if(vNext.z<NEAR&&abs(order)==2.0){vCurrent=vNext+(vCurrent-vNext)*(NEAR-vNext.z)/(vCurrent.z-vNext.z);}}vec4 dCurrent=proj*vCurrent;vec2 _next=project(proj*vNext);vec2 _prev=project(proj*vPrev);vec2 _current=project(dCurrent);if(_prev==_current){if(_next==_current){_next=_current+vec2(1.0,0.0);_prev=_current-_next;}else{_prev=_current+normalize(_current-_next);}}if(_next==_current){_next=_current+normalize(_current-_prev);}vec2 sNext=_next,sCurrent=_current,sPrev=_prev;vec2 dirNext=normalize(sNext-sCurrent);vec2 dirPrev=normalize(sPrev-sCurrent);float dotNP=dot(dirNext,dirPrev);vec2 normalNext=normalize(vec2(-dirNext.y,dirNext.x));vec2 normalPrev=normalize(vec2(dirPrev.y,-dirPrev.x));float d=thickness*sign(order);vec2 m;if(dotNP>=0.99991){m=sCurrent-normalPrev*d;}else{m=getIntersection(sCurrent+normalPrev*d,sPrev+normalPrev*d,sCurrent+normalNext*d,sNext+normalNext*d);if(dotNP>0.5&&dot(dirNext+dirPrev,m-sCurrent)<0.0){float occw=order*sign(dirNext.x*dirPrev.y-dirNext.y*dirPrev.x);if(occw==-1.0){m=sCurrent+normalPrev*d;}else if(occw==1.0){m=sCurrent+normalNext*d;}else if(occw==-2.0){m=sCurrent+normalNext*d;}else if(occw==2.0){m=sCurrent+normalPrev*d;}}else if(distance(sCurrent,m)>min(distance(sCurrent,sNext),distance(sCurrent,sPrev))){m=sCurrent+normalNext*d;}}gl_Position=vec4((2.0*m/viewport-1.0)*dCurrent.w,dCurrent.z+depthOffset,dCurrent.w);}",fragmentShader:"precision highp float;uniform vec4 visibleSphere;varying vec3 uCamPos;varying vec4 vColor;varying vec3 vPos;void main(){if(visibleSphere.w!=0.0){vec3 cam_dir=normalize(vPos-uCamPos);vec3 sph_dir=normalize(vPos-visibleSphere.xyz);if(dot(cam_dir,sph_dir)>0.11){discard;}}gl_FragColor=vec4(vColor.rgb,vColor.a);}"})))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._polylines.length;t++)this._polylines[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._polylines.length,e.__doubleToTwoFloats=this.getRTCPosition.bind(this),this._polylines.push(e),this._entityCollection&&this._entityCollection.renderNode&&(e.setRenderNode(this._entityCollection.renderNode),e.updateRTCPosition()))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._polylines.splice(t,1),this.reindexPolylineArray(t))}reindexPolylineArray(e){let t=this._polylines;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){this._updateRTCEyePosition();let e=this._polylines.length;for(;e--;)this._polylines[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._polylines.length;for(;e--;)this._polylines[e].drawPicking()}}clear(){let e=this._polylines.length;for(;e--;)this._polylines[e]._deleteBuffers(),this._polylines[e]._handler=null,this._polylines[e]._handlerIndex=-1;this._polylines.length=0,this._polylines=[]}getRTCPosition(e,t,i){let s=e.sub(this._relativeCenter);v.doubleToTwoFloats(s,t,i)}setRelativeCenter(e){this._relativeCenter.copy(e);for(let t=0;t<this._polylines.length;t++)this._polylines[t].updateRTCPosition()}_updateRTCEyePosition(){let e=this._renderer;if(e.activeCamera.isFirstPass){let t=e.activeCamera.eye.sub(this._relativeCenter);v.doubleToTwoFloat32Array(t,this._rtcEyePositionHigh,this._rtcEyePositionLow)}}};Vn.__counter__=0;let Bl=Vn;const Un=class Ga{constructor(e){this.__id=Ga.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._rays=[],this._vertexBuffer=null,this._startPositionHighBuffer=null,this._startPositionLowBuffer=null,this._endPositionHighBuffer=null,this._endPositionLowBuffer=null,this._thicknessBuffer=null,this._rgbaBuffer=null,this._pickingColorBuffer=null,this._vertexArr=[],this._startPositionHighArr=[],this._startPositionLowArr=[],this._endPositionHighArr=[],this._endPositionLowArr=[],this._thicknessArr=[],this._rgbaArr=[],this._pickingColorArr=[],this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[5]=this.createVertexBuffer,this._buffersUpdateCallbacks[1]=this.createStartPositionBuffer,this._buffersUpdateCallbacks[2]=this.createEndPositionBuffer,this._buffersUpdateCallbacks[4]=this.createThicknessBuffer,this._buffersUpdateCallbacks[3]=this.createRgbaBuffer,this._buffersUpdateCallbacks[0]=this.createPickingColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}static concArr(e,t){for(let i=0;i<t.length;i++)e.push(t[i])}initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.rayScreen||this._renderer.handler.addProgram(new X("rayScreen",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",resolution:"float",uOpacity:"float"},attributes:{a_vertices:"vec2",a_startPosHigh:"vec3",a_startPosLow:"vec3",a_endPosHigh:"vec3",a_endPosLow:"vec3",a_thickness:"float",a_rgba:"vec4"},vertexShader:"precision highp float;attribute vec4 a_rgba;attribute vec3 a_startPosHigh;attribute vec3 a_startPosLow;attribute vec3 a_endPosHigh;attribute vec3 a_endPosLow;attribute vec2 a_vertices;attribute float a_thickness;varying vec4 v_rgba;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float resolution;uniform float uOpacity;void main(){v_rgba=vec4(a_rgba.rgb,a_rgba.a*uOpacity);vec3 v=(a_endPosHigh-a_startPosHigh)+(a_endPosLow-a_startPosLow);vec3 look=(a_startPosHigh-eyePositionHigh)+(a_startPosLow-eyePositionLow)+v*a_vertices.y;vec3 up=normalize(normalize(v));vec3 right=normalize(cross(look,up));float dist=dot(look,vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]));float focalSize=2.0*dist*resolution;vec3 vert=right*a_thickness*focalSize*a_vertices.x;vec3 highDiff;if(a_vertices.y==0.0){highDiff=a_startPosHigh-eyePositionHigh;vert+=a_startPosLow-eyePositionLow;}else{highDiff=a_endPosHigh-eyePositionHigh;vert+=a_endPosLow-eyePositionLow;}mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+vert,1.0);}",fragmentShader:"precision highp float;varying vec4 v_rgba;void main(){gl_FragColor=v_rgba;}"})))}setRenderer(e){this._renderer=e,this.initProgram()}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_removeRays(){let e=this._rays.length;for(;e--;){let t=this._rays[e];t._handlerIndex=-1,t._handler=null}this._rays.length=0,this._rays=[]}clear(){this._vertexArr=null,this._startPositionHighArr=null,this._startPositionLowArr=null,this._endPositionHighArr=null,this._endPositionLowArr=null,this._thicknessArr=null,this._rgbaArr=null,this._vertexArr=new Float32Array([]),this._startPositionHighArr=new Float32Array([]),this._startPositionLowArr=new Float32Array([]),this._endPositionHighArr=new Float32Array([]),this._endPositionLowArr=new Float32Array([]),this._thicknessArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._removeRays(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e&&(e.deleteBuffer(this._startPositionHighBuffer),e.deleteBuffer(this._startPositionLowBuffer),e.deleteBuffer(this._endPositionHighBuffer),e.deleteBuffer(this._endPositionLowBuffer),e.deleteBuffer(this._thicknessBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._vertexBuffer)),this._startPositionHighBuffer=null,this._startPositionLowBuffer=null,this._endPositionHighBuffer=null,this._endPositionLowBuffer=null,this._thicknessBuffer=null,this._rgbaBuffer=null,this._vertexBuffer=null}}update(){if(this._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}add(e){e._handlerIndex==-1&&(e._handler=this,e._handlerIndex=this._rays.length,this._rays.push(e),this._addRayToArrays(e),this.refresh())}_addRayToArrays(e){e.getVisibility()?this._vertexArr=xe(this._vertexArr,[-.5,1,-.5,0,.5,0,.5,0,.5,1,-.5,1]):this._vertexArr=xe(this._vertexArr,[0,0,0,0,0,0,0,0,0,0,0,0]);let t=e._startPositionHigh.x,i=e._startPositionHigh.y,s=e._startPositionHigh.z;this._startPositionHighArr=xe(this._startPositionHighArr,[t,i,s,t,i,s,t,i,s,t,i,s,t,i,s,t,i,s]),t=e._startPositionLow.x,i=e._startPositionLow.y,s=e._startPositionLow.z,this._startPositionLowArr=xe(this._startPositionLowArr,[t,i,s,t,i,s,t,i,s,t,i,s,t,i,s,t,i,s]),t=e._endPositionHigh.x,i=e._endPositionHigh.y,s=e._endPositionHigh.z,this._endPositionHighArr=xe(this._endPositionHighArr,[t,i,s,t,i,s,t,i,s,t,i,s,t,i,s,t,i,s]),t=e._endPositionLow.x,i=e._endPositionLow.y,s=e._endPositionLow.z,this._endPositionLowArr=xe(this._endPositionLowArr,[t,i,s,t,i,s,t,i,s,t,i,s,t,i,s,t,i,s]),t=e._thickness,this._thicknessArr=xe(this._thicknessArr,[t,t,t,t,t,t]);let r=e._startColor.x,n=e._startColor.y,o=e._startColor.z,l=e._startColor.w,h=e._endColor.x,c=e._endColor.y,d=e._endColor.z,u=e._endColor.w;this._rgbaArr=xe(this._rgbaArr,[h,c,d,u,r,n,o,l,r,n,o,l,r,n,o,l,h,c,d,u,h,c,d,u]),t=e._entity._pickingColor.x/255,i=e._entity._pickingColor.y/255,s=e._entity._pickingColor.z/255,this._pickingColorArr=xe(this._pickingColorArr,[t,i,s,t,i,s,t,i,s,t,i,s,t,i,s,t,i,s])}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.rayScreen.activate();let i=t.programs.rayScreen._program,s=i.attributes,r=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(r.uOpacity,o._fadingOpacity),n.uniformMatrix4fv(r.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(r.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(r.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(r.eyePositionLow,e.activeCamera.eyeLow),n.uniform1f(r.resolution,e.activeCamera._tanViewAngle_hradOneByHeight),n.bindBuffer(n.ARRAY_BUFFER,this._startPositionHighBuffer),n.vertexAttribPointer(s.a_startPosHigh,this._startPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._startPositionLowBuffer),n.vertexAttribPointer(s.a_startPosLow,this._startPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._endPositionHighBuffer),n.vertexAttribPointer(s.a_endPosHigh,this._endPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._endPositionLowBuffer),n.vertexAttribPointer(s.a_endPosLow,this._endPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(s.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._thicknessBuffer),n.vertexAttribPointer(s.a_thickness,this._thicknessBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(s.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_pickingPASS(){}draw(){this._rays.length&&(this.update(),this._displayPASS())}drawPicking(){this._rays.length&&this.pickingEnabled&&this._pickingPASS()}reindexRaysArray(e){let t=this._rays;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}_removeRay(e){let t=e._handlerIndex;this._rays.splice(t,1);let i=24*t;this._rgbaArr=Ae(this._rgbaArr,i,24),i=18*t,this._startPositionHighArr=Ae(this._startPositionHighArr,i,18),this._startPositionLowArr=Ae(this._startPositionLowArr,i,18),this._endPositionHighArr=Ae(this._endPositionHighArr,i,18),this._endPositionLowArr=Ae(this._endPositionLowArr,i,18),this._pickingColorArr=Ae(this._pickingColorArr,i,18),i=12*t,this._vertexArr=Ae(this._vertexArr,i,12),i=6*t,this._thicknessArr=Ae(this._thicknessArr,i,6),this.reindexRaysArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null}remove(e){e._handler&&this.__id===e._handler.__id&&this._removeRay(e)}setStartPositionArr(e,t,i){let s=18*e,r=this._startPositionHighArr,n=t.x,o=t.y,l=t.z;r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,r=this._startPositionLowArr,n=i.x,o=i.y,l=i.z,r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,this._changedBuffers[1]=!0}setEndPositionArr(e,t,i){let s=18*e,r=this._endPositionHighArr,n=t.x,o=t.y,l=t.z;r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,r=this._endPositionLowArr,n=i.x,o=i.y,l=i.z,r[s]=n,r[s+1]=o,r[s+2]=l,r[s+3]=n,r[s+4]=o,r[s+5]=l,r[s+6]=n,r[s+7]=o,r[s+8]=l,r[s+9]=n,r[s+10]=o,r[s+11]=l,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=n,r[s+16]=o,r[s+17]=l,this._changedBuffers[2]=!0}setPickingColorArr(e,t){let i=18*e,s=this._pickingColorArr,r=t.x/255,n=t.y/255,o=t.z/255;s[i]=r,s[i+1]=n,s[i+2]=o,s[i+3]=r,s[i+4]=n,s[i+5]=o,s[i+6]=r,s[i+7]=n,s[i+8]=o,s[i+9]=r,s[i+10]=n,s[i+11]=o,s[i+12]=r,s[i+13]=n,s[i+14]=o,s[i+15]=r,s[i+16]=n,s[i+17]=o,this._changedBuffers[0]=!0}setRgbaArr(e,t,i){let s=24*e,r=this._rgbaArr,n=t.x,o=t.y,l=t.z,h=t.w,c=i.x,d=i.y,u=i.z,g=i.w;r[s]=c,r[s+1]=d,r[s+2]=u,r[s+3]=g,r[s+4]=n,r[s+5]=o,r[s+6]=l,r[s+7]=h,r[s+8]=n,r[s+9]=o,r[s+10]=l,r[s+11]=h,r[s+12]=n,r[s+13]=o,r[s+14]=l,r[s+15]=h,r[s+16]=c,r[s+17]=d,r[s+18]=u,r[s+19]=g,r[s+20]=c,r[s+21]=d,r[s+22]=u,r[s+23]=g,this._changedBuffers[3]=!0}setThicknessArr(e,t){let i=6*e,s=this._thicknessArr;s[i]=t,s[i+1]=t,s[i+2]=t,s[i+3]=t,s[i+4]=t,s[i+5]=t,this._changedBuffers[4]=!0}setVisibility(e,t){let i;i=t?[-.5,1,-.5,0,.5,0,.5,0,.5,1,-.5,1]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e,s=this._vertexArr;s[i]=t[0],s[i+1]=t[1],s[i+2]=t[2],s[i+3]=t[3],s[i+4]=t[4],s[i+5]=t[5],s[i+6]=t[6],s[i+7]=t[7],s[i+8]=t[8],s[i+9]=t[9],s[i+10]=t[10],s[i+11]=t[11],this._changedBuffers[5]=!0}createStartPositionBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._startPositionHighBuffer),this._startPositionHighArr=se(this._startPositionHighArr),this._startPositionHighBuffer=e.createArrayBuffer(this._startPositionHighArr,3,this._startPositionHighArr.length/3,e.gl.DYNAMIC_DRAW),e.gl.deleteBuffer(this._startPositionLowBuffer),this._startPositionLowArr=se(this._startPositionLowArr),this._startPositionLowBuffer=e.createArrayBuffer(this._startPositionLowArr,3,this._startPositionLowArr.length/3,e.gl.DYNAMIC_DRAW)}createEndPositionBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._endPositionHighBuffer),this._endPositionHighArr=se(this._endPositionHighArr),this._endPositionHighBuffer=e.createArrayBuffer(this._endPositionHighArr,3,this._endPositionHighArr.length/3,e.gl.DYNAMIC_DRAW),e.gl.deleteBuffer(this._endPositionLowBuffer),this._endPositionLowArr=se(this._endPositionLowArr),this._endPositionLowBuffer=e.createArrayBuffer(this._endPositionLowArr,3,this._endPositionLowArr.length/3,e.gl.DYNAMIC_DRAW)}createRgbaBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaArr=se(this._rgbaArr),this._rgbaBuffer=e.createArrayBuffer(this._rgbaArr,4,this._rgbaArr.length/4)}createThicknessBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._thicknessBuffer),this._thicknessArr=se(this._thicknessArr),this._thicknessBuffer=e.createArrayBuffer(this._thicknessArr,1,this._thicknessArr.length,e.gl.DYNAMIC_DRAW)}createVertexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexArr=se(this._vertexArr),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,2,this._vertexArr.length/2,e.gl.DYNAMIC_DRAW)}createPickingColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorArr=se(this._pickingColorArr),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}};Un.__counter__=0;let kl=Un;const Gn=class ja{constructor(e){this.__id=ja.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._strips=[]}_initProgram(){this._renderer&&this._renderer.handler&&!this._renderer.handler.programs.strip&&this._renderer.handler.addProgram(new X("strip",{uniforms:{projectionMatrix:{type:"mat4"},viewMatrix:{type:"mat4"},eyePositionHigh:"vec3",eyePositionLow:"vec3",uColor:{type:"vec4"},uOpacity:{type:"float"}},attributes:{aVertexPositionHigh:{type:"vec3"},aVertexPositionLow:{type:"vec3"}},vertexShader:`attribute vec3 aVertexPositionHigh;
126
+ }`})))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._pointClouds.length;t++)this._pointClouds[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._pointClouds.length,this._pointClouds.push(e),this._entityCollection&&this._entityCollection.renderNode&&e.setRenderNode(this._entityCollection.renderNode))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._pointClouds.splice(t,1),this._reindexPointCloudArray(t))}_reindexPointCloudArray(e){let t=this._pointClouds;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e].drawPicking()}}clear(){let e=this._pointClouds.length;for(;e--;)this._pointClouds[e]._deleteBuffers(),this._pointClouds[e]._handler=null,this._pointClouds[e]._handlerIndex=-1;this._pointClouds.length=0,this._pointClouds=[]}};Vn.__counter__=0;let Rl=Vn;const Un=class Go{constructor(e){this.__id=Go.__counter__++,this._entityCollection=e,this._renderer=null,this._polylines=[],this.pickingEnabled=!0,this._relativeCenter=new m,this._rtcEyePositionHigh=new Float32Array([0,0,0]),this._rtcEyePositionLow=new Float32Array([0,0,0])}_initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.polyline_screen||this._renderer.handler.addProgram(new X("polyline_screen",{uniforms:{viewport:"vec2",proj:"mat4",view:"mat4",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",thickness:"float",opacity:"float",depthOffset:"float",visibleSphere:"vec4"},attributes:{prevHigh:"vec3",currentHigh:"vec3",nextHigh:"vec3",prevLow:"vec3",currentLow:"vec3",nextLow:"vec3",order:"float",color:"vec4"},vertexShader:"precision highp float;attribute vec3 prevHigh;attribute vec3 currentHigh;attribute vec3 nextHigh;attribute vec3 prevLow;attribute vec3 currentLow;attribute vec3 nextLow;attribute float order;attribute vec4 color;uniform float thickness;uniform mat4 proj;uniform mat4 view;uniform vec2 viewport;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform float opacity;uniform float depthOffset;varying vec4 vColor;varying vec3 vPos;varying vec3 uCamPos;const float NEAR=-1.0;vec2 getIntersection(vec2 start1,vec2 end1,vec2 start2,vec2 end2){vec2 dir=end2-start2;vec2 perp=vec2(-dir.y,dir.x);float d2=dot(perp,start2);float seg=dot(perp,start1)-d2;float prl=seg-dot(perp,end1)+d2;if(prl>-1.0&&prl<1.0){return start1;}float u=seg/prl;return start1+u*(end1-start1);}vec2 project(vec4 p){return(0.5*p.xyz/p.w+0.5).xy*viewport;}void main(){uCamPos=rtcEyePositionHigh+rtcEyePositionLow;vPos=currentHigh+currentLow;vColor=vec4(color.rgb,color.a*opacity);mat4 viewMatrixRTE=view;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);vec3 highDiff,lowDiff;highDiff=currentHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=currentLow-rtcEyePositionLow;vec4 vCurrent=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=prevHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=prevLow-rtcEyePositionLow;vec4 vPrev=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=nextHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=nextLow-rtcEyePositionLow;vec4 vNext=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);if(vCurrent.z>NEAR){if(vPrev.z<NEAR&&abs(order)==1.0){vCurrent=vPrev+(vCurrent-vPrev)*(NEAR-vPrev.z)/(vCurrent.z-vPrev.z);}else if(vNext.z<NEAR&&abs(order)==2.0){vCurrent=vNext+(vCurrent-vNext)*(NEAR-vNext.z)/(vCurrent.z-vNext.z);}}vec4 dCurrent=proj*vCurrent;vec2 _next=project(proj*vNext);vec2 _prev=project(proj*vPrev);vec2 _current=project(dCurrent);if(_prev==_current){if(_next==_current){_next=_current+vec2(1.0,0.0);_prev=_current-_next;}else{_prev=_current+normalize(_current-_next);}}if(_next==_current){_next=_current+normalize(_current-_prev);}vec2 sNext=_next,sCurrent=_current,sPrev=_prev;vec2 dirNext=normalize(sNext-sCurrent);vec2 dirPrev=normalize(sPrev-sCurrent);float dotNP=dot(dirNext,dirPrev);vec2 normalNext=normalize(vec2(-dirNext.y,dirNext.x));vec2 normalPrev=normalize(vec2(dirPrev.y,-dirPrev.x));float d=thickness*sign(order);vec2 m;if(dotNP>=0.99991){m=sCurrent-normalPrev*d;}else{m=getIntersection(sCurrent+normalPrev*d,sPrev+normalPrev*d,sCurrent+normalNext*d,sNext+normalNext*d);if(dotNP>0.5&&dot(dirNext+dirPrev,m-sCurrent)<0.0){float occw=order*sign(dirNext.x*dirPrev.y-dirNext.y*dirPrev.x);if(occw==-1.0){m=sCurrent+normalPrev*d;}else if(occw==1.0){m=sCurrent+normalNext*d;}else if(occw==-2.0){m=sCurrent+normalNext*d;}else if(occw==2.0){m=sCurrent+normalPrev*d;}}else if(distance(sCurrent,m)>min(distance(sCurrent,sNext),distance(sCurrent,sPrev))){m=sCurrent+normalNext*d;}}gl_Position=vec4((2.0*m/viewport-1.0)*dCurrent.w,dCurrent.z+depthOffset,dCurrent.w);}",fragmentShader:"precision highp float;uniform vec4 visibleSphere;varying vec3 uCamPos;varying vec4 vColor;varying vec3 vPos;void main(){if(visibleSphere.w!=0.0){vec3 cam_dir=normalize(vPos-uCamPos);vec3 sph_dir=normalize(vPos-visibleSphere.xyz);if(dot(cam_dir,sph_dir)>0.11){discard;}}gl_FragColor=vec4(vColor.rgb,vColor.a);}"})),this._renderer.handler.programs.polyline_picking||this._renderer.handler.addProgram(new X("polyline_picking",{uniforms:{viewport:"vec2",proj:"mat4",view:"mat4",rtcEyePositionHigh:"vec3",rtcEyePositionLow:"vec3",color:"vec4",thickness:"float",depthOffset:"float",visibleSphere:"vec4"},attributes:{prevHigh:"vec3",currentHigh:"vec3",nextHigh:"vec3",prevLow:"vec3",currentLow:"vec3",nextLow:"vec3",order:"float"},vertexShader:"precision highp float;attribute vec3 prevHigh;attribute vec3 currentHigh;attribute vec3 nextHigh;attribute vec3 prevLow;attribute vec3 currentLow;attribute vec3 nextLow;attribute float order;uniform float thickness;uniform vec4 color;uniform mat4 proj;uniform mat4 view;uniform vec2 viewport;uniform vec3 rtcEyePositionHigh;uniform vec3 rtcEyePositionLow;uniform float depthOffset;varying vec4 vColor;varying vec3 vPos;varying vec3 uCamPos;const float NEAR=-1.0;vec2 getIntersection(vec2 start1,vec2 end1,vec2 start2,vec2 end2){vec2 dir=end2-start2;vec2 perp=vec2(-dir.y,dir.x);float d2=dot(perp,start2);float seg=dot(perp,start1)-d2;float prl=seg-dot(perp,end1)+d2;if(prl>-1.0&&prl<1.0){return start1;}float u=seg/prl;return start1+u*(end1-start1);}vec2 project(vec4 p){return(0.5*p.xyz/p.w+0.5).xy*viewport;}void main(){uCamPos=rtcEyePositionHigh+rtcEyePositionLow;vPos=currentHigh+currentLow;vColor=color;vec3 highDiff,lowDiff;mat4 viewMatrixRTE=view;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);highDiff=currentHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=currentLow-rtcEyePositionLow;vec4 vCurrent=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=prevHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=prevLow-rtcEyePositionLow;vec4 vPrev=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);highDiff=nextHigh-rtcEyePositionHigh;highDiff=highDiff*step(1.0,length(highDiff));lowDiff=nextLow-rtcEyePositionLow;vec4 vNext=viewMatrixRTE*vec4(highDiff+lowDiff,1.0);if(vCurrent.z>NEAR){if(vPrev.z<NEAR&&abs(order)==1.0){vCurrent=vPrev+(vCurrent-vPrev)*(NEAR-vPrev.z)/(vCurrent.z-vPrev.z);}else if(vNext.z<NEAR&&abs(order)==2.0){vCurrent=vNext+(vCurrent-vNext)*(NEAR-vNext.z)/(vCurrent.z-vNext.z);}}vec4 dCurrent=proj*vCurrent;vec2 _next=project(proj*vNext);vec2 _prev=project(proj*vPrev);vec2 _current=project(dCurrent);if(_prev==_current){if(_next==_current){_next=_current+vec2(1.0,0.0);_prev=_current-_next;}else{_prev=_current+normalize(_current-_next);}}if(_next==_current){_next=_current+normalize(_current-_prev);}vec2 sNext=_next,sCurrent=_current,sPrev=_prev;vec2 dirNext=normalize(sNext-sCurrent);vec2 dirPrev=normalize(sPrev-sCurrent);float dotNP=dot(dirNext,dirPrev);vec2 normalNext=normalize(vec2(-dirNext.y,dirNext.x));vec2 normalPrev=normalize(vec2(dirPrev.y,-dirPrev.x));float d=thickness*sign(order);vec2 m;if(dotNP>=0.99991){m=sCurrent-normalPrev*d;}else{m=getIntersection(sCurrent+normalPrev*d,sPrev+normalPrev*d,sCurrent+normalNext*d,sNext+normalNext*d);if(dotNP>0.5&&dot(dirNext+dirPrev,m-sCurrent)<0.0){float occw=order*sign(dirNext.x*dirPrev.y-dirNext.y*dirPrev.x);if(occw==-1.0){m=sCurrent+normalPrev*d;}else if(occw==1.0){m=sCurrent+normalNext*d;}else if(occw==-2.0){m=sCurrent+normalNext*d;}else if(occw==2.0){m=sCurrent+normalPrev*d;}}else if(distance(sCurrent,m)>min(distance(sCurrent,sNext),distance(sCurrent,sPrev))){m=sCurrent+normalNext*d;}}gl_Position=vec4((2.0*m/viewport-1.0)*dCurrent.w,dCurrent.z+depthOffset,dCurrent.w);}",fragmentShader:"precision highp float;uniform vec4 visibleSphere;varying vec3 uCamPos;varying vec4 vColor;varying vec3 vPos;void main(){if(visibleSphere.w!=0.0){vec3 cam_dir=normalize(vPos-uCamPos);vec3 sph_dir=normalize(vPos-visibleSphere.xyz);if(dot(cam_dir,sph_dir)>0.11){discard;}}gl_FragColor=vec4(vColor.rgb,vColor.a);}"})))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._polylines.length;t++)this._polylines[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._polylines.length,e.__doubleToTwoFloats=this.getRTCPosition.bind(this),this._polylines.push(e),this._entityCollection&&this._entityCollection.renderNode&&(e.setRenderNode(this._entityCollection.renderNode),e.updateRTCPosition()))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._polylines.splice(t,1),this.reindexPolylineArray(t))}reindexPolylineArray(e){let t=this._polylines;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){this._updateRTCEyePosition();let e=this._polylines.length;for(;e--;)this._polylines[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._polylines.length;for(;e--;)this._polylines[e].drawPicking()}}clear(){let e=this._polylines.length;for(;e--;)this._polylines[e]._deleteBuffers(),this._polylines[e]._handler=null,this._polylines[e]._handlerIndex=-1;this._polylines.length=0,this._polylines=[]}getRTCPosition(e,t,i){let r=e.sub(this._relativeCenter);m.doubleToTwoFloats(r,t,i)}setRelativeCenter(e){this._relativeCenter.copy(e);for(let t=0;t<this._polylines.length;t++)this._polylines[t].updateRTCPosition()}_updateRTCEyePosition(){let e=this._renderer;if(e.activeCamera.isFirstPass){let t=e.activeCamera.eye.sub(this._relativeCenter);m.doubleToTwoFloat32Array(t,this._rtcEyePositionHigh,this._rtcEyePositionLow)}}};Un.__counter__=0;let Bl=Un;const Gn=class jo{constructor(e){this.__id=jo.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._rays=[],this._vertexBuffer=null,this._startPositionHighBuffer=null,this._startPositionLowBuffer=null,this._endPositionHighBuffer=null,this._endPositionLowBuffer=null,this._thicknessBuffer=null,this._rgbaBuffer=null,this._pickingColorBuffer=null,this._vertexArr=[],this._startPositionHighArr=[],this._startPositionLowArr=[],this._endPositionHighArr=[],this._endPositionLowArr=[],this._thicknessArr=[],this._rgbaArr=[],this._pickingColorArr=[],this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[5]=this.createVertexBuffer,this._buffersUpdateCallbacks[1]=this.createStartPositionBuffer,this._buffersUpdateCallbacks[2]=this.createEndPositionBuffer,this._buffersUpdateCallbacks[4]=this.createThicknessBuffer,this._buffersUpdateCallbacks[3]=this.createRgbaBuffer,this._buffersUpdateCallbacks[0]=this.createPickingColorBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}static concArr(e,t){for(let i=0;i<t.length;i++)e.push(t[i])}initProgram(){this._renderer&&this._renderer.handler&&(this._renderer.handler.programs.rayScreen||this._renderer.handler.addProgram(new X("rayScreen",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",resolution:"float",uOpacity:"float"},attributes:{a_vertices:"vec2",a_startPosHigh:"vec3",a_startPosLow:"vec3",a_endPosHigh:"vec3",a_endPosLow:"vec3",a_thickness:"float",a_rgba:"vec4"},vertexShader:"precision highp float;attribute vec4 a_rgba;attribute vec3 a_startPosHigh;attribute vec3 a_startPosLow;attribute vec3 a_endPosHigh;attribute vec3 a_endPosLow;attribute vec2 a_vertices;attribute float a_thickness;varying vec4 v_rgba;uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float resolution;uniform float uOpacity;void main(){v_rgba=vec4(a_rgba.rgb,a_rgba.a*uOpacity);vec3 v=(a_endPosHigh-a_startPosHigh)+(a_endPosLow-a_startPosLow);vec3 look=(a_startPosHigh-eyePositionHigh)+(a_startPosLow-eyePositionLow)+v*a_vertices.y;vec3 up=normalize(normalize(v));vec3 right=normalize(cross(look,up));float dist=dot(look,vec3(viewMatrix[0][2],viewMatrix[1][2],viewMatrix[2][2]));float focalSize=2.0*dist*resolution;vec3 vert=right*a_thickness*focalSize*a_vertices.x;vec3 highDiff;if(a_vertices.y==0.0){highDiff=a_startPosHigh-eyePositionHigh;vert+=a_startPosLow-eyePositionLow;}else{highDiff=a_endPosHigh-eyePositionHigh;vert+=a_endPosLow-eyePositionLow;}mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+vert,1.0);}",fragmentShader:"precision highp float;varying vec4 v_rgba;void main(){gl_FragColor=v_rgba;}"})))}setRenderer(e){this._renderer=e,this.initProgram()}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}_removeRays(){let e=this._rays.length;for(;e--;){let t=this._rays[e];t._handlerIndex=-1,t._handler=null}this._rays.length=0,this._rays=[]}clear(){this._vertexArr=null,this._startPositionHighArr=null,this._startPositionLowArr=null,this._endPositionHighArr=null,this._endPositionLowArr=null,this._thicknessArr=null,this._rgbaArr=null,this._vertexArr=new Float32Array([]),this._startPositionHighArr=new Float32Array([]),this._startPositionLowArr=new Float32Array([]),this._endPositionHighArr=new Float32Array([]),this._endPositionLowArr=new Float32Array([]),this._thicknessArr=new Float32Array([]),this._rgbaArr=new Float32Array([]),this._removeRays(),this._deleteBuffers(),this.refresh()}_deleteBuffers(){if(this._renderer){let e=this._renderer.handler.gl;e&&(e.deleteBuffer(this._startPositionHighBuffer),e.deleteBuffer(this._startPositionLowBuffer),e.deleteBuffer(this._endPositionHighBuffer),e.deleteBuffer(this._endPositionLowBuffer),e.deleteBuffer(this._thicknessBuffer),e.deleteBuffer(this._rgbaBuffer),e.deleteBuffer(this._vertexBuffer)),this._startPositionHighBuffer=null,this._startPositionLowBuffer=null,this._endPositionHighBuffer=null,this._endPositionLowBuffer=null,this._thicknessBuffer=null,this._rgbaBuffer=null,this._vertexBuffer=null}}update(){if(this._renderer){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]&&(this._buffersUpdateCallbacks[e].call(this),this._changedBuffers[e]=!1)}}add(e){e._handlerIndex==-1&&(e._handler=this,e._handlerIndex=this._rays.length,this._rays.push(e),this._addRayToArrays(e),this.refresh())}_addRayToArrays(e){e.getVisibility()?this._vertexArr=xe(this._vertexArr,[-.5,1,-.5,0,.5,0,.5,0,.5,1,-.5,1]):this._vertexArr=xe(this._vertexArr,[0,0,0,0,0,0,0,0,0,0,0,0]);let t=e._startPositionHigh.x,i=e._startPositionHigh.y,r=e._startPositionHigh.z;this._startPositionHighArr=xe(this._startPositionHighArr,[t,i,r,t,i,r,t,i,r,t,i,r,t,i,r,t,i,r]),t=e._startPositionLow.x,i=e._startPositionLow.y,r=e._startPositionLow.z,this._startPositionLowArr=xe(this._startPositionLowArr,[t,i,r,t,i,r,t,i,r,t,i,r,t,i,r,t,i,r]),t=e._endPositionHigh.x,i=e._endPositionHigh.y,r=e._endPositionHigh.z,this._endPositionHighArr=xe(this._endPositionHighArr,[t,i,r,t,i,r,t,i,r,t,i,r,t,i,r,t,i,r]),t=e._endPositionLow.x,i=e._endPositionLow.y,r=e._endPositionLow.z,this._endPositionLowArr=xe(this._endPositionLowArr,[t,i,r,t,i,r,t,i,r,t,i,r,t,i,r,t,i,r]),t=e._thickness,this._thicknessArr=xe(this._thicknessArr,[t,t,t,t,t,t]);let s=e._startColor.x,n=e._startColor.y,o=e._startColor.z,l=e._startColor.w,h=e._endColor.x,c=e._endColor.y,d=e._endColor.z,u=e._endColor.w;this._rgbaArr=xe(this._rgbaArr,[h,c,d,u,s,n,o,l,s,n,o,l,s,n,o,l,h,c,d,u,h,c,d,u]),t=e._entity._pickingColor.x/255,i=e._entity._pickingColor.y/255,r=e._entity._pickingColor.z/255,this._pickingColorArr=xe(this._pickingColorArr,[t,i,r,t,i,r,t,i,r,t,i,r,t,i,r,t,i,r])}_displayPASS(){let e=this._renderer,t=e.handler;t.programs.rayScreen.activate();let i=t.programs.rayScreen._program,r=i.attributes,s=i.uniforms,n=t.gl,o=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(s.uOpacity,o._fadingOpacity),n.uniformMatrix4fv(s.viewMatrix,!1,e.activeCamera.getViewMatrix()),n.uniformMatrix4fv(s.projectionMatrix,!1,e.activeCamera.getProjectionMatrix()),n.uniform3fv(s.eyePositionHigh,e.activeCamera.eyeHigh),n.uniform3fv(s.eyePositionLow,e.activeCamera.eyeLow),n.uniform1f(s.resolution,e.activeCamera._tanViewAngle_hradOneByHeight),n.bindBuffer(n.ARRAY_BUFFER,this._startPositionHighBuffer),n.vertexAttribPointer(r.a_startPosHigh,this._startPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._startPositionLowBuffer),n.vertexAttribPointer(r.a_startPosLow,this._startPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._endPositionHighBuffer),n.vertexAttribPointer(r.a_endPosHigh,this._endPositionHighBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._endPositionLowBuffer),n.vertexAttribPointer(r.a_endPosLow,this._endPositionLowBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._rgbaBuffer),n.vertexAttribPointer(r.a_rgba,this._rgbaBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._thicknessBuffer),n.vertexAttribPointer(r.a_thickness,this._thicknessBuffer.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._vertexBuffer),n.vertexAttribPointer(r.a_vertices,this._vertexBuffer.itemSize,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,this._vertexBuffer.numItems),n.enable(n.CULL_FACE)}_pickingPASS(){}draw(){this._rays.length&&(this.update(),this._displayPASS())}drawPicking(){this._rays.length&&this.pickingEnabled&&this._pickingPASS()}reindexRaysArray(e){let t=this._rays;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}_removeRay(e){let t=e._handlerIndex;this._rays.splice(t,1);let i=24*t;this._rgbaArr=Ae(this._rgbaArr,i,24),i=18*t,this._startPositionHighArr=Ae(this._startPositionHighArr,i,18),this._startPositionLowArr=Ae(this._startPositionLowArr,i,18),this._endPositionHighArr=Ae(this._endPositionHighArr,i,18),this._endPositionLowArr=Ae(this._endPositionLowArr,i,18),this._pickingColorArr=Ae(this._pickingColorArr,i,18),i=12*t,this._vertexArr=Ae(this._vertexArr,i,12),i=6*t,this._thicknessArr=Ae(this._thicknessArr,i,6),this.reindexRaysArray(t),this.refresh(),e._handlerIndex=-1,e._handler=null}remove(e){e._handler&&this.__id===e._handler.__id&&this._removeRay(e)}setStartPositionArr(e,t,i){let r=18*e,s=this._startPositionHighArr,n=t.x,o=t.y,l=t.z;s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,s=this._startPositionLowArr,n=i.x,o=i.y,l=i.z,s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,this._changedBuffers[1]=!0}setEndPositionArr(e,t,i){let r=18*e,s=this._endPositionHighArr,n=t.x,o=t.y,l=t.z;s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,s=this._endPositionLowArr,n=i.x,o=i.y,l=i.z,s[r]=n,s[r+1]=o,s[r+2]=l,s[r+3]=n,s[r+4]=o,s[r+5]=l,s[r+6]=n,s[r+7]=o,s[r+8]=l,s[r+9]=n,s[r+10]=o,s[r+11]=l,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=n,s[r+16]=o,s[r+17]=l,this._changedBuffers[2]=!0}setPickingColorArr(e,t){let i=18*e,r=this._pickingColorArr,s=t.x/255,n=t.y/255,o=t.z/255;r[i]=s,r[i+1]=n,r[i+2]=o,r[i+3]=s,r[i+4]=n,r[i+5]=o,r[i+6]=s,r[i+7]=n,r[i+8]=o,r[i+9]=s,r[i+10]=n,r[i+11]=o,r[i+12]=s,r[i+13]=n,r[i+14]=o,r[i+15]=s,r[i+16]=n,r[i+17]=o,this._changedBuffers[0]=!0}setRgbaArr(e,t,i){let r=24*e,s=this._rgbaArr,n=t.x,o=t.y,l=t.z,h=t.w,c=i.x,d=i.y,u=i.z,g=i.w;s[r]=c,s[r+1]=d,s[r+2]=u,s[r+3]=g,s[r+4]=n,s[r+5]=o,s[r+6]=l,s[r+7]=h,s[r+8]=n,s[r+9]=o,s[r+10]=l,s[r+11]=h,s[r+12]=n,s[r+13]=o,s[r+14]=l,s[r+15]=h,s[r+16]=c,s[r+17]=d,s[r+18]=u,s[r+19]=g,s[r+20]=c,s[r+21]=d,s[r+22]=u,s[r+23]=g,this._changedBuffers[3]=!0}setThicknessArr(e,t){let i=6*e,r=this._thicknessArr;r[i]=t,r[i+1]=t,r[i+2]=t,r[i+3]=t,r[i+4]=t,r[i+5]=t,this._changedBuffers[4]=!0}setVisibility(e,t){let i;i=t?[-.5,1,-.5,0,.5,0,.5,0,.5,1,-.5,1]:[0,0,0,0,0,0,0,0,0,0,0,0],this.setVertexArr(e,i)}setVertexArr(e,t){let i=12*e,r=this._vertexArr;r[i]=t[0],r[i+1]=t[1],r[i+2]=t[2],r[i+3]=t[3],r[i+4]=t[4],r[i+5]=t[5],r[i+6]=t[6],r[i+7]=t[7],r[i+8]=t[8],r[i+9]=t[9],r[i+10]=t[10],r[i+11]=t[11],this._changedBuffers[5]=!0}createStartPositionBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._startPositionHighBuffer),this._startPositionHighArr=re(this._startPositionHighArr),this._startPositionHighBuffer=e.createArrayBuffer(this._startPositionHighArr,3,this._startPositionHighArr.length/3,e.gl.DYNAMIC_DRAW),e.gl.deleteBuffer(this._startPositionLowBuffer),this._startPositionLowArr=re(this._startPositionLowArr),this._startPositionLowBuffer=e.createArrayBuffer(this._startPositionLowArr,3,this._startPositionLowArr.length/3,e.gl.DYNAMIC_DRAW)}createEndPositionBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._endPositionHighBuffer),this._endPositionHighArr=re(this._endPositionHighArr),this._endPositionHighBuffer=e.createArrayBuffer(this._endPositionHighArr,3,this._endPositionHighArr.length/3,e.gl.DYNAMIC_DRAW),e.gl.deleteBuffer(this._endPositionLowBuffer),this._endPositionLowArr=re(this._endPositionLowArr),this._endPositionLowBuffer=e.createArrayBuffer(this._endPositionLowArr,3,this._endPositionLowArr.length/3,e.gl.DYNAMIC_DRAW)}createRgbaBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._rgbaBuffer),this._rgbaArr=re(this._rgbaArr),this._rgbaBuffer=e.createArrayBuffer(this._rgbaArr,4,this._rgbaArr.length/4)}createThicknessBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._thicknessBuffer),this._thicknessArr=re(this._thicknessArr),this._thicknessBuffer=e.createArrayBuffer(this._thicknessArr,1,this._thicknessArr.length,e.gl.DYNAMIC_DRAW)}createVertexBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._vertexBuffer),this._vertexArr=re(this._vertexArr),this._vertexBuffer=e.createArrayBuffer(this._vertexArr,2,this._vertexArr.length/2,e.gl.DYNAMIC_DRAW)}createPickingColorBuffer(){let e=this._renderer.handler;e.gl.deleteBuffer(this._pickingColorBuffer),this._pickingColorArr=re(this._pickingColorArr),this._pickingColorBuffer=e.createArrayBuffer(this._pickingColorArr,3,this._pickingColorArr.length/3)}};Gn.__counter__=0;let kl=Gn;const jn=class qo{constructor(e){this.__id=qo.__counter__++,this.pickingEnabled=!0,this._entityCollection=e,this._renderer=null,this._strips=[]}_initProgram(){this._renderer&&this._renderer.handler&&!this._renderer.handler.programs.strip&&this._renderer.handler.addProgram(new X("strip",{uniforms:{projectionMatrix:{type:"mat4"},viewMatrix:{type:"mat4"},eyePositionHigh:"vec3",eyePositionLow:"vec3",uColor:{type:"vec4"},uOpacity:{type:"float"}},attributes:{aVertexPositionHigh:{type:"vec3"},aVertexPositionLow:{type:"vec3"}},vertexShader:`attribute vec3 aVertexPositionHigh;
127
127
  attribute vec3 aVertexPositionLow;
128
128
  uniform mat4 projectionMatrix;
129
129
  uniform mat4 viewMatrix;
@@ -143,26 +143,26 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
143
143
  uniform float uOpacity;
144
144
  void main(void) {
145
145
  gl_FragColor = vec4(uColor.rgb, uColor.a * uOpacity);
146
- }`}))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._strips.length;t++)this._strips[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._strips.length,this._strips.push(e),this._entityCollection&&this._entityCollection.renderNode&&e.setRenderNode(this._entityCollection.renderNode))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._strips.splice(t,1),this.reindexStripArray(t))}reindexStripArray(e){let t=this._strips;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){let e=this._strips.length;for(;e--;)this._strips[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._strips.length;for(;e--;)this._strips[e].drawPicking()}}clear(){let e=this._strips.length;for(;e--;)this._strips[e]._deleteBuffers(),this._strips[e]._handler=null,this._strips[e]._handlerIndex=-1;this._strips.length=0,this._strips=[]}};Gn.__counter__=0;let Il=Gn;const jn=class Ya{constructor(e={}){this._onChangeRelativeCenter=i=>{this.geoObjectHandler.setRelativeCenter(i),this.polylineHandler.setRelativeCenter(i)},this.__id=Ya.__counter__++,this.renderNode=null,this._visibility=e.visibility==null||e.visibility,this.polygonOffsetUnits=e.polygonOffsetUnits!=null?e.polygonOffsetUnits:0,this.billboardHandler=new Ll(this),this.labelHandler=new Ml(this,e.labelMaxLetters),this.polylineHandler=new Bl(this),this.rayHandler=new kl(this),this.pointCloudHandler=new Rl(this),this.stripHandler=new Il(this),this.geoObjectHandler=new Sl(this),e.pickingEnabled!=null&&this.setPickingEnabled(e.pickingEnabled),this._entities=[],this.scaleByDistance=e.scaleByDistance||[1,1,1];let t=new Float32Array([1,1,1]);e.pickingScale!==void 0&&(e.pickingScale instanceof Array?(t[0]=e.pickingScale[0]||t[0],t[1]=e.pickingScale[1]||t[1],t[2]=e.pickingScale[2]||t[2]):typeof e.pickingScale=="number"&&(t[0]=e.pickingScale,t[1]=e.pickingScale,t[2]=e.pickingScale)),this._depthOrder=e.depthOrder||0,this.pickingScale=t,this._opacity=e.opacity==null?1:e.opacity,this._fadingOpacity=this._opacity,this.events=this.rendererEvents=he(zl,this),this._useLighting=e.useLighting!=null?e.useLighting?1:0:1,e.entities&&this.addEntities(e.entities)}get depthOrder(){return this._depthOrder}set depthOrder(e){this._depthOrder=e,this.renderNode&&this.renderNode.updateEntityCollectionsDepthOrder()}isEmpty(){return this._entities.length==0}get id(){return this.__id}get useLighting(){return!!this._useLighting}set useLighting(e){this._useLighting=Number(e)}isEqual(e){return e!==null&&this.__id===e.__id}setVisibility(e){var t;this._visibility=e,this._fadingOpacity=this._opacity*(e?1:0),(t=this.renderNode)==null||t.updateEntityCollectionsDepthOrder(),this.events.dispatch(this.events.visibilitychange,this)}getVisibility(){return this._visibility}setOpacity(e){this._opacity=e}setPickingEnabled(e){this.billboardHandler.pickingEnabled=e,this.labelHandler.pickingEnabled=e,this.polylineHandler.pickingEnabled=e,this.rayHandler.pickingEnabled=e,this.pointCloudHandler.pickingEnabled=e,this.stripHandler.pickingEnabled=e,this.geoObjectHandler.pickingEnabled=e}getOpacity(){return this._opacity}setScaleByDistance(e,t,i){this.scaleByDistance[0]=e,this.scaleByDistance[1]=t,this.scaleByDistance[2]=i||mt}appendChildEntity(e){this._addRecursively(e)}_addRecursively(e){let t=this.renderNode;t&&t.ellipsoid&&e._cartesian.isZero()&&!e.relativePosition&&e.setCartesian3v(t.ellipsoid.lonLatToCartesian(e._lonLat)),this._setPickingColor(e),e._updateAbsolutePosition(),e.setScale3v(e.getScale()),e.billboard&&this.billboardHandler.add(e.billboard),e.label&&this.labelHandler.add(e.label),e.polyline&&this.polylineHandler.add(e.polyline),e.ray&&this.rayHandler.add(e.ray),e.pointCloud&&this.pointCloudHandler.add(e.pointCloud),e.strip&&this.stripHandler.add(e.strip),e.geoObject&&this.geoObjectHandler.add(e.geoObject),this.events.dispatch(this.events.entityadd,e);for(let i=0;i<e.childEntities.length;i++)e.childEntities[i]._entityCollection=this,e.childEntities[i]._entityCollectionIndex=e._entityCollectionIndex,this._addRecursively(e.childEntities[i])}add(e){return e._entityCollection||(e._entityCollection=this,e._entityCollectionIndex=this._entities.length,this._entities.push(e),this._addRecursively(e)),this}addEntities(e){for(let t=0,i=e.length;t<i;t++)this.add(e[t]);return this}belongs(e){return this.isEqual(e._entityCollection)}_removeRecursively(e){e._entityCollection=null,e._entityCollectionIndex=-1,e.billboard&&this.billboardHandler.remove(e.billboard),e.label&&this.labelHandler.remove(e.label),e.polyline&&this.polylineHandler.remove(e.polyline),e.ray&&this.rayHandler.remove(e.ray),e.pointCloud&&this.pointCloudHandler.remove(e.pointCloud),e.strip&&this.stripHandler.remove(e.strip),e.geoObject&&this.geoObjectHandler.remove(e.geoObject);for(let t=0;t<e.childEntities.length;t++)this._removeRecursively(e.childEntities[t])}removeEntity(e){this._entities.splice(e._entityCollectionIndex,1),this.reindexEntitiesArray(e._entityCollectionIndex),this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(e),e._pickingColor.clear()),this.belongs(e)&&this._removeRecursively(e),this.events.dispatch(this.events.entityremove,e)}_removeEntitySilent(e){this._entities.splice(e._entityCollectionIndex,1),this.reindexEntitiesArray(e._entityCollectionIndex),this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(e),e._pickingColor.clear()),this.belongs(e)&&this._removeRecursively(e)}createPickingColors(e=this._entities){if(this.renderNode&&this.renderNode.renderer)for(let t=0;t<e.length;t++){let i=e[t];this._setPickingColor(i),this.createPickingColors(i.childEntities)}}_setPickingColor(e){this.renderNode&&this.renderNode.renderer&&(e._independentPicking||!e.parent?this.renderNode.renderer.assignPickingColor(e):e._pickingColor=e.parent._pickingColor,this.renderNode.renderer.assignPickingColor(e),e.setPickingColor())}reindexEntitiesArray(e){let t=this._entities;for(let i=e;i<t.length;i++)t[i]._entityCollectionIndex=i}addTo(e,t=!1){return this.renderNode||e.addEntityCollection(this,t),this}bindRenderNode(e){e.renderer&&e.renderer.isInitialized()&&(this.billboardHandler.setRenderer(e.renderer),this.labelHandler.setRenderer(e.renderer),this.rayHandler.setRenderer(e.renderer),this.geoObjectHandler.setRenderNode(e),this.polylineHandler.setRenderNode(e),this.pointCloudHandler.setRenderNode(e),this.stripHandler.setRenderNode(e),e.renderer.events.on("changerelativecenter",this._onChangeRelativeCenter),this.updateBillboardsTextureAtlas(),this.updateLabelsFontAtlas(),this.createPickingColors())}_updateGeodeticCoordinates(e){let t=this._entities,i=t.length;for(;i--;){let s=t[i];s._lonLat&&s.setCartesian3v(e.lonLatToCartesian(s._lonLat))}}updateBillboardsTextureAtlas(){let e=this.billboardHandler.billboards;for(let t=0;t<e.length;t++)e[t].setSrc(e[t].getSrc())}updateLabelsFontAtlas(){this.renderNode&&this.labelHandler.updateFonts()}remove(){var e;this.renderNode&&(this.renderNode.removeEntityCollection(this),(e=this.renderNode.renderer)==null||e.events.off("changerelativecenter",this._onChangeRelativeCenter),this.renderNode=null,this.events.dispatch(this.events.remove,this))}getEntities(){return[].concat(this._entities)}each(e){let t=this._entities.length;for(;t--;){let i=this._entities[t];i&&e(i)}}clear(){this.billboardHandler.clear(),this.labelHandler.clear(),this.polylineHandler.clear(),this.rayHandler.clear(),this.pointCloudHandler.clear(),this.stripHandler.clear(),this.geoObjectHandler.clear();let e=this._entities.length;for(;e--;){let t=this._entities[e];this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(t),t._pickingColor.clear()),this._clearEntity(t)}this._entities.length=0,this._entities=[]}_clearEntity(e){e._entityCollection=null,e._entityCollectionIndex=-1;for(let t=0;t<e.childEntities.length;t++)this._clearEntity(e.childEntities[t])}};jn.__counter__=0;let ut=jn;const zl=["draw","drawend","add","remove","entityadd","entityremove","visibilitychange","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];function lt(a,e){if(a>=0){let t=65536*Math.floor(a/65536);e[0]=Math.fround(t),e[1]=Math.fround(a-t)}else{let t=65536*Math.floor(-a/65536);e[0]=Math.fround(-t),e[1]=Math.fround(a+t)}return e}function Yn(a,e){if(a>=0){let t=65536*Math.floor(a/65536);e.x=Math.fround(t),e.y=Math.fround(a-t)}else{let t=65536*Math.floor(-a/65536);e.x=Math.fround(-t),e.y=Math.fround(a+t)}return e}function qn(a,e,t){t=t||2;var i,s,r,n,o,l,h,c=e&&e.length,d=c?e[0]*t:a.length,u=Wn(a,0,d,t,!0),g=[];if(!u)return g;if(c&&(u=function(f,p,_,m){var y,x,w,b=[];for(y=0,x=p.length;y<x;y++)(w=Wn(f,p[y]*m,y<x-1?p[y+1]*m:f.length,m,!1))===w.next&&(w.steiner=!0),b.push(Ul(w));for(b.sort(Hl),y=0;y<b.length;y++)Vl(b[y],_),_=ri(_,_.next);return _}(a,e,u,t)),a.length>80*t){i=r=a[0],s=n=a[1];for(let f=t;f<d;f+=t)(o=a[f])<i&&(i=o),(l=a[f+1])<s&&(s=l),o>r&&(r=o),l>n&&(n=l);h=Math.max(r-i,n-s)}return ni(u,g,t,i,s,h),g}function Wn(a,e,t,i,s){var r,n;if(s===function(o,l,h,c){var d=0;for(let u=l,g=h-c;u<h;u+=c)d+=(o[g]-o[u])*(o[u+1]+o[g+1]),g=u;return d}(a,e,t,i)>0)for(r=e;r<t;r+=i)n=Zn(r,a[r],a[r+1],n);else for(r=t-i;r>=e;r-=i)n=Zn(r,a[r],a[r+1],n);return n&&xt(n,n.next)&&(ai(n),n=n.next),n}function ri(a,e){if(!a)return a;e||(e=a);var t,i=a;do if(t=!1,i.steiner||!xt(i,i.next)&&ze(i.prev,i,i.next)!==0)i=i.next;else{if(ai(i),(i=e=i.prev)===i.next)return null;t=!0}while(t||i!==e);return e}function ni(a,e,t,i,s,r,n){if(a){!n&&r&&function(c,d,u,g){var f=c;do f.z===null&&(f.z=ks(f.x,f.y,d,u,g)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==c);f.prevZ.nextZ=null,f.prevZ=null,function(p){var _,m,y,x,w,b,E,C,T=1;do{for(m=p,p=null,w=null,b=0;m;){for(b++,y=m,E=0,_=0;_<T&&(E++,y=y.nextZ);_++);for(C=T;E>0||C>0&&y;)E!==0&&(C===0||!y||m.z<=y.z)?(x=m,m=m.nextZ,E--):(x=y,y=y.nextZ,C--),w?w.nextZ=x:p=x,x.prevZ=w,w=x;m=y}w.nextZ=null,T*=2}while(b>1)}(f)}(a,i,s,r);for(var o,l,h=a;a.prev!==a.next;)if(o=a.prev,l=a.next,r?Fl(a,i,s,r):Dl(a))e.push(o.i/t),e.push(a.i/t),e.push(l.i/t),ai(a),a=l.next,h=l.next;else if((a=l)===h){n?n===1?ni(a=Ol(a,e,t),e,t,i,s,r,2):n===2&&Nl(a,e,t,i,s,r):ni(ri(a),e,t,i,s,r,1);break}}}function Dl(a){var e=a.prev,t=a,i=a.next;if(ze(e,t,i)>=0)return!1;for(var s=a.next.next;s!==a.prev;){if(Yi(e.x,e.y,t.x,t.y,i.x,i.y,s.x,s.y)&&ze(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function Fl(a,e,t,i){var s=a.prev,r=a,n=a.next;if(ze(s,r,n)>=0)return!1;for(var o=s.x<r.x?s.x<n.x?s.x:n.x:r.x<n.x?r.x:n.x,l=s.y<r.y?s.y<n.y?s.y:n.y:r.y<n.y?r.y:n.y,h=s.x>r.x?s.x>n.x?s.x:n.x:r.x>n.x?r.x:n.x,c=s.y>r.y?s.y>n.y?s.y:n.y:r.y>n.y?r.y:n.y,d=ks(o,l,e,t,i),u=ks(h,c,e,t,i),g=a.nextZ;g&&g.z<=u;){if(g!==a.prev&&g!==a.next&&Yi(s.x,s.y,r.x,r.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(g=a.prevZ;g&&g.z>=d;){if(g!==a.prev&&g!==a.next&&Yi(s.x,s.y,r.x,r.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}function Ol(a,e,t){var i=a;do{var s=i.prev,r=i.next.next;!xt(s,r)&&$n(s,i,i.next,r)&&oi(s,r)&&oi(r,s)&&(e.push(s.i/t),e.push(i.i/t),e.push(r.i/t),ai(i),ai(i.next),i=a=r),i=i.next}while(i!==a);return i}function Nl(a,e,t,i,s,r){var n=a;do{for(var o=n.next.next;o!==n.prev;){if(n.i!==o.i&&Gl(n,o)){var l=Xn(n,o);return n=ri(n,n.next),l=ri(l,l.next),ni(n,e,t,i,s,r),void ni(l,e,t,i,s,r)}o=o.next}n=n.next}while(n!==a)}function Hl(a,e){return a.x-e.x}function Vl(a,e){if(e=function(i,s){var r,n=s,o=i.x,l=i.y,h=-1/0;do{if(l<=n.y&&l>=n.next.y&&n.next.y!==n.y){var c=n.x+(l-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(c<=o&&c>h){if(h=c,c===o){if(l===n.y)return n;if(l===n.next.y)return n.next}r=n.x<n.next.x?n:n.next}}n=n.next}while(n!==s);if(!r)return null;if(o===h)return r.prev;var d,u=r,g=r.x,f=r.y,p=1/0;for(n=r.next;n!==u;)o>=n.x&&n.x>=g&&o!==n.x&&Yi(l<f?o:h,l,g,f,l<f?h:o,l,n.x,n.y)&&((d=Math.abs(l-n.y)/(o-n.x))<p||d===p&&n.x>r.x)&&oi(n,i)&&(r=n,p=d),n=n.next;return r}(a,e)){var t=Xn(e,a);ri(t,t.next)}}function ks(a,e,t,i,s){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-t)/s)|a<<8))|a<<4))|a<<2))|a<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ul(a){var e=a,t=a;do e.x<t.x&&(t=e),e=e.next;while(e!==a);return t}function Yi(a,e,t,i,s,r,n,o){return(s-n)*(e-o)-(a-n)*(r-o)>=0&&(a-n)*(i-o)-(t-n)*(e-o)>=0&&(t-n)*(r-o)-(s-n)*(i-o)>=0}function Gl(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!function(t,i){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==i.i&&s.next.i!==i.i&&$n(s,s.next,t,i))return!0;s=s.next}while(s!==t);return!1}(a,e)&&oi(a,e)&&oi(e,a)&&function(t,i){var s=t,r=!1,n=(t.x+i.x)/2,o=(t.y+i.y)/2;do s.y>o!=s.next.y>o&&s.next.y!==s.y&&n<(s.next.x-s.x)*(o-s.y)/(s.next.y-s.y)+s.x&&(r=!r),s=s.next;while(s!==t);return r}(a,e)}function ze(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function xt(a,e){return a.x===e.x&&a.y===e.y}function $n(a,e,t,i){return!!(xt(a,e)&&xt(t,i)||xt(a,i)&&xt(t,e))||ze(a,e,t)>0!=ze(a,e,i)>0&&ze(t,i,a)>0!=ze(t,i,e)>0}function oi(a,e){return ze(a.prev,a,a.next)<0?ze(a,e,a.next)>=0&&ze(a,a.prev,e)>=0:ze(a,e,a.prev)<0||ze(a,a.next,e)<0}function Xn(a,e){var t=new Is(a.i,a.x,a.y),i=new Is(e.i,e.x,e.y),s=a.next,r=e.prev;return a.next=e,e.prev=a,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zn(a,e,t,i){var s=new Is(a,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function ai(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function Is(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Qn(a){var e=a[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0;for(let s=0;s<a.length;s++){for(let r=0;r<a[s].length;r++)for(let n=0;n<e;n++)t.vertices.push(a[s][r][n]);s>0&&(i+=a[s-1].length,t.holes.push(i))}return t}function zs(a,e,t){let i=a[0],s=a[1];if(i>=0){let r=65536*Math.floor(i/65536);e.x=Math.fround(r),t.x=Math.fround(i-r)}else{let r=65536*Math.floor(-i/65536);e.x=Math.fround(-r),t.x=Math.fround(i+r)}if(s>=0){let r=65536*Math.floor(s/65536);e.y=Math.fround(r),t.y=Math.fround(s-r)}else{let r=65536*Math.floor(-s/65536);e.y=Math.fround(-r),t.y=Math.fround(s+r)}}let Y=new N,q=new N,Ot=new N;const Kn=class qt{constructor(e){this.__id=qt.__counter__++,this._layer=e,this._handler=null,this._geometries=[],this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr=[],this._removeGeometryExtents={},this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyColors=[],this._polyPickingColors=[],this._polyIndexes=[],this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineOrders=[],this._lineIndexes=[],this._lineColors=[],this._linePickingColors=[],this._lineThickness=[],this._lineStrokes=[],this._lineStrokeColors=[],this._polyVerticesHighBufferMerc=null,this._polyVerticesLowBufferMerc=null,this._polyColorsBuffer=null,this._polyPickingColorsBuffer=null,this._polyIndexesBuffer=null,this._lineVerticesHighBufferMerc=null,this._lineVerticesLowBufferMerc=null,this._lineColorsBuffer=null,this._linePickingColorsBuffer=null,this._lineThicknessBuffer=null,this._lineStrokesBuffer=null,this._lineStrokeColorsBuffer=null,this._lineOrdersBuffer=null,this._lineIndexesBuffer=null,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this.createPolyVerticesBuffer,this._buffersUpdateCallbacks[1]=this.createPolyIndexesBuffer,this._buffersUpdateCallbacks[2]=this.createPolyColorsBuffer,this._buffersUpdateCallbacks[3]=this.createLineVerticesBuffer,this._buffersUpdateCallbacks[4]=this.createLineIndexesBuffer,this._buffersUpdateCallbacks[5]=this.createLineOrdersBuffer,this._buffersUpdateCallbacks[6]=this.createLineColorsBuffer,this._buffersUpdateCallbacks[7]=this.createLineThicknessBuffer,this._buffersUpdateCallbacks[8]=this.createLineStrokesBuffer,this._buffersUpdateCallbacks[9]=this.createLineStrokeColorsBuffer,this._buffersUpdateCallbacks[10]=this.createPolyPickingColorsBuffer,this._buffersUpdateCallbacks[11]=this.createLinePickingColorsBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}static appendLineData(e,t,i,s,r,n,o,l,h,c,d,u,g,f,p,_,m,y){var x=0;d.length>0?(x=d[d.length-5]+9,d.push(x,x)):d.push(0,0);var w=r,b=[i.x,i.y,i.z,i.w],E=o,C=[n.x,n.y,n.z,n.w],T=[s.x,s.y,s.z,1];for(let M=0;M<e.length;M++){var L=e[M];if(L.length===0)continue;let R,z,F=x;if(t)R=L[L.length-1];else{let P=L[0],D=L[1];D||(D=P),R=[P[0]+P[0]-D[0],P[1]+P[1]-D[1]]}zs(R,Y,q),l.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),h.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),m.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),y.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]);for(let P=0;P<L.length;P++)zs(L[P],Y,q),l.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),h.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),m.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),y.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]),d.push(x++,x++,x++,x++);if(t)z=L[0],d.push(F,F+1,F+1,F+1);else{let P=L[L.length-1],D=L[L.length-2];D||(D=P),z=[P[0]+P[0]-D[0],P[1]+P[1]-D[1]],d.push(x-1,x-1,x-1,x-1)}zs(z,Y,q),l.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),h.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),m.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),y.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]),M<e.length-1&&(x+=8,d.push(x,x))}}assignHandler(e){this._handler=e,this.refresh(),e.isInitialized()&&this.update()}add(e){if(e._handlerIndex===-1){e._handler=this,e._handlerIndex=this._geometries.length,this._geometries.push(e);let t=e._entity._pickingColor.scaleTo(1/255);if(e._polyVerticesHighMerc=[],e._polyVerticesLowMerc=[],e._lineVerticesHighMerc=[],e._lineVerticesLowMerc=[],e._coordinates[0].length){if(e.type===ti.POLYGON){let i=e._coordinates,s=[];for(let c=0;c<i.length;c++){s[c]=[];for(let d=0;d<i[c].length;d++)s[c][d]=[Xt(i[c][d][0]),Zt(i[c][d][1])]}let r=Qn(s),n=qn(r.vertices,r.holes,2);e._polyVerticesHandlerIndex=this._polyVerticesHighMerc.length,e._polyIndexesHandlerIndex=this._polyIndexes.length;for(let c=0;c<n.length;c++)this._polyIndexes.push(n[c]+.5*e._polyVerticesHandlerIndex);let o=e._style.fillColor,l=[],h=[];for(let c=0;c<.5*r.vertices.length;c++)this._polyColors.push(o.x,o.y,o.z,o.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let c=0;c<r.vertices.length;c++)Yn(r.vertices[c],Ot),l[c]=Ot.x,h[c]=Ot.y;e._polyVerticesHighMerc=l,e._polyVerticesLowMerc=h,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,l),this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc,h),e._polyVerticesLength=r.vertices.length,e._polyIndexesLength=n.length,e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData(s,!0,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ti.MULTIPOLYGON){let i=e._coordinates,s=[],r=[];e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length;for(let h=0;h<i.length;h++){let c=i[h],d=[];for(let f=0;f<c.length;f++){d[f]=[];for(let p=0;p<i[h][f].length;p++)d[f][p]=[Xt(c[f][p][0]),Zt(c[f][p][1])]}let u=Qn(d),g=qn(u.vertices,u.holes,2);for(let f=0;f<g.length;f++)r.push(g[f]+.5*s.length);s.push.apply(s,u.vertices),qt.appendLineData(d,!0,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc)}e._polyVerticesHandlerIndex=this._polyVerticesHighMerc.length,e._polyIndexesHandlerIndex=this._polyIndexes.length;for(let h=0;h<r.length;h++)this._polyIndexes.push(r[h]+.5*e._polyVerticesHandlerIndex);let n=e._style.fillColor,o=[],l=[];for(let h=0;h<.5*s.length;h++)this._polyColors.push(n.x,n.y,n.z,n.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let h=0;h<s.length;h++)Yn(s[h],Ot),o[h]=Ot.x,l[h]=Ot.y;e._polyVerticesHighMerc=o,e._polyVerticesLowMerc=l,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,o),this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc,l),e._polyVerticesLength=s.length,e._polyIndexesLength=r.length,e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ti.LINESTRING){let i=e._coordinates,s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=[Xt(i[r][0]),Zt(i[r][1])];e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData([s],!1,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ti.MULTILINESTRING){let i=e._coordinates,s=[];for(let r=0;r<i.length;r++){s[r]=[];for(let n=0;n<i[r].length;n++)s[r][n]=[Xt(i[r][n][0]),Zt(i[r][n][1])]}e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData(s,!1,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}}this.setGeometryVisibility(e),!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0,this.refresh()}}remove(e){const t=e._handlerIndex;if(t!==-1){this._geometries.splice(t,1),this._polyVerticesHighMerc.splice(e._polyVerticesHandlerIndex,e._polyVerticesLength),this._polyVerticesLowMerc.splice(e._polyVerticesHandlerIndex,e._polyVerticesLength),this._polyColors.splice(2*e._polyVerticesHandlerIndex,2*e._polyVerticesLength),this._polyPickingColors.splice(2*e._polyVerticesHandlerIndex,2*e._polyVerticesLength),this._polyIndexes.splice(e._polyIndexesHandlerIndex,e._polyIndexesLength);let i=.5*e._polyVerticesLength;for(let r=e._polyIndexesHandlerIndex;r<this._polyIndexes.length;r++)this._polyIndexes[r]-=i;this._lineVerticesHighMerc.splice(e._lineVerticesHandlerIndex,e._lineVerticesLength),this._lineVerticesLowMerc.splice(e._lineVerticesHandlerIndex,e._lineVerticesLength),this._lineOrders.splice(e._lineOrdersHandlerIndex,e._lineOrdersLength),this._lineColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._linePickingColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._lineStrokeColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._lineThickness.splice(e._lineThicknessHandlerIndex,e._lineThicknessLength),this._lineStrokes.splice(e._lineThicknessHandlerIndex,e._lineThicknessLength),this._lineIndexes.splice(e._lineIndexesHandlerIndex,e._lineIndexesLength),i=.5*e._lineVerticesLength;for(let r=e._lineIndexesHandlerIndex;r<this._lineIndexes.length;r++)this._lineIndexes[r]-=i;let s=this._geometries;for(let r=t;r<s.length;r++){let n=s[r];n._handlerIndex=r,n._polyVerticesHandlerIndex-=e._polyVerticesLength,n._polyIndexesHandlerIndex-=e._polyIndexesLength,n._lineVerticesHandlerIndex-=e._lineVerticesLength,n._lineOrdersHandlerIndex-=e._lineOrdersLength,n._lineColorsHandlerIndex-=e._lineColorsLength,n._lineThicknessHandlerIndex-=e._lineThicknessLength,n._lineIndexesHandlerIndex-=e._lineIndexesLength}e._pickingReady=!1,e._handler=null,e._handlerIndex=-1,e._polyVerticesHighMerc=[],e._polyVerticesLowMerc=[],e._polyVerticesLength=-1,e._polyIndexesLength=-1,e._polyVerticesHandlerIndex=-1,e._polyIndexesHandlerIndex=-1,e._lineVerticesHighMerc=[],e._lineVerticesLowMerc=[],e._lineVerticesLength=-1,e._lineOrdersLength=-1,e._lineIndexesLength=-1,e._lineColorsLength=-1,e._lineThicknessLength=-1,e._lineVerticesHandlerIndex=-1,e._lineOrdersHandlerIndex=-1,e._lineIndexesHandlerIndex=-1,e._lineThicknessHandlerIndex=-1,e._lineColorsHandlerIndex=-1,!this._removeGeometryExtents[e.__id]&&this._removeGeometryExtentArr.push(e.getExtent()),this._removeGeometryExtents[e.__id]=!0,this.refresh()}}_refreshRecursevely(e,t){if(t.ready){let i=this._layer._id;for(let s=0;s<t.nodes.length;s++){let r=t.nodes[s];if(e.overlaps(r.segment.getExtentLonLat())){this._refreshRecursevely(e,r);let n=r.segment.materials[i];n&&n.isReady&&(n.segment.node.getState()!==1?n.layer.clearMaterial(n):(n.pickingReady=n.pickingReady&&e._pickingReady,n.isReady=!1,n._updateTexture=n.texture,n._updatePickingMask=n.pickingMask),e._pickingReady=!0)}}}}_refreshRecursevelyExt(e,t){if(t.ready){let i=this._layer.__id;for(let s=0;s<t.nodes.length;s++){let r=t.nodes[s];if(e.overlaps(r.segment.getExtentLonLat())){this._refreshRecursevelyExt(e,r);let n=r.segment.materials[i];n&&n.isReady&&n.layer.clearMaterial(n)}}}}_refreshPlanetNode(e){let t,i=this._removeGeometryExtentArr;for(t=0;t<i.length;t++)this._refreshRecursevelyExt(i[t],e);let s=this._updatedGeometryArr;for(t=0;t<s.length;t++)this._refreshRecursevely(s[t],e)}_updatePlanet(){let e=this._layer._planet;if(e){let t=e.quadTreeStrategy.quadTreeList;for(let i=0;i<t.length;i++)this._refreshPlanetNode(t[i])}this._updatedGeometryArr.length=0,this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr.length=0,this._removeGeometryExtentArr=[],this._removeGeometryExtents={}}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}update(){if(this._handler){let e=!1,t=this._changedBuffers.length;for(;t--;)this._changedBuffers[t]&&(e=!0,this._buffersUpdateCallbacks[t].call(this),this._changedBuffers[t]=!1);e&&this._updatePlanet()}}setGeometryVisibility(e){let t=e.getVisibility()?1:0,i=this._polyVerticesHighMerc,s=this._polyVerticesLowMerc,r=e._polyVerticesLength,n=e._polyVerticesHandlerIndex;for(let o=0;o<r;o++)i[n+o]=e._polyVerticesHighMerc[o]*t,s[n+o]=e._polyVerticesLowMerc[o]*t;i=this._lineVerticesHighMerc,s=this._lineVerticesLowMerc,r=e._lineVerticesLength,n=e._lineVerticesHandlerIndex;for(let o=0;o<r;o++)i[n+o]=e._lineVerticesHighMerc[o]*t,s[n+o]=e._lineVerticesLowMerc[o]*t;this._changedBuffers[0]=!0,this._changedBuffers[3]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setPolyColorArr(e,t){let i=2*e._polyVerticesHandlerIndex,s=i+2*e._polyVerticesLength,r=this._polyColors;for(let n=i;n<s;n+=4)r[n]=t.x,r[n+1]=t.y,r[n+2]=t.z,r[n+3]=t.w;this._changedBuffers[2]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineStrokeColorArr(e,t){let i=e._lineColorsHandlerIndex,s=i+e._lineColorsLength,r=this._lineStrokeColors;for(let n=i;n<s;n+=4)r[n]=t.x,r[n+1]=t.y,r[n+2]=t.z,r[n+3]=t.w;this._changedBuffers[9]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineColorArr(e,t){let i=e._lineColorsHandlerIndex,s=i+e._lineColorsLength,r=this._lineColors;for(let n=i;n<s;n+=4)r[n]=t.x,r[n+1]=t.y,r[n+2]=t.z,r[n+3]=t.w;this._changedBuffers[6]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineStrokeArr(e,t){}setLineThicknessArr(e,t){let i=e._lineThicknessHandlerIndex,s=i+e._lineThicknessLength,r=this._lineThickness;for(let n=i;n<s;n++)r[n]=t;this._changedBuffers[7]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}bringToFront(e){let t=this._polyIndexes.splice(e._polyIndexesHandlerIndex,e._polyIndexesLength),i=this._lineIndexes.splice(e._lineIndexesHandlerIndex,e._lineIndexesLength);this._geometries.splice(e._handlerIndex,1);let s=this._geometries;for(let r=e._handlerIndex;r<s.length;r++){let n=s[r];n._handlerIndex=r,n._polyIndexesHandlerIndex-=e._polyIndexesLength,n._lineIndexesHandlerIndex-=e._lineIndexesLength}e._polyIndexesHandlerIndex=this._polyIndexes.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._handlerIndex=this._geometries.length,this._geometries.push(e),this._polyIndexes.push.apply(this._polyIndexes,t),this._lineIndexes.push.apply(this._lineIndexes,i),this._changedBuffers[1]=!0,this._changedBuffers[4]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}createPolyVerticesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyVerticesHighBufferMerc),this._polyVerticesHighBufferMerc=e.createArrayBuffer(new Float32Array(this._polyVerticesHighMerc),2,this._polyVerticesHighMerc.length/2),e.gl.deleteBuffer(this._polyVerticesLowBufferMerc),this._polyVerticesLowBufferMerc=e.createArrayBuffer(new Float32Array(this._polyVerticesLowMerc),2,this._polyVerticesLowMerc.length/2)}createPolyIndexesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyIndexesBuffer),this._polyIndexesBuffer=e.createElementArrayBuffer(new Uint32Array(this._polyIndexes),1,this._polyIndexes.length)}createPolyColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyColorsBuffer),this._polyColorsBuffer=e.createArrayBuffer(new Float32Array(this._polyColors),4,this._polyColors.length/4)}createPolyPickingColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyPickingColorsBuffer),this._polyPickingColorsBuffer=e.createArrayBuffer(new Float32Array(this._polyPickingColors),4,this._polyPickingColors.length/4)}createLineVerticesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineVerticesHighBufferMerc),this._lineVerticesHighBufferMerc=e.createArrayBuffer(new Float32Array(this._lineVerticesHighMerc),2,this._lineVerticesHighMerc.length/2),e.gl.deleteBuffer(this._lineVerticesLowBufferMerc),this._lineVerticesLowBufferMerc=e.createArrayBuffer(new Float32Array(this._lineVerticesLowMerc),2,this._lineVerticesLowMerc.length/2)}createLineIndexesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineIndexesBuffer),this._lineIndexesBuffer=e.createElementArrayBuffer(new Uint32Array(this._lineIndexes),1,this._lineIndexes.length)}createLineOrdersBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineOrdersBuffer),this._lineOrdersBuffer=e.createArrayBuffer(new Float32Array(this._lineOrders),1,this._lineOrders.length/2)}createLineColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineColorsBuffer),this._lineColorsBuffer=e.createArrayBuffer(new Float32Array(this._lineColors),4,this._lineColors.length/4)}createLinePickingColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._linePickingColorsBuffer),this._linePickingColorsBuffer=e.createArrayBuffer(new Float32Array(this._linePickingColors),4,this._linePickingColors.length/4)}createLineThicknessBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineThicknessBuffer),this._lineThicknessBuffer=e.createArrayBuffer(new Float32Array(this._lineThickness),1,this._lineThickness.length)}createLineStrokesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineStrokesBuffer),this._lineStrokesBuffer=e.createArrayBuffer(new Float32Array(this._lineStrokes),1,this._lineStrokes.length)}createLineStrokeColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineStrokeColorsBuffer),this._lineStrokeColorsBuffer=e.createArrayBuffer(new Float32Array(this._lineStrokeColors),4,this._lineStrokeColors.length/4)}clear(){this._geometries=[],this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyIndexes=[],this._polyColors=[],this._polyPickingColors=[],this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineOrders=[],this._lineIndexes=[],this._lineColors=[],this._linePickingColors=[],this._lineThickness=[],this._lineStrokeColors=[],this._lineStrokes=[],this._deleteBuffers(),this._polyVerticesHighBufferMerc=null,this._polyVerticesLowBufferMerc=null,this._polyIndexesBuffer=null,this._polyColorsBuffer=null,this._polyPickingColorsBuffer=null,this._lineVerticesHighBufferMerc=null,this._lineVerticesLowBufferMerc=null,this._lineIndexesBuffer=null,this._lineOrdersBuffer=null,this._lineColorsBuffer=null,this._linePickingColorsBuffer=null,this._lineThicknessBuffer=null,this._lineStrokeColorsBuffer=null,this._lineStrokesBuffer=null,this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr=[],this._removeGeometryExtents={},this.refresh()}_deleteBuffers(){if(this._layer._planet&&this._layer._planet.renderer){let e=this._layer._planet.renderer.handler.gl;e&&(e.deleteBuffer(this._polyVerticesHighBufferMerc),e.deleteBuffer(this._polyVerticesLowBufferMerc),e.deleteBuffer(this._polyIndexesBuffer),e.deleteBuffer(this._polyColorsBuffer),e.deleteBuffer(this._polyPickingColorsBuffer),e.deleteBuffer(this._lineVerticesHighBufferMerc),e.deleteBuffer(this._lineVerticesLowBufferMerc),e.deleteBuffer(this._lineIndexesBuffer),e.deleteBuffer(this._lineOrdersBuffer),e.deleteBuffer(this._lineColorsBuffer),e.deleteBuffer(this._linePickingColorsBuffer),e.deleteBuffer(this._lineThicknessBuffer),e.deleteBuffer(this._lineStrokeColorsBuffer),e.deleteBuffer(this._lineStrokesBuffer))}}};Kn.__counter__=0;let jl=Kn;class ge extends qe{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(Yl),this.isVector=!0,this._hasImageryTiles=!1,this.scaleByDistance=t.scaleByDistance||[mt,mt,mt],this._useLighting=t.useLighting===void 0||t.useLighting;let i=new Float32Array([1,1,1]);t.pickingScale!==void 0&&(t.pickingScale instanceof Array?(i[0]=t.pickingScale[0]||i[0],i[1]=t.pickingScale[1]||i[1],i[2]=t.pickingScale[2]||i[2]):typeof t.pickingScale=="number"&&(i[0]=t.pickingScale,i[1]=t.pickingScale,i[2]=t.pickingScale)),this.pickingScale=i,this.async=t.async===void 0||t.async,this.clampToGround=t.clampToGround||!1,this.relativeToGround=t.relativeToGround||!1,this._entities=function(s){let r=[];for(let n=0;n<s.length;n++){let o=s[n];o.instanceName==="Entity"?r.push(o):r.push(new V(o))}return r}(t.entities||[]),this._labelMaxLetters=t.labelMaxLetters||24,this._stripEntityCollection=new ut({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._stripEntityCollection),this._polylineEntityCollection=new ut({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._polylineEntityCollection),this._geoObjectEntityCollection=new ut({pickingEnabled:this.pickingEnabled,useLighting:this._useLighting}),this._bindEventsDefault(this._geoObjectEntityCollection),this._geometryHandler=new jl(this),this._nodeCapacity=t.nodeCapacity||60,this._entityCollectionsTreeStrategy=null,this.setEntities(this._entities),this.polygonOffsetUnits=t.polygonOffsetUnits!=null?t.polygonOffsetUnits:0,this.pickingEnabled=this._pickingEnabled,this._depthOrder=t.depthOrder||0}get depthOrder(){return this._depthOrder}set depthOrder(e){e!==this._depthOrder&&(this._depthOrder=e,this._planet&&this._planet.updateVisibleLayers())}get useLighting(){return this._useLighting}set useLighting(e){e!==this._useLighting&&(this._geoObjectEntityCollection.useLighting=e,this._useLighting=e)}get labelMaxLetters(){return this._labelMaxLetters}get instanceName(){return"Vector"}_bindPicking(){this._pickingColor.clear()}addTo(e){this._planet||(this._assignPlanet(e),this._geometryHandler.assignHandler(e.renderer.handler),this._polylineEntityCollection.addTo(e,!0),this._stripEntityCollection.addTo(e,!0),this._geoObjectEntityCollection.addTo(e,!0),this._polylineEntityCollection._layer=this,this._stripEntityCollection._layer=this,this._geoObjectEntityCollection._layer=this,this.setEntities(this._entities))}remove(){return super.remove(),this._polylineEntityCollection.remove(),this._stripEntityCollection.remove(),this._geoObjectEntityCollection.remove(),this._polylineEntityCollection._layer=void 0,this._stripEntityCollection._layer=void 0,this._geoObjectEntityCollection._layer=void 0,this}getEntities(){return[].concat(this._entities)}add(e,t=!1){return e._layer||e._entityCollection||(e._layer=this,e._layerIndex=this._entities.length,this._entities.push(e),this._proceedEntity(e,t)),this}insert(e,t,i=!1){if(!e._layer&&!e._entityCollection){e._layer=this,e._layerIndex=t,this._entities.splice(t,0,e);for(let s=t+1,r=this._entities.length;s<r;s++)this._entities[s]._layerIndex=s;this._proceedEntity(e,i)}return this}_proceedEntity(e,t=!1){var i;let s=this._hasImageryTiles;e.strip&&this._stripEntityCollection.add(e),(e.polyline||e.ray)&&this._polylineEntityCollection.add(e),(e.geoObject||e.isEmpty)&&this._geoObjectEntityCollection.add(e),e.geometry&&(this._hasImageryTiles=!0,this._planet&&(this._planet.renderer.assignPickingColor(e),this._geometryHandler.add(e.geometry))),this._planet&&((e.billboard||e.label||e.geoObject||e.isEmpty)&&(e._cartesian.isZero()&&!e._lonLat.isZero()?e._setCartesian3vSilent(this._planet.ellipsoid.lonLatToCartesian(e._lonLat)):(e._lonLat=this._planet.ellipsoid.cartesianToLonLat(e._cartesian),Math.abs(e._lonLat.lat)<ue?e._lonLatMerc=e._lonLat.forwardMercator():e._lonLatMerc.lon=e._lonLatMerc.lat=e._lonLatMerc.height=0)),(e.billboard||e.label)&&((i=this._entityCollectionsTreeStrategy)==null||i.insertEntity(e))),this._planet&&this._hasImageryTiles!==s&&this._planet.updateVisibleLayers(),this.events.dispatch(this.events.entityadd,e)}addEntities(e,t=!1){let i=e.length;for(;i--;)this.add(e[i],t);return this}removeEntity(e){if(e._layer&&this.isEqual(e._layer)){if(this._entities.splice(e._layerIndex,1),this._reindexEntitiesArray(e._layerIndex),e._layer=null,e._layerIndex=-1,e._entityCollection){e._entityCollection._removeEntitySilent(e);let t=e._nodePtr;for(;t;)t.count--,t=t.parentNode;e._nodePtr&&e._nodePtr.count===0&&e._nodePtr.deferredEntities.length===0&&(e._nodePtr.entityCollection=null)}else if(e._nodePtr&&e._nodePtr.deferredEntities.length){let t=e._nodePtr.deferredEntities,i=t.length;for(;i--;)if(t[i].id===e.id){t.splice(i,1);let s=e._nodePtr;for(;s;)s.count--,s=s.parentNode;break}}this._planet&&e.geometry&&(this._geometryHandler.remove(e.geometry),this._planet.renderer.clearPickingColor(e)),e._nodePtr=void 0,this.events.dispatch(this.events.entityremove,e)}return this}set pickingEnabled(e){var t;this._pickingEnabled=e,this._stripEntityCollection.setPickingEnabled(e),this._polylineEntityCollection.setPickingEnabled(e),this._geoObjectEntityCollection.setPickingEnabled(e),(t=this._entityCollectionsTreeStrategy)==null||t.setPickingEnabled(e)}_reindexEntitiesArray(e){const t=this._entities;for(let i=e;i<t.length;i++)t[i]._layerIndex=i}removeEntities(e){let t=e.length;for(;t--;)this.removeEntity(e[t]);return this}clear(){var e;super.clear();let t=new Array(this._entities.length);for(let s=0;s<t.length;s++)t[s]=this._entities[s];let i=this._entities.length;for(;i--;)this._entities[i].remove();this._entities.length=0,this._entities=[];for(let s=0;s<t.length;s++)this._entities[s]=t[s];(e=this._entityCollectionsTreeStrategy)==null||e.dispose(),this._entityCollectionsTreeStrategy=null,this._geometryHandler.clear()}each(e){let t=this._entities,i=t.length;for(;i--;)e(t[i],i)}setEntities(e){let t=new Array(e.length);for(let s=0,r=e.length;s<r;s++)t[s]=e[s];this.clear(),this._entities=new Array(t.length);let i=[];for(let s=0;s<t.length;s++){let r=t[s];r._layer=this,r._layerIndex=s;let n=!(r.strip||r.polyline||r.ray||r.geoObject||r.billboard||r.label);r.strip?this._stripEntityCollection.add(r):r.polyline||r.ray?this._polylineEntityCollection.add(r):r.geoObject||n?this._geoObjectEntityCollection.add(r):(r.billboard||r.label)&&i.push(r),r.geometry&&(this._hasImageryTiles=!0,this._planet&&(this._planet.renderer.assignPickingColor(r),this._geometryHandler.add(r.geometry))),this._entities[s]=r}return this._createEntityCollectionsTree(i),this}_createEntityCollectionsTree(e){this._planet&&(this._entityCollectionsTreeStrategy=this._planet.quadTreeStrategy.createEntitiCollectionsTreeStrategy(this,this._nodeCapacity),this._entityCollectionsTreeStrategy.insertEntities(e))}_bindEventsDefault(e){let t=this.events;e.events.on("mousemove",i=>{t.dispatch(t.mousemove,i)}),e.events.on("mouseenter",i=>{t.dispatch(t.mouseenter,i)}),e.events.on("mouseleave",i=>{t.dispatch(t.mouseleave,i)}),e.events.on("lclick",i=>{t.dispatch(t.lclick,i)}),e.events.on("rclick",i=>{t.dispatch(t.rclick,i)}),e.events.on("mclick",i=>{t.dispatch(t.mclick,i)}),e.events.on("ldblclick",i=>{t.dispatch(t.ldblclick,i)}),e.events.on("rdblclick",i=>{t.dispatch(t.rdblclick,i)}),e.events.on("mdblclick",i=>{t.dispatch(t.mdblclick,i)}),e.events.on("lup",i=>{t.dispatch(t.lup,i)}),e.events.on("rup",i=>{t.dispatch(t.rup,i)}),e.events.on("mup",i=>{t.dispatch(t.mup,i)}),e.events.on("ldown",i=>{t.dispatch(t.ldown,i)}),e.events.on("rdown",i=>{t.dispatch(t.rdown,i)}),e.events.on("mdown",i=>{t.dispatch(t.mdown,i)}),e.events.on("lhold",i=>{t.dispatch(t.lhold,i)}),e.events.on("rhold",i=>{t.dispatch(t.rhold,i)}),e.events.on("mhold",i=>{t.dispatch(t.mhold,i)}),e.events.on("mousewheel",i=>{t.dispatch(t.mousewheel,i)}),e.events.on("touchmove",i=>{t.dispatch(t.touchmove,i)}),e.events.on("touchstart",i=>{t.dispatch(t.touchstart,i)}),e.events.on("touchend",i=>{t.dispatch(t.touchend,i)}),e.events.on("doubletouch",i=>{t.dispatch(t.doubletouch,i)}),e.events.on("touchleave",i=>{t.dispatch(t.touchleave,i)}),e.events.on("touchenter",i=>{t.dispatch(t.touchenter,i)})}_collectStripCollectionPASS(e){let t=this._stripEntityCollection;t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t)}_collectPolylineCollectionPASS(e){let t=this._polylineEntityCollection;if(t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t),this.clampToGround||this.relativeToGround){let i=Number(this.relativeToGround);const s=this._planet._renderedNodes,r=this._planet.getViewExtent();let n=t._entities,o=n.length,l=new v;for(;o--;){let h=n[o]._altitude||0,c=n[o].polyline;if(c&&r.overlaps(c._extent)){let d=c._pathLonLatMerc,u=d.length;for(;u--;){let g=d[u].length;for(;g--;){let f=d[u][g],p=s.length;for(;p--;){let _=s[p].segment;if(_._extent.isInside(f)){let m=c._path3v[u][g];_.getTerrainPoint(m,f,l);let y=i&&c.altitude||0;if(y+=c._pathLonLatMerc[u][g].height||0,y+=h,y){let x=this._planet.ellipsoid.getSurfaceNormal3v(l);c.setPoint3v(l.addA(x.scale(y)),g,u,!0)}else c.setPoint3v(l,g,u,!0);break}}}}}}}}_collectGeoObjectCollectionPASS(e){let t=this._geoObjectEntityCollection;t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t)}collectVisibleCollections(e){let t=this._planet;(this._fading&&this._fadingOpacity>0||this.minZoom<=t.maxCurrZoom&&this.maxZoom>=t.maxCurrZoom)&&(this._collectStripCollectionPASS(e),this._collectPolylineCollectionPASS(e),this._collectGeoObjectCollectionPASS(e),this._entityCollectionsTreeStrategy&&this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(e))}loadMaterial(e){const t=e.segment;this._isBaseLayer?e.texture=t._isNorth?t.planet.solidTextureOne:t.planet.solidTextureTwo:e.texture=t.planet.transparentTexture,this._planet.layerLock.isFree()&&(e.isReady=!1,e.isLoading=!0,this._planet._vectorTileCreator.add(e))}abortMaterialLoading(e){e.isLoading=!1,e.isReady=!1}applyMaterial(e,t=!1){if(e.isReady)return[0,0,1,1];{!e.isLoading&&this.loadMaterial(e);const i=e.segment;let s=i.node,r=!1,n=this.__id,o=e;for(;s.parentNode;){if(o&&o.isReady){r=!0;break}s=s.parentNode,o=s.segment.materials[n]}if(r){e.appliedNodeId=s.nodeId,e.texture=o.texture,e.pickingMask=o.pickingMask;const l=1/(2<<i.tileZoom-s.segment.tileZoom-1);return[i.tileX*l-s.segment.tileX,i.tileY*l-s.segment.tileY,l,l]}return e.textureExists&&e._updateTexture?(e.texture=e._updateTexture,e.pickingMask=e._updatePickingMask):(e.texture=i.planet.transparentTexture,e.pickingMask=i.planet.transparentTexture),e.pickingReady=!0,[0,0,1,1]}}clearMaterial(e){if(e.isReady){const t=e.segment.handler.gl;e.isReady=!1,e.pickingReady=!1;let i=e.texture;e.texture=null,i&&!i.default&&t.deleteTexture(i),i=e.pickingMask,e.pickingMask=null,i&&!i.default&&t.deleteTexture(i),i=e._updateTexture,e._updateTexture=null,i&&!i.default&&t.deleteTexture(i),i=e._updatePickingMask,e._updatePickingMask=null,i&&!i.default&&t.deleteTexture(i)}this.abortMaterialLoading(e),e.isLoading=!1,e.textureExists=!1}update(){this._geometryHandler.update(),this.events.dispatch(this.events.draw,this)}}const Yl=["draw","entityadd","entityremove"],ql=["change","startpoint"],Jn=Z.createCylinder(1,1,2,20,1,!0,!1,0,-.5,0),De=200,li=.3;class eo extends at{constructor(e){super(e.name),this._cornerDblClick=!1,this._onChange=t=>{if(t.geometryType==="POLYGON"){let i=this.getCoordinates(),s=new V({geometry:{type:t.geometryType,coordinates:[i],style:this._fillStyle}});this._geometryLayer.clear(),this._geometryLayer.add(s)}},this._onCornerMouseEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer",this.hideGhostPointer()},this._onCornerMouseLeave=t=>{t.renderer.handler.canvas.style.cursor="default",this.showGhostPointer()},this._onCenterMouseEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer",this.hideGhostPointer()},this._onCenterMouseLeave=t=>{t.renderer.handler.canvas.style.cursor="default",this._pickedCenter||this._pickedCorner||this.showGhostPointer()},this._onLup=t=>{this._planet.renderer.controls.mouseNavigation.activate(),(this._pickedCorner||this._pickedCenter)&&(this.events.dispatch(this.events.change,this),this.setGhostPointerPosition(this._planet.getCartesianFromPixelTerrain(t)),this.showGhostPointer(),this._pickedCorner=null,this._pickedCenter=null)},this._onCornerLdown=t=>{this._pickedCorner=this._getLdown(t)},this._onCenterLdown=t=>{this._pickedCenter=this._getLdown(t)},this._onMouseMove=t=>{this._pickedCenter?this._moveCenterPoint():this._pickedCorner?this._moveCornerPoint(t.pos):this.setGhostPointerPosition(this._planet.getCartesianFromPixelTerrain(t.pos))},this._onCornerLdblclick=t=>{this._cornerDblClick=!0;let i=this.getCoordinates();i.splice(t.pickingObject.layerIndex,1),this.setCoordinates(i)},this._onMouseDblClick=t=>{if(this._cornerDblClick)return void(this._cornerDblClick=!1);if(!this._showGhostPointer)return;let i=this._planet.getCartesianFromPixelTerrain(t);i&&(this._addNew(i),!this._isStartPoint&&this._cornerLayer.getEntities().length>2&&(this._isStartPoint=!0,this.events.dispatch(this.events.startpoint,this)),this.events.dispatch(this.events.change,this))},this.events=he(ql),this._planet=null,this._initCoordinates=e.coordinates||[],this._pickedCorner=null,this._pickedCenter=null,this._startPos=null,this._startClick=new N,this._geometryLayer=new ge,this._cornerStyle={scale:.5,tag:"corners",color:"rgb(350, 350, 0)",object3d:Jn,...e.cornerStyle||{}},this._centerStyle={scale:.4,tag:"centers",color:"rgb(0, 350, 50)",object3d:Jn,...e.centerStyle||{}},this._outlineStyle={thickness:3.5,color:"rgb(0, 350, 50)",...e.outlineStyle||{}},this._fillStyle={fillColor:"rgba(0,146,247,0.2)",...e.fillStyle||{}},this._cornerLayer=new ge("corners",{pickingScale:3,pickingEnabled:!0,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1]}),this._centerLayer=new ge("centers",{pickingScale:3,pickingEnabled:!0,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1]}),this._outlineLayer=new ge("outline",{entities:[new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}})],pickingEnabled:!1,polygonOffsetUnits:-5,relativeToGround:!0}),this._outlineLayer.getEntities()[0].polyline.altitude=li,this._ghostCorner=new V({geoObject:this._cornerStyle}),this._ghostOutlineLayer=new ge("ghost-pointer",{pickingEnabled:!1,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1],opacity:.5}),this._showGhostPointer=!1,this._isStartPoint=!1,this._insertCornerIndex=-1}get geometryType(){return"POLYGON"}getCoordinates(){let e=this._cornerLayer.getEntities();return e.length>0?e.map(t=>{let i=t.getLonLat();return[i.lon,i.lat,i.height]}):this._initCoordinates}bindPlanet(e){this._planet=e}init(){this._initEvents(),this._initGhostLayerPointer(),this._initCoordinates.length&&this.setCoordinates(this._initCoordinates),this._planet.addLayer(this._outlineLayer),this._planet.addLayer(this._cornerLayer),this._planet.addLayer(this._centerLayer),this.showGhostPointer(),this.startNewPoint(),this._geometryLayer.addTo(this._planet),this.events.on("change",this._onChange,this)}onremove(){this._clearEvents(),this.hideGhostPointer(),this.stopNewPoint(),this.clear(),this._geometryLayer.remove()}clear(){this._geometryLayer.clear();let e=this._cornerLayer.getEntities(),t=e.length;for(;t--;)e[t].remove();let i=this._centerLayer.getEntities();for(t=i.length;t--;)i[t].remove();let s=this._outlineLayer.getEntities();for(t=s.length;t--;)s[t].polyline.clear(),t>0&&s[t].remove();this._clearGhostPointer()}setCoordinates(e){this.clear();for(let t=0;t<e.length;t++){let i=e[t],s=this._planet.ellipsoid.lonLatToCartesian(new A(i[0],i[1],i[2]));this._appendCart(s)}this.events.dispatch(this.events.change,this)}stopNewPoint(){this.renderer&&this.renderer.events.off("ldblclick",this._onMouseDblClick)}startNewPoint(){this.renderer.events.on("ldblclick",this._onMouseDblClick,this)}showGhostPointer(){this._showGhostPointer=!0,this._planet.addLayer(this._ghostOutlineLayer),this._insertCornerIndex=this._cornerLayer.getEntities().length}hideGhostPointer(){this._showGhostPointer=!1,this._ghostOutlineLayer.remove(),this._insertCornerIndex=-1}setGhostPointerPosition(e){e&&(this._ghostCorner.setCartesian3v(e),this._updateGhostOutlinePointer(e))}_getLdown(e){this._planet.renderer.controls.mouseNavigation.deactivate(),this._startClick.set(e.x,e.y);let t=e.pickingObject.getCartesian();return this._startPos=this._planet.getPixelFromCartesian(t),e.pickingObject}_initEvents(){this._cornerLayer.events.on("ldblclick",this._onCornerLdblclick,this),this._cornerLayer.events.on("ldown",this._onCornerLdown,this),this._centerLayer.events.on("ldown",this._onCenterLdown,this),this.renderer.events.on("lup",this._onLup,this),this.renderer.events.on("mousemove",this._onMouseMove,this),this._cornerLayer.events.on("mouseenter",this._onCornerMouseEnter,this),this._cornerLayer.events.on("mouseleave",this._onCornerMouseLeave,this),this._centerLayer.events.on("mouseenter",this._onCenterMouseEnter,this),this._centerLayer.events.on("mouseleave",this._onCenterMouseLeave,this)}_clearEvents(){this._cornerLayer.events.off("ldblclick",this._onCornerLdblclick),this._cornerLayer.events.off("ldown",this._onCornerLdown),this._centerLayer.events.off("ldown",this._onCenterLdown),this.renderer.events.off("lup",this._onLup),this.renderer.events.off("mousemove",this._onMouseMove),this._cornerLayer.events.off("mouseenter",this._onCornerMouseEnter),this._cornerLayer.events.off("mouseleave",this._onCornerMouseLeave),this._centerLayer.events.off("mouseenter",this._onCenterMouseEnter),this._centerLayer.events.off("mouseleave",this._onCenterMouseLeave)}_drawCorners(){let e=this._cornerLayer.getEntities();for(let t=0;t<e.length;t++){let i=e[t];this._checkTerrainCollision(i)}}_drawCenters(){let e=this._centerLayer.getEntities();for(let t=0;t<e.length;t++){let i=e[t];this._checkTerrainCollision(i)}}_drawGhostCorner(){this._showGhostPointer&&this._checkTerrainCollision(this._ghostCorner)}frame(){this._drawCorners(),this._drawCenters(),this._drawGhostCorner()}_checkTerrainCollision(e){let t=new v,i=this._planet._renderedNodes;for(let s=0;s<i.length;s++){let r=i[s].segment;if(r&&r._extentLonLat.isInside(e.getLonLat())){r.getEntityTerrainPoint(e,t),e.setCartesian3v(t);break}}}_moveCenterPoint(){let e=this.getCoordinates(),t=this._pickedCenter.layerIndex+1,i=this._pickedCenter.getLonLat(),s=[i.lon,i.lat,i.height];e.splice(t,0,s),this.setCoordinates(e),this._pickedCenter=null,this._pickedCorner=this._cornerLayer.getEntities()[t]}_addNew(e){if(this._insertCornerIndex===-1||this._cornerLayer.getEntities().length<2)this._appendCart(e);else{let t=this.getCoordinates(),i=this._insertCornerIndex,s=this._planet.ellipsoid.cartesianToLonLat(e),r=[s.lon,s.lat,s.height];t.splice(i,0,r),this.clear(),this.setCoordinates(t)}}_appendCart(e){let t=this._cornerLayer.getEntities(),i=t[t.length-1],s=new V({geoObject:this._cornerStyle});if(s.setCartesian3v(e),s.addTo(this._cornerLayer),this._checkTerrainCollision(s),i){let r=t[0].getCartesian(),n=i.getCartesian(),o=s.getCartesian().sub(n),l=s.getCartesian().sub(r),h=o.length(),c=l.length();o.normalize(),l.normalize();let d=[],u=[];for(let x=0;x<=De;x++){let w=o.scaleTo(x*h/De).addA(n);d.push(w);let b=l.scaleTo(x*c/De).addA(r);u.push(b)}this._outlineLayer.getEntities()[0].polyline.setPath3v([u]);let g=new V({polyline:{path3v:[d],isClosed:!1,...this._outlineStyle}});g.polyline.altitude=li,this._outlineLayer.add(g);let f=this._centerLayer.getEntities(),p=f[f.length-1],_=o.scaleTo(.5*h).addA(n),m=l.scaleTo(.5*c).addA(r),y=new V({geoObject:this._centerStyle});y.setCartesian3v(_),y.addTo(this._centerLayer),this._checkTerrainCollision(y),p.remove(),p.addTo(this._centerLayer),p.setCartesian3v(m)}else new V({geoObject:this._centerStyle}).addTo(this._centerLayer)}_clearGhostPointer(){const e=this._ghostOutlineLayer;e.getEntities()[0].polyline.clear(),e.getEntities()[1].polyline.clear()}_moveCornerPoint(e){let t=new N(e.x,e.y).sub(this._startClick),i=this._startPos.add(t),s=this._planet.getCartesianFromPixelTerrain(i);if(s){this._pickedCorner.setCartesian3v(s);let r=this._cornerLayer.getEntities();if(r.length){let n=this._pickedCorner.layerIndex,o=r.length,l=r[n===0?o-1:n-1].getCartesian(),h=r[(n+1)%o].getCartesian(),c=this._pickedCorner.getCartesian().sub(l),d=this._pickedCorner.getCartesian().sub(h),u=c.length(),g=d.length();c.normalize(),d.normalize();let f=[],p=[];for(let T=0;T<=De;T++){let L=c.scaleTo(T*u/De).addA(l);f.push(L);let M=d.scaleTo(T*g/De).addA(h);p.push(M)}let _=this._outlineLayer.getEntities(),m=_[n].polyline,y=_[(n+1)%o].polyline;m==null||m.setPath3v([f]),y==null||y.setPath3v([p]);let x=this._centerLayer.getEntities(),w=x[n===0?o-1:n-1],b=x[n],E=c.scaleTo(.5*u).addA(l),C=d.scaleTo(.5*g).addA(h);w.setCartesian3v(E),this._checkTerrainCollision(w),b.setCartesian3v(C),this._checkTerrainCollision(b)}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let s=0,r=ye;for(let M=0;M<i;M++){let R=t[M].getCartesian().distance(e);R<r&&(r=R,s=M)}let n=t[s].getCartesian(),o=t[(s+1)%i].getCartesian(),l=t[s===0?i-1:s-1].getCartesian().sub(n).normalize(),h=o.sub(n).normalize(),c=e.sub(n).normalize(),d=l.add(h).normalize(),u=c.cross(d),g=l.cross(h);u.dot(g)>0&&(s--,s<0&&(s=i-1));let f=new v;for(let M=0;M<i;M++)if(new Ze(t[M].getCartesian(),t[(M+1)%i].getCartesian()).getNearestDistancePoint(e,f)){let R=f.distance(e);R<r&&(r=R,s=M)}this._insertCornerIndex=(s+1)%i;let p=t[s%i].getCartesian(),_=t[(s+1)%i].getCartesian(),m=this._ghostCorner.getCartesian().sub(p),y=this._ghostCorner.getCartesian().sub(_),x=m.length(),w=y.length();m.normalize(),y.normalize();let b=[],E=[];for(let M=0;M<=De;M++){let R=m.scaleTo(M*x/De).addA(p);b.push(R);let z=y.scaleTo(M*w/De).addA(_);E.push(z)}let C=this._ghostOutlineLayer.getEntities(),T=C[0].polyline,L=C[1].polyline;T==null||T.setPath3v([b]),L==null||L.setPath3v([E])}}_initGhostLayerPointer(){this._ghostOutlineLayer.setEntities([new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),this._ghostCorner]);const e=this._ghostOutlineLayer;e.getEntities()[0].polyline.altitude=e.getEntities()[1].polyline.altitude=li}}class to extends eo{constructor(e){super(e)}get geometryType(){return"LineString"}_addNew(e){this._appendCart(e)}_appendCart(e){let t=this._cornerLayer.getEntities(),i=t[t.length-1],s=new V({geoObject:this._cornerStyle});if(s.setCartesian3v(e),s.addTo(this._cornerLayer),this._checkTerrainCollision(s),i){let r=i.getCartesian(),n=s.getCartesian().sub(r),o=n.length();n.normalize();let l=[];for(let u=0;u<=De;u++){let g=n.scaleTo(u*o/De).addA(r);l.push(g)}let h=new V({polyline:{path3v:[l],isClosed:!1,...this._outlineStyle}});h.polyline.altitude=li,this._outlineLayer.add(h);let c=n.scaleTo(.5*o).addA(r),d=new V({geoObject:this._centerStyle});d.setCartesian3v(c),d.addTo(this._centerLayer),this._checkTerrainCollision(d)}}_clearGhostPointer(){this._ghostOutlineLayer.getEntities()[0].polyline.clear()}_moveCorner(e,t,i){let s=this._cornerLayer.getEntities();if(s.length==0)return;s.length==1&&(e=t=i=0);let r=s[e].getCartesian(),n=this._pickedCorner.getCartesian().sub(r),o=n.length();n.normalize();let l=[];for(let d=0;d<=De;d++){let u=n.scaleTo(d*o/De).addA(r);l.push(u)}let h=this._outlineLayer.getEntities()[t].polyline;h==null||h.setPath3v([l]);let c=this._centerLayer.getEntities()[i];if(c){let d=n.scaleTo(.5*o).addA(r);c.setCartesian3v(d),this._checkTerrainCollision(c)}}_moveCornerPoint(e){let t=new N(e.x,e.y).sub(this._startClick),i=this._startPos.add(t),s=this._planet.getCartesianFromPixelTerrain(i);if(s){this._pickedCorner.setCartesian3v(s);let r=this._cornerLayer.getEntities();if(r.length){let n=this._pickedCorner.layerIndex;n===0?this._moveCorner(n+1,n+1,n):(n===r.length-1||this._moveCorner(n+1,n+1,n),this._moveCorner(n-1,n,n-1))}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let s=i-1;this._insertCornerIndex=s;let r=t[s].getCartesian(),n=this._ghostCorner.getCartesian().sub(r),o=n.length();n.normalize();let l=[];for(let h=0;h<=De;h++){let c=n.scaleTo(h*o/De).addA(r);l.push(c)}this._ghostOutlineLayer.getEntities()[0].polyline.setPath3v([l])}}_initGhostLayerPointer(){this._ghostOutlineLayer.setEntities([new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),this._ghostCorner]),this._ghostOutlineLayer.getEntities()[0].polyline.altitude=li}}class io extends te{constructor(e={}){super(e),this._drawingScene=new to({name:`drawingScene:${this.__id}`,cornerStyle:e.cornerStyle||{},centerStyle:e.centerStyle||{},outlineStyle:e.outlineStyle||{},fillStyle:e.fillStyle||{}})}activatePolygonDrawing(){this.deactivate(),this._drawingScene=new eo({name:`polygonDrawingScene:${this.__id}`,cornerStyle:this._drawingScene._cornerStyle,centerStyle:this._drawingScene._centerStyle,outlineStyle:this._drawingScene._outlineStyle,fillStyle:this._drawingScene._fillStyle}),this.activate()}activateLineStringDrawing(){this.deactivate(),this._drawingScene=new to({name:`linestringDrawingScene:${this.__id}`,cornerStyle:this._drawingScene._cornerStyle,centerStyle:this._drawingScene._centerStyle,outlineStyle:this._drawingScene._outlineStyle,fillStyle:this._drawingScene._fillStyle}),this.activate()}oninit(){}onactivate(){this.planet&&this._drawingScene.bindPlanet(this.planet),this.renderer&&this.renderer.addNode(this._drawingScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._drawingScene)}}const hi={ell:0,msl:1,gnd:2},Ds=.3048,Wl=1/Ds,$l=1/3.6,so=.001*Ds,Xl=1/so,Zl=["m","km","ft","s","h","m/s","km/h","ft/s"],ro=[0,2,0,0,0,0,0,0];let ve=[];function no(a,e,t){return ve[a][e](t)}function Fs(a,e,t,i,s){return a?no(e,t,i).toFixed(s||ro[t]):"--"}function oo(a){return Zl[a]}ve[0]=[],ve[0][0]=a=>a,ve[0][1]=a=>.001*a,ve[0][2]=a=>a*Wl,ve[2]=[],ve[2][0]=a=>a*Ds,ve[2][1]=a=>a*so,ve[2][2]=a=>a,ve[1]=[],ve[1][0]=a=>1e3*a,ve[1][1]=a=>a,ve[1][2]=a=>a*Xl,ve[5]=[],ve[5][5]=a=>a,ve[5][6]=a=>3.6*a,ve[5][7]=a=>3.28084*a,ve[6]=[],ve[6][5]=a=>a*$l,ve[6][6]=a=>a;const ao=Object.freeze(Object.defineProperty({__proto__:null,ELL:0,GND:2,MSL:1,_tenth:ro,convert:no,convertExt:Fs,ft:2,fts:7,h:4,heightMode:hi,km:1,kmh:6,m:0,ms:5,s:3,toString:oo},Symbol.toStringTag,{value:"Module"})),Ql=[`<div class="og-lat-side"></div><div class="og-lat-val"></div>
146
+ }`}))}setRenderNode(e){this._renderer=e.renderer,this._initProgram();for(let t=0;t<this._strips.length;t++)this._strips[t].setRenderNode(e)}add(e){e._handlerIndex===-1&&(e._handler=this,e._handlerIndex=this._strips.length,this._strips.push(e),this._entityCollection&&this._entityCollection.renderNode&&e.setRenderNode(this._entityCollection.renderNode))}remove(e){let t=e._handlerIndex;t!==-1&&(e._deleteBuffers(),e._handlerIndex=-1,e._handler=null,this._strips.splice(t,1),this.reindexStripArray(t))}reindexStripArray(e){let t=this._strips;for(let i=e;i<t.length;i++)t[i]._handlerIndex=i}draw(){let e=this._strips.length;for(;e--;)this._strips[e].draw()}drawPicking(){if(this.pickingEnabled){let e=this._strips.length;for(;e--;)this._strips[e].drawPicking()}}clear(){let e=this._strips.length;for(;e--;)this._strips[e]._deleteBuffers(),this._strips[e]._handler=null,this._strips[e]._handlerIndex=-1;this._strips.length=0,this._strips=[]}};jn.__counter__=0;let Il=jn;const qn=class Yo{constructor(e={}){this._onChangeRelativeCenter=i=>{this.geoObjectHandler.setRelativeCenter(i),this.polylineHandler.setRelativeCenter(i)},this.__id=Yo.__counter__++,this.renderNode=null,this._visibility=e.visibility==null||e.visibility,this.polygonOffsetUnits=e.polygonOffsetUnits!=null?e.polygonOffsetUnits:0,this.billboardHandler=new Ll(this),this.labelHandler=new Ml(this,e.labelMaxLetters),this.polylineHandler=new Bl(this),this.rayHandler=new kl(this),this.pointCloudHandler=new Rl(this),this.stripHandler=new Il(this),this.geoObjectHandler=new Sl(this),e.pickingEnabled!=null&&this.setPickingEnabled(e.pickingEnabled),this._entities=[],this.scaleByDistance=e.scaleByDistance||[1,1,1];let t=new Float32Array([1,1,1]);e.pickingScale!==void 0&&(e.pickingScale instanceof Array?(t[0]=e.pickingScale[0]||t[0],t[1]=e.pickingScale[1]||t[1],t[2]=e.pickingScale[2]||t[2]):typeof e.pickingScale=="number"&&(t[0]=e.pickingScale,t[1]=e.pickingScale,t[2]=e.pickingScale)),this._depthOrder=e.depthOrder||0,this.pickingScale=t,this._opacity=e.opacity==null?1:e.opacity,this._fadingOpacity=this._opacity,this.events=this.rendererEvents=le(zl,this),this._useLighting=e.useLighting!=null?e.useLighting?1:0:1,e.entities&&this.addEntities(e.entities)}get depthOrder(){return this._depthOrder}set depthOrder(e){this._depthOrder=e,this.renderNode&&this.renderNode.updateEntityCollectionsDepthOrder()}isEmpty(){return this._entities.length==0}get id(){return this.__id}get useLighting(){return!!this._useLighting}set useLighting(e){this._useLighting=Number(e)}isEqual(e){return e!==null&&this.__id===e.__id}setVisibility(e){var t;this._visibility=e,this._fadingOpacity=this._opacity*(e?1:0),(t=this.renderNode)==null||t.updateEntityCollectionsDepthOrder(),this.events.dispatch(this.events.visibilitychange,this)}getVisibility(){return this._visibility}setOpacity(e){this._opacity=e}setPickingEnabled(e){this.billboardHandler.pickingEnabled=e,this.labelHandler.pickingEnabled=e,this.polylineHandler.pickingEnabled=e,this.rayHandler.pickingEnabled=e,this.pointCloudHandler.pickingEnabled=e,this.stripHandler.pickingEnabled=e,this.geoObjectHandler.pickingEnabled=e}getOpacity(){return this._opacity}setScaleByDistance(e,t,i){this.scaleByDistance[0]=e,this.scaleByDistance[1]=t,this.scaleByDistance[2]=i||mt}appendChildEntity(e){this._addRecursively(e)}_addRecursively(e){let t=this.renderNode;t&&t.ellipsoid&&e._cartesian.isZero()&&!e.relativePosition&&e.setCartesian3v(t.ellipsoid.lonLatToCartesian(e._lonLat)),this._setPickingColor(e),e._updateAbsolutePosition(),e.setScale3v(e.getScale()),e.billboard&&this.billboardHandler.add(e.billboard),e.label&&this.labelHandler.add(e.label),e.polyline&&this.polylineHandler.add(e.polyline),e.ray&&this.rayHandler.add(e.ray),e.pointCloud&&this.pointCloudHandler.add(e.pointCloud),e.strip&&this.stripHandler.add(e.strip),e.geoObject&&this.geoObjectHandler.add(e.geoObject),this.events.dispatch(this.events.entityadd,e);for(let i=0;i<e.childEntities.length;i++)e.childEntities[i]._entityCollection=this,e.childEntities[i]._entityCollectionIndex=e._entityCollectionIndex,this._addRecursively(e.childEntities[i])}add(e){return e._entityCollection||(e._entityCollection=this,e._entityCollectionIndex=this._entities.length,this._entities.push(e),this._addRecursively(e)),this}addEntities(e){for(let t=0,i=e.length;t<i;t++)this.add(e[t]);return this}belongs(e){return this.isEqual(e._entityCollection)}_removeRecursively(e){e._entityCollection=null,e._entityCollectionIndex=-1,e.billboard&&this.billboardHandler.remove(e.billboard),e.label&&this.labelHandler.remove(e.label),e.polyline&&this.polylineHandler.remove(e.polyline),e.ray&&this.rayHandler.remove(e.ray),e.pointCloud&&this.pointCloudHandler.remove(e.pointCloud),e.strip&&this.stripHandler.remove(e.strip),e.geoObject&&this.geoObjectHandler.remove(e.geoObject);for(let t=0;t<e.childEntities.length;t++)this._removeRecursively(e.childEntities[t])}removeEntity(e){this._entities.splice(e._entityCollectionIndex,1),this.reindexEntitiesArray(e._entityCollectionIndex),this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(e),e._pickingColor.clear()),this.belongs(e)&&this._removeRecursively(e),this.events.dispatch(this.events.entityremove,e)}_removeEntitySilent(e){this._entities.splice(e._entityCollectionIndex,1),this.reindexEntitiesArray(e._entityCollectionIndex),this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(e),e._pickingColor.clear()),this.belongs(e)&&this._removeRecursively(e)}createPickingColors(e=this._entities){if(this.renderNode&&this.renderNode.renderer)for(let t=0;t<e.length;t++){let i=e[t];this._setPickingColor(i),this.createPickingColors(i.childEntities)}}_setPickingColor(e){this.renderNode&&this.renderNode.renderer&&(e._independentPicking||!e.parent?this.renderNode.renderer.assignPickingColor(e):e._pickingColor=e.parent._pickingColor,this.renderNode.renderer.assignPickingColor(e),e.setPickingColor())}reindexEntitiesArray(e){let t=this._entities;for(let i=e;i<t.length;i++)t[i]._entityCollectionIndex=i}addTo(e,t=!1){return this.renderNode||e.addEntityCollection(this,t),this}bindRenderNode(e){e.renderer&&e.renderer.isInitialized()&&(this.billboardHandler.setRenderer(e.renderer),this.labelHandler.setRenderer(e.renderer),this.rayHandler.setRenderer(e.renderer),this.geoObjectHandler.setRenderNode(e),this.polylineHandler.setRenderNode(e),this.pointCloudHandler.setRenderNode(e),this.stripHandler.setRenderNode(e),e.renderer.events.on("changerelativecenter",this._onChangeRelativeCenter),this.updateBillboardsTextureAtlas(),this.updateLabelsFontAtlas(),this.createPickingColors())}_updateGeodeticCoordinates(e){let t=this._entities,i=t.length;for(;i--;){let r=t[i];r._lonLat&&r.setCartesian3v(e.lonLatToCartesian(r._lonLat))}}updateBillboardsTextureAtlas(){let e=this.billboardHandler.billboards;for(let t=0;t<e.length;t++)e[t].setSrc(e[t].getSrc())}updateLabelsFontAtlas(){this.renderNode&&this.labelHandler.updateFonts()}remove(){var e;this.renderNode&&(this.renderNode.removeEntityCollection(this),(e=this.renderNode.renderer)==null||e.events.off("changerelativecenter",this._onChangeRelativeCenter),this.renderNode=null,this.events.dispatch(this.events.remove,this))}getEntities(){return[].concat(this._entities)}each(e){let t=this._entities.length;for(;t--;){let i=this._entities[t];i&&e(i)}}clear(){this.billboardHandler.clear(),this.labelHandler.clear(),this.polylineHandler.clear(),this.rayHandler.clear(),this.pointCloudHandler.clear(),this.stripHandler.clear(),this.geoObjectHandler.clear();let e=this._entities.length;for(;e--;){let t=this._entities[e];this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(t),t._pickingColor.clear()),this._clearEntity(t)}this._entities.length=0,this._entities=[]}_clearEntity(e){e._entityCollection=null,e._entityCollectionIndex=-1;for(let t=0;t<e.childEntities.length;t++)this._clearEntity(e.childEntities[t])}};qn.__counter__=0;let ut=qn;const zl=["draw","drawend","add","remove","entityadd","entityremove","visibilitychange","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];function lt(a,e){if(a>=0){let t=65536*Math.floor(a/65536);e[0]=Math.fround(t),e[1]=Math.fround(a-t)}else{let t=65536*Math.floor(-a/65536);e[0]=Math.fround(-t),e[1]=Math.fround(a+t)}return e}function Yn(a,e){if(a>=0){let t=65536*Math.floor(a/65536);e.x=Math.fround(t),e.y=Math.fround(a-t)}else{let t=65536*Math.floor(-a/65536);e.x=Math.fround(-t),e.y=Math.fround(a+t)}return e}function Wn(a,e,t){t=t||2;var i,r,s,n,o,l,h,c=e&&e.length,d=c?e[0]*t:a.length,u=$n(a,0,d,t,!0),g=[];if(!u)return g;if(c&&(u=function(f,p,_,v){var x,y,w,b=[];for(x=0,y=p.length;x<y;x++)(w=$n(f,p[x]*v,x<y-1?p[x+1]*v:f.length,v,!1))===w.next&&(w.steiner=!0),b.push(Ul(w));for(b.sort(Hl),x=0;x<b.length;x++)Vl(b[x],_),_=ri(_,_.next);return _}(a,e,u,t)),a.length>80*t){i=s=a[0],r=n=a[1];for(let f=t;f<d;f+=t)(o=a[f])<i&&(i=o),(l=a[f+1])<r&&(r=l),o>s&&(s=o),l>n&&(n=l);h=Math.max(s-i,n-r)}return si(u,g,t,i,r,h),g}function $n(a,e,t,i,r){var s,n;if(r===function(o,l,h,c){var d=0;for(let u=l,g=h-c;u<h;u+=c)d+=(o[g]-o[u])*(o[u+1]+o[g+1]),g=u;return d}(a,e,t,i)>0)for(s=e;s<t;s+=i)n=Qn(s,a[s],a[s+1],n);else for(s=t-i;s>=e;s-=i)n=Qn(s,a[s],a[s+1],n);return n&&xt(n,n.next)&&(ai(n),n=n.next),n}function ri(a,e){if(!a)return a;e||(e=a);var t,i=a;do if(t=!1,i.steiner||!xt(i,i.next)&&ke(i.prev,i,i.next)!==0)i=i.next;else{if(ai(i),(i=e=i.prev)===i.next)return null;t=!0}while(t||i!==e);return e}function si(a,e,t,i,r,s,n){if(a){!n&&s&&function(c,d,u,g){var f=c;do f.z===null&&(f.z=Ir(f.x,f.y,d,u,g)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==c);f.prevZ.nextZ=null,f.prevZ=null,function(p){var _,v,x,y,w,b,E,C,T=1;do{for(v=p,p=null,w=null,b=0;v;){for(b++,x=v,E=0,_=0;_<T&&(E++,x=x.nextZ);_++);for(C=T;E>0||C>0&&x;)E!==0&&(C===0||!x||v.z<=x.z)?(y=v,v=v.nextZ,E--):(y=x,x=x.nextZ,C--),w?w.nextZ=y:p=y,y.prevZ=w,w=y;v=x}w.nextZ=null,T*=2}while(b>1)}(f)}(a,i,r,s);for(var o,l,h=a;a.prev!==a.next;)if(o=a.prev,l=a.next,s?Fl(a,i,r,s):Dl(a))e.push(o.i/t),e.push(a.i/t),e.push(l.i/t),ai(a),a=l.next,h=l.next;else if((a=l)===h){n?n===1?si(a=Ol(a,e,t),e,t,i,r,s,2):n===2&&Nl(a,e,t,i,r,s):si(ri(a),e,t,i,r,s,1);break}}}function Dl(a){var e=a.prev,t=a,i=a.next;if(ke(e,t,i)>=0)return!1;for(var r=a.next.next;r!==a.prev;){if(qi(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&ke(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Fl(a,e,t,i){var r=a.prev,s=a,n=a.next;if(ke(r,s,n)>=0)return!1;for(var o=r.x<s.x?r.x<n.x?r.x:n.x:s.x<n.x?s.x:n.x,l=r.y<s.y?r.y<n.y?r.y:n.y:s.y<n.y?s.y:n.y,h=r.x>s.x?r.x>n.x?r.x:n.x:s.x>n.x?s.x:n.x,c=r.y>s.y?r.y>n.y?r.y:n.y:s.y>n.y?s.y:n.y,d=Ir(o,l,e,t,i),u=Ir(h,c,e,t,i),g=a.nextZ;g&&g.z<=u;){if(g!==a.prev&&g!==a.next&&qi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ke(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(g=a.prevZ;g&&g.z>=d;){if(g!==a.prev&&g!==a.next&&qi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ke(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}function Ol(a,e,t){var i=a;do{var r=i.prev,s=i.next.next;!xt(r,s)&&Xn(r,i,i.next,s)&&ni(r,s)&&ni(s,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(s.i/t),ai(i),ai(i.next),i=a=s),i=i.next}while(i!==a);return i}function Nl(a,e,t,i,r,s){var n=a;do{for(var o=n.next.next;o!==n.prev;){if(n.i!==o.i&&Gl(n,o)){var l=Zn(n,o);return n=ri(n,n.next),l=ri(l,l.next),si(n,e,t,i,r,s),void si(l,e,t,i,r,s)}o=o.next}n=n.next}while(n!==a)}function Hl(a,e){return a.x-e.x}function Vl(a,e){if(e=function(i,r){var s,n=r,o=i.x,l=i.y,h=-1/0;do{if(l<=n.y&&l>=n.next.y&&n.next.y!==n.y){var c=n.x+(l-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(c<=o&&c>h){if(h=c,c===o){if(l===n.y)return n;if(l===n.next.y)return n.next}s=n.x<n.next.x?n:n.next}}n=n.next}while(n!==r);if(!s)return null;if(o===h)return s.prev;var d,u=s,g=s.x,f=s.y,p=1/0;for(n=s.next;n!==u;)o>=n.x&&n.x>=g&&o!==n.x&&qi(l<f?o:h,l,g,f,l<f?h:o,l,n.x,n.y)&&((d=Math.abs(l-n.y)/(o-n.x))<p||d===p&&n.x>s.x)&&ni(n,i)&&(s=n,p=d),n=n.next;return s}(a,e)){var t=Zn(e,a);ri(t,t.next)}}function Ir(a,e,t,i,r){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-t)/r)|a<<8))|a<<4))|a<<2))|a<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ul(a){var e=a,t=a;do e.x<t.x&&(t=e),e=e.next;while(e!==a);return t}function qi(a,e,t,i,r,s,n,o){return(r-n)*(e-o)-(a-n)*(s-o)>=0&&(a-n)*(i-o)-(t-n)*(e-o)>=0&&(t-n)*(s-o)-(r-n)*(i-o)>=0}function Gl(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!function(t,i){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==i.i&&r.next.i!==i.i&&Xn(r,r.next,t,i))return!0;r=r.next}while(r!==t);return!1}(a,e)&&ni(a,e)&&ni(e,a)&&function(t,i){var r=t,s=!1,n=(t.x+i.x)/2,o=(t.y+i.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next;while(r!==t);return s}(a,e)}function ke(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function xt(a,e){return a.x===e.x&&a.y===e.y}function Xn(a,e,t,i){return!!(xt(a,e)&&xt(t,i)||xt(a,i)&&xt(t,e))||ke(a,e,t)>0!=ke(a,e,i)>0&&ke(t,i,a)>0!=ke(t,i,e)>0}function ni(a,e){return ke(a.prev,a,a.next)<0?ke(a,e,a.next)>=0&&ke(a,a.prev,e)>=0:ke(a,e,a.prev)<0||ke(a,a.next,e)<0}function Zn(a,e){var t=new zr(a.i,a.x,a.y),i=new zr(e.i,e.x,e.y),r=a.next,s=e.prev;return a.next=e,e.prev=a,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Qn(a,e,t,i){var r=new zr(a,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ai(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function zr(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Kn(a){var e=a[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0;for(let r=0;r<a.length;r++){for(let s=0;s<a[r].length;s++)for(let n=0;n<e;n++)t.vertices.push(a[r][s][n]);r>0&&(i+=a[r-1].length,t.holes.push(i))}return t}function Dr(a,e,t){let i=a[0],r=a[1];if(i>=0){let s=65536*Math.floor(i/65536);e.x=Math.fround(s),t.x=Math.fround(i-s)}else{let s=65536*Math.floor(-i/65536);e.x=Math.fround(-s),t.x=Math.fround(i+s)}if(r>=0){let s=65536*Math.floor(r/65536);e.y=Math.fround(s),t.y=Math.fround(r-s)}else{let s=65536*Math.floor(-r/65536);e.y=Math.fround(-s),t.y=Math.fround(r+s)}}let q=new N,Y=new N,Ft=new N;const Jn=class qt{constructor(e){this.__id=qt.__counter__++,this._layer=e,this._handler=null,this._geometries=[],this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr=[],this._removeGeometryExtents={},this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyColors=[],this._polyPickingColors=[],this._polyIndexes=[],this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineOrders=[],this._lineIndexes=[],this._lineColors=[],this._linePickingColors=[],this._lineThickness=[],this._lineStrokes=[],this._lineStrokeColors=[],this._polyVerticesHighBufferMerc=null,this._polyVerticesLowBufferMerc=null,this._polyColorsBuffer=null,this._polyPickingColorsBuffer=null,this._polyIndexesBuffer=null,this._lineVerticesHighBufferMerc=null,this._lineVerticesLowBufferMerc=null,this._lineColorsBuffer=null,this._linePickingColorsBuffer=null,this._lineThicknessBuffer=null,this._lineStrokesBuffer=null,this._lineStrokeColorsBuffer=null,this._lineOrdersBuffer=null,this._lineIndexesBuffer=null,this._buffersUpdateCallbacks=[],this._buffersUpdateCallbacks[0]=this.createPolyVerticesBuffer,this._buffersUpdateCallbacks[1]=this.createPolyIndexesBuffer,this._buffersUpdateCallbacks[2]=this.createPolyColorsBuffer,this._buffersUpdateCallbacks[3]=this.createLineVerticesBuffer,this._buffersUpdateCallbacks[4]=this.createLineIndexesBuffer,this._buffersUpdateCallbacks[5]=this.createLineOrdersBuffer,this._buffersUpdateCallbacks[6]=this.createLineColorsBuffer,this._buffersUpdateCallbacks[7]=this.createLineThicknessBuffer,this._buffersUpdateCallbacks[8]=this.createLineStrokesBuffer,this._buffersUpdateCallbacks[9]=this.createLineStrokeColorsBuffer,this._buffersUpdateCallbacks[10]=this.createPolyPickingColorsBuffer,this._buffersUpdateCallbacks[11]=this.createLinePickingColorsBuffer,this._changedBuffers=new Array(this._buffersUpdateCallbacks.length)}static appendLineData(e,t,i,r,s,n,o,l,h,c,d,u,g,f,p,_,v,x){var y=0;d.length>0?(y=d[d.length-5]+9,d.push(y,y)):d.push(0,0);var w=s,b=[i.x,i.y,i.z,i.w],E=o,C=[n.x,n.y,n.z,n.w],T=[r.x,r.y,r.z,1];for(let M=0;M<e.length;M++){var L=e[M];if(L.length===0)continue;let R,z,F=y;if(t)R=L[L.length-1];else{let P=L[0],D=L[1];D||(D=P),R=[P[0]+P[0]-D[0],P[1]+P[1]-D[1]]}Dr(R,q,Y),l.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),h.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),v.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),x.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]);for(let P=0;P<L.length;P++)Dr(L[P],q,Y),l.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),h.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),v.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),x.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]),d.push(y++,y++,y++,y++);if(t)z=L[0],d.push(F,F+1,F+1,F+1);else{let P=L[L.length-1],D=L[L.length-2];D||(D=P),z=[P[0]+P[0]-D[0],P[1]+P[1]-D[1]],d.push(y-1,y-1,y-1,y-1)}Dr(z,q,Y),l.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),h.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),v.push(q.x,q.y,q.x,q.y,q.x,q.y,q.x,q.y),x.push(Y.x,Y.y,Y.x,Y.y,Y.x,Y.y,Y.x,Y.y),c.push(1,-1,2,-2),f.push(w,w,w,w),_.push(E,E,E,E),u.push(b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3],b[0],b[1],b[2],b[3]),p.push(C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3],C[0],C[1],C[2],C[3]),g.push(T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3],T[0],T[1],T[2],T[3]),M<e.length-1&&(y+=8,d.push(y,y))}}assignHandler(e){this._handler=e,this.refresh(),e.isInitialized()&&this.update()}add(e){if(e._handlerIndex===-1){e._handler=this,e._handlerIndex=this._geometries.length,this._geometries.push(e);let t=e._entity._pickingColor.scaleTo(1/255);if(e._polyVerticesHighMerc=[],e._polyVerticesLowMerc=[],e._lineVerticesHighMerc=[],e._lineVerticesLowMerc=[],e._coordinates[0].length){if(e.type===ei.POLYGON){let i=e._coordinates,r=[];for(let c=0;c<i.length;c++){r[c]=[];for(let d=0;d<i[c].length;d++)r[c][d]=[$t(i[c][d][0]),Xt(i[c][d][1])]}let s=Kn(r),n=Wn(s.vertices,s.holes,2);e._polyVerticesHandlerIndex=this._polyVerticesHighMerc.length,e._polyIndexesHandlerIndex=this._polyIndexes.length;for(let c=0;c<n.length;c++)this._polyIndexes.push(n[c]+.5*e._polyVerticesHandlerIndex);let o=e._style.fillColor,l=[],h=[];for(let c=0;c<.5*s.vertices.length;c++)this._polyColors.push(o.x,o.y,o.z,o.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let c=0;c<s.vertices.length;c++)Yn(s.vertices[c],Ft),l[c]=Ft.x,h[c]=Ft.y;e._polyVerticesHighMerc=l,e._polyVerticesLowMerc=h,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,l),this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc,h),e._polyVerticesLength=s.vertices.length,e._polyIndexesLength=n.length,e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData(r,!0,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ei.MULTIPOLYGON){let i=e._coordinates,r=[],s=[];e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length;for(let h=0;h<i.length;h++){let c=i[h],d=[];for(let f=0;f<c.length;f++){d[f]=[];for(let p=0;p<i[h][f].length;p++)d[f][p]=[$t(c[f][p][0]),Xt(c[f][p][1])]}let u=Kn(d),g=Wn(u.vertices,u.holes,2);for(let f=0;f<g.length;f++)s.push(g[f]+.5*r.length);r.push.apply(r,u.vertices),qt.appendLineData(d,!0,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc)}e._polyVerticesHandlerIndex=this._polyVerticesHighMerc.length,e._polyIndexesHandlerIndex=this._polyIndexes.length;for(let h=0;h<s.length;h++)this._polyIndexes.push(s[h]+.5*e._polyVerticesHandlerIndex);let n=e._style.fillColor,o=[],l=[];for(let h=0;h<.5*r.length;h++)this._polyColors.push(n.x,n.y,n.z,n.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let h=0;h<r.length;h++)Yn(r[h],Ft),o[h]=Ft.x,l[h]=Ft.y;e._polyVerticesHighMerc=o,e._polyVerticesLowMerc=l,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,o),this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc,l),e._polyVerticesLength=r.length,e._polyIndexesLength=s.length,e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ei.LINESTRING){let i=e._coordinates,r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=[$t(i[s][0]),Xt(i[s][1])];e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData([r],!1,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}else if(e.type===ei.MULTILINESTRING){let i=e._coordinates,r=[];for(let s=0;s<i.length;s++){r[s]=[];for(let n=0;n<i[s].length;n++)r[s][n]=[$t(i[s][n][0]),Xt(i[s][n][1])]}e._lineVerticesHandlerIndex=this._lineVerticesHighMerc.length,e._lineOrdersHandlerIndex=this._lineOrders.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._lineColorsHandlerIndex=this._lineColors.length,e._lineThicknessHandlerIndex=this._lineThickness.length,qt.appendLineData(r,!1,e._style.lineColor,t,e._style.lineWidth,e._style.strokeColor,e._style.strokeWidth,this._lineVerticesHighMerc,this._lineVerticesLowMerc,this._lineOrders,this._lineIndexes,this._lineColors,this._linePickingColors,this._lineThickness,this._lineStrokeColors,this._lineStrokes,e._lineVerticesHighMerc,e._lineVerticesLowMerc),e._lineVerticesLength=this._lineVerticesHighMerc.length-e._lineVerticesHandlerIndex,e._lineOrdersLength=this._lineOrders.length-e._lineOrdersHandlerIndex,e._lineIndexesLength=this._lineIndexes.length-e._lineIndexesHandlerIndex,e._lineColorsLength=this._lineColors.length-e._lineColorsHandlerIndex,e._lineThicknessLength=this._lineThickness.length-e._lineThicknessHandlerIndex}}this.setGeometryVisibility(e),!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0,this.refresh()}}remove(e){const t=e._handlerIndex;if(t!==-1){this._geometries.splice(t,1),this._polyVerticesHighMerc.splice(e._polyVerticesHandlerIndex,e._polyVerticesLength),this._polyVerticesLowMerc.splice(e._polyVerticesHandlerIndex,e._polyVerticesLength),this._polyColors.splice(2*e._polyVerticesHandlerIndex,2*e._polyVerticesLength),this._polyPickingColors.splice(2*e._polyVerticesHandlerIndex,2*e._polyVerticesLength),this._polyIndexes.splice(e._polyIndexesHandlerIndex,e._polyIndexesLength);let i=.5*e._polyVerticesLength;for(let s=e._polyIndexesHandlerIndex;s<this._polyIndexes.length;s++)this._polyIndexes[s]-=i;this._lineVerticesHighMerc.splice(e._lineVerticesHandlerIndex,e._lineVerticesLength),this._lineVerticesLowMerc.splice(e._lineVerticesHandlerIndex,e._lineVerticesLength),this._lineOrders.splice(e._lineOrdersHandlerIndex,e._lineOrdersLength),this._lineColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._linePickingColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._lineStrokeColors.splice(e._lineColorsHandlerIndex,e._lineColorsLength),this._lineThickness.splice(e._lineThicknessHandlerIndex,e._lineThicknessLength),this._lineStrokes.splice(e._lineThicknessHandlerIndex,e._lineThicknessLength),this._lineIndexes.splice(e._lineIndexesHandlerIndex,e._lineIndexesLength),i=.5*e._lineVerticesLength;for(let s=e._lineIndexesHandlerIndex;s<this._lineIndexes.length;s++)this._lineIndexes[s]-=i;let r=this._geometries;for(let s=t;s<r.length;s++){let n=r[s];n._handlerIndex=s,n._polyVerticesHandlerIndex-=e._polyVerticesLength,n._polyIndexesHandlerIndex-=e._polyIndexesLength,n._lineVerticesHandlerIndex-=e._lineVerticesLength,n._lineOrdersHandlerIndex-=e._lineOrdersLength,n._lineColorsHandlerIndex-=e._lineColorsLength,n._lineThicknessHandlerIndex-=e._lineThicknessLength,n._lineIndexesHandlerIndex-=e._lineIndexesLength}e._pickingReady=!1,e._handler=null,e._handlerIndex=-1,e._polyVerticesHighMerc=[],e._polyVerticesLowMerc=[],e._polyVerticesLength=-1,e._polyIndexesLength=-1,e._polyVerticesHandlerIndex=-1,e._polyIndexesHandlerIndex=-1,e._lineVerticesHighMerc=[],e._lineVerticesLowMerc=[],e._lineVerticesLength=-1,e._lineOrdersLength=-1,e._lineIndexesLength=-1,e._lineColorsLength=-1,e._lineThicknessLength=-1,e._lineVerticesHandlerIndex=-1,e._lineOrdersHandlerIndex=-1,e._lineIndexesHandlerIndex=-1,e._lineThicknessHandlerIndex=-1,e._lineColorsHandlerIndex=-1,!this._removeGeometryExtents[e.__id]&&this._removeGeometryExtentArr.push(e.getExtent()),this._removeGeometryExtents[e.__id]=!0,this.refresh()}}_refreshRecursevely(e,t){if(t.ready){let i=this._layer._id;for(let r=0;r<t.nodes.length;r++){let s=t.nodes[r];if(e.overlaps(s.segment.getExtentLonLat())){this._refreshRecursevely(e,s);let n=s.segment.materials[i];n&&n.isReady&&(n.segment.node.getState()!==1?n.layer.clearMaterial(n):(n.pickingReady=n.pickingReady&&e._pickingReady,n.isReady=!1,n._updateTexture=n.texture,n._updatePickingMask=n.pickingMask),e._pickingReady=!0)}}}}_refreshRecursevelyExt(e,t){if(t.ready){let i=this._layer.__id;for(let r=0;r<t.nodes.length;r++){let s=t.nodes[r];if(e.overlaps(s.segment.getExtentLonLat())){this._refreshRecursevelyExt(e,s);let n=s.segment.materials[i];n&&n.isReady&&n.layer.clearMaterial(n)}}}}_refreshPlanetNode(e){let t,i=this._removeGeometryExtentArr;for(t=0;t<i.length;t++)this._refreshRecursevelyExt(i[t],e);let r=this._updatedGeometryArr;for(t=0;t<r.length;t++)this._refreshRecursevely(r[t],e)}_updatePlanet(){let e=this._layer._planet;if(e){let t=e.quadTreeStrategy.quadTreeList;for(let i=0;i<t.length;i++)this._refreshPlanetNode(t[i])}this._updatedGeometryArr.length=0,this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr.length=0,this._removeGeometryExtentArr=[],this._removeGeometryExtents={}}refresh(){let e=this._changedBuffers.length;for(;e--;)this._changedBuffers[e]=!0}update(){if(this._handler){let e=!1,t=this._changedBuffers.length;for(;t--;)this._changedBuffers[t]&&(e=!0,this._buffersUpdateCallbacks[t].call(this),this._changedBuffers[t]=!1);e&&this._updatePlanet()}}setGeometryVisibility(e){let t=e.getVisibility()?1:0,i=this._polyVerticesHighMerc,r=this._polyVerticesLowMerc,s=e._polyVerticesLength,n=e._polyVerticesHandlerIndex;for(let o=0;o<s;o++)i[n+o]=e._polyVerticesHighMerc[o]*t,r[n+o]=e._polyVerticesLowMerc[o]*t;i=this._lineVerticesHighMerc,r=this._lineVerticesLowMerc,s=e._lineVerticesLength,n=e._lineVerticesHandlerIndex;for(let o=0;o<s;o++)i[n+o]=e._lineVerticesHighMerc[o]*t,r[n+o]=e._lineVerticesLowMerc[o]*t;this._changedBuffers[0]=!0,this._changedBuffers[3]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setPolyColorArr(e,t){let i=2*e._polyVerticesHandlerIndex,r=i+2*e._polyVerticesLength,s=this._polyColors;for(let n=i;n<r;n+=4)s[n]=t.x,s[n+1]=t.y,s[n+2]=t.z,s[n+3]=t.w;this._changedBuffers[2]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineStrokeColorArr(e,t){let i=e._lineColorsHandlerIndex,r=i+e._lineColorsLength,s=this._lineStrokeColors;for(let n=i;n<r;n+=4)s[n]=t.x,s[n+1]=t.y,s[n+2]=t.z,s[n+3]=t.w;this._changedBuffers[9]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineColorArr(e,t){let i=e._lineColorsHandlerIndex,r=i+e._lineColorsLength,s=this._lineColors;for(let n=i;n<r;n+=4)s[n]=t.x,s[n+1]=t.y,s[n+2]=t.z,s[n+3]=t.w;this._changedBuffers[6]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}setLineStrokeArr(e,t){}setLineThicknessArr(e,t){let i=e._lineThicknessHandlerIndex,r=i+e._lineThicknessLength,s=this._lineThickness;for(let n=i;n<r;n++)s[n]=t;this._changedBuffers[7]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}bringToFront(e){let t=this._polyIndexes.splice(e._polyIndexesHandlerIndex,e._polyIndexesLength),i=this._lineIndexes.splice(e._lineIndexesHandlerIndex,e._lineIndexesLength);this._geometries.splice(e._handlerIndex,1);let r=this._geometries;for(let s=e._handlerIndex;s<r.length;s++){let n=r[s];n._handlerIndex=s,n._polyIndexesHandlerIndex-=e._polyIndexesLength,n._lineIndexesHandlerIndex-=e._lineIndexesLength}e._polyIndexesHandlerIndex=this._polyIndexes.length,e._lineIndexesHandlerIndex=this._lineIndexes.length,e._handlerIndex=this._geometries.length,this._geometries.push(e),this._polyIndexes.push.apply(this._polyIndexes,t),this._lineIndexes.push.apply(this._lineIndexes,i),this._changedBuffers[1]=!0,this._changedBuffers[4]=!0,!this._updatedGeometry[e.__id]&&this._updatedGeometryArr.push(e),this._updatedGeometry[e.__id]=!0}createPolyVerticesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyVerticesHighBufferMerc),this._polyVerticesHighBufferMerc=e.createArrayBuffer(new Float32Array(this._polyVerticesHighMerc),2,this._polyVerticesHighMerc.length/2),e.gl.deleteBuffer(this._polyVerticesLowBufferMerc),this._polyVerticesLowBufferMerc=e.createArrayBuffer(new Float32Array(this._polyVerticesLowMerc),2,this._polyVerticesLowMerc.length/2)}createPolyIndexesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyIndexesBuffer),this._polyIndexesBuffer=e.createElementArrayBuffer(new Uint32Array(this._polyIndexes),1,this._polyIndexes.length)}createPolyColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyColorsBuffer),this._polyColorsBuffer=e.createArrayBuffer(new Float32Array(this._polyColors),4,this._polyColors.length/4)}createPolyPickingColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._polyPickingColorsBuffer),this._polyPickingColorsBuffer=e.createArrayBuffer(new Float32Array(this._polyPickingColors),4,this._polyPickingColors.length/4)}createLineVerticesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineVerticesHighBufferMerc),this._lineVerticesHighBufferMerc=e.createArrayBuffer(new Float32Array(this._lineVerticesHighMerc),2,this._lineVerticesHighMerc.length/2),e.gl.deleteBuffer(this._lineVerticesLowBufferMerc),this._lineVerticesLowBufferMerc=e.createArrayBuffer(new Float32Array(this._lineVerticesLowMerc),2,this._lineVerticesLowMerc.length/2)}createLineIndexesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineIndexesBuffer),this._lineIndexesBuffer=e.createElementArrayBuffer(new Uint32Array(this._lineIndexes),1,this._lineIndexes.length)}createLineOrdersBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineOrdersBuffer),this._lineOrdersBuffer=e.createArrayBuffer(new Float32Array(this._lineOrders),1,this._lineOrders.length/2)}createLineColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineColorsBuffer),this._lineColorsBuffer=e.createArrayBuffer(new Float32Array(this._lineColors),4,this._lineColors.length/4)}createLinePickingColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._linePickingColorsBuffer),this._linePickingColorsBuffer=e.createArrayBuffer(new Float32Array(this._linePickingColors),4,this._linePickingColors.length/4)}createLineThicknessBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineThicknessBuffer),this._lineThicknessBuffer=e.createArrayBuffer(new Float32Array(this._lineThickness),1,this._lineThickness.length)}createLineStrokesBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineStrokesBuffer),this._lineStrokesBuffer=e.createArrayBuffer(new Float32Array(this._lineStrokes),1,this._lineStrokes.length)}createLineStrokeColorsBuffer(){let e=this._handler;e.gl.deleteBuffer(this._lineStrokeColorsBuffer),this._lineStrokeColorsBuffer=e.createArrayBuffer(new Float32Array(this._lineStrokeColors),4,this._lineStrokeColors.length/4)}clear(){this._geometries=[],this._polyVerticesHighMerc=[],this._polyVerticesLowMerc=[],this._polyIndexes=[],this._polyColors=[],this._polyPickingColors=[],this._lineVerticesHighMerc=[],this._lineVerticesLowMerc=[],this._lineOrders=[],this._lineIndexes=[],this._lineColors=[],this._linePickingColors=[],this._lineThickness=[],this._lineStrokeColors=[],this._lineStrokes=[],this._deleteBuffers(),this._polyVerticesHighBufferMerc=null,this._polyVerticesLowBufferMerc=null,this._polyIndexesBuffer=null,this._polyColorsBuffer=null,this._polyPickingColorsBuffer=null,this._lineVerticesHighBufferMerc=null,this._lineVerticesLowBufferMerc=null,this._lineIndexesBuffer=null,this._lineOrdersBuffer=null,this._lineColorsBuffer=null,this._linePickingColorsBuffer=null,this._lineThicknessBuffer=null,this._lineStrokeColorsBuffer=null,this._lineStrokesBuffer=null,this._updatedGeometryArr=[],this._updatedGeometry={},this._removeGeometryExtentArr=[],this._removeGeometryExtents={},this.refresh()}_deleteBuffers(){if(this._layer._planet&&this._layer._planet.renderer){let e=this._layer._planet.renderer.handler.gl;e&&(e.deleteBuffer(this._polyVerticesHighBufferMerc),e.deleteBuffer(this._polyVerticesLowBufferMerc),e.deleteBuffer(this._polyIndexesBuffer),e.deleteBuffer(this._polyColorsBuffer),e.deleteBuffer(this._polyPickingColorsBuffer),e.deleteBuffer(this._lineVerticesHighBufferMerc),e.deleteBuffer(this._lineVerticesLowBufferMerc),e.deleteBuffer(this._lineIndexesBuffer),e.deleteBuffer(this._lineOrdersBuffer),e.deleteBuffer(this._lineColorsBuffer),e.deleteBuffer(this._linePickingColorsBuffer),e.deleteBuffer(this._lineThicknessBuffer),e.deleteBuffer(this._lineStrokeColorsBuffer),e.deleteBuffer(this._lineStrokesBuffer))}}};Jn.__counter__=0;let jl=Jn;class fe extends Ye{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(ql),this.isVector=!0,this._hasImageryTiles=!1,this.scaleByDistance=t.scaleByDistance||[mt,mt,mt],this._useLighting=t.useLighting===void 0||t.useLighting;let i=new Float32Array([1,1,1]);t.pickingScale!==void 0&&(t.pickingScale instanceof Array?(i[0]=t.pickingScale[0]||i[0],i[1]=t.pickingScale[1]||i[1],i[2]=t.pickingScale[2]||i[2]):typeof t.pickingScale=="number"&&(i[0]=t.pickingScale,i[1]=t.pickingScale,i[2]=t.pickingScale)),this.pickingScale=i,this.async=t.async===void 0||t.async,this.clampToGround=t.clampToGround||!1,this.relativeToGround=t.relativeToGround||!1,this._entities=function(r){let s=[];for(let n=0;n<r.length;n++){let o=r[n];o.instanceName==="Entity"?s.push(o):s.push(new V(o))}return s}(t.entities||[]),this._labelMaxLetters=t.labelMaxLetters||24,this._stripEntityCollection=new ut({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._stripEntityCollection),this._polylineEntityCollection=new ut({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._polylineEntityCollection),this._geoObjectEntityCollection=new ut({pickingEnabled:this.pickingEnabled,useLighting:this._useLighting}),this._bindEventsDefault(this._geoObjectEntityCollection),this._geometryHandler=new jl(this),this._nodeCapacity=t.nodeCapacity||60,this._entityCollectionsTreeStrategy=null,this.setEntities(this._entities),this.polygonOffsetUnits=t.polygonOffsetUnits!=null?t.polygonOffsetUnits:0,this.pickingEnabled=this._pickingEnabled,this._depthOrder=t.depthOrder||0}get depthOrder(){return this._depthOrder}set depthOrder(e){e!==this._depthOrder&&(this._depthOrder=e,this._planet&&this._planet.updateVisibleLayers())}get useLighting(){return this._useLighting}set useLighting(e){e!==this._useLighting&&(this._geoObjectEntityCollection.useLighting=e,this._useLighting=e)}get labelMaxLetters(){return this._labelMaxLetters}get instanceName(){return"Vector"}_bindPicking(){this._pickingColor.clear()}addTo(e){this._planet||(this._assignPlanet(e),this._geometryHandler.assignHandler(e.renderer.handler),this._polylineEntityCollection.addTo(e,!0),this._stripEntityCollection.addTo(e,!0),this._geoObjectEntityCollection.addTo(e,!0),this._polylineEntityCollection._layer=this,this._stripEntityCollection._layer=this,this._geoObjectEntityCollection._layer=this,this.setEntities(this._entities))}remove(){return super.remove(),this._polylineEntityCollection.remove(),this._stripEntityCollection.remove(),this._geoObjectEntityCollection.remove(),this._polylineEntityCollection._layer=void 0,this._stripEntityCollection._layer=void 0,this._geoObjectEntityCollection._layer=void 0,this}getEntities(){return[].concat(this._entities)}add(e){return e._layer||e._entityCollection||(e._layer=this,e._layerIndex=this._entities.length,this._entities.push(e),this._proceedEntity(e)),this}insert(e,t){if(!e._layer&&!e._entityCollection){e._layer=this,e._layerIndex=t,this._entities.splice(t,0,e);for(let i=t+1,r=this._entities.length;i<r;i++)this._entities[i]._layerIndex=i;this._proceedEntity(e)}return this}_proceedEntity(e){var t;let i=this._hasImageryTiles;e.strip&&this._stripEntityCollection.add(e),(e.polyline||e.ray)&&this._polylineEntityCollection.add(e),(e.geoObject||e.isEmpty)&&this._geoObjectEntityCollection.add(e),e.geometry&&(this._hasImageryTiles=!0,this._planet&&(this._planet.renderer.assignPickingColor(e),this._geometryHandler.add(e.geometry))),this._planet&&((e.billboard||e.label||e.geoObject||e.isEmpty)&&(e._cartesian.isZero()&&!e._lonLat.isZero()?e._setCartesian3vSilent(this._planet.ellipsoid.lonLatToCartesian(e._lonLat)):(e._lonLat=this._planet.ellipsoid.cartesianToLonLat(e._cartesian),Math.abs(e._lonLat.lat)<de?e._lonLatMerc=e._lonLat.forwardMercator():e._lonLatMerc.lon=e._lonLatMerc.lat=e._lonLatMerc.height=0)),(e.billboard||e.label)&&((t=this._entityCollectionsTreeStrategy)==null||t.insertEntity(e))),this._planet&&this._hasImageryTiles!==i&&this._planet.updateVisibleLayers(),this.events.dispatch(this.events.entityadd,e)}addEntities(e){let t=e.length;for(;t--;)this.add(e[t]);return this}removeEntity(e){if(e._layer&&this.isEqual(e._layer)){if(this._entities.splice(e._layerIndex,1),this._reindexEntitiesArray(e._layerIndex),e._layer=null,e._layerIndex=-1,e._entityCollection){e._entityCollection._removeEntitySilent(e);let t=e._nodePtr;for(;t;)t.count--,t=t.parentNode;e._nodePtr&&e._nodePtr.count===0&&e._nodePtr.deferredEntities.length===0&&(e._nodePtr.entityCollection=null)}else if(e._nodePtr&&e._nodePtr.deferredEntities.length){let t=e._nodePtr.deferredEntities,i=t.length;for(;i--;)if(t[i].id===e.id){t.splice(i,1);let r=e._nodePtr;for(;r;)r.count--,r=r.parentNode;break}}this._planet&&e.geometry&&(this._geometryHandler.remove(e.geometry),this._planet.renderer.clearPickingColor(e)),e._nodePtr=void 0,this.events.dispatch(this.events.entityremove,e)}return this}set pickingEnabled(e){var t;this._pickingEnabled=e,this._stripEntityCollection.setPickingEnabled(e),this._polylineEntityCollection.setPickingEnabled(e),this._geoObjectEntityCollection.setPickingEnabled(e),(t=this._entityCollectionsTreeStrategy)==null||t.setPickingEnabled(e)}_reindexEntitiesArray(e){const t=this._entities;for(let i=e;i<t.length;i++)t[i]._layerIndex=i}removeEntities(e){let t=e.length;for(;t--;)this.removeEntity(e[t]);return this}clear(){var e;super.clear();let t=new Array(this._entities.length);for(let r=0;r<t.length;r++)t[r]=this._entities[r];let i=this._entities.length;for(;i--;)this._entities[i].remove();this._entities.length=0,this._entities=[];for(let r=0;r<t.length;r++)this._entities[r]=t[r];(e=this._entityCollectionsTreeStrategy)==null||e.dispose(),this._entityCollectionsTreeStrategy=null,this._geometryHandler.clear()}each(e){let t=this._entities,i=t.length;for(;i--;)e(t[i],i)}setEntities(e){let t=new Array(e.length);for(let r=0,s=e.length;r<s;r++)t[r]=e[r];this.clear(),this._entities=new Array(t.length);let i=[];for(let r=0;r<t.length;r++){let s=t[r];s._layer=this,s._layerIndex=r;let n=!(s.strip||s.polyline||s.ray||s.geoObject||s.billboard||s.label);s.strip?this._stripEntityCollection.add(s):s.polyline||s.ray?this._polylineEntityCollection.add(s):s.geoObject||n?this._geoObjectEntityCollection.add(s):(s.billboard||s.label)&&i.push(s),s.geometry&&(this._hasImageryTiles=!0,this._planet&&(this._planet.renderer.assignPickingColor(s),this._geometryHandler.add(s.geometry))),this._entities[r]=s}return this._createEntityCollectionsTree(i),this}_createEntityCollectionsTree(e){this._planet&&(this._entityCollectionsTreeStrategy=this._planet.quadTreeStrategy.createEntityCollectionsTreeStrategy(this,this._nodeCapacity),this._entityCollectionsTreeStrategy.insertEntities(e))}_bindEventsDefault(e){let t=this.events;e.events.on("mousemove",i=>{t.dispatch(t.mousemove,i)}),e.events.on("mouseenter",i=>{t.dispatch(t.mouseenter,i)}),e.events.on("mouseleave",i=>{t.dispatch(t.mouseleave,i)}),e.events.on("lclick",i=>{t.dispatch(t.lclick,i)}),e.events.on("rclick",i=>{t.dispatch(t.rclick,i)}),e.events.on("mclick",i=>{t.dispatch(t.mclick,i)}),e.events.on("ldblclick",i=>{t.dispatch(t.ldblclick,i)}),e.events.on("rdblclick",i=>{t.dispatch(t.rdblclick,i)}),e.events.on("mdblclick",i=>{t.dispatch(t.mdblclick,i)}),e.events.on("lup",i=>{t.dispatch(t.lup,i)}),e.events.on("rup",i=>{t.dispatch(t.rup,i)}),e.events.on("mup",i=>{t.dispatch(t.mup,i)}),e.events.on("ldown",i=>{t.dispatch(t.ldown,i)}),e.events.on("rdown",i=>{t.dispatch(t.rdown,i)}),e.events.on("mdown",i=>{t.dispatch(t.mdown,i)}),e.events.on("lhold",i=>{t.dispatch(t.lhold,i)}),e.events.on("rhold",i=>{t.dispatch(t.rhold,i)}),e.events.on("mhold",i=>{t.dispatch(t.mhold,i)}),e.events.on("mousewheel",i=>{t.dispatch(t.mousewheel,i)}),e.events.on("touchmove",i=>{t.dispatch(t.touchmove,i)}),e.events.on("touchstart",i=>{t.dispatch(t.touchstart,i)}),e.events.on("touchend",i=>{t.dispatch(t.touchend,i)}),e.events.on("doubletouch",i=>{t.dispatch(t.doubletouch,i)}),e.events.on("touchleave",i=>{t.dispatch(t.touchleave,i)}),e.events.on("touchenter",i=>{t.dispatch(t.touchenter,i)})}_collectStripCollectionPASS(e){let t=this._stripEntityCollection;t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t)}_collectPolylineCollectionPASS(e){let t=this._polylineEntityCollection;if(t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t),this.clampToGround||this.relativeToGround){let i=Number(this.relativeToGround);const r=this._planet.quadTreeStrategy._renderedNodes,s=this._planet.getViewExtent();let n=t._entities,o=n.length,l=new m;for(;o--;){let h=n[o]._altitude||0,c=n[o].polyline;if(c&&s.overlaps(c._extent)){let d=c._pathLonLatMerc,u=d.length;for(;u--;){let g=d[u].length;for(;g--;){let f=d[u][g],p=r.length;for(;p--;){let _=r[p].segment;if(_._extent.isInside(f)){let v=c._path3v[u][g];_.getTerrainPoint(v,f,l);let x=i&&c.altitude||h;if(x){let y=this._planet.ellipsoid.getSurfaceNormal3v(l);c.setPoint3v(l.addA(y.scale(x)),g,u,!0)}else c.setPoint3v(l,g,u,!0);break}}}}}}}}_collectGeoObjectCollectionPASS(e){let t=this._geoObjectEntityCollection;t._fadingOpacity=this._fadingOpacity,t.scaleByDistance=this.scaleByDistance,t.pickingScale=this.pickingScale,t.polygonOffsetUnits=this.polygonOffsetUnits,e.push(t)}collectVisibleCollections(e){let t=this._planet;(this._fading&&this._fadingOpacity>0||this.minZoom<=t.quadTreeStrategy.maxCurrZoom&&this.maxZoom>=t.quadTreeStrategy.maxCurrZoom)&&(this._collectStripCollectionPASS(e),this._collectPolylineCollectionPASS(e),this._collectGeoObjectCollectionPASS(e),this._entityCollectionsTreeStrategy&&this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(e))}loadMaterial(e){const t=e.segment;this._isBaseLayer?e.texture=t._isNorth?t.planet.solidTextureOne:t.planet.solidTextureTwo:e.texture=t.planet.transparentTexture,this._planet.layerLock.isFree()&&(e.isReady=!1,e.isLoading=!0,this._planet._vectorTileCreator.add(e))}abortMaterialLoading(e){e.isLoading=!1,e.isReady=!1}applyMaterial(e){if(e.isReady)return[0,0,1,1];{!e.isLoading&&this.loadMaterial(e);const t=e.segment;let i=t.node,r=!1,s=this.__id,n=e;for(;i.parentNode;){if(n&&n.isReady){r=!0;break}i=i.parentNode,n=i.segment.materials[s]}if(r){e.appliedNodeId=i.nodeId,e.texture=n.texture,e.pickingMask=n.pickingMask;const o=1/(2<<t.tileZoom-i.segment.tileZoom-1);return[t.tileX*o-i.segment.tileX,t.tileY*o-i.segment.tileY,o,o]}return e.textureExists&&e._updateTexture?(e.texture=e._updateTexture,e.pickingMask=e._updatePickingMask):(e.texture=t.planet.transparentTexture,e.pickingMask=t.planet.transparentTexture),e.pickingReady=!0,[0,0,1,1]}}clearMaterial(e){if(e.isReady){const t=e.segment.handler.gl;e.isReady=!1,e.pickingReady=!1;let i=e.texture;e.texture=null,i&&!i.default&&t.deleteTexture(i),i=e.pickingMask,e.pickingMask=null,i&&!i.default&&t.deleteTexture(i),i=e._updateTexture,e._updateTexture=null,i&&!i.default&&t.deleteTexture(i),i=e._updatePickingMask,e._updatePickingMask=null,i&&!i.default&&t.deleteTexture(i)}this.abortMaterialLoading(e),e.isLoading=!1,e.textureExists=!1}update(){this._geometryHandler.update(),this.events.dispatch(this.events.draw,this)}}const ql=["draw","entityadd","entityremove"],Yl=["change","startpoint"],ea=Z.createCylinder(1,1,2,20,1,!0,!1,0,-.5,0),Ie=200,oi=.3;class ta extends ot{constructor(e){super(e.name),this._cornerDblClick=!1,this._onChange=t=>{if(t.geometryType==="POLYGON"){let i=this.getCoordinates(),r=new V({geometry:{type:t.geometryType,coordinates:[i],style:this._fillStyle}});this._geometryLayer.clear(),this._geometryLayer.add(r)}},this._onCornerMouseEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer",this.hideGhostPointer()},this._onCornerMouseLeave=t=>{t.renderer.handler.canvas.style.cursor="default",this.showGhostPointer()},this._onCenterMouseEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer",this.hideGhostPointer()},this._onCenterMouseLeave=t=>{t.renderer.handler.canvas.style.cursor="default",this._pickedCenter||this._pickedCorner||this.showGhostPointer()},this._onLup=t=>{this._planet.renderer.controls.mouseNavigation.activate(),(this._pickedCorner||this._pickedCenter)&&(this.events.dispatch(this.events.change,this),this.setGhostPointerPosition(this._planet.getCartesianFromPixelTerrain(t)),this.showGhostPointer(),this._pickedCorner=null,this._pickedCenter=null)},this._onCornerLdown=t=>{this._pickedCorner=this._getLdown(t)},this._onCenterLdown=t=>{this._pickedCenter=this._getLdown(t)},this._onMouseMove=t=>{this._pickedCenter?this._moveCenterPoint():this._pickedCorner?this._moveCornerPoint(t.pos):this.setGhostPointerPosition(this._planet.getCartesianFromPixelTerrain(t.pos))},this._onCornerLdblclick=t=>{this._cornerDblClick=!0;let i=this.getCoordinates();i.splice(t.pickingObject.layerIndex,1),this.setCoordinates(i)},this._onMouseDblClick=t=>{if(this._cornerDblClick)return void(this._cornerDblClick=!1);if(!this._showGhostPointer)return;let i=this._planet.getCartesianFromPixelTerrain(t);i&&(this._addNew(i),!this._isStartPoint&&this._cornerLayer.getEntities().length>2&&(this._isStartPoint=!0,this.events.dispatch(this.events.startpoint,this)),this.events.dispatch(this.events.change,this))},this.events=le(Yl),this._planet=null,this._initCoordinates=e.coordinates||[],this._pickedCorner=null,this._pickedCenter=null,this._startPos=null,this._startClick=new N,this._geometryLayer=new fe,this._cornerStyle={scale:.5,tag:"corners",color:"rgb(350, 350, 0)",object3d:ea,...e.cornerStyle||{}},this._centerStyle={scale:.4,tag:"centers",color:"rgb(0, 350, 50)",object3d:ea,...e.centerStyle||{}},this._outlineStyle={thickness:3.5,color:"rgb(0, 350, 50)",...e.outlineStyle||{}},this._fillStyle={fillColor:"rgba(0,146,247,0.2)",...e.fillStyle||{}},this._cornerLayer=new fe("corners",{pickingScale:3,pickingEnabled:!0,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1]}),this._centerLayer=new fe("centers",{pickingScale:3,pickingEnabled:!0,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1]}),this._outlineLayer=new fe("outline",{entities:[new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}})],pickingEnabled:!1,polygonOffsetUnits:-5,relativeToGround:!0}),this._outlineLayer.getEntities()[0].polyline.altitude=oi,this._ghostCorner=new V({geoObject:this._cornerStyle}),this._ghostOutlineLayer=new fe("ghost-pointer",{pickingEnabled:!1,polygonOffsetUnits:-5,relativeToGround:!0,scaleByDistance:[100,4e6,1],opacity:.5}),this._showGhostPointer=!1,this._isStartPoint=!1,this._insertCornerIndex=-1}get geometryType(){return"POLYGON"}getCoordinates(){let e=this._cornerLayer.getEntities();return e.length>0?e.map(t=>{let i=t.getLonLat();return[i.lon,i.lat,i.height]}):this._initCoordinates}bindPlanet(e){this._planet=e}init(){this._initEvents(),this._initGhostLayerPointer(),this._initCoordinates.length&&this.setCoordinates(this._initCoordinates),this._planet.addLayer(this._outlineLayer),this._planet.addLayer(this._cornerLayer),this._planet.addLayer(this._centerLayer),this.showGhostPointer(),this.startNewPoint(),this._geometryLayer.addTo(this._planet),this.events.on("change",this._onChange,this)}onremove(){this._clearEvents(),this.hideGhostPointer(),this.stopNewPoint(),this.clear(),this._geometryLayer.remove()}clear(){this._geometryLayer.clear();let e=this._cornerLayer.getEntities(),t=e.length;for(;t--;)e[t].remove();let i=this._centerLayer.getEntities();for(t=i.length;t--;)i[t].remove();let r=this._outlineLayer.getEntities();for(t=r.length;t--;)r[t].polyline.clear(),t>0&&r[t].remove();this._clearGhostPointer()}setCoordinates(e){this.clear();for(let t=0;t<e.length;t++){let i=e[t],r=this._planet.ellipsoid.lonLatToCartesian(new A(i[0],i[1],i[2]));this._appendCart(r)}this.events.dispatch(this.events.change,this)}stopNewPoint(){this.renderer&&this.renderer.events.off("ldblclick",this._onMouseDblClick)}startNewPoint(){this.renderer.events.on("ldblclick",this._onMouseDblClick,this)}showGhostPointer(){this._showGhostPointer=!0,this._planet.addLayer(this._ghostOutlineLayer),this._insertCornerIndex=this._cornerLayer.getEntities().length}hideGhostPointer(){this._showGhostPointer=!1,this._ghostOutlineLayer.remove(),this._insertCornerIndex=-1}setGhostPointerPosition(e){e&&(this._ghostCorner.setCartesian3v(e),this._updateGhostOutlinePointer(e))}_getLdown(e){this._planet.renderer.controls.mouseNavigation.deactivate(),this._startClick.set(e.x,e.y);let t=e.pickingObject.getCartesian();return this._startPos=this._planet.getPixelFromCartesian(t),e.pickingObject}_initEvents(){this._cornerLayer.events.on("ldblclick",this._onCornerLdblclick,this),this._cornerLayer.events.on("ldown",this._onCornerLdown,this),this._centerLayer.events.on("ldown",this._onCenterLdown,this),this.renderer.events.on("lup",this._onLup,this),this.renderer.events.on("mousemove",this._onMouseMove,this),this._cornerLayer.events.on("mouseenter",this._onCornerMouseEnter,this),this._cornerLayer.events.on("mouseleave",this._onCornerMouseLeave,this),this._centerLayer.events.on("mouseenter",this._onCenterMouseEnter,this),this._centerLayer.events.on("mouseleave",this._onCenterMouseLeave,this)}_clearEvents(){this._cornerLayer.events.off("ldblclick",this._onCornerLdblclick),this._cornerLayer.events.off("ldown",this._onCornerLdown),this._centerLayer.events.off("ldown",this._onCenterLdown),this.renderer.events.off("lup",this._onLup),this.renderer.events.off("mousemove",this._onMouseMove),this._cornerLayer.events.off("mouseenter",this._onCornerMouseEnter),this._cornerLayer.events.off("mouseleave",this._onCornerMouseLeave),this._centerLayer.events.off("mouseenter",this._onCenterMouseEnter),this._centerLayer.events.off("mouseleave",this._onCenterMouseLeave)}_drawCorners(){let e=this._cornerLayer.getEntities();for(let t=0;t<e.length;t++){let i=e[t];this._checkTerrainCollision(i)}}_drawCenters(){let e=this._centerLayer.getEntities();for(let t=0;t<e.length;t++){let i=e[t];this._checkTerrainCollision(i)}}_drawGhostCorner(){this._showGhostPointer&&this._checkTerrainCollision(this._ghostCorner)}frame(){this._drawCorners(),this._drawCenters(),this._drawGhostCorner()}_checkTerrainCollision(e){let t=new m,i=this._planet.quadTreeStrategy._renderedNodes;for(let r=0;r<i.length;r++){let s=i[r].segment;if(s&&s._extentLonLat.isInside(e.getLonLat())){s.getEntityTerrainPoint(e,t),e.setCartesian3v(t);break}}}_moveCenterPoint(){let e=this.getCoordinates(),t=this._pickedCenter.layerIndex+1,i=this._pickedCenter.getLonLat(),r=[i.lon,i.lat,i.height];e.splice(t,0,r),this.setCoordinates(e),this._pickedCenter=null,this._pickedCorner=this._cornerLayer.getEntities()[t]}_addNew(e){if(this._insertCornerIndex===-1||this._cornerLayer.getEntities().length<2)this._appendCart(e);else{let t=this.getCoordinates(),i=this._insertCornerIndex,r=this._planet.ellipsoid.cartesianToLonLat(e),s=[r.lon,r.lat,r.height];t.splice(i,0,s),this.clear(),this.setCoordinates(t)}}_appendCart(e){let t=this._cornerLayer.getEntities(),i=t[t.length-1],r=new V({geoObject:this._cornerStyle});if(r.setCartesian3v(e),r.addTo(this._cornerLayer),this._checkTerrainCollision(r),i){let s=t[0].getCartesian(),n=i.getCartesian(),o=r.getCartesian().sub(n),l=r.getCartesian().sub(s),h=o.length(),c=l.length();o.normalize(),l.normalize();let d=[],u=[];for(let y=0;y<=Ie;y++){let w=o.scaleTo(y*h/Ie).addA(n);d.push(w);let b=l.scaleTo(y*c/Ie).addA(s);u.push(b)}this._outlineLayer.getEntities()[0].polyline.setPath3v([u]);let g=new V({polyline:{path3v:[d],isClosed:!1,...this._outlineStyle}});g.polyline.altitude=oi,this._outlineLayer.add(g);let f=this._centerLayer.getEntities(),p=f[f.length-1],_=o.scaleTo(.5*h).addA(n),v=l.scaleTo(.5*c).addA(s),x=new V({geoObject:this._centerStyle});x.setCartesian3v(_),x.addTo(this._centerLayer),this._checkTerrainCollision(x),p.remove(),p.addTo(this._centerLayer),p.setCartesian3v(v)}else new V({geoObject:this._centerStyle}).addTo(this._centerLayer)}_clearGhostPointer(){const e=this._ghostOutlineLayer;e.getEntities()[0].polyline.clear(),e.getEntities()[1].polyline.clear()}_moveCornerPoint(e){let t=new N(e.x,e.y).sub(this._startClick),i=this._startPos.add(t),r=this._planet.getCartesianFromPixelTerrain(i);if(r){this._pickedCorner.setCartesian3v(r);let s=this._cornerLayer.getEntities();if(s.length){let n=this._pickedCorner.layerIndex,o=s.length,l=s[n===0?o-1:n-1].getCartesian(),h=s[(n+1)%o].getCartesian(),c=this._pickedCorner.getCartesian().sub(l),d=this._pickedCorner.getCartesian().sub(h),u=c.length(),g=d.length();c.normalize(),d.normalize();let f=[],p=[];for(let T=0;T<=Ie;T++){let L=c.scaleTo(T*u/Ie).addA(l);f.push(L);let M=d.scaleTo(T*g/Ie).addA(h);p.push(M)}let _=this._outlineLayer.getEntities(),v=_[n].polyline,x=_[(n+1)%o].polyline;v==null||v.setPath3v([f]),x==null||x.setPath3v([p]);let y=this._centerLayer.getEntities(),w=y[n===0?o-1:n-1],b=y[n],E=c.scaleTo(.5*u).addA(l),C=d.scaleTo(.5*g).addA(h);w.setCartesian3v(E),this._checkTerrainCollision(w),b.setCartesian3v(C),this._checkTerrainCollision(b)}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let r=0,s=ye;for(let M=0;M<i;M++){let R=t[M].getCartesian().distance(e);R<s&&(s=R,r=M)}let n=t[r].getCartesian(),o=t[(r+1)%i].getCartesian(),l=t[r===0?i-1:r-1].getCartesian().sub(n).normalize(),h=o.sub(n).normalize(),c=e.sub(n).normalize(),d=l.add(h).normalize(),u=c.cross(d),g=l.cross(h);u.dot(g)>0&&(r--,r<0&&(r=i-1));let f=new m;for(let M=0;M<i;M++)if(new Qe(t[M].getCartesian(),t[(M+1)%i].getCartesian()).getNearestDistancePoint(e,f)){let R=f.distance(e);R<s&&(s=R,r=M)}this._insertCornerIndex=(r+1)%i;let p=t[r%i].getCartesian(),_=t[(r+1)%i].getCartesian(),v=this._ghostCorner.getCartesian().sub(p),x=this._ghostCorner.getCartesian().sub(_),y=v.length(),w=x.length();v.normalize(),x.normalize();let b=[],E=[];for(let M=0;M<=Ie;M++){let R=v.scaleTo(M*y/Ie).addA(p);b.push(R);let z=x.scaleTo(M*w/Ie).addA(_);E.push(z)}let C=this._ghostOutlineLayer.getEntities(),T=C[0].polyline,L=C[1].polyline;T==null||T.setPath3v([b]),L==null||L.setPath3v([E])}}_initGhostLayerPointer(){this._ghostOutlineLayer.setEntities([new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),this._ghostCorner]);const e=this._ghostOutlineLayer;e.getEntities()[0].polyline.altitude=e.getEntities()[1].polyline.altitude=oi}}class ia extends ta{constructor(e){super(e)}get geometryType(){return"LineString"}_addNew(e){this._appendCart(e)}_appendCart(e){let t=this._cornerLayer.getEntities(),i=t[t.length-1],r=new V({geoObject:this._cornerStyle});if(r.setCartesian3v(e),r.addTo(this._cornerLayer),this._checkTerrainCollision(r),i){let s=i.getCartesian(),n=r.getCartesian().sub(s),o=n.length();n.normalize();let l=[];for(let u=0;u<=Ie;u++){let g=n.scaleTo(u*o/Ie).addA(s);l.push(g)}let h=new V({polyline:{path3v:[l],isClosed:!1,...this._outlineStyle}});h.polyline.altitude=oi,this._outlineLayer.add(h);let c=n.scaleTo(.5*o).addA(s),d=new V({geoObject:this._centerStyle});d.setCartesian3v(c),d.addTo(this._centerLayer),this._checkTerrainCollision(d)}}_clearGhostPointer(){this._ghostOutlineLayer.getEntities()[0].polyline.clear()}_moveCorner(e,t,i){let r=this._cornerLayer.getEntities();if(r.length==0)return;r.length==1&&(e=t=i=0);let s=r[e].getCartesian(),n=this._pickedCorner.getCartesian().sub(s),o=n.length();n.normalize();let l=[];for(let d=0;d<=Ie;d++){let u=n.scaleTo(d*o/Ie).addA(s);l.push(u)}let h=this._outlineLayer.getEntities()[t].polyline;h==null||h.setPath3v([l]);let c=this._centerLayer.getEntities()[i];if(c){let d=n.scaleTo(.5*o).addA(s);c.setCartesian3v(d),this._checkTerrainCollision(c)}}_moveCornerPoint(e){let t=new N(e.x,e.y).sub(this._startClick),i=this._startPos.add(t),r=this._planet.getCartesianFromPixelTerrain(i);if(r){this._pickedCorner.setCartesian3v(r);let s=this._cornerLayer.getEntities();if(s.length){let n=this._pickedCorner.layerIndex;n===0?this._moveCorner(n+1,n+1,n):(n===s.length-1||this._moveCorner(n+1,n+1,n),this._moveCorner(n-1,n,n-1))}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let r=i-1;this._insertCornerIndex=r;let s=t[r].getCartesian(),n=this._ghostCorner.getCartesian().sub(s),o=n.length();n.normalize();let l=[];for(let h=0;h<=Ie;h++){let c=n.scaleTo(h*o/Ie).addA(s);l.push(c)}this._ghostOutlineLayer.getEntities()[0].polyline.setPath3v([l])}}_initGhostLayerPointer(){this._ghostOutlineLayer.setEntities([new V({polyline:{path3v:[],isClosed:!1,...this._outlineStyle}}),this._ghostCorner]),this._ghostOutlineLayer.getEntities()[0].polyline.altitude=oi}}class ra extends ee{constructor(e={}){super(e),this._drawingScene=new ia({name:`drawingScene:${this.__id}`,cornerStyle:e.cornerStyle||{},centerStyle:e.centerStyle||{},outlineStyle:e.outlineStyle||{},fillStyle:e.fillStyle||{}})}activatePolygonDrawing(){this.deactivate(),this._drawingScene=new ta({name:`polygonDrawingScene:${this.__id}`,cornerStyle:this._drawingScene._cornerStyle,centerStyle:this._drawingScene._centerStyle,outlineStyle:this._drawingScene._outlineStyle,fillStyle:this._drawingScene._fillStyle}),this.activate()}activateLineStringDrawing(){this.deactivate(),this._drawingScene=new ia({name:`linestringDrawingScene:${this.__id}`,cornerStyle:this._drawingScene._cornerStyle,centerStyle:this._drawingScene._centerStyle,outlineStyle:this._drawingScene._outlineStyle,fillStyle:this._drawingScene._fillStyle}),this.activate()}oninit(){}onactivate(){this.planet&&this._drawingScene.bindPlanet(this.planet),this.renderer&&this.renderer.addNode(this._drawingScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._drawingScene)}}const li={ell:0,msl:1,gnd:2},Fr=.3048,Wl=1/Fr,$l=1/3.6,sa=.001*Fr,Xl=1/sa,Zl=["m","km","ft","s","h","m/s","km/h","ft/s"],na=[0,2,0,0,0,0,0,0];let me=[];function aa(a,e,t){return me[a][e](t)}function Or(a,e,t,i,r){return a?aa(e,t,i).toFixed(r||na[t]):"--"}function oa(a){return Zl[a]}me[0]=[],me[0][0]=a=>a,me[0][1]=a=>.001*a,me[0][2]=a=>a*Wl,me[2]=[],me[2][0]=a=>a*Fr,me[2][1]=a=>a*sa,me[2][2]=a=>a,me[1]=[],me[1][0]=a=>1e3*a,me[1][1]=a=>a,me[1][2]=a=>a*Xl,me[5]=[],me[5][5]=a=>a,me[5][6]=a=>3.6*a,me[5][7]=a=>3.28084*a,me[6]=[],me[6][5]=a=>a*$l,me[6][6]=a=>a;const la=Object.freeze(Object.defineProperty({__proto__:null,ELL:0,GND:2,MSL:1,_tenth:na,convert:aa,convertExt:Or,ft:2,fts:7,h:4,heightMode:li,km:1,kmh:6,m:0,ms:5,s:3,toString:oa},Symbol.toStringTag,{value:"Module"})),Ql=[`<div class="og-lat-side"></div><div class="og-lat-val"></div>
147
147
  <div class="og-lon-side"></div><div class="og-lon-val"></div>
148
148
  <div class="og-height"></div>
149
149
  <div class="og-units-height"></div>`,`<div class="og-lat-side"></div><div class="og-lat-val"></div>
150
150
  <div class="og-lon-side"></div><div class="og-lon-val"></div>
151
151
  <div class="og-height"></div>
152
- <div class="og-units-height"></div>`];class lo extends te{constructor(e={}){super(e),this._type=e.type||0,this._TYPE_FUNC=[this._SHOW_DECIMAL,this._SHOW_DEGREE],this._showFn=null,this._el=null,this._latSideEl=null,this._lonSideEl=null,this._latValEl=null,this._lonValEl=null,this._heightEl=null,this._altUnitVal=e.altitudeUnit||"m",this._heightModeVal=e.heightMode||"ell",this._altUnit=ao[this._altUnitVal],this._heightMode=hi[this._heightModeVal],this._lonLat=null,this._centerMode=!1}_SHOW_DECIMAL(e){if(e){let t=e.lat,i=e.lon;this._latSideEl.innerHTML=t>=0?"N":"S",this._lonSideEl.innerHTML=i>=0?"E":"W",this._latValEl.innerHTML=Math.abs(t).toFixed(7)+"°",this._lonValEl.innerHTML=Math.abs(i).toFixed(7)+"°"}}_SHOW_DEGREE(e){if(e){let t=e.lat,i=e.lon;this._latSideEl.innerHTML=t>=0?"N":"S",this._lonSideEl.innerHTML=i>=0?"E":"W";let s=0,r=t<0?Math.ceil(t):Math.floor(t),n=Math.floor(s=60*Math.abs(t-r)),o=Math.floor(6e3*(s-n))/100;this._latValEl.innerHTML=Math.abs(r)+"°"+n+"'"+o.toFixed(0)+'"',r=i<0?Math.ceil(i):Math.floor(i),n=Math.floor(s=60*Math.abs(i-r)),o=Math.floor(6e3*(s-n))/100,this._lonValEl.innerHTML=Math.abs(r)+"°"+n+"'"+o.toFixed(0)+'"'}}_createCenterEl(){let e=document.createElement("div");return e.className="og-center-icon",e.innerHTML='<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#337ab7"></path></g></svg>',e}_updateUnits(){this._heightMode=hi[this._heightModeVal],this._altUnit=ao[this._altUnitVal],this._el.querySelector(".og-units-height").innerHTML=oo(this._altUnit),this._showHeight()}_refreshCoordinates(){this._type>=this._TYPE_FUNC.length&&(this._type=0);let e=this._el;e.innerHTML=Ql[this._type],this._latSideEl=e.querySelector(".og-lat-side"),this._lonSideEl=e.querySelector(".og-lon-side"),this._latValEl=e.querySelector(".og-lat-val"),this._lonValEl=e.querySelector(".og-lon-val"),this._heightEl=e.querySelector(".og-height"),this._showFn=this._TYPE_FUNC[this._type],this._showFn(this._lonLat)}oninit(){this._el=document.createElement("div"),this._el.classList.add("og-coordinates"),this.renderer.div.appendChild(this._el),this._el.addEventListener("click",()=>{this._type++,this._refreshCoordinates(),this._updateUnits(),this._showHeight()}),this._centerMode?(this.renderer.div.appendChild(this._createCenterEl()),this.planet.camera.events.on("moveend",this._grabCoordinates,this),this.planet.camera.events.on("moveend",Kt(()=>this._showHeight(),400,!0),this)):(this.renderer.events.on("mousemove",this._grabCoordinates,this),this.renderer.events.on("mousestop",Kt(()=>this._showHeight(),400,!0),this)),this._refreshCoordinates(),this._updateUnits()}_grabCoordinates(e){let t,i=e.pos,s=this.renderer;t=this._centerMode?s.handler.getCenter():i,this._lonLat=this.planet.getLonLatFromPixelTerrain(t)||null,this._showFn(this._lonLat)}async _showHeight(){if(this._lonLat&&this.planet){let e=0;this._heightEl.style.opacity="0.7",this._heightMode===hi.ell?(e=await this.planet.getHeightAboveELL(this._lonLat),e=Number(Fs(!0,0,this._altUnit,e))):this._heightMode===hi.msl&&(e=await this.planet.getHeightDefault(this._lonLat),e=Number(Fs(!0,0,this._altUnit,e))),this._heightEl.style.opacity="1.0",this._heightEl.innerHTML=e.toString()}}}const Kl=["loadend"];class ci extends qe{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(Kl),this._projType=0,this._frameWidth=256,this._frameHeight=256,this._sourceReady=!1,this._sourceTexture=null,this._materialTexture=null,this._gridBufferLow=null,this._gridBufferHigh=null,this._extentWgs84ParamsHigh=new Float32Array(4),this._extentWgs84ParamsLow=new Float32Array(4),this._extentMercParamsHigh=new Float32Array(4),this._extentMercParamsLow=new Float32Array(4),this._refreshFrame=!0,this._frameCreated=!1,this._sourceCreated=!1,this._animate=!1,this._ready=!1,this._creationProceeding=!1,this._isRendering=!1,this._extentWgs84=new G,this._cornersWgs84=[],this._cornersMerc=[],this._isFullExtent=t.fullExtent?1:0,this.rendering=this._renderingProjType0.bind(this),this._onLoadend_=null,t.corners&&this.setCorners(t.corners)}get isIdle(){return super.isIdle&&this._ready}addTo(e){return this._onLoadend_=this._onLoadend.bind(this),this.events.on("loadend",this._onLoadend_,this),super.addTo(e)}_onLoadend(){this._planet&&this._planet.events.dispatch(this._planet.events.layerloadend,this)}remove(){return this.events.off("loadend",this._onLoadend_),this._onLoadend_=null,super.remove()}get instanceName(){return"BaseGeoImage"}getCornersLonLat(){let e=this._cornersWgs84;return[new A(e[0].lon,e[0].lat),new A(e[1].lon,e[1].lat),new A(e[2].lon,e[2].lat),new A(e[3].lon,e[3].lat)]}getCorners(){let e=this._cornersWgs84;return[[e[0].lon,e[0].lat],[e[1].lon,e[1].lat],[e[2].lon,e[2].lat],[e[3].lon,e[3].lat]]}setCorners(e){this.setCornersLonLat(A.join(e))}setCornersLonLat(e){this._refreshFrame=!0,this._cornersWgs84=[e[0].clone(),e[1].clone(),e[2].clone(),e[3].clone()];for(let i=0;i<this._cornersWgs84.length;i++)this._cornersWgs84[i].lat>=89.9&&(this._cornersWgs84[i].lat=89.9),this._cornersWgs84[i].lat<=-89.9&&(this._cornersWgs84[i].lat=-89.9);this._extent.setByCoordinates(this._cornersWgs84);let t=this._extent;t.southWest.lat>ue||t.northEast.lat<Ne?(this._projType=0,this.rendering=this._renderingProjType0):(this._projType=1,this.rendering=this._renderingProjType1),this._ready&&!this._creationProceeding&&this._planet._geoImageCreator.add(this)}_createFrame(){this._extentWgs84=this._extent.clone(),this._cornersMerc=[this._cornersWgs84[0].forwardMercatorEPS01(),this._cornersWgs84[1].forwardMercatorEPS01(),this._cornersWgs84[2].forwardMercatorEPS01(),this._cornersWgs84[3].forwardMercatorEPS01()],this._extentMerc=new G(this._extentWgs84.southWest.forwardMercatorEPS01(),this._extentWgs84.northEast.forwardMercatorEPS01());let e=new Float32Array(2);if(this._projType===0?(lt(this._extentWgs84.southWest.lon,e),this._extentWgs84ParamsHigh[0]=e[0],this._extentWgs84ParamsLow[0]=e[1],lt(this._extentWgs84.southWest.lat,e),this._extentWgs84ParamsHigh[1]=e[0],this._extentWgs84ParamsLow[1]=e[1],this._extentWgs84ParamsHigh[2]=2/this._extentWgs84.getWidth(),this._extentWgs84ParamsHigh[3]=2/this._extentWgs84.getHeight()):(lt(this._extentMerc.southWest.lon,e),this._extentMercParamsHigh[0]=e[0],this._extentMercParamsLow[0]=e[1],lt(this._extentMerc.southWest.lat,e),this._extentMercParamsHigh[1]=e[0],this._extentMercParamsLow[1]=e[1],this._extentMercParamsHigh[2]=2/this._extentMerc.getWidth(),this._extentMercParamsHigh[3]=2/this._extentMerc.getHeight()),this._planet){let t=this._planet.renderer.handler;t.gl.deleteTexture(this._materialTexture),this._materialTexture=t.createEmptyTexture_l(this._frameWidth,this._frameHeight);let i=this._planet._geoImageCreator.createGridBuffer(this._cornersWgs84,this._projType===1);this._gridBufferHigh=i[0],this._gridBufferLow=i[1],this._refreshFrame=!1}}abortMaterialLoading(e){this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}clear(){let e=this._planet;if(e){let t=e.renderer.handler.gl;this._creationProceeding&&e._geoImageCreator.remove(this),e._clearLayerMaterial(this),t&&(t.deleteBuffer(this._gridBufferHigh),t.deleteBuffer(this._gridBufferLow),t.deleteTexture(this._sourceTexture),this._materialTexture&&!this._materialTexture.default&&t.deleteTexture(this._materialTexture))}this._sourceTexture=null,this._materialTexture=null,this._gridBufferHigh=null,this._gridBufferLow=null,this._refreshFrame=!0,this._sourceCreated=!1,this._ready=!1,this._creationProceeding=!1}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),this._planet&&this._sourceReady&&(e?this._planet._geoImageCreator.add(this):this._planet._geoImageCreator.remove(this)))}clearMaterial(e){e.texture=null,e.isLoading=!1,e.isReady=!1}applyMaterial(e){let t,i,s=e.segment;this._ready?e.applyTexture(this._materialTexture):(e.texture=this._planet.transparentTexture,!this._creationProceeding&&this.loadMaterial(e)),this._projType===0?(t=this._extentWgs84,i=s._extent):(t=this._extentMerc,i=s.getExtentMerc());let r=t.northEast.lon-t.southWest.lon,n=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/r,(t.northEast.lat-i.northEast.lat)/n,(i.northEast.lon-i.southWest.lon)/r,(i.northEast.lat-i.southWest.lat)/n]}get getFrameWidth(){return this._frameWidth}get getFrameHeight(){return this._frameHeight}_createSourceTexture(){}_renderingProjType1(){let e=this._planet,t=e.renderer.handler,i=t.gl,s=e._geoImageCreator;this._refreshFrame&&this._createFrame(),this._createSourceTexture();let r=s._framebuffer;r.setSize(this._frameWidth,this._frameHeight),r.activate(),t.programs.geoImageTransform.activate();let n=t.programs.geoImageTransform._program,o=n.attributes,l=n.uniforms;i.disable(i.CULL_FACE),r.bindOutputTexture(this._materialTexture),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.uniform1i(l.isFullExtent,this._isFullExtent),i.bindBuffer(i.ARRAY_BUFFER,s._texCoordsBuffer),i.vertexAttribPointer(o.texCoords,2,i.UNSIGNED_SHORT,!0,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferHigh),i.vertexAttribPointer(o.cornersHigh,this._gridBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferLow),i.vertexAttribPointer(o.cornersLow,this._gridBufferLow.itemSize,i.FLOAT,!1,0,0),i.uniform4fv(l.extentParamsHigh,this._extentMercParamsHigh),i.uniform4fv(l.extentParamsLow,this._extentMercParamsLow),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._sourceTexture),i.uniform1i(l.sourceTexture,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,s._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,s._indexBuffer.numItems,i.UNSIGNED_INT,0),r.deactivate(),i.enable(i.CULL_FACE),this._ready=!0,this._creationProceeding=!1}_renderingProjType0(){let e=this._planet,t=e.renderer.handler,i=t.gl,s=e._geoImageCreator;this._refreshFrame&&this._createFrame(),this._createSourceTexture();let r=s._framebuffer;r.setSize(this._frameWidth,this._frameHeight),r.activate(),t.programs.geoImageTransform.activate();let n=t.programs.geoImageTransform._program,o=n.attributes,l=n.uniforms;i.disable(i.CULL_FACE),r.bindOutputTexture(this._materialTexture),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.bindBuffer(i.ARRAY_BUFFER,s._texCoordsBuffer),i.vertexAttribPointer(o.texCoords,2,i.UNSIGNED_SHORT,!0,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferHigh),i.vertexAttribPointer(o.cornersHigh,this._gridBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferLow),i.vertexAttribPointer(o.cornersLow,this._gridBufferLow.itemSize,i.FLOAT,!1,0,0),i.uniform4fv(l.extentParamsHigh,this._extentWgs84ParamsHigh),i.uniform4fv(l.extentParamsLow,this._extentWgs84ParamsLow),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._sourceTexture),i.uniform1i(l.sourceTexture,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,s._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,s._indexBuffer.numItems,i.UNSIGNED_INT,0),r.deactivate(),i.enable(i.CULL_FACE),this._ready=!0,this._creationProceeding=!1}}const W={MB_LEFT:0,MB_RIGHT:2,MB_MIDDLE:1,KEY_CTRL:17,KEY_ALT:18,KEY_SHIFT:16,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_PRINTSCREEN:44,KEY_A:65,KEY_D:68,KEY_E:69,KEY_Q:81,KEY_S:83,KEY_W:87,KEY_X:88,KEY_APOSTROPHE:192},Jl=["change","idle","play","pause","stop"];class eh extends be{constructor(e){super({template:He('<button title={title} class="og-layerSwitcher__layerButton">{icon}<div class="og-layerSwitcher__name">{name}</div></button>',{title:e.model.name,name:e.model.name,icon:e.model.iconSrc?`<img src="${e.model.iconSrc}" />`:""}),...e}),this._onVisibilityChange=t=>{this.el&&(this.model.getVisibility()?this.el.classList.add("og-layerSwitcher__visible"):this.el.classList.remove("og-layerSwitcher__visible"))},this._onClick=()=>{this.model.isBaseLayer()?this.model.setVisibility(!0):this.model.setVisibility(!this.model.getVisibility())},this._onDblClick=()=>{this.model.flyExtent()}}render(e){return super.render(e),this.model.events.on("visibilitychange",this._onVisibilityChange),this._onVisibilityChange(this.model),this.el.addEventListener("click",this._onClick),this.el.addEventListener("dblclick",this._onDblClick),this}remove(){super.remove(),this.model.events.off("visibilitychange",this._onVisibilityChange)}}const th=["change"];class Q extends be{constructor(e={}){super({template:He(`<div class="og-slider">
152
+ <div class="og-units-height"></div>`];class ha extends ee{constructor(e={}){super(e),this._type=e.type||0,this._TYPE_FUNC=[this._SHOW_DECIMAL,this._SHOW_DEGREE],this._showFn=null,this._el=null,this._latSideEl=null,this._lonSideEl=null,this._latValEl=null,this._lonValEl=null,this._heightEl=null,this._altUnitVal=e.altitudeUnit||"m",this._heightModeVal=e.heightMode||"ell",this._altUnit=la[this._altUnitVal],this._heightMode=li[this._heightModeVal],this._lonLat=null,this._centerMode=!1}_SHOW_DECIMAL(e){if(e){let t=e.lat,i=e.lon;this._latSideEl.innerHTML=t>=0?"N":"S",this._lonSideEl.innerHTML=i>=0?"E":"W",this._latValEl.innerHTML=Math.abs(t).toFixed(7)+"°",this._lonValEl.innerHTML=Math.abs(i).toFixed(7)+"°"}}_SHOW_DEGREE(e){if(e){let t=e.lat,i=e.lon;this._latSideEl.innerHTML=t>=0?"N":"S",this._lonSideEl.innerHTML=i>=0?"E":"W";let r=0,s=t<0?Math.ceil(t):Math.floor(t),n=Math.floor(r=60*Math.abs(t-s)),o=Math.floor(6e3*(r-n))/100;this._latValEl.innerHTML=Math.abs(s)+"°"+n+"'"+o.toFixed(0)+'"',s=i<0?Math.ceil(i):Math.floor(i),n=Math.floor(r=60*Math.abs(i-s)),o=Math.floor(6e3*(r-n))/100,this._lonValEl.innerHTML=Math.abs(s)+"°"+n+"'"+o.toFixed(0)+'"'}}_createCenterEl(){let e=document.createElement("div");return e.className="og-center-icon",e.innerHTML='<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#337ab7"></path></g></svg>',e}_updateUnits(){this._heightMode=li[this._heightModeVal],this._altUnit=la[this._altUnitVal],this._el.querySelector(".og-units-height").innerHTML=oa(this._altUnit),this._showHeight()}_refreshCoordinates(){this._type>=this._TYPE_FUNC.length&&(this._type=0);let e=this._el;e.innerHTML=Ql[this._type],this._latSideEl=e.querySelector(".og-lat-side"),this._lonSideEl=e.querySelector(".og-lon-side"),this._latValEl=e.querySelector(".og-lat-val"),this._lonValEl=e.querySelector(".og-lon-val"),this._heightEl=e.querySelector(".og-height"),this._showFn=this._TYPE_FUNC[this._type],this._showFn(this._lonLat)}oninit(){this._el=document.createElement("div"),this._el.classList.add("og-coordinates"),this.renderer.div.appendChild(this._el),this._el.addEventListener("click",()=>{this._type++,this._refreshCoordinates(),this._updateUnits(),this._showHeight()}),this._centerMode?(this.renderer.div.appendChild(this._createCenterEl()),this.planet.camera.events.on("moveend",this._grabCoordinates,this),this.planet.camera.events.on("moveend",Qt(()=>this._showHeight(),400,!0),this)):(this.renderer.events.on("mousemove",this._grabCoordinates,this),this.renderer.events.on("mousestop",Qt(()=>this._showHeight(),400,!0),this)),this._refreshCoordinates(),this._updateUnits()}_grabCoordinates(e){let t,i=e.pos,r=this.renderer;t=this._centerMode?r.handler.getCenter():i,this._lonLat=this.planet.getLonLatFromPixelTerrain(t)||null,this._showFn(this._lonLat)}async _showHeight(){if(this._lonLat&&this.planet){let e=0;this._heightEl.style.opacity="0.7",this._heightMode===li.ell?(e=await this.planet.getHeightAboveELL(this._lonLat),e=Number(Or(!0,0,this._altUnit,e))):this._heightMode===li.msl&&(e=await this.planet.getHeightDefault(this._lonLat),e=Number(Or(!0,0,this._altUnit,e))),this._heightEl.style.opacity="1.0",this._heightEl.innerHTML=e.toString()}}}const Kl=["loadend"];class hi extends Ye{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(Kl),this._projType=0,this._frameWidth=256,this._frameHeight=256,this._sourceReady=!1,this._sourceTexture=null,this._materialTexture=null,this._gridBufferLow=null,this._gridBufferHigh=null,this._extentWgs84ParamsHigh=new Float32Array(4),this._extentWgs84ParamsLow=new Float32Array(4),this._extentMercParamsHigh=new Float32Array(4),this._extentMercParamsLow=new Float32Array(4),this._refreshFrame=!0,this._frameCreated=!1,this._sourceCreated=!1,this._animate=!1,this._ready=!1,this._creationProceeding=!1,this._isRendering=!1,this._extentWgs84=new j,this._cornersWgs84=[],this._cornersMerc=[],this._isFullExtent=t.fullExtent?1:0,this.rendering=this._renderingProjType0.bind(this),this._onLoadend_=null,t.corners&&this.setCorners(t.corners)}get isIdle(){return super.isIdle&&this._ready}addTo(e){return this._onLoadend_=this._onLoadend.bind(this),this.events.on("loadend",this._onLoadend_,this),super.addTo(e)}_onLoadend(){this._planet&&this._planet.events.dispatch(this._planet.events.layerloadend,this)}remove(){return this.events.off("loadend",this._onLoadend_),this._onLoadend_=null,super.remove()}get instanceName(){return"BaseGeoImage"}getCornersLonLat(){let e=this._cornersWgs84;return[new A(e[0].lon,e[0].lat),new A(e[1].lon,e[1].lat),new A(e[2].lon,e[2].lat),new A(e[3].lon,e[3].lat)]}getCorners(){let e=this._cornersWgs84;return[[e[0].lon,e[0].lat],[e[1].lon,e[1].lat],[e[2].lon,e[2].lat],[e[3].lon,e[3].lat]]}setCorners(e){this.setCornersLonLat(A.join(e))}setCornersLonLat(e){this._refreshFrame=!0,this._cornersWgs84=[e[0].clone(),e[1].clone(),e[2].clone(),e[3].clone()];for(let i=0;i<this._cornersWgs84.length;i++)this._cornersWgs84[i].lat>=89.9&&(this._cornersWgs84[i].lat=89.9),this._cornersWgs84[i].lat<=-89.9&&(this._cornersWgs84[i].lat=-89.9);this._extent.setByCoordinates(this._cornersWgs84);let t=this._extent;t.southWest.lat>de||t.northEast.lat<Oe?(this._projType=0,this.rendering=this._renderingProjType0):(this._projType=1,this.rendering=this._renderingProjType1),this._ready&&!this._creationProceeding&&this._planet._geoImageCreator.add(this)}_createFrame(){this._extentWgs84=this._extent.clone(),this._cornersMerc=[this._cornersWgs84[0].forwardMercatorEPS01(),this._cornersWgs84[1].forwardMercatorEPS01(),this._cornersWgs84[2].forwardMercatorEPS01(),this._cornersWgs84[3].forwardMercatorEPS01()],this._extentMerc=new j(this._extentWgs84.southWest.forwardMercatorEPS01(),this._extentWgs84.northEast.forwardMercatorEPS01());let e=new Float32Array(2);if(this._projType===0?(lt(this._extentWgs84.southWest.lon,e),this._extentWgs84ParamsHigh[0]=e[0],this._extentWgs84ParamsLow[0]=e[1],lt(this._extentWgs84.southWest.lat,e),this._extentWgs84ParamsHigh[1]=e[0],this._extentWgs84ParamsLow[1]=e[1],this._extentWgs84ParamsHigh[2]=2/this._extentWgs84.getWidth(),this._extentWgs84ParamsHigh[3]=2/this._extentWgs84.getHeight()):(lt(this._extentMerc.southWest.lon,e),this._extentMercParamsHigh[0]=e[0],this._extentMercParamsLow[0]=e[1],lt(this._extentMerc.southWest.lat,e),this._extentMercParamsHigh[1]=e[0],this._extentMercParamsLow[1]=e[1],this._extentMercParamsHigh[2]=2/this._extentMerc.getWidth(),this._extentMercParamsHigh[3]=2/this._extentMerc.getHeight()),this._planet){let t=this._planet.renderer.handler;t.gl.deleteTexture(this._materialTexture),this._materialTexture=t.createEmptyTexture_l(this._frameWidth,this._frameHeight);let i=this._planet._geoImageCreator.createGridBuffer(this._cornersWgs84,this._projType===1);this._gridBufferHigh=i[0],this._gridBufferLow=i[1],this._refreshFrame=!1}}abortMaterialLoading(e){this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}clear(){let e=this._planet;if(e){let t=e.renderer.handler.gl;this._creationProceeding&&e._geoImageCreator.remove(this),e._clearLayerMaterial(this),t&&(t.deleteBuffer(this._gridBufferHigh),t.deleteBuffer(this._gridBufferLow),t.deleteTexture(this._sourceTexture),this._materialTexture&&!this._materialTexture.default&&t.deleteTexture(this._materialTexture))}this._sourceTexture=null,this._materialTexture=null,this._gridBufferHigh=null,this._gridBufferLow=null,this._refreshFrame=!0,this._sourceCreated=!1,this._ready=!1,this._creationProceeding=!1}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),this._planet&&this._sourceReady&&(e?this._planet._geoImageCreator.add(this):this._planet._geoImageCreator.remove(this)))}clearMaterial(e){e.texture=null,e.isLoading=!1,e.isReady=!1}applyMaterial(e){let t,i,r=e.segment;this._ready?e.applyTexture(this._materialTexture):(e.texture=this._planet.transparentTexture,!this._creationProceeding&&this.loadMaterial(e)),this._projType===0?(t=this._extentWgs84,i=r._extent):(t=this._extentMerc,i=r.getExtentMerc());let s=t.northEast.lon-t.southWest.lon,n=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/s,(t.northEast.lat-i.northEast.lat)/n,(i.northEast.lon-i.southWest.lon)/s,(i.northEast.lat-i.southWest.lat)/n]}get getFrameWidth(){return this._frameWidth}get getFrameHeight(){return this._frameHeight}_createSourceTexture(){}_renderingProjType1(){let e=this._planet,t=e.renderer.handler,i=t.gl,r=e._geoImageCreator;this._refreshFrame&&this._createFrame(),this._createSourceTexture();let s=r._framebuffer;s.setSize(this._frameWidth,this._frameHeight),s.activate(),t.programs.geoImageTransform.activate();let n=t.programs.geoImageTransform._program,o=n.attributes,l=n.uniforms;i.disable(i.CULL_FACE),s.bindOutputTexture(this._materialTexture),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.uniform1i(l.isFullExtent,this._isFullExtent),i.bindBuffer(i.ARRAY_BUFFER,r._texCoordsBuffer),i.vertexAttribPointer(o.texCoords,2,i.UNSIGNED_SHORT,!0,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferHigh),i.vertexAttribPointer(o.cornersHigh,this._gridBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferLow),i.vertexAttribPointer(o.cornersLow,this._gridBufferLow.itemSize,i.FLOAT,!1,0,0),i.uniform4fv(l.extentParamsHigh,this._extentMercParamsHigh),i.uniform4fv(l.extentParamsLow,this._extentMercParamsLow),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._sourceTexture),i.uniform1i(l.sourceTexture,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,r._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,r._indexBuffer.numItems,i.UNSIGNED_INT,0),s.deactivate(),i.enable(i.CULL_FACE),this._ready=!0,this._creationProceeding=!1}_renderingProjType0(){let e=this._planet,t=e.renderer.handler,i=t.gl,r=e._geoImageCreator;this._refreshFrame&&this._createFrame(),this._createSourceTexture();let s=r._framebuffer;s.setSize(this._frameWidth,this._frameHeight),s.activate(),t.programs.geoImageTransform.activate();let n=t.programs.geoImageTransform._program,o=n.attributes,l=n.uniforms;i.disable(i.CULL_FACE),s.bindOutputTexture(this._materialTexture),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.bindBuffer(i.ARRAY_BUFFER,r._texCoordsBuffer),i.vertexAttribPointer(o.texCoords,2,i.UNSIGNED_SHORT,!0,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferHigh),i.vertexAttribPointer(o.cornersHigh,this._gridBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._gridBufferLow),i.vertexAttribPointer(o.cornersLow,this._gridBufferLow.itemSize,i.FLOAT,!1,0,0),i.uniform4fv(l.extentParamsHigh,this._extentWgs84ParamsHigh),i.uniform4fv(l.extentParamsLow,this._extentWgs84ParamsLow),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._sourceTexture),i.uniform1i(l.sourceTexture,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,r._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,r._indexBuffer.numItems,i.UNSIGNED_INT,0),s.deactivate(),i.enable(i.CULL_FACE),this._ready=!0,this._creationProceeding=!1}}const W={MB_LEFT:0,MB_RIGHT:2,MB_MIDDLE:1,KEY_CTRL:17,KEY_ALT:18,KEY_SHIFT:16,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_PRINTSCREEN:44,KEY_A:65,KEY_D:68,KEY_E:69,KEY_Q:81,KEY_S:83,KEY_W:87,KEY_X:88,KEY_APOSTROPHE:192},Jl=["change","idle","play","pause","stop"];class eh extends be{constructor(e){super({template:Ne('<button title={title} class="og-layerSwitcher__layerButton">{icon}<div class="og-layerSwitcher__name">{name}</div></button>',{title:e.model.name,name:e.model.name,icon:e.model.iconSrc?`<img src="${e.model.iconSrc}" />`:""}),...e}),this._onVisibilityChange=t=>{this.el&&(this.model.getVisibility()?this.el.classList.add("og-layerSwitcher__visible"):this.el.classList.remove("og-layerSwitcher__visible"))},this._onClick=()=>{this.model.isBaseLayer()?this.model.setVisibility(!0):this.model.setVisibility(!this.model.getVisibility())},this._onDblClick=()=>{this.model.flyExtent()}}render(e){return super.render(e),this.model.events.on("visibilitychange",this._onVisibilityChange),this._onVisibilityChange(this.model),this.el.addEventListener("click",this._onClick),this.el.addEventListener("dblclick",this._onDblClick),this}remove(){super.remove(),this.model.events.off("visibilitychange",this._onVisibilityChange)}}const th=["change"];class Q extends be{constructor(e={}){super({template:Ne(`<div class="og-slider">
153
153
  <div class="og-slider-label">{label}</div>
154
154
  <div class="og-slider-panel">
155
155
  <div class="og-slider-progress"></div>
156
156
  <div class="og-slider-pointer"></div>
157
157
  </div>
158
158
  <input type="number"/>
159
- </div>`,{label:e.label||""})}),this._onResize=()=>{this._setOffset((this._value-this._min)*this.$panel.clientWidth/(this._max-this._min))},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this.value=this._value+Math.sign(t.wheelDelta)*(this._max-this._min)/100},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onInput=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this.value=parseFloat(t.target.value)},this._onMouseDown=t=>{(t=t||window.event).preventDefault(),this._startPosX=t.clientX,this.value=this._min+(this._max-this._min)*(t.offsetX/this.$panel.clientWidth),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp)},this._onMouseMove=t=>{(t=t||window.event).preventDefault(),t.stopPropagation();let i=this.$panel.getBoundingClientRect(),s=Si(t.clientX,i.left,i.right),r=this._startPosX-s;this._startPosX=s,this.value=this._value-r*(this._max-this._min)/this.$panel.clientWidth},this._onMouseUp=()=>{document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove)},this.events=this.events.registerNames(th),this._value=e.value||0,this._min=e.min||0,this._max=e.max||1,this._resizeObserver=new ResizeObserver(this._onResize),this._startPosX=0,this.$label=null,this.$pointer=null,this.$progress=null,this.$input=null,this.$panel=null}render(e){return super.render(e),this.$label=this.select(".og-slider-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$pointer=this.select(".og-slider-pointer"),this.$progress=this.select(".og-slider-progress"),this.$panel=this.select(".og-slider-panel"),this.$input=this.select("input"),this._resizeObserver.observe(this.el),this._initEvents(),this}set value(e){e!==this._value&&(this._value=Si(e,this._min,this._max),this.$input.value=this._value.toString(),this._setOffset((this._value-this._min)*this.$panel.clientWidth/(this._max-this._min)),this.events.dispatch(this.events.change,this._value,this))}get value(){return this._value}_initEvents(){this.$panel.addEventListener("mousedown",this._onMouseDown),this.$panel.addEventListener("mousewheel",this._onMouseWheel),this.$panel.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.$panel.removeEventListener("mousedown",this._onMouseDown),this.$panel.removeEventListener("mousewheel",this._onMouseWheel),this.$panel.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("input",this._onInput)}_setOffset(e){e>=0&&e<=this.$panel.clientWidth&&(this.$pointer.style.left=this.$progress.style.width=100*e/this.$panel.clientWidth+"%")}remove(){this._clearEvents(),super.remove()}}const ih=["input"];let sh=0;class ho extends be{constructor(e={}){super({template:He(`<div class="og-color">
159
+ </div>`,{label:e.label||""})}),this._onResize=()=>{this._setOffset((this._value-this._min)*this.$panel.clientWidth/(this._max-this._min))},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this.value=this._value+Math.sign(t.wheelDelta)*(this._max-this._min)/100},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onInput=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this.value=parseFloat(t.target.value)},this._onMouseDown=t=>{(t=t||window.event).preventDefault(),this._startPosX=t.clientX,this.value=this._min+(this._max-this._min)*(t.offsetX/this.$panel.clientWidth),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp)},this._onMouseMove=t=>{(t=t||window.event).preventDefault(),t.stopPropagation();let i=this.$panel.getBoundingClientRect(),r=Si(t.clientX,i.left,i.right),s=this._startPosX-r;this._startPosX=r,this.value=this._value-s*(this._max-this._min)/this.$panel.clientWidth},this._onMouseUp=()=>{document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove)},this.events=this.events.registerNames(th),this._value=e.value||0,this._min=e.min||0,this._max=e.max||1,this._resizeObserver=new ResizeObserver(this._onResize),this._startPosX=0,this.$label=null,this.$pointer=null,this.$progress=null,this.$input=null,this.$panel=null}render(e){return super.render(e),this.$label=this.select(".og-slider-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$pointer=this.select(".og-slider-pointer"),this.$progress=this.select(".og-slider-progress"),this.$panel=this.select(".og-slider-panel"),this.$input=this.select("input"),this._resizeObserver.observe(this.el),this._initEvents(),this}set value(e){e!==this._value&&(this._value=Si(e,this._min,this._max),this.$input.value=this._value.toString(),this._setOffset((this._value-this._min)*this.$panel.clientWidth/(this._max-this._min)),this.events.dispatch(this.events.change,this._value,this))}get value(){return this._value}_initEvents(){this.$panel.addEventListener("mousedown",this._onMouseDown),this.$panel.addEventListener("mousewheel",this._onMouseWheel),this.$panel.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.$panel.removeEventListener("mousedown",this._onMouseDown),this.$panel.removeEventListener("mousewheel",this._onMouseWheel),this.$panel.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("input",this._onInput)}_setOffset(e){e>=0&&e<=this.$panel.clientWidth&&(this.$pointer.style.left=this.$progress.style.width=100*e/this.$panel.clientWidth+"%")}remove(){this._clearEvents(),super.remove()}}const ih=["input"];let rh=0;class ca extends be{constructor(e={}){super({template:Ne(`<div class="og-color">
160
160
  <label for="{id}" class="og-color-label">{label}</label>
161
161
  <input type="color" name="{id}" value="{value}"/>
162
- </div>`,{id:"color-"+sh++,label:e.label||"",value:e.value||"#000000"})}),this._onInput=t=>{this.value=t.target.value},this.events=this.events.registerNames(ih),this._value=e.value||"blue",this.$label=null,this.$input=null}render(e){return super.render(e),this.$label=this.select(".og-color-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this._initEvents(),this}set value(e){e!==this._value&&(this._value=e,this.$input.value=this._value,this.events.dispatch(this.events.input,this._value,this))}get value(){return this._value}_initEvents(){this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.$input.removeEventListener("input",this._onInput)}remove(){this._clearEvents(),super.remove()}}class Os{constructor(){this._lock=0}lock(e){this._lock|=1<<e.id}free(e){this._lock&=~(1<<e.id)}isFree(){return this._lock===0}isLocked(){return this._lock!==0}}const co=class qa{constructor(){this.__id=qa.__counter__++}get id(){return this.__id}};co.__counter__=0;let di=co;class Ns extends te{constructor(e={}){super(e),this._deactivate=!1,this._shiftBusy=!1,this._name="mouseNavigation",this.grabbedPoint=new v,this._eye0=new v,this.pointOnEarth=new v,this.earthUp=new v,this.inertia=.007,this.grabbedSpheroid=new Ve,this.qRot=new O,this.scaleRot=0,this.distDiff=.3,this.stepsCount=8,this.stepsForward=null,this.stepIndex=0,this._lmbDoubleClickActive=!0,this.minSlope=e.minSlope||.1,this._wheelDirection=1,this._keyLock=new di}static getMovePointsFromPixelTerrain(e,t,i,s,r,n,o){const l=[];let h=e.eye.clone(),c=e.getBackward(),d=e.getRight(),u=e.getUp(),g=t.getCartesianFromPixelTerrain(r);if(g||(g=t.getCartesianFromPixelTerrain(t.renderer.handler.getCenter())),g){o||(o=v.sub(g,e.eye).normalize());let f=s*e.eye.distance(g)/i;f*=n?-1.25:2;const p=c.scaleTo(f);if(o.dot(e.eye.normal().negate())>=.1){const _=new Ve;_.radius=g.length();let m=[],y=[],x=!1;for(let w=0;w<i;w++){h.addA(p);const b=new U(h,o).hitSphere(_);if(y[w]=h.clone(),!b){x=!0;break}m[w]=new ne().rotateBetweenVectors(g.normal(),b.normal())}if(x){h=e.eye.clone();for(let w=0;w<i;w++)l[w]={eye:h.addA(p).clone(),v:u,u:d,n:c}}else for(let w=0;w<i;w++){let b=m[w];l[w]={eye:b.mulVec3(y[w]),v:b.mulVec3(u),u:b.mulVec3(d),n:b.mulVec3(c)}}}else for(let _=0;_<i;_++)l[_]={eye:h.addA(o.scaleTo(-f)).clone(),v:u,u:d,n:c};return l}}onactivate(){this.renderer&&(this.renderer.events.on("mousewheel",this.onMouseWheel,this),this.renderer.events.on("lhold",this.onMouseLeftButtonDown,this),this.renderer.events.on("rhold",this.onMouseRightButtonDown,this),this.renderer.events.on("ldown",this.onMouseLeftButtonClick,this),this.renderer.events.on("lup",this.onMouseLeftButtonUp,this),this.renderer.events.on("rdown",this.onMouseRightButtonClick,this),this.renderer.events.on("draw",this.onDraw,this,-1e3),this.renderer.events.on("mousemove",this.onMouseMove,this),this.renderer.events.on("mouseleave",this.onMouseLeave,this),this.renderer.events.on("mouseenter",this.onMouseEnter,this),this._lmbDoubleClickActive&&this.renderer.events.on("ldblclick",this.onMouseLeftButtonDoubleClick,this))}ondeactivate(){this.renderer&&(this.renderer.events.off("mousewheel",this.onMouseWheel),this.renderer.events.off("lhold",this.onMouseLeftButtonDown),this.renderer.events.off("rhold",this.onMouseRightButtonDown),this.renderer.events.off("ldown",this.onMouseLeftButtonClick),this.renderer.events.off("lup",this.onMouseLeftButtonUp),this.renderer.events.off("rdown",this.onMouseRightButtonClick),this.renderer.events.off("draw",this.onDraw),this.renderer.events.off("ldblclick",this.onMouseLeftButtonDoubleClick),this.renderer.events.off("mouseleave",this.onMouseLeave),this.renderer.events.off("mouseenter",this.onMouseEnter))}activateDoubleClickZoom(){this._lmbDoubleClickActive||(this._lmbDoubleClickActive=!0,this.renderer&&this.renderer.events.on("ldblclick",this.onMouseLeftButtonDoubleClick,this))}deactivateDoubleClickZoom(){this._lmbDoubleClickActive&&(this._lmbDoubleClickActive=!1,this.renderer&&this.renderer.events.off("ldblclick",this.onMouseLeftButtonDoubleClick))}onMouseEnter(e){const t=this.renderer.events;t.isKeyPressed(W.KEY_ALT)&&t.releaseKeys(),t.updateButtonsStates(e.sys.buttons),t.mouseState.leftButtonDown?this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"):this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")}onMouseLeave(){this.renderer.events.mouseState.leftButtonDown&&(this.scaleRot=0),this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")}onMouseWheel(e){this.stepIndex||(this.planet.stopFlying(),this.stopRotation(),this._deactivate=!0,this.lockPlanet(!0),this.stepsForward=Ns.getMovePointsFromPixelTerrain(this.planet.camera,this.planet,this.stepsCount,this.distDiff,e.pos,e.wheelDelta>0,e.direction)||null,this._wheelDirection=e.wheelDelta,this.stepsForward&&(this.stepIndex=this.stepsCount))}oninit(){this.activate(),this.renderer&&(this.renderer.events.on("keyfree",W.KEY_ALT,this.onShiftFree,this),this.renderer.events.on("keyfree",W.KEY_PRINTSCREEN,this.onShiftFree,this))}onMouseLeftButtonDoubleClick(e){this.planet.stopFlying(),this.stopRotation();const t=this.planet.getCartesianFromPixelTerrain(e.pos);if(t){const i=this.planet.camera;let s=i.maxAltitude+this.planet.ellipsoid.polarSize,r=i.minAltitude+this.planet.ellipsoid.polarSize;const n=i.eye.length(),o=this.planet.ellipsoid.cartesianToLonLat(t);if(n>s||n<r)return void this.planet.flyLonLat(new A(o.lon,o.lat));this.renderer.events.isKeyPressed(W.KEY_ALT)?this.planet.flyLonLat(new A(o.lon,o.lat,2*i.eye.distance(t))):this.planet.flyLonLat(new A(o.lon,o.lat,.57*i.eye.distance(t)))}}onMouseLeftButtonClick(){this._active&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this.grabbedPoint=this.planet.getCartesianFromMouseTerrain(),this.grabbedPoint&&(this._eye0.copy(this.planet.camera.eye),this.grabbedSpheroid.radius=this.grabbedPoint.length(),this.stopRotation()))}stopRotation(){this.qRot.clear(),this.freePlanet()}onMouseLeftButtonUp(e){this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.x===e.prev_x&&e.y===e.prev_y&&(this.scaleRot=0)}onMouseLeftButtonDown(e){if(this._active){if(!this.grabbedPoint)return;if(this.planet.stopFlying(),e.moving){let t=this.planet.camera;if(t.slope>.2){const i=new U(t.eye,e.direction).hitSphere(this.grabbedSpheroid);if(i){this.scaleRot=1,this.qRot=O.getRotationBetweenVectors(i.normal(),this.grabbedPoint.normal());let s=this.qRot;t.eye=s.mulVec3(t.eye),t.rotate(s)}}else{let i=this.grabbedPoint,s=v.add(i,t.getRight()),r=v.add(i,i.normal()),n=new v;new U(t.eye,e.direction).hitPlaneRes(Pe.fromPoints(i,s,r),n)===U.INSIDE&&(t.eye=this._eye0.addA(n.subA(i).negate()))}}}}onMouseRightButtonClick(e){this.stopRotation(),this.planet.stopFlying(),this.pointOnEarth=this.planet.getCartesianFromPixelTerrain(e.pos),this.pointOnEarth&&(this.earthUp=this.pointOnEarth.normal())}onMouseRightButtonDown(e){const t=this.planet.camera;if(this.pointOnEarth&&e.moving){this.renderer.controlsBag.scaleRot=1;let i=.5/t.eye.distance(this.pointOnEarth)*t._lonLat.height*j;i>.007?i=.007:i<.003&&(i=.003),t.rotateHorizontal(i*(e.x-e.prev_x),!1,this.pointOnEarth,this.earthUp),t.rotateVertical(i*(e.y-e.prev_y),this.pointOnEarth,this.minSlope)}}onShiftFree(){this._shiftBusy=!1}onMouseMove(e){this._active&&this.renderer.events.isKeyPressed(W.KEY_ALT)&&(this._shiftBusy||(this._shiftBusy=!0,this.onMouseRightButtonClick(e)),this.onMouseRightButtonDown(e))}onDraw(){if(this._active){const e=this.renderer,t=this.planet.camera;let i=t.eye.clone();if(this.stepIndex){e.controlsBag.scaleRot=1;const s=this.stepsForward[this.stepsCount-this.stepIndex--];t.eye=s.eye,t._u=s.v,t._r=s.u,t._b=s.n,t._f.set(-t._b.x,-t._b.y,-t._b.z)}else this._deactivate&&(this._deactivate=!1,this.freePlanet());if(e.events.mouseState.leftButtonDown||!this.scaleRot)return;if(this.scaleRot-=this.inertia,this.scaleRot<=0)this.scaleRot=0;else{e.controlsBag.scaleRot=this.scaleRot;let s=this.qRot.slerp(O.IDENTITY,1-this.scaleRot*this.scaleRot*this.scaleRot).normalize();s.x||s.y||s.z||(this.scaleRot=0),t.eye=s.mulVec3(t.eye),t.rotate(s)}t.eye.distance(i)/t.getAltitude()>.01?this.lockPlanet():this.freePlanet()}}lockPlanet(e){this.planet.layerLock.lock(this._keyLock),!e&&this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock)}freePlanet(){this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}}const rh=["drag","zoom","rotate"],qi=.96;class uo extends te{constructor(e={}){super({name:"mouseNavigation",autoActivate:!0,...e}),this._shiftBusy=!1,this._hold=!1,this._prevVel=new v,this._screenPosIsChanged=!0,this._onShiftFree=()=>{this._shiftBusy=!1},this._onCameraFly=()=>{this.stop()},this._onMouseMove=t=>{this._active&&this.renderer.events.isKeyPressed(W.KEY_ALT)&&(this._shiftBusy||(this._shiftBusy=!0,this._onRHold(t)),this._onRDown(t))},this._onMouseEnter=t=>{const i=this.renderer.events;i.isKeyPressed(W.KEY_ALT)&&i.releaseKeys(),i.updateButtonsStates(t.sys.buttons),i.mouseState.leftButtonDown?this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"):this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this._onMouseLeave=()=>{this.renderer.events.mouseState.leftButtonDown&&this.vel.scale(0),this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this._onRHold=t=>{this._targetRotationPoint&&(this._velInertia=.6,this.force_h=.5*(t.x-t.prev_x),this.force_v=.5*(t.y-t.prev_y))},this._onRDown=t=>{this.planet&&(this.planet.stopFlying(),this._targetRotationPoint=this._getTargetPoint(t.pos),this._targetRotationPoint&&(this._targetZoomPoint=null,this._targetDragPoint=null,this.vel.set(0,0,0),this._tUp=this._targetRotationPoint.getNormal(),this._tRad=this.planet.camera.eye.distance(this._targetRotationPoint)))},this._onMouseWheel=t=>{if(this.planet){this._targetRotationPoint=null,this._targetDragPoint=null;let i=this._getTargetPoint(t.pos);if(!i)return;this._targetZoomPoint=i,this._grabbedSphere.radius=this._targetZoomPoint.length();let s=this.planet.camera;if(this._curPitch=s.getPitch(),this._curYaw=s.getYaw(),this._curRoll=s.getRoll(),Math.sign(t.wheelDelta)!==this._wheelDirection)return this.vel.scale(.3),this._currScreenPos.set(t.x,t.y),void(this._wheelDirection=Math.sign(t.wheelDelta));this._currScreenPos.set(t.x,t.y),this._wheelDirection=Math.sign(t.wheelDelta);let r=20;this._velInertia=.83,this._isTouchPad=t.isTouchPad,t.isTouchPad&&(this._velInertia=.63,r=17);let n=this._targetZoomPoint.sub(s.eye);n.length()>6e3&&this._wheelDirection>0&&s.eye.getNormal().negate().dot(n.normalize())<.3&&(this.fixedUp=!1,r=4.3);let o=this.planet.camera.eye.distance(this._targetZoomPoint)*r;this.force=t.direction.scale(this._wheelDirection).normalize().scale(this._wheelDirection<0?1.3*o:o).scale(this.zoomSpeed),this.vel.set(0,0,0),this.force_roll=this._curRoll}},this._onLDown=t=>{this.stop(),this._targetRotationPoint=null,this._targetZoomPoint=null,this.planet&&(this.planet.stopFlying(),this._grabbedPoint=this._getTargetPoint(t.pos),this._grabbedPoint&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this._grabbedSphere.radius=this._grabbedPoint.length(),this._eye0=this.planet.camera.eye.clone(),this._grabbedCameraHeight=this._eye0.length(),this._curPitch=this.planet.camera.getPitch(),this._curYaw=this.planet.camera.getYaw(),this._curRoll=this.planet.camera.getRoll(),this._currScreenPos.copy(t.pos),this.planet.camera.getUp().dot(new v(0,0,1))>.3&&(this.fixedUp=!0)))},this._onLHold=t=>{if(this._grabbedPoint&&this.planet){let i=this.planet.camera;if(i.slope>.35){let s=new U(i.eye,t.direction).hitSphere(this._grabbedSphere);if(!s)return;this._targetDragPoint=s;let r=new v,n=O.getRotationBetweenVectors(this._targetDragPoint.getNormal(),this._grabbedPoint.getNormal());r.copy(n.mulVec3(i.eye)),this.force=r.sub(i.eye).scale(this.dragInertia)}else{let s=this._grabbedPoint,r=v.add(s,i.getRight()),n=v.add(s,s.getNormal()),o=new v;new U(i.eye,t.direction).hitPlaneRes(Pe.fromPoints(s,r,n),o);let l=i.eye.add(o.subA(s).negate());this.force=l.sub(i.eye).scale(this.dragInertia),this._targetDragPoint=o}this.vel.set(0,0,0),this._currScreenPos.equal(t.pos)||(this._screenPosIsChanged=!0,this._currScreenPos.copy(t.pos)),this._hold=!0}},this._onLUp=t=>{this._hold=!1,this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this.events=he(rh,this),this.force=new v,this.force_h=0,this.force_v=0,this.vel=new v,this.vel_h=0,this.vel_v=0,this.vel_roll=0,this.force_roll=0,this.mass=e.mass!=null?e.mass:1,this.inertia=e.inertia!=null?e.inertia:1,this._velInertia=qi,this.minSlope=e.minSlope!=null?e.minSlope:.35,this.dragInertia=e.dragInertia!=null?e.dragInertia:170,this.zoomSpeed=e.zoomSpeed!=null?e.zoomSpeed:1,this._lookPos=void 0,this._grabbedPoint=null,this._targetZoomPoint=null,this._targetDragPoint=null,this._targetRotationPoint=null,this._tUp=new v,this._tRad=0,this._rotHDir=0,this._rotVDir=0,this._wheelDirection=1,this._currScreenPos=new N,this._grabbedSphere=new Ve,this.fixedUp=e.fixedUp==null||e.fixedUp,this._rot=new O,this._curPitch=0,this._curYaw=0,this._curRoll=0,this._eye0=new v,this._newEye=new v,this._grabbedCameraHeight=0,this._isTouchPad=!1}oninit(){this.renderer&&(this.renderer.events.on("keyfree",W.KEY_ALT,this._onShiftFree),this.renderer.events.on("keyfree",W.KEY_PRINTSCREEN,this._onShiftFree))}onadd(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.on("flystart",this._onCameraFly)}onremove(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.off("flystart",this._onCameraFly)}onactivate(){super.onactivate();let e=this.renderer;e.events.on("mousewheel",this._onMouseWheel),e.events.on("rhold",this._onRHold),e.events.on("rdown",this._onRDown),e.events.on("lhold",this._onLHold),e.events.on("ldown",this._onLDown),e.events.on("lup",this._onLUp),e.events.on("draw",this.onDraw,this,-1e3),e.events.on("mousemove",this._onMouseMove),e.events.on("mouseleave",this._onMouseLeave),e.events.on("mouseenter",this._onMouseEnter)}ondeactivate(){super.ondeactivate();let e=this.renderer;e.events.off("mousewheel",this._onMouseWheel),e.events.off("rhold",this._onRHold),e.events.off("rdown",this._onRDown),e.events.off("lhold",this._onLHold),e.events.off("ldown",this._onLDown),e.events.off("lup",this._onLUp),e.events.off("draw",this.onDraw),e.events.off("mousemove",this._onMouseMove),e.events.off("mouseleave",this._onMouseLeave),e.events.off("mouseenter",this._onMouseEnter)}onDraw(){this._updateVel(),this._handleZoom(),this._handleDrag(),this._handleRotation()}_handleRotation(){if(this.planet&&this._targetRotationPoint){let e=this.planet.camera;if(this.vel_h===0&&this.vel_v===0)return;let t=this.vel_h*this.dt,i=this.vel_v*this.dt;e.rotateHorizontal(t,!1,this._targetRotationPoint,this._tUp),e.rotateVertical(i,this._targetRotationPoint,.1),this.events.dispatch(this.events.rotate,this),this._curPitch=e.getPitch(),this._curYaw=e.getYaw(),this._curRoll=e.getRoll(),this._velInertia=qi}}_getTargetPoint(e){return this.planet?this.planet.camera.getAltitude()>8e4?this.planet.getCartesianFromPixelEllipsoid(e)||null:this.planet.getCartesianFromPixelTerrain(e)||null:null}_handleDrag(){if(this.planet&&this._targetDragPoint&&this._grabbedPoint&&this.vel.length()>.1){this._velInertia=qi;let e=this.planet.camera;if(Math.abs(e.eyeNorm.dot(v.NORTH))>.9&&(this.fixedUp=!1),this._screenPosIsChanged||this.vel.length()>this._prevVel.length()&&(this.fixedUp=!1),this._screenPosIsChanged=!1,this._prevVel.copy(this.vel),e.slope>this.minSlope){let t=this.vel.scaleTo(this.dt),i=v.proj_b_to_plane(t,e.eyeNorm),s=e.eye.add(i).normalize().scale(this._grabbedCameraHeight);if(this.fixedUp)e.eye.copy(s),this._corrRoll(),e.setPitchYawRoll(this._curPitch,this._curYaw,this._curRoll);else{let r=O.getRotationBetweenVectors(e.eye.getNormal(),s.getNormal());e.rotate(r),e.eye.copy(s)}}else{let t=this.vel.scaleTo(this.dt),i=e.eye.add(t);e.eye.copy(i),e.checkTerrainCollision()}this.events.dispatch(this.events.drag,this)}}_corrRoll(){this.planet.camera.slope<.5&&(this._curRoll-=this.vel_roll*this.dt,this._curRoll<.01*Math.PI/180&&(this._curRoll=.01*Math.PI/180))}_handleZoom(){if(this._targetZoomPoint&&this.vel.length()>.1){let e=this.planet.camera,t=this._targetZoomPoint,i=e.eye.clone(),s=t.sub(e.eye).normalize(),r=this.vel.getNormal(),n=Math.sign(r.dot(e.getForward())),o=this.vel.scaleTo(this.dt);this._grabbedSphere.radius>i.length()&&(n*=-1);let l=e.getForward().scaleTo(n*o.length());i.addA(l),this.events.dispatch(this.events.zoom,this);let h=e.maxAltitude+this.planet.ellipsoid.getEquatorialSize();if(i.length()>h)return void i.copy(i.getNormal().scale(h));let c=new U(i,s).hitSphere(this._grabbedSphere);if(!c)return void this.vel.set(0,0,0);let d=O.getRotationBetweenVectors(c.getNormal(),t.getNormal());if(e.eye=d.mulVec3(i),e.rotate(d),this.fixedUp){this._corrRoll(),e.setPitchYawRoll(this._curPitch,this._curYaw,this._curRoll),e.update();let u=e.unproject2v(this._currScreenPos),g=t.sub(e.eye).normalize(),f=new v,p=new v,_=Pe.fromPoints(t,t.add(e.getUp()),t.add(e.getRight()));new U(e.eye,u).hitPlaneRes(_,f),new U(e.eye,g).hitPlaneRes(_,p);let m=p.sub(f);e.eye=e.eye.add(m)}e.checkTerrainCollision()}}_updateVel(){let e=this.force.scale(1/this.mass);this.vel.addA(e),this.vel.scale(this.velocityInertia),this.vel.length()<.001&&this.vel.set(0,0,0),this.force.set(0,0,0),this._updateVel_h(),this._updateVel_v(),this._updateVel_roll()}_updateVel_h(){let e=this.force_h/this.mass;this.vel_h+=e,this.vel_h*=this.velocityInertia,Math.abs(this.vel_h)<.001&&(this.vel_h=0),this.force_h=0}_updateVel_v(){let e=this.force_v/this.mass;this.vel_v+=e,this.vel_v*=this.velocityInertia,Math.abs(this.vel_v)<.001&&(this.vel_v=0),this.force_v=0}_updateVel_roll(){let e=this.force_roll/this.mass;this.vel_roll+=e,this.vel_roll*=this.velocityInertia,this.force_roll=0}get dt(){return .001*this.renderer.handler.deltaTime}get velocityInertia(){return this._velInertia*this.inertia}stop(){this.vel.set(0,0,0),this.vel_h=0,this.vel_v=0,this._velInertia=qi,this._targetZoomPoint=null,this._grabbedPoint=null,this._targetRotationPoint=null,this._targetDragPoint=null}}const _o=a=>a>1e3?`${(a/1e3).toFixed(1)} km`:a>9?`${Math.round(a)} m`:`${a.toFixed(1)} m`;let nh=Z.createCylinder(1.1,0,2.7,20,1,!0,!1,0,0,0);const oh={text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,20,0]},fo={scale:1,instanced:!0,tag:"ruler",color:"rgb(0,305,0)",object3d:nh};class go extends at{constructor(e={}){super(e.name),this._onCornerLdown=t=>{var i,s;if(!this._startLonLat){(s=(i=this.renderer)==null?void 0:i.controls.mouseNavigation)==null||s.deactivate(),this._startClick.set(t.x,t.y);let r=t.pickingObject.getCartesian();this._startPos=this._planet.getPixelFromCartesian(r),this._pickedCorner=t.pickingObject,t.pickingObject.properties.name=="start"?this._anchorLonLat=this._cornerEntity[1].getLonLat().clone():this._anchorLonLat=this._cornerEntity[0].getLonLat().clone()}},this._onLUp=()=>{var t;this._pickedCorner&&((t=this.renderer.controls.mouseNavigation)==null||t.activate(),this._pickedCorner=null,this._anchorLonLat=null)},this._onCornerLup=()=>{this._onLUp()},this._onCornerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onCornerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onLdblclick=()=>{this._preventClick=!0},this._onLclick=t=>{let i=this._planet.getLonLatFromPixelTerrain(t.pos);i&&(this._timeout=setTimeout(()=>{this._preventClick||(this._startLonLat?this._startLonLat=null:(this.setVisibility(!0),this._stopDrawing=!1,this._startLonLat=i)),this._preventClick=!1,this._stopDrawing=!1,clearTimeout(this._timeout)},200),this._startLonLat&&(this._stopDrawing=!0))},this._onMouseMove=t=>{if(this._startLonLat&&!this._stopDrawing){this._propsLabel.label.setVisibility(!0);let i=this._planet.getLonLatFromPixelTerrain(t.pos);if(!i)return;this._drawLine(this._startLonLat,i)}else if(this._pickedCorner){let i=this._planet.getLonLatFromPixelTerrain(t.pos);i&&(this._pickedCorner.properties.name==="start"?this._drawLine(i,this._anchorLonLat):this._drawLine(this._anchorLonLat,i))}},this.events=he(ah),this._ignoreTerrain=e.ignoreTerrain==null||e.ignoreTerrain,this._planet=e.planet||null,this._startLonLat=null,this._preventClick=!1,this._stopDrawing=!1,this._pickedCorner=null,this._startPos=null,this._startClick=new N,this._anchorLonLat=null,this._heading=0,this._trackLayer=new ge("track",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!0}),this._labelLayer=new ge("ruler-label",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-100,relativeToGround:!0,hideInLayerSwitcher:!0}),this._cornersLayer=new ge("corners",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[100,4e6,1],pickingScale:2}),this._propsLabel=new V({name:"propsLabel",label:oh}),this._trackEntity=new V({polyline:{path3v:[],thickness:4.8,color:"rgb(255,131,0)",isClosed:!1}}),this._trackEntity.polyline.altitude=.01,this._cornerEntity=[new V({geoObject:fo,properties:{name:"start"}}),new V({geoObject:fo,properties:{name:"end"}})]}set ignoreTerrain(e){this._ignoreTerrain=e}bindPlanet(e){this._planet=e}_createCorners(){this._cornersLayer.addEntities(this._cornerEntity)}init(){this._createCorners(),this._trackLayer.addEntities([this._trackEntity]),this._labelLayer.addEntities([this._propsLabel]),this._planet.addLayer(this._labelLayer),this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._cornersLayer),this._activate()}onremove(){this._deactivate()}_activate(){this._propsLabel.label.setVisibility(!1),this.setVisibility(!1),this.renderer.events.on("lclick",this._onLclick,this),this.renderer.events.on("mousemove",this._onMouseMove,this),this.renderer.events.on("ldblclick",this._onLdblclick,this),this.renderer.events.on("lup",this._onLUp,this),this._cornersLayer.events.on("mouseenter",this._onCornerEnter,this),this._cornersLayer.events.on("mouseleave",this._onCornerLeave,this),this._cornersLayer.events.on("ldown",this._onCornerLdown,this),this._cornersLayer.events.on("lup",this._onCornerLup,this)}_deactivate(){this._startLonLat=null,this._preventClick=!1,this._stopDrawing=!1,this._pickedCorner=null,this.renderer.events.off("lclick",this._onLclick),this.renderer.events.off("mousemove",this._onMouseMove),this.renderer.events.off("lup",this._onLUp),this._cornersLayer.events.off("mouseenter",this._onCornerEnter),this._cornersLayer.events.off("mouseleave",this._onCornerLeave),this._cornersLayer.events.off("ldown",this._onCornerLdown),this._cornersLayer.events.off("lup",this._onCornerLup),this.clear()}setVisibility(e){this._cornersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._labelLayer.setVisibility(e)}_drawLine(e,t,i){i||(i=this._planet.ellipsoid.lonLatToCartesian(e));let s=this._planet.ellipsoid.lonLatToCartesian(t),r=this._planet.ellipsoid.inverse(e,t),n=r.distance;this._heading=r.initialAzimuth;let o=[],l=s.sub(i),h=l.length();l.normalize();for(let c=0;c<120;c++){let d=l.scaleTo(c*h/120).addA(i);o.push(d)}o.push(s),this._trackEntity.polyline.setPath3v([o]),this._ignoreTerrain&&(this._propsLabel.setCartesian3v(o[Math.floor(o.length/2)]),this._propsLabel.label.setText(`${_o(n)}, ${Math.round(this._heading)} deg`))}clear(){this._trackEntity.remove(),this._cornerEntity[0].remove(),this._cornerEntity[1].remove(),this._propsLabel.remove(),this._planet.removeLayer(this._trackLayer),this._planet.removeLayer(this._cornersLayer)}isCornersPositionChanged(){let e=this._trackEntity.polyline.getPath3v()[0];if(e){const t=e[0].clone(),i=e[e.length-1].clone();return this._cornerEntity[0].getCartesian().equal(t)&&this._cornerEntity[1].getCartesian().equal(i)}return!1}frame(){let e=this._trackEntity.polyline.getPath3v()[0];if(e){const t=e[0].clone(),i=e[e.length-1].clone();if(!this.isCornersPositionChanged()&&(this._cornerEntity[0].setCartesian3v(t),this._cornerEntity[1].setCartesian3v(i),!this._ignoreTerrain)){let s=0;for(let r=0,n=e.length-1;r<n;r++)s+=e[r+1].distance(e[r]);this._propsLabel.setCartesian3v(e[Math.floor(e.length/2)]),this._propsLabel.label.setText(`${_o(s)}, ${Math.round(this._heading)} deg`)}}}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const ah=["add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];class po extends te{constructor(e={}){super(e),this._rulerScene=new go({name:`rulerScene:${this.__id}`,ignoreTerrain:e.ignoreTerrain})}set ignoreTerrain(e){this._rulerScene.ignoreTerrain=e}oninit(){this._rulerScene.bindPlanet(this.planet)}onactivate(){this.renderer&&this.renderer.addNode(this._rulerScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._rulerScene)}}let lh=Z.createCylinder(1.1,0,2,6,1,!0,!0,0,0,0);const mo={startColor:"rgb(255,131,0)",endColor:"rgb(255,131,0)",thickness:5},Hs={text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,18,0]},vo={scale:1,instanced:!0,tag:"height-ruler",color:"rgb(255,131,0)",object3d:lh};class hh extends go{constructor(e={}){super(e),this._geoRulerLayer=new ge("rayHeightRuler",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-2,relativeToGround:!1,hideInLayerSwitcher:!0}),this._rayV=new V({name:"verticalRay",ray:mo}),this._rayH=new V({name:"heightRay",ray:mo}),this._heightLabels=[new V({name:"startCornerLabel",label:{...Hs}}),new V({name:"endCornerLabel",label:{...Hs}}),new V({name:"deltaLabel",label:{...Hs}})]}setVisibility(e){super.setVisibility(e),this._geoRulerLayer.setVisibility(e)}get deltaLabel(){return this._heightLabels[2]}get startLabel(){return this._heightLabels[0]}get endLabel(){return this._heightLabels[1]}get corners(){return this._cornerEntity}get startCorner(){return this.corners[0]}get endCorner(){return this.corners[1]}get startCornerLonLat(){return this.startCorner.getLonLat()}get startCornerHeight(){return this.startCornerLonLat.height}get endCornerLonLat(){return this.endCorner.getLonLat()}get endCornerHeight(){return this.endCornerLonLat.height}get maxHeightCornerLonLat(){return this.startCornerHeight<=this.endCornerHeight?this.endCornerLonLat:this.startCornerLonLat}get minHeightCornerLonLat(){return this.startCornerHeight>this.endCornerHeight?this.endCornerLonLat:this.startCornerLonLat}get deltaHeight(){return Math.abs(this.startCornerHeight-this.endCornerHeight)}_drawLine(e,t,i){super._drawLine(e,t,i),this._updateHeightRaysAndLabels()}async _updateHeightRaysAndLabels(){const e=this.minHeightCornerLonLat.clone();e.height=this.maxHeightCornerLonLat.height,this._rayH.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.maxHeightCornerLonLat)),this._rayH.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(e)),this._rayV.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.minHeightCornerLonLat)),this._rayV.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(e)),e.height=this.minHeightCornerLonLat.height+this.deltaHeight/2,this.deltaLabel.setLonLat(e),this.startLabel.setLonLat(this.startCornerLonLat),this.endLabel.setLonLat(this.endCornerLonLat);const t=await this._planet.getHeightDefault(this.startCornerLonLat),i=await this._planet.getHeightDefault(this.endCornerLonLat);this.deltaLabel.label.setText(`Δ ${Math.abs(t-i).toFixed(1)} m`),this.startLabel.label.setText(`P1 ${t.toFixed(1)} m`),this.endLabel.label.setText(`P2 ${i.toFixed(1)} m`)}clear(){this._rayH.remove(),this._rayV.remove(),this.startCorner.remove(),this.endCorner.remove(),this.startLabel.remove(),this.endLabel.remove(),this.deltaLabel.remove(),super.clear(),this._planet.removeLayer(this._geoRulerLayer)}_createCorners(){this._cornerEntity=[new V({geoObject:vo,properties:{name:"start"}}),new V({geoObject:vo,properties:{name:"end"}})],this._cornersLayer.setEntities(this._cornerEntity)}init(){super.init(),this._createCorners(),this._labelLayer.addEntities(this._heightLabels),this._geoRulerLayer.addEntities([this._rayH,this._rayV]),this._planet.addLayer(this._geoRulerLayer)}frame(){super.frame(),this._updateHeightRaysAndLabels()}}class yo extends po{constructor(e={}){super(e),this._rulerScene=new hh({name:`heightRulerScene:${this.__id}`,ignoreTerrain:!1})}}const Vs=[.001,.005,.01,.05,.1,.2,.5,1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7];class xo extends te{constructor(e={}){e.name&&e.name!==""||(e.name="scaleControl"),super(e),this._template=`<div class="og-scale-container">
162
+ </div>`,{id:"color-"+rh++,label:e.label||"",value:e.value||"#000000"})}),this._onInput=t=>{this.value=t.target.value},this.events=this.events.registerNames(ih),this._value=e.value||"blue",this.$label=null,this.$input=null}render(e){return super.render(e),this.$label=this.select(".og-color-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this._initEvents(),this}set value(e){e!==this._value&&(this._value=e,this.$input.value=this._value,this.events.dispatch(this.events.input,this._value,this))}get value(){return this._value}_initEvents(){this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.$input.removeEventListener("input",this._onInput)}remove(){this._clearEvents(),super.remove()}}class Nr{constructor(){this._lock=0}lock(e){this._lock|=1<<e.id}free(e){this._lock&=~(1<<e.id)}isFree(){return this._lock===0}isLocked(){return this._lock!==0}}const da=class Wo{constructor(){this.__id=Wo.__counter__++}get id(){return this.__id}};da.__counter__=0;let ci=da;class Hr extends ee{constructor(e={}){super(e),this._deactivate=!1,this._shiftBusy=!1,this._name="mouseNavigation",this.grabbedPoint=new m,this._eye0=new m,this.pointOnEarth=new m,this.earthUp=new m,this.inertia=.007,this.grabbedSpheroid=new He,this.qRot=new O,this.scaleRot=0,this.distDiff=.3,this.stepsCount=8,this.stepsForward=null,this.stepIndex=0,this._lmbDoubleClickActive=!0,this.minSlope=e.minSlope||.1,this._wheelDirection=1,this._keyLock=new ci}static getMovePointsFromPixelTerrain(e,t,i,r,s,n,o){const l=[];let h=e.eye.clone(),c=e.getBackward(),d=e.getRight(),u=e.getUp(),g=t.getCartesianFromPixelTerrain(s);if(g||(g=t.getCartesianFromPixelTerrain(t.renderer.handler.getCenter())),g){o||(o=m.sub(g,e.eye).normalize());let f=r*e.eye.distance(g)/i;f*=n?-1.25:2;const p=c.scaleTo(f);if(o.dot(e.eye.normal().negate())>=.1){const _=new He;_.radius=g.length();let v=[],x=[],y=!1;for(let w=0;w<i;w++){h.addA(p);const b=new H(h,o).hitSphere(_);if(x[w]=h.clone(),!b){y=!0;break}v[w]=new ne().rotateBetweenVectors(g.normal(),b.normal())}if(y){h=e.eye.clone();for(let w=0;w<i;w++)l[w]={eye:h.addA(p).clone(),v:u,u:d,n:c}}else for(let w=0;w<i;w++){let b=v[w];l[w]={eye:b.mulVec3(x[w]),v:b.mulVec3(u),u:b.mulVec3(d),n:b.mulVec3(c)}}}else for(let _=0;_<i;_++)l[_]={eye:h.addA(o.scaleTo(-f)).clone(),v:u,u:d,n:c};return l}}onactivate(){this.renderer&&(this.renderer.events.on("mousewheel",this.onMouseWheel,this),this.renderer.events.on("lhold",this.onMouseLeftButtonDown,this),this.renderer.events.on("rhold",this.onMouseRightButtonDown,this),this.renderer.events.on("ldown",this.onMouseLeftButtonClick,this),this.renderer.events.on("lup",this.onMouseLeftButtonUp,this),this.renderer.events.on("rdown",this.onMouseRightButtonClick,this),this.renderer.events.on("draw",this.onDraw,this,-1e3),this.renderer.events.on("mousemove",this.onMouseMove,this),this.renderer.events.on("mouseleave",this.onMouseLeave,this),this.renderer.events.on("mouseenter",this.onMouseEnter,this),this._lmbDoubleClickActive&&this.renderer.events.on("ldblclick",this.onMouseLeftButtonDoubleClick,this))}ondeactivate(){this.renderer&&(this.renderer.events.off("mousewheel",this.onMouseWheel),this.renderer.events.off("lhold",this.onMouseLeftButtonDown),this.renderer.events.off("rhold",this.onMouseRightButtonDown),this.renderer.events.off("ldown",this.onMouseLeftButtonClick),this.renderer.events.off("lup",this.onMouseLeftButtonUp),this.renderer.events.off("rdown",this.onMouseRightButtonClick),this.renderer.events.off("draw",this.onDraw),this.renderer.events.off("ldblclick",this.onMouseLeftButtonDoubleClick),this.renderer.events.off("mouseleave",this.onMouseLeave),this.renderer.events.off("mouseenter",this.onMouseEnter))}activateDoubleClickZoom(){this._lmbDoubleClickActive||(this._lmbDoubleClickActive=!0,this.renderer&&this.renderer.events.on("ldblclick",this.onMouseLeftButtonDoubleClick,this))}deactivateDoubleClickZoom(){this._lmbDoubleClickActive&&(this._lmbDoubleClickActive=!1,this.renderer&&this.renderer.events.off("ldblclick",this.onMouseLeftButtonDoubleClick))}onMouseEnter(e){const t=this.renderer.events;t.isKeyPressed(W.KEY_ALT)&&t.releaseKeys(),t.updateButtonsStates(e.sys.buttons),t.mouseState.leftButtonDown?this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"):this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")}onMouseLeave(){this.renderer.events.mouseState.leftButtonDown&&(this.scaleRot=0),this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")}onMouseWheel(e){this.stepIndex||(this.planet.stopFlying(),this.stopRotation(),this._deactivate=!0,this.lockPlanet(!0),this.stepsForward=Hr.getMovePointsFromPixelTerrain(this.planet.camera,this.planet,this.stepsCount,this.distDiff,e.pos,e.wheelDelta>0,e.direction)||null,this._wheelDirection=e.wheelDelta,this.stepsForward&&(this.stepIndex=this.stepsCount))}oninit(){this.activate(),this.renderer&&(this.renderer.events.on("keyfree",W.KEY_ALT,this.onShiftFree,this),this.renderer.events.on("keyfree",W.KEY_PRINTSCREEN,this.onShiftFree,this))}onMouseLeftButtonDoubleClick(e){this.planet.stopFlying(),this.stopRotation();const t=this.planet.getCartesianFromPixelTerrain(e.pos);if(t){const i=this.planet.camera;let r=i.maxAltitude+this.planet.ellipsoid.polarSize,s=i.minAltitude+this.planet.ellipsoid.polarSize;const n=i.eye.length(),o=this.planet.ellipsoid.cartesianToLonLat(t);if(n>r||n<s)return void this.planet.flyLonLat(new A(o.lon,o.lat));this.renderer.events.isKeyPressed(W.KEY_ALT)?this.planet.flyLonLat(new A(o.lon,o.lat,2*i.eye.distance(t))):this.planet.flyLonLat(new A(o.lon,o.lat,.57*i.eye.distance(t)))}}onMouseLeftButtonClick(){this._active&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this.grabbedPoint=this.planet.getCartesianFromMouseTerrain(),this.grabbedPoint&&(this._eye0.copy(this.planet.camera.eye),this.grabbedSpheroid.radius=this.grabbedPoint.length(),this.stopRotation()))}stopRotation(){this.qRot.clear(),this.freePlanet()}onMouseLeftButtonUp(e){this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.x===e.prev_x&&e.y===e.prev_y&&(this.scaleRot=0)}onMouseLeftButtonDown(e){if(this._active){if(!this.grabbedPoint)return;if(this.planet.stopFlying(),e.moving){let t=this.planet.camera;if(t.slope>.2){const i=new H(t.eye,e.direction).hitSphere(this.grabbedSpheroid);if(i){this.scaleRot=1,this.qRot=O.getRotationBetweenVectors(i.normal(),this.grabbedPoint.normal());let r=this.qRot;t.eye=r.mulVec3(t.eye),t.rotate(r)}}else{let i=this.grabbedPoint,r=m.add(i,t.getRight()),s=m.add(i,i.normal()),n=new m;new H(t.eye,e.direction).hitPlaneRes(we.fromPoints(i,r,s),n)===H.INSIDE&&(t.eye=this._eye0.addA(n.subA(i).negate()))}}}}onMouseRightButtonClick(e){this.stopRotation(),this.planet.stopFlying(),this.pointOnEarth=this.planet.getCartesianFromPixelTerrain(e.pos),this.pointOnEarth&&(this.earthUp=this.pointOnEarth.normal())}onMouseRightButtonDown(e){const t=this.planet.camera;if(this.pointOnEarth&&e.moving){this.renderer.controlsBag.scaleRot=1;let i=.5/t.eye.distance(this.pointOnEarth)*t._lonLat.height*U;i>.007?i=.007:i<.003&&(i=.003),t.rotateHorizontal(i*(e.x-e.prev_x),!1,this.pointOnEarth,this.earthUp),t.rotateVertical(i*(e.y-e.prev_y),this.pointOnEarth,this.minSlope)}}onShiftFree(){this._shiftBusy=!1}onMouseMove(e){this._active&&this.renderer.events.isKeyPressed(W.KEY_ALT)&&(this._shiftBusy||(this._shiftBusy=!0,this.onMouseRightButtonClick(e)),this.onMouseRightButtonDown(e))}onDraw(){if(this._active){const e=this.renderer,t=this.planet.camera;let i=t.eye.clone();if(this.stepIndex){e.controlsBag.scaleRot=1;const r=this.stepsForward[this.stepsCount-this.stepIndex--];t.eye=r.eye,t._u=r.v,t._r=r.u,t._b=r.n,t._f.set(-t._b.x,-t._b.y,-t._b.z)}else this._deactivate&&(this._deactivate=!1,this.freePlanet());if(e.events.mouseState.leftButtonDown||!this.scaleRot)return;if(this.scaleRot-=this.inertia,this.scaleRot<=0)this.scaleRot=0;else{e.controlsBag.scaleRot=this.scaleRot;let r=this.qRot.slerp(O.IDENTITY,1-this.scaleRot*this.scaleRot*this.scaleRot).normalize();r.x||r.y||r.z||(this.scaleRot=0),t.eye=r.mulVec3(t.eye),t.rotate(r)}t.eye.distance(i)/t.getAltitude()>.01?this.lockPlanet():this.freePlanet()}}lockPlanet(e){this.planet.layerLock.lock(this._keyLock),!e&&this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock)}freePlanet(){this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}}const sh=["drag","zoom","rotate"],Yi=.96;class ua extends ee{constructor(e={}){super({name:"mouseNavigation",autoActivate:!0,...e}),this._shiftBusy=!1,this._hold=!1,this._prevVel=new m,this._screenPosIsChanged=!0,this._onShiftFree=()=>{this._shiftBusy=!1},this._onCameraFly=()=>{this.stop()},this._onMouseMove=t=>{this._active&&this.renderer.events.isKeyPressed(W.KEY_ALT)&&(this._shiftBusy||(this._shiftBusy=!0,this._onRHold(t)),this._onRDown(t))},this._onMouseEnter=t=>{const i=this.renderer.events;i.isKeyPressed(W.KEY_ALT)&&i.releaseKeys(),i.updateButtonsStates(t.sys.buttons),i.mouseState.leftButtonDown?this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"):this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this._onMouseLeave=()=>{this.renderer.events.mouseState.leftButtonDown&&this.vel.scale(0),this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this._onRHold=t=>{this._targetRotationPoint&&(this._velInertia=.6,this.force_h=.5*(t.x-t.prev_x),this.force_v=.5*(t.y-t.prev_y))},this._onRDown=t=>{this.planet&&(this.planet.stopFlying(),this._targetRotationPoint=this._getTargetPoint(t.pos),this._targetRotationPoint&&(this._targetZoomPoint=null,this._targetDragPoint=null,this.vel.set(0,0,0),this._tUp=this._targetRotationPoint.getNormal(),this._tRad=this.planet.camera.eye.distance(this._targetRotationPoint)))},this._onMouseWheel=t=>{if(this.planet){this._targetRotationPoint=null,this._targetDragPoint=null;let i=this._getTargetPoint(t.pos);if(!i)return;this._targetZoomPoint=i,this._grabbedSphere.radius=this._targetZoomPoint.length();let r=this.planet.camera;if(this._curPitch=r.getPitch(),this._curYaw=r.getYaw(),this._curRoll=r.getRoll(),Math.sign(t.wheelDelta)!==this._wheelDirection)return this.vel.scale(.3),this._currScreenPos.set(t.x,t.y),void(this._wheelDirection=Math.sign(t.wheelDelta));this._currScreenPos.set(t.x,t.y),this._wheelDirection=Math.sign(t.wheelDelta);let s=20;this._velInertia=.83,this._isTouchPad=t.isTouchPad,t.isTouchPad&&(this._velInertia=.63,s=17);let n=this._targetZoomPoint.sub(r.eye);n.length()>6e3&&this._wheelDirection>0&&r.eye.getNormal().negate().dot(n.normalize())<.3&&(this.fixedUp=!1,s=4.3);let o=this.planet.camera.eye.distance(this._targetZoomPoint)*s;this.force=t.direction.scale(this._wheelDirection).normalize().scale(this._wheelDirection<0?1.3*o:o).scale(this.zoomSpeed),this.vel.set(0,0,0),this.force_roll=this._curRoll}},this._onLDown=t=>{this.stop(),this._targetRotationPoint=null,this._targetZoomPoint=null,this.planet&&(this.planet.stopFlying(),this._grabbedPoint=this._getTargetPoint(t.pos),this._grabbedPoint&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this._grabbedSphere.radius=this._grabbedPoint.length(),this._eye0=this.planet.camera.eye.clone(),this._grabbedCameraHeight=this._eye0.length(),this._curPitch=this.planet.camera.getPitch(),this._curYaw=this.planet.camera.getYaw(),this._curRoll=this.planet.camera.getRoll(),this._currScreenPos.copy(t.pos),this.planet.camera.getUp().dot(new m(0,0,1))>.3&&(this.fixedUp=!0)))},this._onLHold=t=>{if(this._grabbedPoint&&this.planet){let i=this.planet.camera;if(i.slope>.35){let r=new H(i.eye,t.direction).hitSphere(this._grabbedSphere);if(!r)return;this._targetDragPoint=r;let s=new m,n=O.getRotationBetweenVectors(this._targetDragPoint.getNormal(),this._grabbedPoint.getNormal());s.copy(n.mulVec3(i.eye)),this.force=s.sub(i.eye).scale(this.dragInertia)}else{let r=this._grabbedPoint,s=m.add(r,i.getRight()),n=m.add(r,r.getNormal()),o=new m;new H(i.eye,t.direction).hitPlaneRes(we.fromPoints(r,s,n),o);let l=i.eye.add(o.subA(r).negate());this.force=l.sub(i.eye).scale(this.dragInertia),this._targetDragPoint=o}this.vel.set(0,0,0),this._currScreenPos.equal(t.pos)||(this._screenPosIsChanged=!0,this._currScreenPos.copy(t.pos)),this._hold=!0}},this._onLUp=t=>{this._hold=!1,this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner")},this.events=le(sh,this),this.force=new m,this.force_h=0,this.force_v=0,this.vel=new m,this.vel_h=0,this.vel_v=0,this.vel_roll=0,this.force_roll=0,this.mass=e.mass!=null?e.mass:1,this.inertia=e.inertia!=null?e.inertia:1,this._velInertia=Yi,this.minSlope=e.minSlope!=null?e.minSlope:.35,this.dragInertia=e.dragInertia!=null?e.dragInertia:170,this.zoomSpeed=e.zoomSpeed!=null?e.zoomSpeed:1,this._lookPos=void 0,this._grabbedPoint=null,this._targetZoomPoint=null,this._targetDragPoint=null,this._targetRotationPoint=null,this._tUp=new m,this._tRad=0,this._rotHDir=0,this._rotVDir=0,this._wheelDirection=1,this._currScreenPos=new N,this._grabbedSphere=new He,this.fixedUp=e.fixedUp==null||e.fixedUp,this._rot=new O,this._curPitch=0,this._curYaw=0,this._curRoll=0,this._eye0=new m,this._newEye=new m,this._grabbedCameraHeight=0,this._isTouchPad=!1}oninit(){this.renderer&&(this.renderer.events.on("keyfree",W.KEY_ALT,this._onShiftFree),this.renderer.events.on("keyfree",W.KEY_PRINTSCREEN,this._onShiftFree))}onadd(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.on("flystart",this._onCameraFly)}onremove(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.off("flystart",this._onCameraFly)}onactivate(){super.onactivate();let e=this.renderer;e.events.on("mousewheel",this._onMouseWheel),e.events.on("rhold",this._onRHold),e.events.on("rdown",this._onRDown),e.events.on("lhold",this._onLHold),e.events.on("ldown",this._onLDown),e.events.on("lup",this._onLUp),e.events.on("draw",this.onDraw,this,-1e3),e.events.on("mousemove",this._onMouseMove),e.events.on("mouseleave",this._onMouseLeave),e.events.on("mouseenter",this._onMouseEnter)}ondeactivate(){super.ondeactivate();let e=this.renderer;e.events.off("mousewheel",this._onMouseWheel),e.events.off("rhold",this._onRHold),e.events.off("rdown",this._onRDown),e.events.off("lhold",this._onLHold),e.events.off("ldown",this._onLDown),e.events.off("lup",this._onLUp),e.events.off("draw",this.onDraw),e.events.off("mousemove",this._onMouseMove),e.events.off("mouseleave",this._onMouseLeave),e.events.off("mouseenter",this._onMouseEnter)}onDraw(){this._updateVel(),this._handleZoom(),this._handleDrag(),this._handleRotation()}_handleRotation(){if(this.planet&&this._targetRotationPoint){let e=this.planet.camera;if(this.vel_h===0&&this.vel_v===0)return;let t=this.vel_h*this.dt,i=this.vel_v*this.dt;e.rotateHorizontal(t,!1,this._targetRotationPoint,this._tUp),e.rotateVertical(i,this._targetRotationPoint,.1),this.events.dispatch(this.events.rotate,this),this._curPitch=e.getPitch(),this._curYaw=e.getYaw(),this._curRoll=e.getRoll(),this._velInertia=Yi}}_getTargetPoint(e){return this.planet?this.planet.camera.getAltitude()>8e4?this.planet.getCartesianFromPixelEllipsoid(e)||null:this.planet.getCartesianFromPixelTerrain(e)||null:null}_handleDrag(){if(this.planet&&this._targetDragPoint&&this._grabbedPoint&&this.vel.length()>.1){this._velInertia=Yi;let e=this.planet.camera;if(Math.abs(e.eyeNorm.dot(m.NORTH))>.9&&(this.fixedUp=!1),this._screenPosIsChanged||this.vel.length()>this._prevVel.length()&&(this.fixedUp=!1),this._screenPosIsChanged=!1,this._prevVel.copy(this.vel),e.slope>this.minSlope){let t=this.vel.scaleTo(this.dt),i=m.proj_b_to_plane(t,e.eyeNorm),r=e.eye.add(i).normalize().scale(this._grabbedCameraHeight);if(this.fixedUp)e.eye.copy(r),this._corrRoll(),e.setPitchYawRoll(this._curPitch,this._curYaw,this._curRoll);else{let s=O.getRotationBetweenVectors(e.eye.getNormal(),r.getNormal());e.rotate(s),e.eye.copy(r)}}else{let t=this.vel.scaleTo(this.dt),i=e.eye.add(t);e.eye.copy(i),e.checkTerrainCollision()}this.events.dispatch(this.events.drag,this)}}_corrRoll(){this.planet.camera.slope<.5&&(this._curRoll-=this.vel_roll*this.dt,this._curRoll<.01*Math.PI/180&&(this._curRoll=.01*Math.PI/180))}_handleZoom(){if(this._targetZoomPoint&&this.vel.length()>.1){let e=this.planet.camera,t=this._targetZoomPoint,i=e.eye.clone(),r=t.sub(e.eye).normalize(),s=this.vel.getNormal(),n=Math.sign(s.dot(e.getForward())),o=this.vel.scaleTo(this.dt);this._grabbedSphere.radius>i.length()&&(n*=-1);let l=e.getForward().scaleTo(n*o.length());i.addA(l),this.events.dispatch(this.events.zoom,this);let h=e.maxAltitude+this.planet.ellipsoid.getEquatorialSize();if(i.length()>h)return void i.copy(i.getNormal().scale(h));let c=new H(i,r).hitSphere(this._grabbedSphere);if(!c)return void this.vel.set(0,0,0);let d=O.getRotationBetweenVectors(c.getNormal(),t.getNormal());if(e.eye=d.mulVec3(i),e.rotate(d),this.fixedUp){this._corrRoll(),e.setPitchYawRoll(this._curPitch,this._curYaw,this._curRoll),e.update();let u=e.unproject2v(this._currScreenPos),g=t.sub(e.eye).normalize(),f=new m,p=new m,_=we.fromPoints(t,t.add(e.getUp()),t.add(e.getRight()));new H(e.eye,u).hitPlaneRes(_,f),new H(e.eye,g).hitPlaneRes(_,p);let v=p.sub(f);e.eye=e.eye.add(v)}e.checkTerrainCollision()}}_updateVel(){let e=this.force.scale(1/this.mass);this.vel.addA(e),this.vel.scale(this.velocityInertia),this.vel.length()<.001&&this.vel.set(0,0,0),this.force.set(0,0,0),this._updateVel_h(),this._updateVel_v(),this._updateVel_roll()}_updateVel_h(){let e=this.force_h/this.mass;this.vel_h+=e,this.vel_h*=this.velocityInertia,Math.abs(this.vel_h)<.001&&(this.vel_h=0),this.force_h=0}_updateVel_v(){let e=this.force_v/this.mass;this.vel_v+=e,this.vel_v*=this.velocityInertia,Math.abs(this.vel_v)<.001&&(this.vel_v=0),this.force_v=0}_updateVel_roll(){let e=this.force_roll/this.mass;this.vel_roll+=e,this.vel_roll*=this.velocityInertia,this.force_roll=0}get dt(){return .001*this.renderer.handler.deltaTime}get velocityInertia(){return this._velInertia*this.inertia}stop(){this.vel.set(0,0,0),this.vel_h=0,this.vel_v=0,this._velInertia=Yi,this._targetZoomPoint=null,this._grabbedPoint=null,this._targetRotationPoint=null,this._targetDragPoint=null}}const _a=a=>a>1e3?`${(a/1e3).toFixed(1)} km`:a>9?`${Math.round(a)} m`:`${a.toFixed(1)} m`;let nh=Z.createCylinder(1.1,0,2.7,20,1,!0,!1,0,0,0);const ah={text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,20,0]},fa={scale:1,instanced:!0,tag:"ruler",color:"rgb(0,305,0)",object3d:nh};class ga extends ot{constructor(e={}){super(e.name),this._onCornerLdown=t=>{var i,r;if(!this._startLonLat){(r=(i=this.renderer)==null?void 0:i.controls.mouseNavigation)==null||r.deactivate(),this._startClick.set(t.x,t.y);let s=t.pickingObject.getCartesian();this._startPos=this._planet.getPixelFromCartesian(s),this._pickedCorner=t.pickingObject,t.pickingObject.properties.name=="start"?this._anchorLonLat=this._cornerEntity[1].getLonLat().clone():this._anchorLonLat=this._cornerEntity[0].getLonLat().clone()}},this._onLUp=()=>{var t;this._pickedCorner&&((t=this.renderer.controls.mouseNavigation)==null||t.activate(),this._pickedCorner=null,this._anchorLonLat=null)},this._onCornerLup=()=>{this._onLUp()},this._onCornerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onCornerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onLdblclick=()=>{this._preventClick=!0},this._onLclick=t=>{let i=this._planet.getLonLatFromPixelTerrain(t.pos);i&&(this._timeout=setTimeout(()=>{this._preventClick||(this._startLonLat?this._startLonLat=null:(this.setVisibility(!0),this._stopDrawing=!1,this._startLonLat=i)),this._preventClick=!1,this._stopDrawing=!1,clearTimeout(this._timeout)},200),this._startLonLat&&(this._stopDrawing=!0))},this._onMouseMove=t=>{if(this._startLonLat&&!this._stopDrawing){this._propsLabel.label.setVisibility(!0);let i=this._planet.getLonLatFromPixelTerrain(t.pos);if(!i)return;this._drawLine(this._startLonLat,i)}else if(this._pickedCorner){let i=this._planet.getLonLatFromPixelTerrain(t.pos);i&&(this._pickedCorner.properties.name==="start"?this._drawLine(i,this._anchorLonLat):this._drawLine(this._anchorLonLat,i))}},this.events=le(oh),this._ignoreTerrain=e.ignoreTerrain==null||e.ignoreTerrain,this._planet=e.planet||null,this._startLonLat=null,this._preventClick=!1,this._stopDrawing=!1,this._pickedCorner=null,this._startPos=null,this._startClick=new N,this._anchorLonLat=null,this._heading=0,this._trackLayer=new fe("track",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!0}),this._labelLayer=new fe("ruler-label",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-100,relativeToGround:!0,hideInLayerSwitcher:!0}),this._cornersLayer=new fe("corners",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[100,4e6,1],pickingScale:2}),this._propsLabel=new V({name:"propsLabel",label:ah}),this._trackEntity=new V({polyline:{path3v:[],thickness:4.8,color:"rgb(255,131,0)",isClosed:!1}}),this._trackEntity.polyline.altitude=.01,this._cornerEntity=[new V({geoObject:fa,properties:{name:"start"}}),new V({geoObject:fa,properties:{name:"end"}})]}set ignoreTerrain(e){this._ignoreTerrain=e}bindPlanet(e){this._planet=e}_createCorners(){this._cornersLayer.addEntities(this._cornerEntity)}init(){this._createCorners(),this._trackLayer.addEntities([this._trackEntity]),this._labelLayer.addEntities([this._propsLabel]),this._planet.addLayer(this._labelLayer),this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._cornersLayer),this._activate()}onremove(){this._deactivate()}_activate(){this._propsLabel.label.setVisibility(!1),this.setVisibility(!1),this.renderer.events.on("lclick",this._onLclick,this),this.renderer.events.on("mousemove",this._onMouseMove,this),this.renderer.events.on("ldblclick",this._onLdblclick,this),this.renderer.events.on("lup",this._onLUp,this),this._cornersLayer.events.on("mouseenter",this._onCornerEnter,this),this._cornersLayer.events.on("mouseleave",this._onCornerLeave,this),this._cornersLayer.events.on("ldown",this._onCornerLdown,this),this._cornersLayer.events.on("lup",this._onCornerLup,this)}_deactivate(){this._startLonLat=null,this._preventClick=!1,this._stopDrawing=!1,this._pickedCorner=null,this.renderer.events.off("lclick",this._onLclick),this.renderer.events.off("mousemove",this._onMouseMove),this.renderer.events.off("lup",this._onLUp),this._cornersLayer.events.off("mouseenter",this._onCornerEnter),this._cornersLayer.events.off("mouseleave",this._onCornerLeave),this._cornersLayer.events.off("ldown",this._onCornerLdown),this._cornersLayer.events.off("lup",this._onCornerLup),this.clear()}setVisibility(e){this._cornersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._labelLayer.setVisibility(e)}_drawLine(e,t,i){i||(i=this._planet.ellipsoid.lonLatToCartesian(e));let r=this._planet.ellipsoid.lonLatToCartesian(t),s=this._planet.ellipsoid.inverse(e,t),n=s.distance;this._heading=s.initialAzimuth;let o=[],l=r.sub(i),h=l.length();l.normalize();for(let c=0;c<120;c++){let d=l.scaleTo(c*h/120).addA(i);o.push(d)}o.push(r),this._trackEntity.polyline.setPath3v([o]),this._ignoreTerrain&&(this._propsLabel.setCartesian3v(o[Math.floor(o.length/2)]),this._propsLabel.label.setText(`${_a(n)}, ${Math.round(this._heading)} deg`))}clear(){this._trackEntity.remove(),this._cornerEntity[0].remove(),this._cornerEntity[1].remove(),this._propsLabel.remove(),this._planet.removeLayer(this._trackLayer),this._planet.removeLayer(this._cornersLayer)}isCornersPositionChanged(){let e=this._trackEntity.polyline.getPath3v()[0];if(e){const t=e[0].clone(),i=e[e.length-1].clone();return this._cornerEntity[0].getCartesian().equal(t)&&this._cornerEntity[1].getCartesian().equal(i)}return!1}frame(){let e=this._trackEntity.polyline.getPath3v()[0];if(e){const t=e[0].clone(),i=e[e.length-1].clone();if(!this.isCornersPositionChanged()&&(this._cornerEntity[0].setCartesian3v(t),this._cornerEntity[1].setCartesian3v(i),!this._ignoreTerrain)){let r=0;for(let s=0,n=e.length-1;s<n;s++)r+=e[s+1].distance(e[s]);this._propsLabel.setCartesian3v(e[Math.floor(e.length/2)]),this._propsLabel.label.setText(`${_a(r)}, ${Math.round(this._heading)} deg`)}}}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const oh=["add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];class pa extends ee{constructor(e={}){super(e),this._rulerScene=new ga({name:`rulerScene:${this.__id}`,ignoreTerrain:e.ignoreTerrain})}set ignoreTerrain(e){this._rulerScene.ignoreTerrain=e}oninit(){this._rulerScene.bindPlanet(this.planet)}onactivate(){this.renderer&&this.renderer.addNode(this._rulerScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._rulerScene)}}let lh=Z.createCylinder(1.1,0,2,6,1,!0,!0,0,0,0);const ma={startColor:"rgb(255,131,0)",endColor:"rgb(255,131,0)",thickness:5},Vr={text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,18,0]},va={scale:1,instanced:!0,tag:"height-ruler",color:"rgb(255,131,0)",object3d:lh};class hh extends ga{constructor(e={}){super(e),this._geoRulerLayer=new fe("rayHeightRuler",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-2,relativeToGround:!1,hideInLayerSwitcher:!0}),this._rayV=new V({name:"verticalRay",ray:ma}),this._rayH=new V({name:"heightRay",ray:ma}),this._heightLabels=[new V({name:"startCornerLabel",label:{...Vr}}),new V({name:"endCornerLabel",label:{...Vr}}),new V({name:"deltaLabel",label:{...Vr}})]}setVisibility(e){super.setVisibility(e),this._geoRulerLayer.setVisibility(e)}get deltaLabel(){return this._heightLabels[2]}get startLabel(){return this._heightLabels[0]}get endLabel(){return this._heightLabels[1]}get corners(){return this._cornerEntity}get startCorner(){return this.corners[0]}get endCorner(){return this.corners[1]}get startCornerLonLat(){return this.startCorner.getLonLat()}get startCornerHeight(){return this.startCornerLonLat.height}get endCornerLonLat(){return this.endCorner.getLonLat()}get endCornerHeight(){return this.endCornerLonLat.height}get maxHeightCornerLonLat(){return this.startCornerHeight<=this.endCornerHeight?this.endCornerLonLat:this.startCornerLonLat}get minHeightCornerLonLat(){return this.startCornerHeight>this.endCornerHeight?this.endCornerLonLat:this.startCornerLonLat}get deltaHeight(){return Math.abs(this.startCornerHeight-this.endCornerHeight)}_drawLine(e,t,i){super._drawLine(e,t,i),this._updateHeightRaysAndLabels()}async _updateHeightRaysAndLabels(){const e=this.minHeightCornerLonLat.clone();e.height=this.maxHeightCornerLonLat.height,this._rayH.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.maxHeightCornerLonLat)),this._rayH.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(e)),this._rayV.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.minHeightCornerLonLat)),this._rayV.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(e)),e.height=this.minHeightCornerLonLat.height+this.deltaHeight/2,this.deltaLabel.setLonLat(e),this.startLabel.setLonLat(this.startCornerLonLat),this.endLabel.setLonLat(this.endCornerLonLat);const t=await this._planet.getHeightDefault(this.startCornerLonLat),i=await this._planet.getHeightDefault(this.endCornerLonLat);this.deltaLabel.label.setText(`Δ ${Math.abs(t-i).toFixed(1)} m`),this.startLabel.label.setText(`P1 ${t.toFixed(1)} m`),this.endLabel.label.setText(`P2 ${i.toFixed(1)} m`)}clear(){this._rayH.remove(),this._rayV.remove(),this.startCorner.remove(),this.endCorner.remove(),this.startLabel.remove(),this.endLabel.remove(),this.deltaLabel.remove(),super.clear(),this._planet.removeLayer(this._geoRulerLayer)}_createCorners(){this._cornerEntity=[new V({geoObject:va,properties:{name:"start"}}),new V({geoObject:va,properties:{name:"end"}})],this._cornersLayer.setEntities(this._cornerEntity)}init(){super.init(),this._createCorners(),this._labelLayer.addEntities(this._heightLabels),this._geoRulerLayer.addEntities([this._rayH,this._rayV]),this._planet.addLayer(this._geoRulerLayer)}frame(){super.frame(),this._updateHeightRaysAndLabels()}}class ya extends pa{constructor(e={}){super(e),this._rulerScene=new hh({name:`heightRulerScene:${this.__id}`,ignoreTerrain:!1})}}const Ur=[.001,.005,.01,.05,.1,.2,.5,1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7];class xa extends ee{constructor(e={}){e.name&&e.name!==""||(e.name="scaleControl"),super(e),this._template=`<div class="og-scale-container">
163
163
  <div class="og-scale-label"></div>
164
164
  <div class="og-scale-ruler"></div>
165
- </div>`,this._minWidth=100,this._maxWidth=150,this._isCenter=e.isCenter==null||e.isCenter,this._mPx=0,this.currWidth=0,this._metersInMinSize=0,this.el=null,this._scaleLabelEl=null}_renderTemplate(){return us(this._template)[0]}oninit(){this.el=this._renderTemplate(),this._scaleLabelEl=this.el.querySelector(".og-scale-label"),this.renderer.div.appendChild(this.el),this._isCenter?(this.planet.camera.events.on("moveend",()=>{this._drawScreen(this.planet.renderer.handler.getCenter())}),!this.planet.terrain.isEmpty&&this.planet.terrain.events.on("loadend",()=>{this._drawScreen(this.planet.renderer.handler.getCenter())})):(this.renderer.events.on("mousemove",e=>{e.leftButtonHold||e.rightButtonHold||this._drawScreen(e.pos)}),this.planet.camera.events.on("moveend",()=>{let e=this.renderer.events.mouseState;e.leftButtonHold||e.rightButtonHold||this._drawScreen(e.pos)}))}_drawScreen(e){let t=this.planet.camera,i=e,s=this.planet.getDistanceFromPixel(i)||0;s===0&&(i=t.project3v(v.ZERO),s=this.planet.getDistanceFromPixel(i)||0);let r=t.getForward().scaleTo(s).addA(t.eye),n=s*Math.tan(t.viewAngle*j),o=r.add(t.getRight().scaleTo(n)),l=t.project3v(o);this._mPx=n/l.distance(i);let h=this._mPx*this._minWidth,c=yt(Vs,h,(g,f)=>g-f);c<0&&(c=~c);let d=Vs[c],u=(d-h)/(Vs[c+1]-d);this.currWidth=this._minWidth+u*(this._maxWidth-this._minWidth),this._scaleLabelEl.innerText=d>=1e3?d/1e3+" km":d>=1?`${d} m`:d>=.01?100*d+" cm":1e3*d+" mm",this._metersInMinSize=h,this.el.style.width=this.currWidth+"px"}}class bo extends te{constructor(e={}){super({name:"SimpleSkyBackground",...e}),this._colorOne=new Float32Array([128/255,223/255,1]),this._colorTwo=new Float32Array([10/255,15/255,56/255])}get colorOne(){let e=this._colorOne;return ds([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}get colorTwo(){let e=this._colorTwo;return ds([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}set colorOne(e){let t=Fi(e);this._colorOne[0]=t.x,this._colorOne[1]=t.y,this._colorOne[2]=t.z}set colorTwo(e){let t=Fi(e);this._colorTwo[0]=t.x,this._colorTwo[1]=t.y,this._colorTwo[2]=t.z}oninit(){this.renderer.handler.addProgram(new X("simpleSkyBackground",{uniforms:{iResolution:"vec2",fov:"float",camPos:"vec3",earthRadius:"float",viewMatrix:"mat4",colorOne:"vec3",colorTwo:"vec3"},attributes:{corners:"vec3"},vertexShader:`attribute vec2 corners;
165
+ </div>`,this._minWidth=100,this._maxWidth=150,this._isCenter=e.isCenter==null||e.isCenter,this._mPx=0,this.currWidth=0,this._metersInMinSize=0,this.el=null,this._scaleLabelEl=null}_renderTemplate(){return _r(this._template)[0]}oninit(){this.el=this._renderTemplate(),this._scaleLabelEl=this.el.querySelector(".og-scale-label"),this.renderer.div.appendChild(this.el),this._isCenter?(this.planet.camera.events.on("moveend",()=>{this._drawScreen(this.planet.renderer.handler.getCenter())}),!this.planet.terrain.isEmpty&&this.planet.terrain.events.on("loadend",()=>{this._drawScreen(this.planet.renderer.handler.getCenter())})):(this.renderer.events.on("mousemove",e=>{e.leftButtonHold||e.rightButtonHold||this._drawScreen(e.pos)}),this.planet.camera.events.on("moveend",()=>{let e=this.renderer.events.mouseState;e.leftButtonHold||e.rightButtonHold||this._drawScreen(e.pos)}))}_drawScreen(e){let t=this.planet.camera,i=e,r=this.planet.getDistanceFromPixel(i)||0;r===0&&(i=t.project3v(m.ZERO),r=this.planet.getDistanceFromPixel(i)||0);let s=t.getForward().scaleTo(r).addA(t.eye),n=r*Math.tan(t.viewAngle*U),o=s.add(t.getRight().scaleTo(n)),l=t.project3v(o);this._mPx=n/l.distance(i);let h=this._mPx*this._minWidth,c=yt(Ur,h,(g,f)=>g-f);c<0&&(c=~c);let d=Ur[c],u=(d-h)/(Ur[c+1]-d);this.currWidth=this._minWidth+u*(this._maxWidth-this._minWidth),this._scaleLabelEl.innerText=d>=1e3?d/1e3+" km":d>=1?`${d} m`:d>=.01?100*d+" cm":1e3*d+" mm",this._metersInMinSize=h,this.el.style.width=this.currWidth+"px"}}class ba extends ee{constructor(e={}){super({name:"SimpleSkyBackground",...e}),this._colorOne=new Float32Array([128/255,223/255,1]),this._colorTwo=new Float32Array([10/255,15/255,56/255])}get colorOne(){let e=this._colorOne;return ur([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}get colorTwo(){let e=this._colorTwo;return ur([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}set colorOne(e){let t=Fi(e);this._colorOne[0]=t.x,this._colorOne[1]=t.y,this._colorOne[2]=t.z}set colorTwo(e){let t=Fi(e);this._colorTwo[0]=t.x,this._colorTwo[1]=t.y,this._colorTwo[2]=t.z}oninit(){this.renderer.handler.addProgram(new X("simpleSkyBackground",{uniforms:{iResolution:"vec2",fov:"float",camPos:"vec3",earthRadius:"float",viewMatrix:"mat4",colorOne:"vec3",colorTwo:"vec3"},attributes:{corners:"vec3"},vertexShader:`attribute vec2 corners;
166
166
 
167
167
  varying vec2 tc;
168
168
 
@@ -268,7 +268,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
268
268
  float maxI = sqrt(bigRadius * bigRadius + bigRadius * bigRadius);
269
269
 
270
270
  gl_FragColor = vec4(mix(colorOne, colorTwo, Ix / maxI), 1.0);
271
- }`})),this.activate()}onactivate(){super.onactivate(),this.planet.events.on("draw",this._drawBackground,this)}ondeactivate(){super.ondeactivate(),this.planet.events.off("draw",this._drawBackground)}_drawBackground(){let e=this.renderer.handler,t=e.programs.simpleSkyBackground,i=t._program,s=i.uniforms,r=e.gl,n=this.planet.camera;r.disable(r.DEPTH_TEST),t.activate(),r.bindBuffer(r.ARRAY_BUFFER,this.renderer.screenFramePositionBuffer),r.vertexAttribPointer(i.attributes.corners,2,r.FLOAT,!1,0,0),r.uniform3fv(s.camPos,[n.eye.x,n.eye.y,n.eye.z]),r.uniform2fv(s.iResolution,[e.getWidth(),e.getHeight()]),r.uniform1f(s.fov,n.getViewAngle()),r.uniform1f(s.earthRadius,this.planet.ellipsoid.getPolarSize()+1),r.uniform3fv(s.colorOne,this._colorOne),r.uniform3fv(s.colorTwo,this._colorTwo),r.uniformMatrix4fv(s.viewMatrix,!1,n.getViewMatrix()),r.drawArrays(r.TRIANGLE_STRIP,0,4),r.enable(r.DEPTH_TEST)}}const Us=14959787e4;function Gs(a){var e=a-Gi,t=282.9404+470935e-10*e,i=.016709-1151e-12*e,s=os(356.047+.9856002585*e),r=23.4392911-3563e-10*e,n=s+J*i*Math.sin(s*j)*(1+i*Math.cos(s*j)),o=Math.cos(n*j)-i,l=Math.sin(n*j)*Math.sqrt(1-i*i),h=Math.sqrt(o*o+l*l),c=os(Math.atan2(l,o)*J+t),d=o=h*Math.cos(c*j),u=(l=h*Math.sin(c*j))*Math.cos(r*j),g=l*Math.sin(r*j),f=Pi*(24*e/23.9344694-259.853/360);return O.zRotation(-f).mulVec3(new v(-d*Us,-u*Us,g*Us))}class ch{constructor(e){this._renderNode=null,this._position=e.position||new v,this._ambient=e.ambient||new v,this._diffuse=e.diffuse||new v(.8,.8,.8),this._specular=e.specular||new v(.18,.18,.18),this._shininess=e.shininess!=null?e.shininess:3.3,this._active=!0,this._tempAmbient=this._ambient.clone(),this._tempDiffuse=this._diffuse.clone(),this._tempSpecular=this._specular.clone(),this._tempShininess=this._shininess}isActive(){return this._active}setPosition3v(e){this.setPosition(e.x,e.y,e.z)}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,this._renderNode&&(this._renderNode._lightPosition[0]=e,this._renderNode._lightPosition[1]=t,this._renderNode._lightPosition[2]=i)}getPosition(){return this._position.clone()}setAmbient3v(e){this.setAmbient(e.x,e.y,e.z)}setDiffuse3v(e){this.setDiffuse(e.x,e.y,e.z)}setSpecular3v(e){this.setSpecular(e.x,e.y,e.z)}setAmbient(e,t,i){this._ambient.set(e,t,i);const s=this._renderNode;s&&(s._lightParams[0]=e,s._lightParams[1]=t,s._lightParams[2]=i)}setDiffuse(e,t,i){this._diffuse.set(e,t,i);const s=this._renderNode;s&&(s._lightParams[3]=e,s._lightParams[4]=t,s._lightParams[5]=i)}setSpecular(e,t,i){this._specular.set(e,t,i);const s=this._renderNode;s&&(s._lightParams[6]=e,s._lightParams[7]=t,s._lightParams[8]=i)}setShininess(e){this._shininess=e;const t=this._renderNode;t&&(t._lightShininess=e)}addTo(e){this._renderNode=e,this.setShininess(this._shininess),this.setAmbient3v(this._ambient),this.setDiffuse3v(this._diffuse),this.setSpecular3v(this._specular)}}class js extends te{constructor(e={}){super({autoActivate:!0,...e}),this._name="sun",this.activationHeight=e.activationHeight||12079e3,this.offsetVertical=e.offsetVertical||-5e6,this.offsetHorizontal=e.offsetHorizontal||5e6,this.sunlight=new ch({ambient:new v(.15,.15,.25),diffuse:new v(.9,.9,.8),specular:new v(.1,.1,.06),shininess:110}),this._currDate=0,this._prevDate=0,this._clockPtr=null,this._lightOn=!1,this._f=0,this._k=0,this._stopped=e.stopped||!1}oninit(){this.planet.lightEnabled=!0,this.sunlight.addTo(this.planet),this.renderer.events.on("draw",this._draw,this),this._clockPtr||(this._clockPtr=this.renderer.handler.defaultClock)}stop(){this._stopped=!0,this.deactivate()}start(){this._stopped=!1,this.activate()}onactivate(){super.onactivate(),this._stopped=!1}bindClock(e){this._clockPtr=e}_draw(){if(this._clockPtr)if(this._currDate=this._clockPtr.currentDate,this._stopped)this.sunlight.setPosition3v(Gs(this._currDate));else{let e=this.planet.camera;if(e.getHeight()<this.activationHeight||!this._active){this._lightOn=!0,this._f=1;let t=e.eye.normal(),i=e.getForward();i.scale(Math.sign(e.getUp().dot(t))),e.slope>.99&&(i=e.getUp());let s=v.proj_b_to_plane(i,t,i).normalize().scale(this.offsetVertical),r=v.proj_b_to_plane(e.getRight(),t,e.getRight()).normalize().scale(this.offsetHorizontal),n=s.add(r),o=e.eye.add(n);if(this._k>0){this._k-=.001;let l=O.getRotationBetweenVectors(this.sunlight._position.normal(),o.normal()).slerp(O.IDENTITY,this._k).normalize();this.sunlight.setPosition3v(l.mulVec3(this.sunlight._position))}else this.sunlight.setPosition3v(o)}else if(this._k=1,this._f>0){this._f-=.001;let t=O.getRotationBetweenVectors(this.sunlight._position.normal(),Gs(this._currDate).normal()).slerp(O.IDENTITY,this._f).normalize();this.sunlight.setPosition3v(t.mulVec3(this.sunlight._position))}else(Math.abs(this._currDate-this._prevDate)>34e-5&&this._active||this._lightOn)&&(this._lightOn=!1,this._prevDate=this._currDate,this.sunlight.setPosition3v(Gs(this._currDate)),this._f=0)}}}const dh=["inertiamove","drag","doubletapzoom"];class wo{constructor(){this.x=0,this.y=0,this.prev_x=0,this.prev_y=0,this.grabbedPoint=null,this.grabbedSpheroid=new Ve,this._vec=new N,this._vecPrev=new N}get dY(){return this.y-this.prev_y}get dX(){return this.x-this.prev_x}get vec(){return this._vec.set(this.x,this.y)}get vecPrev(){return this._vecPrev.set(this.prev_x,this.prev_y)}}class Co extends te{constructor(e={}){super(e),this._onCameraFly=()=>{this.stopRotation()},this._name="touchNavigation",this.events=he(dh,this),this.grabbedPoint=new v,this.inertia=e.inertia!=null?e.inertia:.007,this.grabbedSpheroid=new Ve,this.planet=null,this.qRot=new O,this.scaleRot=0,this.rot=1,this._eye0=new v,this.pointOnEarth=null,this.earthUp=null,this.touches=[new wo,new wo],this._keyLock=new di,this._touching=!1}oninit(){this.renderer&&(this.renderer.events.on("touchstart",this.onTouchStart,this),this.renderer.events.on("touchend",this.onTouchEnd,this),this.renderer.events.on("doubletouch",this.onDoubleTouch,this),this.renderer.events.on("touchcancel",this.onTouchCancel,this),this.renderer.events.on("touchmove",this.onTouchMove,this),this.renderer.events.on("draw",this.onDraw,this))}onadd(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.on("flystart",this._onCameraFly)}onremove(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.off("flystart",this._onCameraFly)}onTouchStart(e){const t=this.renderer.handler;if(this._touching=!0,e.sys.touches.length===2){const i=this.touches[0],s=this.touches[1];i.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*t.pixelRatio,i.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*t.pixelRatio,i.prev_x=i.x,i.prev_y=i.y,i.grabbedPoint=this.planet.getCartesianFromPixelTerrain(new N(i.x,i.y))||null,s.x=(e.sys.touches.item(1).clientX-e.sys.offsetLeft)*t.pixelRatio,s.y=(e.sys.touches.item(1).clientY-e.sys.offsetTop)*t.pixelRatio,s.prev_x=s.x,s.prev_y=s.y,s.grabbedPoint=this.planet.getCartesianFromPixelTerrain(new N(s.x,s.y))||null,this.pointOnEarth=this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter())||null,this.pointOnEarth&&(this.earthUp=this.pointOnEarth.normal()),i.grabbedPoint&&s.grabbedPoint&&(i.grabbedSpheroid.radius=i.grabbedPoint.length(),s.grabbedSpheroid.radius=s.grabbedPoint.length(),this.stopRotation())}else e.sys.touches.length===1&&this._startTouchOne(e)}_startTouchOne(e){const t=this.touches[0],i=this.renderer.handler;t.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,t.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,t.prev_x=t.x,t.prev_y=t.y,t.grabbedPoint=this.planet.getCartesianFromPixelTerrain(e)||null,this._eye0.copy(this.planet.camera.eye),t.grabbedPoint&&(t.grabbedSpheroid.radius=t.grabbedPoint.length(),this.stopRotation())}stopRotation(){this.qRot.clear(),this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}onDoubleTouch(e){this.planet.stopFlying(),this.stopRotation();const t=this.planet.getCartesianFromPixelTerrain(e);if(t){const i=this.planet.ellipsoid.cartesianToLonLat(t);this.planet.flyLonLat(new A(i.lon,i.lat,.57*this.planet.camera.eye.distance(t))),this.events.dispatch(this.events.doubletapzoom,this)}}onTouchEnd(e){e.sys.touches.length===0&&(this._touching=!1),e.sys.touches.length===1&&this._startTouchOne(e),Math.abs(this.touches[0].x-this.touches[0].prev_x)<3&&Math.abs(this.touches[0].y-this.touches[0].prev_y)<3&&(this.scaleRot=0)}onTouchCancel(e){}onTouchMove(e){let t=this.planet.camera;const i=this.renderer.handler;if(e.sys.touches.length===2){this.renderer.controlsBag.scaleRot=1;let r=this.touches[0],n=this.touches[1];if(!r.grabbedPoint||!n.grabbedPoint)return;this.planet.stopFlying(),r.prev_x=r.x,r.prev_y=r.y,r.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,r.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,n.prev_x=n.x,n.prev_y=n.y,n.x=(e.sys.touches.item(1).clientX-e.sys.offsetLeft)*i.pixelRatio,n.y=(e.sys.touches.item(1).clientY-e.sys.offsetTop)*i.pixelRatio;const o=r.vec.add(n.vec).scale(.5),l=this.planet.getCartesianFromPixelTerrain(o);if(l){this.pointOnEarth=l;const h=Math.atan2(r.prev_y-n.prev_y,r.prev_x-n.prev_x),c=Math.atan2(r.y-n.y,r.x-n.x)-h,d=t.eye.distance(this.pointOnEarth),u=r.vec.sub(n.vec),g=r.vecPrev.sub(n.vecPrev);let f=d*-(1-u.length()/g.length());t.eye.addA(t.getForward().scale(f)),t.rotateAround(-c,!1,this.pointOnEarth,this.earthUp);const p=r.vec.add(n.vec).scale(.5),_=r.vecPrev.add(n.vecPrev).scale(.5),m=p.sub(_).scale(-1);var s=.5/d*t._lonLat.height*j;s>.003&&(s=.003),t.rotateHorizontal(s*-m.x,!1,this.pointOnEarth,this.earthUp),t.rotateVertical(s*-m.y,this.pointOnEarth),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this)}this.scaleRot=0}else if(e.sys.touches.length===1){let r=this.touches[0];if(r.prev_x=r.x,r.prev_y=r.y,r.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,r.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,!r.grabbedPoint)return;this.planet.stopFlying();let n=e.direction,o=new U(t.eye,n).hitSphere(r.grabbedSpheroid);if(o)if(t.slope>.2){this.qRot=O.getRotationBetweenVectors(o.normal(),r.grabbedPoint.normal());let l=this.qRot;t.eye=l.mulVec3(t.eye),t.rotate(l),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this),this.scaleRot=1}else{let l=r.grabbedPoint,h=v.add(l,t.getUp()),c=v.add(l,l.getNormal()),d=t.unproject(r.x,r.y),u=new v;new U(t.eye,d).hitPlaneRes(Pe.fromPoints(l,h,c),u)===U.INSIDE&&(t.eye=this._eye0.addA(u.subA(l).negate()),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this),this.scaleRot=0)}}}onDraw(){const e=this.renderer;if(e.controlsBag.scaleRot=this.scaleRot,this._touching)return;let t=this.planet.camera,i=t.eye.clone();if(!e.events.mouseState.leftButtonDown&&this.scaleRot){if(this.scaleRot-=this.inertia,this.scaleRot<=0)this.scaleRot=0;else{e.controlsBag.scaleRot=this.scaleRot;let s=this.qRot.slerp(O.IDENTITY,1-this.scaleRot*this.scaleRot*this.scaleRot).normalize();s.x||s.y||s.z||(this.scaleRot=0),t.eye=s.mulVec3(t.eye),t.rotate(s),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.inertiamove,this)}t.eye.distance(i)/t.getAltitude()>.01?(this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock)):(this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock))}}}class To extends te{constructor(e={}){super(e),this._keyLock=new di,this._move=0,this._targetPoint=null}oninit(){let e=new nt({classList:["og-map-button","og-zoomin-button"],icon:'<?xml version="1.0"?><svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z"/></svg>'});e.appendTo(this.renderer.div);let t=new nt({classList:["og-map-button","og-zoomout-button"],icon:'<?xml version="1.0"?><svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M 5 11 L 5 13 L 19 13 L 19 11 L 5 11 z"/></svg>'});t.appendTo(this.renderer.div),e.events.on("mousedown",()=>this.zoomIn()),e.events.on("mouseup",()=>this.stopZoom()),t.events.on("mousedown",()=>this.zoomOut()),t.events.on("mouseup",()=>this.stopZoom()),e.events.on("touchstart",()=>this.zoomIn()),e.events.on("touchend",()=>this.stopZoom()),e.events.on("touchcancel",()=>this.stopZoom()),t.events.on("touchstart",()=>this.zoomOut()),t.events.on("touchend",()=>this.stopZoom()),t.events.on("touchcancel",()=>this.stopZoom()),this.renderer.events.on("draw",this._draw,this)}zoomIn(){this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock),this._targetPoint=this.renderer.getCenter(),this._move=1}zoomOut(){this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock),this._targetPoint=this.renderer.getCenter(),this._move=-1}stopZoom(){this._move=0,this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}_draw(e){const t=this.planet.camera;if(this._move!==0){const i=this.planet.getCartesianFromPixelTerrain(e.getCenter());if(i){let s=.035*t.eye.distance(i);t.eye.addA(t.getForward().scale(this._move*s)),t.checkTerrainCollision(),t.update()}}}}class uh extends at{constructor(e={}){var t,i;super(e.name),this._ignoreTerrain=!1,this.events=new Ps(_h),this._ignoreTerrain=e.ignoreTerrain==null||e.ignoreTerrain,this._onSelect=e.onSelect||null,this._autoSelectionHide=e.autoSelectionHide||!1,this._planet=e.planet||null,this._startLonLat=null,this._heading=0,this._propsLabel=new V({name:"propsLabel",label:{text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,18]}}),(i=(t=this._propsLabel)==null?void 0:t.label)==null||i.setVisibility(!1),this._trackEntity=new V({polyline:{path3v:[],thickness:3.8,color:"rgb(455,455,455)",isClosed:!1}}),this._trackEntity.polyline.altitude=.01;let s=Z.createCylinder(1.1,0,2.7,20,1,!0,!1,0,0,0);this._cornerEntity=[new V({geoObject:{scale:1,instanced:!0,tag:"selection",color:"rgb(0,305,0)",object3d:s},properties:{name:"start"}}),new V({geoObject:{scale:1,instanced:!0,tag:"selection",color:"rgb(455,0,0)",object3d:s},properties:{name:"end"}})],this._trackLayer=new ge("track",{entities:[this._trackEntity,this._propsLabel],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!1}),this._cornersLayer=new ge("corners",{entities:[this._cornerEntity[0],this._cornerEntity[1]],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,4e6,.01],pickingScale:2})}set ignoreTerrain(e){this._ignoreTerrain=e}bindPlanet(e){this._planet=e}init(){this._activate()}onremove(){this._deactivate()}_activate(){var e,t,i,s,r;(t=(e=this._propsLabel)==null?void 0:e.label)==null||t.setVisibility(!1),this._onMouseMove_=this._onMouseMove.bind(this),(i=this.renderer)==null||i.events.on("mousemove",this._onMouseMove_,this),this._onMouseLdown_=this._onMouseLdown.bind(this),(s=this.renderer)==null||s.events.on("ldown",this._onMouseLdown_,this),this._onMouseLup_=this._onMouseLup.bind(this),(r=this.renderer)==null||r.events.on("lup",this._onMouseLup_,this),this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._cornersLayer)}_deactivate(){var e,t,i;this._startLonLat=null,this._trackLayer.remove(),this._cornersLayer.remove(),(e=this.renderer)==null||e.events.off("mousemove",this._onMouseMove_),(t=this.renderer)==null||t.events.off("ldown",this._onMouseLdown_),(i=this.renderer)==null||i.events.off("lup",this._onMouseLup_),this.clear(),this._onMouseMove_=null,this._onMouseLdown_=null,this._onMouseLup_=null}_onMouseLdown(e){var t,i,s,r,n,o;if(e.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.renderer.handler.canvas.style.cursor="pointer",!this._startLonLat){(t=this._propsLabel.label)==null||t.setVisibility(!1),(i=this._trackEntity.polyline)==null||i.setPath3v([]),(s=this._cornerEntity[0].geoObject)==null||s.setVisibility(!0),(r=this._cornerEntity[1].geoObject)==null||r.setVisibility(!0),(o=(n=this.renderer)==null?void 0:n.controls.mouseNavigation)==null||o.deactivate(),this._startLonLat=this._planet.getLonLatFromPixelTerrain(e);let l=this._planet.ellipsoid.lonLatToCartesian(this._startLonLat);this._cornerEntity[0].setCartesian3v(l),this._cornerEntity[1].setCartesian3v(l)}}_onMouseLup(e){var t,i,s;if(this._startLonLat){if(this._pickedCorner=null,this._anchorLonLat=null,(t=this._propsLabel.label)==null||t.setVisibility(!0),this._onSelect&&typeof this._onSelect=="function"){let r=this._cornerEntity[0].getLonLat(),n=this._cornerEntity[1].getLonLat(),o=[Math.min(r.lon,n.lon),Math.min(r.lat,n.lat),Math.max(r.lon,n.lon),Math.max(r.lat,n.lat)];this._onSelect(o)}this._autoSelectionHide&&this.clear(),this._startLonLat=null}e.renderer.handler.canvas.style.cursor="default",(s=(i=this.renderer)==null?void 0:i.controls.mouseNavigation)==null||s.activate()}_drawLine(e,t,i){var s;i||(i=this._planet.ellipsoid.lonLatToCartesian(e));let r=this._planet.ellipsoid.lonLatToCartesian(t),n=this._planet.ellipsoid.direct(e,t);this._heading=n.initialAzimuth;let o=[];this._cornerEntity[0].setCartesian3v(i),this._cornerEntity[1].setCartesian3v(r);let l=[i,this._planet.ellipsoid.lonLatToCartesian(new A(t.lon,e.lat,e.height)),r,this._planet.ellipsoid.lonLatToCartesian(new A(e.lon,t.lat,e.height)),i];o.push(i);let h=(c,d)=>{let u=d.sub(c),g=u.length();u.normalize();for(let f=0;f<120;f++){let p=u.scaleTo(f*g/120).addA(c);o.push(p)}};for(let c=0;c<l.length-1;c++)h(l[c],l[c+1]);(s=this._trackEntity.polyline)==null||s.setPath3v([o]),this._ignoreTerrain}_onMouseMove(e){var t;if(this._startLonLat){(t=this._propsLabel.label)==null||t.setVisibility(!0);let i=this._planet.getLonLatFromPixelTerrain(e);if(!i)return;this._drawLine(this._startLonLat,i)}}clear(){var e,t,i;(e=this._trackEntity.polyline)==null||e.clear(),(t=this._cornerEntity[0].geoObject)==null||t.setVisibility(!1),(i=this._cornerEntity[1].geoObject)==null||i.setVisibility(!1)}frame(){var e,t;let i=(e=this._trackEntity.polyline)==null?void 0:e.getPath3v()[0];if(i&&!this._ignoreTerrain){let r=0;for(let n=0,o=i.length-1;n<o;n++)r+=i[n+1].distance(i[n]);this._propsLabel.setCartesian3v(i[Math.floor(i.length/2)]),(t=this._propsLabel.label)==null||t.setText(`${s=r,s>1e3?`${(s/1e3).toFixed(1)} km`:s>9?`${Math.round(s)} m`:`${s.toFixed(1)} m`}, ${Math.round(this._heading)} deg`)}var s}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const _h=["add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];function Ke(a,e){return new Date(+a+1e3*e)}function fh(a,e=!0,t=!1){let i=ph[a.getMonth()],s=a.getUTCDate(),r=a.getUTCFullYear();if(e){let n=a.getUTCHours().toString().padStart(2,"0"),o=a.getUTCMinutes().toString().padStart(2,"0"),l=a.getUTCSeconds().toString().padStart(2,"0");return t?`${i} ${s} ${r} ${n}:${o}:${l}.${a.getUTCMilliseconds().toString().padStart(3,"0")}`:`${i} ${s} ${r} ${n}:${o}:${l}`}return`${i} ${s} ${r}`}function Eo(a,e=0,t=10,i=2,s="white"){a.lineWidth=i,a.strokeStyle=s,a.beginPath(),a.moveTo(e,0),a.lineTo(e,t),a.stroke()}function gh(a,e,t,i,s="12px Arial",r="black",n="left",o="bottom",l=0){a.save(),a.translate(t,i),a.rotate(l*j),a.fillStyle=r,a.textBaseline=o,a.font=s,a.textAlign=n,a.fillText(e,0,0),a.restore()}const Ys=[[.001,10],[.002,10],[.005,10],[.01,10],[.02,10],[.05,10],[.1,10],[.25,10],[.5,5],[1,10],[2,10],[5,5],[10,10],[15,15],[30,6],[60,12],[120,12],[300,5],[600,10],[900,15],[1800,6],[3600,12],[7200,10],[14400,4],[21600,6],[43200,12],[86400,24],[172800,2],[345600,4],[604800,7],[1296e3,15],[2592e3,5],[5184e3,6],[7776e3,9],[15552e3,18],[31536e3,12],[63072e3,2],[126144e3,4],[15768e4,5],[31536e4,10],[63072e4,2],[126144e4,4],[15768e5,5],[31536e5,10],[63072e5,2],[126144e5,4],[15768e6,5],[31536e6,10]],ph=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mh=["change","current"];class vh{constructor(e={}){this.events=he(mh),this._current=e.current||new Date,this._rangeStart=e.rangeStart||new Date,this._rangeEnd=e.rangeEnd||Ke(this._rangeStart,3600),this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this._minDate=e.minDate||null,this._maxDate=e.maxDate||null,this.multiplier=e.multiplier!=null?e.multiplier:1,this._requestAnimationFrameId=0,this._prevNow=0,this.dt=0}play(){this._requestAnimationFrameId||(this._prevNow=window.performance.now(),this._animationFrameCallback())}stop(){this._requestAnimationFrameId&&(window.cancelAnimationFrame(this._requestAnimationFrameId),this._requestAnimationFrameId=0)}stopped(){return this._requestAnimationFrameId==0}_animationFrameCallback(){this._requestAnimationFrameId=window.requestAnimationFrame(()=>{this._frame(),this._animationFrameCallback()})}_frame(){let e=window.performance.now();this.dt=e-this._prevNow,this._prevNow=e,this.current=new Date(this.currentTime+this.dt*this.multiplier)}get range(){return this._range}set(e,t){e===this._rangeStart&&t===this._rangeEnd||(this._rangeStart=e,this._rangeEnd=t,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e,t))}get current(){return this._current}get rangeStart(){return this._rangeStart}get rangeEnd(){return this._rangeEnd}get rangeStartTime(){return this._rangeStart.getTime()}get rangeEndTime(){return this._rangeEnd.getTime()}get currentTime(){return this._current.getTime()}set current(e){e!==this._current&&(this._maxDate&&e>this._maxDate?this._current=this._maxDate:this._minDate&&e<this._minDate?this._current=this._minDate:this._current=e,this.events.dispatch(this.events.current,this._current))}set rangeStart(e){e!==this._rangeStart&&(this._rangeStart=e,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e))}set rangeEnd(e){e!==this._rangeEnd&&(this._rangeEnd=e,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e))}}const Nt=.001,yh=["startdrag","stopdrag","startdragcurrent","stopdragcurrent","setcurrent","reset","play","playback","pause","visibility"],Ao="#bfbfbf";class xh extends be{constructor(e={}){super({template:`<div class="og-timeline">
271
+ }`})),this.activate()}onactivate(){super.onactivate(),this.planet.events.on("draw",this._drawBackground,this)}ondeactivate(){super.ondeactivate(),this.planet.events.off("draw",this._drawBackground)}_drawBackground(){let e=this.renderer.handler,t=e.programs.simpleSkyBackground,i=t._program,r=i.uniforms,s=e.gl,n=this.planet.camera;s.disable(s.DEPTH_TEST),t.activate(),s.bindBuffer(s.ARRAY_BUFFER,this.renderer.screenFramePositionBuffer),s.vertexAttribPointer(i.attributes.corners,2,s.FLOAT,!1,0,0),s.uniform3fv(r.camPos,[n.eye.x,n.eye.y,n.eye.z]),s.uniform2fv(r.iResolution,[e.getWidth(),e.getHeight()]),s.uniform1f(r.fov,n.getViewAngle()),s.uniform1f(r.earthRadius,this.planet.ellipsoid.getPolarSize()+1),s.uniform3fv(r.colorOne,this._colorOne),s.uniform3fv(r.colorTwo,this._colorTwo),s.uniformMatrix4fv(r.viewMatrix,!1,n.getViewMatrix()),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.enable(s.DEPTH_TEST)}}const Gr=14959787e4;function jr(a){var e=a-Gi,t=282.9404+470935e-10*e,i=.016709-1151e-12*e,r=or(356.047+.9856002585*e),s=23.4392911-3563e-10*e,n=r+J*i*Math.sin(r*U)*(1+i*Math.cos(r*U)),o=Math.cos(n*U)-i,l=Math.sin(n*U)*Math.sqrt(1-i*i),h=Math.sqrt(o*o+l*l),c=or(Math.atan2(l,o)*J+t),d=o=h*Math.cos(c*U),u=(l=h*Math.sin(c*U))*Math.cos(s*U),g=l*Math.sin(s*U),f=Pi*(24*e/23.9344694-259.853/360);return O.zRotation(-f).mulVec3(new m(-d*Gr,-u*Gr,g*Gr))}class ch{constructor(e){this._renderNode=null,this._position=e.position||new m,this._ambient=e.ambient||new m,this._diffuse=e.diffuse||new m(.8,.8,.8),this._specular=e.specular||new m(.18,.18,.18),this._shininess=e.shininess!=null?e.shininess:3.3,this._active=!0,this._tempAmbient=this._ambient.clone(),this._tempDiffuse=this._diffuse.clone(),this._tempSpecular=this._specular.clone(),this._tempShininess=this._shininess}isActive(){return this._active}setPosition3v(e){this.setPosition(e.x,e.y,e.z)}setPosition(e,t,i){this._position.x=e,this._position.y=t,this._position.z=i,this._renderNode&&(this._renderNode._lightPosition[0]=e,this._renderNode._lightPosition[1]=t,this._renderNode._lightPosition[2]=i)}getPosition(){return this._position.clone()}setAmbient3v(e){this.setAmbient(e.x,e.y,e.z)}setDiffuse3v(e){this.setDiffuse(e.x,e.y,e.z)}setSpecular3v(e){this.setSpecular(e.x,e.y,e.z)}setAmbient(e,t,i){this._ambient.set(e,t,i);const r=this._renderNode;r&&(r._lightParams[0]=e,r._lightParams[1]=t,r._lightParams[2]=i)}setDiffuse(e,t,i){this._diffuse.set(e,t,i);const r=this._renderNode;r&&(r._lightParams[3]=e,r._lightParams[4]=t,r._lightParams[5]=i)}setSpecular(e,t,i){this._specular.set(e,t,i);const r=this._renderNode;r&&(r._lightParams[6]=e,r._lightParams[7]=t,r._lightParams[8]=i)}setShininess(e){this._shininess=e;const t=this._renderNode;t&&(t._lightShininess=e)}addTo(e){this._renderNode=e,this.setShininess(this._shininess),this.setAmbient3v(this._ambient),this.setDiffuse3v(this._diffuse),this.setSpecular3v(this._specular)}}class qr extends ee{constructor(e={}){super({autoActivate:!0,...e}),this._name="sun",this.activationHeight=e.activationHeight||12079e3,this.offsetVertical=e.offsetVertical||-5e6,this.offsetHorizontal=e.offsetHorizontal||5e6,this.sunlight=new ch({ambient:new m(.15,.15,.25),diffuse:new m(.9,.9,.8),specular:new m(.1,.1,.06),shininess:110}),this._currDate=0,this._prevDate=0,this._clockPtr=null,this._lightOn=!1,this._f=0,this._k=0,this._stopped=e.stopped||!1}oninit(){this.planet.lightEnabled=!0,this.sunlight.addTo(this.planet),this.renderer.events.on("draw",this._draw,this),this._clockPtr||(this._clockPtr=this.renderer.handler.defaultClock)}stop(){this._stopped=!0,this.deactivate()}start(){this._stopped=!1,this.activate()}onactivate(){super.onactivate(),this._stopped=!1}bindClock(e){this._clockPtr=e}_draw(){if(this._clockPtr)if(this._currDate=this._clockPtr.currentDate,this._stopped)this.sunlight.setPosition3v(jr(this._currDate));else{let e=this.planet.camera;if(e.getHeight()<this.activationHeight||!this._active){this._lightOn=!0,this._f=1;let t=e.eye.normal(),i=e.getForward();i.scale(Math.sign(e.getUp().dot(t))),e.slope>.99&&(i=e.getUp());let r=m.proj_b_to_plane(i,t,i).normalize().scale(this.offsetVertical),s=m.proj_b_to_plane(e.getRight(),t,e.getRight()).normalize().scale(this.offsetHorizontal),n=r.add(s),o=e.eye.add(n);if(this._k>0){this._k-=.001;let l=O.getRotationBetweenVectors(this.sunlight._position.normal(),o.normal()).slerp(O.IDENTITY,this._k).normalize();this.sunlight.setPosition3v(l.mulVec3(this.sunlight._position))}else this.sunlight.setPosition3v(o)}else if(this._k=1,this._f>0){this._f-=.001;let t=O.getRotationBetweenVectors(this.sunlight._position.normal(),jr(this._currDate).normal()).slerp(O.IDENTITY,this._f).normalize();this.sunlight.setPosition3v(t.mulVec3(this.sunlight._position))}else(Math.abs(this._currDate-this._prevDate)>34e-5&&this._active||this._lightOn)&&(this._lightOn=!1,this._prevDate=this._currDate,this.sunlight.setPosition3v(jr(this._currDate)),this._f=0)}}}const dh=["inertiamove","drag","doubletapzoom"];class wa{constructor(){this.x=0,this.y=0,this.prev_x=0,this.prev_y=0,this.grabbedPoint=null,this.grabbedSpheroid=new He,this._vec=new N,this._vecPrev=new N}get dY(){return this.y-this.prev_y}get dX(){return this.x-this.prev_x}get vec(){return this._vec.set(this.x,this.y)}get vecPrev(){return this._vecPrev.set(this.prev_x,this.prev_y)}}class Ca extends ee{constructor(e={}){super(e),this._onCameraFly=()=>{this.stopRotation()},this._name="touchNavigation",this.events=le(dh,this),this.grabbedPoint=new m,this.inertia=e.inertia!=null?e.inertia:.007,this.grabbedSpheroid=new He,this.planet=null,this.qRot=new O,this.scaleRot=0,this.rot=1,this._eye0=new m,this.pointOnEarth=null,this.earthUp=null,this.touches=[new wa,new wa],this._keyLock=new ci,this._touching=!1}oninit(){this.renderer&&(this.renderer.events.on("touchstart",this.onTouchStart,this),this.renderer.events.on("touchend",this.onTouchEnd,this),this.renderer.events.on("doubletouch",this.onDoubleTouch,this),this.renderer.events.on("touchcancel",this.onTouchCancel,this),this.renderer.events.on("touchmove",this.onTouchMove,this),this.renderer.events.on("draw",this.onDraw,this))}onadd(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.on("flystart",this._onCameraFly)}onremove(){var e;(e=this.planet)!=null&&e.camera&&this.planet.camera.events.off("flystart",this._onCameraFly)}onTouchStart(e){const t=this.renderer.handler;if(this._touching=!0,e.sys.touches.length===2){const i=this.touches[0],r=this.touches[1];i.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*t.pixelRatio,i.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*t.pixelRatio,i.prev_x=i.x,i.prev_y=i.y,i.grabbedPoint=this.planet.getCartesianFromPixelTerrain(new N(i.x,i.y))||null,r.x=(e.sys.touches.item(1).clientX-e.sys.offsetLeft)*t.pixelRatio,r.y=(e.sys.touches.item(1).clientY-e.sys.offsetTop)*t.pixelRatio,r.prev_x=r.x,r.prev_y=r.y,r.grabbedPoint=this.planet.getCartesianFromPixelTerrain(new N(r.x,r.y))||null,this.pointOnEarth=this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter())||null,this.pointOnEarth&&(this.earthUp=this.pointOnEarth.normal()),i.grabbedPoint&&r.grabbedPoint&&(i.grabbedSpheroid.radius=i.grabbedPoint.length(),r.grabbedSpheroid.radius=r.grabbedPoint.length(),this.stopRotation())}else e.sys.touches.length===1&&this._startTouchOne(e)}_startTouchOne(e){const t=this.touches[0],i=this.renderer.handler;t.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,t.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,t.prev_x=t.x,t.prev_y=t.y,t.grabbedPoint=this.planet.getCartesianFromPixelTerrain(e)||null,this._eye0.copy(this.planet.camera.eye),t.grabbedPoint&&(t.grabbedSpheroid.radius=t.grabbedPoint.length(),this.stopRotation())}stopRotation(){this.qRot.clear(),this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}onDoubleTouch(e){this.planet.stopFlying(),this.stopRotation();const t=this.planet.getCartesianFromPixelTerrain(e);if(t){const i=this.planet.ellipsoid.cartesianToLonLat(t);this.planet.flyLonLat(new A(i.lon,i.lat,.57*this.planet.camera.eye.distance(t))),this.events.dispatch(this.events.doubletapzoom,this)}}onTouchEnd(e){e.sys.touches.length===0&&(this._touching=!1),e.sys.touches.length===1&&this._startTouchOne(e),Math.abs(this.touches[0].x-this.touches[0].prev_x)<3&&Math.abs(this.touches[0].y-this.touches[0].prev_y)<3&&(this.scaleRot=0)}onTouchCancel(e){}onTouchMove(e){let t=this.planet.camera;const i=this.renderer.handler;if(e.sys.touches.length===2){this.renderer.controlsBag.scaleRot=1;let s=this.touches[0],n=this.touches[1];if(!s.grabbedPoint||!n.grabbedPoint)return;this.planet.stopFlying(),s.prev_x=s.x,s.prev_y=s.y,s.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,s.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,n.prev_x=n.x,n.prev_y=n.y,n.x=(e.sys.touches.item(1).clientX-e.sys.offsetLeft)*i.pixelRatio,n.y=(e.sys.touches.item(1).clientY-e.sys.offsetTop)*i.pixelRatio;const o=s.vec.add(n.vec).scale(.5),l=this.planet.getCartesianFromPixelTerrain(o);if(l){this.pointOnEarth=l;const h=Math.atan2(s.prev_y-n.prev_y,s.prev_x-n.prev_x),c=Math.atan2(s.y-n.y,s.x-n.x)-h,d=t.eye.distance(this.pointOnEarth),u=s.vec.sub(n.vec),g=s.vecPrev.sub(n.vecPrev);let f=d*-(1-u.length()/g.length());t.eye.addA(t.getForward().scale(f)),t.rotateAround(-c,!1,this.pointOnEarth,this.earthUp);const p=s.vec.add(n.vec).scale(.5),_=s.vecPrev.add(n.vecPrev).scale(.5),v=p.sub(_).scale(-1);var r=.5/d*t._lonLat.height*U;r>.003&&(r=.003),t.rotateHorizontal(r*-v.x,!1,this.pointOnEarth,this.earthUp),t.rotateVertical(r*-v.y,this.pointOnEarth),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this)}this.scaleRot=0}else if(e.sys.touches.length===1){let s=this.touches[0];if(s.prev_x=s.x,s.prev_y=s.y,s.x=(e.sys.touches.item(0).clientX-e.sys.offsetLeft)*i.pixelRatio,s.y=(e.sys.touches.item(0).clientY-e.sys.offsetTop)*i.pixelRatio,!s.grabbedPoint)return;this.planet.stopFlying();let n=e.direction,o=new H(t.eye,n).hitSphere(s.grabbedSpheroid);if(o)if(t.slope>.2){this.qRot=O.getRotationBetweenVectors(o.normal(),s.grabbedPoint.normal());let l=this.qRot;t.eye=l.mulVec3(t.eye),t.rotate(l),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this),this.scaleRot=1}else{let l=s.grabbedPoint,h=m.add(l,t.getUp()),c=m.add(l,l.getNormal()),d=t.unproject(s.x,s.y),u=new m;new H(t.eye,d).hitPlaneRes(we.fromPoints(l,h,c),u)===H.INSIDE&&(t.eye=this._eye0.addA(u.subA(l).negate()),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.drag,this),this.scaleRot=0)}}}onDraw(){const e=this.renderer;if(e.controlsBag.scaleRot=this.scaleRot,this._touching)return;let t=this.planet.camera,i=t.eye.clone();if(!e.events.mouseState.leftButtonDown&&this.scaleRot){if(this.scaleRot-=this.inertia,this.scaleRot<=0)this.scaleRot=0;else{e.controlsBag.scaleRot=this.scaleRot;let r=this.qRot.slerp(O.IDENTITY,1-this.scaleRot*this.scaleRot*this.scaleRot).normalize();r.x||r.y||r.z||(this.scaleRot=0),t.eye=r.mulVec3(t.eye),t.rotate(r),t.checkTerrainCollision(),t.update(),this.events.dispatch(this.events.inertiamove,this)}t.eye.distance(i)/t.getAltitude()>.01?(this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock)):(this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock))}}}class Ta extends ee{constructor(e={}){super(e),this._keyLock=new ci,this._move=0,this._targetPoint=null}oninit(){let e=new nt({classList:["og-map-button","og-zoomin-button"],icon:'<?xml version="1.0"?><svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z"/></svg>'});e.appendTo(this.renderer.div);let t=new nt({classList:["og-map-button","og-zoomout-button"],icon:'<?xml version="1.0"?><svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M 5 11 L 5 13 L 19 13 L 19 11 L 5 11 z"/></svg>'});t.appendTo(this.renderer.div),e.events.on("mousedown",()=>this.zoomIn()),e.events.on("mouseup",()=>this.stopZoom()),t.events.on("mousedown",()=>this.zoomOut()),t.events.on("mouseup",()=>this.stopZoom()),e.events.on("touchstart",()=>this.zoomIn()),e.events.on("touchend",()=>this.stopZoom()),e.events.on("touchcancel",()=>this.stopZoom()),t.events.on("touchstart",()=>this.zoomOut()),t.events.on("touchend",()=>this.stopZoom()),t.events.on("touchcancel",()=>this.stopZoom()),this.renderer.events.on("draw",this._draw,this)}zoomIn(){this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock),this._targetPoint=this.renderer.getCenter(),this._move=1}zoomOut(){this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet._normalMapCreator.lock(this._keyLock),this._targetPoint=this.renderer.getCenter(),this._move=-1}stopZoom(){this._move=0,this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet._normalMapCreator.free(this._keyLock)}_draw(e){const t=this.planet.camera;if(this._move!==0){const i=this.planet.getCartesianFromPixelTerrain(e.getCenter());if(i){let r=.035*t.eye.distance(i);t.eye.addA(t.getForward().scale(this._move*r)),t.checkTerrainCollision(),t.update()}}}}class uh extends ot{constructor(e={}){var t,i;super(e.name),this._ignoreTerrain=!1,this.events=new Sr(_h),this._ignoreTerrain=e.ignoreTerrain==null||e.ignoreTerrain,this._onSelect=e.onSelect||null,this._autoSelectionHide=e.autoSelectionHide||!1,this._planet=e.planet||null,this._startLonLat=null,this._heading=0,this._propsLabel=new V({name:"propsLabel",label:{text:"",size:11,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"center",offset:[0,18]}}),(i=(t=this._propsLabel)==null?void 0:t.label)==null||i.setVisibility(!1),this._trackEntity=new V({polyline:{path3v:[],thickness:3.8,color:"rgb(455,455,455)",isClosed:!1}}),this._trackEntity.polyline.altitude=.01;let r=Z.createCylinder(1.1,0,2.7,20,1,!0,!1,0,0,0);this._cornerEntity=[new V({geoObject:{scale:1,instanced:!0,tag:"selection",color:"rgb(0,305,0)",object3d:r},properties:{name:"start"}}),new V({geoObject:{scale:1,instanced:!0,tag:"selection",color:"rgb(455,0,0)",object3d:r},properties:{name:"end"}})],this._trackLayer=new fe("track",{entities:[this._trackEntity,this._propsLabel],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!1}),this._cornersLayer=new fe("corners",{entities:[this._cornerEntity[0],this._cornerEntity[1]],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,4e6,.01],pickingScale:2})}set ignoreTerrain(e){this._ignoreTerrain=e}bindPlanet(e){this._planet=e}init(){this._activate()}onremove(){this._deactivate()}_activate(){var e,t,i,r,s;(t=(e=this._propsLabel)==null?void 0:e.label)==null||t.setVisibility(!1),this._onMouseMove_=this._onMouseMove.bind(this),(i=this.renderer)==null||i.events.on("mousemove",this._onMouseMove_,this),this._onMouseLdown_=this._onMouseLdown.bind(this),(r=this.renderer)==null||r.events.on("ldown",this._onMouseLdown_,this),this._onMouseLup_=this._onMouseLup.bind(this),(s=this.renderer)==null||s.events.on("lup",this._onMouseLup_,this),this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._cornersLayer)}_deactivate(){var e,t,i;this._startLonLat=null,this._trackLayer.remove(),this._cornersLayer.remove(),(e=this.renderer)==null||e.events.off("mousemove",this._onMouseMove_),(t=this.renderer)==null||t.events.off("ldown",this._onMouseLdown_),(i=this.renderer)==null||i.events.off("lup",this._onMouseLup_),this.clear(),this._onMouseMove_=null,this._onMouseLdown_=null,this._onMouseLup_=null}_onMouseLdown(e){var t,i,r,s,n,o;if(e.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.renderer.handler.canvas.style.cursor="pointer",!this._startLonLat){(t=this._propsLabel.label)==null||t.setVisibility(!1),(i=this._trackEntity.polyline)==null||i.setPath3v([]),(r=this._cornerEntity[0].geoObject)==null||r.setVisibility(!0),(s=this._cornerEntity[1].geoObject)==null||s.setVisibility(!0),(o=(n=this.renderer)==null?void 0:n.controls.mouseNavigation)==null||o.deactivate(),this._startLonLat=this._planet.getLonLatFromPixelTerrain(e);let l=this._planet.ellipsoid.lonLatToCartesian(this._startLonLat);this._cornerEntity[0].setCartesian3v(l),this._cornerEntity[1].setCartesian3v(l)}}_onMouseLup(e){var t,i,r;if(this._startLonLat){if(this._pickedCorner=null,this._anchorLonLat=null,(t=this._propsLabel.label)==null||t.setVisibility(!0),this._onSelect&&typeof this._onSelect=="function"){let s=this._cornerEntity[0].getLonLat(),n=this._cornerEntity[1].getLonLat(),o=[Math.min(s.lon,n.lon),Math.min(s.lat,n.lat),Math.max(s.lon,n.lon),Math.max(s.lat,n.lat)];this._onSelect(o)}this._autoSelectionHide&&this.clear(),this._startLonLat=null}e.renderer.handler.canvas.style.cursor="default",(r=(i=this.renderer)==null?void 0:i.controls.mouseNavigation)==null||r.activate()}_drawLine(e,t,i){var r;i||(i=this._planet.ellipsoid.lonLatToCartesian(e));let s=this._planet.ellipsoid.lonLatToCartesian(t),n=this._planet.ellipsoid.direct(e,t);this._heading=n.initialAzimuth;let o=[];this._cornerEntity[0].setCartesian3v(i),this._cornerEntity[1].setCartesian3v(s);let l=[i,this._planet.ellipsoid.lonLatToCartesian(new A(t.lon,e.lat,e.height)),s,this._planet.ellipsoid.lonLatToCartesian(new A(e.lon,t.lat,e.height)),i];o.push(i);let h=(c,d)=>{let u=d.sub(c),g=u.length();u.normalize();for(let f=0;f<120;f++){let p=u.scaleTo(f*g/120).addA(c);o.push(p)}};for(let c=0;c<l.length-1;c++)h(l[c],l[c+1]);(r=this._trackEntity.polyline)==null||r.setPath3v([o]),this._ignoreTerrain}_onMouseMove(e){var t;if(this._startLonLat){(t=this._propsLabel.label)==null||t.setVisibility(!0);let i=this._planet.getLonLatFromPixelTerrain(e);if(!i)return;this._drawLine(this._startLonLat,i)}}clear(){var e,t,i;(e=this._trackEntity.polyline)==null||e.clear(),(t=this._cornerEntity[0].geoObject)==null||t.setVisibility(!1),(i=this._cornerEntity[1].geoObject)==null||i.setVisibility(!1)}frame(){var e,t;let i=(e=this._trackEntity.polyline)==null?void 0:e.getPath3v()[0];if(i&&!this._ignoreTerrain){let s=0;for(let n=0,o=i.length-1;n<o;n++)s+=i[n+1].distance(i[n]);this._propsLabel.setCartesian3v(i[Math.floor(i.length/2)]),(t=this._propsLabel.label)==null||t.setText(`${r=s,r>1e3?`${(r/1e3).toFixed(1)} km`:r>9?`${Math.round(r)} m`:`${r.toFixed(1)} m`}, ${Math.round(this._heading)} deg`)}var r}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const _h=["add","remove","mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter"];function Je(a,e){return new Date(+a+1e3*e)}function fh(a,e=!0,t=!1){let i=ph[a.getMonth()],r=a.getUTCDate(),s=a.getUTCFullYear();if(e){let n=a.getUTCHours().toString().padStart(2,"0"),o=a.getUTCMinutes().toString().padStart(2,"0"),l=a.getUTCSeconds().toString().padStart(2,"0");return t?`${i} ${r} ${s} ${n}:${o}:${l}.${a.getUTCMilliseconds().toString().padStart(3,"0")}`:`${i} ${r} ${s} ${n}:${o}:${l}`}return`${i} ${r} ${s}`}function Ea(a,e=0,t=10,i=2,r="white"){a.lineWidth=i,a.strokeStyle=r,a.beginPath(),a.moveTo(e,0),a.lineTo(e,t),a.stroke()}function gh(a,e,t,i,r="12px Arial",s="black",n="left",o="bottom",l=0){a.save(),a.translate(t,i),a.rotate(l*U),a.fillStyle=s,a.textBaseline=o,a.font=r,a.textAlign=n,a.fillText(e,0,0),a.restore()}const Yr=[[.001,10],[.002,10],[.005,10],[.01,10],[.02,10],[.05,10],[.1,10],[.25,10],[.5,5],[1,10],[2,10],[5,5],[10,10],[15,15],[30,6],[60,12],[120,12],[300,5],[600,10],[900,15],[1800,6],[3600,12],[7200,10],[14400,4],[21600,6],[43200,12],[86400,24],[172800,2],[345600,4],[604800,7],[1296e3,15],[2592e3,5],[5184e3,6],[7776e3,9],[15552e3,18],[31536e3,12],[63072e3,2],[126144e3,4],[15768e4,5],[31536e4,10],[63072e4,2],[126144e4,4],[15768e5,5],[31536e5,10],[63072e5,2],[126144e5,4],[15768e6,5],[31536e6,10]],ph=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mh=["change","current"];class vh{constructor(e={}){this.events=le(mh),this._current=e.current||new Date,this._rangeStart=e.rangeStart||new Date,this._rangeEnd=e.rangeEnd||Je(this._rangeStart,3600),this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this._minDate=e.minDate||null,this._maxDate=e.maxDate||null,this.multiplier=e.multiplier!=null?e.multiplier:1,this._requestAnimationFrameId=0,this._prevNow=0,this.dt=0}play(){this._requestAnimationFrameId||(this._prevNow=window.performance.now(),this._animationFrameCallback())}stop(){this._requestAnimationFrameId&&(window.cancelAnimationFrame(this._requestAnimationFrameId),this._requestAnimationFrameId=0)}stopped(){return this._requestAnimationFrameId==0}_animationFrameCallback(){this._requestAnimationFrameId=window.requestAnimationFrame(()=>{this._frame(),this._animationFrameCallback()})}_frame(){let e=window.performance.now();this.dt=e-this._prevNow,this._prevNow=e,this.current=new Date(this.currentTime+this.dt*this.multiplier)}get range(){return this._range}set(e,t){e===this._rangeStart&&t===this._rangeEnd||(this._rangeStart=e,this._rangeEnd=t,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e,t))}get current(){return this._current}get rangeStart(){return this._rangeStart}get rangeEnd(){return this._rangeEnd}get rangeStartTime(){return this._rangeStart.getTime()}get rangeEndTime(){return this._rangeEnd.getTime()}get currentTime(){return this._current.getTime()}set current(e){e!==this._current&&(this._maxDate&&e>this._maxDate?this._current=this._maxDate:this._minDate&&e<this._minDate?this._current=this._minDate:this._current=e,this.events.dispatch(this.events.current,this._current))}set rangeStart(e){e!==this._rangeStart&&(this._rangeStart=e,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e))}set rangeEnd(e){e!==this._rangeEnd&&(this._rangeEnd=e,this._range=this._rangeEnd.getTime()-this._rangeStart.getTime(),this.events.dispatch(this.events.change,e))}}const Ot=.001,yh=["startdrag","stopdrag","startdragcurrent","stopdragcurrent","setcurrent","reset","play","playback","pause","visibility"],Aa="#bfbfbf";class xh extends be{constructor(e={}){super({template:`<div class="og-timeline">
272
272
 
273
273
  <div class="og-timeline-top">
274
274
  </div>
@@ -287,7 +287,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
287
287
  </div>
288
288
  </div>
289
289
 
290
- </div>`,model:new vh({rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,current:e.currentDate,minDate:e.minDate,maxDate:e.maxDate})}),this._onMouseWheel=t=>{if(this._isMouseOver){let i=this._canvasEl.getBoundingClientRect(),s=t.clientX-i.left,r=-(s-.5*this.clientWidth),n=this.model.rangeStartTime+this._millisecondsInPixel*s;this._zoom(n,r,Math.sign(t.wheelDelta))}else if(this._isCurrentMouseOver){let i=-((this.model.currentTime-this.model.rangeStartTime)/this._millisecondsInPixel-.5*this.clientWidth);this._zoom(this.model.currentTime,i,Math.sign(t.wheelDelta))}},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onMouseDown=t=>{this._isMouseOver?(this._isDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._clickTime=Date.now(),this._clickRangeStart=this.model.rangeStart,this._clickRangeEnd=this.model.rangeEnd,this.events.dispatch(this.events.startdrag,t)):this._isCurrentMouseOver&&(this._isCurrentDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._clickCurrentDate=this.model.current,this.events.dispatch(this.events.startdragcurrent,t))},this._onMouseUp=t=>{if(this._isDragging)if(this._isDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this._clickPosX===t.clientX&&Date.now()-this._clickTime<this._clickDelay){let i=this._canvasEl.getBoundingClientRect(),s=new Date(this.model.rangeStartTime+(t.clientX-i.left)*this._millisecondsInPixel);this.model.current=s,this.events.dispatch(this.events.stopdrag,s),this.events.dispatch(this.events.setcurrent,s)}else this.events.dispatch(this.events.stopdrag,this.model.current);else this._isCurrentDragging&&(this._isCurrentDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this.events.dispatch(this.events.stopdragcurrent,this.model.current))},this._onMouseEnter=()=>{this._isMouseOver=!0},this._onMouseOut=()=>{this._isMouseOver=!1},this._onCurrentMouseEnter=()=>{this._isCurrentMouseOver=!0},this._onCurrentMouseOut=()=>{this._isCurrentMouseOver=!1},this._onMouseMove=t=>{if(this._isDragging){let i=(this._clickPosX-t.clientX)*this._millisecondsInPixel*Nt;this.model.set(Ke(this._clickRangeStart,i),Ke(this._clickRangeEnd,i))}else if(this._isCurrentDragging){let i=(this._clickPosX-t.clientX)*this._millisecondsInPixel*Nt,s=Ke(this._clickCurrentDate,-i);s>=this.model.rangeStart&&s<=this.model.rangeEnd&&(this.model.current=Ke(this._clickCurrentDate,-i))}},this.events=this.events.registerNames(yh),this.fillStyle=e.fillStyle||"rgba(64, 59, 59, 1.0)",this.$controls=null,this._frameEl=null,this._currentEl=null,this._canvasEl=document.createElement("canvas"),this._ctx=this._canvasEl.getContext("2d"),this._isMouseOver=!1,this._isDragging=!1,this._isCurrentDragging=!1,this._isCurrentMouseOver=!1,this._minWidth=330,this._canvasScale=2,this._millisecondsInPixel=0,this._clickPosX=0,this._clickRangeStart=new Date,this._clickRangeEnd=new Date,this._clickCurrentDate=new Date,this._clickTime=0,this._clickDelay=450,this._onResizeObserver_=this._onResizeObserver.bind(this),this._resizeObserver=new ResizeObserver(this._onResizeObserver_),this._pauseBtn=new fe({classList:["og-timeline-control_button"],icon:`<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 512 512" height="512px" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="Layer_6"><rect fill="#252525" height="320" width="60" x="153" y="96"/><rect fill="#252525" height="320" width="60" x="299" y="96"/></g></svg>`,name:"pause"}),this._playBtn=new fe({classList:["og-timeline-control_button"],icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M8 5v14l11-7z" style="fill: black;"/></svg>',name:"play"}),this._buttons=new rn({buttons:[this._pauseBtn,this._playBtn]}),this._visibility=!1}_onResizeObserver(){this.resize()}get canvasScale(){return this._canvasScale}set canvasScale(e){e!==this._canvasScale&&(this._canvasScale=e,this.resize())}resize(){this._resize(),this.draw()}afterRender(e){this.resize()}render(){return super.render(),this.$controls=this.select(".og-timeline-controls"),this._frameEl=this.select(".og-timeline-frame"),this._currentEl=this.select(".og-timeline-current"),this.select(".og-timeline-frame .og-timeline-scale").appendChild(this._canvasEl),this._resizeObserver.observe(this.el),this.model.events.on("change",()=>{this.draw()}),this.model.events.on("current",e=>{this._drawCurrent(),this.events.dispatch(this.events.setcurrent,e)}),this._canvasEl.addEventListener("mouseenter",this._onMouseEnter),this._canvasEl.addEventListener("mouseout",this._onMouseOut),this._currentEl.addEventListener("mouseenter",this._onCurrentMouseEnter),this._currentEl.addEventListener("mouseout",this._onCurrentMouseOut),document.body.addEventListener("mousemove",this._onMouseMove),document.body.addEventListener("mousedown",this._onMouseDown),document.body.addEventListener("mouseup",this._onMouseUp),document.body.addEventListener("wheel",this._onMouseWheelFF),this._playBtn.appendTo(this.$controls),this._pauseBtn.appendTo(this.$controls),this.model.stopped()?(this._pauseBtn.setActive(!0,!0),this._pauseBtn.preventClick=!0):(this._playBtn.setActive(!0,!0),this._playBtn.preventClick=!0),this._buttons.events.on("change",e=>{switch(e.name){case"play":this.play();break;case"pause":this.pause()}}),this.setVisibility(!0),this}setVisibility(e){e!==this._visibility&&(this._visibility=e,this.el&&(this.el.style.display=e?"block":"none"),this.events.dispatch(this.events.visibility,e))}reset(){this.model.stop(),this.events.dispatch(this.events.reset,this.model)}play(){this.model.multiplier=Math.abs(this.model.multiplier),this.model.play(),this.events.dispatch(this.events.play,this.model)}pause(){this.model.stop(),this.events.dispatch(this.events.pause,this.model)}playBack(){this.model.multiplier=-1*Math.abs(this.model.multiplier),this.model.play(),this.events.dispatch(this.events.playback,this.model)}_zoom(e,t,i){let s=(e-(this.model.rangeStartTime+.5*this.model.range))*Nt,r=Ke(this.model.rangeStart,s),n=Ke(this.model.rangeEnd,s),o=(n.getTime()-r.getTime())/20*Nt,l=Ke(r,o*i),h=Ke(n,-o*i),c=(h.getTime()-l.getTime())/this.clientWidth;if(c<31536e6&&c>.1){let d=c*t*Nt;this.model.set(Ke(l,d),Ke(h,d))}}get clientWidth(){return this._canvasEl?this._canvasEl.width/this._canvasScale:0}get clientHeight(){return this._canvasEl?this._canvasEl.height/this._canvasScale:0}_resize(){this._frameEl&&(this._canvasEl.width=this._frameEl.clientWidth*this._canvasScale,this._canvasEl.height=this._frameEl.clientHeight*this._canvasScale,this._canvasEl.style.width=`${this._frameEl.clientWidth}px`,this._canvasEl.style.height=`${this._frameEl.clientHeight}px`)}getOffsetByTime(e){return(e-this.model.rangeStartTime)/this._millisecondsInPixel}remove(){super.remove(),this.model.stop()}_clearCanvas(){this._ctx.fillStyle=this.fillStyle,this._ctx.fillRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}_drawCurrent(){let e=(this.model.currentTime-this.model.rangeStartTime)/this._millisecondsInPixel;this.model.current<this.model.rangeStart||this.model.current>this.model.rangeEnd?this._currentEl.style.display="none":(this._currentEl.style.display="block",this._currentEl.style.transform=`translateX(${e}px)`)}draw(){this._millisecondsInPixel=this.model.range/this.clientWidth;let e=function(i){for(let s=0,r=Ys.length;s<r;s++)if(Ys[s][0]>i)return Ys[s-1]}(this._minWidth*this._millisecondsInPixel*Nt);if(e){this._clearCanvas();let i=1e3*e[0],s=i/this._millisecondsInPixel,r=e[1],n=(t=this.model.rangeStartTime)-t%i,o=e[0]<1,l=e[0]<86400;for(let h=n,c=this.model.rangeEndTime+i;h<c;h+=i){let d=this.getOffsetByTime(h);d>=0&&d<=this.clientWidth*this._canvasScale&&Eo(this._ctx,d*this._canvasScale,10*this._canvasScale,2*this._canvasScale,Ao);for(let u=1;u<r;u++){let g=d+u*(s/r);g>=0&&g<=this.clientWidth*this._canvasScale&&Eo(this._ctx,g*this._canvasScale,5*this._canvasScale,1*this._canvasScale,Ao)}gh(this._ctx,fh(new Date(h),l,o),d*this._canvasScale,26*this._canvasScale,"24px monospace","#bfbfbf","center")}this._drawCurrent()}var t}}function Lo(a,e){const t=new Date(a);return t.setHours(t.getHours()+e),t}class ui{constructor(){this.resolve=()=>{},this.reject=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t}),Object.freeze(this)}}const bh=["startcollecting","profilecollected","clear"];class wh{constructor(e={}){this.events=he(bh),this.planet=e.planet||null,this._warningHeightLevel=5,this._pointsReady=!1,this._isWarning=!1,this._minX=0,this._planeDistance=this._maxX=1e3,this._minY=0,this._maxY=200,this._drawData=[[],[]],this._promiseArr=[],this._promiseCounter=0,this._pMaxY=0,this._pMinY=0,this._pDist=0,this._pTrackCoords=[],this._pGroundCoords=[],this._pIndex=0}bindPlanet(e){this.planet=e}setWarningHeightLevel(e=0){this._warningHeightLevel=e}setRange(e,t,i,s){this._minX=e,this._maxX=t,i&&(this._minY=i),s&&(this._maxY=s)}_getHeightAsync(e,t,i){let s=new ui;if(this.planet){let r=this.planet.terrain.geoid.getHeightLonLat(e);this.planet.terrain.getHeightAsync(e,n=>{this.planet&&i===this._promiseCounter?(n+=r,this._pGroundCoords[t][1]=n,this._pGroundCoords[t][2]=0,this._pGroundCoords[t][3]=e.height,n>this._pMaxY&&(this._pMaxY=n),n<this._pMinY&&(this._pMinY=n),this._updatePointType(t),s.resolve(n)):s.reject()})}else s.reject();return s.promise}_collectCoordsBetweenTwoTrackPoints(e,t,i,s,r,n){if(this.planet)for(let o=1;o<=t;o++){this._pDist+=1,this._pIndex++;let l=o*i,h=s.add(r.scaleTo(l)),c=this.planet.ellipsoid.cartesianToLonLat(h);this._pGroundCoords[this._pIndex]=[this._pDist,0,0,0,e],((d,u)=>{this._promiseArr.push(this._getHeightAsync(d,u,n))})(c,this._pIndex)}}_collectAllPoints(e,t){if(!this.planet||t!==this._promiseCounter)return;let i=new v,s=new v;for(let r=1,n=e.length;r<n;r++){let o=e[r-1],l=e[r];this.planet.ellipsoid.lonLatToCartesianRes(o,i),this.planet.ellipsoid.lonLatToCartesianRes(l,s);let h=s.sub(i),c=h.length(),d=this.planet.ellipsoid.getSurfaceNormal3v(i),u=v.proj_b_to_plane(h,d),g=u.length(),f=Math.floor(g/1),p=1*c/g;this._getGroundElevation(o,r-1,t),u.normalize(),h.normalize(),this._collectCoordsBetweenTwoTrackPoints(r-1,f,p,i,h,t),this._pDist+=g-1*f,this._pIndex++;let _=l.height;_>this._pMaxY&&(this._pMaxY=_),_<this._pMinY&&(this._pMinY=_),this._pTrackCoords[r]=[this._pDist,_,this._pIndex]}}_getGroundElevation(e,t,i){this._pGroundCoords[this._pIndex]=[this._pDist,0,0,0,t],this._promiseArr.push(this._getHeightAsync(e,this._pIndex,i))}_calcPointsAsync(e,t){return new Promise((i,s)=>{this._pTrackCoords=[[0,e[0].height,0]],this._pMaxY=e[0].height,this._pMinY=this._pMaxY,this._pDist=0,this._pGroundCoords=[],this._pIndex=0,this._promiseArr=[],this._collectAllPoints(e,t),this._getGroundElevation(e[e.length-1],e.length-1,t),Promise.all(this._promiseArr).then(()=>{i({dist:this._pDist,minY:this._pMinY,maxY:this._pMaxY,trackCoords:this._pTrackCoords,groundCoords:this._pGroundCoords})})})}get minX(){return this._minX}get planeDistance(){return this._planeDistance}get maxX(){return this._maxX}get minY(){return this._minY}get maxY(){return this._maxY}get pointsReady(){return this._pointsReady}get isWarningOrCollision(){return this._isWarning}get drawData(){return this._drawData}collectProfile(e){let t=new ui;return this.planet||t.reject(),this._pointsReady=!1,this._isWarning=!1,e&&e.length?(this.events.dispatch(this.events.startcollecting,this),this._promiseCounter++,(i=>{this._calcPointsAsync(e,i).then(s=>{i===this._promiseCounter&&(this._planeDistance=s.dist,this.setRange(0,s.dist,s.minY-.1*Math.abs(s.minY),s.maxY+.2*Math.abs(s.maxY)),this._pointsReady=!0,this._drawData=[s.trackCoords,s.groundCoords],this.events.dispatch(this.events.profilecollected,this._drawData,this),t.resolve(this._drawData))})})(this._promiseCounter),t.promise):(t.reject(),t.promise)}_updatePointType(e){this._pGroundCoords[e][3]>=this._pGroundCoords[e][1]&&this._pGroundCoords[e][3]<this._pGroundCoords[e][1]+this._warningHeightLevel-.1&&(this._pGroundCoords[e][2]=1),this._pGroundCoords[e][3]<=this._pGroundCoords[e][1]+1&&(this._pGroundCoords[e][2]=2),this._pGroundCoords[e][2]!==1&&this._pGroundCoords[e][2]!==2||(this._isWarning=!0)}_setPointsType(){this._isWarning=!1,this._pTrackCoords=this._drawData[0],this._pGroundCoords=this._drawData[1];for(let e=0;e<this._pGroundCoords.length;e++)this._updatePointType(e);this._drawData[1]=this._pGroundCoords,this.events.dispatch(this.events.profilecollected,this._drawData,this)}clear(){this._promiseCounter=0,this._pointsReady=!1,this._isWarning=!1,this._drawData=[[],[]],this._pMaxY=0,this._pMinY=0,this._pDist=0,this._pTrackCoords=[],this._pGroundCoords=[],this._pIndex=0,this.events.dispatch(this.events.clear,this._drawData,this)}}const Po="rgb(198, 198, 198)",So=[Po,"rgb(255, 255, 0)","rgb(255, 0, 0)"],Ch=["startdrag","stopdrag","pointer","mouseenter","mouseleave","dblclick","tracklength","groundlength","warninglength","collisionlength"];class Th extends be{constructor(e={}){super({template:`<div class="og-elevationprofile">
290
+ </div>`,model:new vh({rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,current:e.currentDate,minDate:e.minDate,maxDate:e.maxDate})}),this._onMouseWheel=t=>{if(this._isMouseOver){let i=this._canvasEl.getBoundingClientRect(),r=t.clientX-i.left,s=-(r-.5*this.clientWidth),n=this.model.rangeStartTime+this._millisecondsInPixel*r;this._zoom(n,s,Math.sign(t.wheelDelta))}else if(this._isCurrentMouseOver){let i=-((this.model.currentTime-this.model.rangeStartTime)/this._millisecondsInPixel-.5*this.clientWidth);this._zoom(this.model.currentTime,i,Math.sign(t.wheelDelta))}},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onMouseDown=t=>{this._isMouseOver?(this._isDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._clickTime=Date.now(),this._clickRangeStart=this.model.rangeStart,this._clickRangeEnd=this.model.rangeEnd,this.events.dispatch(this.events.startdrag,t)):this._isCurrentMouseOver&&(this._isCurrentDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._clickCurrentDate=this.model.current,this.events.dispatch(this.events.startdragcurrent,t))},this._onMouseUp=t=>{if(this._isDragging)if(this._isDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this._clickPosX===t.clientX&&Date.now()-this._clickTime<this._clickDelay){let i=this._canvasEl.getBoundingClientRect(),r=new Date(this.model.rangeStartTime+(t.clientX-i.left)*this._millisecondsInPixel);this.model.current=r,this.events.dispatch(this.events.stopdrag,r),this.events.dispatch(this.events.setcurrent,r)}else this.events.dispatch(this.events.stopdrag,this.model.current);else this._isCurrentDragging&&(this._isCurrentDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this.events.dispatch(this.events.stopdragcurrent,this.model.current))},this._onMouseEnter=()=>{this._isMouseOver=!0},this._onMouseOut=()=>{this._isMouseOver=!1},this._onCurrentMouseEnter=()=>{this._isCurrentMouseOver=!0},this._onCurrentMouseOut=()=>{this._isCurrentMouseOver=!1},this._onMouseMove=t=>{if(this._isDragging){let i=(this._clickPosX-t.clientX)*this._millisecondsInPixel*Ot;this.model.set(Je(this._clickRangeStart,i),Je(this._clickRangeEnd,i))}else if(this._isCurrentDragging){let i=(this._clickPosX-t.clientX)*this._millisecondsInPixel*Ot,r=Je(this._clickCurrentDate,-i);r>=this.model.rangeStart&&r<=this.model.rangeEnd&&(this.model.current=Je(this._clickCurrentDate,-i))}},this.events=this.events.registerNames(yh),this.fillStyle=e.fillStyle||"rgba(64, 59, 59, 1.0)",this.$controls=null,this._frameEl=null,this._currentEl=null,this._canvasEl=document.createElement("canvas"),this._ctx=this._canvasEl.getContext("2d"),this._isMouseOver=!1,this._isDragging=!1,this._isCurrentDragging=!1,this._isCurrentMouseOver=!1,this._minWidth=330,this._canvasScale=2,this._millisecondsInPixel=0,this._clickPosX=0,this._clickRangeStart=new Date,this._clickRangeEnd=new Date,this._clickCurrentDate=new Date,this._clickTime=0,this._clickDelay=450,this._onResizeObserver_=this._onResizeObserver.bind(this),this._resizeObserver=new ResizeObserver(this._onResizeObserver_),this._pauseBtn=new _e({classList:["og-timeline-control_button"],icon:`<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 512 512" height="512px" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="Layer_6"><rect fill="#252525" height="320" width="60" x="153" y="96"/><rect fill="#252525" height="320" width="60" x="299" y="96"/></g></svg>`,name:"pause"}),this._playBtn=new _e({classList:["og-timeline-control_button"],icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M8 5v14l11-7z" style="fill: black;"/></svg>',name:"play"}),this._buttons=new nn({buttons:[this._pauseBtn,this._playBtn]}),this._visibility=!1}_onResizeObserver(){this.resize()}get canvasScale(){return this._canvasScale}set canvasScale(e){e!==this._canvasScale&&(this._canvasScale=e,this.resize())}resize(){this._resize(),this.draw()}afterRender(e){this.resize()}render(){return super.render(),this.$controls=this.select(".og-timeline-controls"),this._frameEl=this.select(".og-timeline-frame"),this._currentEl=this.select(".og-timeline-current"),this.select(".og-timeline-frame .og-timeline-scale").appendChild(this._canvasEl),this._resizeObserver.observe(this.el),this.model.events.on("change",()=>{this.draw()}),this.model.events.on("current",e=>{this._drawCurrent(),this.events.dispatch(this.events.setcurrent,e)}),this._canvasEl.addEventListener("mouseenter",this._onMouseEnter),this._canvasEl.addEventListener("mouseout",this._onMouseOut),this._currentEl.addEventListener("mouseenter",this._onCurrentMouseEnter),this._currentEl.addEventListener("mouseout",this._onCurrentMouseOut),document.body.addEventListener("mousemove",this._onMouseMove),document.body.addEventListener("mousedown",this._onMouseDown),document.body.addEventListener("mouseup",this._onMouseUp),document.body.addEventListener("wheel",this._onMouseWheelFF),this._playBtn.appendTo(this.$controls),this._pauseBtn.appendTo(this.$controls),this.model.stopped()?(this._pauseBtn.setActive(!0,!0),this._pauseBtn.preventClick=!0):(this._playBtn.setActive(!0,!0),this._playBtn.preventClick=!0),this._buttons.events.on("change",e=>{switch(e.name){case"play":this.play();break;case"pause":this.pause()}}),this.setVisibility(!0),this}setVisibility(e){e!==this._visibility&&(this._visibility=e,this.el&&(this.el.style.display=e?"block":"none"),this.events.dispatch(this.events.visibility,e))}reset(){this.model.stop(),this.events.dispatch(this.events.reset,this.model)}play(){this.model.multiplier=Math.abs(this.model.multiplier),this.model.play(),this.events.dispatch(this.events.play,this.model)}pause(){this.model.stop(),this.events.dispatch(this.events.pause,this.model)}playBack(){this.model.multiplier=-1*Math.abs(this.model.multiplier),this.model.play(),this.events.dispatch(this.events.playback,this.model)}_zoom(e,t,i){let r=(e-(this.model.rangeStartTime+.5*this.model.range))*Ot,s=Je(this.model.rangeStart,r),n=Je(this.model.rangeEnd,r),o=(n.getTime()-s.getTime())/20*Ot,l=Je(s,o*i),h=Je(n,-o*i),c=(h.getTime()-l.getTime())/this.clientWidth;if(c<31536e6&&c>.1){let d=c*t*Ot;this.model.set(Je(l,d),Je(h,d))}}get clientWidth(){return this._canvasEl?this._canvasEl.width/this._canvasScale:0}get clientHeight(){return this._canvasEl?this._canvasEl.height/this._canvasScale:0}_resize(){this._frameEl&&(this._canvasEl.width=this._frameEl.clientWidth*this._canvasScale,this._canvasEl.height=this._frameEl.clientHeight*this._canvasScale,this._canvasEl.style.width=`${this._frameEl.clientWidth}px`,this._canvasEl.style.height=`${this._frameEl.clientHeight}px`)}getOffsetByTime(e){return(e-this.model.rangeStartTime)/this._millisecondsInPixel}remove(){super.remove(),this.model.stop()}_clearCanvas(){this._ctx.fillStyle=this.fillStyle,this._ctx.fillRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}_drawCurrent(){let e=(this.model.currentTime-this.model.rangeStartTime)/this._millisecondsInPixel;this.model.current<this.model.rangeStart||this.model.current>this.model.rangeEnd?this._currentEl.style.display="none":(this._currentEl.style.display="block",this._currentEl.style.transform=`translateX(${e}px)`)}draw(){this._millisecondsInPixel=this.model.range/this.clientWidth;let e=function(i){for(let r=0,s=Yr.length;r<s;r++)if(Yr[r][0]>i)return Yr[r-1]}(this._minWidth*this._millisecondsInPixel*Ot);if(e){this._clearCanvas();let i=1e3*e[0],r=i/this._millisecondsInPixel,s=e[1],n=(t=this.model.rangeStartTime)-t%i,o=e[0]<1,l=e[0]<86400;for(let h=n,c=this.model.rangeEndTime+i;h<c;h+=i){let d=this.getOffsetByTime(h);d>=0&&d<=this.clientWidth*this._canvasScale&&Ea(this._ctx,d*this._canvasScale,10*this._canvasScale,2*this._canvasScale,Aa);for(let u=1;u<s;u++){let g=d+u*(r/s);g>=0&&g<=this.clientWidth*this._canvasScale&&Ea(this._ctx,g*this._canvasScale,5*this._canvasScale,1*this._canvasScale,Aa)}gh(this._ctx,fh(new Date(h),l,o),d*this._canvasScale,26*this._canvasScale,"24px monospace","#bfbfbf","center")}this._drawCurrent()}var t}}function La(a,e){const t=new Date(a);return t.setHours(t.getHours()+e),t}class di{constructor(){this.resolve=()=>{},this.reject=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t}),Object.freeze(this)}}const bh=["startcollecting","profilecollected","clear"];class wh{constructor(e={}){this.events=le(bh),this.planet=e.planet||null,this._warningHeightLevel=5,this._pointsReady=!1,this._isWarning=!1,this._minX=0,this._planeDistance=this._maxX=1e3,this._minY=0,this._maxY=200,this._drawData=[[],[]],this._promiseArr=[],this._promiseCounter=0,this._pMaxY=0,this._pMinY=0,this._pDist=0,this._pTrackCoords=[],this._pGroundCoords=[],this._pIndex=0}bindPlanet(e){this.planet=e}setWarningHeightLevel(e=0){this._warningHeightLevel=e}setRange(e,t,i,r){this._minX=e,this._maxX=t,i&&(this._minY=i),r&&(this._maxY=r)}_getHeightAsync(e,t,i){let r=new di;if(this.planet){let s=this.planet.terrain.geoid.getHeightLonLat(e);this.planet.terrain.getHeightAsync(e,n=>{this.planet&&i===this._promiseCounter?(n+=s,this._pGroundCoords[t][1]=n,this._pGroundCoords[t][2]=0,this._pGroundCoords[t][3]=e.height,n>this._pMaxY&&(this._pMaxY=n),n<this._pMinY&&(this._pMinY=n),this._updatePointType(t),r.resolve(n)):r.reject()})}else r.reject();return r.promise}_collectCoordsBetweenTwoTrackPoints(e,t,i,r,s,n){if(this.planet)for(let o=1;o<=t;o++){this._pDist+=1,this._pIndex++;let l=o*i,h=r.add(s.scaleTo(l)),c=this.planet.ellipsoid.cartesianToLonLat(h);this._pGroundCoords[this._pIndex]=[this._pDist,0,0,0,e],((d,u)=>{this._promiseArr.push(this._getHeightAsync(d,u,n))})(c,this._pIndex)}}_collectAllPoints(e,t){if(!this.planet||t!==this._promiseCounter)return;let i=new m,r=new m;for(let s=1,n=e.length;s<n;s++){let o=e[s-1],l=e[s];this.planet.ellipsoid.lonLatToCartesianRes(o,i),this.planet.ellipsoid.lonLatToCartesianRes(l,r);let h=r.sub(i),c=h.length(),d=this.planet.ellipsoid.getSurfaceNormal3v(i),u=m.proj_b_to_plane(h,d),g=u.length(),f=Math.floor(g/1),p=1*c/g;this._getGroundElevation(o,s-1,t),u.normalize(),h.normalize(),this._collectCoordsBetweenTwoTrackPoints(s-1,f,p,i,h,t),this._pDist+=g-1*f,this._pIndex++;let _=l.height;_>this._pMaxY&&(this._pMaxY=_),_<this._pMinY&&(this._pMinY=_),this._pTrackCoords[s]=[this._pDist,_,this._pIndex]}}_getGroundElevation(e,t,i){this._pGroundCoords[this._pIndex]=[this._pDist,0,0,0,t],this._promiseArr.push(this._getHeightAsync(e,this._pIndex,i))}_calcPointsAsync(e,t){return new Promise((i,r)=>{this._pTrackCoords=[[0,e[0].height,0]],this._pMaxY=e[0].height,this._pMinY=this._pMaxY,this._pDist=0,this._pGroundCoords=[],this._pIndex=0,this._promiseArr=[],this._collectAllPoints(e,t),this._getGroundElevation(e[e.length-1],e.length-1,t),Promise.all(this._promiseArr).then(()=>{i({dist:this._pDist,minY:this._pMinY,maxY:this._pMaxY,trackCoords:this._pTrackCoords,groundCoords:this._pGroundCoords})})})}get minX(){return this._minX}get planeDistance(){return this._planeDistance}get maxX(){return this._maxX}get minY(){return this._minY}get maxY(){return this._maxY}get pointsReady(){return this._pointsReady}get isWarningOrCollision(){return this._isWarning}get drawData(){return this._drawData}collectProfile(e){let t=new di;return this.planet||t.reject(),this._pointsReady=!1,this._isWarning=!1,e&&e.length?(this.events.dispatch(this.events.startcollecting,this),this._promiseCounter++,(i=>{this._calcPointsAsync(e,i).then(r=>{i===this._promiseCounter&&(this._planeDistance=r.dist,this.setRange(0,r.dist,r.minY-.1*Math.abs(r.minY),r.maxY+.2*Math.abs(r.maxY)),this._pointsReady=!0,this._drawData=[r.trackCoords,r.groundCoords],this.events.dispatch(this.events.profilecollected,this._drawData,this),t.resolve(this._drawData))})})(this._promiseCounter),t.promise):(t.reject(),t.promise)}_updatePointType(e){this._pGroundCoords[e][3]>=this._pGroundCoords[e][1]&&this._pGroundCoords[e][3]<this._pGroundCoords[e][1]+this._warningHeightLevel-.1&&(this._pGroundCoords[e][2]=1),this._pGroundCoords[e][3]<=this._pGroundCoords[e][1]+1&&(this._pGroundCoords[e][2]=2),this._pGroundCoords[e][2]!==1&&this._pGroundCoords[e][2]!==2||(this._isWarning=!0)}_setPointsType(){this._isWarning=!1,this._pTrackCoords=this._drawData[0],this._pGroundCoords=this._drawData[1];for(let e=0;e<this._pGroundCoords.length;e++)this._updatePointType(e);this._drawData[1]=this._pGroundCoords,this.events.dispatch(this.events.profilecollected,this._drawData,this)}clear(){this._promiseCounter=0,this._pointsReady=!1,this._isWarning=!1,this._drawData=[[],[]],this._pMaxY=0,this._pMinY=0,this._pDist=0,this._pTrackCoords=[],this._pGroundCoords=[],this._pIndex=0,this.events.dispatch(this.events.clear,this._drawData,this)}}const Pa="rgb(198, 198, 198)",Sa=[Pa,"rgb(255, 255, 0)","rgb(255, 0, 0)"],Ch=["startdrag","stopdrag","pointer","mouseenter","mouseleave","dblclick","tracklength","groundlength","warninglength","collisionlength"];class Th extends be{constructor(e={}){super({template:`<div class="og-elevationprofile">
291
291
  <div class="og-elevationprofile-loading" style="display: none;">
292
292
  <div class="loadingio-spinner-bars-r354qqyl5v">
293
293
  <div class="ldio-p0v5a1f6oz">
@@ -298,7 +298,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
298
298
  </div>
299
299
  </div>
300
300
  </div>
301
- </div>`,model:new wh}),this._onMouseDblClick=t=>{let i,s=this.$canvas.getBoundingClientRect(),r=t.clientX-s.left,n=this._leftDistance+(this._rightDistance-this._leftDistance)*r/this.clientWidth,o=this.model.drawData[1],l=this.model.drawData[0];n<0?(i=1,n=0,r=(0-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):n>this.model.planeDistance?(i=o.length-1,n=this.model.planeDistance,r=(n-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):i=-1-yt(o,n,(m,y)=>m-y[0]);let h=o[i-1],c=o[i],d=(n-h[0])/(c[0]-h[0]),u=h[1]+d*(c[1]-h[1]),g=h[4],f=l[g],p=l[g+1];d=(n-f[0])/(p[0]-f[0]);let _=f[1]+d*(p[1]-f[1]);this.events.dispatch(this.events.dblclick,n,f,p,h,c,g,i-1,_-u)},this._onMouseEnter=t=>{this._isMouseOver=!0,this.events.dispatch(this.events.mouseenter,t)},this._onMouseOut=t=>{this._isMouseOver=!1,this.events.dispatch(this.events.mouseleave,t)},this._onMouseDown=t=>{this._isMouseOver&&(this._isDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX),this._clickLeftDistance=this._leftDistance,this._clickRightDistance=this._rightDistance,this.events.dispatch(this.events.startdrag,t))},this._onMouseUp=t=>{this._isDragging&&(this._isDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this.events.dispatch(this.events.stopdrag,t))},this._onCanvasMouseMove=t=>{if(this.model.pointsReady)if(this._isDragging)this.clearPointerCanvas();else{this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX);let i=this.$pointerCanvas.getBoundingClientRect(),s=t.clientX-i.left;this.redrawPointerCanvas(s)}},this._onMouseMove=t=>{if(this._isDragging&&this.model.pointsReady){let i=(this._clickPosX-t.clientX)*this._canvasScale/this._pixelsInMeter_x;this.setFrame(this._clickLeftDistance+i,this._clickRightDistance+i)}},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onMouseWheel=t=>{if(this._isMouseOver&&this.model.pointsReady){this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX),this._customFrame=!0;let i=Math.sign(t.wheelDelta)*(this._rightDistance-this._leftDistance)/20,s=this.$canvas.getBoundingClientRect(),r=t.clientX-s.left,n=r-.5*this.$canvas.clientWidth,o=n*this._canvasScale/this._pixelsInMeter_x,l=o+this._leftDistance+i,h=o+this._rightDistance-i;o=-n*(h-l)/this.clientWidth,this.setFrame(l+o,h+o),this.redrawPointerCanvas(r)}},this.events=this.events.registerNames(Ch),this.fillStyle=e.fillStyle||"rgb(63, 63, 63)",this._customFrame=!1,this._leftDistance=0,this._rightDistance=0,this._pixelsInMeter_x=0,this._pixelsInMeter_y=0,this._canvasScale=2,this.$canvas=document.createElement("canvas"),this.$canvas.style.position="absolute",this._ctx=this.$canvas.getContext("2d"),this.$pointerCanvas=document.createElement("canvas"),this.$pointerCanvas.style.pointerEvents="none",this.$pointerCanvas.style.position="absolute",this._pointerCtx=this.$pointerCanvas.getContext("2d"),this.$loading=null,this._isMouseOver=!1,this._isDragging=!1,this._clickPosX=0,this._clickLeftDistance=0,this._clickRightDistance=0,this._timeStartHandler=0,this._onResizeObserver_=this._onResizeObserver.bind(this),this._resizeObserver=new ResizeObserver(this._onResizeObserver_)}_onResizeObserver(){this.resize()}get canvasScale(){return this._canvasScale}set canvasScale(e){e!==this._canvasScale&&(this._canvasScale=e,this.resize())}resize(){this._resize(),this.draw()}render(){return super.render(),this._resizeObserver.observe(this.el),this.el.appendChild(this.$canvas),this.el.appendChild(this.$pointerCanvas),this.model.events.on("profilecollected",e=>{this._hideLoading(),this.clearPointerCanvas(),this.draw()}),this.model.events.on("startcollecting",()=>{clearTimeout(this._timeStartHandler),this._timeStartHandler=setTimeout(()=>{this._showLoading()},450)}),this.model.events.on("clear",()=>{this._customFrame=!1,this._leftDistance=0,this.clearCanvas(),this.clearPointerCanvas()}),this.$loading=this.select(".og-elevationprofile-loading"),this.$canvas.addEventListener("mouseenter",this._onMouseEnter),this.$canvas.addEventListener("mouseout",this._onMouseOut),this.$canvas.addEventListener("dblclick",this._onMouseDblClick),this.$canvas.addEventListener("mousemove",this._onCanvasMouseMove),document.body.addEventListener("mousemove",this._onMouseMove),document.body.addEventListener("mousedown",this._onMouseDown),document.body.addEventListener("mouseup",this._onMouseUp),document.body.addEventListener("wheel",this._onMouseWheelFF),this}_hideLoading(){clearTimeout(this._timeStartHandler),this.$loading.style.display="none"}_showLoading(){this.$loading.style.display="flex"}redrawPointerCanvas(e){this.clearPointerCanvas();let t,i=this._leftDistance+(this._rightDistance-this._leftDistance)*e/this.clientWidth,s=this.model.drawData[1],r=this.model.drawData[0];i<0?(t=1,i=0,e=(0-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):i>this.model.planeDistance?(t=s.length-1,i=this.model.planeDistance,e=(i-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):t=-1-yt(s,i,(y,x)=>y-x[0]);let n=s[t-1],o=s[t],l=(i-n[0])/(o[0]-n[0]),h=n[1]+l*(o[1]-n[1]),c=n[4],d=r[c],u=r[c+1];l=(i-d[0])/(u[0]-d[0]);let g=d[1]+l*(u[1]-d[1]),f=(this.model.maxY-g)*this._pixelsInMeter_y,p=(this.model.maxY-h)*this._pixelsInMeter_y;this.events.dispatch(this.events.pointer,i,d,u,n,o,c,t-1,g-h);let _=this._pointerCtx;_.lineWidth=3,_.strokeStyle="rgba(64,64,64,0.6)",_.beginPath(),_.moveTo(e*this._canvasScale,0),_.lineTo(e*this._canvasScale,this.clientHeight*this._canvasScale),_.stroke(),_.beginPath(),_.arc(e*this._canvasScale,p,4,0,2*Math.PI,!1),_.fillStyle="#FFB277",_.fill(),_.lineWidth=4,_.strokeStyle="#FFB277",_.stroke(),_.beginPath(),_.arc(e*this._canvasScale,f,4,0,2*Math.PI,!1),_.fillStyle="#FFB277",_.fill(),_.lineWidth=4,_.strokeStyle="#FFB277",_.stroke(),_.lineWidth=3,_.strokeStyle="#FFB277",_.beginPath(),_.moveTo(e*this._canvasScale,p),_.lineTo(e*this._canvasScale,f),_.stroke(),_.fillStyle="white",_.font=28/devicePixelRatio+"px Arial",_.textBaseline="middle",_.textAlign="left",_.fillText(`${Math.round(g-h).toString()} m`,(e+5)*this._canvasScale,p+.5*(f-p)),_.fillStyle="white",_.font=28/devicePixelRatio+"px Arial",_.textAlign="right";let m=Dt(i);_.fillText(`${m[0]} ${m[1]}`,(e-5)*this._canvasScale,(this.clientHeight-7)*this._canvasScale)}get clientWidth(){return this.$canvas?this.$canvas.width/this._canvasScale:0}get clientHeight(){return this.$canvas?this.$canvas.height/this._canvasScale:0}_resize(){this.el&&(this.$canvas.width=this.el.clientWidth*this._canvasScale,this.$canvas.height=this.el.clientHeight*this._canvasScale,this.$canvas.style.width=`${this.el.clientWidth}px`,this.$canvas.style.height=`${this.el.clientHeight}px`,this.$pointerCanvas.width=this.el.clientWidth*this._canvasScale,this.$pointerCanvas.height=this.el.clientHeight*this._canvasScale,this.$pointerCanvas.style.width=`${this.el.clientWidth}px`,this.$pointerCanvas.style.height=`${this.el.clientHeight}px`,this._customFrame&&(this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this._rightDistance-this._leftDistance)))}clearPointerCanvas(){this._pointerCtx.fillStyle="rgba(0,0,0,0)",this._pointerCtx.clearRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}clearCanvas(){const e=this._ctx.createLinearGradient(0,0,0,this.clientHeight*this._canvasScale);e.addColorStop(0,"black"),e.addColorStop(1,this.fillStyle),this._ctx.fillStyle=e,this._ctx.fillRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}setFrame(e,t){this._leftDistance=e,this._rightDistance=t,this._customFrame=!0,this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this._rightDistance-this._leftDistance),this.model.setRange(e,t),this.draw()}_updateUnits(){this._customFrame||(this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this.model.maxX-this.model.minX)),this._pixelsInMeter_y=this._canvasScale*this.clientHeight/(this.model.maxY-this.model.minY)}clear(){this.model.clear(),this.clearCanvas()}draw(){let e=this.model.drawData[0];if(e.length>1){this._updateUnits(),this.clearCanvas();let t=this.model.drawData[1];this._drawTrack(e,t),this._drawTerrain(t),this._drawWarningAndCollision(t),this._drawLabels(e,t)}else this.clearCanvas()}_drawLabels(e,t){let i=this._ctx;if(i){let s=e[0];const r=this.model.maxY;let n=(-this._leftDistance+s[0])*this._pixelsInMeter_x,o=(r-s[1])*this._pixelsInMeter_y;t[s[2]][1],this._pixelsInMeter_y,i.beginPath(),i.fillStyle="#F7F718",i.fillRect(n-4,o-4,8,8),i.stroke(),i.fillStyle="white",i.font=26/devicePixelRatio+"px Arial",i.textBaseline="bottom",i.textAlign="left",i.fillText(`${Math.round(s[1]-t[s[2]][1]).toString()} m`,n+1,o-10),i.stroke();for(let l=1,h=e.length;l<h;l++){let c=e[l];n=(-this._leftDistance+c[0])*this._pixelsInMeter_x,o=(r-c[1])*this._pixelsInMeter_y,t[c[2]][1],this._pixelsInMeter_y,i.beginPath(),i.fillStyle="#F7F718",i.fillRect(n-4,o-4,8,8),i.stroke(),i.fillStyle="white",i.fillText(`${Math.round(c[1]-t[c[2]][1]).toString()} m`,n+1,o-10),i.stroke()}}}_drawTrack(e,t){let i=e[0],s=this._ctx;if(s){const r=this.model.maxY;s.lineWidth=5,s.strokeStyle="rgb(0, 255, 50)",s.beginPath(),s.moveTo((-this._leftDistance+i[0])*this._pixelsInMeter_x,(r-i[1])*this._pixelsInMeter_y);let n=0;for(let c=1,d=e.length;c<d;c++){let u=e[c];s.lineTo((-this._leftDistance+u[0])*this._pixelsInMeter_x,(r-u[1])*this._pixelsInMeter_y);let g=e[c-1],f=u[0]-g[0],p=u[1]-g[1],_=f*f,m=p*p;n+=Math.sqrt(_+m)}s.stroke(),s.lineWidth=2,s.strokeStyle="rgba(255,255,255,0.7)",s.beginPath();let o=(-this._leftDistance+i[0])*this._pixelsInMeter_x,l=(r-i[1])*this._pixelsInMeter_y,h=(r-t[i[2]][1])*this._pixelsInMeter_y;s.moveTo(o,l),s.lineTo(o,h);for(let c=1,d=e.length;c<d;c++){let u=e[c];o=(-this._leftDistance+u[0])*this._pixelsInMeter_x,l=(r-u[1])*this._pixelsInMeter_y,h=(r-t[u[2]][1])*this._pixelsInMeter_y,s.strokeStyle="rgba(255,255,255,0.7)",s.moveTo(o,l),s.lineTo(o,h)}s.stroke(),this.events.dispatch(this.events.tracklength,n)}}_drawTerrain(e){let t=e[0],i=this._ctx;if(i){const s=this.model.maxY;i.lineWidth=5,i.strokeStyle=Po,i.beginPath(),i.moveTo((-this._leftDistance+t[0])*this._pixelsInMeter_x,this.$canvas.height),i.lineTo((-this._leftDistance+t[0])*this._pixelsInMeter_x,(s-t[1])*this._pixelsInMeter_y);let r=0;for(let n=1,o=e.length;n<o;n++){let l=e[n];i.lineTo((-this._leftDistance+l[0])*this._pixelsInMeter_x,(s-l[1])*this._pixelsInMeter_y);let h=e[n-1],c=l[0]-h[0],d=l[1]-h[1],u=c*c,g=d*d;r+=Math.sqrt(u+g)}i.lineTo((-this._leftDistance+e[e.length-1][0])*this._pixelsInMeter_x,this.$canvas.height),i.closePath(),i.stroke(),i.save(),i.fillStyle="rgb(64, 68, 82)",i.globalAlpha=.5,i.fill(),i.restore(),i.globalAlpha=1,this.events.dispatch(this.events.groundlength,r)}}_drawWarningAndCollision(e){let t=this._ctx;if(t&&e.length>1){let i=this.model.maxY;t.lineWidth=5,t.beginPath();let s=0,r=0;for(let n=0,o=e.length-1;n<o;n++){let l=e[n],h=e[n+1];if(l[2]!==0&&h[2]!==0){let c=h[0]-l[0],d=h[1]-l[1],u=c*c,g=d*d;l[2]===2?(t.stroke(),t.beginPath(),t.strokeStyle=So[2],r+=Math.sqrt(u+g)):l[2]===1&&(t.stroke(),t.beginPath(),t.strokeStyle=So[1],s+=Math.sqrt(u+g)),t.moveTo((-this._leftDistance+l[0])*this._pixelsInMeter_x,(i-l[1])*this._pixelsInMeter_y),t.lineTo((-this._leftDistance+h[0])*this._pixelsInMeter_x,(i-h[1])*this._pixelsInMeter_y)}}t.stroke(),this.events.dispatch(this.events.warninglength,s),this.events.dispatch(this.events.collisionlength,r)}}}let Eh=Z.createCylinder(.33,0,1,20,1,!0,!1,0,0,0),Ah=Z.createCylinder(.33,.33,1.1,20,1,!0,!0,0,-.55,0);const Lh={startPosition:new v,endPosition:new v,startColor:"rgba(255,131,0,0.2)",endColor:"rgba(255,131,0,1.0)",thickness:2.7},Ph={src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjEuNBNAaMQAAAiLSURBVHhe7Z0r0BxFEMcjIhAIRERERAQCgUAgEBEIBAIRiUAgIiIQiAgEIlUREQgEIgIREYFAIBCIiAgEIiIiAoGIoHimqPAKz5CP/t23/8vcbe89d/dmZ/pf9avLdZK72e6+ee3M7Imjo6Opc8o4b7xn3DIeGEOJz+Y7+C6+k+/2yjQZXOMEOGdcNe4anv4wvjV+m73bT3wGn8VneqIMlIUyeWXNGteYKTj4feNrI9W/xi/HfxxVfCffnYqyUcbJJINrzIjTxjvGV0aqn43fj/+YhSgLZUpFmd81uAbv2rLANWbAC8ZHxp+GxC8ufZ+rKGNaI1FLcC1ck3etB8U1HhCqzk8N6T/jENV7X6LsXIN008iqeXCNB+B54zND+tt4ePzHIsS1cE0SicA1e74YFdc4IgyjrhvqTP3TvJas9Bq59oP2EVzjCJw03jI0TCMBcurUDS1qBCU9PnjbwCeerwbFNQ4MVd9tQ5pyG7+v0mvHJ6N3FF3jgFwy1JPvmlipUfIFvmHY6/luEFzjANDO0fGRfm1eQ0+UzlriqzOG58tecY0985LxnYH+al5D3ZKP8Bm+83zaG66xRy4a6uzU3NZvK/nqkUEH0fNtL7jGHqBH+4EhTWEGL2ddMwYZJbjGPaGgHxuIDA7tJ/mQGdLek8A17sHTxucGiva+P6kGxbf42PP9TrjGHUmDH1V+/xokCVzjDkTwx1HvSeAat4R2SWP8CP7wko9ZmrZ3n8A1bok6fBH88SRf4/u9ksA1bgFr4ZDG+qHxpLuKLFD1YrMRrnFDLhjocfMaGl8aIjLh5sVoLa5xA140+lhxG+pHNAk7TRu7xjXQ+9TK3Jru4ecqxYB7B88YXsw6cY1rUKcv7ujlI907YLbQi1knrnEFavej05ef1ClkpZUXOxfX2AH3p6Pdz1/E6FnDi2EL19iBVu3Gbd18pdgwU+jFsIVrdHjDQHGDJ39pkojm2ovlAq5xCXqWWtETmo7uG2t3L7vGJTTbF73+6UhNARtVvZjOcY0JZ42Y45+uGK2t7BC6xoQbBoqO3/SkGpt5Gy+2M1xjw3MGGZRubgxNS5qv6dxw4hob9OuPsf90pWnizlrANRpM+sSvvwypFqBGb8W6ZWjgHjOKtn/6Ug3OMv1WrFsG4ykjqv3yxGiudbdw4U2DbvjEuL8cqSZv7TJaeNOg1b2h8nTHWIj3whuDSQOUHmcSKkPagr5wNE0afLhioOj8lSc16QvTw2nwYfk8vlB5YjnfPOZp8FX9x8kd5Uqju3kzkCYAPUQU1X+5UjPACaatBEiPcAmVrfmKIQU/Jn/qEpNCs82lSgCOL0U/Na+hcvVD8/qKMU8AjiZDsdGjfCnGl415AnyCJVSVZptIlAD3sISqEgt9ZwnAHSIU07/1SMv7T5EA7CpFPzavofKljuA5EkCbPmICqB4p1m+SAPQGQ3XqMgnAQwtCdeo6CRBTwPXqJgnAKpFQnbpDAsQcQL26RwLEzt96dZ8ECFWsSIDKFQlQuSIBKlckQOUiAThLJlSnZqOAmAeoV7N5gJgJrFd3SQCePBGqU7dIgLgbWK9mdwO1ITRUn66QADoQIlYE1SPF+gIJEGsC69PCmkDOk0WxKrgeaQf4aRIA9AiYUD2a7wuA2BlUn1gKOE8A9ouj2BtYvh42r4z+5gnATlEUHcHy9X3z+poxT4A4H6Aecfxv63wAiOXh9ah1QgioHxAnhJYr1fKz9h/SBOA0aRSnhJUrJQCP/m0lAMQ5geWr85xA0I2haAbKk4b4K08KVTMQ08LlSU37vPqHNPgiVgiVK5r4hXgvvGm4aKC4PVyOFMuNnhfABEFMCpWnjZ8YAjxfBkUiTF/q/LH0rxXrlqFBJ4friVOh6Uod+oUHRYiWIYFnzaG4QzhdqefPo/+9GK9MAJ42SQ0QtcB0pV//wtAvxTUmqBaIiaHpSff9Z0fCduEaE+gLxBNEpyliRuzctl+4xiU0Ioh5gelIsfrQ8GI6xzUuwdjxgRGalojZacOL6RzX6KDNI0wmhPKWev6tWT8P19jBFwaKDmG+0pD9tnHS8OK4gGvsgDuFUQPkr7UdvxTXuAI9Wk7nzYfykX6clwwvdi6ucQ3MKqEYFeQjxYKFvRtV/cI1roG9hDpdNNYPHl6KAWc9re31L+MaN4DHzMUUcT4iFi8bXqxW4ho3RP2Bx81raHw9al557J8Xo7W4xi24ZqAYHYwv+XztbN8qXOMW0OFQpzBuG48n+XrrTt8yrnFLWELGViMUSTC85GN8Ptvftw+ucQcYGTD7hCIJhpN8y8rtrXv8Hq5xR7hpdNdAkQT9Sz7Fx70EH1zjHlAl6Z5BdAz7k3xJLdta2bsPrnFP0j5BzBXsL/mwlzZ/GdfYA/RMbxgo5gl2l3yHL/fq7XfhGnskfSpp3DvYXKmvZs/5HwrX2DOcP6QVRVqoGOqWfMSmnFcNz6e94RoH4IyhziGLFeMmUlv4RItv8RU+83zZK65xIGjDOH9AnZoYKj6RfIFvrhqDtPcernFg2KTwpSHVvMQsvXa2bnNus+ezwXCNI6DaQOPbGoeLumZ8gC9G+9WnuMYRYeOJdh+hGiaP0mvkiF584PlmFFzjAWAxgzqJqMRESK+Ja91pAUffuMYDwvGlaSJQTU65j0DZ0+aNaztveNd+EFxjBjB3QPWYOm9Kh1WkZeUa2KDJNXnXelBcY0bQPnKs2fIj7nOsFZbLRJkp+0Hb+HW4xgzhMGuqTubEl2sC9igcYpqZ71zeH0HZKCNlpczetWSFa8wcJQO7lrtONiUQ3xh9TDbxGXxWVxNEGSjLZIKe4honxlnjdYMFqnSyhhxB8Nl8B9/Fd/LdXpkmg2ssANpdfpEsXacdZq6BJ6Tya+VZyWnnUsLG3/Fv+Lf8H/4vn8FnZd2W78bRif8BxMOwtJg5Ph4AAAAASUVORK5CYII=",color:"rgb(255,131,0)",size:[8,8]},Sh={text:"",face:"arial",size:10.5,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"left",offset:[5,15,-5]},Mo={face:"arial",text:"",size:10.5,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"right",offset:[-47,25,0]},Mh={instanced:!0,tag:"ground-pointer",color:"rgb(0,305,0)",object3d:Eh},Rh={instanced:!0,tag:"head-pointer",color:"rgb(305,305,0)",object3d:Ah};class Bh extends at{constructor(e={}){super("ElevationProfileScene"),this._onLClick=t=>{let i=this._planet.getCartesianFromPixelTerrain(t.pos);i&&this.addGroundPoint3vAsync(i)},this._onMouseMove=t=>{if(this._planet.getCartesianFromMouseTerrain(),this._pickedGroundEntity){let i=new N(t.x,t.y).sub(this._startClickPos),s=this._startEntityPos.add(i),r=this._planet.getCartesianFromPixelTerrain(s);r&&this.setGroundPointCartesian3v(this._pickedGroundEntity.properties.index,r)}else if(this._pickedHeadEntity){let i=this._planet.camera,s=this._pickedHeadEntity.properties.groundEntity.getCartesian(),r=this._planet.ellipsoid.getSurfaceNormal3v(s),n=s.add(r),o=s.add(i.getRight()),l=new v;if(new U(i.eye,t.direction).hitPlaneRes(Pe.fromPoints(s,n,o),l)===U.INSIDE){let h=v.proj_b_to_a(l,s),c=h.sub(s).dot(s),d=s.add(r.scale(Math.sign(c)*h.distance(s)));this.setHeadPointCartesian3v(this._pickedHeadEntity.properties.index,d)}}},this._onLUp=t=>{},this._onGroundPointerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onGroundPointerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onGroundPointerLDown=t=>{this._clampToGround=!1,this.renderer.controls.mouseNavigation.deactivate(),this._pickedGroundEntity=t.pickingObject;const i=this._pickedGroundEntity.getCartesian();this._startClickPos.set(t.x,t.y),this._startEntityPos=this._planet.getPixelFromCartesian(i)},this._onGroundPointerLUp=t=>{this._clampToGround=!0,this.renderer.controls.mouseNavigation.activate(),this._pickedGroundEntity=null},this._onHeadPointerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onHeadPointerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onHeadPointerLDown=t=>{this.renderer.controls.mouseNavigation.deactivate(),this._pickedHeadEntity=t.pickingObject},this._onHeadPointerLUp=t=>{this.renderer.controls.mouseNavigation.activate(),this._pickedHeadEntity=null},this.events=he(kh),this._planet=e.planet||null,this._pickedGroundEntity=null,this._pickedHeadEntity=null,this._startClickPos=new N,this._startEntityPos=new N,this._clampToGround=!0,this._trackLayer=new ge("track",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!0}),this._groundPointersLayer=new ge("ground-pointers",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,5e3,.02],pickingScale:1.5}),this._headPointersLayer=new ge("head-pointers",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,1e4,.02],pickingScale:1}),this._columnPointersLayer=new ge("column-pointers",{entities:[],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._trackEntity=new V({polyline:{path3v:[],thickness:3.8,color:"rgba(0,305,0,0.8)",isClosed:!1}}),this._trackLayer=new ge("column-pointers",{entities:[this._trackEntity],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._heightsLayer=new ge("heights-labels",{entities:[],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._pointerHeadEntity=new V({cartesian:new v,billboard:Ph}),this._pointerLabelEntity=new V({cartesian:new v,label:Sh}),this._pointerRayEntity=new V({cartesian:new v,ray:Lh}),this._pointerLayer=new ge("pointer",{entities:[this._pointerHeadEntity,this._pointerLabelEntity,this._pointerRayEntity],pickingEnabled:!1,hideInLayerSwitcher:!0})}flyExtent(){let e=this._headPointersLayer.getEntities(),t=180,i=180,s=-180,r=-180,n=-1e6;if(e.length>1){for(let o=0;o<e.length;o++){let l=e[o].getLonLat();l.lon<t&&(t=l.lon),l.lat<i&&(i=l.lat),l.lon>s&&(s=l.lon),l.lat>r&&(r=l.lat),l.height>n&&(n=l.height)}this._planet.camera.flyExtent(new G(new A(t,i),new A(s,r)),n,null,0)}}get planet(){return this._planet}_createGroundPointer(e,t=10){let i=this.ellipsoid.getSurfaceNormal3v(e),s=e.add(i.scale(t)),r=new V({ray:{startPosition:e,endPosition:s,startColor:"rgba(255,255,255,0.2)",endColor:"rgba(355,355,355,1.0)",thickness:3.2}}),n=new V({cartesian:e,geoObject:Mh}),o=new V({cartesian:s,geoObject:Rh,properties:{}}),l=new V({cartesian:s,label:Mo});l.appendChild(new V({cartesian:s,label:{...Mo,offset:[-47,45,0]}}));const h=this._groundPointersLayer.getEntities().length;return r.properties=n.properties=o.properties={index:h,altitude:t,lonLatEll:new A,headEntity:o,groundEntity:n,columnEntity:r,heightLabelEntity:l},{headEntity:o,groundEntity:n,columnEntity:r,heightLabelEntity:l}}setPointerCartesian3v(e,t){this._pointerLabelEntity.setCartesian3v(e),this._pointerLabelEntity.label.setText(`${Math.round(t).toString()} m`),this._pointerRayEntity.ray.setEndPosition3v(e);let i=this._planet.ellipsoid.getSurfaceNormal3v(e);this._pointerRayEntity.ray.setStartPosition3v(e.add(i.scale(-t))),this._pointerHeadEntity.setCartesian3v(e)}bindPlanet(e){this._planet=e}init(){this._activate()}onremove(){this._deactivate()}_activate(){this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._groundPointersLayer),this._planet.addLayer(this._columnPointersLayer),this._planet.addLayer(this._headPointersLayer),this._planet.addLayer(this._heightsLayer),this._planet.addLayer(this._pointerLayer),this.renderer.events.on("ldblclick",this._onLClick),this.renderer.events.on("mousemove",this._onMouseMove),this.renderer.events.on("lup",this._onLUp),this._groundPointersLayer.events.on("mouseenter",this._onGroundPointerEnter),this._groundPointersLayer.events.on("mouseleave",this._onGroundPointerLeave),this._groundPointersLayer.events.on("ldown",this._onGroundPointerLDown),this._groundPointersLayer.events.on("lup",this._onGroundPointerLUp),this._headPointersLayer.events.on("mouseenter",this._onHeadPointerEnter),this._headPointersLayer.events.on("mouseleave",this._onHeadPointerLeave),this._headPointersLayer.events.on("ldown",this._onHeadPointerLDown),this._headPointersLayer.events.on("lup",this._onHeadPointerLUp),this.setPointerVisibility(!1)}getPointLonLat(e){let t=this._headPointersLayer.getEntities()[e];if(t)return t.getLonLat()}getPointsLonLat(){let e=this._headPointersLayer.getEntities(),t=new Array(e.length);for(let i=0,s=t.length;i<s;i++){let r=e[i];t[i]=r.getLonLat()}return t}getHeightMSL(e){return this._planet&&this._planet.terrain.geoid?this._planet.terrain.geoid.getHeightLonLat(e):0}getHeightELLAsync(e){return new Promise((t,i)=>{this._planet.terrain.getHeightAsync(e,s=>{if(this._planet){let r=this.getHeightMSL(e);t(s+r)}else i()})})}addPointLonLatArrayAsync(e,t=!1){if(!this._planet)throw new Error("Planet is not defined");let i=this._planet.ellipsoid;for(let r=0,n=e.length-1;r<n;r++){let o=i.lonLatToCartesian(e[r]),l=i.lonLatToCartesian(e[r+1]);if(o.distance(l)>1e5)throw new Error("Track is too long! 100 km is maximum.")}let s=new Array(e.length);for(let r=0,n=e.length;r<n;r++)s[r]=this.addPointLonLatAsync(e[r],!0);return Promise.all(s).then(()=>{t||this.events.dispatch(this.events.change,this)}),s}addPointLonLatAsync(e,t=!1){let i=this._planet.ellipsoid.lonLatToCartesian(e),s=this._planet.ellipsoid.getSurfaceNormal3v(i),r=new A(e.lon,e.lat),n=this._planet.ellipsoid.lonLatToCartesian(r),{headEntity:o,groundEntity:l,columnEntity:h,heightLabelEntity:c}=this._createGroundPointer(n);return this._groundPointersLayer.add(l),this._columnPointersLayer.add(h),this._headPointersLayer.add(o),this._heightsLayer.add(c),this._trackEntity.polyline.appendPoint3v(o.getCartesian()),l.properties.lonLatEll.lon=r.lon,l.properties.lonLatEll.lat=r.lat,l.properties.lonLatEll.height=r.height,new Promise(d=>{this.getHeightELLAsync(e).then(u=>{var g;l.properties.lonLatEll.height=u;let f,p=10;e.height===0?(f=i.add(s.scaleTo(u)),i=f.add(s.scaleTo(p))):(p=e.height-u,f=i.sub(s.scaleTo(p))),l.setCartesian3v(f),c.setCartesian3v(i),c.label.setText(`${u.toFixed(1)} m`),c.childEntities[0].label.setText(`${p.toFixed(1)} m`),o.properties.altitude=p,o.setCartesian3v(i),o.properties.columnEntity.ray.setStartPosition3v(f),o.properties.columnEntity.ray.setEndPosition3v(i),(g=this._trackEntity.polyline)==null||g.setPoint3v(i,o.properties.index),t||(this.events.dispatch(this.events.addpoint,o,this),this.events.dispatch(this.events.change,this)),d(o)})})}addGroundPointLonLatAsync(e,t=10,i=!1){let s=this._planet.ellipsoid.lonLatToCartesian(e);return this._addPoint(s,e,t,i)}addGroundPoint3vAsync(e,t=10,i=!1){let s=this._planet.ellipsoid.cartesianToLonLat(e);return this._addPoint(e,s,t,i)}_addPoint(e,t,i,s=!1){return new Promise((r,n)=>{let{headEntity:o,groundEntity:l,columnEntity:h,heightLabelEntity:c}=this._createGroundPointer(e,i);this._groundPointersLayer.add(l),this._columnPointersLayer.add(h),this._headPointersLayer.add(o),this._heightsLayer.add(c),this._trackEntity.polyline.appendPoint3v(o.getCartesian()),l.properties.lonLatEll.lon=t.lon,l.properties.lonLatEll.lat=t.lat,l.properties.lonLatEll.height=t.height,this.getHeightELLAsync(t).then(d=>{var u;l.properties.lonLatEll.height=t.height=d;let g=this._planet.ellipsoid.lonLatToCartesian(t),f=this._planet.ellipsoid.getSurfaceNormal3v(g),p=g.add(f.scale(i));c.setCartesian3v(p),c.label.setText(`${d.toFixed(1)} m`),c.childEntities[0].label.setText(`${i.toFixed(1)} m`),o.setCartesian3v(p),o.properties.columnEntity.ray.setEndPosition3v(p),(u=this._trackEntity.polyline)==null||u.setPoint3v(p,o.properties.index),s||(this.events.dispatch(this.events.addpoint,o,this),this.events.dispatch(this.events.change,this)),r(o)})})}setHeadPointCartesian3v(e,t){const i=this._headPointersLayer.getEntities()[e];if(i){let s=this._planet.ellipsoid.lonLatToCartesian(i.properties.lonLatEll),r=t.length()-s.length();r<=0&&(t=s,r=0),i.properties.altitude=r,i.setCartesian3v(t),i.properties.columnEntity.ray.setEndPosition3v(t),i.properties.heightLabelEntity.setCartesian3v(t),i.properties.heightLabelEntity.childEntities[0].label.setText(`${r.toFixed(1)} m`),this._trackEntity.polyline.setPoint3v(t,e),this.events.dispatch(this.events.change,this._pickedHeadEntity)}}setGroundPointCartesian3v(e,t){var i;let s=this._groundPointersLayer.getEntities()[e];if(s){let r=this._planet.ellipsoid.cartesianToLonLat(t);s.properties.lonLatEll.lon=r.lon,s.properties.lonLatEll.lat=r.lat,s.properties.lonLatEll.height=r.height;let n=this._planet.ellipsoid.getSurfaceNormal3v(t),o=s.properties.headEntity,l=s.properties.heightLabelEntity,h=s.properties.altitude;s.setCartesian3v(t);let c=t.add(n.scale(h));o.setCartesian3v(c),o.properties.columnEntity.ray.setStartPosition3v(t),o.properties.columnEntity.ray.setEndPosition3v(c),(i=this._trackEntity.polyline)==null||i.setPoint3v(c,o.properties.index),l.setCartesian3v(c),l.label.setText(`${r.height.toFixed(1)} m`),l.childEntities[0].label.setText(`${h.toFixed(1)} m`),this.events.dispatch(this.events.change,s.properties.headEntity)}}_deactivate(){this.renderer.events.off("ldblclick",this._onLClick),this.renderer.events.off("mousemove",this._onMouseMove),this.renderer.events.off("lup",this._onLUp),this._groundPointersLayer.events.off("mouseenter",this._onGroundPointerEnter),this._groundPointersLayer.events.off("mouseleave",this._onGroundPointerLeave),this._groundPointersLayer.events.off("ldown",this._onGroundPointerLDown),this._groundPointersLayer.events.off("lup",this._onGroundPointerLUp),this._headPointersLayer.events.off("mouseenter",this._onHeadPointerEnter),this._headPointersLayer.events.off("mouseleave",this._onHeadPointerLeave),this._headPointersLayer.events.off("ldown",this._onHeadPointerLDown),this._headPointersLayer.events.off("lup",this._onHeadPointerLUp),this._trackLayer.remove(),this._groundPointersLayer.remove(),this._headPointersLayer.remove(),this._columnPointersLayer.remove(),this._trackLayer.remove(),this._heightsLayer.remove(),this._pointerLayer.remove(),this.clear()}setPointerVisibility(e){this._pointerLayer.setVisibility(e)}setVisibility(e){this._groundPointersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._columnPointersLayer.setVisibility(e),this._headPointersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._heightsLayer.setVisibility(e),this._pointerLayer.setVisibility(e)}clear(){this._headPointersLayer.setEntities([]),this._groundPointersLayer.setEntities([]),this._columnPointersLayer.setEntities([]),this._heightsLayer.setEntities([]),this._trackEntity.polyline.setPath3v([])}frame(){if(this._clampToGround){let e=new v;const t=this._planet._renderedNodes,i=this._groundPointersLayer.getEntities();for(let s=0;s<i.length;s++){let r=i[s];for(let n=0;n<t.length;n++){let o=t[n];if(o.segment.isEntityInside(r)){o.segment.getEntityTerrainPoint(r,e),r.setCartesian3v(e),r.properties.columnEntity.ray.setStartPosition3v(e);break}}}}}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const kh=["change","addpoint"],Ih=["reset","list","location"];class zh extends be{constructor(e={}){super({...e,template:'<div class="og-elevationprofile-buttons"></div>'}),this.events=this.events.registerNames(Ih),this.pointListBtn=new fe({classList:["og-elevationprofile-button"],icon:'<?xml version="1.0" encoding="utf-8"?><svg width="800px" height="800px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>list</title><rect x="10" y="6" width="18" height="2"/><rect x="10" y="24" width="18" height="2"/><rect x="10" y="15" width="18" height="2"/><rect x="4" y="15" width="2" height="2"/><rect x="4" y="6" width="2" height="2"/><rect x="4" y="24" width="2" height="2"/></svg>',title:"Point List"}),this.pointListBtn.events.on("change",t=>{this.events.dispatch(this.events.list,t)})}render(e){super.render(e);let t=new nt({classList:["og-elevationprofile-button"],icon:`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
301
+ </div>`,model:new wh}),this._onMouseDblClick=t=>{let i,r=this.$canvas.getBoundingClientRect(),s=t.clientX-r.left,n=this._leftDistance+(this._rightDistance-this._leftDistance)*s/this.clientWidth,o=this.model.drawData[1],l=this.model.drawData[0];n<0?(i=1,n=0,s=(0-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):n>this.model.planeDistance?(i=o.length-1,n=this.model.planeDistance,s=(n-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):i=-1-yt(o,n,(v,x)=>v-x[0]);let h=o[i-1],c=o[i],d=(n-h[0])/(c[0]-h[0]),u=h[1]+d*(c[1]-h[1]),g=h[4],f=l[g],p=l[g+1];d=(n-f[0])/(p[0]-f[0]);let _=f[1]+d*(p[1]-f[1]);this.events.dispatch(this.events.dblclick,n,f,p,h,c,g,i-1,_-u)},this._onMouseEnter=t=>{this._isMouseOver=!0,this.events.dispatch(this.events.mouseenter,t)},this._onMouseOut=t=>{this._isMouseOver=!1,this.events.dispatch(this.events.mouseleave,t)},this._onMouseDown=t=>{this._isMouseOver&&(this._isDragging=!0,document.body.classList.add("og-timeline-unselectable"),this._clickPosX=t.clientX,this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX),this._clickLeftDistance=this._leftDistance,this._clickRightDistance=this._rightDistance,this.events.dispatch(this.events.startdrag,t))},this._onMouseUp=t=>{this._isDragging&&(this._isDragging=!1,document.body.classList.remove("og-timeline-unselectable"),this.events.dispatch(this.events.stopdrag,t))},this._onCanvasMouseMove=t=>{if(this.model.pointsReady)if(this._isDragging)this.clearPointerCanvas();else{this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX);let i=this.$pointerCanvas.getBoundingClientRect(),r=t.clientX-i.left;this.redrawPointerCanvas(r)}},this._onMouseMove=t=>{if(this._isDragging&&this.model.pointsReady){let i=(this._clickPosX-t.clientX)*this._canvasScale/this._pixelsInMeter_x;this.setFrame(this._clickLeftDistance+i,this._clickRightDistance+i)}},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onMouseWheel=t=>{if(this._isMouseOver&&this.model.pointsReady){this._customFrame||(this._leftDistance=this.model.minX,this._rightDistance=this.model.maxX),this._customFrame=!0;let i=Math.sign(t.wheelDelta)*(this._rightDistance-this._leftDistance)/20,r=this.$canvas.getBoundingClientRect(),s=t.clientX-r.left,n=s-.5*this.$canvas.clientWidth,o=n*this._canvasScale/this._pixelsInMeter_x,l=o+this._leftDistance+i,h=o+this._rightDistance-i;o=-n*(h-l)/this.clientWidth,this.setFrame(l+o,h+o),this.redrawPointerCanvas(s)}},this.events=this.events.registerNames(Ch),this.fillStyle=e.fillStyle||"rgb(63, 63, 63)",this._customFrame=!1,this._leftDistance=0,this._rightDistance=0,this._pixelsInMeter_x=0,this._pixelsInMeter_y=0,this._canvasScale=2,this.$canvas=document.createElement("canvas"),this.$canvas.style.position="absolute",this._ctx=this.$canvas.getContext("2d"),this.$pointerCanvas=document.createElement("canvas"),this.$pointerCanvas.style.pointerEvents="none",this.$pointerCanvas.style.position="absolute",this._pointerCtx=this.$pointerCanvas.getContext("2d"),this.$loading=null,this._isMouseOver=!1,this._isDragging=!1,this._clickPosX=0,this._clickLeftDistance=0,this._clickRightDistance=0,this._timeStartHandler=0,this._onResizeObserver_=this._onResizeObserver.bind(this),this._resizeObserver=new ResizeObserver(this._onResizeObserver_)}_onResizeObserver(){this.resize()}get canvasScale(){return this._canvasScale}set canvasScale(e){e!==this._canvasScale&&(this._canvasScale=e,this.resize())}resize(){this._resize(),this.draw()}render(){return super.render(),this._resizeObserver.observe(this.el),this.el.appendChild(this.$canvas),this.el.appendChild(this.$pointerCanvas),this.model.events.on("profilecollected",e=>{this._hideLoading(),this.clearPointerCanvas(),this.draw()}),this.model.events.on("startcollecting",()=>{clearTimeout(this._timeStartHandler),this._timeStartHandler=setTimeout(()=>{this._showLoading()},450)}),this.model.events.on("clear",()=>{this._customFrame=!1,this._leftDistance=0,this.clearCanvas(),this.clearPointerCanvas()}),this.$loading=this.select(".og-elevationprofile-loading"),this.$canvas.addEventListener("mouseenter",this._onMouseEnter),this.$canvas.addEventListener("mouseout",this._onMouseOut),this.$canvas.addEventListener("dblclick",this._onMouseDblClick),this.$canvas.addEventListener("mousemove",this._onCanvasMouseMove),document.body.addEventListener("mousemove",this._onMouseMove),document.body.addEventListener("mousedown",this._onMouseDown),document.body.addEventListener("mouseup",this._onMouseUp),document.body.addEventListener("wheel",this._onMouseWheelFF),this}_hideLoading(){clearTimeout(this._timeStartHandler),this.$loading.style.display="none"}_showLoading(){this.$loading.style.display="flex"}redrawPointerCanvas(e){this.clearPointerCanvas();let t,i=this._leftDistance+(this._rightDistance-this._leftDistance)*e/this.clientWidth,r=this.model.drawData[1],s=this.model.drawData[0];i<0?(t=1,i=0,e=(0-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):i>this.model.planeDistance?(t=r.length-1,i=this.model.planeDistance,e=(i-this._leftDistance)*this.clientWidth/(this._rightDistance-this._leftDistance)):t=-1-yt(r,i,(x,y)=>x-y[0]);let n=r[t-1],o=r[t],l=(i-n[0])/(o[0]-n[0]),h=n[1]+l*(o[1]-n[1]),c=n[4],d=s[c],u=s[c+1];l=(i-d[0])/(u[0]-d[0]);let g=d[1]+l*(u[1]-d[1]),f=(this.model.maxY-g)*this._pixelsInMeter_y,p=(this.model.maxY-h)*this._pixelsInMeter_y;this.events.dispatch(this.events.pointer,i,d,u,n,o,c,t-1,g-h);let _=this._pointerCtx;_.lineWidth=3,_.strokeStyle="rgba(64,64,64,0.6)",_.beginPath(),_.moveTo(e*this._canvasScale,0),_.lineTo(e*this._canvasScale,this.clientHeight*this._canvasScale),_.stroke(),_.beginPath(),_.arc(e*this._canvasScale,p,4,0,2*Math.PI,!1),_.fillStyle="#FFB277",_.fill(),_.lineWidth=4,_.strokeStyle="#FFB277",_.stroke(),_.beginPath(),_.arc(e*this._canvasScale,f,4,0,2*Math.PI,!1),_.fillStyle="#FFB277",_.fill(),_.lineWidth=4,_.strokeStyle="#FFB277",_.stroke(),_.lineWidth=3,_.strokeStyle="#FFB277",_.beginPath(),_.moveTo(e*this._canvasScale,p),_.lineTo(e*this._canvasScale,f),_.stroke(),_.fillStyle="white",_.font=28/devicePixelRatio+"px Arial",_.textBaseline="middle",_.textAlign="left",_.fillText(`${Math.round(g-h).toString()} m`,(e+5)*this._canvasScale,p+.5*(f-p)),_.fillStyle="white",_.font=28/devicePixelRatio+"px Arial",_.textAlign="right";let v=zt(i);_.fillText(`${v[0]} ${v[1]}`,(e-5)*this._canvasScale,(this.clientHeight-7)*this._canvasScale)}get clientWidth(){return this.$canvas?this.$canvas.width/this._canvasScale:0}get clientHeight(){return this.$canvas?this.$canvas.height/this._canvasScale:0}_resize(){this.el&&(this.$canvas.width=this.el.clientWidth*this._canvasScale,this.$canvas.height=this.el.clientHeight*this._canvasScale,this.$canvas.style.width=`${this.el.clientWidth}px`,this.$canvas.style.height=`${this.el.clientHeight}px`,this.$pointerCanvas.width=this.el.clientWidth*this._canvasScale,this.$pointerCanvas.height=this.el.clientHeight*this._canvasScale,this.$pointerCanvas.style.width=`${this.el.clientWidth}px`,this.$pointerCanvas.style.height=`${this.el.clientHeight}px`,this._customFrame&&(this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this._rightDistance-this._leftDistance)))}clearPointerCanvas(){this._pointerCtx.fillStyle="rgba(0,0,0,0)",this._pointerCtx.clearRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}clearCanvas(){const e=this._ctx.createLinearGradient(0,0,0,this.clientHeight*this._canvasScale);e.addColorStop(0,"black"),e.addColorStop(1,this.fillStyle),this._ctx.fillStyle=e,this._ctx.fillRect(0,0,this.clientWidth*this._canvasScale,this.clientHeight*this._canvasScale)}setFrame(e,t){this._leftDistance=e,this._rightDistance=t,this._customFrame=!0,this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this._rightDistance-this._leftDistance),this.model.setRange(e,t),this.draw()}_updateUnits(){this._customFrame||(this._pixelsInMeter_x=this._canvasScale*this.clientWidth/(this.model.maxX-this.model.minX)),this._pixelsInMeter_y=this._canvasScale*this.clientHeight/(this.model.maxY-this.model.minY)}clear(){this.model.clear(),this.clearCanvas()}draw(){let e=this.model.drawData[0];if(e.length>1){this._updateUnits(),this.clearCanvas();let t=this.model.drawData[1];this._drawTrack(e,t),this._drawTerrain(t),this._drawWarningAndCollision(t),this._drawLabels(e,t)}else this.clearCanvas()}_drawLabels(e,t){let i=this._ctx;if(i){let r=e[0];const s=this.model.maxY;let n=(-this._leftDistance+r[0])*this._pixelsInMeter_x,o=(s-r[1])*this._pixelsInMeter_y;t[r[2]][1],this._pixelsInMeter_y,i.beginPath(),i.fillStyle="#F7F718",i.fillRect(n-4,o-4,8,8),i.stroke(),i.fillStyle="white",i.font=26/devicePixelRatio+"px Arial",i.textBaseline="bottom",i.textAlign="left",i.fillText(`${Math.round(r[1]-t[r[2]][1]).toString()} m`,n+1,o-10),i.stroke();for(let l=1,h=e.length;l<h;l++){let c=e[l];n=(-this._leftDistance+c[0])*this._pixelsInMeter_x,o=(s-c[1])*this._pixelsInMeter_y,t[c[2]][1],this._pixelsInMeter_y,i.beginPath(),i.fillStyle="#F7F718",i.fillRect(n-4,o-4,8,8),i.stroke(),i.fillStyle="white",i.fillText(`${Math.round(c[1]-t[c[2]][1]).toString()} m`,n+1,o-10),i.stroke()}}}_drawTrack(e,t){let i=e[0],r=this._ctx;if(r){const s=this.model.maxY;r.lineWidth=5,r.strokeStyle="rgb(0, 255, 50)",r.beginPath(),r.moveTo((-this._leftDistance+i[0])*this._pixelsInMeter_x,(s-i[1])*this._pixelsInMeter_y);let n=0;for(let c=1,d=e.length;c<d;c++){let u=e[c];r.lineTo((-this._leftDistance+u[0])*this._pixelsInMeter_x,(s-u[1])*this._pixelsInMeter_y);let g=e[c-1],f=u[0]-g[0],p=u[1]-g[1],_=f*f,v=p*p;n+=Math.sqrt(_+v)}r.stroke(),r.lineWidth=2,r.strokeStyle="rgba(255,255,255,0.7)",r.beginPath();let o=(-this._leftDistance+i[0])*this._pixelsInMeter_x,l=(s-i[1])*this._pixelsInMeter_y,h=(s-t[i[2]][1])*this._pixelsInMeter_y;r.moveTo(o,l),r.lineTo(o,h);for(let c=1,d=e.length;c<d;c++){let u=e[c];o=(-this._leftDistance+u[0])*this._pixelsInMeter_x,l=(s-u[1])*this._pixelsInMeter_y,h=(s-t[u[2]][1])*this._pixelsInMeter_y,r.strokeStyle="rgba(255,255,255,0.7)",r.moveTo(o,l),r.lineTo(o,h)}r.stroke(),this.events.dispatch(this.events.tracklength,n)}}_drawTerrain(e){let t=e[0],i=this._ctx;if(i){const r=this.model.maxY;i.lineWidth=5,i.strokeStyle=Pa,i.beginPath(),i.moveTo((-this._leftDistance+t[0])*this._pixelsInMeter_x,this.$canvas.height),i.lineTo((-this._leftDistance+t[0])*this._pixelsInMeter_x,(r-t[1])*this._pixelsInMeter_y);let s=0;for(let n=1,o=e.length;n<o;n++){let l=e[n];i.lineTo((-this._leftDistance+l[0])*this._pixelsInMeter_x,(r-l[1])*this._pixelsInMeter_y);let h=e[n-1],c=l[0]-h[0],d=l[1]-h[1],u=c*c,g=d*d;s+=Math.sqrt(u+g)}i.lineTo((-this._leftDistance+e[e.length-1][0])*this._pixelsInMeter_x,this.$canvas.height),i.closePath(),i.stroke(),i.save(),i.fillStyle="rgb(64, 68, 82)",i.globalAlpha=.5,i.fill(),i.restore(),i.globalAlpha=1,this.events.dispatch(this.events.groundlength,s)}}_drawWarningAndCollision(e){let t=this._ctx;if(t&&e.length>1){let i=this.model.maxY;t.lineWidth=5,t.beginPath();let r=0,s=0;for(let n=0,o=e.length-1;n<o;n++){let l=e[n],h=e[n+1];if(l[2]!==0&&h[2]!==0){let c=h[0]-l[0],d=h[1]-l[1],u=c*c,g=d*d;l[2]===2?(t.stroke(),t.beginPath(),t.strokeStyle=Sa[2],s+=Math.sqrt(u+g)):l[2]===1&&(t.stroke(),t.beginPath(),t.strokeStyle=Sa[1],r+=Math.sqrt(u+g)),t.moveTo((-this._leftDistance+l[0])*this._pixelsInMeter_x,(i-l[1])*this._pixelsInMeter_y),t.lineTo((-this._leftDistance+h[0])*this._pixelsInMeter_x,(i-h[1])*this._pixelsInMeter_y)}}t.stroke(),this.events.dispatch(this.events.warninglength,r),this.events.dispatch(this.events.collisionlength,s)}}}let Eh=Z.createCylinder(.33,0,1,20,1,!0,!1,0,0,0),Ah=Z.createCylinder(.33,.33,1.1,20,1,!0,!0,0,-.55,0);const Lh={startPosition:new m,endPosition:new m,startColor:"rgba(255,131,0,0.2)",endColor:"rgba(255,131,0,1.0)",thickness:2.7},Ph={src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjEuNBNAaMQAAAiLSURBVHhe7Z0r0BxFEMcjIhAIRERERAQCgUAgEBEIBAIRiUAgIiIQiAgEIlUREQgEIgIREYFAIBCIiAgEIiIiAoGIoHimqPAKz5CP/t23/8vcbe89d/dmZ/pf9avLdZK72e6+ee3M7Imjo6Opc8o4b7xn3DIeGEOJz+Y7+C6+k+/2yjQZXOMEOGdcNe4anv4wvjV+m73bT3wGn8VneqIMlIUyeWXNGteYKTj4feNrI9W/xi/HfxxVfCffnYqyUcbJJINrzIjTxjvGV0aqn43fj/+YhSgLZUpFmd81uAbv2rLANWbAC8ZHxp+GxC8ufZ+rKGNaI1FLcC1ck3etB8U1HhCqzk8N6T/jENV7X6LsXIN008iqeXCNB+B54zND+tt4ePzHIsS1cE0SicA1e74YFdc4IgyjrhvqTP3TvJas9Bq59oP2EVzjCJw03jI0TCMBcurUDS1qBCU9PnjbwCeerwbFNQ4MVd9tQ5pyG7+v0mvHJ6N3FF3jgFwy1JPvmlipUfIFvmHY6/luEFzjANDO0fGRfm1eQ0+UzlriqzOG58tecY0985LxnYH+al5D3ZKP8Bm+83zaG66xRy4a6uzU3NZvK/nqkUEH0fNtL7jGHqBH+4EhTWEGL2ddMwYZJbjGPaGgHxuIDA7tJ/mQGdLek8A17sHTxucGiva+P6kGxbf42PP9TrjGHUmDH1V+/xokCVzjDkTwx1HvSeAat4R2SWP8CP7wko9ZmrZ3n8A1bok6fBH88SRf4/u9ksA1bgFr4ZDG+qHxpLuKLFD1YrMRrnFDLhjocfMaGl8aIjLh5sVoLa5xA140+lhxG+pHNAk7TRu7xjXQ+9TK3Jru4ecqxYB7B88YXsw6cY1rUKcv7ujlI907YLbQi1knrnEFavej05ef1ClkpZUXOxfX2AH3p6Pdz1/E6FnDi2EL19iBVu3Gbd18pdgwU+jFsIVrdHjDQHGDJ39pkojm2ovlAq5xCXqWWtETmo7uG2t3L7vGJTTbF73+6UhNARtVvZjOcY0JZ42Y45+uGK2t7BC6xoQbBoqO3/SkGpt5Gy+2M1xjw3MGGZRubgxNS5qv6dxw4hob9OuPsf90pWnizlrANRpM+sSvvwypFqBGb8W6ZWjgHjOKtn/6Ug3OMv1WrFsG4ykjqv3yxGiudbdw4U2DbvjEuL8cqSZv7TJaeNOg1b2h8nTHWIj3whuDSQOUHmcSKkPagr5wNE0afLhioOj8lSc16QvTw2nwYfk8vlB5YjnfPOZp8FX9x8kd5Uqju3kzkCYAPUQU1X+5UjPACaatBEiPcAmVrfmKIQU/Jn/qEpNCs82lSgCOL0U/Na+hcvVD8/qKMU8AjiZDsdGjfCnGl415AnyCJVSVZptIlAD3sISqEgt9ZwnAHSIU07/1SMv7T5EA7CpFPzavofKljuA5EkCbPmICqB4p1m+SAPQGQ3XqMgnAQwtCdeo6CRBTwPXqJgnAKpFQnbpDAsQcQL26RwLEzt96dZ8ECFWsSIDKFQlQuSIBKlckQOUiAThLJlSnZqOAmAeoV7N5gJgJrFd3SQCePBGqU7dIgLgbWK9mdwO1ITRUn66QADoQIlYE1SPF+gIJEGsC69PCmkDOk0WxKrgeaQf4aRIA9AiYUD2a7wuA2BlUn1gKOE8A9ouj2BtYvh42r4z+5gnATlEUHcHy9X3z+poxT4A4H6Aecfxv63wAiOXh9ah1QgioHxAnhJYr1fKz9h/SBOA0aRSnhJUrJQCP/m0lAMQ5geWr85xA0I2haAbKk4b4K08KVTMQ08LlSU37vPqHNPgiVgiVK5r4hXgvvGm4aKC4PVyOFMuNnhfABEFMCpWnjZ8YAjxfBkUiTF/q/LH0rxXrlqFBJ4friVOh6Uod+oUHRYiWIYFnzaG4QzhdqefPo/+9GK9MAJ42SQ0QtcB0pV//wtAvxTUmqBaIiaHpSff9Z0fCduEaE+gLxBNEpyliRuzctl+4xiU0Ioh5gelIsfrQ8GI6xzUuwdjxgRGalojZacOL6RzX6KDNI0wmhPKWev6tWT8P19jBFwaKDmG+0pD9tnHS8OK4gGvsgDuFUQPkr7UdvxTXuAI9Wk7nzYfykX6clwwvdi6ucQ3MKqEYFeQjxYKFvRtV/cI1roG9hDpdNNYPHl6KAWc9re31L+MaN4DHzMUUcT4iFi8bXqxW4ho3RP2Bx81raHw9al557J8Xo7W4xi24ZqAYHYwv+XztbN8qXOMW0OFQpzBuG48n+XrrTt8yrnFLWELGViMUSTC85GN8Ptvftw+ucQcYGTD7hCIJhpN8y8rtrXv8Hq5xR7hpdNdAkQT9Sz7Fx70EH1zjHlAl6Z5BdAz7k3xJLdta2bsPrnFP0j5BzBXsL/mwlzZ/GdfYA/RMbxgo5gl2l3yHL/fq7XfhGnskfSpp3DvYXKmvZs/5HwrX2DOcP6QVRVqoGOqWfMSmnFcNz6e94RoH4IyhziGLFeMmUlv4RItv8RU+83zZK65xIGjDOH9AnZoYKj6RfIFvrhqDtPcernFg2KTwpSHVvMQsvXa2bnNus+ezwXCNI6DaQOPbGoeLumZ8gC9G+9WnuMYRYeOJdh+hGiaP0mvkiF584PlmFFzjAWAxgzqJqMRESK+Ja91pAUffuMYDwvGlaSJQTU65j0DZ0+aNaztveNd+EFxjBjB3QPWYOm9Kh1WkZeUa2KDJNXnXelBcY0bQPnKs2fIj7nOsFZbLRJkp+0Hb+HW4xgzhMGuqTubEl2sC9igcYpqZ71zeH0HZKCNlpczetWSFa8wcJQO7lrtONiUQ3xh9TDbxGXxWVxNEGSjLZIKe4honxlnjdYMFqnSyhhxB8Nl8B9/Fd/LdXpkmg2ssANpdfpEsXacdZq6BJ6Tya+VZyWnnUsLG3/Fv+Lf8H/4vn8FnZd2W78bRif8BxMOwtJg5Ph4AAAAASUVORK5CYII=",color:"rgb(255,131,0)",size:[8,8]},Sh={text:"",face:"arial",size:10.5,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"left",offset:[5,15,-5]},Ma={face:"arial",text:"",size:10.5,color:"rgba(455,455,455,1.0)",outlineColor:"rgba(0,0,0,0.34)",outline:.23,align:"right",offset:[-47,25,0]},Mh={instanced:!0,tag:"ground-pointer",color:"rgb(0,305,0)",object3d:Eh},Rh={instanced:!0,tag:"head-pointer",color:"rgb(305,305,0)",object3d:Ah};class Bh extends ot{constructor(e={}){super("ElevationProfileScene"),this._onLClick=t=>{let i=this._planet.getCartesianFromPixelTerrain(t.pos);i&&this.addGroundPoint3vAsync(i)},this._onMouseMove=t=>{if(this._planet.getCartesianFromMouseTerrain(),this._pickedGroundEntity){let i=new N(t.x,t.y).sub(this._startClickPos),r=this._startEntityPos.add(i),s=this._planet.getCartesianFromPixelTerrain(r);s&&this.setGroundPointCartesian3v(this._pickedGroundEntity.properties.index,s)}else if(this._pickedHeadEntity){let i=this._planet.camera,r=this._pickedHeadEntity.properties.groundEntity.getCartesian(),s=this._planet.ellipsoid.getSurfaceNormal3v(r),n=r.add(s),o=r.add(i.getRight()),l=new m;if(new H(i.eye,t.direction).hitPlaneRes(we.fromPoints(r,n,o),l)===H.INSIDE){let h=m.proj_b_to_a(l,r),c=h.sub(r).dot(r),d=r.add(s.scale(Math.sign(c)*h.distance(r)));this.setHeadPointCartesian3v(this._pickedHeadEntity.properties.index,d)}}},this._onLUp=t=>{},this._onGroundPointerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onGroundPointerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onGroundPointerLDown=t=>{this._clampToGround=!1,this.renderer.controls.mouseNavigation.deactivate(),this._pickedGroundEntity=t.pickingObject;const i=this._pickedGroundEntity.getCartesian();this._startClickPos.set(t.x,t.y),this._startEntityPos=this._planet.getPixelFromCartesian(i)},this._onGroundPointerLUp=t=>{this._clampToGround=!0,this.renderer.controls.mouseNavigation.activate(),this._pickedGroundEntity=null},this._onHeadPointerEnter=t=>{t.renderer.handler.canvas.style.cursor="pointer"},this._onHeadPointerLeave=t=>{t.renderer.handler.canvas.style.cursor="default"},this._onHeadPointerLDown=t=>{this.renderer.controls.mouseNavigation.deactivate(),this._pickedHeadEntity=t.pickingObject},this._onHeadPointerLUp=t=>{this.renderer.controls.mouseNavigation.activate(),this._pickedHeadEntity=null},this.events=le(kh),this._planet=e.planet||null,this._pickedGroundEntity=null,this._pickedHeadEntity=null,this._startClickPos=new N,this._startEntityPos=new N,this._clampToGround=!0,this._trackLayer=new fe("track",{entities:[],pickingEnabled:!1,polygonOffsetUnits:-1,relativeToGround:!0,hideInLayerSwitcher:!0}),this._groundPointersLayer=new fe("ground-pointers",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,5e3,.02],pickingScale:1.5}),this._headPointersLayer=new fe("head-pointers",{entities:[],pickingEnabled:!0,hideInLayerSwitcher:!0,scaleByDistance:[1,1e4,.02],pickingScale:1}),this._columnPointersLayer=new fe("column-pointers",{entities:[],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._trackEntity=new V({polyline:{path3v:[],thickness:3.8,color:"rgba(0,305,0,0.8)",isClosed:!1}}),this._trackLayer=new fe("column-pointers",{entities:[this._trackEntity],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._heightsLayer=new fe("heights-labels",{entities:[],pickingEnabled:!1,hideInLayerSwitcher:!0}),this._pointerHeadEntity=new V({cartesian:new m,billboard:Ph}),this._pointerLabelEntity=new V({cartesian:new m,label:Sh}),this._pointerRayEntity=new V({cartesian:new m,ray:Lh}),this._pointerLayer=new fe("pointer",{entities:[this._pointerHeadEntity,this._pointerLabelEntity,this._pointerRayEntity],pickingEnabled:!1,hideInLayerSwitcher:!0})}flyExtent(){let e=this._headPointersLayer.getEntities(),t=180,i=180,r=-180,s=-180,n=-1e6;if(e.length>1){for(let o=0;o<e.length;o++){let l=e[o].getLonLat();l.lon<t&&(t=l.lon),l.lat<i&&(i=l.lat),l.lon>r&&(r=l.lon),l.lat>s&&(s=l.lat),l.height>n&&(n=l.height)}this._planet.camera.flyExtent(new j(new A(t,i),new A(r,s)),n,{amplitude:0})}}get planet(){return this._planet}_createGroundPointer(e,t=10){let i=this.ellipsoid.getSurfaceNormal3v(e),r=e.add(i.scale(t)),s=new V({ray:{startPosition:e,endPosition:r,startColor:"rgba(255,255,255,0.2)",endColor:"rgba(355,355,355,1.0)",thickness:3.2}}),n=new V({cartesian:e,geoObject:Mh}),o=new V({cartesian:r,geoObject:Rh,properties:{}}),l=new V({cartesian:r,label:Ma});l.appendChild(new V({cartesian:r,label:{...Ma,offset:[-47,45,0]}}));const h=this._groundPointersLayer.getEntities().length;return s.properties=n.properties=o.properties={index:h,altitude:t,lonLatEll:new A,headEntity:o,groundEntity:n,columnEntity:s,heightLabelEntity:l},{headEntity:o,groundEntity:n,columnEntity:s,heightLabelEntity:l}}setPointerCartesian3v(e,t){this._pointerLabelEntity.setCartesian3v(e),this._pointerLabelEntity.label.setText(`${Math.round(t).toString()} m`),this._pointerRayEntity.ray.setEndPosition3v(e);let i=this._planet.ellipsoid.getSurfaceNormal3v(e);this._pointerRayEntity.ray.setStartPosition3v(e.add(i.scale(-t))),this._pointerHeadEntity.setCartesian3v(e)}bindPlanet(e){this._planet=e}init(){this._activate()}onremove(){this._deactivate()}_activate(){this._planet.addLayer(this._trackLayer),this._planet.addLayer(this._groundPointersLayer),this._planet.addLayer(this._columnPointersLayer),this._planet.addLayer(this._headPointersLayer),this._planet.addLayer(this._heightsLayer),this._planet.addLayer(this._pointerLayer),this.renderer.events.on("ldblclick",this._onLClick),this.renderer.events.on("mousemove",this._onMouseMove),this.renderer.events.on("lup",this._onLUp),this._groundPointersLayer.events.on("mouseenter",this._onGroundPointerEnter),this._groundPointersLayer.events.on("mouseleave",this._onGroundPointerLeave),this._groundPointersLayer.events.on("ldown",this._onGroundPointerLDown),this._groundPointersLayer.events.on("lup",this._onGroundPointerLUp),this._headPointersLayer.events.on("mouseenter",this._onHeadPointerEnter),this._headPointersLayer.events.on("mouseleave",this._onHeadPointerLeave),this._headPointersLayer.events.on("ldown",this._onHeadPointerLDown),this._headPointersLayer.events.on("lup",this._onHeadPointerLUp),this.setPointerVisibility(!1)}getPointLonLat(e){let t=this._headPointersLayer.getEntities()[e];if(t)return t.getLonLat()}getPointsLonLat(){let e=this._headPointersLayer.getEntities(),t=new Array(e.length);for(let i=0,r=t.length;i<r;i++){let s=e[i];t[i]=s.getLonLat()}return t}getHeightMSL(e){return this._planet&&this._planet.terrain.geoid?this._planet.terrain.geoid.getHeightLonLat(e):0}getHeightELLAsync(e){return new Promise((t,i)=>{this._planet.terrain.getHeightAsync(e,r=>{if(this._planet){let s=this.getHeightMSL(e);t(r+s)}else i()})})}addPointLonLatArrayAsync(e,t=!1){if(!this._planet)throw new Error("Planet is not defined");let i=this._planet.ellipsoid;for(let s=0,n=e.length-1;s<n;s++){let o=i.lonLatToCartesian(e[s]),l=i.lonLatToCartesian(e[s+1]);if(o.distance(l)>1e5)throw new Error("Track is too long! 100 km is maximum.")}let r=new Array(e.length);for(let s=0,n=e.length;s<n;s++)r[s]=this.addPointLonLatAsync(e[s],!0);return Promise.all(r).then(()=>{t||this.events.dispatch(this.events.change,this)}),r}addPointLonLatAsync(e,t=!1){let i=this._planet.ellipsoid.lonLatToCartesian(e),r=this._planet.ellipsoid.getSurfaceNormal3v(i),s=new A(e.lon,e.lat),n=this._planet.ellipsoid.lonLatToCartesian(s),{headEntity:o,groundEntity:l,columnEntity:h,heightLabelEntity:c}=this._createGroundPointer(n);return this._groundPointersLayer.add(l),this._columnPointersLayer.add(h),this._headPointersLayer.add(o),this._heightsLayer.add(c),this._trackEntity.polyline.appendPoint3v(o.getCartesian()),l.properties.lonLatEll.lon=s.lon,l.properties.lonLatEll.lat=s.lat,l.properties.lonLatEll.height=s.height,new Promise(d=>{this.getHeightELLAsync(e).then(u=>{var g;l.properties.lonLatEll.height=u;let f,p=10;e.height===0?(f=i.add(r.scaleTo(u)),i=f.add(r.scaleTo(p))):(p=e.height-u,f=i.sub(r.scaleTo(p))),l.setCartesian3v(f),c.setCartesian3v(i),c.label.setText(`${u.toFixed(1)} m`),c.childEntities[0].label.setText(`${p.toFixed(1)} m`),o.properties.altitude=p,o.setCartesian3v(i),o.properties.columnEntity.ray.setStartPosition3v(f),o.properties.columnEntity.ray.setEndPosition3v(i),(g=this._trackEntity.polyline)==null||g.setPoint3v(i,o.properties.index),t||(this.events.dispatch(this.events.addpoint,o,this),this.events.dispatch(this.events.change,this)),d(o)})})}addGroundPointLonLatAsync(e,t=10,i=!1){let r=this._planet.ellipsoid.lonLatToCartesian(e);return this._addPoint(r,e,t,i)}addGroundPoint3vAsync(e,t=10,i=!1){let r=this._planet.ellipsoid.cartesianToLonLat(e);return this._addPoint(e,r,t,i)}_addPoint(e,t,i,r=!1){return new Promise((s,n)=>{let{headEntity:o,groundEntity:l,columnEntity:h,heightLabelEntity:c}=this._createGroundPointer(e,i);this._groundPointersLayer.add(l),this._columnPointersLayer.add(h),this._headPointersLayer.add(o),this._heightsLayer.add(c),this._trackEntity.polyline.appendPoint3v(o.getCartesian()),l.properties.lonLatEll.lon=t.lon,l.properties.lonLatEll.lat=t.lat,l.properties.lonLatEll.height=t.height,this.getHeightELLAsync(t).then(d=>{var u;l.properties.lonLatEll.height=t.height=d;let g=this._planet.ellipsoid.lonLatToCartesian(t),f=this._planet.ellipsoid.getSurfaceNormal3v(g),p=g.add(f.scale(i));c.setCartesian3v(p),c.label.setText(`${d.toFixed(1)} m`),c.childEntities[0].label.setText(`${i.toFixed(1)} m`),o.setCartesian3v(p),o.properties.columnEntity.ray.setEndPosition3v(p),(u=this._trackEntity.polyline)==null||u.setPoint3v(p,o.properties.index),r||(this.events.dispatch(this.events.addpoint,o,this),this.events.dispatch(this.events.change,this)),s(o)})})}setHeadPointCartesian3v(e,t){const i=this._headPointersLayer.getEntities()[e];if(i){let r=this._planet.ellipsoid.lonLatToCartesian(i.properties.lonLatEll),s=t.length()-r.length();s<=0&&(t=r,s=0),i.properties.altitude=s,i.setCartesian3v(t),i.properties.columnEntity.ray.setEndPosition3v(t),i.properties.heightLabelEntity.setCartesian3v(t),i.properties.heightLabelEntity.childEntities[0].label.setText(`${s.toFixed(1)} m`),this._trackEntity.polyline.setPoint3v(t,e),this.events.dispatch(this.events.change,this._pickedHeadEntity)}}setGroundPointCartesian3v(e,t){var i;let r=this._groundPointersLayer.getEntities()[e];if(r){let s=this._planet.ellipsoid.cartesianToLonLat(t);r.properties.lonLatEll.lon=s.lon,r.properties.lonLatEll.lat=s.lat,r.properties.lonLatEll.height=s.height;let n=this._planet.ellipsoid.getSurfaceNormal3v(t),o=r.properties.headEntity,l=r.properties.heightLabelEntity,h=r.properties.altitude;r.setCartesian3v(t);let c=t.add(n.scale(h));o.setCartesian3v(c),o.properties.columnEntity.ray.setStartPosition3v(t),o.properties.columnEntity.ray.setEndPosition3v(c),(i=this._trackEntity.polyline)==null||i.setPoint3v(c,o.properties.index),l.setCartesian3v(c),l.label.setText(`${s.height.toFixed(1)} m`),l.childEntities[0].label.setText(`${h.toFixed(1)} m`),this.events.dispatch(this.events.change,r.properties.headEntity)}}_deactivate(){this.renderer.events.off("ldblclick",this._onLClick),this.renderer.events.off("mousemove",this._onMouseMove),this.renderer.events.off("lup",this._onLUp),this._groundPointersLayer.events.off("mouseenter",this._onGroundPointerEnter),this._groundPointersLayer.events.off("mouseleave",this._onGroundPointerLeave),this._groundPointersLayer.events.off("ldown",this._onGroundPointerLDown),this._groundPointersLayer.events.off("lup",this._onGroundPointerLUp),this._headPointersLayer.events.off("mouseenter",this._onHeadPointerEnter),this._headPointersLayer.events.off("mouseleave",this._onHeadPointerLeave),this._headPointersLayer.events.off("ldown",this._onHeadPointerLDown),this._headPointersLayer.events.off("lup",this._onHeadPointerLUp),this._trackLayer.remove(),this._groundPointersLayer.remove(),this._headPointersLayer.remove(),this._columnPointersLayer.remove(),this._trackLayer.remove(),this._heightsLayer.remove(),this._pointerLayer.remove(),this.clear()}setPointerVisibility(e){this._pointerLayer.setVisibility(e)}setVisibility(e){this._groundPointersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._columnPointersLayer.setVisibility(e),this._headPointersLayer.setVisibility(e),this._trackLayer.setVisibility(e),this._heightsLayer.setVisibility(e),this._pointerLayer.setVisibility(e)}clear(){this._headPointersLayer.setEntities([]),this._groundPointersLayer.setEntities([]),this._columnPointersLayer.setEntities([]),this._heightsLayer.setEntities([]),this._trackEntity.polyline.setPath3v([])}frame(){if(this._clampToGround){let e=new m;const t=this._planet.quadTreeStrategy._renderedNodes,i=this._groundPointersLayer.getEntities();for(let r=0;r<i.length;r++){let s=i[r];for(let n=0;n<t.length;n++){let o=t[n];if(o.segment.isEntityInside(s)){o.segment.getEntityTerrainPoint(s,e),s.setCartesian3v(e),s.properties.columnEntity.ray.setStartPosition3v(e);break}}}}}get ellipsoid(){return this._planet?this._planet.ellipsoid:null}}const kh=["change","addpoint"],Ih=["reset","list","location"];class zh extends be{constructor(e={}){super({...e,template:'<div class="og-elevationprofile-buttons"></div>'}),this.events=this.events.registerNames(Ih),this.pointListBtn=new _e({classList:["og-elevationprofile-button"],icon:'<?xml version="1.0" encoding="utf-8"?><svg width="800px" height="800px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>list</title><rect x="10" y="6" width="18" height="2"/><rect x="10" y="24" width="18" height="2"/><rect x="10" y="15" width="18" height="2"/><rect x="4" y="15" width="2" height="2"/><rect x="4" y="6" width="2" height="2"/><rect x="4" y="24" width="2" height="2"/></svg>',title:"Point List"}),this.pointListBtn.events.on("change",t=>{this.events.dispatch(this.events.list,t)})}render(e){super.render(e);let t=new nt({classList:["og-elevationprofile-button"],icon:`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
302
302
  <svg width="30" height="30" viewBox="0 0 30 30" version="1.1">
303
303
  <g transform="translate(0,-289.0625)">
304
304
  <path d="M 15 6 C 10.041282 6 6 10.04128 6 15 C 6 19.95872 10.041282 24 15 24 C 16.586491 24 18.07668 23.58246 19.373047 22.857422 L 17.888672 21.375 C 17.00816 21.772814 16.032235 22 15 22 C 11.122162 22 8 18.87784 8 15 C 8 11.12216 11.122162 8 15 8 C 18.877838 8 22 11.12216 22 15 L 19 15 L 23 20 L 27 15 L 24 15 C 24 10.04128 19.958718 6 15 6 z " transform="translate(0,289.0625)" />
@@ -309,7 +309,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
309
309
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
310
310
  <metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
311
311
  <g><g><path fill="#000000" d="M127,169.4c23.7,0,42.8-18.3,42.8-41s-19.2-41-42.8-41c-23.7,0-42.8,18.4-42.8,41S103.4,169.4,127,169.4z"/><path fill="#000000" d="M221.7,120.2c-3.8-44-40.9-78.9-87-82V15h-16.3v23.6c-44.8,4-80.3,38.5-84.1,81.7H10v15.6h24.3c3.8,43.1,39.3,77.4,84.1,81.7V241h16.3v-23.2c46-3.1,83.2-37.9,87-82H246v-15.6H221.7L221.7,120.2L221.7,120.2z M128,201.6c-42.5,0-76.7-33-76.7-73.4c0-40.4,34.5-73.4,76.7-73.4c42.5,0,76.7,33,76.7,73.4C204.7,168.5,170.5,201.6,128,201.6L128,201.6z"/></g></g>
312
- </svg>`,title:"View bounds"});return i.appendTo(this.el),i.events.on("click",()=>{this.events.dispatch(this.events.location,this)}),this}}class Dh extends ot{constructor(e){super({title:"Points List",visible:!1,resizable:!0,useHide:!0,top:150,left:200,width:400,height:300,minHeight:100,minWidth:100,...e}),this._onApplyClick=()=>{try{this.model.clear();let t=JSON.parse(this.$textarea.value),i=new Array(t.length);for(let s=0;s<t.length;s++){let r=t[s];i[s]=new A(r[0],r[1],r[2])}this.model.addPointLonLatArrayAsync(i)}catch(t){console.error(t)}},this.$textarea=null}render(e){super.render(e);let t=new be({template:`<div class="og-elevationprofile-list">
312
+ </svg>`,title:"View bounds"});return i.appendTo(this.el),i.events.on("click",()=>{this.events.dispatch(this.events.location,this)}),this}}class Dh extends at{constructor(e){super({title:"Points List",visible:!1,resizable:!0,useHide:!0,top:150,left:200,width:400,height:300,minHeight:100,minWidth:100,...e}),this._onApplyClick=()=>{try{this.model.clear();let t=JSON.parse(this.$textarea.value),i=new Array(t.length);for(let r=0;r<t.length;r++){let s=t[r];i[r]=new A(s[0],s[1],s[2])}this.model.addPointLonLatArrayAsync(i)}catch(t){console.error(t)}},this.$textarea=null}render(e){super.render(e);let t=new be({template:`<div class="og-elevationprofile-list">
313
313
  <textarea placeholder="[[lon, lat, height], [lon, lat, height], ..., [lon, lat, height]]"></textarea>
314
314
  <div class="og-elevationprofile-list-buttons"></div>
315
315
  </div>`});t.appendTo(this.container);let i=new nt({classList:["og-elevationprofile-list-apply"],icon:"Apply"});return i.appendTo(t.select(".og-elevationprofile-list-buttons")),i.events.on("click",this._onApplyClick),this.$textarea=t.select("textarea"),this}}class Fh extends be{constructor(e={}){super({...e,template:`<div class="og-elevationprofile-legend">
@@ -333,20 +333,20 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
333
333
  <div class="og-elevationprofile-value">0</div>
334
334
  <div class="og-elevationprofile-units">m</div>
335
335
  </div>
336
- </div>`}),this.$groundValue=null,this.$trackValue=null,this.$warningValue=null,this.$collisionValue=null,this.$trackUnits=null,this.$groundUnits=null,this.$warningUnits=null,this.$collisionUnits=null}render(e){return super.render(e),this.$trackValue=this.select(".og-elevationprofile-legend__track .og-elevationprofile-value"),this.$groundValue=this.select(".og-elevationprofile-legend__ground .og-elevationprofile-value"),this.$warningValue=this.select(".og-elevationprofile-legend__warning .og-elevationprofile-value"),this.$collisionValue=this.select(".og-elevationprofile-legend__collision .og-elevationprofile-value"),this.$trackUnits=this.select(".og-elevationprofile-legend__track .og-elevationprofile-units"),this.$groundUnits=this.select(".og-elevationprofile-legend__ground .og-elevationprofile-units"),this.$warningUnits=this.select(".og-elevationprofile-legend__warning .og-elevationprofile-units"),this.$collisionUnits=this.select(".og-elevationprofile-legend__collision .og-elevationprofile-units"),this}clear(){this.$trackValue&&(this.$trackValue.innerText="0"),this.$trackUnits&&(this.$trackUnits.innerText="m"),this.$groundValue&&(this.$groundValue.innerText="0"),this.$groundUnits&&(this.$groundUnits.innerText="m"),this.$warningValue&&(this.$warningValue.innerText="0"),this.$warningUnits&&(this.$warningUnits.innerText="m"),this.$collisionValue&&(this.$collisionValue.innerText="0"),this.$collisionUnits&&(this.$collisionUnits.innerText="m")}setTrackLength(e){let t=Dt(e);this.$trackValue.innerText=t[0],this.$trackUnits.innerText=t[1]}setGroundLength(e){let t=Dt(e);this.$groundValue.innerText=t[0],this.$groundUnits.innerText=t[1]}setWarningLength(e){let t=Dt(e);this.$warningValue.innerText=t[0],this.$warningUnits.innerText=t[1]}setCollisionLength(e){let t=Dt(e);this.$collisionValue.innerText=t[0],this.$collisionUnits.innerText=t[1]}}const Ht="rgb(253,77,77)",qs="rgb(248,115,115)",Wi="rgb(73,73,239)",Ws="rgb(90,90,253)",$i="rgb(26,122,26)",$s="rgb(55,191,55)",Ro="rgba(255,255,255,0.8)",Xi=.1,Bo=new v(Xi,Xi,Xi),ko=.17,Io=.0095,Oh=Z.createCylinder(Io,Io,.83).scale(Bo),Nh=Z.createCylinder(0,.04,ko,16,16,!1,!0,0,-.17).scale(Bo);class Xs extends V{constructor(e={}){super({independentPicking:!0,yaw:e.yaw||0,pitch:e.pitch||0,roll:e.roll||0,forceGlobalPosition:!0,geoObject:{color:e.color||Ht,scale:1,tag:"line",object3d:Oh},properties:e.properties}),this._size=e.size!=null?e.size:1,this.appendChild(new V({yaw:e.yaw||0,pitch:e.pitch||0,roll:e.roll||0,forceGlobalPosition:!0,geoObject:{color:e.color||Ht,scale:1,tag:"tip",object3d:Nh},properties:e.properties}))}setSize(e){this._size=e;const t=new v(1,(this._size-ko)/.83,1),i=new v(0,this._size*Xi,0);let s=this.childEntities[0];this.setScale3v(t),s.geoObject.setTranslate3v(i)}setColorHTML(e){let t=this.childEntities[0];this.geoObject.setColorHTML(e),t.geoObject.setColorHTML(e)}}class Hh extends V{constructor(e={}){super(e),this._size=e.size!=null?e.size:1,this.childEntities=[],this._init()}_init(){let e=new Xs({color:Ht,yaw:0,pitch:0,roll:90*j,properties:{opName:"move_x",noEdit:!0,style:{color:Ht,selectColor:qs}}}),t=new Xs({color:Wi,yaw:0,pitch:0,roll:0,properties:{opName:"move_y",noEdit:!0,style:{color:Wi,selectColor:Ws}}}),i=new Xs({color:$i,yaw:0,pitch:90*j,roll:0,properties:{opName:"move_z",noEdit:!0,style:{color:$i,selectColor:$s}}});this.appendChild(e),this.appendChild(t),this.appendChild(i),this.setSize(this._size)}setSize(e){this.childEntities[0].setSize(e),this.childEntities[1].setSize(e),this.childEntities[2].setSize(e)}setPitch(e){let t=this.childEntities[0],i=t.childEntities[0];t.setPitch(e),i.setPitch(e),t=this.childEntities[1],i=t.childEntities[0],t.setPitch(e),i.setPitch(e),t=this.childEntities[2],i=t.childEntities[0],t.setPitch(e+90),i.setPitch(e+90)}setYaw(e){let t=this.childEntities[0],i=t.childEntities[0];t.setYaw(e),i.setYaw(e),t=this.childEntities[1],i=t.childEntities[0],t.setYaw(e),i.setYaw(e),t=this.childEntities[2],i=t.childEntities[0],t.setYaw(e),i.setYaw(e)}setRoll(e){let t=this.childEntities[0],i=t.childEntities[0];t.setRoll(e+90),i.setRoll(e+90),t=this.childEntities[1],i=t.childEntities[0],t.setRoll(e),i.setRoll(e)}getY(){return this.childEntities[1].getAbsoluteRotation().mulVec3(v.UP).normalize()}}const Vh=Z.createPlane(1,1,-.5,0,.5);class Uh extends V{constructor(e={}){super(e),this._init()}_init(){let e=new V({independentPicking:!0,scale:.025,forceGlobalPosition:!0,geoObject:{color:Ro,tag:"plane",object3d:Vh},properties:{opName:"move_xz",noEdit:!0,style:{color:Ro,selectColor:"rgba(255,255,255,1.0)"}}});this.appendChild(e)}}const _i=360,Zs=.95,zo=new Array(_i),Do=new Array(_i),Fo=new Array(_i);class Gh extends V{constructor(e={}){super(e),this._init()}_init(){const e=_i;let t=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(r,n)=>new v)],thickness:3.1,color:Ht,isClosed:!0},properties:{opName:"rotate_pitch",noEdit:!0,style:{color:Ht,selectColor:qs}}}),i=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(r,n)=>new v)],thickness:2.5,color:Wi,isClosed:!0},properties:{opName:"rotate_yaw",noEdit:!0,style:{color:Wi,selectColor:Ws}}}),s=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(r,n)=>new v)],thickness:2.5,color:$i,isClosed:!0},properties:{opName:"rotate_roll",noEdit:!0,style:{color:$i,selectColor:$s}}});this.appendChild(t),this.appendChild(i),this.appendChild(s)}setCartesian3v(e,t=0){if(super.setCartesian3v(e),this._entityCollection&&this._entityCollection.renderNode){let i=this._entityCollection.renderNode,s=i.renderer.activeCamera,r=i.getFrameRotation(e).conjugate(),n=.15*s.eye.distance(e),o=O.xRotation(0),l=O.yRotation(t),h=O.zRotation(0).mul(o).mul(l).mul(i.getFrameRotation(e)).conjugate();for(let g=0,f=0,p=1;g<_i;g+=p,f++){let _=g*j,m=Math.cos(_),y=Math.sin(_),x=h.mulVec3(new v(0,y,m)).normalize().scale(n).add(e),w=r.mulVec3(new v(m,0,y)).normalize().scale(n).add(e),b=h.mulVec3(new v(m,y,0)).normalize().scale(n).add(e);zo[f]=x,Do[f]=w,Fo[f]=b}this.childEntities[0].polyline.setPath3v([zo],void 0,!0),this.childEntities[1].polyline.setPath3v([Do],void 0,!0),this.childEntities[2].polyline.setPath3v([Fo],void 0,!0);let c=h.mulVec3(new v(1,0,0)).normalize(),d=r.mulVec3(new v(0,1,0)).normalize(),u=h.mulVec3(new v(0,0,1)).normalize();this.childEntities[0].polyline.setVisibleSphere(e,Math.abs(c.dot(s.getForward()))>Zs?0:n),this.childEntities[1].polyline.setVisibleSphere(e,Math.abs(d.dot(s.getForward()))>Zs?0:n),this.childEntities[2].polyline.setVisibleSphere(e,Math.abs(u.dot(s.getForward()))>Zs?0:n)}}}class jh extends V{constructor(e={}){super({...e,forceGlobalPosition:!0}),this._init()}_init(){let e=[],t=[],i=[],s=_t(qs),r=_t(Ws),n=_t($s);for(let c=0;c<20;c++){let d=1;if(c<5){let u=c/5;d=.5*(1-Math.cos(Math.PI*u))}else if(c>15){let u=(c-15)/5;d=1-.5*(1-Math.cos(Math.PI*u))}t.push([n[0],n[1],n[2],d]),e.push([s[0],s[1],s[2],d]),i.push([r[0],r[1],r[2],d])}let o=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new v)],thickness:2.5,pathColors:[e],isClosed:!1}}),l=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new v)],thickness:2.5,pathColors:[i],isClosed:!1}}),h=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new v)],thickness:2.5,pathColors:[t],isClosed:!1}});this.appendChild(o),this.appendChild(l),this.appendChild(h)}setCartesian3v(e){if(super.setCartesian3v(e),this._entityCollection&&this._entityCollection.renderNode){let t=this._entityCollection.renderNode,i=.05*t.renderer.activeCamera.eye.distance(e);if(t.planet){let s=[],r=[],n=[],o=t.planet.ellipsoid.getSurfaceNormal3v(e),l=this._lonLat,h=10;for(let c=-10;c<h;c++)n.push(new A(l.lon,l.lat+c,l.height)),r.push(new A(l.lon+c,l.lat,l.height)),s.push(e.add(o.scaleTo(c*i)));this.childEntities[0].polyline.setPathLonLatFast([r]),this.childEntities[1].polyline.setPath3vFast([s]),this.childEntities[2].polyline.setPathLonLatFast([n])}else{let s=[],r=[],n=[],o=v.UNIT_Y,l=v.UNIT_X,h=v.UNIT_Z,c=10;for(let d=-10;d<c;d++)r.push(e.add(l.scaleTo(d*i))),n.push(e.add(o.scaleTo(d*i))),s.push(e.add(h.scaleTo(d*i)));this.childEntities[0].polyline.setPath3vFast([r]),this.childEntities[1].polyline.setPath3vFast([n]),this.childEntities[2].polyline.setPath3vFast([s])}}}}function Oo(a,e,t,i,s,r){let n=s.add(v.UP),o=s.add(a),l=new v;if(new U(e,t).hitPlaneRes(Pe.fromPoints(s,n,o),l)===U.INSIDE){let h=v.proj_b_to_a(l,a);if(new U(e,i).hitPlaneRes(Pe.fromPoints(s,n,o),l)===U.INSIDE){let c=v.proj_b_to_a(l,a).sub(h);r.copy(s.add(c))}}}class Yh extends at{constructor(e={}){super(e.name||"GeoObjectEditorScene"),this._onAxisLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onAxisLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.setColorHTML(t.pickingObject.properties.style.color)},this._onAxisLayerLUp=t=>{this._selectedMove=null,this._navActivate(),this._setAxisTrackVisibility(!1)},this._onAxisLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._setAxisTrackVisibility(!0)),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onPlaneLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.geoObject.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onPlaneLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.geoObject.setColorHTML(t.pickingObject.properties.style.color)},this._onPlaneLayerLUp=t=>{this._selectedMove=null,this._navActivate(),this._setAxisTrackVisibility(!1)},this._onPlaneLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._setAxisTrackVisibility(!0)),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onRotateLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.polyline.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onRotateLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.polyline.setColorHTML(t.pickingObject.properties.style.color)},this._onRotateLayerLUp=t=>{this._selectedMove=null,this._navActivate()},this._onRotateLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._selectedEntity&&(this._selectedEntityPitch=this._selectedEntity.getAbsolutePitch(),this._selectedEntityYaw=this._selectedEntity.getAbsoluteYaw(),this._selectedEntityRoll=this._selectedEntity.getAbsoluteRoll())),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onMouseMove=t=>{this._selectedEntity&&this._selectedMove&&this._ops[this._selectedMove]&&this._ops[this._selectedMove](t)},this._onLclick=t=>{t.pickingObject&&t.pickingObject instanceof V&&this.select(t.pickingObject)},this._moveX=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=i.unproject(this._clickPos.x,this._clickPos.y),n=new v;if(this.planet){let o=new U(i.eye,r).hitSphere(new Ve(s.length(),new v)),l=new U(i.eye,t.direction).hitSphere(new Ve(s.length(),new v));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(s),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(s),c=this.ellipsoid.cartesianToLonLat(n);this.ellipsoid.lonLatToCartesianRes(new A(c.lon,h.lat,h.height),n)}}else Oo(v.UNIT_X,i.eye,r,t.direction,s,n);this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveY=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=v.UP;this.planet&&(r=this._axisEntity.getY());let n=s.add(r),o=s.add(i.getRight()),l=new v,h=i.unproject(this._clickPos.x,this._clickPos.y);if(new U(i.eye,h).hitPlaneRes(Pe.fromPoints(s,n,o),l)===U.INSIDE){let c=v.proj_b_to_a(l,r);if(new U(i.eye,t.direction).hitPlaneRes(Pe.fromPoints(s,n,o),l)===U.INSIDE){let d=v.proj_b_to_a(l,r).sub(c),u=this._selectedEntityCart.add(d);this._selectedEntity.setAbsoluteCartesian3v(u),this.events.dispatch(this.events.position,l,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}}},this._moveZ=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=i.unproject(this._clickPos.x,this._clickPos.y),n=new v;if(this.planet){let o=new U(i.eye,r).hitSphere(new Ve(s.length(),new v)),l=new U(i.eye,t.direction).hitSphere(new Ve(s.length(),new v));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(s),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(s),c=this.ellipsoid.cartesianToLonLat(n);this.ellipsoid.lonLatToCartesianRes(new A(h.lon,c.lat,h.height),n)}}else Oo(v.UNIT_Z,i.eye,r,t.direction,s,n);this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveXZ=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=i.unproject(this._clickPos.x,this._clickPos.y),n=new v;if(this.planet){let o=new U(i.eye,r).hitSphere(new Ve(s.length(),new v)),l=new U(i.eye,t.direction).hitSphere(new Ve(s.length(),new v));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(s),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(n),c=this._selectedEntity.getLonLat().height;this.ellipsoid.lonLatToCartesianRes(new A(h.lon,h.lat,c),n)}}else{let o=s.add(v.UNIT_X),l=s.add(v.UNIT_Z),h=new v,c=new v;if(new U(i.eye,r).hitPlaneRes(Pe.fromPoints(s,o,l),h)===U.INSIDE&&new U(i.eye,t.direction).hitPlaneRes(Pe.fromPoints(s,o,l),c)===U.INSIDE){let d=c.sub(h);n=s.add(d)}}this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveXY=t=>{console.log("moveXY")},this._moveZY=t=>{console.log("moveZY")},this._rotatePitch=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=O.xRotation(0),n=O.yRotation(this._selectedEntity.getYaw()),o=O.zRotation(0).mul(r).mul(n).mul(this.getFrameRotation(s)).conjugate().mulVec3(new v(1,0,0)).normalize(),l=i.unproject(this._clickPos.x,this._clickPos.y),h=new Pe(s,o),c=new v,d=new v;if(new U(i.eye,l).hitPlaneRes(h,c)===U.INSIDE&&new U(i.eye,t.direction).hitPlaneRes(h,d)===U.INSIDE){let u=c.sub(s).normalize(),g=d.sub(s).normalize(),f=Math.sign(u.cross(g).dot(o)),p=Math.acos(u.dot(g)),_=this._selectedEntityPitch+f*p;this._selectedEntity.setAbsolutePitch(_),this.events.dispatch(this.events.pitch,_,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._rotateYaw=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart,r=this.getFrameRotation(s).conjugate().mulVec3(new v(0,1,0)).normalize(),n=i.unproject(this._clickPos.x,this._clickPos.y),o=new Pe(s,r),l=new v,h=new v;if(new U(i.eye,n).hitPlaneRes(o,l)===U.INSIDE&&new U(i.eye,t.direction).hitPlaneRes(o,h)===U.INSIDE){let c=l.sub(s).normalize(),d=h.sub(s).normalize(),u=Math.sign(d.cross(c).dot(r)),g=Math.acos(c.dot(d)),f=this._selectedEntityYaw+u*g;this._selectedEntity.setAbsoluteYaw(f),this.events.dispatch(this.events.yaw,f,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._rotateRoll=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,s=this._selectedEntityCart;this.getFrameRotation(s).conjugate();let r=O.xRotation(0),n=O.yRotation(this._selectedEntity.getYaw()),o=O.zRotation(0).mul(r).mul(n).mul(this.getFrameRotation(s)).conjugate().mulVec3(new v(0,0,1)).normalize(),l=i.unproject(this._clickPos.x,this._clickPos.y),h=new Pe(s,o),c=new v,d=new v;if(new U(i.eye,l).hitPlaneRes(h,c)===U.INSIDE&&new U(i.eye,t.direction).hitPlaneRes(h,d)===U.INSIDE){let u=c.sub(s).normalize(),g=d.sub(s).normalize(),f=Math.sign(u.cross(g).dot(o)),p=Math.acos(u.dot(g)),_=this._selectedEntityRoll+f*p;this._selectedEntity.setAbsoluteRoll(_),this.events.dispatch(this.events.roll,_,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._scale=t=>{this.events.dispatch(this.events.scale,1,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._scaleX=t=>{},this._scaleY=t=>{},this._scaleZ=t=>{},this.events=he(qh),this._planet=e.planet||null,this._startPos=null,this._startClick=new N,this._axisEntity=new Hh,this._planeEntity=new Uh,this._rotateEntity=new Gh,this._axisTrackEntity=new jh,this._moveLayer=new ut({scaleByDistance:[.1,mt,.1],useLighting:!1,pickingScale:[5,1.1,5],visibility:!1,depthOrder:1e3}),this._planeLayer=new ut({scaleByDistance:[.1,mt,.1],useLighting:!1,visibility:!1,depthOrder:1e3}),this._rotateLayer=new ut({useLighting:!1,visibility:!1,depthOrder:1e3,pickingScale:5}),this._selectedEntity=null,this._clickPos=new N,this._selectedEntityCart=new v,this._selectedEntityPitch=0,this._selectedEntityYaw=0,this._selectedEntityRoll=0,this._selectedMove=null,this._axisTrackVisibility=!1,this._axisTrackLayer=new ut({useLighting:!1,visibility:!1,pickingScale:5,pickingEnabled:!1,opacity:.6}),this._ops={move_x:this._moveX,move_y:this._moveY,move_z:this._moveZ,move_xz:this._moveXZ,move_xy:this._moveXY,move_zy:this._moveZY,rotate_pitch:this._rotatePitch,rotate_yaw:this._rotateYaw,rotate_roll:this._rotateRoll,scale:this._scale,scale_x:this._scaleX,scale_y:this._scaleY,scale_z:this._scaleZ}}get ellipsoid(){if(this._planet)return this._planet.ellipsoid}get planet(){return this._planet}bindPlanet(e){this._planet=e}init(){this.activate()}onremove(){this.deactivate()}_addAxisLayers(){this._moveLayer.addTo(this),this._planeLayer.addTo(this),this._rotateLayer.addTo(this),this._axisTrackLayer.addTo(this),this._moveLayer.add(this._axisEntity),this._moveLayer.events.on("mouseenter",this._onAxisLayerMouseEnter),this._moveLayer.events.on("mouseleave",this._onAxisLayerMouseLeave),this._moveLayer.events.on("lup",this._onAxisLayerLUp),this._moveLayer.events.on("ldown",this._onAxisLayerLDown),this._planeLayer.add(this._planeEntity),this._planeLayer.events.on("mouseenter",this._onPlaneLayerMouseEnter),this._planeLayer.events.on("mouseleave",this._onPlaneLayerMouseLeave),this._planeLayer.events.on("lup",this._onPlaneLayerLUp),this._planeLayer.events.on("ldown",this._onPlaneLayerLDown),this._rotateLayer.add(this._rotateEntity),this._rotateLayer.events.on("mouseenter",this._onRotateLayerMouseEnter),this._rotateLayer.events.on("mouseleave",this._onRotateLayerMouseLeave),this._rotateLayer.events.on("lup",this._onRotateLayerLUp),this._rotateLayer.events.on("ldown",this._onRotateLayerLDown),this._axisTrackLayer.add(this._axisTrackEntity)}_navActivate(){this.renderer&&(this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.activate(),this.renderer.controls.SimpleNavigation&&this.renderer.controls.SimpleNavigation.activate())}_navDeactivate(){this.renderer&&(this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.deactivate(),this.renderer.controls.SimpleNavigation&&this.renderer.controls.SimpleNavigation.deactivate())}_removeAxisLayers(){this._moveLayer.remove(),this._planeLayer.remove(),this._rotateLayer.remove()}activate(){this.renderer.events.on("lclick",this._onLclick),this.renderer.events.on("mousemove",this._onMouseMove),this._addAxisLayers()}deactivate(){this.renderer.events.off("lclick",this._onLclick),this.renderer.events.off("mousemove",this._onMouseMove),this._removeAxisLayers(),this.clear()}_setAxisTrackVisibility(e){e!==this._axisTrackVisibility&&(this._axisTrackVisibility=e,this._axisTrackLayer.setVisibility(e))}setVisibility(e){this._moveLayer.setVisibility(e),this._planeLayer.setVisibility(e),this._rotateLayer.setVisibility(e),this.unlockView()}readyToEdit(e){return!e.properties||!e.properties.noEdit}select(e){(!this._selectedEntity||this._selectedEntity&&!e.isEqual(this._selectedEntity))&&this.readyToEdit(e)&&(this._selectedEntity&&this.unselect(),this._selectedEntity=e,this.renderer&&this.renderer.setRelativeCenter(),this.setVisibility(!0),this.events.dispatch(this.events.select,this._selectedEntity))}unselect(){this.setVisibility(!1);let e=this._selectedEntity;this._selectedEntity=null,this.events.dispatch(this.events.unselect,e)}clear(){this.removeEntityCollection(this._moveLayer),this.removeEntityCollection(this._planeLayer),this.removeEntityCollection(this._rotateLayer)}frame(){if(this._selectedEntity){let e=this._selectedEntity.getAbsoluteCartesian();this._axisEntity.setCartesian3v(e),this._planeEntity.setCartesian3v(e),this._rotateEntity.setCartesian3v(e,this._selectedEntity.getAbsoluteYaw()),this._axisTrackEntity.setCartesian3v(e)}}getFrameRotation(e){return this._planet?this._planet.getFrameRotation(e):super.getFrameRotation(e)}getSelectedEntity(){return this._selectedEntity}lockView(){this.renderer&&this._selectedEntity&&this.renderer.controls.CameraLock.lockView(this._selectedEntity)}unlockView(){if(this.renderer&&this._selectedEntity){let e=this.renderer.controls.CameraLock;e&&e.unlockView()}}}const qh=["mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter","select","unselect","change","position","pitch","yaw","roll","scale"],Wh=["change"];class we extends be{constructor(e={}){super({template:He(`<div class="og-input">
336
+ </div>`}),this.$groundValue=null,this.$trackValue=null,this.$warningValue=null,this.$collisionValue=null,this.$trackUnits=null,this.$groundUnits=null,this.$warningUnits=null,this.$collisionUnits=null}render(e){return super.render(e),this.$trackValue=this.select(".og-elevationprofile-legend__track .og-elevationprofile-value"),this.$groundValue=this.select(".og-elevationprofile-legend__ground .og-elevationprofile-value"),this.$warningValue=this.select(".og-elevationprofile-legend__warning .og-elevationprofile-value"),this.$collisionValue=this.select(".og-elevationprofile-legend__collision .og-elevationprofile-value"),this.$trackUnits=this.select(".og-elevationprofile-legend__track .og-elevationprofile-units"),this.$groundUnits=this.select(".og-elevationprofile-legend__ground .og-elevationprofile-units"),this.$warningUnits=this.select(".og-elevationprofile-legend__warning .og-elevationprofile-units"),this.$collisionUnits=this.select(".og-elevationprofile-legend__collision .og-elevationprofile-units"),this}clear(){this.$trackValue&&(this.$trackValue.innerText="0"),this.$trackUnits&&(this.$trackUnits.innerText="m"),this.$groundValue&&(this.$groundValue.innerText="0"),this.$groundUnits&&(this.$groundUnits.innerText="m"),this.$warningValue&&(this.$warningValue.innerText="0"),this.$warningUnits&&(this.$warningUnits.innerText="m"),this.$collisionValue&&(this.$collisionValue.innerText="0"),this.$collisionUnits&&(this.$collisionUnits.innerText="m")}setTrackLength(e){let t=zt(e);this.$trackValue.innerText=t[0],this.$trackUnits.innerText=t[1]}setGroundLength(e){let t=zt(e);this.$groundValue.innerText=t[0],this.$groundUnits.innerText=t[1]}setWarningLength(e){let t=zt(e);this.$warningValue.innerText=t[0],this.$warningUnits.innerText=t[1]}setCollisionLength(e){let t=zt(e);this.$collisionValue.innerText=t[0],this.$collisionUnits.innerText=t[1]}}const Nt="rgb(253,77,77)",Wr="rgb(248,115,115)",Wi="rgb(73,73,239)",$r="rgb(90,90,253)",$i="rgb(26,122,26)",Xr="rgb(55,191,55)",Ra="rgba(255,255,255,0.8)",Xi=.1,Ba=new m(Xi,Xi,Xi),ka=.17,Ia=.0095,Oh=Z.createCylinder(Ia,Ia,.83).scale(Ba),Nh=Z.createCylinder(0,.04,ka,16,16,!1,!0,0,-.17).scale(Ba);class Zr extends V{constructor(e={}){super({independentPicking:!0,yaw:e.yaw||0,pitch:e.pitch||0,roll:e.roll||0,forceGlobalPosition:!0,geoObject:{color:e.color||Nt,scale:1,tag:"line",object3d:Oh},properties:e.properties}),this._size=e.size!=null?e.size:1,this.appendChild(new V({yaw:e.yaw||0,pitch:e.pitch||0,roll:e.roll||0,forceGlobalPosition:!0,geoObject:{color:e.color||Nt,scale:1,tag:"tip",object3d:Nh},properties:e.properties}))}setSize(e){this._size=e;const t=new m(1,(this._size-ka)/.83,1),i=new m(0,this._size*Xi,0);let r=this.childEntities[0];this.setScale3v(t),r.geoObject.setTranslate3v(i)}setColorHTML(e){let t=this.childEntities[0];this.geoObject.setColorHTML(e),t.geoObject.setColorHTML(e)}}class Hh extends V{constructor(e={}){super(e),this._size=e.size!=null?e.size:1,this.childEntities=[],this._init()}_init(){let e=new Zr({color:Nt,yaw:0,pitch:0,roll:90*U,properties:{opName:"move_x",noEdit:!0,style:{color:Nt,selectColor:Wr}}}),t=new Zr({color:Wi,yaw:0,pitch:0,roll:0,properties:{opName:"move_y",noEdit:!0,style:{color:Wi,selectColor:$r}}}),i=new Zr({color:$i,yaw:0,pitch:90*U,roll:0,properties:{opName:"move_z",noEdit:!0,style:{color:$i,selectColor:Xr}}});this.appendChild(e),this.appendChild(t),this.appendChild(i),this.setSize(this._size)}setSize(e){this.childEntities[0].setSize(e),this.childEntities[1].setSize(e),this.childEntities[2].setSize(e)}setPitch(e){let t=this.childEntities[0],i=t.childEntities[0];t.setPitch(e),i.setPitch(e),t=this.childEntities[1],i=t.childEntities[0],t.setPitch(e),i.setPitch(e),t=this.childEntities[2],i=t.childEntities[0],t.setPitch(e+90),i.setPitch(e+90)}setYaw(e){let t=this.childEntities[0],i=t.childEntities[0];t.setYaw(e),i.setYaw(e),t=this.childEntities[1],i=t.childEntities[0],t.setYaw(e),i.setYaw(e),t=this.childEntities[2],i=t.childEntities[0],t.setYaw(e),i.setYaw(e)}setRoll(e){let t=this.childEntities[0],i=t.childEntities[0];t.setRoll(e+90),i.setRoll(e+90),t=this.childEntities[1],i=t.childEntities[0],t.setRoll(e),i.setRoll(e)}getY(){return this.childEntities[1].getAbsoluteRotation().mulVec3(m.UP).normalize()}}const Vh=Z.createPlane(1,1,-.5,0,.5);class Uh extends V{constructor(e={}){super(e),this._init()}_init(){let e=new V({independentPicking:!0,scale:.025,forceGlobalPosition:!0,geoObject:{color:Ra,tag:"plane",object3d:Vh},properties:{opName:"move_xz",noEdit:!0,style:{color:Ra,selectColor:"rgba(255,255,255,1.0)"}}});this.appendChild(e)}}const ui=360,Qr=.95,za=new Array(ui),Da=new Array(ui),Fa=new Array(ui);class Gh extends V{constructor(e={}){super(e),this._init()}_init(){const e=ui;let t=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(s,n)=>new m)],thickness:3.1,color:Nt,isClosed:!0},properties:{opName:"rotate_pitch",noEdit:!0,style:{color:Nt,selectColor:Wr}}}),i=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(s,n)=>new m)],thickness:2.5,color:Wi,isClosed:!0},properties:{opName:"rotate_yaw",noEdit:!0,style:{color:Wi,selectColor:$r}}}),r=new V({independentPicking:!0,polyline:{path3v:[Array.from({length:e},(s,n)=>new m)],thickness:2.5,color:$i,isClosed:!0},properties:{opName:"rotate_roll",noEdit:!0,style:{color:$i,selectColor:Xr}}});this.appendChild(t),this.appendChild(i),this.appendChild(r)}setCartesian3v(e,t=0){if(super.setCartesian3v(e),this._entityCollection&&this._entityCollection.renderNode){let i=this._entityCollection.renderNode,r=i.renderer.activeCamera,s=i.getFrameRotation(e).conjugate(),n=.15*r.eye.distance(e),o=O.xRotation(0),l=O.yRotation(t),h=O.zRotation(0).mul(o).mul(l).mul(i.getFrameRotation(e)).conjugate();for(let g=0,f=0,p=1;g<ui;g+=p,f++){let _=g*U,v=Math.cos(_),x=Math.sin(_),y=h.mulVec3(new m(0,x,v)).normalize().scale(n).add(e),w=s.mulVec3(new m(v,0,x)).normalize().scale(n).add(e),b=h.mulVec3(new m(v,x,0)).normalize().scale(n).add(e);za[f]=y,Da[f]=w,Fa[f]=b}this.childEntities[0].polyline.setPath3v([za],void 0,!0),this.childEntities[1].polyline.setPath3v([Da],void 0,!0),this.childEntities[2].polyline.setPath3v([Fa],void 0,!0);let c=h.mulVec3(new m(1,0,0)).normalize(),d=s.mulVec3(new m(0,1,0)).normalize(),u=h.mulVec3(new m(0,0,1)).normalize();this.childEntities[0].polyline.setVisibleSphere(e,Math.abs(c.dot(r.getForward()))>Qr?0:n),this.childEntities[1].polyline.setVisibleSphere(e,Math.abs(d.dot(r.getForward()))>Qr?0:n),this.childEntities[2].polyline.setVisibleSphere(e,Math.abs(u.dot(r.getForward()))>Qr?0:n)}}}class jh extends V{constructor(e={}){super({...e,forceGlobalPosition:!0}),this._init()}_init(){let e=[],t=[],i=[],r=_t(Wr),s=_t($r),n=_t(Xr);for(let c=0;c<20;c++){let d=1;if(c<5){let u=c/5;d=.5*(1-Math.cos(Math.PI*u))}else if(c>15){let u=(c-15)/5;d=1-.5*(1-Math.cos(Math.PI*u))}t.push([n[0],n[1],n[2],d]),e.push([r[0],r[1],r[2],d]),i.push([s[0],s[1],s[2],d])}let o=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new m)],thickness:2.5,pathColors:[e],isClosed:!1}}),l=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new m)],thickness:2.5,pathColors:[i],isClosed:!1}}),h=new V({polyline:{path3v:[Array.from({length:20},(c,d)=>new m)],thickness:2.5,pathColors:[t],isClosed:!1}});this.appendChild(o),this.appendChild(l),this.appendChild(h)}setCartesian3v(e){if(super.setCartesian3v(e),this._entityCollection&&this._entityCollection.renderNode){let t=this._entityCollection.renderNode,i=.05*t.renderer.activeCamera.eye.distance(e);if(t.planet){let r=[],s=[],n=[],o=t.planet.ellipsoid.getSurfaceNormal3v(e),l=this._lonLat,h=10;for(let c=-10;c<h;c++)n.push(new A(l.lon,l.lat+c,l.height)),s.push(new A(l.lon+c,l.lat,l.height)),r.push(e.add(o.scaleTo(c*i)));this.childEntities[0].polyline.setPathLonLatFast([s]),this.childEntities[1].polyline.setPath3vFast([r]),this.childEntities[2].polyline.setPathLonLatFast([n])}else{let r=[],s=[],n=[],o=m.UNIT_Y,l=m.UNIT_X,h=m.UNIT_Z,c=10;for(let d=-10;d<c;d++)s.push(e.add(l.scaleTo(d*i))),n.push(e.add(o.scaleTo(d*i))),r.push(e.add(h.scaleTo(d*i)));this.childEntities[0].polyline.setPath3vFast([s]),this.childEntities[1].polyline.setPath3vFast([n]),this.childEntities[2].polyline.setPath3vFast([r])}}}}function Oa(a,e,t,i,r,s){let n=r.add(m.UP),o=r.add(a),l=new m;if(new H(e,t).hitPlaneRes(we.fromPoints(r,n,o),l)===H.INSIDE){let h=m.proj_b_to_a(l,a);if(new H(e,i).hitPlaneRes(we.fromPoints(r,n,o),l)===H.INSIDE){let c=m.proj_b_to_a(l,a).sub(h);s.copy(r.add(c))}}}class qh extends ot{constructor(e={}){super(e.name||"GeoObjectEditorScene"),this._onAxisLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onAxisLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.setColorHTML(t.pickingObject.properties.style.color)},this._onAxisLayerLUp=t=>{this._selectedMove=null,this._navActivate(),this._setAxisTrackVisibility(!1)},this._onAxisLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._setAxisTrackVisibility(!0)),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onPlaneLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.geoObject.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onPlaneLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.geoObject.setColorHTML(t.pickingObject.properties.style.color)},this._onPlaneLayerLUp=t=>{this._selectedMove=null,this._navActivate(),this._setAxisTrackVisibility(!1)},this._onPlaneLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._setAxisTrackVisibility(!0)),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onRotateLayerMouseEnter=t=>{this.renderer.handler.canvas.style.cursor="pointer",t.pickingObject.polyline.setColorHTML(t.pickingObject.properties.style.selectColor)},this._onRotateLayerMouseLeave=t=>{this.renderer.handler.canvas.style.cursor="default",t.pickingObject.polyline.setColorHTML(t.pickingObject.properties.style.color)},this._onRotateLayerLUp=t=>{this._selectedMove=null,this._navActivate()},this._onRotateLayerLDown=t=>{this._clickPos=t.pos.clone(),this._selectedEntity&&(this._selectedEntityCart=this._selectedEntity.getAbsoluteCartesian(),this._selectedEntity&&(this._selectedEntityPitch=this._selectedEntity.getAbsolutePitch(),this._selectedEntityYaw=this._selectedEntity.getAbsoluteYaw(),this._selectedEntityRoll=this._selectedEntity.getAbsoluteRoll())),this._selectedMove=t.pickingObject.properties.opName,this._navDeactivate()},this._onMouseMove=t=>{this._selectedEntity&&this._selectedMove&&this._ops[this._selectedMove]&&this._ops[this._selectedMove](t)},this._onLclick=t=>{t.pickingObject&&t.pickingObject instanceof V&&this.select(t.pickingObject)},this._moveX=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=i.unproject(this._clickPos.x,this._clickPos.y),n=new m;if(this.planet){let o=new H(i.eye,s).hitSphere(new He(r.length(),new m)),l=new H(i.eye,t.direction).hitSphere(new He(r.length(),new m));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(r),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(r),c=this.ellipsoid.cartesianToLonLat(n);this.ellipsoid.lonLatToCartesianRes(new A(c.lon,h.lat,h.height),n)}}else Oa(m.UNIT_X,i.eye,s,t.direction,r,n);this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveY=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=m.UP;this.planet&&(s=this._axisEntity.getY());let n=r.add(s),o=r.add(i.getRight()),l=new m,h=i.unproject(this._clickPos.x,this._clickPos.y);if(new H(i.eye,h).hitPlaneRes(we.fromPoints(r,n,o),l)===H.INSIDE){let c=m.proj_b_to_a(l,s);if(new H(i.eye,t.direction).hitPlaneRes(we.fromPoints(r,n,o),l)===H.INSIDE){let d=m.proj_b_to_a(l,s).sub(c),u=this._selectedEntityCart.add(d);this._selectedEntity.setAbsoluteCartesian3v(u),this.events.dispatch(this.events.position,l,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}}},this._moveZ=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=i.unproject(this._clickPos.x,this._clickPos.y),n=new m;if(this.planet){let o=new H(i.eye,s).hitSphere(new He(r.length(),new m)),l=new H(i.eye,t.direction).hitSphere(new He(r.length(),new m));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(r),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(r),c=this.ellipsoid.cartesianToLonLat(n);this.ellipsoid.lonLatToCartesianRes(new A(h.lon,c.lat,h.height),n)}}else Oa(m.UNIT_Z,i.eye,s,t.direction,r,n);this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveXZ=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=i.unproject(this._clickPos.x,this._clickPos.y),n=new m;if(this.planet){let o=new H(i.eye,s).hitSphere(new He(r.length(),new m)),l=new H(i.eye,t.direction).hitSphere(new He(r.length(),new m));if(!l)return;if(n=O.getRotationBetweenVectors(o.normal(),l.normal()).mulVec3(r),this.ellipsoid){let h=this.ellipsoid.cartesianToLonLat(n),c=this._selectedEntity.getLonLat().height;this.ellipsoid.lonLatToCartesianRes(new A(h.lon,h.lat,c),n)}}else{let o=r.add(m.UNIT_X),l=r.add(m.UNIT_Z),h=new m,c=new m;if(new H(i.eye,s).hitPlaneRes(we.fromPoints(r,o,l),h)===H.INSIDE&&new H(i.eye,t.direction).hitPlaneRes(we.fromPoints(r,o,l),c)===H.INSIDE){let d=c.sub(h);n=r.add(d)}}this._selectedEntity.setAbsoluteCartesian3v(n),this.events.dispatch(this.events.position,n,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._moveXY=t=>{console.log("moveXY")},this._moveZY=t=>{console.log("moveZY")},this._rotatePitch=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=O.xRotation(0),n=O.yRotation(this._selectedEntity.getYaw()),o=O.zRotation(0).mul(s).mul(n).mul(this.getFrameRotation(r)).conjugate().mulVec3(new m(1,0,0)).normalize(),l=i.unproject(this._clickPos.x,this._clickPos.y),h=new we(r,o),c=new m,d=new m;if(new H(i.eye,l).hitPlaneRes(h,c)===H.INSIDE&&new H(i.eye,t.direction).hitPlaneRes(h,d)===H.INSIDE){let u=c.sub(r).normalize(),g=d.sub(r).normalize(),f=Math.sign(u.cross(g).dot(o)),p=Math.acos(u.dot(g)),_=this._selectedEntityPitch+f*p;this._selectedEntity.setAbsolutePitch(_),this.events.dispatch(this.events.pitch,_,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._rotateYaw=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart,s=this.getFrameRotation(r).conjugate().mulVec3(new m(0,1,0)).normalize(),n=i.unproject(this._clickPos.x,this._clickPos.y),o=new we(r,s),l=new m,h=new m;if(new H(i.eye,n).hitPlaneRes(o,l)===H.INSIDE&&new H(i.eye,t.direction).hitPlaneRes(o,h)===H.INSIDE){let c=l.sub(r).normalize(),d=h.sub(r).normalize(),u=Math.sign(d.cross(c).dot(s)),g=Math.acos(c.dot(d)),f=this._selectedEntityYaw+u*g;this._selectedEntity.setAbsoluteYaw(f),this.events.dispatch(this.events.yaw,f,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._rotateRoll=t=>{if(!this._selectedEntity)return;let i=this.renderer.activeCamera,r=this._selectedEntityCart;this.getFrameRotation(r).conjugate();let s=O.xRotation(0),n=O.yRotation(this._selectedEntity.getYaw()),o=O.zRotation(0).mul(s).mul(n).mul(this.getFrameRotation(r)).conjugate().mulVec3(new m(0,0,1)).normalize(),l=i.unproject(this._clickPos.x,this._clickPos.y),h=new we(r,o),c=new m,d=new m;if(new H(i.eye,l).hitPlaneRes(h,c)===H.INSIDE&&new H(i.eye,t.direction).hitPlaneRes(h,d)===H.INSIDE){let u=c.sub(r).normalize(),g=d.sub(r).normalize(),f=Math.sign(u.cross(g).dot(o)),p=Math.acos(u.dot(g)),_=this._selectedEntityRoll+f*p;this._selectedEntity.setAbsoluteRoll(_),this.events.dispatch(this.events.roll,_,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)}},this._scale=t=>{this.events.dispatch(this.events.scale,1,this._selectedEntity),this.events.dispatch(this.events.change,this._selectedEntity)},this._scaleX=t=>{},this._scaleY=t=>{},this._scaleZ=t=>{},this.events=le(Yh),this._planet=e.planet||null,this._startPos=null,this._startClick=new N,this._axisEntity=new Hh,this._planeEntity=new Uh,this._rotateEntity=new Gh,this._axisTrackEntity=new jh,this._moveLayer=new ut({scaleByDistance:[.1,mt,.1],useLighting:!1,pickingScale:[5,1.1,5],visibility:!1,depthOrder:1e3}),this._planeLayer=new ut({scaleByDistance:[.1,mt,.1],useLighting:!1,visibility:!1,depthOrder:1e3}),this._rotateLayer=new ut({useLighting:!1,visibility:!1,depthOrder:1e3,pickingScale:5}),this._selectedEntity=null,this._clickPos=new N,this._selectedEntityCart=new m,this._selectedEntityPitch=0,this._selectedEntityYaw=0,this._selectedEntityRoll=0,this._selectedMove=null,this._axisTrackVisibility=!1,this._axisTrackLayer=new ut({useLighting:!1,visibility:!1,pickingScale:5,pickingEnabled:!1,opacity:.6}),this._ops={move_x:this._moveX,move_y:this._moveY,move_z:this._moveZ,move_xz:this._moveXZ,move_xy:this._moveXY,move_zy:this._moveZY,rotate_pitch:this._rotatePitch,rotate_yaw:this._rotateYaw,rotate_roll:this._rotateRoll,scale:this._scale,scale_x:this._scaleX,scale_y:this._scaleY,scale_z:this._scaleZ}}get ellipsoid(){if(this._planet)return this._planet.ellipsoid}get planet(){return this._planet}bindPlanet(e){this._planet=e}init(){this.activate()}onremove(){this.deactivate()}_addAxisLayers(){this._moveLayer.addTo(this),this._planeLayer.addTo(this),this._rotateLayer.addTo(this),this._axisTrackLayer.addTo(this),this._moveLayer.add(this._axisEntity),this._moveLayer.events.on("mouseenter",this._onAxisLayerMouseEnter),this._moveLayer.events.on("mouseleave",this._onAxisLayerMouseLeave),this._moveLayer.events.on("lup",this._onAxisLayerLUp),this._moveLayer.events.on("ldown",this._onAxisLayerLDown),this._planeLayer.add(this._planeEntity),this._planeLayer.events.on("mouseenter",this._onPlaneLayerMouseEnter),this._planeLayer.events.on("mouseleave",this._onPlaneLayerMouseLeave),this._planeLayer.events.on("lup",this._onPlaneLayerLUp),this._planeLayer.events.on("ldown",this._onPlaneLayerLDown),this._rotateLayer.add(this._rotateEntity),this._rotateLayer.events.on("mouseenter",this._onRotateLayerMouseEnter),this._rotateLayer.events.on("mouseleave",this._onRotateLayerMouseLeave),this._rotateLayer.events.on("lup",this._onRotateLayerLUp),this._rotateLayer.events.on("ldown",this._onRotateLayerLDown),this._axisTrackLayer.add(this._axisTrackEntity)}_navActivate(){this.renderer&&(this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.activate(),this.renderer.controls.SimpleNavigation&&this.renderer.controls.SimpleNavigation.activate())}_navDeactivate(){this.renderer&&(this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.deactivate(),this.renderer.controls.SimpleNavigation&&this.renderer.controls.SimpleNavigation.deactivate())}_removeAxisLayers(){this._moveLayer.remove(),this._planeLayer.remove(),this._rotateLayer.remove()}activate(){this.renderer.events.on("lclick",this._onLclick),this.renderer.events.on("mousemove",this._onMouseMove),this._addAxisLayers()}deactivate(){this.renderer.events.off("lclick",this._onLclick),this.renderer.events.off("mousemove",this._onMouseMove),this._removeAxisLayers(),this.clear()}_setAxisTrackVisibility(e){e!==this._axisTrackVisibility&&(this._axisTrackVisibility=e,this._axisTrackLayer.setVisibility(e))}setVisibility(e){this._moveLayer.setVisibility(e),this._planeLayer.setVisibility(e),this._rotateLayer.setVisibility(e),this.unlockView()}readyToEdit(e){return!e.properties||!e.properties.noEdit}select(e){(!this._selectedEntity||this._selectedEntity&&!e.isEqual(this._selectedEntity))&&this.readyToEdit(e)&&(this._selectedEntity&&this.unselect(),this._selectedEntity=e,this.renderer&&this.renderer.setRelativeCenter(),this.setVisibility(!0),this.events.dispatch(this.events.select,this._selectedEntity))}unselect(){this.setVisibility(!1);let e=this._selectedEntity;this._selectedEntity=null,this.events.dispatch(this.events.unselect,e)}clear(){this.removeEntityCollection(this._moveLayer),this.removeEntityCollection(this._planeLayer),this.removeEntityCollection(this._rotateLayer)}frame(){if(this._selectedEntity){let e=this._selectedEntity.getAbsoluteCartesian();this._axisEntity.setCartesian3v(e),this._planeEntity.setCartesian3v(e),this._rotateEntity.setCartesian3v(e,this._selectedEntity.getAbsoluteYaw()),this._axisTrackEntity.setCartesian3v(e)}}getFrameRotation(e){return this._planet?this._planet.getFrameRotation(e):super.getFrameRotation(e)}getSelectedEntity(){return this._selectedEntity}lockView(){this.renderer&&this._selectedEntity&&this.renderer.controls.CameraLock.lockView(this._selectedEntity)}unlockView(){if(this.renderer&&this._selectedEntity){let e=this.renderer.controls.CameraLock;e&&e.unlockView()}}}const Yh=["mousemove","mouseenter","mouseleave","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchmove","touchstart","touchend","doubletouch","touchleave","touchenter","select","unselect","change","position","pitch","yaw","roll","scale"],Wh=["change"];class Ce extends be{constructor(e={}){super({template:Ne(`<div class="og-input">
337
337
  <div class="og-input-label">{label}</div>
338
338
  <input type="{type}"/>
339
- </div>`,{label:e.label||"",type:e.type||"text"})}),this._onResize=()=>{},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation()},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onInput=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this._setValue(t.target.value)},this.events=this.events.registerNames(Wh),this._value=e.value||"",this._maxFixed=e.maxFixed!=null?e.maxFixed:-1,this.$label=null,this.$input=null}render(e){return super.render(e),this.$label=this.select(".og-input-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this._initEvents(),this}set value(e){e!==this._value&&(this._value=typeof e=="number"?xs(e,this._maxFixed):e,this.$input&&(this.$input.value=this._value),this.events.dispatch(this.events.change,this._value,this))}_setValue(e){e!==this._value&&(this._value=typeof e=="number"?xs(e,this._maxFixed):e,this.events.dispatch(this.events.change,this._value,this))}get value(){return this._value}_initEvents(){this.el.addEventListener("mousewheel",this._onMouseWheel),this.el.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.el.removeEventListener("mousewheel",this._onMouseWheel),this.el.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("input",this._onInput)}remove(){this._clearEvents(),super.remove()}set visibility(e){this.el&&(this.el.style.display=e?"":"none")}}const $h=["change"];class Xh extends be{constructor(e={}){super({template:He(`<div class="og-checkbox">
339
+ </div>`,{label:e.label||"",type:e.type||"text"})}),this._onResize=()=>{},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation()},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onInput=t=>{(t=t||window.event).preventDefault(),t.stopPropagation(),this._setValue(t.target.value)},this.events=this.events.registerNames(Wh),this._value=e.value||"",this._maxFixed=e.maxFixed!=null?e.maxFixed:-1,this.$label=null,this.$input=null}render(e){return super.render(e),this.$label=this.select(".og-input-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this._initEvents(),this}set value(e){e!==this._value&&(this._value=typeof e=="number"?br(e,this._maxFixed):e,this.$input&&(this.$input.value=this._value),this.events.dispatch(this.events.change,this._value,this))}_setValue(e){e!==this._value&&(this._value=typeof e=="number"?br(e,this._maxFixed):e,this.events.dispatch(this.events.change,this._value,this))}get value(){return this._value}_initEvents(){this.el.addEventListener("mousewheel",this._onMouseWheel),this.el.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("input",this._onInput)}_clearEvents(){this.el.removeEventListener("mousewheel",this._onMouseWheel),this.el.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("input",this._onInput)}remove(){this._clearEvents(),super.remove()}set visibility(e){this.el&&(this.el.style.display=e?"":"none")}}const $h=["change"];class Xh extends be{constructor(e={}){super({template:Ne(`<div class="og-checkbox">
340
340
  <div class="og-input-label">{label}</div>
341
341
  <div class="og-checkbox-input">
342
342
  <input type="checkbox" {checked}/>
343
343
  </div>
344
- </div>`,{label:e.label||"",checked:e.checked?"checked":""})}),this._onResize=()=>{},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation()},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onClick=t=>{(t=t||window.event).stopPropagation(),this.checked=!this._checked},this._checked=e.checked||!1,this._disabled=e.disabled||!1,this.events=this.events.registerNames($h),this.$label=null,this.$input=null}set disabled(e){this._disabled=e,this._updateDisabled()}_updateDisabled(){this.el&&(this._disabled?this.el.classList.add("og-input-disabled"):this.el.classList.remove("og-input-disabled"))}get disabled(){return this._disabled}render(e){return super.render(e),this.$label=this.select(".og-input-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this.$input.checked=this._checked,this._updateDisabled(),this._initEvents(),this}set checked(e){e!==this._checked&&(this._checked=e,this.$input&&(this.$input.checked=this._checked),this.events.dispatch(this.events.change,this._checked,this))}get checked(){return this._checked}_initEvents(){this.el.addEventListener("mousewheel",this._onMouseWheel),this.el.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("click",this._onClick)}_clearEvents(){this.el.removeEventListener("mousewheel",this._onMouseWheel),this.el.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("click",this._onClick)}remove(){this._clearEvents(),super.remove()}set visibility(e){this.el&&(this.el.style.display=e?"":"none")}}class Zh extends ot{constructor(e){super({title:"GeoObject Properties",visible:!1,resizable:!0,useHide:!0,top:25,right:85,width:252,height:480,minHeight:100,minWidth:100,model:e.model}),this._onVisibility=t=>{this.model.setVisibility(t)},this._onSelect=t=>{this.show(),this._refresh(t)},this._onUnselect=t=>{this.hide()},this._onChangeRelativePosition=t=>{let i=this.model.getSelectedEntity();i&&(i.relativePosition=t,this._refresh(i))},this._onPosition=(t,i)=>{this._refresh(i)},this._onPitch=(t,i)=>{this._pitchView.stopPropagation(),this._pitchView.value=i.getPitch()*J,this._absolutePitchView.stopPropagation(),this._absolutePitchView.value=i.getAbsolutePitch()*J},this._onYaw=(t,i)=>{this._yawView.stopPropagation(),this._yawView.value=i.getYaw()*J,this._absoluteYawView.stopPropagation(),this._absoluteYawView.value=i.getAbsoluteYaw()*J},this._onRoll=(t,i)=>{this._rollView.stopPropagation(),this._rollView.value=i.getRoll()*J,this._absoluteRollView.stopPropagation(),this._absoluteRollView.value=i.getAbsoluteRoll()*J},this._onChangeLon=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getLonLat();i.setLonLat2(parseFloat(t),s.lat,s.height),this._refresh(i)}},this._onChangeLat=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getLonLat();i.setLonLat2(s.lon,parseFloat(t),s.height),this._refresh(i)}},this._onChangeHeight=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getLonLat();i.setLonLat2(s.lon,s.lat,parseFloat(t)),this._refresh(i)}},this._onChangeX=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getCartesian();i.setCartesian(parseFloat(t),s.y,s.z),this._refresh(i)}},this._onChangeY=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getCartesian();i.setCartesian(s.x,parseFloat(t),s.z),this._refresh(i)}},this._onChangeZ=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getCartesian();i.setCartesian(s.x,s.y,parseFloat(t)),this._refresh(i)}},this._onChangeAbsoluteX=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getAbsoluteCartesian();i.setAbsoluteCartesian(parseFloat(t),s.y,s.z),this._refresh(i)}},this._onChangeAbsoluteY=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getAbsoluteCartesian();i.setAbsoluteCartesian(s.x,parseFloat(t),s.z),this._refresh(i)}},this._onChangeAbsoluteZ=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getAbsoluteCartesian();i.setAbsoluteCartesian(s.x,s.y,parseFloat(t)),this._refresh(i)}},this._onChangePitch=t=>{let i=this.model.getSelectedEntity();i&&(i.setPitch(parseFloat(t)*j),this._refresh(i))},this._onChangeYaw=t=>{let i=this.model.getSelectedEntity();i&&(i.setYaw(parseFloat(t)*j),this._refresh(i))},this._onChangeRoll=t=>{let i=this.model.getSelectedEntity();i&&(i.setRoll(parseFloat(t)*j),this._refresh(i))},this._onChangeAbsolutePitch=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsolutePitch(parseFloat(t)*j),this._refresh(i))},this._onChangeAbsoluteYaw=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsoluteYaw(parseFloat(t)*j),this._refresh(i))},this._onChangeAbsoluteRoll=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsoluteRoll(parseFloat(t)*j),this._refresh(i))},this._onChangeScale=t=>{let i=this.model.getSelectedEntity();if(i){let s=parseFloat(t);i.setScale(s),this._scaleXView.stopPropagation(),this._scaleYView.stopPropagation(),this._scaleZView.stopPropagation(),this._scaleXView.value=s,this._scaleYView.value=s,this._scaleZView.value=s}},this._onChangeScaleX=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getScale();i.setScale3v(new v(parseFloat(t),s.y,s.z))}},this._onChangeScaleY=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getScale();i.setScale3v(new v(s.x,parseFloat(t),s.z))}},this._onChangeScaleZ=t=>{let i=this.model.getSelectedEntity();if(i){let s=i.getScale();i.setScale3v(new v(s.x,s.y,parseFloat(t)))}},this._onGround=()=>{let t=this.model.getSelectedEntity();t&&this.model.planet&&(this.model.planet.terrain?this.model.planet.terrain.getHeightAsync(t.getLonLat(),i=>{this._heightView.value=i}):this._heightView.value=0)},this._relativePositionView=new Xh({label:"Relative position"}),this._lonView=new we({label:"Lon",type:"number",min:-180,max:180,maxFixed:10}),this._latView=new we({label:"Lat",type:"number",min:-90,max:90,maxFixed:10}),this._heightView=new we({label:"Height",type:"number",maxFixed:4}),this._xView=new we({label:"X",type:"number",maxFixed:10}),this._yView=new we({label:"Y",type:"number"}),this._zView=new we({label:"Z",type:"number"}),this._absXView=new we({label:"Absolute X",type:"number",maxFixed:10}),this._absYView=new we({label:"Absolute Y",type:"number"}),this._absZView=new we({label:"Absolute Z",type:"number"}),this._pitchView=new we({label:"Pitch",type:"number",maxFixed:2}),this._yawView=new we({label:"Yaw",type:"number",maxFixed:2}),this._rollView=new we({label:"Roll",type:"number",maxFixed:2}),this._absolutePitchView=new we({label:"Absolute pitch",type:"number",maxFixed:2}),this._absoluteYawView=new we({label:"Absolute yaw",type:"number",maxFixed:2}),this._absoluteRollView=new we({label:"Absolute roll",type:"number",maxFixed:2}),this._scaleView=new we({label:"Scale",type:"number",maxFixed:2}),this._scaleXView=new we({label:"Scale X",type:"number",maxFixed:2}),this._scaleYView=new we({label:"Scale Y",type:"number",maxFixed:2}),this._scaleZView=new we({label:"Scale Z",type:"number",maxFixed:2}),this._groundBtn=new nt({text:"Ground",title:"Put on the ground",name:"ground",classList:["og-editor-ground_button"]})}render(e){var t;super.render(e),this._initSceneEvents();let i=document.createElement("div");i.classList.add("og-editor_toolbar"),(t=this.container)==null||t.appendChild(i);let s=new fe({classList:["og-editor_toolbar-button"],icon:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" id="filter-center-focus">
344
+ </div>`,{label:e.label||"",checked:e.checked?"checked":""})}),this._onResize=()=>{},this._onMouseWheel=t=>{(t=t||window.event).preventDefault(),t.stopPropagation()},this._onMouseWheelFF=t=>{this._onMouseWheel(t)},this._onClick=t=>{(t=t||window.event).stopPropagation(),this.checked=!this._checked},this._checked=e.checked||!1,this._disabled=e.disabled||!1,this.events=this.events.registerNames($h),this.$label=null,this.$input=null}set disabled(e){this._disabled=e,this._updateDisabled()}_updateDisabled(){this.el&&(this._disabled?this.el.classList.add("og-input-disabled"):this.el.classList.remove("og-input-disabled"))}get disabled(){return this._disabled}render(e){return super.render(e),this.$label=this.select(".og-input-label"),this.$label.innerHTML===""&&(this.$label.style.display="none"),this.$input=this.select("input"),this.$input.checked=this._checked,this._updateDisabled(),this._initEvents(),this}set checked(e){e!==this._checked&&(this._checked=e,this.$input&&(this.$input.checked=this._checked),this.events.dispatch(this.events.change,this._checked,this))}get checked(){return this._checked}_initEvents(){this.el.addEventListener("mousewheel",this._onMouseWheel),this.el.addEventListener("wheel",this._onMouseWheelFF),this.$input.addEventListener("click",this._onClick)}_clearEvents(){this.el.removeEventListener("mousewheel",this._onMouseWheel),this.el.removeEventListener("wheel",this._onMouseWheelFF),this.$input.removeEventListener("click",this._onClick)}remove(){this._clearEvents(),super.remove()}set visibility(e){this.el&&(this.el.style.display=e?"":"none")}}class Zh extends at{constructor(e){super({title:"GeoObject Properties",visible:!1,resizable:!0,useHide:!0,top:25,right:85,width:252,height:480,minHeight:100,minWidth:100,model:e.model}),this._onVisibility=t=>{this.model.setVisibility(t)},this._onSelect=t=>{this.show(),this._refresh(t)},this._onUnselect=t=>{this.hide()},this._onChangeRelativePosition=t=>{let i=this.model.getSelectedEntity();i&&(i.relativePosition=t,this._refresh(i))},this._onPosition=(t,i)=>{this._refresh(i)},this._onPitch=(t,i)=>{this._pitchView.stopPropagation(),this._pitchView.value=i.getPitch()*J,this._absolutePitchView.stopPropagation(),this._absolutePitchView.value=i.getAbsolutePitch()*J},this._onYaw=(t,i)=>{this._yawView.stopPropagation(),this._yawView.value=i.getYaw()*J,this._absoluteYawView.stopPropagation(),this._absoluteYawView.value=i.getAbsoluteYaw()*J},this._onRoll=(t,i)=>{this._rollView.stopPropagation(),this._rollView.value=i.getRoll()*J,this._absoluteRollView.stopPropagation(),this._absoluteRollView.value=i.getAbsoluteRoll()*J},this._onChangeLon=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getLonLat();i.setLonLat2(parseFloat(t),r.lat,r.height),this._refresh(i)}},this._onChangeLat=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getLonLat();i.setLonLat2(r.lon,parseFloat(t),r.height),this._refresh(i)}},this._onChangeHeight=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getLonLat();i.setLonLat2(r.lon,r.lat,parseFloat(t)),this._refresh(i)}},this._onChangeX=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getCartesian();i.setCartesian(parseFloat(t),r.y,r.z),this._refresh(i)}},this._onChangeY=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getCartesian();i.setCartesian(r.x,parseFloat(t),r.z),this._refresh(i)}},this._onChangeZ=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getCartesian();i.setCartesian(r.x,r.y,parseFloat(t)),this._refresh(i)}},this._onChangeAbsoluteX=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getAbsoluteCartesian();i.setAbsoluteCartesian(parseFloat(t),r.y,r.z),this._refresh(i)}},this._onChangeAbsoluteY=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getAbsoluteCartesian();i.setAbsoluteCartesian(r.x,parseFloat(t),r.z),this._refresh(i)}},this._onChangeAbsoluteZ=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getAbsoluteCartesian();i.setAbsoluteCartesian(r.x,r.y,parseFloat(t)),this._refresh(i)}},this._onChangePitch=t=>{let i=this.model.getSelectedEntity();i&&(i.setPitch(parseFloat(t)*U),this._refresh(i))},this._onChangeYaw=t=>{let i=this.model.getSelectedEntity();i&&(i.setYaw(parseFloat(t)*U),this._refresh(i))},this._onChangeRoll=t=>{let i=this.model.getSelectedEntity();i&&(i.setRoll(parseFloat(t)*U),this._refresh(i))},this._onChangeAbsolutePitch=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsolutePitch(parseFloat(t)*U),this._refresh(i))},this._onChangeAbsoluteYaw=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsoluteYaw(parseFloat(t)*U),this._refresh(i))},this._onChangeAbsoluteRoll=t=>{let i=this.model.getSelectedEntity();i&&(i.setAbsoluteRoll(parseFloat(t)*U),this._refresh(i))},this._onChangeScale=t=>{let i=this.model.getSelectedEntity();if(i){let r=parseFloat(t);i.setScale(r),this._scaleXView.stopPropagation(),this._scaleYView.stopPropagation(),this._scaleZView.stopPropagation(),this._scaleXView.value=r,this._scaleYView.value=r,this._scaleZView.value=r}},this._onChangeScaleX=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getScale();i.setScale3v(new m(parseFloat(t),r.y,r.z))}},this._onChangeScaleY=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getScale();i.setScale3v(new m(r.x,parseFloat(t),r.z))}},this._onChangeScaleZ=t=>{let i=this.model.getSelectedEntity();if(i){let r=i.getScale();i.setScale3v(new m(r.x,r.y,parseFloat(t)))}},this._onGround=()=>{let t=this.model.getSelectedEntity();t&&this.model.planet&&(this.model.planet.terrain?this.model.planet.terrain.getHeightAsync(t.getLonLat(),i=>{this._heightView.value=i}):this._heightView.value=0)},this._relativePositionView=new Xh({label:"Relative position"}),this._lonView=new Ce({label:"Lon",type:"number",min:-180,max:180,maxFixed:10}),this._latView=new Ce({label:"Lat",type:"number",min:-90,max:90,maxFixed:10}),this._heightView=new Ce({label:"Height",type:"number",maxFixed:4}),this._xView=new Ce({label:"X",type:"number",maxFixed:10}),this._yView=new Ce({label:"Y",type:"number"}),this._zView=new Ce({label:"Z",type:"number"}),this._absXView=new Ce({label:"Absolute X",type:"number",maxFixed:10}),this._absYView=new Ce({label:"Absolute Y",type:"number"}),this._absZView=new Ce({label:"Absolute Z",type:"number"}),this._pitchView=new Ce({label:"Pitch",type:"number",maxFixed:2}),this._yawView=new Ce({label:"Yaw",type:"number",maxFixed:2}),this._rollView=new Ce({label:"Roll",type:"number",maxFixed:2}),this._absolutePitchView=new Ce({label:"Absolute pitch",type:"number",maxFixed:2}),this._absoluteYawView=new Ce({label:"Absolute yaw",type:"number",maxFixed:2}),this._absoluteRollView=new Ce({label:"Absolute roll",type:"number",maxFixed:2}),this._scaleView=new Ce({label:"Scale",type:"number",maxFixed:2}),this._scaleXView=new Ce({label:"Scale X",type:"number",maxFixed:2}),this._scaleYView=new Ce({label:"Scale Y",type:"number",maxFixed:2}),this._scaleZView=new Ce({label:"Scale Z",type:"number",maxFixed:2}),this._groundBtn=new nt({text:"Ground",title:"Put on the ground",name:"ground",classList:["og-editor-ground_button"]})}render(e){var t;super.render(e),this._initSceneEvents();let i=document.createElement("div");i.classList.add("og-editor_toolbar"),(t=this.container)==null||t.appendChild(i);let r=new _e({classList:["og-editor_toolbar-button"],icon:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" id="filter-center-focus">
345
345
  <path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/>
346
- </svg>`,title:"Lock/Unlock camera view"});return s.appendTo(i),s.events.on("change",r=>{r?this.model.lockView():this.model.unlockView()}),this.events.on("visibility",r=>{r||(s.events.stopPropagation(),s.setActive(!1))}),this.events.on("visibility",this._onVisibility),this._relativePositionView.appendTo(this.container),this.model.planet&&(this._lonView.appendTo(this.container),this._latView.appendTo(this.container),this._heightView.appendTo(this.container)),this._xView.appendTo(this.container),this._yView.appendTo(this.container),this._zView.appendTo(this.container),this._absXView.appendTo(this.container),this._absYView.appendTo(this.container),this._absZView.appendTo(this.container),this._pitchView.appendTo(this.container),this._yawView.appendTo(this.container),this._rollView.appendTo(this.container),this._absolutePitchView.appendTo(this.container),this._absoluteYawView.appendTo(this.container),this._absoluteRollView.appendTo(this.container),this._scaleView.appendTo(this.container),this._scaleXView.appendTo(this.container),this._scaleYView.appendTo(this.container),this._scaleZView.appendTo(this.container),this.model.planet&&this._groundBtn.appendTo(this.container),this._relativePositionView.events.on("change",this._onChangeRelativePosition),this._lonView.events.on("change",this._onChangeLon),this._latView.events.on("change",this._onChangeLat),this._heightView.events.on("change",this._onChangeHeight),this._xView.events.on("change",this._onChangeX),this._yView.events.on("change",this._onChangeY),this._zView.events.on("change",this._onChangeZ),this._absXView.events.on("change",this._onChangeAbsoluteX),this._absYView.events.on("change",this._onChangeAbsoluteY),this._absZView.events.on("change",this._onChangeAbsoluteZ),this._pitchView.events.on("change",this._onChangePitch),this._yawView.events.on("change",this._onChangeYaw),this._rollView.events.on("change",this._onChangeRoll),this._absolutePitchView.events.on("change",this._onChangeAbsolutePitch),this._absoluteYawView.events.on("change",this._onChangeAbsoluteYaw),this._absoluteRollView.events.on("change",this._onChangeAbsoluteRoll),this._scaleView.events.on("change",this._onChangeScale),this._scaleXView.events.on("change",this._onChangeScaleX),this._scaleYView.events.on("change",this._onChangeScaleY),this._scaleZView.events.on("change",this._onChangeScaleZ),this._groundBtn.appendTo(this.container),this._groundBtn.events.on("click",this._onGround),this}remove(){super.remove(),this._clearSceneEvents()}_initSceneEvents(){this.model.events.on("select",this._onSelect),this.model.events.on("unselect",this._onUnselect),this.model.events.on("position",this._onPosition),this.model.events.on("pitch",this._onPitch),this.model.events.on("yaw",this._onYaw),this.model.events.on("roll",this._onRoll)}_clearSceneEvents(){this.model.events.off("select",this._onSelect),this.model.events.off("unselect",this._onUnselect),this.model.events.off("position",this._onPosition),this.model.events.off("pitch",this._onPitch),this.model.events.off("yaw",this._onYaw),this.model.events.off("roll",this._onRoll)}_refresh(e){e.parent?this._relativePositionView.disabled=!1:this._relativePositionView.disabled=!0,this._relativePositionView.checked=e.relativePosition;let t=e.getLonLat();this._lonView.stopPropagation(),this._latView.stopPropagation(),this._heightView.stopPropagation(),this._lonView.value=t.lon,this._latView.value=t.lat,this._heightView.value=t.height;let i=e.getCartesian();this._xView.stopPropagation(),this._yView.stopPropagation(),this._zView.stopPropagation(),this._xView.value=i.x,this._yView.value=i.y,this._zView.value=i.z,i=e.getAbsoluteCartesian(),this._absXView.stopPropagation(),this._absYView.stopPropagation(),this._absZView.stopPropagation(),this._absXView.value=i.x,this._absYView.value=i.y,this._absZView.value=i.z,this._pitchView.stopPropagation(),this._yawView.stopPropagation(),this._rollView.stopPropagation(),this._pitchView.value=e.getPitch()*J,this._yawView.value=e.getYaw()*J,this._rollView.value=e.getRoll()*J,this._absolutePitchView.stopPropagation(),this._absoluteYawView.stopPropagation(),this._absoluteRollView.stopPropagation(),this._absolutePitchView.value=e.getAbsolutePitch()*J,this._absoluteYawView.value=e.getAbsoluteYaw()*J,this._absoluteRollView.value=e.getAbsoluteRoll()*J,this._scaleView.stopPropagation();let s=e.getScale();s.x===s.y&&s.y===s.z?this._scaleView.value=s.x:this._scaleView.value=1,this._scaleXView.stopPropagation(),this._scaleYView.stopPropagation(),this._scaleZView.stopPropagation(),this._scaleXView.value=s.x,this._scaleYView.value=s.y,this._scaleZView.value=s.z}hide(){super.hide(),this.model.events.stopPropagation(),this.model.unselect()}}const Qh=["lockview","unlockview"];class No extends te{constructor(e={}){super(e),this._onLockViewDraw=()=>{this.renderer&&this._lockEntity&&(this._isFromTheBack||this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(),this._lockDistance))},this._onMouseWheel=t=>{if(this.renderer&&this._lockEntity&&!this._isFromTheBack){let i=this.renderer.activeCamera.eye.distance(this._lockEntity.getAbsoluteCartesian());this._lockDistance-=.33*i*Math.sign(t.wheelDelta),this._lockDistance<.001&&(this._lockDistance=.001),this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(),this._lockDistance)}},this._onMouseMove=t=>{if(this._lockEntity&&this.renderer&&(t.rightButtonDown||this.renderer.events.isKeyPressed(W.KEY_ALT))){let i=this._lockEntity.getAbsoluteCartesian(),s=this.renderer.activeCamera,r=.5/j;r>.007&&(r=.007),this.planet?s.rotateHorizontal(r*(t.x-t.prev_x),!1,i,i.isZero()?v.UP:i.normal()):s.rotateHorizontal(r*(t.x-t.prev_x),!1,i,v.UP),s.rotateVertical(r*(t.y-t.prev_y),i),this._viewDir=i.sub(s.eye).normalize()}},this.events=he(Qh),this._name="CameraLock",this.planet=e.planet||null,this._lockDistance=0,this._isFromTheBack=!1,this._lockEntity=null,this._viewDir=new v(0,0,0)}onactivate(){this.renderer}ondeactivate(){this.renderer&&this.unlockView()}oninit(){this.activate(),this.renderer}flyCartesian(e,t=120){if(!e.isZero()&&this.renderer)if(this.unlockView(),this.planet){let i=this.planet.camera;this.isVisibleDistance(e)&&i.flyDistance(e,t),i.eye.distance(e)<1e6?i.flyDistance(e,t):i.viewDistance(e,t)}else this.renderer.activeCamera.viewDistance(e,t)}lockView(e,t=!1){if(!this.renderer)return;this._lockDistance=this._getDistance(e,this._lockEntity),this._isFromTheBack=t,this._deactivateLockViewEvents(),this._lockEntity=e;let i=this.renderer.activeCamera;this.planet&&this.planet.camera.stopFlying(),i.viewDistance(e.getAbsoluteCartesian(),this._lockDistance),this._deactivateNav(),this._activateLockViewEvents(),this._viewDir=e.getAbsoluteCartesian().sub(i.eye).normalize(),this.events.dispatch(this.events.lockview,this._lockEntity,t)}_activateNav(){this.renderer&&this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.activate(),this.renderer&&this.renderer.controls.simpleNavigation&&this.renderer.controls.simpleNavigation.activate()}_deactivateNav(){this.renderer&&this.renderer.controls.mouseNavigation&&(this.renderer.controls.mouseNavigation.deactivate(),this.renderer.controls.mouseNavigation.stop()),this.renderer&&this.renderer.controls.simpleNavigation&&this.renderer.controls.simpleNavigation.deactivate()}unlockView(){this._lockEntity&&(this._deactivateLockViewEvents(),this._activateNav(),this.events.dispatch(this.events.unlockview,this._lockEntity),this._lockEntity=null)}_getCenterDist(){return this.renderer&&this.renderer.getDistanceFromPixel(this.renderer.handler.getCenter())||0}_getDistance(e,t){if(this.renderer){let i=e.getAbsoluteCartesian(),s=this.renderer.activeCamera,r=s.eye.distance(i);return t&&(r=s.eye.distance(t.getAbsoluteCartesian())),this.isVisibleDistance(i)?r:s.eye.distance(i)<1e6?this._getCenterDist():120}return 0}isVisibleDistance(e,t=0){if(this.planet){let i=this.planet.ellipsoid.equatorialSize,s=this.planet.camera.eye;return s.distance(e)<Math.sqrt(s.length2()-i*i)+t}return!0}get lockEntity(){return this._lockEntity}flyLonLat(e,t=120){if(this.planet){let i=this.planet.ellipsoid.lonLatToCartesian(e);this.flyCartesian(i,t)}}_activateLockViewEvents(){this.renderer&&(this.renderer.events.on("mousewheel",this._onMouseWheel),this.renderer.events.on("mousemove",this._onMouseMove),this.renderer.events.on("draw",this._onLockViewDraw))}_deactivateLockViewEvents(){this.renderer&&(this.renderer.events.off("mousewheel",this._onMouseWheel),this.renderer.events.off("mousemove",this._onMouseMove),this._lockEntity&&this.renderer.events.off("draw",this._onLockViewDraw))}}const Kh=["click"];class Jh extends be{constructor(e){super({template:He(`<button class="og-object3d-collection__item">
346
+ </svg>`,title:"Lock/Unlock camera view"});return r.appendTo(i),r.events.on("change",s=>{s?this.model.lockView():this.model.unlockView()}),this.events.on("visibility",s=>{s||(r.events.stopPropagation(),r.setActive(!1))}),this.events.on("visibility",this._onVisibility),this._relativePositionView.appendTo(this.container),this.model.planet&&(this._lonView.appendTo(this.container),this._latView.appendTo(this.container),this._heightView.appendTo(this.container)),this._xView.appendTo(this.container),this._yView.appendTo(this.container),this._zView.appendTo(this.container),this._absXView.appendTo(this.container),this._absYView.appendTo(this.container),this._absZView.appendTo(this.container),this._pitchView.appendTo(this.container),this._yawView.appendTo(this.container),this._rollView.appendTo(this.container),this._absolutePitchView.appendTo(this.container),this._absoluteYawView.appendTo(this.container),this._absoluteRollView.appendTo(this.container),this._scaleView.appendTo(this.container),this._scaleXView.appendTo(this.container),this._scaleYView.appendTo(this.container),this._scaleZView.appendTo(this.container),this.model.planet&&this._groundBtn.appendTo(this.container),this._relativePositionView.events.on("change",this._onChangeRelativePosition),this._lonView.events.on("change",this._onChangeLon),this._latView.events.on("change",this._onChangeLat),this._heightView.events.on("change",this._onChangeHeight),this._xView.events.on("change",this._onChangeX),this._yView.events.on("change",this._onChangeY),this._zView.events.on("change",this._onChangeZ),this._absXView.events.on("change",this._onChangeAbsoluteX),this._absYView.events.on("change",this._onChangeAbsoluteY),this._absZView.events.on("change",this._onChangeAbsoluteZ),this._pitchView.events.on("change",this._onChangePitch),this._yawView.events.on("change",this._onChangeYaw),this._rollView.events.on("change",this._onChangeRoll),this._absolutePitchView.events.on("change",this._onChangeAbsolutePitch),this._absoluteYawView.events.on("change",this._onChangeAbsoluteYaw),this._absoluteRollView.events.on("change",this._onChangeAbsoluteRoll),this._scaleView.events.on("change",this._onChangeScale),this._scaleXView.events.on("change",this._onChangeScaleX),this._scaleYView.events.on("change",this._onChangeScaleY),this._scaleZView.events.on("change",this._onChangeScaleZ),this._groundBtn.appendTo(this.container),this._groundBtn.events.on("click",this._onGround),this}remove(){super.remove(),this._clearSceneEvents()}_initSceneEvents(){this.model.events.on("select",this._onSelect),this.model.events.on("unselect",this._onUnselect),this.model.events.on("position",this._onPosition),this.model.events.on("pitch",this._onPitch),this.model.events.on("yaw",this._onYaw),this.model.events.on("roll",this._onRoll)}_clearSceneEvents(){this.model.events.off("select",this._onSelect),this.model.events.off("unselect",this._onUnselect),this.model.events.off("position",this._onPosition),this.model.events.off("pitch",this._onPitch),this.model.events.off("yaw",this._onYaw),this.model.events.off("roll",this._onRoll)}_refresh(e){e.parent?this._relativePositionView.disabled=!1:this._relativePositionView.disabled=!0,this._relativePositionView.checked=e.relativePosition;let t=e.getLonLat();this._lonView.stopPropagation(),this._latView.stopPropagation(),this._heightView.stopPropagation(),this._lonView.value=t.lon,this._latView.value=t.lat,this._heightView.value=t.height;let i=e.getCartesian();this._xView.stopPropagation(),this._yView.stopPropagation(),this._zView.stopPropagation(),this._xView.value=i.x,this._yView.value=i.y,this._zView.value=i.z,i=e.getAbsoluteCartesian(),this._absXView.stopPropagation(),this._absYView.stopPropagation(),this._absZView.stopPropagation(),this._absXView.value=i.x,this._absYView.value=i.y,this._absZView.value=i.z,this._pitchView.stopPropagation(),this._yawView.stopPropagation(),this._rollView.stopPropagation(),this._pitchView.value=e.getPitch()*J,this._yawView.value=e.getYaw()*J,this._rollView.value=e.getRoll()*J,this._absolutePitchView.stopPropagation(),this._absoluteYawView.stopPropagation(),this._absoluteRollView.stopPropagation(),this._absolutePitchView.value=e.getAbsolutePitch()*J,this._absoluteYawView.value=e.getAbsoluteYaw()*J,this._absoluteRollView.value=e.getAbsoluteRoll()*J,this._scaleView.stopPropagation();let r=e.getScale();r.x===r.y&&r.y===r.z?this._scaleView.value=r.x:this._scaleView.value=1,this._scaleXView.stopPropagation(),this._scaleYView.stopPropagation(),this._scaleZView.stopPropagation(),this._scaleXView.value=r.x,this._scaleYView.value=r.y,this._scaleZView.value=r.z}hide(){super.hide(),this.model.events.stopPropagation(),this.model.unselect()}}const Qh=["lockview","unlockview"];class Na extends ee{constructor(e={}){super(e),this._onLockViewDraw=()=>{this.renderer&&this._lockEntity&&(this._isFromTheBack||this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(),this._lockDistance))},this._onMouseWheel=t=>{if(this.renderer&&this._lockEntity&&!this._isFromTheBack){let i=this.renderer.activeCamera.eye.distance(this._lockEntity.getAbsoluteCartesian());this._lockDistance-=.33*i*Math.sign(t.wheelDelta),this._lockDistance<.001&&(this._lockDistance=.001),this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(),this._lockDistance)}},this._onMouseMove=t=>{if(this._lockEntity&&this.renderer&&(t.rightButtonDown||this.renderer.events.isKeyPressed(W.KEY_ALT))){let i=this._lockEntity.getAbsoluteCartesian(),r=this.renderer.activeCamera,s=.5/U;s>.007&&(s=.007),this.planet?r.rotateHorizontal(s*(t.x-t.prev_x),!1,i,i.isZero()?m.UP:i.normal()):r.rotateHorizontal(s*(t.x-t.prev_x),!1,i,m.UP),r.rotateVertical(s*(t.y-t.prev_y),i),this._viewDir=i.sub(r.eye).normalize()}},this.events=le(Qh),this._name="CameraLock",this.planet=e.planet||null,this._lockDistance=0,this._isFromTheBack=!1,this._lockEntity=null,this._viewDir=new m(0,0,0)}onactivate(){this.renderer}ondeactivate(){this.renderer&&this.unlockView()}oninit(){this.activate(),this.renderer}flyCartesian(e,t=120){if(!e.isZero()&&this.renderer)if(this.unlockView(),this.planet){let i=this.planet.camera;this.isVisibleDistance(e)&&i.flyDistance(e,t),i.eye.distance(e)<1e6?i.flyDistance(e,t):i.viewDistance(e,t)}else this.renderer.activeCamera.viewDistance(e,t)}lockView(e,t=!1){if(!this.renderer)return;this._lockDistance=this._getDistance(e,this._lockEntity),this._isFromTheBack=t,this._deactivateLockViewEvents(),this._lockEntity=e;let i=this.renderer.activeCamera;this.planet&&this.planet.camera.stopFlying(),i.viewDistance(e.getAbsoluteCartesian(),this._lockDistance),this._deactivateNav(),this._activateLockViewEvents(),this._viewDir=e.getAbsoluteCartesian().sub(i.eye).normalize(),this.events.dispatch(this.events.lockview,this._lockEntity,t)}_activateNav(){this.renderer&&this.renderer.controls.mouseNavigation&&this.renderer.controls.mouseNavigation.activate(),this.renderer&&this.renderer.controls.simpleNavigation&&this.renderer.controls.simpleNavigation.activate()}_deactivateNav(){this.renderer&&this.renderer.controls.mouseNavigation&&(this.renderer.controls.mouseNavigation.deactivate(),this.renderer.controls.mouseNavigation.stop()),this.renderer&&this.renderer.controls.simpleNavigation&&this.renderer.controls.simpleNavigation.deactivate()}unlockView(){this._lockEntity&&(this._deactivateLockViewEvents(),this._activateNav(),this.events.dispatch(this.events.unlockview,this._lockEntity),this._lockEntity=null)}_getCenterDist(){return this.renderer&&this.renderer.getDistanceFromPixel(this.renderer.handler.getCenter())||0}_getDistance(e,t){if(this.renderer){let i=e.getAbsoluteCartesian(),r=this.renderer.activeCamera,s=r.eye.distance(i);return t&&(s=r.eye.distance(t.getAbsoluteCartesian())),this.isVisibleDistance(i)?s:r.eye.distance(i)<1e6?this._getCenterDist():120}return 0}isVisibleDistance(e,t=0){if(this.planet){let i=this.planet.ellipsoid.equatorialSize,r=this.planet.camera.eye;return r.distance(e)<Math.sqrt(r.length2()-i*i)+t}return!0}get lockEntity(){return this._lockEntity}flyLonLat(e,t=120){if(this.planet){let i=this.planet.ellipsoid.lonLatToCartesian(e);this.flyCartesian(i,t)}}_activateLockViewEvents(){this.renderer&&(this.renderer.events.on("mousewheel",this._onMouseWheel),this.renderer.events.on("mousemove",this._onMouseMove),this.renderer.events.on("draw",this._onLockViewDraw))}_deactivateLockViewEvents(){this.renderer&&(this.renderer.events.off("mousewheel",this._onMouseWheel),this.renderer.events.off("mousemove",this._onMouseMove),this._lockEntity&&this.renderer.events.off("draw",this._onLockViewDraw))}}const Kh=["click"];class Jh extends be{constructor(e){super({template:Ne(`<button class="og-object3d-collection__item">
347
347
  <div class="og-object3d-collection__item_name">{name}</div>
348
- </button>`,{name:e.model.name}),...e}),this.events=he(Kh)}render(e){var t;return super.render(e),(t=this.el)==null||t.addEventListener("click",i=>{this.events.dispatch(this.events.click,this.model,this,i)}),this}}const ec=["select"];class tc extends be{constructor(e){super({template:'<div class="og-object3d-collection"></div>',model:e.model,...e}),this._onAdd=t=>{this._addItem(t)},this.events=he(ec),this._activeView=null}_addItem(e){let t=new Jh({model:e});t.appendTo(this.el),t.events.on("click",i=>{var s,r;this._activeView&&((s=this._activeView.el)==null||s.classList.remove("active")),this._activeView=t,(r=this._activeView.el)==null||r.classList.add("active"),this.events.dispatch(this.events.select,i,t)})}render(e){super.render(e);let t=this.model.getItems();for(let i of t)this._addItem(i);return this._initEvents(),this}_initEvents(){this.model.events.on("add",this._onAdd)}}const ic=["select"];class sc extends ot{constructor(e){super({classList:["og-object3d-manager"],title:"Object3D Collection",visible:!1,resizable:!0,useHide:!0,top:25,right:85,width:252,height:480,minHeight:100,minWidth:100}),this._onLoadClick=()=>{let t=new be({initRender:!0,template:'<input type="file" accept=".obj,.mtl" multiple />'});t.el&&(t.el.addEventListener("change",i=>{const s=i.target;if(s.files){const r=Array.from(s.files),n=r.find(l=>l.name.toLowerCase().endsWith(".obj")),o=r.find(l=>l.name.toLowerCase().endsWith(".mtl"));n&&async function(l,h){return await Z.readFileObj(l,h).then(c=>({name:l.name,objects:h?c:[Z.merge(c)]}))}(n,o).then(this._addObject)}}),t.el.click())},this._addObject=t=>{this._object3dCollectionView.model.addItem(t)},this.events=he(ic),this._object3dCollectionView=new tc({model:e.model})}render(e){var t;super.render(e);let i=document.createElement("div");i.classList.add("og-editor_toolbar"),(t=this.container)==null||t.appendChild(i);let s=new nt({classList:["og-editor_toolbar-button"],icon:'<svg class="svg-icon" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M426.666667 170.666667H170.666667c-47.146667 0-84.906667 38.186667-84.906667 85.333333L85.333333 768c0 47.146667 38.186667 85.333333 85.333334 85.333333h682.666666c47.146667 0 85.333333-38.186667 85.333334-85.333333V341.333333c0-47.146667-38.186667-85.333333-85.333334-85.333333H512l-85.333333-85.333333z" /></svg>',title:"Load 3D object"});return s.appendTo(i),s.events.on("click",this._onLoadClick),this._object3dCollectionView.appendTo(this.container),this._object3dCollectionView.events.on("select",r=>{this.events.dispatch(this.events.select,r)}),this}}const rc=["add","remove"];class Qs{constructor(e={}){this.events=he(rc,this),this._items=Qs.createItemsMap(e.collection||[])}static createItemsMap(e){let t=new Map;for(let i=0;i<e.length;i++)t.set(e[i].name,e[i]);return t}getItem(e){return this._items.get(e)}addItem(e,t=!1){this._items.has(e.name)&&!t||(this._items.set(e.name,e),this.events.dispatch(this.events.add,e))}getItems(){return Array.from(this._items,([e,t])=>t)}}class Ks extends te{constructor(e={}){super({name:"CameraFrameComposer",autoActivate:!0,...e}),this._onPostdraw=()=>{for(let t=0,i=this._frameHandlers.length;t<i;t++)this._frameHandlers[t].frame()},this._cameraLayer=new ut({scaleByDistance:[100,1e6,1],pickingEnabled:!1}),this._cameraScene=new at("CameraScene"),this._frameHandlers=e.frameHandlers||[]}get frameHandlers(){return[...this._frameHandlers]}add(e){e.addTo(this),this._cameraLayer.add(e.cameraEntity)}oninit(){super.oninit(),this._cameraLayer.addTo(this._cameraScene)}activate(){super.activate(),this.renderer&&(this.renderer.events.on("postdraw",this._onPostdraw),this.renderer.addNode(this._cameraScene))}deactivate(){super.deactivate(),this.renderer&&(this.renderer.events.off("postdraw",this._onPostdraw),this.renderer.removeNode(this._cameraScene))}}let nc=Z.createFrustum();class Ho{constructor(e){this.camera=e.camera,this.frameBuffer=e.frameBuffer,this.frameHandler=e.frameHandler||null,this._composer=null,this._composerIndex=-1,this.showFrustum=e.showFrustum==null||e.showFrustum,this.cameraEntity=new V({visibility:!0,scale:this.frustumScale,geoObject:{tag:"frustum",color:"rgba(0,255,0,0.20)",object3d:nc}}),this.frameBuffer.init()}get frustumScale(){return Z.getFrustumScaleByCameraAspectRatio(1e3,this.camera.getViewAngle(),this.camera.getAspectRatio())}addTo(e){this._composer||(this._composer=e,this._composerIndex=e.frameHandlers.length,this._composer._frameHandlers.push(this))}remove(){this._composer&&(this._composer._frameHandlers.splice(this._composerIndex,1),this._composer=null,this._composerIndex=-1)}frame(){if(this.frameHandler&&this.frameBuffer.handler.gl&&(this.frameHandler(this),this.showFrustum)){let e=this.camera,t=Z.getFrustumScaleByCameraAngles(100,e.horizontalViewAngle,e.verticalViewAngle);this.cameraEntity.setScale3v(t),this.cameraEntity.setCartesian3v(e.eye),this.cameraEntity.setAbsolutePitch(e.getAbsolutePitch()),this.cameraEntity.setAbsoluteYaw(e.getAbsoluteYaw()),this.cameraEntity.setAbsoluteRoll(e.getAbsoluteRoll())}}}function Vt(a){let e=1/Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);a[0]*=e,a[1]*=e,a[2]*=e,a[3]*=e}class Vo{constructor(e={}){this._pickingColorU=new Float32Array([0,0,0]),this._f=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],this.projectionMatrix=new ne,this.inverseProjectionMatrix=new ne,this.projectionViewMatrix=new ne,this.projectionViewRTEMatrix=new ne,this.inverseProjectionViewMatrix=new ne,this.left=0,this.right=0,this.bottom=0,this.top=0,this.near=0,this.far=0,this.cameraFrustumIndex=e.cameraFrustumIndex!=null?e.cameraFrustumIndex:-1,this.setProjectionMatrix(e.fov||30,e.aspect||1,e.near||1,e.far||1e3)}getRightPlane(){return this._f[0]}getLeftPlane(){return this._f[1]}getBottomPlane(){return this._f[2]}getTopPlane(){return this._f[3]}getBackwardPlane(){return this._f[4]}getForwardPlane(){return this._f[5]}getProjectionViewMatrix(){return this.projectionViewMatrix._m}getProjectionViewRTEMatrix(){return this.projectionViewRTEMatrix._m}getProjectionMatrix(){return this.projectionMatrix._m}getInverseProjectionMatrix(){return this.inverseProjectionMatrix._m}setProjectionMatrix(e,t,i,s){this.top=i*Math.tan(e*et),this.bottom=-this.top,this.right=this.top*t,this.left=-this.right,this.near=i,this.far=s,this.projectionMatrix.setPerspective(this.left,this.right,this.bottom,this.top,i,s),this.projectionMatrix.inverseTo(this.inverseProjectionMatrix)}setProjectionViewRTEMatrix(e){this.projectionViewRTEMatrix=this.projectionMatrix.mul(e)}setViewMatrix(e){this.projectionViewMatrix=this.projectionMatrix.mul(e),this.projectionViewMatrix.inverseTo(this.inverseProjectionViewMatrix);let t=this.projectionViewMatrix._m;this._f[0][0]=t[3]-t[0],this._f[0][1]=t[7]-t[4],this._f[0][2]=t[11]-t[8],this._f[0][3]=t[15]-t[12],Vt(this._f[0]),this._f[1][0]=t[3]+t[0],this._f[1][1]=t[7]+t[4],this._f[1][2]=t[11]+t[8],this._f[1][3]=t[15]+t[12],Vt(this._f[1]),this._f[2][0]=t[3]+t[1],this._f[2][1]=t[7]+t[5],this._f[2][2]=t[11]+t[9],this._f[2][3]=t[15]+t[13],Vt(this._f[2]),this._f[3][0]=t[3]-t[1],this._f[3][1]=t[7]-t[5],this._f[3][2]=t[11]-t[9],this._f[3][3]=t[15]-t[13],Vt(this._f[3]),this._f[4][0]=t[3]-t[2],this._f[4][1]=t[7]-t[6],this._f[4][2]=t[11]-t[10],this._f[4][3]=t[15]-t[14],Vt(this._f[4]),this._f[5][0]=t[3]+t[2],this._f[5][1]=t[7]+t[6],this._f[5][2]=t[11]+t[10],this._f[5][3]=t[15]+t[14],Vt(this._f[5])}containsPoint(e){for(let t=0;t<6;t++)if(e.dotArr(this._f[t])+this._f[t][3]<=0)return!1;return!0}containsSphereBottomExc(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[0])+i[0][3]<=t||e.center.dotArr(i[1])+i[1][3]<=t||e.center.dotArr(i[3])+i[3][3]<=t||e.center.dotArr(i[4])+i[4][3]<=t||e.center.dotArr(i[5])+i[5][3]<=t)}containsSphereButtom(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[2])+i[2][3]<=t)}containsSphere(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[0])+i[0][3]<=t||e.center.dotArr(i[1])+i[1][3]<=t||e.center.dotArr(i[2])+i[2][3]<=t||e.center.dotArr(i[3])+i[3][3]<=t||e.center.dotArr(i[4])+i[4][3]<=t||e.center.dotArr(i[5])+i[5][3]<=t)}containsSphere2(e,t){let i=-t;return!(e.dotArr(this._f[0])+this._f[0][3]<=i||e.dotArr(this._f[1])+this._f[1][3]<=i||e.dotArr(this._f[2])+this._f[2][3]<=i||e.dotArr(this._f[3])+this._f[3][3]<=i||e.dotArr(this._f[4])+this._f[4][3]<=i||e.dotArr(this._f[5])+this._f[5][3]<=i)}containsBox(e){let t,i,s=!0;for(let r=0;r<6;r++){t=0,i=0;for(let n=0;n<8&&(i===0||t===0);n++)e.vertices[n].dotArr(this._f[r])+this._f[r][3]<0?t++:i++;if(i===0)return!1;t>0&&(s=!0)}return s}}const oc=["viewchange","moveend"],Uo=class Wa{constructor(e={}){if(this.__id=Wa.__counter__++,this.events=he(oc,this),this._width=e.width||1,this._height=e.height||1,this.eye=e.eye||new v,this.eyeHigh=new Float32Array(3),this.eyeLow=new Float32Array(3),this._viewAngle=e.viewAngle||47,this._horizontalViewAngle=0,this._viewMatrix=new ne,this._viewMatrixRTE=new ne,this._normalMatrix=new vt,this._r=new v(1,0,0),this._u=new v(0,1,0),this._b=new v(0,0,1),this._f=this._b.negateTo(),this._pr=this._r.clone(),this._pu=this._u.clone(),this._pb=this._b.clone(),this._peye=this.eye.clone(),this.isMoving=!1,this._tanViewAngle_hrad=0,this._tanViewAngle_hradOneByHeight=0,this.frustums=[],this.frustumColors=[],e.frustums)for(let t=0,i=e.frustums.length;t<i;t++){let s=e.frustums[t],r=new Vo({fov:this._viewAngle,aspect:this.getAspectRatio(),near:s[0],far:s[1]});r.cameraFrustumIndex=this.frustums.length,this.frustums.push(r),this.frustumColors.push(r._pickingColorU[0],r._pickingColorU[1],r._pickingColorU[2])}else{let t=.1,i=1e3,s=new Vo({fov:this._viewAngle,aspect:this.getAspectRatio(),near:t,far:i});s.cameraFrustumIndex=this.frustums.length,this.frustums.push(s),this.frustumColors.push(s._pickingColorU[0],s._pickingColorU[1],s._pickingColorU[2])}this.FARTHEST_FRUSTUM_INDEX=this.frustums.length-1,this.currentFrustumIndex=0,this.frustumColorIndex=0,this.isFirstPass=!1,this._projSizeConst=0,this.set(e.eye||new v(0,0,1),e.look||new v,e.up||new v(0,1,0))}get id(){return this.__id}checkMoveEnd(){let e=this._r,t=this._u,i=this._b,s=this.eye;this._peye.equal(s)&&this._pr.equal(e)&&this._pu.equal(t)&&this._pb.equal(i)?(this.isMoving&&this.events.dispatch(this.events.moveend,this),this.isMoving=!1):this.isMoving=!0,this._pr.copy(e),this._pu.copy(t),this._pb.copy(i),this._peye.copy(s)}bindFrustumsPickingColors(e){for(let t=0;t<this.frustums.length;t++)e.assignPickingColor(this.frustums[t])}_init(e){this._setProj(this._viewAngle,this.getAspectRatio()),this.set(e.eye||new v(0,0,1),e.look||new v,e.up||new v(0,1,0))}getUp(){return this._u.clone()}getDown(){return this._u.negateTo()}getRight(){return this._r.clone()}getLeft(){return this._r.negateTo()}getForward(){return this._f.clone()}getBackward(){return this._b.clone()}update(){let e=this._r,t=this._u,i=this._b,s=this.eye;v.doubleToTwoFloat32Array(s,this.eyeHigh,this.eyeLow),this._viewMatrix.set([e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,-s.dot(e),-s.dot(t),-s.dot(i),1]),this._viewMatrixRTE.set([e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1]);for(let r=0,n=this.frustums.length;r<n;r++)this.frustums[r].setViewMatrix(this._viewMatrix),this.frustums[r].setProjectionViewRTEMatrix(this._viewMatrixRTE);this.events.dispatch(this.events.viewchange,this)}refresh(){this._setProj(this._viewAngle,this.getAspectRatio()),this.update()}get width(){return this._width}get height(){return this._height}setViewportSize(e,t){this._width=e,this._height=t,this.refresh()}getAspectRatio(){return this._width/this._height}_setProj(e,t){this._viewAngle=e;for(let r=0,n=this.frustums.length;r<n;r++)this.frustums[r].setProjectionMatrix(e,t,this.frustums[r].near,this.frustums[r].far);var i,s;this._horizontalViewAngle=(i=e,s=t,ts*Math.atan(Math.tan(et*i)*s)),this._updateViewportParameters()}_updateViewportParameters(){this._tanViewAngle_hrad=Math.tan(this._viewAngle*et),this._tanViewAngle_hradOneByHeight=this._tanViewAngle_hrad*(1/this._height),this._projSizeConst=Math.min(this._width<512?512:this._width,this._height<512?512:this._height)/(this._viewAngle*j)}setViewAngle(e){this._viewAngle=e,this.refresh()}getViewAngle(){return this._viewAngle}get viewAngle(){return this._viewAngle}get verticalViewAngle(){return this._viewAngle}get horizontalViewAngle(){return this._horizontalViewAngle}set(e,t,i){return this.eye.x=e.x,this.eye.y=e.y,this.eye.z=e.z,t=t||this._b,i=i||this._u,this._b.x=e.x-t.x,this._b.y=e.y-t.y,this._b.z=e.z-t.z,this._r.copy(i.cross(this._b)),this._b.normalize(),this._r.normalize(),this._u.copy(this._b.cross(this._r)),this._f.set(-this._b.x,-this._b.y,-this._b.z),this}look(e,t){this._b.set(this.eye.x-e.x,this.eye.y-e.y,this.eye.z-e.z),this._r.copy((t||this._u).cross(this._b)),this._b.normalize(),this._f.set(-this._b.x,-this._b.y,-this._b.z),this._r.normalize(),this._u.copy(this._b.cross(this._r))}slide(e,t,i){this.eye.x+=e*this._r.x+t*this._u.x+i*this._b.x,this.eye.y+=e*this._r.y+t*this._u.y+i*this._b.y,this.eye.z+=e*this._r.z+t*this._u.z+i*this._b.z}setRoll(e){let t=Math.cos(e),i=Math.sin(e),s=this._r.clone();this._r.set(t*s.x-i*this._u.x,t*s.y-i*this._u.y,t*s.z-i*this._u.z),this._u.set(i*s.x+t*this._u.x,i*s.y+t*this._u.y,i*s.z+t*this._u.z)}setPitch(e){let t=Math.cos(e),i=Math.sin(e),s=this._b;this._b.set(t*s.x-i*this._u.x,t*s.y-i*this._u.y,t*s.z-i*this._u.z),this._u.set(i*s.x+t*this._u.x,i*s.y+t*this._u.y,i*s.z+t*this._u.z)}setYaw(e){let t=Math.cos(e),i=Math.sin(e),s=this._r;this._r.set(t*s.x-i*this._b.x,t*s.y-i*this._b.y,t*s.z-i*this._b.z),this._b.set(i*s.x+t*this._b.x,i*s.y+t*this._b.y,i*s.z+t*this._b.z)}setPitchYawRoll(e,t,i){let s=new O;s.setPitchYawRoll(e,t,i),this.setRotation(s)}getPitch(){return this.getRotation().getPitch()}getYaw(){return this.getRotation().getYaw()}getRoll(){return this.getRotation().getRoll()}getAbsolutePitch(){return this.getRotation().getPitch()}getAbsoluteYaw(){return this.getRotation().getYaw()}getAbsoluteRoll(){return this.getRotation().getRoll()}getRotation(){return O.getLookRotation(this._f,this._u).conjugate()}setRotation(e,t,i,s){e.mulVec3Res(t||new v(0,1,0),this._u),e.mulVec3Res(i||new v(1,0,0),this._r),e.mulVec3Res(s||new v(0,0,1),this._b),this._f.set(-this._b.x,-this._b.y,-this._b.z)}rotate(e){e.mulVec3Res(this._u,this._u),e.mulVec3Res(this._r,this._r),e.mulVec3Res(this._b,this._b),this._f.set(-this._b.x,-this._b.y,-this._b.z)}unproject2v(e){return this.unproject(e.x,e.y)}unproject(e,t){let i=.5*this._width,s=.5*this._height,r=(e-i)/i,n=-(t-s)/s,o=this.frustums[0].inverseProjectionViewMatrix.mulVec4(new ee(r,n,-1,1)).affinity();return this.frustums[0].inverseProjectionViewMatrix.mulVec4(new ee(r,n,0,1)).affinity().subA(o).toVec3().normalize()}project3v(e){return this.project(e.x,e.y,e.z)}project(e,t,i){let s=this.frustums[0].projectionViewMatrix.mulVec4(new ee(e,t,i,1));return new N((1+s.x/s.w)*this._width*.5,(1-s.y/s.w)*this._height*.5)}rotateAround(e,t=!1,i=v.ZERO,s=v.UP){s=t?this._u:s;let r=ne.getRotation(e,s),n=ne.getRotationAroundPoint(e,i,s);this.eye=n.mulVec3(this.eye),this._u=r.mulVec3(this._u).normalize(),this._r=r.mulVec3(this._r).normalize(),this._b=r.mulVec3(this._b).normalize(),this._f.set(-this._b.x,-this._b.y,-this._b.z)}rotateHorizontal(e,t,i,s){this.rotateAround(e,t,i,s)}rotateVertical(e,t){this.rotateAround(e,!1,t,this._r)}projectedSize(e,t){return Math.atan(t/this.eye.distance(e))*this._projSizeConst}getViewMatrix(){return this._viewMatrix._m}getNormalMatrix(){return this._normalMatrix._m}setCurrentFrustum(e){this.currentFrustumIndex=e,this.frustumColorIndex=10*(e+1)/255,this.isFirstPass=e===this.FARTHEST_FRUSTUM_INDEX}getCurrentFrustum(){return this.currentFrustumIndex}containsSphere(e){for(let t=0;t<this.frustums.length;t++)if(this.frustums[t].containsSphere(e))return!0;return!1}get frustum(){return this.frustums[this.currentFrustumIndex]}getProjectionMatrix(){return this.frustum.projectionMatrix._m}getProjectionViewMatrix(){return this.frustum.projectionViewMatrix._m}getProjectionViewRTEMatrix(){return this.frustum.projectionViewRTEMatrix._m}getInverseProjectionViewMatrix(){return this.frustum.inverseProjectionViewMatrix._m}getInverseProjectionMatrix(){return this.frustum.inverseProjectionMatrix._m}viewDistance(e,t=1e4){let i=e.add(this.getBackward().scaleTo(t));this.set(i,e),this.update()}copy(e){this.eye.copy(e.eye),this._r.copy(e._r),this._u.copy(e._u),this._b.copy(e._b),this._f.copy(e._f),this._width=e.width,this._height=e.height,this.setViewAngle(e.viewAngle),this.update()}getAltitude(){return this.eye.y}};Uo.__counter__=0;let Js=Uo;const K=class{};K.Linear=a=>a,K.QuadIn=a=>a*a,K.QuadOut=a=>1-(1-a)*(1-a),K.QuadInOut=a=>a<.5?2*a*a:1-Math.pow(-2*a+2,2)/2,K.CubicIn=a=>a*a*a,K.CubicOut=a=>1-Math.pow(1-a,3),K.CubicInOut=a=>a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,K.QuartIn=a=>a*a*a*a,K.QuartOut=a=>1-Math.pow(1-a,4),K.QuartInOut=a=>a<.5?8*a*a*a*a:1-Math.pow(-2*a+2,4)/2,K.QuintIn=a=>a*a*a*a*a,K.QuintOut=a=>1-Math.pow(1-a,5),K.QuintInOut=a=>a<.5?16*a*a*a*a*a:1-Math.pow(-2*a+2,5)/2,K.SineIn=a=>1-Math.cos(a*Math.PI/2),K.SineOut=a=>Math.sin(a*Math.PI/2),K.SineInOut=a=>-(Math.cos(Math.PI*a)-1)/2,K.ExpoIn=a=>a===0?0:Math.pow(2,10*a-10),K.ExpoOut=a=>a===1?1:1-Math.pow(2,-10*a),K.ExpoInOut=a=>a===0?0:a===1?1:a<.5?Math.pow(2,20*a-10)/2:(2-Math.pow(2,-20*a+10))/2,K.CircIn=a=>1-Math.sqrt(1-Math.pow(a,2)),K.CircOut=a=>Math.sqrt(1-Math.pow(a-1,2)),K.CircInOut=a=>a<.5?(1-Math.sqrt(1-Math.pow(2*a,2)))/2:(Math.sqrt(1-Math.pow(-2*a+2,2))+1)/2,K.BackIn=a=>2.70158*a*a*a-1.70158*a*a,K.BackOut=a=>1+2.70158*Math.pow(a-1,3)+1.70158*Math.pow(a-1,2),K.BackInOut=a=>{const e=2.5949095;return a<.5?Math.pow(2*a,2)*(7.189819*a-e)/2:(Math.pow(2*a-2,2)*((e+1)*(2*a-2)+e)+2)/2},K.ElasticIn=a=>{const e=2*Math.PI/3;return a===0?0:a===1?1:-Math.pow(2,10*a-10)*Math.sin((10*a-10.75)*e)},K.ElasticOut=a=>{const e=2*Math.PI/3;return a===0?0:a===1?1:Math.pow(2,-10*a)*Math.sin((10*a-.75)*e)+1},K.ElasticInOut=a=>{const e=2*Math.PI/4.5;return a===0?0:a===1?1:a<.5?-Math.pow(2,20*a-10)*Math.sin((20*a-11.125)*e)/2:Math.pow(2,-20*a+10)*Math.sin((20*a-11.125)*e)/2+1},K.BounceOut=a=>a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375,K.BounceIn=a=>1-K.BounceOut(1-a),K.BounceInOut=a=>a<.5?.5*(1-K.BounceOut(1-2*a)):.5*(K.BounceOut(2*a-1)+1);let ac=K;const lc=["flystart","flyend","flystop"],bt=ac.CubicInOut;class Go extends Js{constructor(e,t={}){super({...t,frustums:t.frustums||[[1,100.075],[100,1000.075],[1e3,101e4],[1e6,1e9]]}),this.events=this.events.registerNames(lc),this.planet=e,this.minAltitude=t.minAltitude||1,this.maxAltitude=t.maxAltitude||2e7,this._lonLat=this.planet.ellipsoid.cartesianToLonLat(this.eye),this._lonLatMerc=this._lonLat.forwardMercator(),this._terrainAltitude=this._lonLat.height,this._terrainPoint=new v,this._insideSegment=null,this.slope=0,this._keyLock=new di,this._flight=null,this._completeCallback=null,this._frameCallback=null,this._flying=!1,this._checkTerrainCollision=!0,this.eyeNorm=this.eye.getNormal()}setTerrainCollisionActivity(e){this._checkTerrainCollision=e}update(){this.events.stopPropagation();let e=this.maxAltitude+this.planet.ellipsoid.getEquatorialSize();this.eye.length()>e&&this.eye.copy(this.eye.getNormal().scale(e)),super.update(),this.updateGeodeticPosition(),this.eyeNorm=this.eye.getNormal(),this.slope=this._b.dot(this.eyeNorm),this.events.dispatch(this.events.viewchange,this)}updateGeodeticPosition(){this.planet.ellipsoid.cartesianToLonLatRes(this.eye,this._lonLat),Math.abs(this._lonLat.lat)<=ue&&A.forwardMercatorRes(this._lonLat,this._lonLatMerc)}setAltitude(e){let t=this._terrainPoint,i=this.planet.ellipsoid.getSurfaceNormal3v(this.eye);this.eye.x=i.x*e+t.x,this.eye.y=i.y*e+t.y,this.eye.z=i.z*e+t.z,this._terrainAltitude=e}getAltitude(){return this._terrainAltitude}setLonLat(e,t,i){this.stopFlying(),this._lonLat.set(e.lon,e.lat,e.height||this._lonLat.height);let s=this.planet.ellipsoid,r=s.lonLatToCartesian(this._lonLat),n=t?s.lonLatToCartesian(t):v.ZERO;this.set(r,n,i||r.getNormal()),this.update()}getLonLat(){return this._lonLat}getHeight(){return this._lonLat.height}getExtentPosition(e,t){t=t||0;let i=e.getNorth(),s=e.getSouth(),r=e.getEast(),n=e.getWest();n>r&&(r+=360);let o=this.planet.ellipsoid,l=new A(r,i),h=o.lonLatToCartesian(l);l.lat=s;let c=o.lonLatToCartesian(l);l.lon=n;let d=o.lonLatToCartesian(l);l.lat=i;let u=o.lonLatToCartesian(l),g=v.sub(h,d).scale(.5).addA(d),f=g.length();f<1e-6&&(l.lon=.5*(r+n),l.lat=.5*(i+s),g=o.lonLatToCartesian(l)),u.subA(g),c.subA(g),h.subA(g),d.subA(g);let p=g.getNormal(),_=p.cross(v.NORTH).normalize(),m=_.cross(p).normalize(),y=Math.max(Math.abs(m.dot(u)),Math.abs(m.dot(c)),Math.abs(m.dot(h)),Math.abs(m.dot(d))),x=Math.max(Math.abs(_.dot(u)),Math.abs(_.dot(c)),Math.abs(_.dot(h)),Math.abs(_.dot(d))),w=Math.tan(this._viewAngle*j*.5),b=this.getAspectRatio()*w,E=Math.max(x/b,y/w);return g.normalize(),g.scale(f+E+t),g}viewExtent(e,t){this.stopFlying(),this.set(this.getExtentPosition(e,t),v.ZERO,v.NORTH),this.update()}flyExtent(e,t,i,s,r=800,n=bt,o,l,h){this.flyCartesian(this.getExtentPosition(e,t),v.ZERO,i,s??1,r,n,o,l,h)}viewDistance(e,t=1e4){let i=this.eye.add(this.getForward().scaleTo(t)),s=O.getRotationBetweenVectors(i.getNormal(),e.getNormal());if(s.isZero()){let r=e.add(this.getBackward().scaleTo(t));this.set(r,e)}else{let r=e.add(s.mulVec3(this.getBackward()).scale(t)),n=s.mulVec3(this.getUp());this.set(r,e,n)}this.update()}flyDistance(e,t=1e4,i=0,s=800,r=bt,n,o,l){let h=this.eye.add(this.getForward().scaleTo(t)),c=O.getRotationBetweenVectors(h.getNormal(),e.getNormal());if(c.isZero()){let d=e.add(this.getBackward().scaleTo(t));this.set(d,e)}else{let d=e.add(c.mulVec3(this.getBackward()).scale(t)),u=c.mulVec3(this.getUp());this.flyCartesian(d,e,u,i,s,r,n,o,l)}}flyCartesian(e,t=v.ZERO,i=v.NORTH,s=1,r=800,n=bt,o=()=>{},l=()=>{},h=()=>{}){this.stopFlying(),t=t||v.ZERO,i=i||v.NORTH,this._completeCallback=o,this._frameCallback=h,l&&l.call(this),t instanceof A&&(t=this.planet.ellipsoid.lonLatToCartesian(t));let c=this.eye.clone(),d=this._u,u=this._b,g=this.planet.ellipsoid.cartesianToLonLat(e),f=i,p=this.planet.ellipsoid.lonLatToCartesian(new A(g.lon,g.lat,0)),_=v.sub(e,t),m=f.cross(_);_.normalize(),m.normalize();let y=_.cross(m),x=c.getNormal(),w=p.getNormal(),b=1-x.dot(w),E=s*br*Math.sqrt(b>0?b:0),C=6639613,T=Math.max(this._lonLat.height,g.height);T>C&&(C=T);let L=T+2.5*E*(C-T),M=v.ZERO;this._flight={fly:R=>{let z=n(R),F=1-z,P=c.smerp(p,F).normalize(),D=this.planet.getRayIntersectionEllipsoid(new U(M,P)),I=this._lonLat.height*F*F*F+3*L*F*F*z+3*L*F*z*z+g.height*z*z*z,k=D.addA(P.scale(I)),B=d.smerp(y,F),H=v.add(k,u.smerp(_,F).negateTo()),Ce=new v(k.x-H.x,k.y-H.y,k.z-H.z),ce=B.cross(Ce);Ce.normalize(),ce.normalize();let Be=Ce.cross(ce);return{eye:k,n:Ce,u:ce,v:Be}},duration:r,startedAt:Date.now()},this._flying=!0,this.events.dispatch(this.events.flystart,this)}flyLonLat(e,t,i,s,r=800,n=bt,o,l,h){let c=new A(e.lon,e.lat,e.height||this._lonLat.height);this.flyCartesian(this.planet.ellipsoid.lonLatToCartesian(c),t,i,s,r,n,o,l,h)}stopFlying(){this._flying&&(this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet.normalMapCreator.free(this._keyLock),this._flying=!1,this._flight=null,this._frameCallback=null,this.events.dispatch(this.events.flystop,this))}isFlying(){return this._flying}rotateLeft(e,t){this.rotateHorizontal(e,t!==!0,v.ZERO),this.update()}rotateRight(e,t){this.rotateHorizontal(-e,t!==!0,v.ZERO),this.update()}rotateUp(e){this.rotateVertical(e,v.ZERO),this.update()}rotateDown(e){this.rotateVertical(-e,v.ZERO),this.update()}rotateVertical(e,t,i=0){let s=new ne().setRotation(this._r,e),r=new ne().setIdentity().translate(t),n=new ne().setIdentity().translate(t.negateTo()),o=r.mul(s).mul(n).mulVec3(this.eye),l=s.mulVec3(this._u).normalize(),h=s.mulVec3(this._r).normalize(),c=s.mulVec3(this._b).normalize(),d=o.getNormal(),u=c.dot(d);if(i){let g=u-this.slope;if(u<i&&g<0)return;(u>.1&&l.dot(d)>0||this.slope<=.1||this._u.dot(this.eye.getNormal())<=0)&&(this.eye=o,this._u=l,this._r=h,this._b=c,this._f.set(-c.x,-c.y,-c.z))}else this.eye=o,this._u=l,this._r=h,this._b=c,this._f.set(-c.x,-c.y,-c.z)}checkFly(){if(this._flying&&this._flight!==null){let e=Math.min((Date.now()-this._flight.startedAt)/this._flight.duration,1);this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet.normalMapCreator.lock(this._keyLock);const t=this._flight.fly(e);this.eye=t.eye,this._r=t.u,this._u=t.v,this._b=t.n,this._f.set(-this._b.x,-this._b.y,-this._b.z),this._frameCallback&&this._frameCallback(),this.update(),e>=1&&(this.stopFlying(),this._completeCallback&&(this.events.dispatch(this.events.flyend,this),this._completeCallback(),this._completeCallback=null))}}checkTerrainCollision(){if(this._terrainAltitude=this._lonLat.height,this._insideSegment&&this._insideSegment.planet)return this._terrainAltitude=this._insideSegment.getTerrainPoint(this.eye,this._insideSegment.getInsideLonLat(this),this._terrainPoint),this._terrainAltitude<this.minAltitude&&this._checkTerrainCollision&&this.setAltitude(this.minAltitude),this._terrainPoint}getSurfaceVisibleDistance(e){let t=this.planet.ellipsoid.equatorialSize;return t*Math.acos(t/(t+this._lonLat.height+e))}getHeading(){let e=this.eye.getNormal(),t=v.proj_b_to_plane(this.slope>=.97?this.getUp():this.getForward(),e).normalize(),i=v.proj_b_to_plane(v.NORTH,e).normalize(),s=Math.sign(e.dot(t.cross(i)))*Math.acos(t.dot(i))*J;return s<0?360+s:s}isVisible(e){let t=this.eye.length();return this.eye.distance(e)<Math.sqrt(t*t-this.planet.ellipsoid.equatorialSizeSqr)}getPitch(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getPitch()}getYaw(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getYaw()}getRoll(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getRoll()}setPitch(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(e,this.getYaw(),this.getRoll(),t),this.setRotation(i)}setYaw(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(this.getPitch(),e,this.getRoll(),t),this.setRotation(i)}setRoll(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(this.getPitch(),this.getYaw(),e,t),this.setRotation(i)}setPitchYawRoll(e,t,i){let s=this.planet.getFrameRotation(this.eye),r=new O;r.setPitchYawRoll(e,t,i,s).conjugate(),this.setRotation(r)}}const jo=class $a{constructor(e,t={}){this.handler=e,this.__id=$a.__counter__++,this._fbo=null,this._width=t.width||e.canvas.width,this._height=t.height||e.canvas.height,this._depthComponent=t.depthComponent!=null?t.depthComponent:"DEPTH_COMPONENT16",this._useDepth=t.useDepth==null||t.useDepth,this._active=!1,this._size=t.size||1,this._depthRenderbuffer=null,this._filter=t.filter||"NEAREST"}get width(){return this._width}get height(){return this._height}setSize(e,t,i=!1){this._width=e,this._height=t,this._active&&this.handler.gl.viewport(0,0,this._width,this._height),(this._useDepth||i)&&(this.destroy(),this.init())}init(){}destroy(){}isComplete(){let e=this.handler.gl;return e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE}checkStatus(){let e=this.handler.gl;return e.checkFramebufferStatus(e.FRAMEBUFFER)}activate(){let e=this.handler.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo),e.viewport(0,0,this._width,this._height),this._active=!0;let t=this.handler.framebufferStack.current().data;return t&&(t._active=!1),this.handler.framebufferStack.push(this),this}deactivate(){let e=this.handler,t=e.gl;t.bindFramebuffer(t.FRAMEBUFFER,null),this._active=!1;let i=this.handler.framebufferStack.popPrev();i?(t.bindFramebuffer(t.FRAMEBUFFER,i._fbo),t.viewport(0,0,i._width,i._height)):t.viewport(0,0,e.canvas.width,e.canvas.height)}isEqual(e){return!!e&&this.__id===e.__id}};jo.__counter__=0;let Yo=jo;class fi{constructor(e=256,t=256){this._canvas=document.createElement("canvas"),this._canvas.width=e,this._canvas.height=t,this._context=this._canvas.getContext("2d",{willReadFrequently:!0})}getCanvas(){return this._canvas}getContext(){return this._context}fillEmpty(){let e=this._context.getImageData(0,0,this._canvas.width,this._canvas.height),t=e.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=t[i+1]=t[i+2]=t[i+3]=0;this._context.putImageData(e,0,0)}fill(e){this._context.fillStyle=e,this._context.fill()}getData(){return this._context.getImageData(0,0,this._canvas.width,this._canvas.height).data}fillColor(e){this._context.fillStyle=e,this._context.fillRect(0,0,this._canvas.width,this._canvas.height)}setData(e){let t=this._context.createImageData(this._canvas.width,this._canvas.height);t.data.set(e),this._context.putImageData(t,0,0)}resize(e,t){this._canvas.width=e,this._canvas.height=t,this._context=this._canvas.getContext("2d")}drawImage(e,t,i,s,r){this._context.drawImage(e,t||0,i||0,s||e.width,r||e.height)}getImage(){let e=new Image;return e.width=this.getWidth(),e.height=this.getHeight(),e.src=this._canvas.toDataURL("image/png"),e}getTextWidth(e){let t=this._context.measureText(e);return Math.round(t.width)}drawText(e,t=0,i=14,s="normal 14px Verdana",r="black"){this._context.fillStyle=r,this._context.font=s,this._context.fillText(e,t,i)}getWidth(){return this._canvas.width}getHeight(){return this._canvas.height}load(e,t){let i=new Image,s=this;i.onload=function(){s.resize(i.width,i.height),s._context.drawImage(i,0,0,i.width,i.height),t&&t(i)},i.src=e}openImage(){let e=this.getImage(),t="<!DOCTYPE html>";t+="<html>",t+="<head><title>Print</title></head>",t+="<body>",t+='<img src="'+e.src+'">',t+="</body>",t+="</html>";let i=window.open("","","width="+e.width+"px ,height="+e.height+"px");i&&(i.document.open(),i.document.write(t),i.document.close(),i.focus())}destroy(){this._canvas.width=1,this._canvas.height=1,this._canvas=null,this._context=null}}const qo={UNSIGNED_BYTE:Uint8Array,FLOAT:Float32Array};class Me extends Yo{constructor(e,t={}){super(e,t),this.readPixelBuffersAsync=i=>{const s=this.handler.gl;if(this._skipFrame)return;this._skipFrame=!0;let r=this.width,n=this.height,o=this.pixelBuffers;this.activate();for(let d=0;d<o.length;d++){let u=o[d];s.bindBuffer(s.PIXEL_PACK_BUFFER,u.buffer),s.bufferData(s.PIXEL_PACK_BUFFER,u.data.byteLength,s.STREAM_READ),s.readBuffer(u.glAttachment),s.readPixels(0,0,r,n,s.RGBA,u.glType,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null)}this.deactivate();const l=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);var h,c;s.flush(),(h=s,c=l,new Promise((d,u)=>{(function g(){const f=h.clientWaitSync(c,0,0);f==h.WAIT_FAILED?u():f==h.TIMEOUT_EXPIRED?requestAnimationFrame(g):d()})()})).then(()=>{this._skipFrame=!1,s.deleteSync(l);for(let d=0;d<o.length;d++){let u=o[d];u.data&&(s.bindBuffer(s.PIXEL_PACK_BUFFER,u.buffer),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,u.data),i&&i(this))}s.bindBuffer(s.PIXEL_PACK_BUFFER,null)})},this._targets=Me.createTargets(t.targets),this._size=this._targets.length,this._renderbufferTarget=t.renderbufferTarget!=null?t.renderbufferTarget:"DEPTH_ATTACHMENT",this.textures=t.textures||new Array(this._size),this.pixelBuffers=[],this._skipFrame=!1}static createTargets(e){let t=0,i=0;return e?e.map(s=>{let r=s.attachment||"COLOR_ATTACHMENT";r==="COLOR_ATTACHMENT"&&(r="COLOR_ATTACHMENT"+t++);let n=s.type||"UNSIGNED_BYTE";return{internalFormat:s.internalFormat||"RGBA",format:s.format||"RGBA",type:n,attachment:r,filter:s.filter||"NEAREST",pixelBufferIndex:s.readAsync?i++:-1,TypeArrayConstructor:qo[n]}}):[{internalFormat:"RGBA",format:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT0",filter:"NEAREST",pixelBufferIndex:-1,TypeArrayConstructor:qo.UNSIGNED_BYTE}]}destroy(){let e=this.handler.gl;if(e){for(let t=0;t<this.textures.length;t++)e.deleteTexture(this.textures[t]);this.textures=new Array(this._size);for(let t=0;t<this.pixelBuffers.length;t++)this.pixelBuffers[t].data=null,e.deleteBuffer(this.pixelBuffers[t].buffer);this.pixelBuffers=[],e.deleteFramebuffer(this._fbo),e.deleteRenderbuffer(this._depthRenderbuffer),this._depthRenderbuffer=null,this._fbo=null,this._active=!1}}init(){let e=this.handler.gl;if(!e)return;this._fbo=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo);let t=[];for(let i=0;i<this._targets.length;i++){let s=this._targets[i],r=this.textures[i]||this.handler.createEmptyTexture2DExt(this._width,this._height,s.filter,s.internalFormat,s.format,s.type),n=e[s.attachment];r&&(this.bindOutputTexture(r,n),this.textures[i]=r),s.attachment!=="DEPTH_ATTACHMENT"&&t.push(n),s.pixelBufferIndex!==-1&&this._createPixelBuffer(s)}e.drawBuffers&&e.drawBuffers(t),this._useDepth&&(this._depthRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthRenderbuffer),e.renderbufferStorage(e.RENDERBUFFER,e[this._depthComponent],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e[this._renderbufferTarget],e.RENDERBUFFER,this._depthRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null)),e.bindFramebuffer(e.FRAMEBUFFER,null)}getPixelBufferData(e=0){let t=this._targets[e].pixelBufferIndex;return t!==-1?this.pixelBuffers[t].data:null}_createPixelBuffer(e){let t=this.handler.gl,i=e.pixelBufferIndex,s=this.pixelBuffers[i];s||(s=this.pixelBuffers[i]={buffer:null,data:null,glType:-1,glAttachment:-1});let r=this.width*this.height*4;s.data=null,s.data=new e.TypeArrayConstructor(r),s.buffer=t.createBuffer(),t.bindBuffer(t.PIXEL_PACK_BUFFER,s.buffer),t.bufferData(t.PIXEL_PACK_BUFFER,r,t.STREAM_READ),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),s.glType=t[e.type],s.glAttachment=t[e.attachment]}bindOutputTexture(e,t){let i=this.handler.gl;i.bindTexture(i.TEXTURE_2D,e),i.framebufferTexture2D(i.FRAMEBUFFER,t||i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.bindTexture(i.TEXTURE_2D,null)}readPixels(e,t,i,s=0,r=1,n=1){let o=this.handler.gl;o.bindFramebuffer(o.FRAMEBUFFER,this._fbo),o.readBuffer&&o.readBuffer(o.COLOR_ATTACHMENT0+s||0),o.readPixels(t*this._width,i*this._height,r,n,o.RGBA,o[this._targets[s].type],e),o.bindFramebuffer(o.FRAMEBUFFER,null)}readAllPixels(e,t=0){let i=this.handler.gl;i.bindFramebuffer(i.FRAMEBUFFER,this._fbo),i.readBuffer&&i.readBuffer(i.COLOR_ATTACHMENT0+t),i.readPixels(0,0,this._width,this._height,i.RGBA,i[this._targets[t].type],e),i.bindFramebuffer(i.FRAMEBUFFER,null)}getImage(){let e=new Uint8Array(4*this._width*this._height);this.readAllPixels(e);let t=new fi(this._width,this._height);return t.setData(e),t.getImage()}readData(e,t,i,s=0){const r=this.width,n=this.height,o=Math.floor(e*(r-1)),l=4*(Math.floor(t*(n-1))*r+o),h=this.pixelBuffers[s].data;h&&(i[0]=h[l],i[1]=h[l+1],i[2]=h[l+2],i[3]=h[l+3])}}const hc=["tick","end","start","stop"],Wo=class Xa{constructor(e={}){this.__handler=null,this.active=!0,this.__id=Xa.__counter__++,this.events=he(hc,this),this.name=e.name||"",this.startDate=e.startDate||0,this.endDate=e.endDate||0;let t=e.currentDate||ji(new Date);e.startDate&&t<e.startDate&&(t=e.startDate),e.endDate&&t>e.endDate&&(t=e.endDate),this.currentDate=t,this._multiplier=e.multiplier!==void 0?e.multiplier:1,this._running=1,this.deltaTicks=0,this.active=!0,this._intervalDelay=0,this._intervalStart=0,this._intervalCallback=null}clearInterval(){this._intervalDelay=0,this._intervalStart=0,this._intervalCallback=null}setInterval(e,t){this._intervalStart=this.currentDate,this._intervalDelay=e*Ts,this._intervalCallback=t}setDate(e){let t=ji(e);this.startDate&&t<this.startDate&&(t=this.startDate),this.endDate&&t>this.endDate&&(t=this.endDate),this.currentDate=t}getDate(){return Ls(this.currentDate)}reset(){this.startDate&&(this.currentDate=this.startDate)}tick(e){let t=this._multiplier*this._running;if(this.deltaTicks=e*t,this.active){let i=Gr(this.currentDate,this.deltaTicks);t>0?this.endDate&&i>this.endDate?(this.currentDate=this.startDate,this.events.dispatch(this.events.end,this)):this.currentDate=i:this.startDate&&i<this.startDate?(this.currentDate=this.endDate,this.events.dispatch(this.events.end,this)):this.currentDate=i,this._intervalCallback&&this.currentDate-this._intervalStart>=this._intervalDelay&&(this._intervalStart=this.currentDate,this._intervalCallback(this)),this.events.dispatch(this.events.tick,this)}}isEqual(e){return this.__id===e.__id}start(){this._running===0&&(this._running=1,this.events.dispatch(this.events.start,this))}get multiplier(){return this._multiplier}set multiplier(e){this._multiplier=e}stop(){this._running===1&&(this._running=0,this.events.dispatch(this.events.stop,this))}};Wo.__counter__=0;let cc=Wo;class dc{constructor(e,t){t._programController=this,this._program=t,this._handler=e,this._activated=!1}initialize(){this._handler.gl&&this._program.createProgram(this._handler.gl)}getProgram(){return this._program}activate(){if(!this._activated){this._handler.activeProgram.deactivate(),this._handler.activeProgram=this;let e=this._program;this._activated=!0,e.enableAttribArrays(),e.use()}return this}remove(){let e=this._handler.programs;e[this._program.name]&&(this._activated&&this.deactivate(),this._program.delete(),delete e[this._program.name])}deactivate(){this._program.disableAttribArrays(),this._activated=!1}isActive(){return this._activated}set(e){return this.activate(),this._program.set(e),this}drawIndexBuffer(e,t){return this._program.drawIndexBuffer(e,t),this}drawArrays(e,t){return this._program.drawArrays(e,t),this}}let $o=class{constructor(){this.next=null,this.prev=null,this.data=null}};class er{constructor(e=256){this._current=new $o,this._head=this._current;for(let t=0;t<e;t++){let i=new $o;i.prev=this._current,this._current.next=i,this._current=i}this._current=this._head}current(){return this._current}push(e){this._current=this._current.next,this._current.data=e}pop(){let e=this._current.data;return this._current=this._current.prev,e}popPrev(){return this._current=this._current.prev,this._current.data}}const Xo=["","WEBKIT_","MOZ_"],tr=["webgl2","webgl"];class wt{constructor(e,t={}){this.framebufferStack=new er,this._requestAnimationFrameId=0,this.drawFrame=()=>{let i=window.performance.now(),s=this.deltaTime;this.deltaTime=.5*(i-this._lastAnimationFrameTime+this.prevDeltaTime),this.deltaTime>3?this.deltaTime=3:this.deltaTime<1&&(this.deltaTime=1),this.prevDeltaTime=s,this._lastAnimationFrameTime=i,this.defaultClock.tick(this.deltaTime);for(let n=0;n<this._clocks.length;n++)this._clocks[n].tick(this.deltaTime);let r=this.canvas;Math.floor(r.clientWidth*this._params.pixelRatio)===r.width&&Math.floor(r.clientHeight*this._params.pixelRatio)===r.height||(r.clientWidth===0||r.clientHeight===0?this.stop():document.hidden||(this.start(),this.setSize(r.clientWidth,r.clientHeight))),this._frameCallback()},this.events=he(["visibilitychange","resize"]),this._throttledDrawFrame=this.drawFrame,this.defaultClock=new cc,this._clocks=[],this.prevDeltaTime=0,this.deltaTime=0,this.canvas=null,this.gl=null,this.programs={},this.activeProgram=null,this._canvasSize=[0,0],this._params={anisotropy:t.anisotropy||4,width:t.width||256,height:t.height||256,pixelRatio:Hr("og_dpi")||t.pixelRatio||1,extensions:t.extensions||[],context:t.context||{}},this.extensions={},this._canvasTarget=e,this._lastAnimationFrameTime=0,this._initialized=!1,this._frameCallback=function(){},this.transparentTexture=null,this.defaultTexture=null,this.framebufferStack=new er,this.createTexture_n=this.createTexture_n_webgl2.bind(this),this.createTexture_l=this.createTexture_l_webgl2.bind(this),this.createTexture_mm=this.createTexture_mm_webgl2.bind(this),this.createTexture_a=this.createTexture_a_webgl2.bind(this),this.createTexture={NEAREST:this.createTexture_n,LINEAR:this.createTexture_l,MIPMAP:this.createTexture_mm,ANISOTROPIC:this.createTexture_a},this.createTextureDefault=this.createTexture_n,this.ONCANVASRESIZE=null,this._createCanvas(),(t.autoActivate||Ge(t.autoActivate))&&this.initialize()}set frameDelay(e){this._throttledDrawFrame=e===0?this.drawFrame:Kt(this.drawFrame,e)}isInitialized(){return this._initialized}_createCanvas(){this._canvasTarget?this._canvasTarget instanceof HTMLElement?this.canvas=this._canvasTarget:this.canvas=document.getElementById(this._canvasTarget)||document.querySelector(this._canvasTarget):(this.canvas=document.createElement("canvas"),this.canvas.width=this._params.width,this.canvas.height=this._params.height)}static getExtension(e,t){if(!e)return;let i,s;for(i in Xo)if(s=e.getExtension(Xo[i]+t),s)return s}static getContext(e,t){let i=null;try{let s=new URLSearchParams(location.search).get("og_ver");if(s)i=e.getContext(s,t),i&&(i.type=s);else for(let r=0;r<tr.length;r++)if(i=e.getContext(tr[r],t),i){i.type=tr[r];break}}catch{Qe.logErr("exception during the GL context initialization")}return i||Qe.logErr("could not initialise WebGL"),i}setFrameCallback(e){e&&(this._frameCallback=e)}createEmptyTexture2DExt(e=1,t=1,i="NEAREST",s="RGBA",r="RGBA",n="UNSIGNED_BYTE",o="CLAMP_TO_EDGE",l=0){let h=this.gl,c=h.createTexture();return h.bindTexture(h.TEXTURE_2D,c),h.texImage2D(h.TEXTURE_2D,l,h[s.toUpperCase()],e,t,0,h[r.toUpperCase()],h[n.toUpperCase()],null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h[i.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h[i.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h[o.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h[o.toUpperCase()]),h.bindTexture(h.TEXTURE_2D,null),c}createEmptyTexture_n(e,t,i,s){let r=this.gl,n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.texImage2D(r.TEXTURE_2D,0,i||r.RGBA,e,t,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,s||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,s||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),n}createEmptyTexture_l(e,t,i,s){let r=this.gl,n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.texImage2D(r.TEXTURE_2D,0,i||r.RGBA,e,t,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,s||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,s||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),n}createTexture_n_webgl1(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,t||r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_l_webgl1(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,t||r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_mm_webgl1(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,t||r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.generateMipmap(r.TEXTURE_2D),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_a_webgl1(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,t||r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.generateMipmap(r.TEXTURE_2D),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameterf(r.TEXTURE_2D,this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._params.anisotropy),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_n_webgl2(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texStorage2D(r.TEXTURE_2D,1,t||r.RGBA8,e.width,e.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.width,e.height,r.RGBA,r.UNSIGNED_BYTE,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_l_webgl2(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texStorage2D(r.TEXTURE_2D,1,t||r.RGBA8,e.width,e.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.width,e.height,r.RGBA,r.UNSIGNED_BYTE,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_mm_webgl2(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texStorage2D(r.TEXTURE_2D,2,t||r.RGBA8,e.width,e.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.width,e.height,r.RGBA,r.UNSIGNED_BYTE,e),r.generateMipmap(r.TEXTURE_2D),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}createTexture_a_webgl2(e,t,i,s=null){let r=this.gl;return s=s||r.createTexture(),r.bindTexture(r.TEXTURE_2D,s),r.texStorage2D(r.TEXTURE_2D,2,t||r.RGBA8,e.width,e.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.width,e.height,r.RGBA,r.UNSIGNED_BYTE,e),r.generateMipmap(r.TEXTURE_2D),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameterf(r.TEXTURE_2D,this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._params.anisotropy),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,i||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,i||r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),s}loadCubeMapTexture(e){let t=this.gl,i=t.createTexture();t.bindTexture(t.TEXTURE_CUBE_MAP,i),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR);let s=[[e.px,t.TEXTURE_CUBE_MAP_POSITIVE_X],[e.nx,t.TEXTURE_CUBE_MAP_NEGATIVE_X],[e.py,t.TEXTURE_CUBE_MAP_POSITIVE_Y],[e.ny,t.TEXTURE_CUBE_MAP_NEGATIVE_Y],[e.pz,t.TEXTURE_CUBE_MAP_POSITIVE_Z],[e.nz,t.TEXTURE_CUBE_MAP_NEGATIVE_Z]],r=new fi;r.fillEmpty();let n=r.getImage();for(let o=0;o<s.length;o++){let l=s[o][1];t.bindTexture(t.TEXTURE_CUBE_MAP,i),t.texImage2D(l,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)}for(let o=0;o<s.length;o++){let l=s[o][1],h=new Image;h.crossOrigin="",h.onload=function(c,d,u){return function(){t&&c&&(t.bindTexture(t.TEXTURE_CUBE_MAP,c),t.texImage2D(d,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,u))}}(i,l,h),h.src=s[o][0]}return i}addProgram(e,t=!1){if(this.programs[e.name])console.warn(`Shader program: "${e.name}" already exists.`);else{let i=new dc(this,e);this.programs[e.name]=i,this._initProgramController(i),t&&(i._activated=!1)}return e}removeProgram(e){this.programs[e]&&this.programs[e].remove()}addPrograms(e){for(let t=0;t<e.length;t++)this.addProgram(e[t])}_initProgramController(e){this._initialized&&(e.initialize(),this.activeProgram?(e.deactivate(),this.activeProgram._program.enableAttribArrays(),this.activeProgram._program.use()):(this.activeProgram=e,e.activate()))}_initPrograms(){for(let e in this.programs)this._initProgramController(this.programs[e])}initializeExtension(e,t=!1){if(!this.extensions||!this.extensions[e]){let i=wt.getExtension(this.gl,e);i?this.extensions[e]=i:t&&console.warn("og.webgl.Handler: extension '"+e+"' doesn't initialize.")}return this.extensions&&this.extensions[e]}initialize(){if(this._initialized||!this.canvas||(this.gl=wt.getContext(this.canvas,this._params.context),!this.gl))return;this._initialized=!0,this._params.extensions.push("EXT_texture_filter_anisotropic"),this.gl.type==="webgl"?(this._params.extensions.push("OES_standard_derivatives"),this._params.extensions.push("OES_element_index_uint"),this._params.extensions.push("WEBGL_depth_texture"),this._params.extensions.push("ANGLE_instanced_arrays")):(this._params.extensions.push("EXT_color_buffer_float"),this._params.extensions.push("OES_texture_float_linear"));let e=this._params.extensions.length;for(;e--;)this.initializeExtension(this._params.extensions[e],!0);this.gl.type==="webgl"?(this.createTexture_n=this.createTexture_n_webgl1.bind(this),this.createTexture_l=this.createTexture_l_webgl1.bind(this),this.createTexture_mm=this.createTexture_mm_webgl1.bind(this),this.createTexture_a=this.createTexture_a_webgl1.bind(this)):(this.createTexture_n=this.createTexture_n_webgl2.bind(this),this.createTexture_l=this.createTexture_l_webgl2.bind(this),this.createTexture_mm=this.createTexture_mm_webgl2.bind(this),this.createTexture_a=this.createTexture_a_webgl2.bind(this)),this.createTexture.NEAREST=this.createTexture_n,this.createTexture.LINEAR=this.createTexture_l,this.createTexture.MIPMAP=this.createTexture_mm,this.createTexture.ANISOTROPIC=this.createTexture_a,this.extensions.EXT_texture_filter_anisotropic?this.createTextureDefault=this.createTexture_a:this.createTextureDefault=this.createTexture_mm,this._initPrograms(),this._setDefaults(),this.intersectionObserver=new IntersectionObserver(t=>{this._toggleVisibilityChange(t[t.length-1].isIntersecting)},{threshold:0}),this.intersectionObserver.observe(this.canvas),this.resizeObserver=new ResizeObserver(t=>{this._toggleVisibilityChange(t[0].contentRect.width!==0&&t[0].contentRect.height!==0)}),this.resizeObserver.observe(this.canvas),document.addEventListener("visibilitychange",()=>{this._toggleVisibilityChange(document.visibilityState==="visible")})}_toggleVisibilityChange(e){e?(this.start(),this.ONCANVASRESIZE&&this.ONCANVASRESIZE(),this.events.dispatch(this.events.visibilitychange,!0)):(this.events.dispatch(this.events.visibilitychange,!1),this.stop())}_setDefaults(){let e=this.gl;e&&this.canvas&&(e.depthFunc(e.LESS),e.enable(e.DEPTH_TEST),this.setSize(this.canvas.clientWidth||this._params.width,this.canvas.clientHeight||this._params.height),e.frontFace(e.CCW),e.cullFace(e.BACK),e.enable(e.CULL_FACE),e.disable(e.BLEND),this.createDefaultTexture({color:"rgba(0,0,0,0.0)"},t=>{this.transparentTexture=t}),this.createDefaultTexture({color:"rgba(255, 255, 255, 1.0)"},t=>{this.defaultTexture=t}))}getCanvasSize(){return this._canvasSize}createStreamArrayBuffer(e,t,i,s=4){let r=this.gl,n=r.createBuffer();return r.bindBuffer(r.ARRAY_BUFFER,n),r.bufferData(r.ARRAY_BUFFER,t*e*s,i||r.STREAM_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),n.itemSize=e,n.numItems=t,n}setStreamArrayBuffer(e,t,i=0){let s=this.gl;return s.bindBuffer(s.ARRAY_BUFFER,e),s.bufferSubData(s.ARRAY_BUFFER,i,t),s.bindBuffer(s.ARRAY_BUFFER,null),e}createArrayBuffer(e,t,i,s){let r=this.gl,n=r.createBuffer();return r.bindBuffer(r.ARRAY_BUFFER,n),r.bufferData(r.ARRAY_BUFFER,e,s||r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),n.itemSize=t,n.numItems=i,n}createArrayBufferLength(e,t){let i=this.gl,s=i.createBuffer();return i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,e,t||i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s.itemSize=1,s.numItems=e,s}createElementArrayBuffer(e,t,i,s){let r=this.gl,n=r.createBuffer();return r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,n),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e,s||r.STATIC_DRAW),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null),n.itemSize=t,n.numItems=i||e.length,n}setSize(e,t){this._params.width=e,this._params.height=t,this.canvas&&(this.canvas.width=e*this._params.pixelRatio,this.canvas.height=t*this._params.pixelRatio,this._canvasSize[0]=this.canvas.width,this._canvasSize[1]=this.canvas.height,this.gl&&this.gl.viewport(0,0,e,t),this.ONCANVASRESIZE&&this.ONCANVASRESIZE(this.canvas),this.events.dispatch(this.events.resize,this))}get pixelRatio(){return this._params.pixelRatio}set pixelRatio(e){this._params.pixelRatio=e,this.setSize(this._params.width,this._params.height)}getWidth(){return this.canvas?this.canvas.width:0}getHeight(){return this.canvas?this.canvas.height:0}getClientAspect(){return this.canvas?this.canvas.clientWidth/this.canvas.clientHeight:0}getCenter(){let e=this.canvas;return e?new N(Math.round(.5*e.width),Math.round(.5*e.height)):new N}clearFrame(){let e=this.gl;e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}start(){!this._requestAnimationFrameId&&this._initialized&&this._animationFrameCallback()}stop(){this._requestAnimationFrameId&&(window.cancelAnimationFrame(this._requestAnimationFrameId),this._requestAnimationFrameId=0)}isStopped(){return!this._requestAnimationFrameId}isWebGl2(){return!!this.gl&&this.gl.type==="webgl2"}_animationFrameCallback(){this._requestAnimationFrameId=window.requestAnimationFrame(()=>{this._throttledDrawFrame(),this._requestAnimationFrameId&&this._animationFrameCallback()})}createDefaultTexture(e,t){let i,s;if(e&&e.color)i=new fi(2,2),i.fillColor(e.color),s=this.createTexture_n(i.getCanvas()),s.default=!0,t(s);else if(e&&e.url){let r=new Image,n=this;r.onload=function(){s=n.createTextureDefault(r),s.default=!0,t(s)},r.src=e.url}else i=new fi(2,2),i.fillColor("#C5C5C5"),s=this.createTexture_n(i.getCanvas()),s.default=!0,t(s)}deleteTexture(e){e&&!e.default&&this.gl.deleteTexture(e)}destroy(){var e,t;(e=this.resizeObserver)==null||e.disconnect(),(t=this.intersectionObserver)==null||t.disconnect(),this.stop();for(let s in this.programs)this.removeProgram(s);let i=this.gl;if(i){i.deleteTexture(this.transparentTexture),this.transparentTexture=null,i.deleteTexture(this.defaultTexture),this.defaultTexture=null,this.framebufferStack=new er;let s=i.getParameter(i.MAX_VERTEX_ATTRIBS),r=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,r);for(let o=0;o<s;++o)i.disableVertexAttribArray(o),i.vertexAttribPointer(o,4,i.FLOAT,!1,0,0),i.vertexAttrib1f(o,0);i.deleteBuffer(r);let n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let o=0;o<n;++o)i.activeTexture(i.TEXTURE0+o),i.bindTexture(i.TEXTURE_CUBE_MAP,null),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(null),i.bindBuffer(i.ARRAY_BUFFER,null),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindRenderbuffer(i.RENDERBUFFER,null),i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.DITHER),i.disable(i.SCISSOR_TEST),i.blendColor(0,0,0,0),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.clearColor(0,0,0,0),i.clearDepth(1),i.clearStencil(-1)}this.canvas&&(this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.width=1,this.canvas.height=1,this.canvas=null),this.gl=null,this._initialized=!1}addClock(e){e.__handler||(e.__handler=this,this._clocks.push(e))}addClocks(e){for(let t=0;t<e.length;t++)this.addClock(e[t])}removeClock(e){if(e.__handler){let t=this._clocks,i=t.length;for(;i--;)if(t[i].isEqual(e)){e.__handler=null,t.splice(i,1);break}}}}class Zo extends Yo{constructor(e,t={}){super(e,t),this._internalFormat=t.internalFormat?t.internalFormat.toUpperCase():"RGBA8",this._msaa=t.msaa!=null?t.msaa:4,this._glFilter=0,this.renderbuffers=new Array(this._size)}destroy(){let e=this.handler.gl;if(e){for(let t=0;t<this.renderbuffers.length;t++)e.deleteRenderbuffer(this.renderbuffers[t]);this.renderbuffers=new Array(this._size),e.deleteFramebuffer(this._fbo),e.deleteRenderbuffer(this._depthRenderbuffer),this._depthRenderbuffer=null,this._fbo=null,this._active=!1}}init(){let e=this.handler.gl;if(!e)return;this._glFilter=e[this._filter],this._fbo=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo);let t=[];for(let i=0;i<this.renderbuffers.length;i++){let s=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,s),this._msaa>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,this._msaa,e[this._internalFormat],this._width,this._height):e.renderbufferStorage(e.RENDERBUFFER,e[this._internalFormat],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,s),t.push(e.COLOR_ATTACHMENT0+i),this.renderbuffers[i]=s,e.bindRenderbuffer(e.RENDERBUFFER,null)}e.drawBuffers(t),this._useDepth&&(this._depthRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthRenderbuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,this._msaa,e[this._depthComponent],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this._depthRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null)),e.bindFramebuffer(e.FRAMEBUFFER,null)}blitTo(e,t=0){let i=this.handler.gl;i.bindFramebuffer(i.READ_FRAMEBUFFER,this._fbo),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,e._fbo),i.readBuffer(i.COLOR_ATTACHMENT0+t),i.clearBufferfv(i.COLOR,0,[0,0,0,1]),i.blitFramebuffer(0,0,this._width,this._height,0,0,e._width,e._height,i.COLOR_BUFFER_BIT,this._glFilter),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null)}}Object.freeze(Object.defineProperty({__proto__:null,Framebuffer:Me,Handler:wt,Multisample:Zo,Program:X,types:_e},Symbol.toStringTag,{value:"Module"}));class ir extends ci{constructor(e,t={}){super(e,t),this._image=t.image||null,this._src=t.src||null,this._onLoad_=null}get instanceName(){return"GeoImage"}abortLoading(){this._image instanceof HTMLImageElement&&(this._image.src="")}setSrc(e){this._planet&&this._planet._geoImageCreator.remove(this),this._src=e,this._sourceReady=!1,this._sourceCreated=!1,this._image=new Image,this._image.crossOrigin="Anonymous",this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_),this._image.src=e}setImage(e){this._planet&&this._planet._geoImageCreator.remove(this),this._sourceCreated=!1,this._sourceReady=!1,this._image=e,this._image.crossOrigin="Anonymous",this._src=e.src,ys(this._image)?this._applyImage(this._image):(this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_))}_createSourceTexture(){!this._sourceCreated&&this._image&&(this._sourceTexture=this._planet.renderer.handler.createTexture_l(this._image),this._sourceCreated=!0)}_onLoad(e){this._applyImage(this._image),this._image instanceof HTMLImageElement&&this._image.removeEventListener("load",this._onLoad_),this._onLoad_=null}_applyImage(e){e&&(this._frameWidth=Mt(2*e.width,4096),this._frameHeight=Mt(3*e.height,4096),this._sourceReady=!0,this._planet&&this._planet._geoImageCreator.add(this))}loadMaterial(e){e.isLoading=!0,this._creationProceeding=!0,!this._sourceReady&&this._src?this._image?this._image instanceof HTMLImageElement&&(ys(this._image)?this._applyImage(this._image):(this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_))):(this._image=new Image,this._image.crossOrigin="Anonymous",this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_),this._image.src=this._src):this._planet&&this._planet._geoImageCreator.add(this)}abortMaterialLoading(e){this._image&&this._image instanceof HTMLImageElement&&(this._image.src=""),this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}Object.freeze(Object.defineProperty({__proto__:null,AtmosphereConfig:class extends te{constructor(a={}){super(a),this.$maxOpacity=null,this.$minOpacity=null,this.$rayleight=null,this.$mie=null,this.$height=null,this.$bottomRadius=null,this.$mieScatteringCoefficient=null,this.$mieExtinctionCoefficient=null,this.$rayleighScatteringCoefficientA=null,this.$rayleighScatteringCoefficientB=null,this.$rayleighScatteringCoefficientC=null,this.$ozoneAbsorptionCoefficientA=null,this.$ozoneAbsorptionCoefficientB=null,this.$ozoneAbsorptionCoefficientC=null,this.$sunAngularRadius=null,this.$sunIntensity=null,this.$groundAlbedo=null,this.$ozoneDensityHeight=null,this.$ozoneDensityWide=null,this._toggleBtn=new fe({classList:["og-map-button","og-atmosphere_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
349
- <svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M135.688 18.5c-6.798 74.842-23.842 85.39-107.907 59.656 84.85 52.022 73.57 64.954-6.843 96.938 87.743-10.27 103.29 4.89 70.75 87.594 17.805-27.56 32.5-44.498 46.282-54.47-11.813 28.26-18.345 59.274-18.345 91.813 0 84.184 43.71 157.96 109.656 200.376-41.624-43.834-67.686-102.7-67.686-167.875 0-134.923 109.45-244.405 244.375-244.405 30.92 0 60.76 5.762 88 16.25-38.584-26.87-85.517-42.625-136.064-42.625-55.257 0-106.14 18.802-146.562 50.375 4.627-18.783 17.39-38.073 41.03-60.906C190.18 90.942 153.53 95.634 135.69 18.5zm10.03 77.188c5.67.002 11.428 1.247 16.876 3.874 14.506 6.998 22.72 21.81 22 36.938-10.26 10.87-19.507 22.696-27.594 35.344-9.035 2.753-19.075 2.27-28.25-2.156-19.37-9.343-27.5-32.6-18.156-51.97 6.715-13.92 20.638-22.036 35.125-22.03z"/></svg>`}),this._dialog=new ot({title:"Atmosphere Parameters",visible:!1,useHide:!0,top:60,left:60,width:720}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._panel=new be({template:`<div class="og-atmosphere og-options-container">
348
+ </button>`,{name:e.model.name}),...e}),this.events=le(Kh)}render(e){var t;return super.render(e),(t=this.el)==null||t.addEventListener("click",i=>{this.events.dispatch(this.events.click,this.model,this,i)}),this}}const ec=["select"];class tc extends be{constructor(e){super({template:'<div class="og-object3d-collection"></div>',model:e.model,...e}),this._onAdd=t=>{this._addItem(t)},this.events=le(ec),this._activeView=null}_addItem(e){let t=new Jh({model:e});t.appendTo(this.el),t.events.on("click",i=>{var r,s;this._activeView&&((r=this._activeView.el)==null||r.classList.remove("active")),this._activeView=t,(s=this._activeView.el)==null||s.classList.add("active"),this.events.dispatch(this.events.select,i,t)})}render(e){super.render(e);let t=this.model.getItems();for(let i of t)this._addItem(i);return this._initEvents(),this}_initEvents(){this.model.events.on("add",this._onAdd)}}const ic=["select"];class rc extends at{constructor(e){super({classList:["og-object3d-manager"],title:"Object3D Collection",visible:!1,resizable:!0,useHide:!0,top:25,right:85,width:252,height:480,minHeight:100,minWidth:100}),this._onLoadClick=()=>{let t=new be({initRender:!0,template:'<input type="file" accept=".obj,.mtl" multiple />'});t.el&&(t.el.addEventListener("change",i=>{const r=i.target;if(r.files){const s=Array.from(r.files),n=s.find(l=>l.name.toLowerCase().endsWith(".obj")),o=s.find(l=>l.name.toLowerCase().endsWith(".mtl"));n&&async function(l,h){return await Z.readFileObj(l,h).then(c=>({name:l.name,objects:h?c:[Z.merge(c)]}))}(n,o).then(this._addObject)}}),t.el.click())},this._addObject=t=>{this._object3dCollectionView.model.addItem(t)},this.events=le(ic),this._object3dCollectionView=new tc({model:e.model})}render(e){var t;super.render(e);let i=document.createElement("div");i.classList.add("og-editor_toolbar"),(t=this.container)==null||t.appendChild(i);let r=new nt({classList:["og-editor_toolbar-button"],icon:'<svg class="svg-icon" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M426.666667 170.666667H170.666667c-47.146667 0-84.906667 38.186667-84.906667 85.333333L85.333333 768c0 47.146667 38.186667 85.333333 85.333334 85.333333h682.666666c47.146667 0 85.333333-38.186667 85.333334-85.333333V341.333333c0-47.146667-38.186667-85.333333-85.333334-85.333333H512l-85.333333-85.333333z" /></svg>',title:"Load 3D object"});return r.appendTo(i),r.events.on("click",this._onLoadClick),this._object3dCollectionView.appendTo(this.container),this._object3dCollectionView.events.on("select",s=>{this.events.dispatch(this.events.select,s)}),this}}const sc=["add","remove"];class Kr{constructor(e={}){this.events=le(sc,this),this._items=Kr.createItemsMap(e.collection||[])}static createItemsMap(e){let t=new Map;for(let i=0;i<e.length;i++)t.set(e[i].name,e[i]);return t}getItem(e){return this._items.get(e)}addItem(e,t=!1){this._items.has(e.name)&&!t||(this._items.set(e.name,e),this.events.dispatch(this.events.add,e))}getItems(){return Array.from(this._items,([e,t])=>t)}}class Jr extends ee{constructor(e={}){super({name:"CameraFrameComposer",autoActivate:!0,...e}),this._onPostdraw=()=>{for(let t=0,i=this._frameHandlers.length;t<i;t++)this._frameHandlers[t].frame()},this._cameraLayer=new ut({scaleByDistance:[100,1e6,1],pickingEnabled:!1}),this._cameraScene=new ot("CameraScene"),this._frameHandlers=e.frameHandlers||[]}get frameHandlers(){return[...this._frameHandlers]}add(e){e.addTo(this),this._cameraLayer.add(e.cameraEntity)}oninit(){super.oninit(),this._cameraLayer.addTo(this._cameraScene)}activate(){super.activate(),this.renderer&&(this.renderer.events.on("postdraw",this._onPostdraw),this.renderer.addNode(this._cameraScene))}deactivate(){super.deactivate(),this.renderer&&(this.renderer.events.off("postdraw",this._onPostdraw),this.renderer.removeNode(this._cameraScene))}}let nc=Z.createFrustum();class Ha{constructor(e){this.camera=e.camera,this.frameBuffer=e.frameBuffer,this.frameHandler=e.frameHandler||null,this._composer=null,this._composerIndex=-1,this.showFrustum=e.showFrustum==null||e.showFrustum,this.cameraEntity=new V({visibility:!0,scale:this.frustumScale,geoObject:{tag:"frustum",color:"rgba(0,255,0,0.20)",object3d:nc}}),this.frameBuffer.init()}get frustumScale(){return Z.getFrustumScaleByCameraAspectRatio(1e3,this.camera.getViewAngle(),this.camera.getAspectRatio())}addTo(e){this._composer||(this._composer=e,this._composerIndex=e.frameHandlers.length,this._composer._frameHandlers.push(this))}remove(){this._composer&&(this._composer._frameHandlers.splice(this._composerIndex,1),this._composer=null,this._composerIndex=-1)}frame(){if(this.frameHandler&&this.frameBuffer.handler.gl&&(this.frameHandler(this),this.showFrustum)){let e=this.camera,t=Z.getFrustumScaleByCameraAngles(100,e.horizontalViewAngle,e.verticalViewAngle);this.cameraEntity.setScale3v(t),this.cameraEntity.setCartesian3v(e.eye),this.cameraEntity.setAbsolutePitch(e.getAbsolutePitch()),this.cameraEntity.setAbsoluteYaw(e.getAbsoluteYaw()),this.cameraEntity.setAbsoluteRoll(e.getAbsoluteRoll())}}}function Ht(a){let e=1/Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);a[0]*=e,a[1]*=e,a[2]*=e,a[3]*=e}class Va{constructor(e={}){this._pickingColorU=new Float32Array([0,0,0]),this._f=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],this.projectionMatrix=new ne,this.inverseProjectionMatrix=new ne,this.projectionViewMatrix=new ne,this.projectionViewRTEMatrix=new ne,this.inverseProjectionViewMatrix=new ne,this.left=0,this.right=0,this.bottom=0,this.top=0,this.near=0,this.far=0,this.cameraFrustumIndex=e.cameraFrustumIndex!=null?e.cameraFrustumIndex:-1,this.setProjectionMatrix(e.fov||30,e.aspect||1,e.near||1,e.far||1e3)}getRightPlane(){return this._f[0]}getLeftPlane(){return this._f[1]}getBottomPlane(){return this._f[2]}getTopPlane(){return this._f[3]}getBackwardPlane(){return this._f[4]}getForwardPlane(){return this._f[5]}getProjectionViewMatrix(){return this.projectionViewMatrix._m}getProjectionViewRTEMatrix(){return this.projectionViewRTEMatrix._m}getProjectionMatrix(){return this.projectionMatrix._m}getInverseProjectionMatrix(){return this.inverseProjectionMatrix._m}setProjectionMatrix(e,t,i,r,s,n=10){if(s){let o=n*Math.tan(e*Xe),l=o*t;this._setFrustumParams(o,l,i,r),this.projectionMatrix.setOrthographic(this.left,this.right,this.bottom,this.top,this.near,this.far)}else{let o=i*Math.tan(e*Xe),l=o*t;this._setFrustumParams(o,l,i,r),this.projectionMatrix.setPerspective(this.left,this.right,this.bottom,this.top,this.near,this.far)}this.projectionMatrix.inverseTo(this.inverseProjectionMatrix)}_setFrustumParams(e,t,i,r){this.top=e,this.right=t,this.bottom=-this.top,this.left=-this.right,this.near=i,this.far=r}setProjectionViewRTEMatrix(e){this.projectionViewRTEMatrix=this.projectionMatrix.mul(e)}setViewMatrix(e){this.projectionViewMatrix=this.projectionMatrix.mul(e),this.projectionViewMatrix.inverseTo(this.inverseProjectionViewMatrix);let t=this.projectionViewMatrix._m;this._f[0][0]=t[3]-t[0],this._f[0][1]=t[7]-t[4],this._f[0][2]=t[11]-t[8],this._f[0][3]=t[15]-t[12],Ht(this._f[0]),this._f[1][0]=t[3]+t[0],this._f[1][1]=t[7]+t[4],this._f[1][2]=t[11]+t[8],this._f[1][3]=t[15]+t[12],Ht(this._f[1]),this._f[2][0]=t[3]+t[1],this._f[2][1]=t[7]+t[5],this._f[2][2]=t[11]+t[9],this._f[2][3]=t[15]+t[13],Ht(this._f[2]),this._f[3][0]=t[3]-t[1],this._f[3][1]=t[7]-t[5],this._f[3][2]=t[11]-t[9],this._f[3][3]=t[15]-t[13],Ht(this._f[3]),this._f[4][0]=t[3]-t[2],this._f[4][1]=t[7]-t[6],this._f[4][2]=t[11]-t[10],this._f[4][3]=t[15]-t[14],Ht(this._f[4]),this._f[5][0]=t[3]+t[2],this._f[5][1]=t[7]+t[6],this._f[5][2]=t[11]+t[10],this._f[5][3]=t[15]+t[14],Ht(this._f[5])}containsPoint(e){for(let t=0;t<6;t++)if(e.dotArr(this._f[t])+this._f[t][3]<=0)return!1;return!0}containsSphereBottomExc(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[0])+i[0][3]<=t||e.center.dotArr(i[1])+i[1][3]<=t||e.center.dotArr(i[3])+i[3][3]<=t||e.center.dotArr(i[4])+i[4][3]<=t||e.center.dotArr(i[5])+i[5][3]<=t)}containsSphereButtom(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[2])+i[2][3]<=t)}containsSphere(e){let t=-e.radius,i=this._f;return!(e.center.dotArr(i[0])+i[0][3]<=t||e.center.dotArr(i[1])+i[1][3]<=t||e.center.dotArr(i[2])+i[2][3]<=t||e.center.dotArr(i[3])+i[3][3]<=t||e.center.dotArr(i[4])+i[4][3]<=t||e.center.dotArr(i[5])+i[5][3]<=t)}containsSphere2(e,t){let i=-t;return!(e.dotArr(this._f[0])+this._f[0][3]<=i||e.dotArr(this._f[1])+this._f[1][3]<=i||e.dotArr(this._f[2])+this._f[2][3]<=i||e.dotArr(this._f[3])+this._f[3][3]<=i||e.dotArr(this._f[4])+this._f[4][3]<=i||e.dotArr(this._f[5])+this._f[5][3]<=i)}containsBox(e){let t,i,r=!0;for(let s=0;s<6;s++){t=0,i=0;for(let n=0;n<8&&(i===0||t===0);n++)e.vertices[n].dotArr(this._f[s])+this._f[s][3]<0?t++:i++;if(i===0)return!1;t>0&&(r=!0)}return r}}const K=class{};K.Linear=a=>a,K.QuadIn=a=>a*a,K.QuadOut=a=>1-(1-a)*(1-a),K.QuadInOut=a=>a<.5?2*a*a:1-Math.pow(-2*a+2,2)/2,K.CubicIn=a=>a*a*a,K.CubicOut=a=>1-Math.pow(1-a,3),K.CubicInOut=a=>a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,K.QuartIn=a=>a*a*a*a,K.QuartOut=a=>1-Math.pow(1-a,4),K.QuartInOut=a=>a<.5?8*a*a*a*a:1-Math.pow(-2*a+2,4)/2,K.QuintIn=a=>a*a*a*a*a,K.QuintOut=a=>1-Math.pow(1-a,5),K.QuintInOut=a=>a<.5?16*a*a*a*a*a:1-Math.pow(-2*a+2,5)/2,K.SineIn=a=>1-Math.cos(a*Math.PI/2),K.SineOut=a=>Math.sin(a*Math.PI/2),K.SineInOut=a=>-(Math.cos(Math.PI*a)-1)/2,K.ExpoIn=a=>a===0?0:Math.pow(2,10*a-10),K.ExpoOut=a=>a===1?1:1-Math.pow(2,-10*a),K.ExpoInOut=a=>a===0?0:a===1?1:a<.5?Math.pow(2,20*a-10)/2:(2-Math.pow(2,-20*a+10))/2,K.CircIn=a=>1-Math.sqrt(1-Math.pow(a,2)),K.CircOut=a=>Math.sqrt(1-Math.pow(a-1,2)),K.CircInOut=a=>a<.5?(1-Math.sqrt(1-Math.pow(2*a,2)))/2:(Math.sqrt(1-Math.pow(-2*a+2,2))+1)/2,K.BackIn=a=>2.70158*a*a*a-1.70158*a*a,K.BackOut=a=>1+2.70158*Math.pow(a-1,3)+1.70158*Math.pow(a-1,2),K.BackInOut=a=>{const e=2.5949095;return a<.5?Math.pow(2*a,2)*(7.189819*a-e)/2:(Math.pow(2*a-2,2)*((e+1)*(2*a-2)+e)+2)/2},K.ElasticIn=a=>{const e=2*Math.PI/3;return a===0?0:a===1?1:-Math.pow(2,10*a-10)*Math.sin((10*a-10.75)*e)},K.ElasticOut=a=>{const e=2*Math.PI/3;return a===0?0:a===1?1:Math.pow(2,-10*a)*Math.sin((10*a-.75)*e)+1},K.ElasticInOut=a=>{const e=2*Math.PI/4.5;return a===0?0:a===1?1:a<.5?-Math.pow(2,20*a-10)*Math.sin((20*a-11.125)*e)/2:Math.pow(2,-20*a+10)*Math.sin((20*a-11.125)*e)/2+1},K.BounceOut=a=>a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375,K.BounceIn=a=>1-K.BounceOut(1-a),K.BounceInOut=a=>a<.5?.5*(1-K.BounceOut(1-2*a)):.5*(K.BounceOut(2*a-1)+1);let ac=K;const oc=["viewchange","moveend","flystart","flyend","flystop"],Ua=ac.CubicInOut,Ga=class $o{constructor(e={}){if(this.__id=$o.__counter__++,this.events=le(oc,this),this._isOrthographic=e.isOrthographic??!1,this._focusDistance=e.focusDistance!=null?e.focusDistance:10,this._width=e.width||1,this._height=e.height||1,this.eye=e.eye||new m,this.eyeHigh=new Float32Array(3),this.eyeLow=new Float32Array(3),this._viewAngle=e.viewAngle||47,this._horizontalViewAngle=0,this._viewMatrix=new ne,this._viewMatrixRTE=new ne,this._normalMatrix=new vt,this._r=new m(1,0,0),this._u=new m(0,1,0),this._b=new m(0,0,1),this._f=this._b.negateTo(),this._pr=this._r.clone(),this._pu=this._u.clone(),this._pb=this._b.clone(),this._peye=this.eye.clone(),this.isMoving=!1,this._flight=null,this._completeCallback=null,this._frameCallback=null,this._flying=!1,this._tanViewAngle_hrad=0,this._tanViewAngle_hradOneByHeight=0,this.frustums=[],this.frustumColors=[],e.frustums)for(let t=0,i=e.frustums.length;t<i;t++){let r=e.frustums[t],s=new Va({fov:this._viewAngle,aspect:this.getAspectRatio(),near:r[0],far:r[1]});s.cameraFrustumIndex=this.frustums.length,this.frustums.push(s),this.frustumColors.push(s._pickingColorU[0],s._pickingColorU[1],s._pickingColorU[2])}else{let t=.1,i=1e3,r=new Va({fov:this._viewAngle,aspect:this.getAspectRatio(),near:t,far:i});r.cameraFrustumIndex=this.frustums.length,this.frustums.push(r),this.frustumColors.push(r._pickingColorU[0],r._pickingColorU[1],r._pickingColorU[2])}this.FARTHEST_FRUSTUM_INDEX=this.frustums.length-1,this.currentFrustumIndex=0,this.frustumColorIndex=0,this.isFirstPass=!1,this._projSizeConst=0,this.set(e.eye||new m(0,0,1),e.look||new m,e.up||new m(0,1,0))}get isOrthographic(){return this._isOrthographic}set isOrthographic(e){this._isOrthographic!==e&&(this._isOrthographic=e,this.refresh())}get focusDistance(){return this._focusDistance}set focusDistance(e){e!==this._focusDistance&&(this._focusDistance=e,this._isOrthographic&&this.refresh())}get id(){return this.__id}flyCartesian(e,t={}){this.stopFlying(),t.look=t.look||m.ZERO,t.up=t.up||m.UP,t.duration=t.duration||800;const i=t.ease||Ua;this._completeCallback=t.completeCallback||(()=>{}),this._frameCallback=t.frameCallback||(()=>{}),t.startCallback&&t.startCallback.call(this);let r=this.eye.clone(),s=this._u,n=this._b,o=t.up,l=e.clone(),h=m.sub(e,t.look),c=o.cross(h);h.normalize(),c.normalize();let d=h.cross(c);this._flight={fly:u=>{let g=1-i(u),f=r.smerp(l,g),p=s.smerp(d,g),_=m.add(f,n.smerp(h,g).negateTo()),v=new m(f.x-_.x,f.y-_.y,f.z-_.z),x=p.cross(v);v.normalize(),x.normalize();let y=v.cross(x);return{eye:f,n:v,u:x,v:y}},duration:t.duration,startedAt:Date.now()},this._flying=!0,this.events.dispatch(this.events.flystart,this)}stopFlying(){this._flying&&(this._flying=!1,this._flight=null,this._frameCallback=null,this.events.dispatch(this.events.flystop,this))}checkFly(){if(this._flying&&this._flight!==null){let e=Math.min((Date.now()-this._flight.startedAt)/this._flight.duration,1);const t=this._flight.fly(e);this.eye=t.eye,this._r=t.u,this._u=t.v,this._b=t.n,this._f.set(-this._b.x,-this._b.y,-this._b.z),this._frameCallback&&this._frameCallback(),this.update(),e>=1&&(this.stopFlying(),this._completeCallback&&(this.events.dispatch(this.events.flyend,this),this._completeCallback(),this._completeCallback=null))}}isFlying(){return this._flying}checkMoveEnd(){let e=this._r,t=this._u,i=this._b,r=this.eye;this._peye.equal(r)&&this._pr.equal(e)&&this._pu.equal(t)&&this._pb.equal(i)?(this.isMoving&&this.events.dispatch(this.events.moveend,this),this.isMoving=!1):this.isMoving=!0,this._pr.copy(e),this._pu.copy(t),this._pb.copy(i),this._peye.copy(r)}bindFrustumsPickingColors(e){for(let t=0;t<this.frustums.length;t++)e.assignPickingColor(this.frustums[t])}_init(e){this._setProj(this._viewAngle,this.getAspectRatio()),this.set(e.eye||new m(0,0,1),e.look||new m,e.up||new m(0,1,0))}getUp(){return this._u.clone()}getDown(){return this._u.negateTo()}getRight(){return this._r.clone()}getLeft(){return this._r.negateTo()}getForward(){return this._f.clone()}getBackward(){return this._b.clone()}update(){let e=this._r,t=this._u,i=this._b,r=this.eye;m.doubleToTwoFloat32Array(r,this.eyeHigh,this.eyeLow),this._viewMatrix.set([e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,-r.dot(e),-r.dot(t),-r.dot(i),1]),this._viewMatrixRTE.set([e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1]);for(let s=0,n=this.frustums.length;s<n;s++)this.frustums[s].setViewMatrix(this._viewMatrix),this.frustums[s].setProjectionViewRTEMatrix(this._viewMatrixRTE);this.events.dispatch(this.events.viewchange,this)}refresh(){this._setProj(this._viewAngle,this.getAspectRatio()),this.update()}get width(){return this._width}get height(){return this._height}setViewportSize(e,t){this._width=e,this._height=t,this.refresh()}getAspectRatio(){return this._width/this._height}_setProj(e,t){this._viewAngle=e;for(let s=0,n=this.frustums.length;s<n;s++){let o=this.frustums[s];o.setProjectionMatrix(e,t,o.near,o.far,this._isOrthographic,this._focusDistance)}var i,r;this._horizontalViewAngle=(i=e,r=t,ir*Math.atan(Math.tan(Xe*i)*r)),this._updateViewportParameters()}_updateViewportParameters(){this._tanViewAngle_hrad=Math.tan(this._viewAngle*Xe),this._tanViewAngle_hradOneByHeight=this._tanViewAngle_hrad*(1/this._height),this._projSizeConst=Math.min(this._width<512?512:this._width,this._height<512?512:this._height)/(this._viewAngle*U)}setViewAngle(e){this._viewAngle=e,this.refresh()}getViewAngle(){return this._viewAngle}get viewAngle(){return this._viewAngle}get verticalViewAngle(){return this._viewAngle}get horizontalViewAngle(){return this._horizontalViewAngle}set(e,t,i){return this.eye.x=e.x,this.eye.y=e.y,this.eye.z=e.z,t=t||this._b,i=i||this._u,this._b.x=e.x-t.x,this._b.y=e.y-t.y,this._b.z=e.z-t.z,this._r.copy(i.cross(this._b)),this._b.normalize(),this._r.normalize(),this._u.copy(this._b.cross(this._r)),this._f.set(-this._b.x,-this._b.y,-this._b.z),this}look(e,t){this._b.set(this.eye.x-e.x,this.eye.y-e.y,this.eye.z-e.z),this._r.copy((t||this._u).cross(this._b)),this._b.normalize(),this._f.set(-this._b.x,-this._b.y,-this._b.z),this._r.normalize(),this._u.copy(this._b.cross(this._r))}slide(e,t,i){this.eye.x+=e*this._r.x+t*this._u.x+i*this._b.x,this.eye.y+=e*this._r.y+t*this._u.y+i*this._b.y,this.eye.z+=e*this._r.z+t*this._u.z+i*this._b.z}setRoll(e){let t=Math.cos(e),i=Math.sin(e),r=this._r.clone();this._r.set(t*r.x-i*this._u.x,t*r.y-i*this._u.y,t*r.z-i*this._u.z),this._u.set(i*r.x+t*this._u.x,i*r.y+t*this._u.y,i*r.z+t*this._u.z)}setPitch(e){let t=Math.cos(e),i=Math.sin(e),r=this._b;this._b.set(t*r.x-i*this._u.x,t*r.y-i*this._u.y,t*r.z-i*this._u.z),this._u.set(i*r.x+t*this._u.x,i*r.y+t*this._u.y,i*r.z+t*this._u.z)}setYaw(e){let t=Math.cos(e),i=Math.sin(e),r=this._r;this._r.set(t*r.x-i*this._b.x,t*r.y-i*this._b.y,t*r.z-i*this._b.z),this._b.set(i*r.x+t*this._b.x,i*r.y+t*this._b.y,i*r.z+t*this._b.z)}setPitchYawRoll(e,t,i){let r=new O;r.setPitchYawRoll(e,t,i),this.setRotation(r)}getPitch(){return this.getRotation().getPitch()}getYaw(){return this.getRotation().getYaw()}getRoll(){return this.getRotation().getRoll()}getAbsolutePitch(){return this.getRotation().getPitch()}getAbsoluteYaw(){return this.getRotation().getYaw()}getAbsoluteRoll(){return this.getRotation().getRoll()}getRotation(){return O.getLookRotation(this._f,this._u).conjugate()}setRotation(e,t,i,r){e.mulVec3Res(t||new m(0,1,0),this._u),e.mulVec3Res(i||new m(1,0,0),this._r),e.mulVec3Res(r||new m(0,0,1),this._b),this._f.set(-this._b.x,-this._b.y,-this._b.z)}rotate(e){e.mulVec3Res(this._u,this._u),e.mulVec3Res(this._r,this._r),e.mulVec3Res(this._b,this._b),this._f.set(-this._b.x,-this._b.y,-this._b.z)}unproject2v(e){return this.unproject(e.x,e.y)}unproject(e,t,i,r){let s=.5*this._width,n=.5*this._height,o=(e-s)/s,l=-(t-n)/n,h=this.frustums[0];if(this.isOrthographic){if(i){let c=.5*(h.right-h.left)*o,d=.5*(h.top-h.bottom)*l,u=this.getUp().scale(d),g=this.getRight().scale(c),f=u.addA(g),p=this.eye.add(f),_=this.getForward(),v=p.addA(_.scaleTo(i));return r&&r.copy(v),v.sub(this.eye).normalize()}return this.getForward()}{let c=h.inverseProjectionViewMatrix,d=c.mulVec4(new te(o,l,-1,1)).affinity();return c.mulVec4(new te(o,l,0,1)).affinity().subA(d).toVec3().normalize()}}project3v(e){return this.project(e.x,e.y,e.z)}project(e,t,i){let r=this.frustums[0].projectionViewMatrix.mulVec4(new te(e,t,i,1));return new N((1+r.x/r.w)*this._width*.5,(1-r.y/r.w)*this._height*.5)}rotateAround(e,t=!1,i=m.ZERO,r=m.UP){r=t?this._u:r;let s=ne.getRotation(e,r),n=ne.getRotationAroundPoint(e,i,r);this.eye=n.mulVec3(this.eye),this._u=s.mulVec3(this._u).normalize(),this._r=s.mulVec3(this._r).normalize(),this._b=s.mulVec3(this._b).normalize(),this._f.set(-this._b.x,-this._b.y,-this._b.z)}rotateHorizontal(e,t,i,r){this.rotateAround(e,t,i,r)}rotateVertical(e,t){this.rotateAround(e,!1,t,this._r)}projectedSize(e,t){return Math.atan(t/this.eye.distance(e))*this._projSizeConst}getViewMatrix(){return this._viewMatrix._m}getNormalMatrix(){return this._normalMatrix._m}setCurrentFrustum(e){this.currentFrustumIndex=e,this.frustumColorIndex=10*(e+1)/255,this.isFirstPass=e===this.FARTHEST_FRUSTUM_INDEX}getCurrentFrustum(){return this.currentFrustumIndex}containsSphere(e){for(let t=0;t<this.frustums.length;t++)if(this.frustums[t].containsSphere(e))return!0;return!1}get frustum(){return this.frustums[this.currentFrustumIndex]}getProjectionMatrix(){return this.frustum.projectionMatrix._m}getProjectionViewMatrix(){return this.frustum.projectionViewMatrix._m}getProjectionViewRTEMatrix(){return this.frustum.projectionViewRTEMatrix._m}getInverseProjectionViewMatrix(){return this.frustum.inverseProjectionViewMatrix._m}getInverseProjectionMatrix(){return this.frustum.inverseProjectionMatrix._m}viewDistance(e,t=1e4){let i=e.add(this.getBackward().scaleTo(t));this.set(i,e),this.update()}copy(e){this.eye.copy(e.eye),this._r.copy(e._r),this._u.copy(e._u),this._b.copy(e._b),this._f.copy(e._f),this._width=e.width,this._height=e.height,this.setViewAngle(e.viewAngle),this.update()}getAltitude(){return this.eye.y}};Ga.__counter__=0;let es=Ga;class ja extends es{constructor(e,t={}){super({...t,frustums:t.frustums||[[1,100.075],[100,1000.075],[1e3,101e4],[1e6,1e9]]}),this.planet=e,this.minAltitude=t.minAltitude||1,this.maxAltitude=t.maxAltitude||2e7,this._lonLat=this.planet.ellipsoid.cartesianToLonLat(this.eye),this._lonLatMerc=this._lonLat.forwardMercator(),this._terrainAltitude=this._lonLat.height,this._terrainPoint=new m,this._insideSegment=null,this.slope=0,this._keyLock=new ci,this._flight=null,this._completeCallback=null,this._frameCallback=null,this._flying=!1,this._checkTerrainCollision=!0,this.eyeNorm=this.eye.getNormal()}setTerrainCollisionActivity(e){this._checkTerrainCollision=e}update(){this.events.stopPropagation();let e=this.maxAltitude+this.planet.ellipsoid.getEquatorialSize();this.eye.length()>e&&this.eye.copy(this.eye.getNormal().scale(e)),super.update(),this.updateGeodeticPosition(),this.eyeNorm=this.eye.getNormal(),this.slope=this._b.dot(this.eyeNorm),this.events.dispatch(this.events.viewchange,this)}updateGeodeticPosition(){this.planet.ellipsoid.cartesianToLonLatRes(this.eye,this._lonLat),Math.abs(this._lonLat.lat)<=de&&A.forwardMercatorRes(this._lonLat,this._lonLatMerc)}setAltitude(e){let t=this._terrainPoint,i=this.planet.ellipsoid.getSurfaceNormal3v(this.eye);this.eye.x=i.x*e+t.x,this.eye.y=i.y*e+t.y,this.eye.z=i.z*e+t.z,this._terrainAltitude=e}getAltitude(){return this._terrainAltitude}setLonLat(e,t,i){this.stopFlying(),this._lonLat.set(e.lon,e.lat,e.height||this._lonLat.height);let r=this.planet.ellipsoid,s=r.lonLatToCartesian(this._lonLat),n=t?r.lonLatToCartesian(t):m.ZERO;this.set(s,n,i||s.getNormal()),this.update()}getLonLat(){return this._lonLat}getHeight(){return this._lonLat.height}getExtentPosition(e,t){t=t||0;let i=e.getNorth(),r=e.getSouth(),s=e.getEast(),n=e.getWest();n>s&&(s+=360);let o=this.planet.ellipsoid,l=new A(s,i),h=o.lonLatToCartesian(l);l.lat=r;let c=o.lonLatToCartesian(l);l.lon=n;let d=o.lonLatToCartesian(l);l.lat=i;let u=o.lonLatToCartesian(l),g=m.sub(h,d).scale(.5).addA(d),f=g.length();f<1e-6&&(l.lon=.5*(s+n),l.lat=.5*(i+r),g=o.lonLatToCartesian(l)),u.subA(g),c.subA(g),h.subA(g),d.subA(g);let p=g.getNormal(),_=p.cross(m.NORTH).normalize(),v=_.cross(p).normalize(),x=Math.max(Math.abs(v.dot(u)),Math.abs(v.dot(c)),Math.abs(v.dot(h)),Math.abs(v.dot(d))),y=Math.max(Math.abs(_.dot(u)),Math.abs(_.dot(c)),Math.abs(_.dot(h)),Math.abs(_.dot(d))),w=Math.tan(this._viewAngle*U*.5),b=this.getAspectRatio()*w,E=Math.max(y/b,x/w);return g.normalize(),g.scale(f+E+t),g}viewExtent(e,t){this.stopFlying(),this.set(this.getExtentPosition(e,t),m.ZERO,m.NORTH),this.update()}flyExtent(e,t,i={}){i.look=m.ZERO,this.flyCartesian(this.getExtentPosition(e,t),i)}viewDistance(e,t=1e4){let i=this.eye.add(this.getForward().scaleTo(t)),r=O.getRotationBetweenVectors(i.getNormal(),e.getNormal());if(r.isZero()){let s=e.add(this.getBackward().scaleTo(t));this.set(s,e)}else{let s=e.add(r.mulVec3(this.getBackward()).scale(t)),n=r.mulVec3(this.getUp());this.set(s,e,n)}this.update()}flyLonLat(e,t={}){let i=new A(e.lon,e.lat,e.height||this._lonLat.height);this.flyCartesian(this.planet.ellipsoid.lonLatToCartesian(i),t)}flyDistance(e,t=1e4,i={}){let r=this.eye.add(this.getForward().scaleTo(t)),s=O.getRotationBetweenVectors(r.getNormal(),e.getNormal());if(s.isZero()){let n=e.add(this.getBackward().scaleTo(t));this.set(n,e)}else{let n=e.add(s.mulVec3(this.getBackward()).scale(t)),o=s.mulVec3(this.getUp());i.look=e,i.up=o,this.flyCartesian(n,i)}}flyCartesian(e,t={}){this.stopFlying(),t.preventLock||(this.planet.layerLock.lock(this._keyLock),this.planet.terrainLock.lock(this._keyLock),this.planet.normalMapCreator.lock(this._keyLock)),t.amplitude=t.amplitude!=null?t.amplitude:1,t.look=t.look||m.ZERO,t.up=t.up||m.NORTH,t.duration=t.duration||800;const i=t.ease||Ua;this._completeCallback=t.completeCallback||(()=>{}),this._frameCallback=t.frameCallback||(()=>{}),t.startCallback&&t.startCallback.call(this),t.look instanceof A&&(t.look=this.planet.ellipsoid.lonLatToCartesian(t.look));let r=this.eye.clone(),s=this._u,n=this._b,o=this.planet.ellipsoid.cartesianToLonLat(e),l=t.up,h=this.planet.ellipsoid.lonLatToCartesian(new A(o.lon,o.lat,0)),c=m.sub(e,t.look),d=l.cross(c);c.normalize(),d.normalize();let u=c.cross(d),g=r.getNormal(),f=h.getNormal(),p=1-g.dot(f),_=t.amplitude*ws*Math.sqrt(p>0?p:0),v=6639613,x=Math.max(this._lonLat.height,o.height);x>v&&(v=x);let y=x+2.5*_*(v-x),w=m.ZERO;this._flight={fly:b=>{let E=i(b),C=1-E,T=r.smerp(h,C).normalize(),L=this.planet.getRayIntersectionEllipsoid(new H(w,T)),M=this._lonLat.height*C*C*C+3*y*C*C*E+3*y*C*E*E+o.height*E*E*E,R=L.addA(T.scale(M)),z=s.smerp(u,C),F=m.add(R,n.smerp(c,C).negateTo()),P=new m(R.x-F.x,R.y-F.y,R.z-F.z),D=z.cross(P);P.normalize(),D.normalize();let k=P.cross(D);return{eye:R,n:P,u:D,v:k}},duration:t.duration,startedAt:Date.now()},this._flying=!0,this.events.dispatch(this.events.flystart,this)}stopFlying(){this._flying&&(this.planet.layerLock.free(this._keyLock),this.planet.terrainLock.free(this._keyLock),this.planet.normalMapCreator.free(this._keyLock),super.stopFlying())}rotateLeft(e,t){this.rotateHorizontal(e,t!==!0,m.ZERO),this.update()}rotateRight(e,t){this.rotateHorizontal(-e,t!==!0,m.ZERO),this.update()}rotateUp(e){this.rotateVertical(e,m.ZERO),this.update()}rotateDown(e){this.rotateVertical(-e,m.ZERO),this.update()}rotateVertical(e,t,i=0){let r=new ne().setRotation(this._r,e),s=new ne().setIdentity().translate(t),n=new ne().setIdentity().translate(t.negateTo()),o=s.mul(r).mul(n).mulVec3(this.eye),l=r.mulVec3(this._u).normalize(),h=r.mulVec3(this._r).normalize(),c=r.mulVec3(this._b).normalize(),d=o.getNormal(),u=c.dot(d);if(i){let g=u-this.slope;if(u<i&&g<0)return;(u>.1&&l.dot(d)>0||this.slope<=.1||this._u.dot(this.eye.getNormal())<=0)&&(this.eye=o,this._u=l,this._r=h,this._b=c,this._f.set(-c.x,-c.y,-c.z))}else this.eye=o,this._u=l,this._r=h,this._b=c,this._f.set(-c.x,-c.y,-c.z)}checkTerrainCollision(){if(this._terrainAltitude=this._lonLat.height,this._insideSegment&&this._insideSegment.planet)return this._terrainAltitude=this._insideSegment.getTerrainPoint(this.eye,this._insideSegment.getInsideLonLat(this),this._terrainPoint),this._terrainAltitude<this.minAltitude&&this._checkTerrainCollision&&this.setAltitude(this.minAltitude),this._terrainPoint}getSurfaceVisibleDistance(e){let t=this.planet.ellipsoid.equatorialSize;return t*Math.acos(t/(t+this._lonLat.height+e))}getHeading(){let e=this.eye.getNormal(),t=m.proj_b_to_plane(this.slope>=.97?this.getUp():this.getForward(),e).normalize(),i=m.proj_b_to_plane(m.NORTH,e).normalize(),r=Math.sign(e.dot(t.cross(i)))*Math.acos(t.dot(i))*J;return r<0?360+r:r}isVisible(e){let t=this.eye.length();return this.eye.distance(e)<Math.sqrt(t*t-this.planet.ellipsoid.equatorialSizeSqr)}getPitch(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getPitch()}getYaw(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getYaw()}getRoll(){return this.planet.getFrameRotation(this.eye).conjugate().inverse().mul(this.getRotation()).getRoll()}setPitch(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(e,this.getYaw(),this.getRoll(),t),this.setRotation(i)}setYaw(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(this.getPitch(),e,this.getRoll(),t),this.setRotation(i)}setRoll(e){let t=this.planet.getFrameRotation(this.eye),i=new O;i.setPitchYawRoll(this.getPitch(),this.getYaw(),e,t),this.setRotation(i)}setPitchYawRoll(e,t,i){let r=this.planet.getFrameRotation(this.eye),s=new O;s.setPitchYawRoll(e,t,i,r).conjugate(),this.setRotation(s)}}const qa=class Xo{constructor(e,t={}){this.handler=e,this.__id=Xo.__counter__++,this._fbo=null,this._width=t.width||e.canvas.width,this._height=t.height||e.canvas.height,this._depthComponent=t.depthComponent!=null?t.depthComponent:"DEPTH_COMPONENT16",this._useDepth=t.useDepth==null||t.useDepth,this._active=!1,this._size=t.size||1,this._depthRenderbuffer=null,this._filter=t.filter||"NEAREST"}get width(){return this._width}get height(){return this._height}setSize(e,t,i=!1){this._width=e,this._height=t,this._active&&this.handler.gl.viewport(0,0,this._width,this._height),(this._useDepth||i)&&(this.destroy(),this.init())}init(){}destroy(){}isComplete(){let e=this.handler.gl;return e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE}checkStatus(){let e=this.handler.gl;return e.checkFramebufferStatus(e.FRAMEBUFFER)}activate(){let e=this.handler.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo),e.viewport(0,0,this._width,this._height),this._active=!0;let t=this.handler.framebufferStack.current().data;return t&&(t._active=!1),this.handler.framebufferStack.push(this),this}deactivate(){let e=this.handler,t=e.gl;t.bindFramebuffer(t.FRAMEBUFFER,null),this._active=!1;let i=this.handler.framebufferStack.popPrev();i?(t.bindFramebuffer(t.FRAMEBUFFER,i._fbo),t.viewport(0,0,i._width,i._height)):t.viewport(0,0,e.canvas.width,e.canvas.height)}isEqual(e){return!!e&&this.__id===e.__id}};qa.__counter__=0;let Ya=qa;class _i{constructor(e=256,t=256){this._canvas=document.createElement("canvas"),this._canvas.width=e,this._canvas.height=t,this._context=this._canvas.getContext("2d",{willReadFrequently:!0})}getCanvas(){return this._canvas}getContext(){return this._context}fillEmpty(){let e=this._context.getImageData(0,0,this._canvas.width,this._canvas.height),t=e.data;for(let i=0,r=t.length;i<r;i+=4)t[i]=t[i+1]=t[i+2]=t[i+3]=0;this._context.putImageData(e,0,0)}fill(e){this._context.fillStyle=e,this._context.fill()}getData(){return this._context.getImageData(0,0,this._canvas.width,this._canvas.height).data}fillColor(e){this._context.fillStyle=e,this._context.fillRect(0,0,this._canvas.width,this._canvas.height)}setData(e){let t=this._context.createImageData(this._canvas.width,this._canvas.height);t.data.set(e),this._context.putImageData(t,0,0)}resize(e,t){this._canvas.width=e,this._canvas.height=t,this._context=this._canvas.getContext("2d")}drawImage(e,t,i,r,s){this._context.drawImage(e,t||0,i||0,r||e.width,s||e.height)}getImage(){let e=new Image;return e.width=this.getWidth(),e.height=this.getHeight(),e.src=this._canvas.toDataURL("image/png"),e}getTextWidth(e){let t=this._context.measureText(e);return Math.round(t.width)}drawText(e,t=0,i=14,r="normal 14px Verdana",s="black"){this._context.fillStyle=s,this._context.font=r,this._context.fillText(e,t,i)}getWidth(){return this._canvas.width}getHeight(){return this._canvas.height}load(e,t){let i=new Image,r=this;i.onload=function(){r.resize(i.width,i.height),r._context.drawImage(i,0,0,i.width,i.height),t&&t(i)},i.src=e}openImage(){let e=this.getImage(),t="<!DOCTYPE html>";t+="<html>",t+="<head><title>Print</title></head>",t+="<body>",t+='<img src="'+e.src+'">',t+="</body>",t+="</html>";let i=window.open("","","width="+e.width+"px ,height="+e.height+"px");i&&(i.document.open(),i.document.write(t),i.document.close(),i.focus())}destroy(){this._canvas.width=1,this._canvas.height=1,this._canvas=null,this._context=null}}const Wa={UNSIGNED_BYTE:Uint8Array,FLOAT:Float32Array};class Se extends Ya{constructor(e,t={}){super(e,t),this.readPixelBuffersAsync=i=>{const r=this.handler.gl;if(this._skipFrame)return;this._skipFrame=!0;let s=this.width,n=this.height,o=this.pixelBuffers;this.activate();for(let d=0;d<o.length;d++){let u=o[d];r.bindBuffer(r.PIXEL_PACK_BUFFER,u.buffer),r.bufferData(r.PIXEL_PACK_BUFFER,u.data.byteLength,r.STREAM_READ),r.readBuffer(u.glAttachment),r.readPixels(0,0,s,n,r.RGBA,u.glType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null)}this.deactivate();const l=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);var h,c;r.flush(),(h=r,c=l,new Promise((d,u)=>{(function g(){const f=h.clientWaitSync(c,0,0);f==h.WAIT_FAILED?u():f==h.TIMEOUT_EXPIRED?requestAnimationFrame(g):d()})()})).then(()=>{this._skipFrame=!1,r.deleteSync(l);for(let d=0;d<o.length;d++){let u=o[d];u.data&&(r.bindBuffer(r.PIXEL_PACK_BUFFER,u.buffer),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,u.data))}r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i&&i(this)})},this._targets=Se.createTargets(t.targets),this._size=this._targets.length,this._renderbufferTarget=t.renderbufferTarget!=null?t.renderbufferTarget:"DEPTH_ATTACHMENT",this.textures=t.textures||new Array(this._size),this.pixelBuffers=[],this._skipFrame=!1}static createTargets(e){let t=0,i=0;return e?e.map(r=>{let s=r.attachment||"COLOR_ATTACHMENT";s==="COLOR_ATTACHMENT"&&(s="COLOR_ATTACHMENT"+t++);let n=r.type||"UNSIGNED_BYTE";return{internalFormat:r.internalFormat||"RGBA",format:r.format||"RGBA",type:n,attachment:s,filter:r.filter||"NEAREST",pixelBufferIndex:r.readAsync?i++:-1,TypeArrayConstructor:Wa[n]}}):[{internalFormat:"RGBA",format:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT0",filter:"NEAREST",pixelBufferIndex:-1,TypeArrayConstructor:Wa.UNSIGNED_BYTE}]}destroy(){let e=this.handler.gl;if(e){for(let t=0;t<this.textures.length;t++)e.deleteTexture(this.textures[t]);this.textures=new Array(this._size);for(let t=0;t<this.pixelBuffers.length;t++)this.pixelBuffers[t].data=null,e.deleteBuffer(this.pixelBuffers[t].buffer);this.pixelBuffers=[],e.deleteFramebuffer(this._fbo),e.deleteRenderbuffer(this._depthRenderbuffer),this._depthRenderbuffer=null,this._fbo=null,this._active=!1}}init(){let e=this.handler.gl;if(!e)return;this._fbo=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo);let t=[];for(let i=0;i<this._targets.length;i++){let r=this._targets[i],s=this.textures[i]||this.handler.createEmptyTexture2DExt(this._width,this._height,r.filter,r.internalFormat,r.format,r.type),n=e[r.attachment];s&&(this.bindOutputTexture(s,n),this.textures[i]=s),r.attachment!=="DEPTH_ATTACHMENT"&&t.push(n),r.pixelBufferIndex!==-1&&this._createPixelBuffer(r)}e.drawBuffers&&e.drawBuffers(t),this._useDepth&&(this._depthRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthRenderbuffer),e.renderbufferStorage(e.RENDERBUFFER,e[this._depthComponent],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e[this._renderbufferTarget],e.RENDERBUFFER,this._depthRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null)),e.bindFramebuffer(e.FRAMEBUFFER,null)}getPixelBufferData(e=0){let t=this._targets[e].pixelBufferIndex;return t!==-1?this.pixelBuffers[t].data:null}_createPixelBuffer(e){let t=this.handler.gl,i=e.pixelBufferIndex,r=this.pixelBuffers[i];r||(r=this.pixelBuffers[i]={buffer:null,data:null,glType:-1,glAttachment:-1});let s=this.width*this.height*4;r.data=null,r.data=new e.TypeArrayConstructor(s),r.buffer=t.createBuffer(),t.bindBuffer(t.PIXEL_PACK_BUFFER,r.buffer),t.bufferData(t.PIXEL_PACK_BUFFER,s,t.STREAM_READ),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),r.glType=t[e.type],r.glAttachment=t[e.attachment]}bindOutputTexture(e,t){let i=this.handler.gl;i.bindTexture(i.TEXTURE_2D,e),i.framebufferTexture2D(i.FRAMEBUFFER,t||i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.bindTexture(i.TEXTURE_2D,null)}readPixels(e,t,i,r=0,s=1,n=1){let o=this.handler.gl;o.bindFramebuffer(o.FRAMEBUFFER,this._fbo),o.readBuffer&&o.readBuffer(o.COLOR_ATTACHMENT0+r||0),o.readPixels(t*this._width,i*this._height,s,n,o.RGBA,o[this._targets[r].type],e),o.bindFramebuffer(o.FRAMEBUFFER,null)}readAllPixels(e,t=0){let i=this.handler.gl;i.bindFramebuffer(i.FRAMEBUFFER,this._fbo),i.readBuffer&&i.readBuffer(i.COLOR_ATTACHMENT0+t),i.readPixels(0,0,this._width,this._height,i.RGBA,i[this._targets[t].type],e),i.bindFramebuffer(i.FRAMEBUFFER,null)}getImage(){let e=new Uint8Array(4*this._width*this._height);this.readAllPixels(e);let t=new _i(this._width,this._height);return t.setData(e),t.getImage()}readData(e,t,i,r=0){const s=this.width,n=this.height,o=Math.floor(e*(s-1)),l=4*(Math.floor(t*(n-1))*s+o),h=this.pixelBuffers[r].data;h&&(i[0]=h[l],i[1]=h[l+1],i[2]=h[l+2],i[3]=h[l+3])}}const lc=["tick","end","start","stop"],$a=class Zo{constructor(e={}){this.__handler=null,this.active=!0,this.__id=Zo.__counter__++,this.events=le(lc,this),this.name=e.name||"",this.startDate=e.startDate||0,this.endDate=e.endDate||0;let t=e.currentDate||ji(new Date);e.startDate&&t<e.startDate&&(t=e.startDate),e.endDate&&t>e.endDate&&(t=e.endDate),this.currentDate=t,this._multiplier=e.multiplier!==void 0?e.multiplier:1,this._running=1,this.deltaTicks=0,this.active=!0,this._intervalDelay=0,this._intervalStart=0,this._intervalCallback=null}clearInterval(){this._intervalDelay=0,this._intervalStart=0,this._intervalCallback=null}setInterval(e,t){this._intervalStart=this.currentDate,this._intervalDelay=e*Er,this._intervalCallback=t}setDate(e){let t=ji(e);this.startDate&&t<this.startDate&&(t=this.startDate),this.endDate&&t>this.endDate&&(t=this.endDate),this.currentDate=t}getDate(){return Pr(this.currentDate)}reset(){this.startDate&&(this.currentDate=this.startDate)}tick(e){let t=this._multiplier*this._running;if(this.deltaTicks=e*t,this.active){let i=js(this.currentDate,this.deltaTicks);t>0?this.endDate&&i>this.endDate?(this.currentDate=this.startDate,this.events.dispatch(this.events.end,this)):this.currentDate=i:this.startDate&&i<this.startDate?(this.currentDate=this.endDate,this.events.dispatch(this.events.end,this)):this.currentDate=i,this._intervalCallback&&this.currentDate-this._intervalStart>=this._intervalDelay&&(this._intervalStart=this.currentDate,this._intervalCallback(this)),this.events.dispatch(this.events.tick,this)}}isEqual(e){return this.__id===e.__id}start(){this._running===0&&(this._running=1,this.events.dispatch(this.events.start,this))}get multiplier(){return this._multiplier}set multiplier(e){this._multiplier=e}stop(){this._running===1&&(this._running=0,this.events.dispatch(this.events.stop,this))}};$a.__counter__=0;let hc=$a;class cc{constructor(e,t){t._programController=this,this._program=t,this._handler=e,this._activated=!1}initialize(){this._handler.gl&&this._program.createProgram(this._handler.gl)}getProgram(){return this._program}activate(){if(!this._activated){this._handler.activeProgram.deactivate(),this._handler.activeProgram=this;let e=this._program;this._activated=!0,e.enableAttribArrays(),e.use()}return this}remove(){let e=this._handler.programs;e[this._program.name]&&(this._activated&&this.deactivate(),this._program.delete(),delete e[this._program.name])}deactivate(){this._program.disableAttribArrays(),this._activated=!1}isActive(){return this._activated}set(e){return this.activate(),this._program.set(e),this}drawIndexBuffer(e,t){return this._program.drawIndexBuffer(e,t),this}drawArrays(e,t){return this._program.drawArrays(e,t),this}}let Xa=class{constructor(){this.next=null,this.prev=null,this.data=null}};class ts{constructor(e=256){this._current=new Xa,this._head=this._current;for(let t=0;t<e;t++){let i=new Xa;i.prev=this._current,this._current.next=i,this._current=i}this._current=this._head}current(){return this._current}push(e){this._current=this._current.next,this._current.data=e}pop(){let e=this._current.data;return this._current=this._current.prev,e}popPrev(){return this._current=this._current.prev,this._current.data}}const Za=["","WEBKIT_","MOZ_"],is=["webgl2","webgl"];class bt{constructor(e,t={}){this.framebufferStack=new ts,this._requestAnimationFrameId=0,this.drawFrame=()=>{let i=window.performance.now(),r=this.deltaTime;this.deltaTime=.5*(i-this._lastAnimationFrameTime+this.prevDeltaTime),this.deltaTime>3?this.deltaTime=3:this.deltaTime<1&&(this.deltaTime=1),this.prevDeltaTime=r,this._lastAnimationFrameTime=i,this.defaultClock.tick(this.deltaTime);for(let n=0;n<this._clocks.length;n++)this._clocks[n].tick(this.deltaTime);let s=this.canvas;Math.floor(s.clientWidth*this._params.pixelRatio)===s.width&&Math.floor(s.clientHeight*this._params.pixelRatio)===s.height||(s.clientWidth===0||s.clientHeight===0?this.stop():document.hidden||(this.start(),this.setSize(s.clientWidth,s.clientHeight))),this._frameCallback()},this.events=le(["visibilitychange","resize"]),this._throttledDrawFrame=this.drawFrame,this.defaultClock=new hc,this._clocks=[],this.prevDeltaTime=0,this.deltaTime=0,this.canvas=null,this.gl=null,this.programs={},this.activeProgram=null,this._canvasSize=[0,0],this._params={anisotropy:t.anisotropy||4,width:t.width||256,height:t.height||256,pixelRatio:Vs("og_dpi")||t.pixelRatio||1,extensions:t.extensions||[],context:t.context||{}},this.extensions={},this._canvasTarget=e,this._lastAnimationFrameTime=0,this._initialized=!1,this._frameCallback=function(){},this.transparentTexture=null,this.defaultTexture=null,this.framebufferStack=new ts,this.createTexture_n=this.createTexture_n_webgl2.bind(this),this.createTexture_l=this.createTexture_l_webgl2.bind(this),this.createTexture_mm=this.createTexture_mm_webgl2.bind(this),this.createTexture_a=this.createTexture_a_webgl2.bind(this),this.createTexture={NEAREST:this.createTexture_n,LINEAR:this.createTexture_l,MIPMAP:this.createTexture_mm,ANISOTROPIC:this.createTexture_a},this.createTextureDefault=this.createTexture_n,this.ONCANVASRESIZE=null,this._createCanvas(),(t.autoActivate||Ge(t.autoActivate))&&this.initialize()}set frameDelay(e){this._throttledDrawFrame=e===0?this.drawFrame:Qt(this.drawFrame,e)}isInitialized(){return this._initialized}_createCanvas(){this._canvasTarget?this._canvasTarget instanceof HTMLElement?this.canvas=this._canvasTarget:this.canvas=document.getElementById(this._canvasTarget)||document.querySelector(this._canvasTarget):(this.canvas=document.createElement("canvas"),this.canvas.width=this._params.width,this.canvas.height=this._params.height)}static getExtension(e,t){if(!e)return;let i,r;for(i in Za)if(r=e.getExtension(Za[i]+t),r)return r}static getContext(e,t){let i=null;try{let r=new URLSearchParams(location.search).get("og_ver");if(r)i=e.getContext(r,t),i&&(i.type=r);else for(let s=0;s<is.length;s++)if(i=e.getContext(is[s],t),i){i.type=is[s];break}}catch{Ke.logErr("exception during the GL context initialization")}return i||Ke.logErr("could not initialise WebGL"),i}setFrameCallback(e){e&&(this._frameCallback=e)}createEmptyTexture2DExt(e=1,t=1,i="NEAREST",r="RGBA",s="RGBA",n="UNSIGNED_BYTE",o="CLAMP_TO_EDGE",l=0){let h=this.gl,c=h.createTexture();return h.bindTexture(h.TEXTURE_2D,c),h.texImage2D(h.TEXTURE_2D,l,h[r.toUpperCase()],e,t,0,h[s.toUpperCase()],h[n.toUpperCase()],null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h[i.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h[i.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h[o.toUpperCase()]),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h[o.toUpperCase()]),h.bindTexture(h.TEXTURE_2D,null),c}createEmptyTexture_n(e,t,i,r){let s=this.gl,n=s.createTexture();return s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,i||s.RGBA,e,t,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),n}createEmptyTexture_l(e,t,i,r){let s=this.gl,n=s.createTexture();return s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,i||s.RGBA,e,t,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),n}createTexture_n_webgl1(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texImage2D(s.TEXTURE_2D,0,t||s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_l_webgl1(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texImage2D(s.TEXTURE_2D,0,t||s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_mm_webgl1(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texImage2D(s.TEXTURE_2D,0,t||s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_a_webgl1(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texImage2D(s.TEXTURE_2D,0,t||s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameterf(s.TEXTURE_2D,this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._params.anisotropy),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_n_webgl2(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texStorage2D(s.TEXTURE_2D,1,t||s.RGBA8,e.width,e.height),s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.width,e.height,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_l_webgl2(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texStorage2D(s.TEXTURE_2D,1,t||s.RGBA8,e.width,e.height),s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.width,e.height,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_mm_webgl2(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texStorage2D(s.TEXTURE_2D,2,t||s.RGBA8,e.width,e.height),s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.width,e.height,s.RGBA,s.UNSIGNED_BYTE,e),s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}createTexture_a_webgl2(e,t,i,r=null){let s=this.gl;return r=r||s.createTexture(),s.bindTexture(s.TEXTURE_2D,r),s.texStorage2D(s.TEXTURE_2D,2,t||s.RGBA8,e.width,e.height),s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.width,e.height,s.RGBA,s.UNSIGNED_BYTE,e),s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameterf(s.TEXTURE_2D,this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._params.anisotropy),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i||s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i||s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),r}loadCubeMapTexture(e){let t=this.gl,i=t.createTexture();t.bindTexture(t.TEXTURE_CUBE_MAP,i),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR);let r=[[e.px,t.TEXTURE_CUBE_MAP_POSITIVE_X],[e.nx,t.TEXTURE_CUBE_MAP_NEGATIVE_X],[e.py,t.TEXTURE_CUBE_MAP_POSITIVE_Y],[e.ny,t.TEXTURE_CUBE_MAP_NEGATIVE_Y],[e.pz,t.TEXTURE_CUBE_MAP_POSITIVE_Z],[e.nz,t.TEXTURE_CUBE_MAP_NEGATIVE_Z]],s=new _i;s.fillEmpty();let n=s.getImage();for(let o=0;o<r.length;o++){let l=r[o][1];t.bindTexture(t.TEXTURE_CUBE_MAP,i),t.texImage2D(l,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)}for(let o=0;o<r.length;o++){let l=r[o][1],h=new Image;h.crossOrigin="",h.onload=function(c,d,u){return function(){t&&c&&(t.bindTexture(t.TEXTURE_CUBE_MAP,c),t.texImage2D(d,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,u))}}(i,l,h),h.src=r[o][0]}return i}addProgram(e,t=!1){if(this.programs[e.name])console.warn(`Shader program: "${e.name}" already exists.`);else{let i=new cc(this,e);this.programs[e.name]=i,this._initProgramController(i),t||(i._activated=!1)}return e}removeProgram(e){this.programs[e]&&this.programs[e].remove()}addPrograms(e){for(let t=0;t<e.length;t++)this.addProgram(e[t])}_initProgramController(e){this._initialized&&(e.initialize(),this.activeProgram?(e.deactivate(),this.activeProgram._program.enableAttribArrays(),this.activeProgram._program.use()):(this.activeProgram=e,e.activate()))}_initPrograms(){for(let e in this.programs)this._initProgramController(this.programs[e])}initializeExtension(e,t=!1){if(!this.extensions||!this.extensions[e]){let i=bt.getExtension(this.gl,e);i?this.extensions[e]=i:t&&console.warn("og.webgl.Handler: extension '"+e+"' doesn't initialize.")}return this.extensions&&this.extensions[e]}initialize(){if(this._initialized||!this.canvas||(this.gl=bt.getContext(this.canvas,this._params.context),!this.gl))return;this._initialized=!0,this._params.extensions.push("EXT_texture_filter_anisotropic"),this.gl.type==="webgl"?(this._params.extensions.push("OES_standard_derivatives"),this._params.extensions.push("OES_element_index_uint"),this._params.extensions.push("WEBGL_depth_texture"),this._params.extensions.push("ANGLE_instanced_arrays")):(this._params.extensions.push("EXT_color_buffer_float"),this._params.extensions.push("OES_texture_float_linear"));let e=this._params.extensions.length;for(;e--;)this.initializeExtension(this._params.extensions[e],!0);this.gl.type==="webgl"?(this.createTexture_n=this.createTexture_n_webgl1.bind(this),this.createTexture_l=this.createTexture_l_webgl1.bind(this),this.createTexture_mm=this.createTexture_mm_webgl1.bind(this),this.createTexture_a=this.createTexture_a_webgl1.bind(this)):(this.createTexture_n=this.createTexture_n_webgl2.bind(this),this.createTexture_l=this.createTexture_l_webgl2.bind(this),this.createTexture_mm=this.createTexture_mm_webgl2.bind(this),this.createTexture_a=this.createTexture_a_webgl2.bind(this)),this.createTexture.NEAREST=this.createTexture_n,this.createTexture.LINEAR=this.createTexture_l,this.createTexture.MIPMAP=this.createTexture_mm,this.createTexture.ANISOTROPIC=this.createTexture_a,this.extensions.EXT_texture_filter_anisotropic?this.createTextureDefault=this.createTexture_a:this.createTextureDefault=this.createTexture_mm,this._initPrograms(),this._setDefaults(),this.intersectionObserver=new IntersectionObserver(t=>{this._toggleVisibilityChange(t[t.length-1].isIntersecting)},{threshold:0}),this.intersectionObserver.observe(this.canvas),this.resizeObserver=new ResizeObserver(t=>{this._toggleVisibilityChange(t[0].contentRect.width!==0&&t[0].contentRect.height!==0)}),this.resizeObserver.observe(this.canvas),document.addEventListener("visibilitychange",()=>{this._toggleVisibilityChange(document.visibilityState==="visible")})}_toggleVisibilityChange(e){e?(this.start(),this.ONCANVASRESIZE&&this.ONCANVASRESIZE(),this.events.dispatch(this.events.visibilitychange,!0)):(this.events.dispatch(this.events.visibilitychange,!1),this.stop())}_setDefaults(){let e=this.gl;e&&this.canvas&&(e.depthFunc(e.LESS),e.enable(e.DEPTH_TEST),this.setSize(this.canvas.clientWidth||this._params.width,this.canvas.clientHeight||this._params.height),e.frontFace(e.CCW),e.cullFace(e.BACK),e.enable(e.CULL_FACE),e.disable(e.BLEND),this.createDefaultTexture({color:"rgba(0,0,0,0.0)"},t=>{this.transparentTexture=t}),this.createDefaultTexture({color:"rgba(255, 255, 255, 1.0)"},t=>{this.defaultTexture=t}))}getCanvasSize(){return this._canvasSize}createStreamArrayBuffer(e,t,i,r=4){let s=this.gl,n=s.createBuffer();return s.bindBuffer(s.ARRAY_BUFFER,n),s.bufferData(s.ARRAY_BUFFER,t*e*r,i||s.STREAM_DRAW),s.bindBuffer(s.ARRAY_BUFFER,null),n.itemSize=e,n.numItems=t,n}setStreamArrayBuffer(e,t,i=0){let r=this.gl;return r.bindBuffer(r.ARRAY_BUFFER,e),r.bufferSubData(r.ARRAY_BUFFER,i,t),r.bindBuffer(r.ARRAY_BUFFER,null),e}createArrayBuffer(e,t,i,r){let s=this.gl,n=s.createBuffer();return s.bindBuffer(s.ARRAY_BUFFER,n),s.bufferData(s.ARRAY_BUFFER,e,r||s.STATIC_DRAW),s.bindBuffer(s.ARRAY_BUFFER,null),n.itemSize=t,n.numItems=i,n}createArrayBufferLength(e,t){let i=this.gl,r=i.createBuffer();return i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,e,t||i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),r.itemSize=1,r.numItems=e,r}createElementArrayBuffer(e,t,i,r){let s=this.gl,n=s.createBuffer();return s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,n),s.bufferData(s.ELEMENT_ARRAY_BUFFER,e,r||s.STATIC_DRAW),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null),n.itemSize=t,n.numItems=i||e.length,n}setSize(e,t){this._params.width=e,this._params.height=t,this.canvas&&(this.canvas.width=e*this._params.pixelRatio,this.canvas.height=t*this._params.pixelRatio,this._canvasSize[0]=this.canvas.width,this._canvasSize[1]=this.canvas.height,this.gl&&this.gl.viewport(0,0,e,t),this.ONCANVASRESIZE&&this.ONCANVASRESIZE(this.canvas),this.events.dispatch(this.events.resize,this))}get pixelRatio(){return this._params.pixelRatio}set pixelRatio(e){this._params.pixelRatio=e,this.setSize(this._params.width,this._params.height)}getWidth(){return this.canvas?this.canvas.width:0}getHeight(){return this.canvas?this.canvas.height:0}getClientAspect(){return this.canvas?this.canvas.clientWidth/this.canvas.clientHeight:0}getCenter(){let e=this.canvas;return e?new N(Math.round(.5*e.width),Math.round(.5*e.height)):new N}clearFrame(){let e=this.gl;e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}start(){!this._requestAnimationFrameId&&this._initialized&&this._animationFrameCallback()}stop(){this._requestAnimationFrameId&&(window.cancelAnimationFrame(this._requestAnimationFrameId),this._requestAnimationFrameId=0)}isStopped(){return!this._requestAnimationFrameId}isWebGl2(){return!!this.gl&&this.gl.type==="webgl2"}_animationFrameCallback(){this._requestAnimationFrameId=window.requestAnimationFrame(()=>{this._throttledDrawFrame(),this._requestAnimationFrameId&&this._animationFrameCallback()})}createDefaultTexture(e,t){let i,r;if(e&&e.color)i=new _i(2,2),i.fillColor(e.color),r=this.createTexture_n(i.getCanvas()),r.default=!0,t(r);else if(e&&e.url){let s=new Image,n=this;s.onload=function(){r=n.createTextureDefault(s),r.default=!0,t(r)},s.src=e.url}else i=new _i(2,2),i.fillColor("#C5C5C5"),r=this.createTexture_n(i.getCanvas()),r.default=!0,t(r)}deleteTexture(e){e&&!e.default&&this.gl.deleteTexture(e)}destroy(){var e,t;(e=this.resizeObserver)==null||e.disconnect(),(t=this.intersectionObserver)==null||t.disconnect(),this.stop();for(let r in this.programs)this.removeProgram(r);let i=this.gl;if(i){i.deleteTexture(this.transparentTexture),this.transparentTexture=null,i.deleteTexture(this.defaultTexture),this.defaultTexture=null,this.framebufferStack=new ts;let r=i.getParameter(i.MAX_VERTEX_ATTRIBS),s=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,s);for(let o=0;o<r;++o)i.disableVertexAttribArray(o),i.vertexAttribPointer(o,4,i.FLOAT,!1,0,0),i.vertexAttrib1f(o,0);i.deleteBuffer(s);let n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let o=0;o<n;++o)i.activeTexture(i.TEXTURE0+o),i.bindTexture(i.TEXTURE_CUBE_MAP,null),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(null),i.bindBuffer(i.ARRAY_BUFFER,null),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindRenderbuffer(i.RENDERBUFFER,null),i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.DITHER),i.disable(i.SCISSOR_TEST),i.blendColor(0,0,0,0),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.clearColor(0,0,0,0),i.clearDepth(1),i.clearStencil(-1)}this.canvas&&(this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.width=1,this.canvas.height=1,this.canvas=null),this.gl=null,this._initialized=!1}addClock(e){e.__handler||(e.__handler=this,this._clocks.push(e))}addClocks(e){for(let t=0;t<e.length;t++)this.addClock(e[t])}removeClock(e){if(e.__handler){let t=this._clocks,i=t.length;for(;i--;)if(t[i].isEqual(e)){e.__handler=null,t.splice(i,1);break}}}}class Qa extends Ya{constructor(e,t={}){super(e,t),this._internalFormat=t.internalFormat?t.internalFormat.toUpperCase():"RGBA8",this._msaa=t.msaa!=null?t.msaa:4,this._glFilter=0,this.renderbuffers=new Array(this._size)}destroy(){let e=this.handler.gl;if(e){for(let t=0;t<this.renderbuffers.length;t++)e.deleteRenderbuffer(this.renderbuffers[t]);this.renderbuffers=new Array(this._size),e.deleteFramebuffer(this._fbo),e.deleteRenderbuffer(this._depthRenderbuffer),this._depthRenderbuffer=null,this._fbo=null,this._active=!1}}init(){let e=this.handler.gl;if(!e)return;this._glFilter=e[this._filter],this._fbo=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._fbo);let t=[];for(let i=0;i<this.renderbuffers.length;i++){let r=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,r),this._msaa>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,this._msaa,e[this._internalFormat],this._width,this._height):e.renderbufferStorage(e.RENDERBUFFER,e[this._internalFormat],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,r),t.push(e.COLOR_ATTACHMENT0+i),this.renderbuffers[i]=r,e.bindRenderbuffer(e.RENDERBUFFER,null)}e.drawBuffers(t),this._useDepth&&(this._depthRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthRenderbuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,this._msaa,e[this._depthComponent],this._width,this._height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this._depthRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null)),e.bindFramebuffer(e.FRAMEBUFFER,null)}blitTo(e,t=0){let i=this.handler.gl;i.bindFramebuffer(i.READ_FRAMEBUFFER,this._fbo),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,e._fbo),i.readBuffer(i.COLOR_ATTACHMENT0+t),i.clearBufferfv(i.COLOR,0,[0,0,0,1]),i.blitFramebuffer(0,0,this._width,this._height,0,0,e._width,e._height,i.COLOR_BUFFER_BIT,this._glFilter),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null)}}Object.freeze(Object.defineProperty({__proto__:null,Framebuffer:Se,Handler:bt,Multisample:Qa,Program:X,types:ue},Symbol.toStringTag,{value:"Module"}));class rs extends hi{constructor(e,t={}){super(e,t),this._image=t.image||null,this._src=t.src||null,this._onLoad_=null}get instanceName(){return"GeoImage"}abortLoading(){this._image instanceof HTMLImageElement&&(this._image.src="")}setSrc(e){this._planet&&this._planet._geoImageCreator.remove(this),this._src=e,this._sourceReady=!1,this._sourceCreated=!1,this._image=new Image,this._image.crossOrigin="Anonymous",this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_),this._image.src=e}setImage(e){this._planet&&this._planet._geoImageCreator.remove(this),this._sourceCreated=!1,this._sourceReady=!1,this._image=e,this._image.crossOrigin="Anonymous",this._src=e.src,xr(this._image)?this._applyImage(this._image):(this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_))}_createSourceTexture(){!this._sourceCreated&&this._image&&(this._sourceTexture=this._planet.renderer.handler.createTexture_l(this._image),this._sourceCreated=!0)}_onLoad(e){this._applyImage(this._image),this._image instanceof HTMLImageElement&&this._image.removeEventListener("load",this._onLoad_),this._onLoad_=null}_applyImage(e){e&&(this._frameWidth=St(2*e.width,4096),this._frameHeight=St(3*e.height,4096),this._sourceReady=!0,this._planet&&this._planet._geoImageCreator.add(this))}loadMaterial(e){e.isLoading=!0,this._creationProceeding=!0,!this._sourceReady&&this._src?this._image?this._image instanceof HTMLImageElement&&(xr(this._image)?this._applyImage(this._image):(this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_))):(this._image=new Image,this._image.crossOrigin="Anonymous",this._onLoad_=this._onLoad.bind(this),this._image.addEventListener("load",this._onLoad_),this._image.src=this._src):this._planet&&this._planet._geoImageCreator.add(this)}abortMaterialLoading(e){this._image&&this._image instanceof HTMLImageElement&&(this._image.src=""),this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}Object.freeze(Object.defineProperty({__proto__:null,AtmosphereConfig:class extends ee{constructor(a={}){super(a),this.$maxOpacity=null,this.$minOpacity=null,this.$rayleight=null,this.$mie=null,this.$height=null,this.$bottomRadius=null,this.$mieScatteringCoefficient=null,this.$mieExtinctionCoefficient=null,this.$rayleighScatteringCoefficientA=null,this.$rayleighScatteringCoefficientB=null,this.$rayleighScatteringCoefficientC=null,this.$ozoneAbsorptionCoefficientA=null,this.$ozoneAbsorptionCoefficientB=null,this.$ozoneAbsorptionCoefficientC=null,this.$sunAngularRadius=null,this.$sunIntensity=null,this.$groundAlbedo=null,this.$ozoneDensityHeight=null,this.$ozoneDensityWide=null,this._toggleBtn=new _e({classList:["og-map-button","og-atmosphere_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
349
+ <svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M135.688 18.5c-6.798 74.842-23.842 85.39-107.907 59.656 84.85 52.022 73.57 64.954-6.843 96.938 87.743-10.27 103.29 4.89 70.75 87.594 17.805-27.56 32.5-44.498 46.282-54.47-11.813 28.26-18.345 59.274-18.345 91.813 0 84.184 43.71 157.96 109.656 200.376-41.624-43.834-67.686-102.7-67.686-167.875 0-134.923 109.45-244.405 244.375-244.405 30.92 0 60.76 5.762 88 16.25-38.584-26.87-85.517-42.625-136.064-42.625-55.257 0-106.14 18.802-146.562 50.375 4.627-18.783 17.39-38.073 41.03-60.906C190.18 90.942 153.53 95.634 135.69 18.5zm10.03 77.188c5.67.002 11.428 1.247 16.876 3.874 14.506 6.998 22.72 21.81 22 36.938-10.26 10.87-19.507 22.696-27.594 35.344-9.035 2.753-19.075 2.27-28.25-2.156-19.37-9.343-27.5-32.6-18.156-51.97 6.715-13.92 20.638-22.036 35.125-22.03z"/></svg>`}),this._dialog=new at({title:"Atmosphere Parameters",visible:!1,useHide:!0,top:60,left:60,width:720}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._panel=new be({template:`<div class="og-atmosphere og-options-container">
350
350
 
351
351
  <div class="og-option og-atmosphere-maxOpacity"></div>
352
352
  <div class="og-option og-atmosphere-minOpacity"></div>
@@ -389,7 +389,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
389
389
  <div class="og-option og-atmosphere-sunIntensity"></div>
390
390
  <div class="og-option og-atmosphere-earthAlbedo"></div>
391
391
 
392
- </div>`}),this._maxOpacity=new Q({label:"Max.opacity",max:5}),this._minOpacity=new Q({label:"Min.opacity",max:5}),this._rayleight=new Q({label:"Rayleight Scale",min:-10,max:10}),this._mie=new Q({label:"Mie Scale",min:-10,max:10}),this._height=new Q({label:"Height",max:1e6}),this._bottomRadius=new Q({label:"Planet Radius",max:31783761571225896e-9}),this._mieScatteringCoefficient=new Q({label:"Mie Scattering Coefficient e-6",min:-39.96,max:39.96}),this._mieExtinctionCoefficient=new Q({label:"Mie Extinction Coef.e-6",min:4.44*-10,max:10*4.44}),this._rayleighScatteringCoefficientA=new Q({label:"Rayleight Scattering Coef A.e-6",min:5.802*-10,max:10*5.802}),this._rayleighScatteringCoefficientB=new Q({label:"Rayleight Scattering Coef B.e-6",min:13.558*-10,max:10*13.558}),this._rayleighScatteringCoefficientC=new Q({label:"Rayleight Scattering Coef C.e-6",min:-331,max:331}),this._ozoneAbsorptionCoefficientA=new Q({label:"Ozone absorbtion Coef A.e-6",min:-6.5,max:6.5}),this._ozoneAbsorptionCoefficientB=new Q({label:"Ozone absorbtion Coef B.e-6",min:-6.5,max:18.81}),this._ozoneAbsorptionCoefficientC=new Q({label:"Ozone absorbtion Coef C.e-6",min:.085*-10,max:10*.085}),this._ozoneDensityHeight=new Q({label:"Ozone Density Height",max:25e5}),this._ozoneDensityWide=new Q({label:"Ozone Density Wide",max:25e5}),this._sunAngularRadius=new Q({label:"Sun Angular Radius",max:4.685}),this._sunIntensity=new Q({label:"Sun Intensity",max:10}),this._groundAlbedo=new Q({label:"Earth Albedo",max:.5}),this._parameters={ATMOS_HEIGHT:0,RAYLEIGH_SCALE:0,MIE_SCALE:0,GROUND_ALBEDO:0,BOTTOM_RADIUS:0,rayleighScatteringCoefficient_0:0,rayleighScatteringCoefficient_1:0,rayleighScatteringCoefficient_2:0,mieScatteringCoefficient:0,mieExtinctionCoefficient:0,ozoneAbsorptionCoefficient_0:0,ozoneAbsorptionCoefficient_1:0,ozoneAbsorptionCoefficient_2:0,SUN_ANGULAR_RADIUS:0,SUN_INTENSITY:0,ozoneDensityHeight:0,ozoneDensityWide:0}}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._panel.appendTo(this._dialog.container),this._panel.el&&(this.$height=this._panel.el.querySelector(".og-option.og-atmosphere-height"),this.$maxOpacity=this._panel.el.querySelector(".og-option.og-atmosphere-maxOpacity"),this.$minOpacity=this._panel.el.querySelector(".og-option.og-atmosphere-minOpacity"),this.$rayleight=this._panel.el.querySelector(".og-option.og-atmosphere-rayleight"),this.$mie=this._panel.el.querySelector(".og-option.og-atmosphere-mie"),this.$bottomRadius=this._panel.el.querySelector(".og-option.og-atmosphere-bottomRadius"),this.$mieScatteringCoefficient=this._panel.el.querySelector(".og-option.og-atmosphere-mieScatteringCoefficient"),this.$mieExtinctionCoefficient=this._panel.el.querySelector(".og-option.og-atmosphere-mieExtinctionCoefficient"),this.$rayleighScatteringCoefficientA=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientA"),this.$rayleighScatteringCoefficientB=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientB"),this.$rayleighScatteringCoefficientC=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientC"),this.$ozoneAbsorptionCoefficientA=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientA"),this.$ozoneAbsorptionCoefficientB=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientB"),this.$ozoneAbsorptionCoefficientC=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientC"),this.$sunAngularRadius=this._panel.el.querySelector(".og-option.og-atmosphere-sunAngularRadius"),this.$sunIntensity=this._panel.el.querySelector(".og-option.og-atmosphere-sunIntensity"),this.$groundAlbedo=this._panel.el.querySelector(".og-option.og-atmosphere-earthAlbedo"),this.$ozoneDensityHeight=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneDensityHeight"),this.$ozoneDensityWide=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneDensityWide")),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this._maxOpacity.appendTo(this.$maxOpacity),this._minOpacity.appendTo(this.$minOpacity),this._height.appendTo(this.$height),this._rayleight.appendTo(this.$rayleight),this._mie.appendTo(this.$mie),this._bottomRadius.appendTo(this.$bottomRadius),this._mieScatteringCoefficient.appendTo(this.$mieScatteringCoefficient),this._mieExtinctionCoefficient.appendTo(this.$mieExtinctionCoefficient),this._rayleighScatteringCoefficientA.appendTo(this.$rayleighScatteringCoefficientA),this._rayleighScatteringCoefficientB.appendTo(this.$rayleighScatteringCoefficientB),this._rayleighScatteringCoefficientC.appendTo(this.$rayleighScatteringCoefficientC),this._ozoneAbsorptionCoefficientA.appendTo(this.$ozoneAbsorptionCoefficientA),this._ozoneAbsorptionCoefficientB.appendTo(this.$ozoneAbsorptionCoefficientB),this._ozoneAbsorptionCoefficientC.appendTo(this.$ozoneAbsorptionCoefficientC),this._sunAngularRadius.appendTo(this.$sunAngularRadius),this._sunIntensity.appendTo(this.$sunIntensity),this._groundAlbedo.appendTo(this.$groundAlbedo),this._ozoneDensityHeight.appendTo(this.$ozoneDensityHeight),this._ozoneDensityWide.appendTo(this.$ozoneDensityWide),this.planet&&(this._parameters=this.planet.atmosphereControl.parameters,this._height.value=this._parameters.ATMOS_HEIGHT,this._rayleight.value=this._parameters.RAYLEIGH_SCALE,this._mie.value=this._parameters.MIE_SCALE,this._bottomRadius.value=this._parameters.BOTTOM_RADIUS,this._mieScatteringCoefficient.value=this._parameters.mieScatteringCoefficient,this._mieExtinctionCoefficient.value=this._parameters.mieExtinctionCoefficient,this._rayleighScatteringCoefficientA.value=this._parameters.rayleighScatteringCoefficient_0,this._rayleighScatteringCoefficientB.value=this._parameters.rayleighScatteringCoefficient_1,this._rayleighScatteringCoefficientC.value=this._parameters.rayleighScatteringCoefficient_2,this._ozoneAbsorptionCoefficientA.value=this._parameters.ozoneAbsorptionCoefficient_0,this._ozoneAbsorptionCoefficientB.value=this._parameters.ozoneAbsorptionCoefficient_1,this._ozoneAbsorptionCoefficientC.value=this._parameters.ozoneAbsorptionCoefficient_2,this._sunAngularRadius.value=this._parameters.SUN_ANGULAR_RADIUS,this._sunIntensity.value=this._parameters.SUN_INTENSITY,this._groundAlbedo.value=this._parameters.GROUND_ALBEDO,this._ozoneDensityHeight.value=this._parameters.ozoneDensityHeight,this._ozoneDensityWide.value=this._parameters.ozoneDensityWide),this._minOpacity.value=this.planet.atmosphereMinOpacity,this._minOpacity.events.on("change",a=>{this.planet.atmosphereMinOpacity=a}),this._maxOpacity.value=this.planet.atmosphereMaxOpacity,this._maxOpacity.events.on("change",a=>{this.planet.atmosphereMaxOpacity=a}),this._rayleight.events.on("change",a=>{this._parameters.RAYLEIGH_SCALE=a,this._update()}),this._mie.events.on("change",a=>{this._parameters.MIE_SCALE=a,this._update()}),this._height.events.on("change",a=>{this._parameters.ATMOS_HEIGHT=a,this._update()}),this._bottomRadius.events.on("change",a=>{this._parameters.BOTTOM_RADIUS=a,this._update()}),this._mieScatteringCoefficient.events.on("change",a=>{this._parameters.mieScatteringCoefficient=a,this._update()}),this._mieExtinctionCoefficient.events.on("change",a=>{this._parameters.mieExtinctionCoefficient=a,this._update()}),this._rayleighScatteringCoefficientA.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_0=a,this._update()}),this._rayleighScatteringCoefficientB.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_1=a,this._update()}),this._rayleighScatteringCoefficientC.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_2=a,this._update()}),this._ozoneAbsorptionCoefficientA.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_0=a,this._update()}),this._ozoneAbsorptionCoefficientB.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_1=a,this._update()}),this._ozoneAbsorptionCoefficientC.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_2=a,this._update()}),this._sunAngularRadius.events.on("change",a=>{this._parameters.SUN_ANGULAR_RADIUS=a,this._update()}),this._sunIntensity.events.on("change",a=>{this._parameters.SUN_INTENSITY=a,this._update()}),this._groundAlbedo.events.on("change",a=>{this._parameters.GROUND_ALBEDO=a,this._update()}),this._ozoneDensityHeight.events.on("change",a=>{this._parameters.ozoneDensityHeight=a,this._update()}),this._ozoneDensityWide.events.on("change",a=>{this._parameters.ozoneDensityWide=a,this._update()})}_update(){this.planet&&this.planet.atmosphereControl.setParameters(this._parameters)}},CameraDepthHandler:class extends te{constructor(a){super(a),this._depthHandlerCallback=e=>{if(!this.planet)return;let t=e.camera,i=e.frameBuffer,s=i.handler.gl;i.activate(),s.clearColor(0,0,0,1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.disable(s.BLEND);let r=i.handler;r.programs.camera_depth.activate();let n=r.programs.camera_depth._program,o=n.uniforms;s.uniformMatrix4fv(o.viewMatrix,!1,t.getViewMatrix()),s.uniformMatrix4fv(o.projectionMatrix,!1,t.getProjectionMatrix()),s.uniform3fv(o.eyePositionHigh,t.eyeHigh),s.uniform3fv(o.eyePositionLow,t.eyeLow);let l=this.planet._renderedNodes,h=l.length;for(;h--;)l[h].segment._transitionOpacity>=1&&l[h].segment.depthRendering(n);for(let f=0;f<this.planet._fadingOpaqueSegments.length;++f)this.planet._fadingOpaqueSegments[f].depthRendering(n);i.deactivate(),i.readPixelBuffersAsync();let c=this.getLonLatFromPixelTerrain(1,1),d=this.getLonLatFromPixelTerrain(i.width-1,1),u=this.getLonLatFromPixelTerrain(i.width-1,i.height-1),g=this.getLonLatFromPixelTerrain(1,i.height-1);c&&d&&u&&g&&this.cameraGeoImage.setCorners([[c.lon,c.lat],[d.lon,d.lat],[u.lon,u.lat],[g.lon,g.lat]])},this._frameComposer=new Ks,this._depthHandler=null,this.cameraGeoImage=new ir(`cameraGeoImage:${this.__id}`,{src:"test4.jpg",corners:[[0,1],[1,1],[1,0],[0,0]],visibility:!0,isBaseLayer:!1,opacity:.7})}_createCamera(){return this.planet?new Go(this.planet,{frustums:[[10,1e4]],width:640,height:480,viewAngle:45}):new Js({frustums:[[10,1e4]],width:640,height:480,viewAngle:45})}get camera(){if(this._depthHandler)return this._depthHandler.camera}oninit(){if(super.oninit(),!this.renderer)return;this.renderer.handler.addProgram(new X("camera_depth",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",height:"float",eyePositionHigh:"vec3",eyePositionLow:"vec3"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3"},vertexShader:`#version 300 es
392
+ </div>`}),this._maxOpacity=new Q({label:"Max.opacity",max:5}),this._minOpacity=new Q({label:"Min.opacity",max:5}),this._rayleight=new Q({label:"Rayleight Scale",min:-10,max:10}),this._mie=new Q({label:"Mie Scale",min:-10,max:10}),this._height=new Q({label:"Height",max:1e6}),this._bottomRadius=new Q({label:"Planet Radius",max:31783761571225896e-9}),this._mieScatteringCoefficient=new Q({label:"Mie Scattering Coefficient e-6",min:-39.96,max:39.96}),this._mieExtinctionCoefficient=new Q({label:"Mie Extinction Coef.e-6",min:4.44*-10,max:10*4.44}),this._rayleighScatteringCoefficientA=new Q({label:"Rayleight Scattering Coef A.e-6",min:5.802*-10,max:10*5.802}),this._rayleighScatteringCoefficientB=new Q({label:"Rayleight Scattering Coef B.e-6",min:13.558*-10,max:10*13.558}),this._rayleighScatteringCoefficientC=new Q({label:"Rayleight Scattering Coef C.e-6",min:-331,max:331}),this._ozoneAbsorptionCoefficientA=new Q({label:"Ozone absorbtion Coef A.e-6",min:-6.5,max:6.5}),this._ozoneAbsorptionCoefficientB=new Q({label:"Ozone absorbtion Coef B.e-6",min:-6.5,max:18.81}),this._ozoneAbsorptionCoefficientC=new Q({label:"Ozone absorbtion Coef C.e-6",min:.085*-10,max:10*.085}),this._ozoneDensityHeight=new Q({label:"Ozone Density Height",max:25e5}),this._ozoneDensityWide=new Q({label:"Ozone Density Wide",max:25e5}),this._sunAngularRadius=new Q({label:"Sun Angular Radius",max:4.685}),this._sunIntensity=new Q({label:"Sun Intensity",max:10}),this._groundAlbedo=new Q({label:"Earth Albedo",max:.5}),this._parameters={ATMOS_HEIGHT:0,RAYLEIGH_SCALE:0,MIE_SCALE:0,GROUND_ALBEDO:0,BOTTOM_RADIUS:0,rayleighScatteringCoefficient_0:0,rayleighScatteringCoefficient_1:0,rayleighScatteringCoefficient_2:0,mieScatteringCoefficient:0,mieExtinctionCoefficient:0,ozoneAbsorptionCoefficient_0:0,ozoneAbsorptionCoefficient_1:0,ozoneAbsorptionCoefficient_2:0,SUN_ANGULAR_RADIUS:0,SUN_INTENSITY:0,ozoneDensityHeight:0,ozoneDensityWide:0}}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._panel.appendTo(this._dialog.container),this._panel.el&&(this.$height=this._panel.el.querySelector(".og-option.og-atmosphere-height"),this.$maxOpacity=this._panel.el.querySelector(".og-option.og-atmosphere-maxOpacity"),this.$minOpacity=this._panel.el.querySelector(".og-option.og-atmosphere-minOpacity"),this.$rayleight=this._panel.el.querySelector(".og-option.og-atmosphere-rayleight"),this.$mie=this._panel.el.querySelector(".og-option.og-atmosphere-mie"),this.$bottomRadius=this._panel.el.querySelector(".og-option.og-atmosphere-bottomRadius"),this.$mieScatteringCoefficient=this._panel.el.querySelector(".og-option.og-atmosphere-mieScatteringCoefficient"),this.$mieExtinctionCoefficient=this._panel.el.querySelector(".og-option.og-atmosphere-mieExtinctionCoefficient"),this.$rayleighScatteringCoefficientA=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientA"),this.$rayleighScatteringCoefficientB=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientB"),this.$rayleighScatteringCoefficientC=this._panel.el.querySelector(".og-option.og-atmosphere-rayleighScatteringCoefficientC"),this.$ozoneAbsorptionCoefficientA=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientA"),this.$ozoneAbsorptionCoefficientB=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientB"),this.$ozoneAbsorptionCoefficientC=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneAbsorptionCoefficientC"),this.$sunAngularRadius=this._panel.el.querySelector(".og-option.og-atmosphere-sunAngularRadius"),this.$sunIntensity=this._panel.el.querySelector(".og-option.og-atmosphere-sunIntensity"),this.$groundAlbedo=this._panel.el.querySelector(".og-option.og-atmosphere-earthAlbedo"),this.$ozoneDensityHeight=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneDensityHeight"),this.$ozoneDensityWide=this._panel.el.querySelector(".og-option.og-atmosphere-ozoneDensityWide")),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this._maxOpacity.appendTo(this.$maxOpacity),this._minOpacity.appendTo(this.$minOpacity),this._height.appendTo(this.$height),this._rayleight.appendTo(this.$rayleight),this._mie.appendTo(this.$mie),this._bottomRadius.appendTo(this.$bottomRadius),this._mieScatteringCoefficient.appendTo(this.$mieScatteringCoefficient),this._mieExtinctionCoefficient.appendTo(this.$mieExtinctionCoefficient),this._rayleighScatteringCoefficientA.appendTo(this.$rayleighScatteringCoefficientA),this._rayleighScatteringCoefficientB.appendTo(this.$rayleighScatteringCoefficientB),this._rayleighScatteringCoefficientC.appendTo(this.$rayleighScatteringCoefficientC),this._ozoneAbsorptionCoefficientA.appendTo(this.$ozoneAbsorptionCoefficientA),this._ozoneAbsorptionCoefficientB.appendTo(this.$ozoneAbsorptionCoefficientB),this._ozoneAbsorptionCoefficientC.appendTo(this.$ozoneAbsorptionCoefficientC),this._sunAngularRadius.appendTo(this.$sunAngularRadius),this._sunIntensity.appendTo(this.$sunIntensity),this._groundAlbedo.appendTo(this.$groundAlbedo),this._ozoneDensityHeight.appendTo(this.$ozoneDensityHeight),this._ozoneDensityWide.appendTo(this.$ozoneDensityWide),this.planet&&(this._parameters=this.planet.atmosphereControl.parameters,this._height.value=this._parameters.ATMOS_HEIGHT,this._rayleight.value=this._parameters.RAYLEIGH_SCALE,this._mie.value=this._parameters.MIE_SCALE,this._bottomRadius.value=this._parameters.BOTTOM_RADIUS,this._mieScatteringCoefficient.value=this._parameters.mieScatteringCoefficient,this._mieExtinctionCoefficient.value=this._parameters.mieExtinctionCoefficient,this._rayleighScatteringCoefficientA.value=this._parameters.rayleighScatteringCoefficient_0,this._rayleighScatteringCoefficientB.value=this._parameters.rayleighScatteringCoefficient_1,this._rayleighScatteringCoefficientC.value=this._parameters.rayleighScatteringCoefficient_2,this._ozoneAbsorptionCoefficientA.value=this._parameters.ozoneAbsorptionCoefficient_0,this._ozoneAbsorptionCoefficientB.value=this._parameters.ozoneAbsorptionCoefficient_1,this._ozoneAbsorptionCoefficientC.value=this._parameters.ozoneAbsorptionCoefficient_2,this._sunAngularRadius.value=this._parameters.SUN_ANGULAR_RADIUS,this._sunIntensity.value=this._parameters.SUN_INTENSITY,this._groundAlbedo.value=this._parameters.GROUND_ALBEDO,this._ozoneDensityHeight.value=this._parameters.ozoneDensityHeight,this._ozoneDensityWide.value=this._parameters.ozoneDensityWide),this._minOpacity.value=this.planet.atmosphereMinOpacity,this._minOpacity.events.on("change",a=>{this.planet.atmosphereMinOpacity=a}),this._maxOpacity.value=this.planet.atmosphereMaxOpacity,this._maxOpacity.events.on("change",a=>{this.planet.atmosphereMaxOpacity=a}),this._rayleight.events.on("change",a=>{this._parameters.RAYLEIGH_SCALE=a,this._update()}),this._mie.events.on("change",a=>{this._parameters.MIE_SCALE=a,this._update()}),this._height.events.on("change",a=>{this._parameters.ATMOS_HEIGHT=a,this._update()}),this._bottomRadius.events.on("change",a=>{this._parameters.BOTTOM_RADIUS=a,this._update()}),this._mieScatteringCoefficient.events.on("change",a=>{this._parameters.mieScatteringCoefficient=a,this._update()}),this._mieExtinctionCoefficient.events.on("change",a=>{this._parameters.mieExtinctionCoefficient=a,this._update()}),this._rayleighScatteringCoefficientA.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_0=a,this._update()}),this._rayleighScatteringCoefficientB.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_1=a,this._update()}),this._rayleighScatteringCoefficientC.events.on("change",a=>{this._parameters.rayleighScatteringCoefficient_2=a,this._update()}),this._ozoneAbsorptionCoefficientA.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_0=a,this._update()}),this._ozoneAbsorptionCoefficientB.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_1=a,this._update()}),this._ozoneAbsorptionCoefficientC.events.on("change",a=>{this._parameters.ozoneAbsorptionCoefficient_2=a,this._update()}),this._sunAngularRadius.events.on("change",a=>{this._parameters.SUN_ANGULAR_RADIUS=a,this._update()}),this._sunIntensity.events.on("change",a=>{this._parameters.SUN_INTENSITY=a,this._update()}),this._groundAlbedo.events.on("change",a=>{this._parameters.GROUND_ALBEDO=a,this._update()}),this._ozoneDensityHeight.events.on("change",a=>{this._parameters.ozoneDensityHeight=a,this._update()}),this._ozoneDensityWide.events.on("change",a=>{this._parameters.ozoneDensityWide=a,this._update()})}_update(){this.planet&&this.planet.atmosphereControl.setParameters(this._parameters)}},CameraDepthHandler:class extends ee{constructor(a){super(a),this._skipPreRender=!1,this._depthHandlerCallback=e=>{if(!this.planet)return;let t=e.frameBuffer;if(t.handler.gl,t.activate(),this._quadTreeStrategy){let o=e.camera;this._skipPreRender&&this._quadTreeStrategy.collectRenderNodes(o),this._skipPreRender=!0,console.log(this._quadTreeStrategy._renderedNodes)}t.deactivate(),t.readPixelBuffersAsync();let i=this.getLonLatFromPixelTerrain(1,1),r=this.getLonLatFromPixelTerrain(t.width-1,1),s=this.getLonLatFromPixelTerrain(t.width-1,t.height-1),n=this.getLonLatFromPixelTerrain(1,t.height-1);i&&r&&s&&n&&this.cameraGeoImage.setCorners([[i.lon,i.lat],[r.lon,r.lat],[s.lon,s.lat],[n.lon,n.lat]])},this._frameComposer=new Jr,this._frameHandler=null,this.cameraGeoImage=new rs(`cameraGeoImage:${this.__id}`,{src:"test4.jpg",corners:[[0,1],[1,1],[1,0],[0,0]],visibility:!0,isBaseLayer:!1,opacity:.7}),this._quadTreeStrategy=null}_createCamera(){return this.planet?new ja(this.planet,{frustums:[[100,1e9]],width:640,height:480,viewAngle:45}):new es({frustums:[[100,1e9]],width:640,height:480,viewAngle:45})}get camera(){if(this._frameHandler)return this._frameHandler.camera}oninit(){if(super.oninit(),!this.renderer)return;this.renderer.handler.addProgram(new X("camera_depth",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",height:"float",eyePositionHigh:"vec3",eyePositionLow:"vec3"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3"},vertexShader:`#version 300 es
393
393
 
394
394
  precision highp float;
395
395
 
@@ -426,7 +426,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
426
426
 
427
427
  void main(void) {
428
428
  depthColor = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, 1.0);
429
- }`})),this.planet&&this.planet.addLayer(this.cameraGeoImage);let a=new Me(this.renderer.handler,{width:640,height:480,targets:[{internalFormat:"RGBA16F",type:"FLOAT",attachment:"COLOR_ATTACHMENT",readAsync:!0}],useDepth:!0});this._depthHandler=new Ho({camera:this._createCamera(),frameBuffer:a,frameHandler:this._depthHandlerCallback}),this.renderer.controls.CameraFrameComposer?this._frameComposer=this.renderer.controls.CameraFrameComposer:this.renderer.addControl(this._frameComposer),this._frameComposer.add(this._depthHandler)}get framebuffer(){if(this._depthHandler)return this._depthHandler.frameBuffer}getCartesianFromPixelTerrain(a,e){if(this._depthHandler){let t=this._depthHandler.frameBuffer,i=this._depthHandler.camera,s=function(o,l,h,c){let d=new N(o,l),u=d.x/c.width,g=(c.height-d.y)/c.height,f=new Float32Array(4),p=0;if(c.readData(u,g,f,0),f[0]===0)return 0;let _=f[0],m=h.frustums[0].inverseProjectionMatrix,y=new ee(2*u-1,2*g-1,2*_-1,1),x=m.mulVec4(y),w=h.unproject(u*h.width,(1-g)*h.height);return p=-x.z/x.w/w.dot(h.getForward()),p}(a,e,i,t);if(s===0)return;let r=a/t.width,n=(t.height-e)/t.height;return i.unproject(r*i.width,(1-n)*i.height).scaleTo(s).addA(i.eye)}}getLonLatFromPixelTerrain(a,e){if(this.planet){let t=this.getCartesianFromPixelTerrain(a,e);if(t)return this.planet.ellipsoid.cartesianToLonLat(t)}}activate(){super.activate()}deactivate(){super.deactivate()}},CameraFrameComposer:Ks,CameraFrameHandler:Ho,CameraLock:No,CompassButton:Zr,Control:te,DebugInfo:class extends te{constructor(a={}){a.name&&a.name!==""||(a.name="DebugInfo"),super(a),this.el=null,this._watch=a.watch||[],this._toggleBtn=new fe({classList:["og-map-button","og-debuginfo_button"],icon:`<?xml version="1.0" encoding="iso-8859-1"?>
429
+ }`})),this.planet&&this.planet.addLayer(this.cameraGeoImage);let a=new Se(this.renderer.handler,{width:640,height:480,targets:[{internalFormat:"RGBA16F",type:"FLOAT",attachment:"COLOR_ATTACHMENT",readAsync:!0}],useDepth:!0});if(this._frameHandler=new Ha({camera:this._createCamera(),frameBuffer:a,frameHandler:this._depthHandlerCallback}),this.renderer.controls.CameraFrameComposer?this._frameComposer=this.renderer.controls.CameraFrameComposer:this.renderer.addControl(this._frameComposer),this._frameComposer.add(this._frameHandler),this.planet){const e={planet:this.planet,maxEqualZoomAltitude:this.planet.quadTreeStrategy.maxEqualZoomAltitude,minEqualZoomAltitude:this.planet.quadTreeStrategy.minEqualZoomAltitude,minEqualZoomCameraSlope:this.planet.quadTreeStrategy.minEqualZoomCameraSlope,transitionOpacityEnabled:!1};this._quadTreeStrategy=new this.planet.quadTreeStrategyPrototype(e),this._quadTreeStrategy.init(this.camera),this._quadTreeStrategy.preRender(),this._quadTreeStrategy.clearRenderedNodes(),this._skipPreRender=!1,this._quadTreeStrategy.preLoad()}}get framebuffer(){if(this._frameHandler)return this._frameHandler.frameBuffer}getCartesianFromPixelTerrain(a,e){if(this._frameHandler){let t=this._frameHandler.frameBuffer,i=this._frameHandler.camera,r=function(o,l,h,c){let d=new N(o,l),u=d.x/c.width,g=(c.height-d.y)/c.height,f=new Float32Array(4),p=0;if(c.readData(u,g,f,0),f[0]===0)return 0;let _=f[0],v=h.frustums[0].inverseProjectionMatrix,x=new te(2*u-1,2*g-1,2*_-1,1),y=v.mulVec4(x),w=h.unproject(u*h.width,(1-g)*h.height);return p=-y.z/y.w/w.dot(h.getForward()),p}(a,e,i,t);if(r===0)return;let s=a/t.width,n=(t.height-e)/t.height;return i.unproject(s*i.width,(1-n)*i.height).scaleTo(r).addA(i.eye)}}getLonLatFromPixelTerrain(a,e){if(this.planet){let t=this.getCartesianFromPixelTerrain(a,e);if(t)return this.planet.ellipsoid.cartesianToLonLat(t)}}activate(){super.activate()}deactivate(){super.deactivate()}},CameraFrameComposer:Jr,CameraFrameHandler:Ha,CameraLock:Na,CompassButton:Qs,Control:ee,DebugInfo:class extends ee{constructor(a={}){a.name&&a.name!==""||(a.name="DebugInfo"),super(a),this.el=null,this._watch=a.watch||[],this._toggleBtn=new _e({classList:["og-map-button","og-debuginfo_button"],icon:`<?xml version="1.0" encoding="iso-8859-1"?>
430
430
  <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
431
431
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
432
432
  <svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
@@ -465,19 +465,19 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
465
465
  c36.3,0.4,65.399,30.301,65,66.601c-0.4,36.3-30.301,65.399-66.601,65c-36.3-0.4-65.399-30.3-65-66.601
466
466
  C302.1,704.538,332,675.438,368.3,675.837z"/>
467
467
  </g>
468
- </svg>`}),this._dialog=new ot({title:"Debug Info",visible:!1,useHide:!0,top:120,left:60,width:480}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._canvasTiles=new sn("Tile grid",{visibility:!0,isBaseLayer:!1,hideInLayerSwitcher:!0,drawTile:function(e,t){let i,s=document.createElement("canvas"),r=s.getContext("2d");s.width=256,s.height=256,r.clearRect(0,0,s.width,s.height),r.beginPath(),r.rect(0,0,s.width,s.height),r.lineWidth=2,r.strokeStyle="black",r.stroke(),i=e.segment.tileZoom>14?"26":"32",r.fillStyle="black",r.font="normal "+i+"px Verdana",r.textAlign="center",r.fillText(e.segment.tileX+","+e.segment.tileY+","+e.segment.tileZoom,s.width/2,s.height/2),t(s)}})}addWatches(a){for(let e=0;e<a.length;e++)this.addWatch(a[e])}addWatch(a){this._watch.push(a);let e=document.createElement("div");e.classList.add("og-watch-line"),e.innerHTML=`<div class="og-watch-label">${a.label}</div><div class="og-watch-value"></div>`,a.valEl=e.querySelector(".og-watch-value"),this.el.appendChild(e)}oninit(){var a;this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._toggleBtn.events.on("change",n=>{this._dialog.setVisibility(n)}),this.el=document.createElement("div"),this.el.className="og-debug-info";let e=document.createElement("div");e.classList.add("og-debuginfo_controls"),this.el.appendChild(e);let t=this._watch;this._watch=[];for(let n=0;n<t.length;n++)this.addWatch(t[n]);(a=this._dialog.container)==null||a.appendChild(this.el),this.renderer.events.on("draw",this._frame,this);let i=this.planet;i&&this.addWatches([{label:"Nodes count",frame:()=>i._renderedNodes.length},{label:"Planet._fadingNodes",frame:()=>i._fadingNodes.size},{label:"createdNodes",frame:()=>i._createdNodesCount},{label:"indexesCache",frame:()=>i._indexesCacheToRemoveCounter},{label:"distBeforeMemClear",frame:()=>Math.round(i._distBeforeMemClear)},{label:"maxZoom/minZoom",frame:()=>i.maxCurrZoom+" / "+(i==null?void 0:i.minCurrZoom)},{label:"viewExtent",frame:()=>i.getViewExtent().toString()},{label:"Mouse distance, m",frame:()=>{let n=i.getCartesianFromMouseTerrain();return n?i.camera.eye.distance(n).toFixed(3):""}},{label:"lodSize",frame:()=>Math.round(i.lodSize)},{label:"deltaTime/FPS",frame:()=>`<div style="width:70px"><div style="width:20px; float: left;">
468
+ </svg>`}),this._dialog=new at({title:"Debug Info",visible:!1,useHide:!0,top:120,left:60,width:480}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._canvasTiles=new sn("Tile grid",{visibility:!0,isBaseLayer:!1,hideInLayerSwitcher:!0,drawTile:function(e,t){let i,r=document.createElement("canvas"),s=r.getContext("2d");r.width=256,r.height=256,s.clearRect(0,0,r.width,r.height),s.beginPath(),s.rect(0,0,r.width,r.height),s.lineWidth=2,s.strokeStyle="black",s.stroke(),i=e.segment.tileZoom>14?"26":"32",s.fillStyle="black",s.font="normal "+i+"px Verdana",s.textAlign="center",s.fillText(e.segment.tileX+","+e.segment.tileY+","+e.segment.tileZoom,r.width/2,r.height/2),t(r)}})}addWatches(a){for(let e=0;e<a.length;e++)this.addWatch(a[e])}addWatch(a){this._watch.push(a);let e=document.createElement("div");e.classList.add("og-watch-line"),e.innerHTML=`<div class="og-watch-label">${a.label}</div><div class="og-watch-value"></div>`,a.valEl=e.querySelector(".og-watch-value"),this.el.appendChild(e)}oninit(){var a;this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._toggleBtn.events.on("change",n=>{this._dialog.setVisibility(n)}),this.el=document.createElement("div"),this.el.className="og-debug-info";let e=document.createElement("div");e.classList.add("og-debuginfo_controls"),this.el.appendChild(e);let t=this._watch;this._watch=[];for(let n=0;n<t.length;n++)this.addWatch(t[n]);(a=this._dialog.container)==null||a.appendChild(this.el),this.renderer.events.on("draw",this._frame,this);let i=this.planet;i&&this.addWatches([{label:"Nodes count",frame:()=>i.quadTreeStrategy._renderedNodes.length},{label:"Planet._fadingNodes",frame:()=>i.quadTreeStrategy._fadingNodes.size},{label:"createdNodes",frame:()=>i._createdNodesCount},{label:"indexesCache",frame:()=>i._indexesCacheToRemoveCounter},{label:"distBeforeMemClear",frame:()=>Math.round(i._distBeforeMemClear)},{label:"maxZoom/minZoom",frame:()=>i.quadTreeStrategy.maxCurrZoom+" / "+(i==null?void 0:i.quadTreeStrategy.minCurrZoom)},{label:"viewExtent",frame:()=>i.getViewExtent().toString()},{label:"Mouse distance, m",frame:()=>{let n=i.getCartesianFromMouseTerrain();return n?i.camera.eye.distance(n).toFixed(3):""}},{label:"lodSize",frame:()=>Math.round(i.quadTreeStrategy.lodSize)},{label:"deltaTime/FPS",frame:()=>`<div style="width:70px"><div style="width:20px; float: left;">
469
469
  ${Math.round(i.renderer.handler.deltaTime)}
470
470
  </div> <div style="float: left">
471
471
  ${Math.round(1e3/i.renderer.handler.deltaTime)}
472
- </div></div>`},{label:"-------------------------"},{label:"Pitch, deg",frame:()=>(i.camera.getPitch()*J).toFixed(2)},{label:"Yaw, deg",frame:()=>(i.camera.getYaw()*J).toFixed(2)},{label:"Roll, deg",frame:()=>(i.camera.getRoll()*J).toFixed(2)},{label:"Lon, Lat",frame:()=>`<div style="width:190px">${i.camera._lonLat.lon.toFixed(7)}, ${i.camera._lonLat.lon.toFixed(7)}</div>`},{label:"height/alt, m",frame:()=>`<div style="width:190px">${i.camera._lonLat.height.toFixed(2)+" / "+i.camera.getAltitude().toFixed(2)}</div>`},{label:"cam.slope",frame:()=>i.camera.slope.toFixed(3)},{label:"-------------------------"},{label:"_renderCompleted / renderCompletedActivated",frame:()=>`${i._renderCompleted} / ${i._renderCompletedActivated}`},{label:"_terrainCompleted / terrainCompletedActivated",frame:()=>`${i._terrainCompleted} / ${i._terrainCompletedActivated}`},{label:"PlainWorker",frame:()=>i._plainSegmentWorker.pendingQueue.length},{label:"TileLoader",frame:()=>`${i._tileLoader.loading} ${i._tileLoader.queue.length}`},{label:"TerrainLoader",frame:()=>i.terrain&&!i.terrain.isEmpty?`${i.terrain.loader.loading} ${i.terrain.loader.queue.length}`:""},{label:"TerrainWorker",frame:()=>i._terrainWorker.pendingQueue.length},{label:"NormalMapCreator",frame:()=>i._normalMapCreator.queueSize},{label:"VectorTileCreator",frame:()=>i._vectorTileCreator.queueSize}]);let s=new fe({classList:["og-debuginfo_controls-button"],icon:`<?xml version="1.0" encoding="utf-8"?>
472
+ </div></div>`},{label:"-------------------------"},{label:"Pitch, deg",frame:()=>(i.camera.getPitch()*J).toFixed(2)},{label:"Yaw, deg",frame:()=>(i.camera.getYaw()*J).toFixed(2)},{label:"Roll, deg",frame:()=>(i.camera.getRoll()*J).toFixed(2)},{label:"Lon, Lat",frame:()=>`<div style="width:190px">${i.camera._lonLat.lon.toFixed(7)}, ${i.camera._lonLat.lon.toFixed(7)}</div>`},{label:"height/alt, m",frame:()=>`<div style="width:190px">${i.camera._lonLat.height.toFixed(2)+" / "+i.camera.getAltitude().toFixed(2)}</div>`},{label:"cam.slope",frame:()=>i.camera.slope.toFixed(3)},{label:"-------------------------"},{label:"_renderCompleted / renderCompletedActivated",frame:()=>`${i.quadTreeStrategy._renderCompleted} / ${i.quadTreeStrategy._renderCompletedActivated}`},{label:"_terrainCompleted / terrainCompletedActivated",frame:()=>`${i.quadTreeStrategy._terrainCompleted} / ${i.quadTreeStrategy._terrainCompletedActivated}`},{label:"PlainWorker",frame:()=>i._plainSegmentWorker.pendingQueue.length},{label:"TileLoader",frame:()=>`${i._tileLoader.loading} ${i._tileLoader.queue.length}`},{label:"TerrainLoader",frame:()=>i.terrain&&!i.terrain.isEmpty?`${i.terrain.loader.loading} ${i.terrain.loader.queue.length}`:""},{label:"TerrainWorker",frame:()=>i._terrainWorker.pendingQueue.length},{label:"NormalMapCreator",frame:()=>i._normalMapCreator.queueSize},{label:"VectorTileCreator",frame:()=>i._vectorTileCreator.queueSize}]);let r=new _e({classList:["og-debuginfo_controls-button"],icon:`<?xml version="1.0" encoding="utf-8"?>
473
473
  <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
474
474
  <svg fill="#000000" width="800px" height="800px" viewBox="-7.5 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
475
475
  <title>lock</title>
476
476
  <path d="M14.625 15.156h2.094c0.281 0 0.5 0.25 0.5 0.531v11c0 0.281-0.219 0.5-0.5 0.5h-16.219c-0.281 0-0.5-0.219-0.5-0.5v-11c0-0.281 0.219-0.531 0.5-0.531h2.031v-5.125c0-2.875 1.844-5.25 4.688-5.25h2.688c2.875 0 4.719 2.375 4.719 5.25v5.125zM5.188 15.156h6.813v-4.875c0-1.594-1.313-2.938-2.938-2.938h-0.969c-1.594 0-2.906 1.344-2.906 2.938v4.875zM7.156 24h2.906l-0.719-3.156c0.5-0.25 0.844-0.781 0.844-1.375 0-0.906-0.719-1.594-1.594-1.594s-1.563 0.688-1.563 1.594c0 0.594 0.344 1.125 0.844 1.375z"></path>
477
- </svg>`,title:"Lock/Unlock quad tree"});s.appendTo(e),s.events.on("change",n=>{n?i.lockQuadTree():i.unlockQuadTree()});let r=new fe({classList:["og-debuginfo_controls-button"],icon:`<?xml version="1.0"?>
477
+ </svg>`,title:"Lock/Unlock quad tree"});r.appendTo(e),r.events.on("change",n=>{n?i.lockQuadTree():i.unlockQuadTree()});let s=new _e({classList:["og-debuginfo_controls-button"],icon:`<?xml version="1.0"?>
478
478
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
479
479
  <path d="M 4 4 L 4 8 L 8 8 L 8 4 L 4 4 z M 10 4 L 10 8 L 14 8 L 14 4 L 10 4 z M 16 4 L 16 8 L 20 8 L 20 4 L 16 4 z M 4 10 L 4 14 L 8 14 L 8 10 L 4 10 z M 10 10 L 10 14 L 14 14 L 14 10 L 10 10 z M 16 10 L 16 14 L 20 14 L 20 10 L 16 10 z M 4 16 L 4 20 L 8 20 L 8 16 L 4 16 z M 10 16 L 10 20 L 14 20 L 14 16 L 10 16 z M 16 16 L 16 20 L 20 20 L 20 16 L 16 16 z"/>
480
- </svg>`,title:"Show/Hide grid"});r.appendTo(e),r.events.on("change",n=>{n?this.planet.addLayer(this._canvasTiles):this._canvasTiles.remove()})}_frame(){this._watch.forEach(a=>{a.valEl&&(a.valEl.innerHTML=a.frame?String(a.frame()):"")})}},DrawingControl:io,DrawingSwitcher:class extends te{constructor(a={}){super({name:"DrawingSwitcher",...a}),this.drawingControl=new io(a)}oninit(){this.planet.addControl(this.drawingControl),this._createMenu()}onactivate(){this.drawingControl.activate()}ondeactivate(){this.drawingControl.deactivate()}_createMenu(){let a=new fe({classList:["og-map-button","og-drawing-default_button"],icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 0l16 12.279-6.951 1.17 4.325 8.817-3.596 1.734-4.35-8.879-5.428 4.702z"/></svg>',name:"default",isActive:!0}),e=new fe({classList:["og-map-button","og-drawing-polygon_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
480
+ </svg>`,title:"Show/Hide grid"});s.appendTo(e),s.events.on("change",n=>{n?this.planet.addLayer(this._canvasTiles):this._canvasTiles.remove()})}_frame(){this._watch.forEach(a=>{a.valEl&&(a.valEl.innerHTML=a.frame?String(a.frame()):"")})}},DrawingControl:ra,DrawingSwitcher:class extends ee{constructor(a={}){super({name:"DrawingSwitcher",...a}),this.drawingControl=new ra(a)}oninit(){this.planet.addControl(this.drawingControl),this._createMenu()}onactivate(){this.drawingControl.activate()}ondeactivate(){this.drawingControl.deactivate()}_createMenu(){let a=new _e({classList:["og-map-button","og-drawing-default_button"],icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 0l16 12.279-6.951 1.17 4.325 8.817-3.596 1.734-4.35-8.879-5.428 4.702z"/></svg>',name:"default",isActive:!0}),e=new _e({classList:["og-map-button","og-drawing-polygon_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
481
481
  <!-- Generator: Adobe Illustrator 24.1.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
482
482
  <svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
483
483
  viewBox="0 0 1024 1024" style="enable-background:new 0 0 1024 1024;" xml:space="preserve">
@@ -504,11 +504,11 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
504
504
  c-5.1,3.18-11.07,5.1-17.52,5.1c-6.08,0-11.71-1.76-16.62-4.61c-9.71-5.64-16.33-15.94-16.64-27.89c-0.01-0.29-0.09-0.56-0.09-0.85
505
505
  c0-11.75,6.14-22.05,15.36-28c5.2-3.35,11.35-5.35,17.99-5.35C944.41,385.78,959.36,400.75,959.36,419.13z"/>
506
506
  </g>
507
- </svg>`,name:"polygon"}),t=new fe({classList:["og-map-button","og-drawing-linestring_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- License: MIT. Made by Esri: https://github.com/Esri/calcite-ui-icons -->
508
- <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21 6h.046l-5.25 9h-.944L10 9.455V7H7v2.926L1.862 18H0v3h3v-2.926L8.138 10h1.01L14 15.545V18h3v-3h-.046l5.25-9H24V3h-3zM8 8h1v1H8zM2 20H1v-1h1zm14-3h-1v-1h1zm7-13v1h-1V4z"/></svg>`,name:"linestring"});new rn({buttons:[a,e,t]}).events.on("change",i=>{switch(this.drawingControl.deactivate(),i.name){case"polygon":this.drawingControl.activatePolygonDrawing();break;case"linestring":this.drawingControl.activateLineStringDrawing()}}),a.appendTo(this.renderer.div),e.appendTo(this.renderer.div),t.appendTo(this.renderer.div)}},EarthCoordinates:lo,ElevationProfileControl:class extends te{constructor(a={}){super({name:"ElevationProfileControl",...a}),this._onSceneChange=()=>{this._collectProfileThrottled()},this._onElevationProfilePointer=(e,t,i,s,r,n,o,l)=>{let h=this._elevationProfileScene.getPointLonLat(n),c=this._elevationProfileScene.getPointLonLat(n+1),d=this.planet.ellipsoid.lonLatToCartesian(h),u=this.planet.ellipsoid.lonLatToCartesian(c),g=(e-t[0])/(i[0]-t[0]),f=u.sub(d);this._elevationProfileScene.setPointerCartesian3v(d.add(f.scale(g)),l)},this._onElevationProfileDblClick=(e,t,i,s,r,n,o,l)=>{let h=this._elevationProfileScene.getPointLonLat(n),c=this._elevationProfileScene.getPointLonLat(n+1),d=this.planet.ellipsoid.lonLatToCartesian(h),u=this.planet.ellipsoid.lonLatToCartesian(c),g=(e-t[0])/(i[0]-t[0]),f=u.sub(d),p=d.add(f.scale(g));this.planet.camera.flyDistance(p,this.planet.camera.eye.distance(p))},this._onElevationProfileMouseEnter=()=>{this._elevationProfileView.model.pointsReady&&this._elevationProfileScene.setPointerVisibility(!0)},this._onElevationProfileMouseLeave=()=>{},this._elevationProfileScene=new Bh,this._elevationProfileView=new Th,this._elevationProfileLegend=new Fh,this._elevationProfileButtonsView=new zh({model:this._elevationProfileView.model}),this._elevationProfileView.events.on("pointer",this._onElevationProfilePointer),this._elevationProfileView.events.on("dblclick",this._onElevationProfileDblClick),this._elevationProfileView.events.on("mouseenter",this._onElevationProfileMouseEnter),this._elevationProfileView.events.on("mouseleave",this._onElevationProfileMouseLeave),this._dialog=new ot({title:"Elevation Profile",visible:!1,resizable:!0,useHide:!0,top:175,left:65,width:400,height:200,minHeight:100,minWidth:100}),this._graphView=new be({template:`<div class="og-elevationprofile__container">
507
+ </svg>`,name:"polygon"}),t=new _e({classList:["og-map-button","og-drawing-linestring_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- License: MIT. Made by Esri: https://github.com/Esri/calcite-ui-icons -->
508
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21 6h.046l-5.25 9h-.944L10 9.455V7H7v2.926L1.862 18H0v3h3v-2.926L8.138 10h1.01L14 15.545V18h3v-3h-.046l5.25-9H24V3h-3zM8 8h1v1H8zM2 20H1v-1h1zm14-3h-1v-1h1zm7-13v1h-1V4z"/></svg>`,name:"linestring"});new nn({buttons:[a,e,t]}).events.on("change",i=>{switch(this.drawingControl.deactivate(),i.name){case"polygon":this.drawingControl.activatePolygonDrawing();break;case"linestring":this.drawingControl.activateLineStringDrawing()}}),a.appendTo(this.renderer.div),e.appendTo(this.renderer.div),t.appendTo(this.renderer.div)}},EarthCoordinates:ha,ElevationProfileControl:class extends ee{constructor(a={}){super({name:"ElevationProfileControl",...a}),this._onSceneChange=()=>{this._collectProfileThrottled()},this._onElevationProfilePointer=(e,t,i,r,s,n,o,l)=>{let h=this._elevationProfileScene.getPointLonLat(n),c=this._elevationProfileScene.getPointLonLat(n+1),d=this.planet.ellipsoid.lonLatToCartesian(h),u=this.planet.ellipsoid.lonLatToCartesian(c),g=(e-t[0])/(i[0]-t[0]),f=u.sub(d);this._elevationProfileScene.setPointerCartesian3v(d.add(f.scale(g)),l)},this._onElevationProfileDblClick=(e,t,i,r,s,n,o,l)=>{let h=this._elevationProfileScene.getPointLonLat(n),c=this._elevationProfileScene.getPointLonLat(n+1),d=this.planet.ellipsoid.lonLatToCartesian(h),u=this.planet.ellipsoid.lonLatToCartesian(c),g=(e-t[0])/(i[0]-t[0]),f=u.sub(d),p=d.add(f.scale(g));this.planet.camera.flyDistance(p,this.planet.camera.eye.distance(p))},this._onElevationProfileMouseEnter=()=>{this._elevationProfileView.model.pointsReady&&this._elevationProfileScene.setPointerVisibility(!0)},this._onElevationProfileMouseLeave=()=>{},this._elevationProfileScene=new Bh,this._elevationProfileView=new Th,this._elevationProfileLegend=new Fh,this._elevationProfileButtonsView=new zh({model:this._elevationProfileView.model}),this._elevationProfileView.events.on("pointer",this._onElevationProfilePointer),this._elevationProfileView.events.on("dblclick",this._onElevationProfileDblClick),this._elevationProfileView.events.on("mouseenter",this._onElevationProfileMouseEnter),this._elevationProfileView.events.on("mouseleave",this._onElevationProfileMouseLeave),this._dialog=new at({title:"Elevation Profile",visible:!1,resizable:!0,useHide:!0,top:175,left:65,width:400,height:200,minHeight:100,minWidth:100}),this._graphView=new be({template:`<div class="og-elevationprofile__container">
509
509
  <div class="og-elevationprofile__menu"></div>
510
510
  <div class="og-elevationprofile__graph"></div>
511
- </div>`}),this._poiListDialog=new Dh({model:this._elevationProfileScene}),this._toggleBtn=new fe({classList:["og-map-button","og-elevationprofile_button"],icon:'<svg style="width: 2em; height: 2em;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M128 896v-158.293333l331.946667-191.573334 160.853333 93.866667L896 480V896H128M896 381.44l-275.2 159.146667-160.853333-92.586667L128 640v-94.293333l331.946667-191.573334 160.853333 93.866667L896 288v93.44z" fill="" /></svg>'}),this._collectProfileThrottled=Kt(()=>{let e=this._elevationProfileScene.getPointsLonLat();this._elevationProfileView.model.collectProfile(e)},250)}oninit(){this._dialog.appendTo(this.planet.renderer.div),this._graphView.appendTo(this._dialog.container),this._toggleBtn.appendTo(this.renderer.div),this._dialog.events.on("visibility",a=>{this._toggleBtn.setActive(a),a?(this.activate(),this._elevationProfileView.resize()):this.deactivate()}),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this._elevationProfileView.appendTo(this._graphView.select(".og-elevationprofile__graph")),this._elevationProfileView.model.bindPlanet(this.planet),this._elevationProfileView.model.events.on("clear",()=>{this._elevationProfileScene.clear(),this._elevationProfileLegend.clear()}),this._elevationProfileView.model.events.on("startcollecting",()=>{this._elevationProfileScene.setPointerVisibility(!1)}),this._elevationProfileView.events.on("tracklength",a=>{this._elevationProfileLegend.setTrackLength(a)}),this._elevationProfileView.events.on("groundlength",a=>{this._elevationProfileLegend.setGroundLength(a)}),this._elevationProfileView.events.on("warninglength",a=>{this._elevationProfileLegend.setWarningLength(a)}),this._elevationProfileView.events.on("collisionlength",a=>{this._elevationProfileLegend.setCollisionLength(a)}),this._poiListDialog.appendTo(this.planet.renderer.div),this._poiListDialog.events.on("visibility",a=>{this._elevationProfileButtonsView.pointListBtn.setActive(a,!0)}),this._elevationProfileLegend.appendTo(this._graphView.select(".og-elevationprofile__menu")),this._elevationProfileButtonsView.appendTo(this._graphView.select(".og-elevationprofile__menu")),this._elevationProfileButtonsView.events.on("list",a=>{this._poiListDialog.setVisibility(a)}),this._elevationProfileButtonsView.events.on("location",a=>{this._elevationProfileScene.flyExtent()}),this._elevationProfileButtonsView.events.on("reset",a=>{this._elevationProfileScene.setPointerVisibility(!1)}),this._elevationProfileScene.events.on("change",this._onSceneChange)}onactivate(){this.planet&&this._elevationProfileScene.bindPlanet(this.planet),this.renderer&&this.renderer.addNode(this._elevationProfileScene)}ondeactivate(){this._poiListDialog.setVisibility(!1),this._elevationProfileView.model.clear(),this.renderer&&this.renderer.removeNode(this._elevationProfileScene),this._dialog.hide()}},FramebufferPreview:class extends te{constructor(a){super({autoActivate:!0,...a}),this._onDraw=()=>{if(this._framebuffer&&this._screenFramebuffer){let e=this.renderer,t=e.handler.gl;t.disable(t.BLEND),this._screenFramebuffer.activate();let i=this._program._programController,s=i._program;t.bindBuffer(t.ARRAY_BUFFER,e.screenFramePositionBuffer),t.vertexAttribPointer(s.attributes.corners,2,t.FLOAT,!1,0,0),i.activate(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._framebuffer.textures[this.framebufferCurrentTexture]),t.uniform1i(s.uniforms.inputTexture,0),t.drawArrays(t.TRIANGLE_STRIP,0,4),this._screenFramebuffer.deactivate(),t.enable(t.BLEND),this._screenFramebuffer.readPixelBuffersAsync(r=>{let n=r.getPixelBufferData();if(n){let o=r.width,l=r.height,h=this.$canvas.getContext("2d"),c=new Uint8ClampedArray(n.buffer,n.byteOffset,n.byteLength),d=new ImageData(c,o,l);createImageBitmap(d).then(u=>{h.clearRect(0,0,this.$canvas.width,this.$canvas.height),h.drawImage(u,0,0,this.$canvas.width,this.$canvas.height)})}})}},this._dialog=new ot({title:a.title||"",width:580,height:340,left:100,top:100}),this.$canvas=function(e,t){let i=document.createElement("canvas");return i.width=e,i.height=t,i.style.position="absolute",i.style.width="100%",i.style.height="100%",i}(this._dialog.width,this._dialog.height),this._framebuffer=a.framebuffer||null,this._screenFramebuffer=null,this.framebufferCurrentTexture=0,this._program=function(e=0,t,i,s){return new X(`framebuffer_dialog_screen:${e.toString()}`,{uniforms:{inputTexture:"sampler2D"},attributes:{corners:"vec2"},vertexShader:`#version 300 es
511
+ </div>`}),this._poiListDialog=new Dh({model:this._elevationProfileScene}),this._toggleBtn=new _e({classList:["og-map-button","og-elevationprofile_button"],icon:'<svg style="width: 2em; height: 2em;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M128 896v-158.293333l331.946667-191.573334 160.853333 93.866667L896 480V896H128M896 381.44l-275.2 159.146667-160.853333-92.586667L128 640v-94.293333l331.946667-191.573334 160.853333 93.866667L896 288v93.44z" fill="" /></svg>'}),this._collectProfileThrottled=Qt(()=>{let e=this._elevationProfileScene.getPointsLonLat();this._elevationProfileView.model.collectProfile(e)},250)}oninit(){this._dialog.appendTo(this.planet.renderer.div),this._graphView.appendTo(this._dialog.container),this._toggleBtn.appendTo(this.renderer.div),this._dialog.events.on("visibility",a=>{this._toggleBtn.setActive(a),a?(this.activate(),this._elevationProfileView.resize()):this.deactivate()}),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this._elevationProfileView.appendTo(this._graphView.select(".og-elevationprofile__graph")),this._elevationProfileView.model.bindPlanet(this.planet),this._elevationProfileView.model.events.on("clear",()=>{this._elevationProfileScene.clear(),this._elevationProfileLegend.clear()}),this._elevationProfileView.model.events.on("startcollecting",()=>{this._elevationProfileScene.setPointerVisibility(!1)}),this._elevationProfileView.events.on("tracklength",a=>{this._elevationProfileLegend.setTrackLength(a)}),this._elevationProfileView.events.on("groundlength",a=>{this._elevationProfileLegend.setGroundLength(a)}),this._elevationProfileView.events.on("warninglength",a=>{this._elevationProfileLegend.setWarningLength(a)}),this._elevationProfileView.events.on("collisionlength",a=>{this._elevationProfileLegend.setCollisionLength(a)}),this._poiListDialog.appendTo(this.planet.renderer.div),this._poiListDialog.events.on("visibility",a=>{this._elevationProfileButtonsView.pointListBtn.setActive(a,!0)}),this._elevationProfileLegend.appendTo(this._graphView.select(".og-elevationprofile__menu")),this._elevationProfileButtonsView.appendTo(this._graphView.select(".og-elevationprofile__menu")),this._elevationProfileButtonsView.events.on("list",a=>{this._poiListDialog.setVisibility(a)}),this._elevationProfileButtonsView.events.on("location",a=>{this._elevationProfileScene.flyExtent()}),this._elevationProfileButtonsView.events.on("reset",a=>{this._elevationProfileScene.setPointerVisibility(!1)}),this._elevationProfileScene.events.on("change",this._onSceneChange)}onactivate(){this.planet&&this._elevationProfileScene.bindPlanet(this.planet),this.renderer&&this.renderer.addNode(this._elevationProfileScene)}ondeactivate(){this._poiListDialog.setVisibility(!1),this._elevationProfileView.model.clear(),this.renderer&&this.renderer.removeNode(this._elevationProfileScene),this._dialog.hide()}},FramebufferPreview:class extends ee{constructor(a){super({autoActivate:!0,...a}),this._onDraw=()=>{if(this._framebuffer&&this._screenFramebuffer){let e=this.renderer,t=e.handler.gl;t.disable(t.BLEND),this._screenFramebuffer.activate();let i=this._program._programController,r=i._program;t.bindBuffer(t.ARRAY_BUFFER,e.screenFramePositionBuffer),t.vertexAttribPointer(r.attributes.corners,2,t.FLOAT,!1,0,0),i.activate(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._framebuffer.textures[this.framebufferCurrentTexture]),t.uniform1i(r.uniforms.inputTexture,0),t.drawArrays(t.TRIANGLE_STRIP,0,4),this._screenFramebuffer.deactivate(),t.enable(t.BLEND),this._screenFramebuffer.readPixelBuffersAsync(s=>{let n=s.getPixelBufferData();if(n){let o=s.width,l=s.height,h=this.$canvas.getContext("2d"),c=new Uint8ClampedArray(n.buffer,n.byteOffset,n.byteLength),d=new ImageData(c,o,l);createImageBitmap(d).then(u=>{h.clearRect(0,0,this.$canvas.width,this.$canvas.height),h.drawImage(u,0,0,this.$canvas.width,this.$canvas.height)})}})}},this._dialog=new at({title:a.title||"",width:580,height:340,left:100,top:100}),this.$canvas=function(e,t){let i=document.createElement("canvas");return i.width=e,i.height=t,i.style.position="absolute",i.style.width="100%",i.style.height="100%",i}(this._dialog.width,this._dialog.height),this._framebuffer=a.framebuffer||null,this._screenFramebuffer=null,this.framebufferCurrentTexture=0,this._program=function(e=0,t,i,r){return new X(`framebuffer_dialog_screen:${e.toString()}`,{uniforms:{inputTexture:"sampler2D"},attributes:{corners:"vec2"},vertexShader:`#version 300 es
512
512
 
513
513
  in vec2 corners;
514
514
 
@@ -517,7 +517,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
517
517
  void main(void) {
518
518
  gl_Position = vec4(corners, 0.0, 1.0);
519
519
  tc = corners * 0.5 + 0.5;
520
- ${s?"tc.y = 1.0 - tc.y;":""}
520
+ ${r?"tc.y = 1.0 - tc.y;":""}
521
521
  }`,fragmentShader:`#version 300 es
522
522
 
523
523
  precision highp float;
@@ -536,20 +536,20 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
536
536
 
537
537
  void main(void) {
538
538
  mainImage(fragColor, tc);
539
- }`})}(this.__id,a.common,a.image,a.flippedUV)}bindFramebuffer(a){a.isEqual(this._framebuffer)||(this._framebuffer=a)}oninit(){var a,e;super.oninit(),this.renderer&&(this.renderer.handler.addProgram(this._program),this._screenFramebuffer=new Me(this.renderer.handler,{width:(a=this._framebuffer)==null?void 0:a.width,height:(e=this._framebuffer)==null?void 0:e.height,useDepth:!1,targets:[{internalFormat:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT",readAsync:!0}]}),this._screenFramebuffer.init())}activate(){var a,e;super.activate(),this._dialog.appendTo(document.body),(a=this._dialog.container)==null||a.appendChild(this.$canvas),(e=this.renderer)==null||e.events.on("draw",this._onDraw)}deactivate(){var a;super.deactivate(),this._dialog.remove(),(a=this.renderer)==null||a.events.off("draw",this._onDraw)}},GeoImageDragControl:class extends te{constructor(a={}){super(a),this._cornerIndex=-1,this._catchCorner=!1,this._toggleBtn=new fe({classList:["og-map-button","og-geoimagegrag_button"],icon:'<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M16 13l6.964 4.062-2.973.85 2.125 3.681-1.732 1-2.125-3.68-2.223 2.15L16 13zm-2-7h2v2h5a1 1 0 0 1 1 1v4h-2v-3H10v10h4v2H9a1 1 0 0 1-1-1v-5H6v-2h2V9a1 1 0 0 1 1-1h5V6zM4 14v2H2v-2h2zm0-4v2H2v-2h2zm0-4v2H2V6h2zm0-4v2H2V2h2zm4 0v2H6V2h2zm4 0v2h-2V2h2zm4 0v2h-2V2h2z" fill="#000"/></svg>'})}oninit(){this._toggleBtn.appendTo(this.renderer.div),this.planet.events.on("layeradd",a=>{this.isActive()&&this._bindLayer(a)},this),this._toggleBtn.events.on("change",a=>{a?this.activate():this.deactivate()})}onactivate(){super.onactivate();const a=this.planet;for(let e=0;e<a.layers.length;e++)this._bindLayer(a.layers[e])}ondeactivate(){super.ondeactivate();const a=this.planet;for(let e=0;e<a.layers.length;e++)this._unbindLayer(a.layers[e])}_bindLayer(a){a instanceof ci&&(a.events.on("mousemove",this._onMouseMove,this),a.events.on("mouseleave",this._onMouseLeave,this),a.events.on("ldown",this._onLDown,this),a.events.on("lup",this._onLUp,this))}_unbindLayer(a){a instanceof ci&&(a.events.off("mousemove",this._onMouseMove),a.events.off("mouseleave",this._onMouseLeave),a.events.off("ldown",this._onLDown),a.events.off("lup",this._onLUp))}_onLUp(a){this._catchCorner=!1,a.renderer.controls.mouseNavigation.activate()}_onLDown(a){this._cornerIndex!==-1&&(this._catchCorner=!0,a.renderer.controls.mouseNavigation.deactivate())}_onMouseLeave(){document.body.style.cursor="auto"}_onMouseMove(a){let e=a.pickingObject;const t=this.planet;if(this._catchCorner){let i=e.getCornersLonLat();i[this._cornerIndex]=t.getLonLatFromPixelTerrain(a),e.setCornersLonLat(i)}else{this._cornerIndex=-1;for(let i=0;i<e._cornersWgs84.length;i++){let s=t.getLonLatFromPixelTerrain(a);if(s&&t.ellipsoid.getGreatCircleDistance(e._cornersWgs84[i],s)/t.getDistanceFromPixel(a)<=.05){this._cornerIndex=i,document.body.style.cursor="move";break}document.body.style.cursor="auto"}}}},GeoObjectEditor:class extends te{constructor(a={}){super(a),this._geoObjectEditopScene=new Yh({name:`geoObjectEditorScene:${this.__id}`}),this._dialog=new Zh({model:this._geoObjectEditopScene})}oninit(){this.renderer&&(this.renderer.addControl(new No({planet:this.planet})),this._geoObjectEditopScene.bindPlanet(this.planet),this._dialog.appendTo(this.renderer.div||document.body),this.activate())}onactivate(){this.renderer&&this.renderer.addNode(this._geoObjectEditopScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._geoObjectEditopScene),this._dialog.hide()}},HeightRuler:yo,KeyboardNavigation:class extends te{constructor(a={}){a=a||{},super({name:"KeyboardNavigation",...a}),this.onCameraPitchUp=()=>{this._camera&&this._camera.setPitch(this._camera.getPitch()+.1*j)},this.onCameraPitchDown=()=>{this._camera&&this._camera.setPitch(this._camera.getPitch()-.1*j)},this.onCameraYawLeft=()=>{this._camera&&this._camera.setYaw(this._camera.getYaw()-.1*j)},this.onCameraYawRight=()=>{this._camera&&this._camera.setYaw(this._camera.getYaw()+.1*j)},this.onCameraMoveForward=()=>{this._camera&&this.force.addA(this._camera.getForward()).normalize()},this.onCameraMoveBackward=()=>{this._camera&&this.force.addA(this._camera.getBackward()).normalize()},this._camera=a.camera||null,this.speed=a.speed||10,this.force=new v,this.vel=new v,this.mass=1}bindCamera(a){this._camera=a}onactivate(){let a=this.renderer;a.events.on("keypress",W.KEY_S,this.onCameraMoveBackward,this),a.events.on("keypress",W.KEY_W,this.onCameraMoveForward,this),a.events.on("keypress",W.KEY_UP,this.onCameraPitchUp,this),a.events.on("keypress",W.KEY_DOWN,this.onCameraPitchDown,this),a.events.on("keypress",W.KEY_LEFT,this.onCameraYawLeft,this),a.events.on("keypress",W.KEY_RIGHT,this.onCameraYawRight,this),a.events.on("draw",this.onDraw,this,-1e3)}ondeactivate(){this.renderer}oninit(){this.activate()}get dt(){return .001*this.renderer.handler.deltaTime}onDraw(){if(this.renderer&&this._camera){let a=this.force.scale(1/this.mass);this.vel.addA(a),this.vel.scale(.96),this.force.set(0,0,0);let e=this._camera;e.eye=e.eye.add(this.vel.scaleTo(this.dt)),e.update()}}},LayerAnimation:class extends te{constructor(a={}){super(a),this._currVisibleIndex=0,this._onViewchange=()=>{this._timeoutStart=performance.now()},this._onVisibilityChange=e=>{e||this.pause()},this._onLayerLoadend=e=>{let t=this._layersArr[this._currentIndex];if(t&&t.isEqual(e)){let i=this._getFrameIndex(this._currentIndex)*this._frameSize,s=this._currentIndex;for(let n=i;n<s;n++){let o=this._layersArr[n];o.opacity=0,o.setVisibility(!1)}t.opacity=1;let r=this._layersArr[this._currVisibleIndex];if(r){r.opacity=0,r.setVisibility(!1);let n=this._getFrameIndex(this._currVisibleIndex);this._getFrameIndex(this._currentIndex)!==n&&this._removeFrameFromPlanet(n)}this.events.dispatch(this.events.idle,t)}},this.events=he(Jl),this._name=a.name||`layerAnimation-${this.__id}`,this._layersArr=a.layers?[].concat(a.layers):[],this._currentIndex=-1,this._playInterval=a.playInterval||120,this._playIntervalHandler=-1,this._playIndex=0,this._frameSize=a.frameSize||50,this.repeat=a.repeat==null||a.repeat,this.skipTimeout=a.skipTimeout||5e3,this._timeoutStart=0}_getFramesNum(){return Math.ceil(this._layersArr.length/this._frameSize)}_setFrame(a){for(let e=0,t=this._getFramesNum();e<t;e++)e!==a?this._removeFrameFromPlanet(e):this._appendFrameToPlanet(e)}_getFrameIndex(a){return Math.floor(a/this._frameSize)}_appendFrameToPlanet(a){if(this.planet){let e=a*this._frameSize,t=e+this._frameSize;for(let i=e,s=t>this._layersArr.length?this._layersArr.length:t;i<s;i++)this.planet.addLayer(this._layersArr[i])}}_removeFrameFromPlanet(a){if(this.planet){let e=a*this._frameSize,t=e+this._frameSize;for(let i=e,s=t>this._layersArr.length?this._layersArr.length:t;i<s;i++)this._layersArr[i].abortLoading(),this._layersArr[i].remove(),this._layersArr[i].setVisibility(!1)}}oninit(){super.oninit(),this.onactivate(),this._initLayers(),this.planet.events.on("layerloadend",this._onLayerLoadend),this._setCurrentIndexAsync(0,!1,!0)}onactivate(){super.onactivate(),this.planet.camera.events.on("viewchange",this._onViewchange),this.planet.renderer.handler.events.on("visibilitychange",this._onVisibilityChange)}ondeactivate(){super.ondeactivate(),this.planet.camera.events.off("viewchange",this._onViewchange);for(let a=0;a<this._layersArr.length;a++)this._layersArr[a].setVisibility(!1);this.planet.events.off("layerloadend",this._onLayerLoadend),this.planet.renderer.handler.events.off("visibilitychange",this._onVisibilityChange)}clear(){this.stop(),this._currentIndex=-1,this._currVisibleIndex=-1;let a=this._layersArr;this._layersArr=[];for(let e=0;e<a.length;e++)a[e].remove()}_initLayers(){if(this.planet){for(let a=0,e=this._layersArr.length;a<e;a++){let t=this._layersArr[a];t.setVisibility(!1),t.setBaseLayer(!1),t.opacity=0}this._appendFrameToPlanet(0)}}setLayers(a){this.clear(),this._layersArr=[].concat(a),this._initLayers()}appendLayer(a){var e;this._layersArr.push(a),a.setVisibility(!1),a.setBaseLayer(!1),a.opacity=0,(e=this.planet)==null||e.addLayer(a)}get isIdle(){let a=this._layersArr[this._currentIndex];return a&&a.isIdle||!a}get playInterval(){return this._playInterval}set playInterval(a){a!==this._playInterval&&(this._playInterval=a,this.isPlaying&&(this.pause(),this.play()))}get isPlaying(){return this._playIntervalHandler!==-1}get layers(){return this._layersArr}_checkEnd(){this._playIndex>this._layersArr.length&&(this.repeat?this._playIndex=0:this.pause())}play(){this.isPlaying||(this._currentIndex>=this._layersArr.length-1&&this.stop(),this._timeoutStart=performance.now(),this._playIntervalHandler=setInterval(()=>{this._checkEnd(),this._setCurrentIndexAsync(this._playIndex,!1,!1),requestAnimationFrame(()=>{(this.isIdle||performance.now()-this._timeoutStart>this.skipTimeout)&&(this._playIndex++,this._timeoutStart=performance.now())})},this._playInterval),this.events.dispatch(this.events.play))}stop(){this._playIndex>0&&(this._clearInterval(),this._playIndex=0,this.setCurrentIndex(0),this.events.dispatch(this.events.stop))}pause(){this.isPlaying&&(this._clearInterval(),this.events.dispatch(this.events.pause))}_clearInterval(){clearInterval(this._playIntervalHandler),this._playIntervalHandler=-1}setCurrentIndex(a,e=!1){this._setCurrentIndexAsync(a,!0,e)}_setCurrentIndexAsync(a,e=!1,t=!1){if(a!=this._currentIndex&&a>=0&&a<this._layersArr.length){let i=this._currentIndex;this._currentIndex=a,this._playIndex=a;let s=this._getFrameIndex(i),r=this._getFrameIndex(this._currentIndex),n=this._layersArr[i],o=this._layersArr[a],l=r!=s;l&&this._appendFrameToPlanet(r),n&&(n.isIdle?this._currVisibleIndex=i:(n.opacity=0,n.setVisibility(!1))),o&&(o.opacity=0,o.setVisibility(!0),requestAnimationFrame(()=>{if(o.isIdle||e){o.opacity=1,l&&this._removeFrameFromPlanet(s),n&&(n.opacity=0,n.setVisibility(!1));let h=this._layersArr[this._currVisibleIndex];h&&(h.opacity=0,h.setVisibility(!1))}}),t||this.events.dispatch(this.events.change,this._currentIndex,i))}}},LayerSwitcher:class extends te{constructor(a={}){super({name:"LayerSwitcher",...a}),this.addLayer=e=>{if(!e.hideInLayerSwitcher){let t=this._createLayerButton(e);this._layerViews.push(t),e.isBaseLayer()?t.appendTo(this.$baseLayers):t.appendTo(this.$overlays)}},this.removeLayer=e=>{for(let t=0;t<this._layerViews.length;t++){let i=this._layerViews[t];if(i.model.isEqual(e)){i.remove(),this._layerViews.splice(t,1);break}}},this._dialog=new ot({title:"Layer Switcher",top:15,useHide:!0,visible:!1,width:300,maxHeight:500}),this._panel=new be({template:`<div class="og-layerSwitcher">
539
+ }`})}(this.__id,a.common,a.image,a.flippedUV)}bindFramebuffer(a){a.isEqual(this._framebuffer)||(this._framebuffer=a)}oninit(){var a,e;super.oninit(),this.renderer&&(this.renderer.handler.addProgram(this._program),this._screenFramebuffer=new Se(this.renderer.handler,{width:(a=this._framebuffer)==null?void 0:a.width,height:(e=this._framebuffer)==null?void 0:e.height,useDepth:!1,targets:[{internalFormat:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT",readAsync:!0}]}),this._screenFramebuffer.init())}activate(){var a,e;super.activate(),this._dialog.appendTo(document.body),(a=this._dialog.container)==null||a.appendChild(this.$canvas),(e=this.renderer)==null||e.events.on("draw",this._onDraw)}deactivate(){var a;super.deactivate(),this._dialog.remove(),(a=this.renderer)==null||a.events.off("draw",this._onDraw)}},GeoImageDragControl:class extends ee{constructor(a={}){super(a),this._cornerIndex=-1,this._catchCorner=!1,this._toggleBtn=new _e({classList:["og-map-button","og-geoimagegrag_button"],icon:'<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M16 13l6.964 4.062-2.973.85 2.125 3.681-1.732 1-2.125-3.68-2.223 2.15L16 13zm-2-7h2v2h5a1 1 0 0 1 1 1v4h-2v-3H10v10h4v2H9a1 1 0 0 1-1-1v-5H6v-2h2V9a1 1 0 0 1 1-1h5V6zM4 14v2H2v-2h2zm0-4v2H2v-2h2zm0-4v2H2V6h2zm0-4v2H2V2h2zm4 0v2H6V2h2zm4 0v2h-2V2h2zm4 0v2h-2V2h2z" fill="#000"/></svg>'})}oninit(){this._toggleBtn.appendTo(this.renderer.div),this.planet.events.on("layeradd",a=>{this.isActive()&&this._bindLayer(a)},this),this._toggleBtn.events.on("change",a=>{a?this.activate():this.deactivate()})}onactivate(){super.onactivate();const a=this.planet;for(let e=0;e<a.layers.length;e++)this._bindLayer(a.layers[e])}ondeactivate(){super.ondeactivate();const a=this.planet;for(let e=0;e<a.layers.length;e++)this._unbindLayer(a.layers[e])}_bindLayer(a){a instanceof hi&&(a.events.on("mousemove",this._onMouseMove,this),a.events.on("mouseleave",this._onMouseLeave,this),a.events.on("ldown",this._onLDown,this),a.events.on("lup",this._onLUp,this))}_unbindLayer(a){a instanceof hi&&(a.events.off("mousemove",this._onMouseMove),a.events.off("mouseleave",this._onMouseLeave),a.events.off("ldown",this._onLDown),a.events.off("lup",this._onLUp))}_onLUp(a){this._catchCorner=!1,a.renderer.controls.mouseNavigation.activate()}_onLDown(a){this._cornerIndex!==-1&&(this._catchCorner=!0,a.renderer.controls.mouseNavigation.deactivate())}_onMouseLeave(){document.body.style.cursor="auto"}_onMouseMove(a){let e=a.pickingObject;const t=this.planet;if(this._catchCorner){let i=e.getCornersLonLat();i[this._cornerIndex]=t.getLonLatFromPixelTerrain(a),e.setCornersLonLat(i)}else{this._cornerIndex=-1;for(let i=0;i<e._cornersWgs84.length;i++){let r=t.getLonLatFromPixelTerrain(a);if(r&&t.ellipsoid.getGreatCircleDistance(e._cornersWgs84[i],r)/t.getDistanceFromPixel(a)<=.05){this._cornerIndex=i,document.body.style.cursor="move";break}document.body.style.cursor="auto"}}}},GeoObjectEditor:class extends ee{constructor(a={}){super(a),this._geoObjectEditopScene=new qh({name:`geoObjectEditorScene:${this.__id}`}),this._dialog=new Zh({model:this._geoObjectEditopScene})}oninit(){this.renderer&&(this.renderer.addControl(new Na({planet:this.planet})),this._geoObjectEditopScene.bindPlanet(this.planet),this._dialog.appendTo(this.renderer.div||document.body),this.activate())}onactivate(){this.renderer&&this.renderer.addNode(this._geoObjectEditopScene)}ondeactivate(){this.renderer&&this.renderer.removeNode(this._geoObjectEditopScene),this._dialog.hide()}},HeightRuler:ya,KeyboardNavigation:class extends ee{constructor(a={}){a=a||{},super({name:"KeyboardNavigation",...a}),this.onCameraPitchUp=()=>{this._camera&&this._camera.setPitch(this._camera.getPitch()+.1*U)},this.onCameraPitchDown=()=>{this._camera&&this._camera.setPitch(this._camera.getPitch()-.1*U)},this.onCameraYawLeft=()=>{this._camera&&this._camera.setYaw(this._camera.getYaw()-.1*U)},this.onCameraYawRight=()=>{this._camera&&this._camera.setYaw(this._camera.getYaw()+.1*U)},this.onCameraMoveForward=()=>{this._camera&&this.force.addA(this._camera.getForward()).normalize()},this.onCameraMoveBackward=()=>{this._camera&&this.force.addA(this._camera.getBackward()).normalize()},this._camera=a.camera||null,this.speed=a.speed||10,this.force=new m,this.vel=new m,this.mass=1}bindCamera(a){this._camera=a}onactivate(){let a=this.renderer;a.events.on("keypress",W.KEY_S,this.onCameraMoveBackward,this),a.events.on("keypress",W.KEY_W,this.onCameraMoveForward,this),a.events.on("keypress",W.KEY_UP,this.onCameraPitchUp,this),a.events.on("keypress",W.KEY_DOWN,this.onCameraPitchDown,this),a.events.on("keypress",W.KEY_LEFT,this.onCameraYawLeft,this),a.events.on("keypress",W.KEY_RIGHT,this.onCameraYawRight,this),a.events.on("draw",this.onDraw,this,-1e3)}ondeactivate(){this.renderer}oninit(){this.activate()}get dt(){return .001*this.renderer.handler.deltaTime}onDraw(){if(this.renderer&&this._camera){let a=this.force.scale(1/this.mass);this.vel.addA(a),this.vel.scale(.96),this.force.set(0,0,0);let e=this._camera;e.eye=e.eye.add(this.vel.scaleTo(this.dt)),e.update()}}},LayerAnimation:class extends ee{constructor(a={}){super(a),this._currVisibleIndex=0,this._onViewchange=()=>{this._timeoutStart=performance.now()},this._onVisibilityChange=e=>{e||this.pause()},this._onLayerLoadend=e=>{let t=this._layersArr[this._currentIndex];if(t&&t.isEqual(e)){let i=this._getFrameIndex(this._currentIndex)*this._frameSize,r=this._currentIndex;for(let n=i;n<r;n++){let o=this._layersArr[n];o.opacity=0,o.setVisibility(!1)}t.opacity=1;let s=this._layersArr[this._currVisibleIndex];if(s){s.opacity=0,s.setVisibility(!1);let n=this._getFrameIndex(this._currVisibleIndex);this._getFrameIndex(this._currentIndex)!==n&&this._removeFrameFromPlanet(n)}this.events.dispatch(this.events.idle,t)}},this.events=le(Jl),this._name=a.name||`layerAnimation-${this.__id}`,this._layersArr=a.layers?[].concat(a.layers):[],this._currentIndex=-1,this._playInterval=a.playInterval||120,this._playIntervalHandler=-1,this._playIndex=0,this._frameSize=a.frameSize||50,this.repeat=a.repeat==null||a.repeat,this.skipTimeout=a.skipTimeout||5e3,this._timeoutStart=0}_getFramesNum(){return Math.ceil(this._layersArr.length/this._frameSize)}_setFrame(a){for(let e=0,t=this._getFramesNum();e<t;e++)e!==a?this._removeFrameFromPlanet(e):this._appendFrameToPlanet(e)}_getFrameIndex(a){return Math.floor(a/this._frameSize)}_appendFrameToPlanet(a){if(this.planet){let e=a*this._frameSize,t=e+this._frameSize;for(let i=e,r=t>this._layersArr.length?this._layersArr.length:t;i<r;i++)this.planet.addLayer(this._layersArr[i])}}_removeFrameFromPlanet(a){if(this.planet){let e=a*this._frameSize,t=e+this._frameSize;for(let i=e,r=t>this._layersArr.length?this._layersArr.length:t;i<r;i++)this._layersArr[i].abortLoading(),this._layersArr[i].remove(),this._layersArr[i].setVisibility(!1)}}oninit(){super.oninit(),this.onactivate(),this._initLayers(),this.planet.events.on("layerloadend",this._onLayerLoadend),this._setCurrentIndexAsync(0,!1,!0)}onactivate(){super.onactivate(),this.planet.camera.events.on("viewchange",this._onViewchange),this.planet.renderer.handler.events.on("visibilitychange",this._onVisibilityChange)}ondeactivate(){super.ondeactivate(),this.planet.camera.events.off("viewchange",this._onViewchange);for(let a=0;a<this._layersArr.length;a++)this._layersArr[a].setVisibility(!1);this.planet.events.off("layerloadend",this._onLayerLoadend),this.planet.renderer.handler.events.off("visibilitychange",this._onVisibilityChange)}clear(){this.stop(),this._currentIndex=-1,this._currVisibleIndex=-1;let a=this._layersArr;this._layersArr=[];for(let e=0;e<a.length;e++)a[e].remove()}_initLayers(){if(this.planet){for(let a=0,e=this._layersArr.length;a<e;a++){let t=this._layersArr[a];t.setVisibility(!1),t.setBaseLayer(!1),t.opacity=0}this._appendFrameToPlanet(0)}}setLayers(a){this.clear(),this._layersArr=[].concat(a),this._initLayers()}appendLayer(a){var e;this._layersArr.push(a),a.setVisibility(!1),a.setBaseLayer(!1),a.opacity=0,(e=this.planet)==null||e.addLayer(a)}get isIdle(){let a=this._layersArr[this._currentIndex];return a&&a.isIdle||!a}get playInterval(){return this._playInterval}set playInterval(a){a!==this._playInterval&&(this._playInterval=a,this.isPlaying&&(this.pause(),this.play()))}get isPlaying(){return this._playIntervalHandler!==-1}get layers(){return this._layersArr}_checkEnd(){this._playIndex>this._layersArr.length&&(this.repeat?this._playIndex=0:this.pause())}play(){this.isPlaying||(this._currentIndex>=this._layersArr.length-1&&this.stop(),this._timeoutStart=performance.now(),this._playIntervalHandler=setInterval(()=>{this._checkEnd(),this._setCurrentIndexAsync(this._playIndex,!1,!1),requestAnimationFrame(()=>{(this.isIdle||performance.now()-this._timeoutStart>this.skipTimeout)&&(this._playIndex++,this._timeoutStart=performance.now())})},this._playInterval),this.events.dispatch(this.events.play))}stop(){this._playIndex>0&&(this._clearInterval(),this._playIndex=0,this.setCurrentIndex(0),this.events.dispatch(this.events.stop))}pause(){this.isPlaying&&(this._clearInterval(),this.events.dispatch(this.events.pause))}_clearInterval(){clearInterval(this._playIntervalHandler),this._playIntervalHandler=-1}setCurrentIndex(a,e=!1){this._setCurrentIndexAsync(a,!0,e)}_setCurrentIndexAsync(a,e=!1,t=!1){if(a!=this._currentIndex&&a>=0&&a<this._layersArr.length){let i=this._currentIndex;this._currentIndex=a,this._playIndex=a;let r=this._getFrameIndex(i),s=this._getFrameIndex(this._currentIndex),n=this._layersArr[i],o=this._layersArr[a],l=s!=r;l&&this._appendFrameToPlanet(s),n&&(n.isIdle?this._currVisibleIndex=i:(n.opacity=0,n.setVisibility(!1))),o&&(o.opacity=0,o.setVisibility(!0),requestAnimationFrame(()=>{if(o.isIdle||e){o.opacity=1,l&&this._removeFrameFromPlanet(r),n&&(n.opacity=0,n.setVisibility(!1));let h=this._layersArr[this._currVisibleIndex];h&&(h.opacity=0,h.setVisibility(!1))}}),t||this.events.dispatch(this.events.change,this._currentIndex,i))}}},LayerSwitcher:class extends ee{constructor(a={}){super({name:"LayerSwitcher",...a}),this.addLayer=e=>{if(!e.hideInLayerSwitcher){let t=this._createLayerButton(e);this._layerViews.push(t),e.isBaseLayer()?t.appendTo(this.$baseLayers):t.appendTo(this.$overlays)}},this.removeLayer=e=>{for(let t=0;t<this._layerViews.length;t++){let i=this._layerViews[t];if(i.model.isEqual(e)){i.remove(),this._layerViews.splice(t,1);break}}},this._dialog=new at({title:"Layer Switcher",top:15,useHide:!0,visible:!1,width:300,maxHeight:500}),this._panel=new be({template:`<div class="og-layerSwitcher">
540
540
  <div class="og-layerSwitcher__title">Base Layers</div>
541
541
  <div class="og-layerSwitcher__list og-layerSwitcher__baseLayers"></div>
542
542
 
543
543
  <div class="og-layerSwitcher__title">Overlays</div>
544
544
  <div class="og-layerSwitcher__list og-layerSwitcher__overlays"></div>
545
545
 
546
- </div>`}),this._toggleBtn=new fe({classList:["og-map-button","og-layerSwitcher_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
546
+ </div>`}),this._toggleBtn=new _e({classList:["og-map-button","og-layerSwitcher_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
547
547
  <!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
548
548
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
549
549
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
550
550
  <metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
551
551
  <g><path d="M500,573.5c-3.2,0-6.5-0.6-9.5-1.9L25,375.6c-9.1-3.8-15-12.7-15-22.6s5.9-18.8,15-22.6l465.5-196c6.1-2.5,12.9-2.5,19,0l465.5,196c9.1,3.8,15,12.7,15,22.6s-5.9,18.8-15,22.6l-465.5,196C506.5,572.9,503.2,573.5,500,573.5L500,573.5z M97.6,353L500,522.4L902.4,353L500,183.6L97.6,353L97.6,353z"/><path d="M500,720.5c-3.2,0-6.5-0.6-9.5-1.9L25,522.6c-12.4-5.2-18.3-19.6-13.1-32.1c5.2-12.5,19.6-18.3,32.1-13.1l456,192l456-192c12.4-5.2,26.9,0.6,32.1,13.1s-0.6,26.9-13.1,32.1l-465.5,196C506.5,719.9,503.2,720.5,500,720.5L500,720.5z"/><path d="M500,867.5c-3.2,0-6.5-0.6-9.5-1.9L25,669.6c-12.4-5.2-18.3-19.6-13.1-32.1c5.2-12.5,19.6-18.3,32.1-13.1l456,192l456-192c12.4-5.2,26.9,0.6,32.1,13.1c5.2,12.5-0.6,26.8-13.1,32.1l-465.5,196C506.5,866.9,503.2,867.5,500,867.5L500,867.5z"/></g>
552
- </svg>`}),this.$baseLayers=null,this.$overlays=null,this._layerViews=[]}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.planet.renderer.div),this._panel.appendTo(this._dialog.container),this.$baseLayers=this._panel.el.querySelector(".og-layerSwitcher__baseLayers"),this.$overlays=this._panel.el.querySelector(".og-layerSwitcher__overlays"),this._dialog.setPosition(this.planet.renderer.div.clientWidth-this._dialog.width-67),this._dialog.events.on("visibility",a=>{this._toggleBtn.setActive(a)}),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this.planet.events.on("layeradd",this.addLayer,this),this.planet.events.on("layerremove",this.removeLayer,this),this._initLayers()}_initLayers(){let a=this.planet.layers;for(let e=0;e<a.length;e++)this.addLayer(a[e])}_createLayerButton(a){return new eh({model:a})}onactivate(){}ondeactivate(){this._dialog.hide()}},Lighting:class extends te{constructor(a={}){super(a),this._selectedLayer=null,this._toggleBtn=new fe({classList:["og-map-button","og-lighting_button"],icon:`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="256" height="256" viewBox="0 0 256 256" xml:space="preserve">
552
+ </svg>`}),this.$baseLayers=null,this.$overlays=null,this._layerViews=[]}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.planet.renderer.div),this._panel.appendTo(this._dialog.container),this.$baseLayers=this._panel.el.querySelector(".og-layerSwitcher__baseLayers"),this.$overlays=this._panel.el.querySelector(".og-layerSwitcher__overlays"),this._dialog.setPosition(this.planet.renderer.div.clientWidth-this._dialog.width-67),this._dialog.events.on("visibility",a=>{this._toggleBtn.setActive(a)}),this._toggleBtn.events.on("change",a=>{this._dialog.setVisibility(a)}),this.planet.events.on("layeradd",this.addLayer,this),this.planet.events.on("layerremove",this.removeLayer,this),this._initLayers()}_initLayers(){let a=this.planet.layers;for(let e=0;e<a.length;e++)this.addLayer(a[e])}_createLayerButton(a){return new eh({model:a})}onactivate(){}ondeactivate(){this._dialog.hide()}},Lighting:class extends ee{constructor(a={}){super(a),this._selectedLayer=null,this._toggleBtn=new _e({classList:["og-map-button","og-lighting_button"],icon:`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="256" height="256" viewBox="0 0 256 256" xml:space="preserve">
553
553
 
554
554
  <defs>
555
555
  </defs>
@@ -564,7 +564,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
564
564
  <path d="M 23.473 26.473 c -0.768 0 -1.536 -0.293 -2.121 -0.878 l -8.171 -8.171 c -1.172 -1.172 -1.172 -3.071 0 -4.243 c 1.172 -1.172 3.072 -1.171 4.243 0 l 8.171 8.171 c 1.172 1.172 1.172 3.071 0 4.243 C 25.008 26.18 24.24 26.473 23.473 26.473 z" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill-rule: nonzero; opacity: 1;" transform=" matrix(1 0 0 1 0 0) " stroke-linecap="round" />
565
565
  <path d="M 74.698 77.698 c -0.768 0 -1.535 -0.293 -2.121 -0.879 l -8.171 -8.171 c -1.172 -1.171 -1.172 -3.071 0 -4.242 c 1.172 -1.172 3.07 -1.172 4.242 0 l 8.171 8.171 c 1.172 1.171 1.172 3.071 0 4.242 C 76.233 77.405 75.466 77.698 74.698 77.698 z" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill-rule: nonzero; opacity: 1;" transform=" matrix(1 0 0 1 0 0) " stroke-linecap="round" />
566
566
  </g>
567
- </svg>`}),this._dialog=new ot({title:"Lighting Parameters",visible:!1,useHide:!0,top:60,left:60,width:600}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._panel=new be({template:`<div class="og-lighing og-options-container">
567
+ </svg>`}),this._dialog=new at({title:"Lighting Parameters",visible:!1,useHide:!0,top:60,left:60,width:600}),this._dialog.events.on("visibility",e=>{this._toggleBtn.setActive(e)}),this._panel=new be({template:`<div class="og-lighing og-options-container">
568
568
 
569
569
  <div class="og-option">
570
570
  <div class="og-suncontrol"></div>
@@ -607,11 +607,11 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
607
607
  <div class="og-option og-specular">
608
608
  </div>
609
609
 
610
- </div>`}),this.$gamma=null,this.$exposure=null,this.$night=null,this.$opacity=null,this.$diffuse=null,this.$ambient=null,this.$specular=null,this.$atmosphereOpacity=null,this.$simpleSkyBackground=null,this._atmosphereMaxOpacity=new Q({label:"Max.opacity",max:5}),this._atmosphereMinOpacity=new Q({label:"Min.opacity",max:5}),this._simpleSkyBackgroundColorOne=new ho({label:"Color One"}),this._simpleSkyBackgroundColorTwo=new ho({label:"Color Two"}),this._gamma=new Q({label:"Gamma",max:5}),this._exposure=new Q({label:"Exposure",max:5}),this._night=new Q({label:"Nightlight",max:5}),this._opacity=new Q({label:"Opacity",max:1}),this._diffuse_r=new Q({label:"Diffuse R",max:5}),this._diffuse_g=new Q({label:"Diffuse G",max:5}),this._diffuse_b=new Q({label:"Diffuse B",max:5}),this._ambient_r=new Q({label:"Ambient R",max:5}),this._ambient_g=new Q({label:"Ambient G",max:5}),this._ambient_b=new Q({label:"Ambient B",max:5}),this._specular_r=new Q({label:"Specular R",max:.2}),this._specular_g=new Q({label:"Specular G",max:.2}),this._specular_b=new Q({label:"Specular B",max:.2}),this._shininess=new Q({label:"Shininess",max:100})}bindLayer(a){this._selectedLayer=a,this._opacity.value=a.opacity,this._update()}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._panel.appendTo(this._dialog.container),this._panel.el&&(this.$atmosphereOpacity=this._panel.el.querySelector(".og-atmosphere-opacity"),this.$simpleSkyBackground=this._panel.el.querySelector(".og-simpleskybackground"),this.$gamma=this._panel.el.querySelector(".og-option.og-gamma"),this.$exposure=this._panel.el.querySelector(".og-option.og-exposure"),this.$opacity=this._panel.el.querySelector(".og-option.og-opacity"),this.$diffuse=this._panel.el.querySelector(".og-option.og-diffuse"),this.$ambient=this._panel.el.querySelector(".og-option.og-ambient"),this.$specular=this._panel.el.querySelector(".og-option.og-specular"),this.$night=this._panel.el.querySelector(".og-option.og-night")),this._toggleBtn.events.on("change",n=>{this._dialog.setVisibility(n)});let a=this._dialog.select(".og-suncontrol"),e=new fe({classList:["og-suncontrol-button"],isActive:!0,icon:'<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 70.41" style="enable-background:new 0 0 122.88 70.41" xml:space="preserve"><g><path d="M60.91,19.12c6.95,0,13.24,2.95,17.8,7.72c4.55,4.77,7.37,11.37,7.37,18.64c0,1.94-0.2,3.83-0.58,5.65h31.61 c2.1,0,2.62,1.16,2.62,2.59c0,1.43-0.52,2.59-2.62,2.59H7.09c-2.1,0-2.62-1.16-2.62-2.59c0-1.43,0.52-2.59,2.62-2.59h29.23 c-0.38-1.82-0.58-3.71-0.58-5.65c0-7.28,2.82-13.87,7.37-18.64C47.67,22.08,53.96,19.12,60.91,19.12L60.91,19.12L60.91,19.12z M63.4,70.41c-2.1,0-2.62-1.16-2.62-2.59s0.52-2.59,2.62-2.59h56.86c2.1,0,2.62,1.16,2.62,2.59s-0.52,2.59-2.62,2.59H63.4 L63.4,70.41z M2.62,70.41c-2.1,0-2.62-1.16-2.62-2.59s0.52-2.59,2.62-2.59h29.51c2.1,0,2.62,1.16,2.62,2.59s-0.52,2.59-2.62,2.59 H2.62L2.62,70.41z M38.39,9.46c-0.78-1.35-0.32-3.07,1.03-3.85c1.35-0.78,3.07-0.32,3.85,1.03l3.62,6.27 c0.78,1.35,0.32,3.07-1.03,3.85c-1.35,0.78-3.07,0.32-3.85-1.03L38.39,9.46L38.39,9.46L38.39,9.46z M58.67,2.83 c0-1.56,1.27-2.83,2.83-2.83c1.56,0,2.83,1.27,2.83,2.83v7.24c0,1.56-1.27,2.83-2.83,2.83c-1.56,0-2.83-1.26-2.83-2.83V2.83 L58.67,2.83L58.67,2.83z M79.56,7.23c0.77-1.35,2.49-1.81,3.84-1.04c1.35,0.77,1.81,2.49,1.04,3.84l-3.62,6.27 c-0.77,1.35-2.49,1.81-3.84,1.04c-1.35-0.77-1.81-2.49-1.04-3.84L79.56,7.23L79.56,7.23L79.56,7.23z M95.45,21.48 c1.35-0.78,3.07-0.32,3.85,1.03c0.78,1.35,0.32,3.07-1.03,3.85L92,29.98c-1.35,0.78-3.07,0.32-3.85-1.03 c-0.78-1.35-0.32-3.07,1.03-3.85L95.45,21.48L95.45,21.48L95.45,21.48z M102.08,41.76c1.56,0,2.83,1.27,2.83,2.83 c0,1.56-1.27,2.83-2.83,2.83h-7.24c-1.56,0-2.83-1.26-2.83-2.83s1.26-2.83,2.83-2.83H102.08L102.08,41.76L102.08,41.76z M19.74,46.25c-1.56,0-2.83-1.27-2.83-2.83c0-1.56,1.27-2.83,2.83-2.83h7.24c1.56,0,2.83,1.26,2.83,2.83s-1.27,2.83-2.83,2.83 H19.74L19.74,46.25L19.74,46.25z M24.14,25.35c-1.35-0.77-1.81-2.49-1.04-3.84c0.77-1.35,2.49-1.81,3.84-1.04l6.27,3.62 c1.35,0.77,1.81,2.49,1.04,3.84c-0.77,1.35-2.49,1.81-3.84,1.04L24.14,25.35L24.14,25.35L24.14,25.35z"/></g></svg>',title:"Star/stop the Sun from following the camera"});e.appendTo(a);let t=new fe({classList:["og-suncontrol-button"],isActive:!0,icon:`<?xml version="1.0"?>
610
+ </div>`}),this.$gamma=null,this.$exposure=null,this.$night=null,this.$opacity=null,this.$diffuse=null,this.$ambient=null,this.$specular=null,this.$atmosphereOpacity=null,this.$simpleSkyBackground=null,this._atmosphereMaxOpacity=new Q({label:"Max.opacity",max:5}),this._atmosphereMinOpacity=new Q({label:"Min.opacity",max:5}),this._simpleSkyBackgroundColorOne=new ca({label:"Color One"}),this._simpleSkyBackgroundColorTwo=new ca({label:"Color Two"}),this._gamma=new Q({label:"Gamma",max:5}),this._exposure=new Q({label:"Exposure",max:5}),this._night=new Q({label:"Nightlight",max:5}),this._opacity=new Q({label:"Opacity",max:1}),this._diffuse_r=new Q({label:"Diffuse R",max:5}),this._diffuse_g=new Q({label:"Diffuse G",max:5}),this._diffuse_b=new Q({label:"Diffuse B",max:5}),this._ambient_r=new Q({label:"Ambient R",max:5}),this._ambient_g=new Q({label:"Ambient G",max:5}),this._ambient_b=new Q({label:"Ambient B",max:5}),this._specular_r=new Q({label:"Specular R",max:.2}),this._specular_g=new Q({label:"Specular G",max:.2}),this._specular_b=new Q({label:"Specular B",max:.2}),this._shininess=new Q({label:"Shininess",max:100})}bindLayer(a){this._selectedLayer=a,this._opacity.value=a.opacity,this._update()}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._dialog.appendTo(this.renderer.div),this._panel.appendTo(this._dialog.container),this._panel.el&&(this.$atmosphereOpacity=this._panel.el.querySelector(".og-atmosphere-opacity"),this.$simpleSkyBackground=this._panel.el.querySelector(".og-simpleskybackground"),this.$gamma=this._panel.el.querySelector(".og-option.og-gamma"),this.$exposure=this._panel.el.querySelector(".og-option.og-exposure"),this.$opacity=this._panel.el.querySelector(".og-option.og-opacity"),this.$diffuse=this._panel.el.querySelector(".og-option.og-diffuse"),this.$ambient=this._panel.el.querySelector(".og-option.og-ambient"),this.$specular=this._panel.el.querySelector(".og-option.og-specular"),this.$night=this._panel.el.querySelector(".og-option.og-night")),this._toggleBtn.events.on("change",n=>{this._dialog.setVisibility(n)});let a=this._dialog.select(".og-suncontrol"),e=new _e({classList:["og-suncontrol-button"],isActive:!0,icon:'<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 70.41" style="enable-background:new 0 0 122.88 70.41" xml:space="preserve"><g><path d="M60.91,19.12c6.95,0,13.24,2.95,17.8,7.72c4.55,4.77,7.37,11.37,7.37,18.64c0,1.94-0.2,3.83-0.58,5.65h31.61 c2.1,0,2.62,1.16,2.62,2.59c0,1.43-0.52,2.59-2.62,2.59H7.09c-2.1,0-2.62-1.16-2.62-2.59c0-1.43,0.52-2.59,2.62-2.59h29.23 c-0.38-1.82-0.58-3.71-0.58-5.65c0-7.28,2.82-13.87,7.37-18.64C47.67,22.08,53.96,19.12,60.91,19.12L60.91,19.12L60.91,19.12z M63.4,70.41c-2.1,0-2.62-1.16-2.62-2.59s0.52-2.59,2.62-2.59h56.86c2.1,0,2.62,1.16,2.62,2.59s-0.52,2.59-2.62,2.59H63.4 L63.4,70.41z M2.62,70.41c-2.1,0-2.62-1.16-2.62-2.59s0.52-2.59,2.62-2.59h29.51c2.1,0,2.62,1.16,2.62,2.59s-0.52,2.59-2.62,2.59 H2.62L2.62,70.41z M38.39,9.46c-0.78-1.35-0.32-3.07,1.03-3.85c1.35-0.78,3.07-0.32,3.85,1.03l3.62,6.27 c0.78,1.35,0.32,3.07-1.03,3.85c-1.35,0.78-3.07,0.32-3.85-1.03L38.39,9.46L38.39,9.46L38.39,9.46z M58.67,2.83 c0-1.56,1.27-2.83,2.83-2.83c1.56,0,2.83,1.27,2.83,2.83v7.24c0,1.56-1.27,2.83-2.83,2.83c-1.56,0-2.83-1.26-2.83-2.83V2.83 L58.67,2.83L58.67,2.83z M79.56,7.23c0.77-1.35,2.49-1.81,3.84-1.04c1.35,0.77,1.81,2.49,1.04,3.84l-3.62,6.27 c-0.77,1.35-2.49,1.81-3.84,1.04c-1.35-0.77-1.81-2.49-1.04-3.84L79.56,7.23L79.56,7.23L79.56,7.23z M95.45,21.48 c1.35-0.78,3.07-0.32,3.85,1.03c0.78,1.35,0.32,3.07-1.03,3.85L92,29.98c-1.35,0.78-3.07,0.32-3.85-1.03 c-0.78-1.35-0.32-3.07,1.03-3.85L95.45,21.48L95.45,21.48L95.45,21.48z M102.08,41.76c1.56,0,2.83,1.27,2.83,2.83 c0,1.56-1.27,2.83-2.83,2.83h-7.24c-1.56,0-2.83-1.26-2.83-2.83s1.26-2.83,2.83-2.83H102.08L102.08,41.76L102.08,41.76z M19.74,46.25c-1.56,0-2.83-1.27-2.83-2.83c0-1.56,1.27-2.83,2.83-2.83h7.24c1.56,0,2.83,1.26,2.83,2.83s-1.27,2.83-2.83,2.83 H19.74L19.74,46.25L19.74,46.25z M24.14,25.35c-1.35-0.77-1.81-2.49-1.04-3.84c0.77-1.35,2.49-1.81,3.84-1.04l6.27,3.62 c1.35,0.77,1.81,2.49,1.04,3.84c-0.77,1.35-2.49,1.81-3.84,1.04L24.14,25.35L24.14,25.35L24.14,25.35z"/></g></svg>',title:"Star/stop the Sun from following the camera"});e.appendTo(a);let t=new _e({classList:["og-suncontrol-button"],isActive:!0,icon:`<?xml version="1.0"?>
611
611
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
612
612
  <path style="text-indent:0;text-align:start;line-height:normal;text-transform:none;block-progression:tb;-inkscape-font-specification:Sans" d="M 16 4 C 9.3844277 4 4 9.3844277 4 16 C 4 22.615572 9.3844277 28 16 28 C 22.615572 28 28 22.615572 28 16 C 28 9.3844277 22.615572 4 16 4 z M 16 6 C 16.389823 6 16.778223 6.0506339 17.15625 6.09375 C 18.631659 7.6568432 21 10.9245 21 16 C 21 21.0755 18.631659 24.343157 17.15625 25.90625 C 16.778223 25.949366 16.389823 26 16 26 C 10.465308 26 6 21.534692 6 16 C 6 10.465308 10.465308 6 16 6 z" overflow="visible" font-family="Sans"/>
613
613
  </svg>
614
- `,title:"Activate/deactivate the Sun current time positioning"});t.appendTo(a),e.events.on("change",n=>{const o=this.planet.renderer.controls.sun;n?o.start():o.stop()}),t.events.on("change",n=>{const o=this.planet.renderer.controls.sun;n?o.activate():o.deactivate()});let i=new fe({classList:["og-suncontrol-button"],isActive:this.planet.lightEnabled,icon:`<?xml version="1.0" encoding="utf-8"?>
614
+ `,title:"Activate/deactivate the Sun current time positioning"});t.appendTo(a),e.events.on("change",n=>{const o=this.planet.renderer.controls.sun;n?o.start():o.stop()}),t.events.on("change",n=>{const o=this.planet.renderer.controls.sun;n?o.activate():o.deactivate()});let i=new _e({classList:["og-suncontrol-button"],isActive:this.planet.lightEnabled,icon:`<?xml version="1.0" encoding="utf-8"?>
615
615
  <!-- Generated by IcoMoon.io -->
616
616
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
617
617
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="512" height="512" viewBox="0 0 512 512">
@@ -626,8 +626,8 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
626
626
  <path d="M96.266 396.073l22.722 22.938 55.778-56.289-22.692-22.928z" fill="#000000" />
627
627
  <path d="M43.633 240.537h78.879v32.43h-78.879v-32.43z" fill="#000000" />
628
628
  <path d="M115.394 93.051l-22.681 22.907 55.757 56.258 22.702-22.917z" fill="#000000" />
629
- </svg>`,title:"Enable/disable planet lighting"});i.appendTo(a),i.events.on("change",n=>{this.planet.lightEnabled=n});let s=new fe({classList:["og-suncontrol-button"],isActive:this.planet.atmosphereEnabled,icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
630
- <svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M135.688 18.5c-6.798 74.842-23.842 85.39-107.907 59.656 84.85 52.022 73.57 64.954-6.843 96.938 87.743-10.27 103.29 4.89 70.75 87.594 17.805-27.56 32.5-44.498 46.282-54.47-11.813 28.26-18.345 59.274-18.345 91.813 0 84.184 43.71 157.96 109.656 200.376-41.624-43.834-67.686-102.7-67.686-167.875 0-134.923 109.45-244.405 244.375-244.405 30.92 0 60.76 5.762 88 16.25-38.584-26.87-85.517-42.625-136.064-42.625-55.257 0-106.14 18.802-146.562 50.375 4.627-18.783 17.39-38.073 41.03-60.906C190.18 90.942 153.53 95.634 135.69 18.5zm10.03 77.188c5.67.002 11.428 1.247 16.876 3.874 14.506 6.998 22.72 21.81 22 36.938-10.26 10.87-19.507 22.696-27.594 35.344-9.035 2.753-19.075 2.27-28.25-2.156-19.37-9.343-27.5-32.6-18.156-51.97 6.715-13.92 20.638-22.036 35.125-22.03z"/></svg>`,title:"Enable/disable atmosphere scattering"});s.appendTo(a),this.planet.atmosphereEnabled?(this.$atmosphereOpacity.style.display="block",this.$simpleSkyBackground.style.display="none"):(this.$atmosphereOpacity.style.display="none",this.$simpleSkyBackground.style.display="flex"),s.events.on("change",n=>{this.planet.atmosphereEnabled=n,this.planet.atmosphereEnabled?(this.$atmosphereOpacity.style.display="block",this.$simpleSkyBackground.style.display="none"):(this.$atmosphereOpacity.style.display="none",this.$simpleSkyBackground.style.display="flex")}),this._atmosphereMaxOpacity.appendTo(this.$atmosphereOpacity),this._atmosphereMinOpacity.appendTo(this.$atmosphereOpacity),this._simpleSkyBackgroundColorOne.appendTo(this.$simpleSkyBackground),this._simpleSkyBackgroundColorTwo.appendTo(this.$simpleSkyBackground),this._gamma.appendTo(this.$gamma),this._exposure.appendTo(this.$exposure),this._night.appendTo(this.$night),this._opacity.appendTo(this.$opacity),this._diffuse_r.appendTo(this.$diffuse),this._diffuse_g.appendTo(this.$diffuse),this._diffuse_b.appendTo(this.$diffuse),this._ambient_r.appendTo(this.$ambient),this._ambient_g.appendTo(this.$ambient),this._ambient_b.appendTo(this.$ambient),this._specular_r.appendTo(this.$specular),this._specular_g.appendTo(this.$specular),this._specular_b.appendTo(this.$specular),this._shininess.appendTo(this.$specular),this._gamma.value=this.planet.renderer.gamma,this._gamma.events.on("change",n=>{this.planet.renderer.gamma=n}),this._exposure.value=this.planet.renderer.exposure,this._exposure.events.on("change",n=>{this.planet.renderer.exposure=n}),this._atmosphereMinOpacity.value=this.planet.atmosphereMinOpacity,this._atmosphereMinOpacity.events.on("change",n=>{this.planet.atmosphereMinOpacity=n}),this._atmosphereMaxOpacity.value=this.planet.atmosphereMaxOpacity,this._atmosphereMaxOpacity.events.on("change",n=>{this.planet.atmosphereMaxOpacity=n,this.planet.renderer.controls.Atmosphere.opacity=n});let r=this.planet.renderer.controls.SimpleSkyBackground;r&&(this._simpleSkyBackgroundColorOne.value=r.colorOne,this._simpleSkyBackgroundColorTwo.value=r.colorTwo),this._simpleSkyBackgroundColorOne.events.on("input",n=>{let o=this.planet.renderer.controls.SimpleSkyBackground;o&&(o.colorOne=n)}),this._simpleSkyBackgroundColorTwo.events.on("input",n=>{let o=this.planet.renderer.controls.SimpleSkyBackground;o&&(o.colorTwo=n)}),this._panel.el.querySelector("#layers").addEventListener("change",n=>{const o=this.planet.getLayerByName(n.target.value);o&&this.bindLayer(o)}),this._night.events.on("change",n=>{this._selectedLayer&&(this._selectedLayer.nightTextureCoefficient=n)}),this._opacity.events.on("change",n=>{this._selectedLayer&&(this._selectedLayer.opacity=n)}),this._ambient_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[0]=n)}),this._ambient_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[1]=n)}),this._ambient_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[2]=n)}),this._diffuse_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[0]=n)}),this._diffuse_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[1]=n)}),this._diffuse_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[2]=n)}),this._specular_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[0]=n)}),this._specular_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[1]=n)}),this._specular_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[2]=n)}),this._shininess.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[3]=n)}),this.planet&&(this.planet.events.on("layeradd",this._onLayerAdd,this),this.planet.events.on("layerremove",this._onLayerRemove,this)),this._fetchLayers()}_update(){let a=this._selectedLayer;this._opacity.value=a&&a.opacity?a.opacity:0,this._night.value=a&&a.nightTextureCoefficient?a.nightTextureCoefficient:this.planet.nightTextureCoefficient;let e=a&&a._ambient?a._ambient:this.planet._ambient;this._ambient_r.value=e[0],this._ambient_g.value=e[1],this._ambient_b.value=e[2];let t=a&&a._diffuse?a._diffuse:this.planet._diffuse;this._diffuse_r.value=t[0],this._diffuse_g.value=t[1],this._diffuse_b.value=t[2];let i=a&&a._specular?a._specular:this.planet._specular;this._specular_r.value=i[0],this._specular_g.value=i[1],this._specular_b.value=i[2],this._shininess.value=i[3]}_fetchLayers(){if(this.planet)for(let a=0;a<this.planet.layers.length;a++)this._onLayerAdd(this.planet.layers[a])}_onLayerAdd(a){this.bindLayer(a);let e=document.createElement("option");e.value=a.name,e.innerText=a.name,this._panel.el.querySelector("#layers").appendChild(e),this._panel.el.querySelector("#layers").value=a.name}_onLayerRemove(a){}},MouseNavigation:uo,Object3dManager:class extends te{constructor(a={}){super(a),this._onSelect=e=>{this._currentItem=e},this._onClick=e=>{if(!this.planet||!this._layer||!this._currentItem)return;let t=this.planet.getLonLatFromPixelTerrain(e.pos);if(t&&(this.renderer.setRelativeCenter(this.planet.camera.eye),this.renderer.events.isKeyPressed(W.KEY_CTRL))){let i=this._createEntity(this._currentItem,t);this._layer.add(i)}},this._layer=a.layer||null,this._currentItem=null,this._collection=new Qs({collection:a.collection}),this._dialog=new sc({model:this._collection})}oninit(){this.renderer&&(this._dialog.appendTo(this.renderer.div||document.body),this._dialog.events.on("select",this._onSelect),this.activate())}onactivate(){this._dialog.show(),this._initEvents()}ondeactivate(){this._dialog.hide(),this._clearEvents()}bindLayer(a){this._layer=a}_initEvents(){this.planet&&this.planet.renderer&&this.planet.renderer.events.on("lclick",this._onClick)}_clearEvents(){this.planet&&this.planet.renderer&&this.planet.renderer.events.off("lclick",this._onClick)}_createEntity(a,e){let t=a.name,i=a.scale,s=new V({lonlat:e,pitch:0,yaw:0,roll:0,scale:i});for(let r=0;r<a.objects.length;r++){let n=a.objects[r],o=new V({forceGlobalPosition:!0,forceGlobalRotation:!0,forceGlobalScale:!0,geoObject:{tag:`${t}:${r.toString()}`,object3d:n}});s.appendChild(o)}return s}},OldMouseNavigation:Ns,Ruler:po,RulerSwitcher:class extends te{constructor(a={}){super({name:"RulerSwitcher",...a}),this.ruler=new yo({ignoreTerrain:a.ignoreTerrain})}oninit(){this.planet.addControl(this.ruler),this._createMenuBtn()}onactivate(){this.ruler.activate()}ondeactivate(){this.ruler.deactivate()}_createMenuBtn(){let a=new fe({classList:["og-map-button","og-ruler_button"],icon:`<?xml version="1.0" encoding="iso-8859-1"?>
629
+ </svg>`,title:"Enable/disable planet lighting"});i.appendTo(a),i.events.on("change",n=>{this.planet.lightEnabled=n});let r=new _e({classList:["og-suncontrol-button"],isActive:this.planet.atmosphereEnabled,icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
630
+ <svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M135.688 18.5c-6.798 74.842-23.842 85.39-107.907 59.656 84.85 52.022 73.57 64.954-6.843 96.938 87.743-10.27 103.29 4.89 70.75 87.594 17.805-27.56 32.5-44.498 46.282-54.47-11.813 28.26-18.345 59.274-18.345 91.813 0 84.184 43.71 157.96 109.656 200.376-41.624-43.834-67.686-102.7-67.686-167.875 0-134.923 109.45-244.405 244.375-244.405 30.92 0 60.76 5.762 88 16.25-38.584-26.87-85.517-42.625-136.064-42.625-55.257 0-106.14 18.802-146.562 50.375 4.627-18.783 17.39-38.073 41.03-60.906C190.18 90.942 153.53 95.634 135.69 18.5zm10.03 77.188c5.67.002 11.428 1.247 16.876 3.874 14.506 6.998 22.72 21.81 22 36.938-10.26 10.87-19.507 22.696-27.594 35.344-9.035 2.753-19.075 2.27-28.25-2.156-19.37-9.343-27.5-32.6-18.156-51.97 6.715-13.92 20.638-22.036 35.125-22.03z"/></svg>`,title:"Enable/disable atmosphere scattering"});r.appendTo(a),this.planet.atmosphereEnabled?(this.$atmosphereOpacity.style.display="block",this.$simpleSkyBackground.style.display="none"):(this.$atmosphereOpacity.style.display="none",this.$simpleSkyBackground.style.display="flex"),r.events.on("change",n=>{this.planet.atmosphereEnabled=n,this.planet.atmosphereEnabled?(this.$atmosphereOpacity.style.display="block",this.$simpleSkyBackground.style.display="none"):(this.$atmosphereOpacity.style.display="none",this.$simpleSkyBackground.style.display="flex")}),this._atmosphereMaxOpacity.appendTo(this.$atmosphereOpacity),this._atmosphereMinOpacity.appendTo(this.$atmosphereOpacity),this._simpleSkyBackgroundColorOne.appendTo(this.$simpleSkyBackground),this._simpleSkyBackgroundColorTwo.appendTo(this.$simpleSkyBackground),this._gamma.appendTo(this.$gamma),this._exposure.appendTo(this.$exposure),this._night.appendTo(this.$night),this._opacity.appendTo(this.$opacity),this._diffuse_r.appendTo(this.$diffuse),this._diffuse_g.appendTo(this.$diffuse),this._diffuse_b.appendTo(this.$diffuse),this._ambient_r.appendTo(this.$ambient),this._ambient_g.appendTo(this.$ambient),this._ambient_b.appendTo(this.$ambient),this._specular_r.appendTo(this.$specular),this._specular_g.appendTo(this.$specular),this._specular_b.appendTo(this.$specular),this._shininess.appendTo(this.$specular),this._gamma.value=this.planet.renderer.gamma,this._gamma.events.on("change",n=>{this.planet.renderer.gamma=n}),this._exposure.value=this.planet.renderer.exposure,this._exposure.events.on("change",n=>{this.planet.renderer.exposure=n}),this._atmosphereMinOpacity.value=this.planet.atmosphereMinOpacity,this._atmosphereMinOpacity.events.on("change",n=>{this.planet.atmosphereMinOpacity=n}),this._atmosphereMaxOpacity.value=this.planet.atmosphereMaxOpacity,this._atmosphereMaxOpacity.events.on("change",n=>{this.planet.atmosphereMaxOpacity=n,this.planet.renderer.controls.Atmosphere.opacity=n});let s=this.planet.renderer.controls.SimpleSkyBackground;s&&(this._simpleSkyBackgroundColorOne.value=s.colorOne,this._simpleSkyBackgroundColorTwo.value=s.colorTwo),this._simpleSkyBackgroundColorOne.events.on("input",n=>{let o=this.planet.renderer.controls.SimpleSkyBackground;o&&(o.colorOne=n)}),this._simpleSkyBackgroundColorTwo.events.on("input",n=>{let o=this.planet.renderer.controls.SimpleSkyBackground;o&&(o.colorTwo=n)}),this._panel.el.querySelector("#layers").addEventListener("change",n=>{const o=this.planet.getLayerByName(n.target.value);o&&this.bindLayer(o)}),this._night.events.on("change",n=>{this._selectedLayer&&(this._selectedLayer.nightTextureCoefficient=n)}),this._opacity.events.on("change",n=>{this._selectedLayer&&(this._selectedLayer.opacity=n)}),this._ambient_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[0]=n)}),this._ambient_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[1]=n)}),this._ambient_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._ambient&&(this._selectedLayer._ambient[2]=n)}),this._diffuse_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[0]=n)}),this._diffuse_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[1]=n)}),this._diffuse_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._diffuse&&(this._selectedLayer._diffuse[2]=n)}),this._specular_r.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[0]=n)}),this._specular_g.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[1]=n)}),this._specular_b.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[2]=n)}),this._shininess.events.on("change",n=>{this._selectedLayer&&this._selectedLayer._specular&&(this._selectedLayer._specular[3]=n)}),this.planet&&(this.planet.events.on("layeradd",this._onLayerAdd,this),this.planet.events.on("layerremove",this._onLayerRemove,this)),this._fetchLayers()}_update(){let a=this._selectedLayer;this._opacity.value=a&&a.opacity?a.opacity:0,this._night.value=a&&a.nightTextureCoefficient?a.nightTextureCoefficient:this.planet.nightTextureCoefficient;let e=a&&a._ambient?a._ambient:this.planet._ambient;this._ambient_r.value=e[0],this._ambient_g.value=e[1],this._ambient_b.value=e[2];let t=a&&a._diffuse?a._diffuse:this.planet._diffuse;this._diffuse_r.value=t[0],this._diffuse_g.value=t[1],this._diffuse_b.value=t[2];let i=a&&a._specular?a._specular:this.planet._specular;this._specular_r.value=i[0],this._specular_g.value=i[1],this._specular_b.value=i[2],this._shininess.value=i[3]}_fetchLayers(){if(this.planet)for(let a=0;a<this.planet.layers.length;a++)this._onLayerAdd(this.planet.layers[a])}_onLayerAdd(a){this.bindLayer(a);let e=document.createElement("option");e.value=a.name,e.innerText=a.name,this._panel.el.querySelector("#layers").appendChild(e),this._panel.el.querySelector("#layers").value=a.name}_onLayerRemove(a){}},MouseNavigation:ua,Object3dManager:class extends ee{constructor(a={}){super(a),this._onSelect=e=>{this._currentItem=e},this._onClick=e=>{if(!this.planet||!this._layer||!this._currentItem)return;let t=this.planet.getLonLatFromPixelTerrain(e.pos);if(t&&(this.renderer.setRelativeCenter(this.planet.camera.eye),this.renderer.events.isKeyPressed(W.KEY_CTRL))){let i=this._createEntity(this._currentItem,t);this._layer.add(i)}},this._layer=a.layer||null,this._currentItem=null,this._collection=new Kr({collection:a.collection}),this._dialog=new rc({model:this._collection})}oninit(){this.renderer&&(this._dialog.appendTo(this.renderer.div||document.body),this._dialog.events.on("select",this._onSelect),this.activate())}onactivate(){this._dialog.show(),this._initEvents()}ondeactivate(){this._dialog.hide(),this._clearEvents()}bindLayer(a){this._layer=a}_initEvents(){this.planet&&this.planet.renderer&&this.planet.renderer.events.on("lclick",this._onClick)}_clearEvents(){this.planet&&this.planet.renderer&&this.planet.renderer.events.off("lclick",this._onClick)}_createEntity(a,e){let t=a.name,i=a.scale,r=new V({lonlat:e,pitch:0,yaw:0,roll:0,scale:i});for(let s=0;s<a.objects.length;s++){let n=a.objects[s],o=new V({forceGlobalPosition:!0,forceGlobalRotation:!0,forceGlobalScale:!0,geoObject:{tag:`${t}:${s.toString()}`,object3d:n}});r.appendChild(o)}return r}},OldMouseNavigation:Hr,Ruler:pa,RulerSwitcher:class extends ee{constructor(a={}){super({name:"RulerSwitcher",...a}),this.ruler=new ya({ignoreTerrain:a.ignoreTerrain})}oninit(){this.planet.addControl(this.ruler),this._createMenuBtn()}onactivate(){this.ruler.activate()}ondeactivate(){this.ruler.deactivate()}_createMenuBtn(){let a=new _e({classList:["og-map-button","og-ruler_button"],icon:`<?xml version="1.0" encoding="iso-8859-1"?>
631
631
  <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
632
632
  <svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
633
633
  viewBox="0 0 512 512" xml:space="preserve">
@@ -641,14 +641,14 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
641
641
  l95.564,95.564L142.85,464.714L47.286,369.15z"/>
642
642
  </g>
643
643
  </g>
644
- </svg>`});a.appendTo(this.renderer.div),a.events.on("change",e=>{e?this.onactivate():this.ondeactivate()})}},ScaleControl:xo,Selection:class extends te{constructor(a={}){super(a),this._selectorScene=new uh({name:`selectionScene:${this.__id}`,ignoreTerrain:a.ignoreTerrain,onSelect:a.onSelect,autoSelectionHide:a.autoSelectionHide}),this._toggleBtn=new fe({classList:["og-map-button","og-selection_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
645
- <svg width="800px" height="800px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M2.1 0v1.914H0v6h3V3h5.1V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h1.8v1.2h3V0h-4.8zm1.8 7.2v6h3v-6h-3zM0 10.913v6h3v-6H0zM66.9 16.2v6h3v-6h-3zM0 19.914v6h3v-6H0zM66.9 25.2v6h3v-6h-3zM0 28.914v6h3v-6H0zM66.9 34.2v6h3v-6h-3zM0 37.914v6h3v-6H0zM66.9 43.2v6h3v-6h-3zM0 46.914v6h3v-6H0zM66.9 52.2v6h3v-6h-3zM0 55.914v5.191h3.809v-3H3v-2.19H0zm6.809 2.191v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9.648 1.899a2.076 2.076 0 0 0-2.19 2.324l3.137 33.676c.2 1.635 2.135 2.399 3.397 1.34l6.623-5.371l2.969 5.142c1.707 2.958 4.417 3.684 7.375 1.977c2.957-1.708 3.684-4.417 1.976-7.375l-2.959-5.125l7.848-3.008c1.548-.564 1.855-2.62.539-3.611L71.576 60.416a2.073 2.073 0 0 0-1.119-.412z" fill="#000000"></path></svg>`})}set ignoreTerrain(a){this._selectorScene.ignoreTerrain=a}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._toggleBtn.events.on("change",a=>{a?this.activate():this.deactivate()}),this._selectorScene.bindPlanet(this.planet)}onactivate(){this.renderer.addNode(this._selectorScene)}ondeactivate(){this.renderer.removeNode(this._selectorScene)}},ShowFps:class extends te{constructor(a){super(a)}oninit(){let a=document.createElement("div");a.className="defaultText ",a.id="ogShowFpsControl",document.body.appendChild(a),this.renderer.events.on("draw",this._draw,this)}_draw(){Ir("ogShowFpsControl",(1e3/this.renderer.handler.deltaTime).toFixed(1),this.renderer.handler.canvas.clientWidth-60,0)}},SimpleNavigation:class extends te{constructor(a={}){super({name:"SimpleNavigation",autoActivate:!0,...a}),this._onMouseLeftButtonClick=e=>{this._active&&this.renderer&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this._grabbedPoint=this.renderer.getCartesianFromPixel(e),this._grabbedPoint&&this._eye0.copy(this.renderer.activeCamera.eye))},this._onMouseLeftButtonUp=e=>{this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.x===e.prev_x&&(e.y,e.prev_y)},this._onMouseLeftButtonDown=e=>{if(this._active&&this.renderer){if(!this._grabbedPoint)return;if(e.moving){let t,i,s=this.renderer.activeCamera,r=Math.abs(s.getForward().dot(v.UP)),n=this._grabbedPoint;r>.7?(t=v.add(n,v.LEFT),i=v.add(n,s.getRight())):(t=v.add(n,s.getRight()),i=v.add(n,v.UP));let o=new v;new U(s.eye,e.direction).hitPlaneRes(Pe.fromPoints(n,t,i),o)===U.INSIDE&&(s.eye=this._eye0.addA(o.subA(n).negate()))}}},this._onRHold=e=>{if(this._lookPos&&e.moving&&this.renderer){const t=this.renderer.activeCamera;this.renderer.controlsBag.scaleRot=1;let i=.5/t.eye.distance(this._lookPos)*j;i>.007?i=.007:i<.003&&(i=.003),t.rotateHorizontal(i*(e.x-e.prev_x),!1,this._lookPos,this._up),t.rotateVertical(i*(e.y-e.prev_y),this._lookPos)}},this._onRDown=e=>{this.renderer&&(this._lookPos=this.renderer.getCartesianFromPixel(e.pos),this._lookPos&&(this._up=v.UP))},this._onMouseWheel=e=>{if(this.renderer){let t=this.renderer.getCartesianFromPixel(e),i=10;t&&(i=this.renderer.activeCamera.eye.distance(t)),this.force.addA(e.direction.scale(e.wheelDelta)).normalize().scale(i)}},this.onCameraMoveForward=()=>{this.force.addA(this.renderer.activeCamera.getForward()).normalize()},this.onCameraMoveBackward=()=>{this.force.addA(this.renderer.activeCamera.getBackward()).normalize()},this.onCameraStrifeLeft=()=>{this.force.addA(this.renderer.activeCamera.getLeft()).normalize()},this.onCameraStrifeRight=()=>{this.force.addA(this.renderer.activeCamera.getRight()).normalize()},this.onCameraLookUp=()=>{let e=this.renderer.activeCamera;e.setPitch(.5),e.update()},this.onCameraLookDown=()=>{let e=this.renderer.activeCamera;e.setPitch(-.5),e.update()},this.onCameraTurnLeft=()=>{let e=this.renderer.activeCamera;e.setYaw(.5),e.update()},this.onCameraTurnRight=()=>{let e=this.renderer.activeCamera;e.setYaw(-.5),e.update()},this.onCameraRollLeft=()=>{let e=this.renderer.activeCamera;e.setRoll(-.5),e.update()},this.onCameraRollRight=()=>{let e=this.renderer.activeCamera;e.setRoll(.5),e.update()},this.speed=a.speed||1,this.force=new v,this.vel=new v,this.mass=1,this._lookPos=void 0,this._grabbedPoint=void 0,this._up=null,this._eye0=new v}oninit(){}onactivate(){super.onactivate();let a=this.renderer;a.events.on("mousewheel",this._onMouseWheel),a.events.on("keypress",W.KEY_W,this.onCameraMoveForward,this),a.events.on("keypress",W.KEY_S,this.onCameraMoveBackward,this),a.events.on("keypress",W.KEY_A,this.onCameraStrifeLeft,this),a.events.on("keypress",W.KEY_D,this.onCameraStrifeRight,this),a.events.on("keypress",W.KEY_UP,this.onCameraLookUp,this),a.events.on("keypress",W.KEY_DOWN,this.onCameraLookDown,this),a.events.on("keypress",W.KEY_LEFT,this.onCameraTurnLeft,this),a.events.on("keypress",W.KEY_RIGHT,this.onCameraTurnRight,this),a.events.on("keypress",W.KEY_Q,this.onCameraRollLeft,this),a.events.on("keypress",W.KEY_E,this.onCameraRollRight,this),a.events.on("rhold",this._onRHold,this),a.events.on("rdown",this._onRDown,this),a.events.on("lhold",this._onMouseLeftButtonDown),a.events.on("ldown",this._onMouseLeftButtonClick),a.events.on("lup",this._onMouseLeftButtonUp),a.events.on("draw",this.onDraw,this,-1e3)}ondeactivate(){super.ondeactivate();let a=this.renderer;a.events.off("mousewheel",this._onMouseWheel),a.events.off("keypress",W.KEY_W,this.onCameraMoveForward),a.events.off("keypress",W.KEY_S,this.onCameraMoveBackward),a.events.off("keypress",W.KEY_A,this.onCameraStrifeLeft),a.events.off("keypress",W.KEY_D,this.onCameraStrifeRight),a.events.off("keypress",W.KEY_UP,this.onCameraLookUp),a.events.off("keypress",W.KEY_DOWN,this.onCameraLookDown),a.events.off("keypress",W.KEY_LEFT,this.onCameraTurnLeft),a.events.off("keypress",W.KEY_RIGHT,this.onCameraTurnRight),a.events.off("keypress",W.KEY_Q,this.onCameraRollLeft),a.events.off("keypress",W.KEY_E,this.onCameraRollRight),a.events.off("rhold",this._onRHold),a.events.off("rdown",this._onRDown),a.events.off("lhold",this._onMouseLeftButtonDown),a.events.off("ldown",this._onMouseLeftButtonClick),a.events.off("lup",this._onMouseLeftButtonUp),a.events.off("draw",this.onDraw)}get dt(){return .001*this.renderer.handler.deltaTime}onDraw(){if(this.renderer){let a=this.force.scale(1/this.mass);this.vel.addA(a),this.vel.scale(.96),this.force.set(0,0,0);let e=this.renderer.activeCamera;e.eye=e.eye.add(this.vel.scaleTo(this.dt)),e.update()}}},SimpleSkyBackground:bo,Sun:js,TimelineControl:class extends te{constructor(a={}){super({name:"timeline",...a});let e=a.current||new Date,t=a.rangeStart||Lo(e,-12),i=a.rangeEnd||Lo(e,12);this._timelineView=new xh({rangeStart:t,rangeEnd:i,currentDate:e}),this._toggleBtn=new fe({classList:["og-map-button","og-timeline_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
644
+ </svg>`});a.appendTo(this.renderer.div),a.events.on("change",e=>{e?this.onactivate():this.ondeactivate()})}},ScaleControl:xa,Selection:class extends ee{constructor(a={}){super(a),this._selectorScene=new uh({name:`selectionScene:${this.__id}`,ignoreTerrain:a.ignoreTerrain,onSelect:a.onSelect,autoSelectionHide:a.autoSelectionHide}),this._toggleBtn=new _e({classList:["og-map-button","og-selection_button"],icon:`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
645
+ <svg width="800px" height="800px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M2.1 0v1.914H0v6h3V3h5.1V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h1.8v1.2h3V0h-4.8zm1.8 7.2v6h3v-6h-3zM0 10.913v6h3v-6H0zM66.9 16.2v6h3v-6h-3zM0 19.914v6h3v-6H0zM66.9 25.2v6h3v-6h-3zM0 28.914v6h3v-6H0zM66.9 34.2v6h3v-6h-3zM0 37.914v6h3v-6H0zM66.9 43.2v6h3v-6h-3zM0 46.914v6h3v-6H0zM66.9 52.2v6h3v-6h-3zM0 55.914v5.191h3.809v-3H3v-2.19H0zm6.809 2.191v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9.648 1.899a2.076 2.076 0 0 0-2.19 2.324l3.137 33.676c.2 1.635 2.135 2.399 3.397 1.34l6.623-5.371l2.969 5.142c1.707 2.958 4.417 3.684 7.375 1.977c2.957-1.708 3.684-4.417 1.976-7.375l-2.959-5.125l7.848-3.008c1.548-.564 1.855-2.62.539-3.611L71.576 60.416a2.073 2.073 0 0 0-1.119-.412z" fill="#000000"></path></svg>`})}set ignoreTerrain(a){this._selectorScene.ignoreTerrain=a}oninit(){this._toggleBtn.appendTo(this.renderer.div),this._toggleBtn.events.on("change",a=>{a?this.activate():this.deactivate()}),this._selectorScene.bindPlanet(this.planet)}onactivate(){this.renderer.addNode(this._selectorScene)}ondeactivate(){this.renderer.removeNode(this._selectorScene)}},ShowFps:class extends ee{constructor(a){super(a)}oninit(){let a=document.createElement("div");a.className="defaultText ",a.id="ogShowFpsControl",document.body.appendChild(a),this.renderer.events.on("draw",this._draw,this)}_draw(){zs("ogShowFpsControl",(1e3/this.renderer.handler.deltaTime).toFixed(1),this.renderer.handler.canvas.clientWidth-60,0)}},SimpleNavigation:class extends ee{constructor(a={}){super({name:"SimpleNavigation",autoActivate:!0,...a}),this._onMouseLeftButtonDown=e=>{this._active&&this.renderer&&(this.renderer.handler.canvas.classList.add("ogGrabbingPoiner"),this._grabbedPoint=this.renderer.getCartesianFromPixel(e),this._grabbedScreenPoint.set(e.nx,e.ny),this._grabbedPoint&&this._eye0.copy(this.renderer.activeCamera.eye))},this._onMouseLeftButtonUp=e=>{this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner"),e.x===e.prev_x&&(e.y,e.prev_y)},this._onMouseLeftButtonHold=e=>{if(this.renderer&&this._grabbedPoint&&e.moving){let t=this.renderer.activeCamera;if(t.isOrthographic){let i=e.nx-this._grabbedScreenPoint.x,r=e.ny-this._grabbedScreenPoint.y,s=t.frustum,n=-(s.right-s.left)*i,o=(s.top-s.bottom)*r,l=t.getUp().scale(o),h=t.getRight().scale(n);t.eye=this._eye0.add(h.add(l))}else{let i,r,s=Math.abs(t.getForward().dot(m.UP)),n=this._grabbedPoint;s>.7?(i=m.add(n,m.LEFT),r=m.add(n,t.getRight())):(i=m.add(n,t.getRight()),r=m.add(n,m.UP));let o=new m;new H(t.eye,e.direction).hitPlaneRes(we.fromPoints(n,i,r),o)===H.INSIDE&&(t.eye=t.eye.add(n.sub(o)))}t.update()}},this._onRHold=e=>{if(this._lookPos&&e.moving&&this.renderer){const t=this.renderer.activeCamera;this.renderer.controlsBag.scaleRot=1;let i=.5/t.eye.distance(this._lookPos)*U;i>.007?i=.007:i<.003&&(i=.003),t.rotateHorizontal(i*(e.x-e.prev_x),!1,this._lookPos,this._up),t.rotateVertical(i*(e.y-e.prev_y),this._lookPos),t.update()}},this._onRDown=e=>{if(this.renderer)if(this._lookPos=this.renderer.getCartesianFromPixel(e.pos),this._lookPos)this._up=m.UP;else{const t=this.renderer.activeCamera;let i=new we(m.ZERO,m.UP),r=new H(t.eye,e.direction);this._lookPos=new m,r.hitPlaneRes(i,this._lookPos),this._up=m.UP}},this._onMouseWheel=e=>{if(this.renderer){let t=this.renderer.activeCamera,i=this.renderer.getCartesianFromPixel(e);if(!i){i=new m;let n=new we(m.ZERO,m.UP);new H(t.eye,e.direction).hitPlaneRes(n,i)}this._wheelPos.copy(i);let r=i.sub(t.eye).normalize(),s=8*t.eye.distance(i);this.force.addA(r.scale(e.wheelDelta)).normalize().scale(s)}},this.onCameraMoveForward=()=>{this.force.addA(this.renderer.activeCamera.getForward()).normalize()},this.onCameraMoveBackward=()=>{this.force.addA(this.renderer.activeCamera.getBackward()).normalize()},this.onCameraStrifeLeft=()=>{this.force.addA(this.renderer.activeCamera.getLeft()).normalize()},this.onCameraStrifeRight=()=>{this.force.addA(this.renderer.activeCamera.getRight()).normalize()},this.onCameraLookUp=()=>{this.renderer.activeCamera.update()},this.onCameraLookDown=()=>{this.renderer.activeCamera.update()},this.onCameraTurnLeft=()=>{this.renderer.activeCamera.update()},this.onCameraTurnRight=()=>{this.renderer.activeCamera.update()},this.onCameraRollLeft=()=>{this.renderer.activeCamera.update()},this.onCameraRollRight=()=>{this.renderer.activeCamera.update()},this.speed=a.speed||1,this.force=new m,this.vel=new m,this.mass=1,this._lookPos=void 0,this._grabbedPoint=void 0,this._grabbedScreenPoint=new N,this._up=null,this._eye0=new m,this._wheelPos=new m}oninit(){}onactivate(){super.onactivate();let a=this.renderer;a.activeCamera.isOrthographic&&a.getDepthMinDistanceAsync().then(e=>{a.activeCamera.focusDistance=e}),a.events.on("mousewheel",this._onMouseWheel),a.events.on("keypress",W.KEY_W,this.onCameraMoveForward,this),a.events.on("keypress",W.KEY_S,this.onCameraMoveBackward,this),a.events.on("keypress",W.KEY_A,this.onCameraStrifeLeft,this),a.events.on("keypress",W.KEY_D,this.onCameraStrifeRight,this),a.events.on("keypress",W.KEY_UP,this.onCameraLookUp,this),a.events.on("keypress",W.KEY_DOWN,this.onCameraLookDown,this),a.events.on("keypress",W.KEY_LEFT,this.onCameraTurnLeft,this),a.events.on("keypress",W.KEY_RIGHT,this.onCameraTurnRight,this),a.events.on("keypress",W.KEY_Q,this.onCameraRollLeft,this),a.events.on("keypress",W.KEY_E,this.onCameraRollRight,this),a.events.on("rhold",this._onRHold,this),a.events.on("rdown",this._onRDown,this),a.events.on("lhold",this._onMouseLeftButtonHold),a.events.on("ldown",this._onMouseLeftButtonDown),a.events.on("lup",this._onMouseLeftButtonUp),a.events.on("draw",this.onDraw,this,-1e3)}ondeactivate(){super.ondeactivate();let a=this.renderer;a.events.off("mousewheel",this._onMouseWheel),a.events.off("keypress",W.KEY_W,this.onCameraMoveForward),a.events.off("keypress",W.KEY_S,this.onCameraMoveBackward),a.events.off("keypress",W.KEY_A,this.onCameraStrifeLeft),a.events.off("keypress",W.KEY_D,this.onCameraStrifeRight),a.events.off("keypress",W.KEY_UP,this.onCameraLookUp),a.events.off("keypress",W.KEY_DOWN,this.onCameraLookDown),a.events.off("keypress",W.KEY_LEFT,this.onCameraTurnLeft),a.events.off("keypress",W.KEY_RIGHT,this.onCameraTurnRight),a.events.off("keypress",W.KEY_Q,this.onCameraRollLeft),a.events.off("keypress",W.KEY_E,this.onCameraRollRight),a.events.off("rhold",this._onRHold),a.events.off("rdown",this._onRDown),a.events.off("lhold",this._onMouseLeftButtonHold),a.events.off("ldown",this._onMouseLeftButtonDown),a.events.off("lup",this._onMouseLeftButtonUp),a.events.off("draw",this.onDraw)}_handleMouseWheel(){let a=this.renderer.activeCamera,e=a.eye.clone();if(a.eye=a.eye.add(this.vel.scaleTo(this.dt)),a.isOrthographic){let t=e.distance(this._wheelPos),i=a.eye.distance(this._wheelPos)/t,r=a.focusDistance;a.focusDistance=a.focusDistance*i;let s=a.focusDistance/i-r;a.eye=a.eye.add(a.getForward().scale(s))}a.update()}onDraw(){this._updateVel(),this.renderer&&this.vel.length()>.01&&this._handleMouseWheel()}get dt(){return .001*this.renderer.handler.deltaTime}_updateVel(){let a=this.force.scale(1/this.mass);this.vel.addA(a),this.vel.scale(.77),this.force.set(0,0,0)}},SimpleSkyBackground:ba,Sun:qr,TimelineControl:class extends ee{constructor(a={}){super({name:"timeline",...a});let e=a.current||new Date,t=a.rangeStart||La(e,-12),i=a.rangeEnd||La(e,12);this._timelineView=new xh({rangeStart:t,rangeEnd:i,currentDate:e}),this._toggleBtn=new _e({classList:["og-map-button","og-timeline_button"],icon:`<?xml version="1.0" encoding="utf-8"?>
646
646
  <!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
647
647
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
648
648
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
649
649
  <metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
650
650
  <g><path d="M500,10C229.4,10,10,229.4,10,500s219.4,490,490,490s490-219.4,490-490S770.6,10,500,10z M800.3,800.3c-39,39-84.5,69.7-135,91C613,913.5,557.4,924.7,500,924.7s-112.9-11.2-165.3-33.3c-50.5-21.3-95.9-52-135-91c-39-39-69.7-84.5-91-135C86.5,612.9,75.3,557.4,75.3,500s11.2-112.9,33.3-165.3c21.3-50.5,52-95.9,91-135c39-39,84.5-69.7,135-91C387.1,86.5,442.6,75.3,500,75.3s112.9,11.2,165.3,33.3c50.5,21.3,95.9,52,135,91c39,39,69.7,84.5,91,135c22.1,52.3,33.3,107.9,33.3,165.3s-11.2,112.9-33.3,165.3C869.9,715.8,839.3,761.2,800.3,800.3z"/><path d="M761.3,532.7H532.7V304c0-18.1-14.6-32.7-32.7-32.7s-32.7,14.6-32.7,32.7v261.3l0,0c0,18.1,14.6,32.7,32.7,32.7h261.3c18.1,0,32.7-14.6,32.7-32.7l0,0C794,547.3,779.4,532.7,761.3,532.7z"/></g>
651
- </svg>`}),this._dialog=new ot({title:"Timeline",visible:!1,resizable:!0,useHide:!0,top:10,left:60,width:600,height:115,minHeight:115,maxHeight:110}),this._dialog.events.on("visibility",s=>{this._toggleBtn.setActive(s)})}oninit(){let a=this.renderer.div;this._toggleBtn.appendTo(a),this._dialog.appendTo(a),this._toggleBtn.events.on("change",e=>{this._dialog.setVisibility(e),e&&this._timelineView.resize()}),this._timelineView.appendTo(this._dialog.container),this._timelineView.events.on("setcurrent",e=>{this.renderer&&this.renderer.handler.defaultClock.setDate(e)}),this._timelineView.events.on("startdrag",()=>{var e;(e=this.planet)==null||e.sun.stop(),this.renderer&&this.renderer.controls.mouseNavigation.deactivate()}),this._timelineView.events.on("stopdrag",()=>{this.renderer&&this.renderer.controls.mouseNavigation.activate()}),this._timelineView.events.on("startdragcurrent",()=>{var e;(e=this.planet)==null||e.sun.stop(),this.renderer&&this.renderer.controls.mouseNavigation.deactivate()}),this._timelineView.events.on("stopdragcurrent",()=>{this.renderer&&this.renderer.controls.mouseNavigation.activate()})}},ToggleWireframe:class extends te{constructor(a={}){super(a),this._isActive=!1,this.toogleWireframe=()=>{this.renderer&&this.renderer.handler.gl&&(this.planet.drawMode===this.renderer.handler.gl.LINE_STRIP?this.planet.setDrawMode(this.renderer.handler.gl.TRIANGLE_STRIP):this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP))},this._isActive=a.isActive||!1}oninit(){this.renderer.events.on("charkeypress",W.KEY_X,this.toogleWireframe,this),this._isActive&&this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP)}},TouchNavigation:Co,ZoomControl:To},Symbol.toStringTag,{value:"Module"}));function Ut(a){return new Uint32Array(a)}function uc(a){let e=[],t=0,i=0,s=0;for(let r=1;r<a-1-1;r++){for(let n=1;n<a-1;n++)t=r*a+n,s=(r+1)*a,i=s+n,e.push(t,i);e.push(i,s+1)}return e.push(e[e.length-1],a*a-a),Ut(e)}function _c(a,e){let t=[];const i=(a-1)/e,s=a*a-a;let r=0;for(let n=0;n<a-2;n++){n%i==0&&(r=n);let o=s-a*n-a+1,l=s-a*r;t.push(l,o)}return e===a-1&&(t.push(a),t.push(0)),Ut(t)}function fc(a,e){let t=[];const i=(a-1)/e;let s=0;for(let r=0;r<a-2;r++){r%i==0&&(s=r);let n=a+r+1,o=s;t.push(o,n)}return e===a-1&&(t.push(a-2),t.push(a-1)),Ut(t)}function gc(a,e){let t=[];const i=(a-1)/e;let s=0;for(let r=0;r<a-2;r++){r%i==0&&(s=r);let n=a*(r+1)+a-2,o=a+a*s-1;t.push(o,n)}return e===a-1&&(t.push(a*(a-1)-1),t.push(a*a-1)),Ut(t)}function pc(a,e){let t=[];const i=(a-1)/e;let s=0;const r=a*(a-1)-2,n=a*a-1;for(let o=0;o<a-2;o++){o%i==0&&(s=o);let l=r-o,h=n-s;t.push(h,l)}return e===a-1&&t.push(a*a-a+1),t.push(a*a-a),Ut(t)}function Qo(a){let e=[[],[],[],[]];for(let t=0;t<=a;t++){let i=Math.pow(2,t)+1;e[0][t]=[],e[3][t]=[],e[2][t]=[],e[1][t]=[];for(let s=0;s<=a;s++){let r=Math.pow(2,s);e[3][t][s]=_c(i,r),e[0][t][s]=fc(i,r),e[1][t][s]=gc(i,r),e[2][t][s]=pc(i,r)}}return e}function Ko(a){let e=[];for(let t=0;t<=a;t++){const i=Math.pow(2,t);e[t]=uc(i+1)}return e}function mc(a){let e=new Uint16Array((a+1)*(a+1)*2),t=0;for(let i=0;i<=a;i++)for(let s=0;s<=a;s++)e[t++]=s/a*65535,e[t++]=i/a*65535;return e}let vc=new class{constructor(a=0){this._maxGridSize=a,this.centerIndexesTable=Ko(this._maxGridSize),this.skirtsIndexesTable=Qo(this._maxGridSize)}get maxGridSize(){return this._maxGridSize}init(){this.centerIndexesTable=Ko(this._maxGridSize),this.skirtsIndexesTable=Qo(this._maxGridSize)}setMaxGridSize(a){this._maxGridSize=a,this.init()}createSegmentIndexes(a,e){if(a){let i=this.centerIndexesTable[a],s=this.skirtsIndexesTable[3][a][e[3]],r=this.skirtsIndexesTable[0][a][e[0]],n=this.skirtsIndexesTable[1][a][e[1]],o=this.skirtsIndexesTable[2][a][e[2]],l=(t=i.length+s.length+r.length+n.length+o.length,new Uint32Array(t));return l.set(i,0),l.set(s,i.length),l.set(r,i.length+s.length),l.set(n,i.length+s.length+r.length),l.set(o,i.length+s.length+r.length+n.length),l}var t;return Ut([0,2,1,3])}initTextureCoordsTable(a){let e=[];for(let t=0;t<=a;t++){const i=Math.pow(2,t);e[t]=mc(i)}return e}};function Zi(){return vc}function Jo(){return new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",camHeight:"float",nightTextureCoefficient:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec4 uGlobalTextureCoord;uniform vec3 uNormalMapBias;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec4 vTextureCoord;varying vec3 v_vertex;varying vec3 cameraPosition;varying vec2 vGlobalTextureCoord;varying float v_height;void main(void){vec3 aVertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 nh=height*normalize(aVertexPosition);vTextureCoord.xy=aTextureCoord;vGlobalTextureCoord=uGlobalTextureCoord.xy+(uGlobalTextureCoord.zw-uGlobalTextureCoord.xy)*aTextureCoord;vTextureCoord.zw=uNormalMapBias.z*(aTextureCoord+uNormalMapBias.xy);cameraPosition=eyePositionHigh+eyePositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);v_height=height;v_vertex=aVertexPosition+nh;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}
651
+ </svg>`}),this._dialog=new at({title:"Timeline",visible:!1,resizable:!0,useHide:!0,top:10,left:60,width:600,height:115,minHeight:115,maxHeight:110}),this._dialog.events.on("visibility",r=>{this._toggleBtn.setActive(r)})}oninit(){let a=this.renderer.div;this._toggleBtn.appendTo(a),this._dialog.appendTo(a),this._toggleBtn.events.on("change",e=>{this._dialog.setVisibility(e),e&&this._timelineView.resize()}),this._timelineView.appendTo(this._dialog.container),this._timelineView.events.on("setcurrent",e=>{this.renderer&&this.renderer.handler.defaultClock.setDate(e)}),this._timelineView.events.on("startdrag",()=>{var e;(e=this.planet)==null||e.sun.stop(),this.renderer&&this.renderer.controls.mouseNavigation.deactivate()}),this._timelineView.events.on("stopdrag",()=>{this.renderer&&this.renderer.controls.mouseNavigation.activate()}),this._timelineView.events.on("startdragcurrent",()=>{var e;(e=this.planet)==null||e.sun.stop(),this.renderer&&this.renderer.controls.mouseNavigation.deactivate()}),this._timelineView.events.on("stopdragcurrent",()=>{this.renderer&&this.renderer.controls.mouseNavigation.activate()})}},ToggleWireframe:class extends ee{constructor(a={}){super(a),this._isActive=!1,this.toogleWireframe=()=>{this.renderer&&this.renderer.handler.gl&&(this.planet.drawMode===this.renderer.handler.gl.LINE_STRIP?this.planet.setDrawMode(this.renderer.handler.gl.TRIANGLE_STRIP):this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP))},this._isActive=a.isActive||!1}oninit(){this.renderer.events.on("charkeypress",W.KEY_X,this.toogleWireframe,this),this._isActive&&this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP)}},TouchNavigation:Ca,ZoomControl:Ta},Symbol.toStringTag,{value:"Module"}));function Vt(a){return new Uint32Array(a)}function dc(a){let e=[],t=0,i=0,r=0;for(let s=1;s<a-1-1;s++){for(let n=1;n<a-1;n++)t=s*a+n,r=(s+1)*a,i=r+n,e.push(t,i);e.push(i,r+1)}return e.push(e[e.length-1],a*a-a),Vt(e)}function uc(a,e){let t=[];const i=(a-1)/e,r=a*a-a;let s=0;for(let n=0;n<a-2;n++){n%i==0&&(s=n);let o=r-a*n-a+1,l=r-a*s;t.push(l,o)}return e===a-1&&(t.push(a),t.push(0)),Vt(t)}function _c(a,e){let t=[];const i=(a-1)/e;let r=0;for(let s=0;s<a-2;s++){s%i==0&&(r=s);let n=a+s+1,o=r;t.push(o,n)}return e===a-1&&(t.push(a-2),t.push(a-1)),Vt(t)}function fc(a,e){let t=[];const i=(a-1)/e;let r=0;for(let s=0;s<a-2;s++){s%i==0&&(r=s);let n=a*(s+1)+a-2,o=a+a*r-1;t.push(o,n)}return e===a-1&&(t.push(a*(a-1)-1),t.push(a*a-1)),Vt(t)}function gc(a,e){let t=[];const i=(a-1)/e;let r=0;const s=a*(a-1)-2,n=a*a-1;for(let o=0;o<a-2;o++){o%i==0&&(r=o);let l=s-o,h=n-r;t.push(h,l)}return e===a-1&&t.push(a*a-a+1),t.push(a*a-a),Vt(t)}function Ka(a){let e=[[],[],[],[]];for(let t=0;t<=a;t++){let i=Math.pow(2,t)+1;e[0][t]=[],e[3][t]=[],e[2][t]=[],e[1][t]=[];for(let r=0;r<=a;r++){let s=Math.pow(2,r);e[3][t][r]=uc(i,s),e[0][t][r]=_c(i,s),e[1][t][r]=fc(i,s),e[2][t][r]=gc(i,s)}}return e}function Ja(a){let e=[];for(let t=0;t<=a;t++){const i=Math.pow(2,t);e[t]=dc(i+1)}return e}function pc(a){let e=new Uint16Array((a+1)*(a+1)*2),t=0;for(let i=0;i<=a;i++)for(let r=0;r<=a;r++)e[t++]=r/a*65535,e[t++]=i/a*65535;return e}let mc=new class{constructor(a=0){this._maxGridSize=a,this.centerIndexesTable=Ja(this._maxGridSize),this.skirtsIndexesTable=Ka(this._maxGridSize)}get maxGridSize(){return this._maxGridSize}init(){this.centerIndexesTable=Ja(this._maxGridSize),this.skirtsIndexesTable=Ka(this._maxGridSize)}setMaxGridSize(a){this._maxGridSize=a,this.init()}createSegmentIndexes(a,e){if(a){let i=this.centerIndexesTable[a],r=this.skirtsIndexesTable[3][a][e[3]],s=this.skirtsIndexesTable[0][a][e[0]],n=this.skirtsIndexesTable[1][a][e[1]],o=this.skirtsIndexesTable[2][a][e[2]],l=(t=i.length+r.length+s.length+n.length+o.length,new Uint32Array(t));return l.set(i,0),l.set(r,i.length),l.set(s,i.length+r.length),l.set(n,i.length+r.length+s.length),l.set(o,i.length+r.length+s.length+n.length),l}var t;return Vt([0,2,1,3])}initTextureCoordsTable(a){let e=[];for(let t=0;t<=a;t++){const i=Math.pow(2,t);e[t]=pc(i)}return e}};function Zi(){return mc}function eo(){return new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",camHeight:"float",nightTextureCoefficient:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec4 uGlobalTextureCoord;uniform vec3 uNormalMapBias;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec4 vTextureCoord;varying vec3 v_vertex;varying vec3 cameraPosition;varying vec2 vGlobalTextureCoord;varying float v_height;void main(void){vec3 aVertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 nh=height*normalize(aVertexPosition);vTextureCoord.xy=aTextureCoord;vGlobalTextureCoord=uGlobalTextureCoord.xy+(uGlobalTextureCoord.zw-uGlobalTextureCoord.xy)*aTextureCoord;vTextureCoord.zw=uNormalMapBias.z*(aTextureCoord+uNormalMapBias.xy);cameraPosition=eyePositionHigh+eyePositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);v_height=height;v_vertex=aVertexPosition+nh;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}
652
652
  #ifdef WEBGL2
653
653
  #define TEXTURE_FUNC texture
654
654
  #else
@@ -657,8 +657,8 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
657
657
  #define SLICE_SIZE 5
658
658
  #define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;
659
659
  #define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);
660
- const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec3 lightPosition;uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform float camHeight;varying vec4 vTextureCoord;varying vec3 v_vertex;varying vec3 cameraPosition;varying vec2 vGlobalTextureCoord;varying float v_height;vec3 sunPos;void main(void){sunPos=lightPosition;vec3 texNormal=texture2D(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);float overGround=1.0-step(0.1,v_height);float shininess=texture2D(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture2D(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+diffuse*diffuseLightWeighting+night,1.0);gl_FragColor=texture2D(defaultTexture,vTextureCoord.xy);if(samplerCount==0){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}vec4 src;blend(gl_FragColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);}`})}function ea(a){return new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",transmittanceTexture:"sampler2D",scatteringTexture:"sampler2D",camHeight:"float",nightTextureCoefficient:"float",maxMinOpacity:"vec2",transitionOpacity:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:`#version 300 es
661
- precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec4 uGlobalTextureCoord;uniform vec3 uNormalMapBias;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;out vec4 vTextureCoord;out vec3 v_vertex;out vec3 cameraPosition;out vec2 vGlobalTextureCoord;out float v_height;void main(void){vec3 aVertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 nh=height*normalize(aVertexPosition);vTextureCoord.xy=aTextureCoord;vGlobalTextureCoord=uGlobalTextureCoord.xy+(uGlobalTextureCoord.zw-uGlobalTextureCoord.xy)*aTextureCoord;vTextureCoord.zw=uNormalMapBias.z*(aTextureCoord+uNormalMapBias.xy);cameraPosition=eyePositionHigh+eyePositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);v_height=height;v_vertex=aVertexPosition+nh;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}`,fragmentShader:Qt("#version 300 es\nprecision highp float;\n#ifdef WEBGL2\n#define TEXTURE_FUNC texture\n#else\n#define TEXTURE_FUNC texture2D\n#endif\n#define SLICE_SIZE 5\n#define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;\n#define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);\nconst vec3 nightStep=10.0*vec3(0.58,0.48,0.25);float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform vec3 lightPosition;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D transmittanceTexture;uniform sampler2D scatteringTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform vec2 maxMinOpacity;uniform float camHeight;uniform float transitionOpacity;in vec4 vTextureCoord;in vec3 v_vertex;in vec3 cameraPosition;in vec2 vGlobalTextureCoord;in float v_height;vec3 sunPos;layout(location=0)out vec4 diffuseColor;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture(transmittanceTexture,vec2(u,v)).xyz;}vec3 multipleScatteringContributionFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture(scatteringTexture,vec2(u,v)).xyz;}void getSunIlluminance(in vec3 point,in vec3 lightDir,out vec3 sunIlluminance){float mu_s=dot(normalize(point),lightDir);float height=length(point)-BOTTOM_RADIUS;sunIlluminance=SUN_INTENSITY*transmittanceFromTexture(height,mu_s);}void atmosGroundColor(out vec4 fragColor,in vec3 normal){vec3 cameraPosition=cameraPosition;if(length(cameraPosition*SPHERE_TO_ELLIPSOID_SCALE)<BOTTOM_RADIUS+1.0){cameraPosition=normalize(cameraPosition*SPHERE_TO_ELLIPSOID_SCALE)*(BOTTOM_RADIUS+1.0)/SPHERE_TO_ELLIPSOID_SCALE;}vec3 rayDirection=normalize(v_vertex-cameraPosition);vec3 lightDir=normalize(sunPos);rayDirection=normalize(rayDirection*SPHERE_TO_ELLIPSOID_SCALE);vec3 camPos=cameraPosition*SPHERE_TO_ELLIPSOID_SCALE;lightDir=normalize(lightDir*SPHERE_TO_ELLIPSOID_SCALE);vec3 light=vec3(0.0);vec3 transmittanceFromCameraToSpace=vec3(1.0);float offset=0.0;float distanceToSpace=0.0;intersectSphere(camPos,rayDirection,TOP_RADIUS,offset,distanceToSpace);vec3 rayOrigin=camPos;if(offset>0.0){rayOrigin+=rayDirection*offset;}float height=length(rayOrigin)-BOTTOM_RADIUS;float rayAngle=dot(rayOrigin,rayDirection)/length(rayOrigin);bool cameraBelow=rayAngle<0.0;transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float phaseAngle=dot(lightDir,rayDirection);float rayleighPhase=rayleighPhase(phaseAngle);float miePhase=miePhase(phaseAngle);float distanceToGround=0.0;bool hitGround=intersectSphere(camPos,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(length(v_vertex*SPHERE_TO_ELLIPSOID_SCALE)>BOTTOM_RADIUS){distanceToGround=distance(camPos,v_vertex*SPHERE_TO_ELLIPSOID_SCALE);}float segmentLength=(distanceToGround-max(offset,0.0))/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDir);vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x*rayleighPhase+mieScatteringCoefficient*opticalDensity.y*miePhase);scatteredLight+=multipleScatteringContributionFromTexture(height,lightAngle)*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y);light+=transmittanceCamera*scatteredLight*segmentLength;t+=segmentLength;}light*=SUN_INTENSITY;vec3 hitPoint=camPos+rayDirection*distanceToGround;vec3 up=normalize(hitPoint);float diffuseAngle=max(dot(up,lightDir),0.0);float lightAngle=dot(normal,lightDir);vec3 tA=transmittanceCamera*GROUND_ALBEDO*SUN_INTENSITY;vec3 scatteringLight=multipleScatteringContributionFromTexture(height,lightAngle);vec3 diffuseTransmittanceLight=transmittanceLight*diffuseAngle;light+=tA*(scatteringLight+diffuseTransmittanceLight);fragColor=vec4(pow(light*8.0,vec3(1.0/2.2)),1.0);}void getAtmosFadingOpacity(out float opacity){float c=length(cameraPosition);float maxDist=sqrt(c*c-BOTTOM_RADIUS*BOTTOM_RADIUS);float minDist=c-BOTTOM_RADIUS;float vertDist=distance(cameraPosition,v_vertex);opacity=clamp(maxMinOpacity.y+(maxMinOpacity.x-maxMinOpacity.y)*getLerpValue(minDist,maxDist,vertDist),0.0,1.0);}void main(void){sunPos=lightPosition;vec3 texNormal=texture(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);vec4 atmosColor;atmosGroundColor(atmosColor,normal);vec3 sunIlluminance;getSunIlluminance(v_vertex*SPHERE_TO_ELLIPSOID_SCALE,lightDir*SPHERE_TO_ELLIPSOID_SCALE,sunIlluminance);float overGround=1.0-step(0.1,v_height);float shininess=texture(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=sunIlluminance*specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+sunIlluminance*diffuse*diffuseLightWeighting+night,1.0);float fadingOpacity;getAtmosFadingOpacity(fadingOpacity);getSunIlluminance(cameraPosition,viewDir*SPHERE_TO_ELLIPSOID_SCALE,sunIlluminance);spec*=sunIlluminance;diffuseColor=texture(defaultTexture,vTextureCoord.xy);if(samplerCount==0){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}vec4 src;blend(diffuseColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;}",a)})}var yc="attribute vec2 corners;void main(void){gl_Position=vec4(corners,0.0,1.0);}",xc="precision lowp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform mat4 viewMatrix;uniform vec3 sunPos;uniform vec3 camPos;uniform vec2 iResolution;uniform float fov;uniform float opacity;uniform sampler2D transmittanceTexture;uniform sampler2D scatteringTexture;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(transmittanceTexture,vec2(u,v)).xyz;}vec3 multipleScatteringContributionFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(scatteringTexture,vec2(u,v)).xyz;}bool intersectEllipsoidToSphere(in vec3 ro,in vec3 rd,in vec3 ellRadii,in float sphereRadius,out float t1,out float t2){float offset=0.0,distanceToSpace=0.0;if(intersectEllipsoid(ro,rd,ellRadii,offset,distanceToSpace)){vec3 hitEll=ro+rd*offset;vec3 nEll=normalEllipsoid(hitEll,ellRadii);float t=0.0;bool intersectsSphere=intersectSphere(hitEll,nEll,sphereRadius,t);vec3 hitSphere=hitEll+nEll*t;t1=length(hitSphere-ro);hitEll=ro+rd*distanceToSpace;nEll=normalEllipsoid(hitEll,ellRadii);t=0.0;intersectsSphere=intersectSphere(hitEll,nEll,sphereRadius,t);hitSphere=hitEll+nEll*t;t2=length(hitSphere-ro);return true;}return false;}mat4 transpose(in mat4 m){vec4 i0=m[0];vec4 i1=m[1];vec4 i2=m[2];vec4 i3=m[3];mat4 outMatrix=mat4(vec4(i0.x,i1.x,i2.x,i3.x),vec4(i0.y,i1.y,i2.y,i3.y),vec4(i0.z,i1.z,i2.z,i3.z),vec4(i0.w,i1.w,i2.w,i3.w));return outMatrix;}void mainImage(out vec4 fragColor){vec3 cameraPosition=camPos;vec3 lightDirection=normalize(sunPos);vec2 uv=(2.0*gl_FragCoord.xy-iResolution.xy)/iResolution.y;float fieldOfView=fov;float z=1.0/tan(fieldOfView*0.5*PI/180.0);vec3 rayDirection=normalize(vec3(uv,-z));vec4 rd=transpose(viewMatrix)*vec4(rayDirection,1.0);rayDirection=rd.xyz;vec3 light=vec3(0.0);vec3 transmittanceFromCameraToSpace=vec3(1.0);float offset=0.0;float distanceToSpace=0.0;rayDirection=normalize(rayDirection*SPHERE_TO_ELLIPSOID_SCALE);cameraPosition*=SPHERE_TO_ELLIPSOID_SCALE;lightDirection=normalize(lightDirection*SPHERE_TO_ELLIPSOID_SCALE);if(length(cameraPosition)<BOTTOM_RADIUS+100.0){cameraPosition=normalize(cameraPosition)*(BOTTOM_RADIUS+100.0);}if(intersectSphere(cameraPosition,rayDirection,TOP_RADIUS,offset,distanceToSpace)){vec3 rayOrigin=cameraPosition;if(offset>0.0){rayOrigin=cameraPosition+rayDirection*offset;}float height=length(rayOrigin)-BOTTOM_RADIUS;float rayAngle=dot(rayOrigin,rayDirection)/length(rayOrigin);bool cameraBelow=rayAngle<0.0;transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float phaseAngle=dot(lightDirection,rayDirection);float rayleighPhase=rayleighPhase(phaseAngle);float miePhase=miePhase(phaseAngle);float distanceToGround=0.0;bool hitGround=intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS-100000.0,distanceToGround)&&hitGround){discard;}float segmentLength=((hitGround ? distanceToGround : distanceToSpace)-max(offset,0.0))/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDirection);vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x*rayleighPhase+mieScatteringCoefficient*opticalDensity.y*miePhase);scatteredLight+=multipleScatteringContributionFromTexture(height,lightAngle)*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y);light+=transmittanceCamera*scatteredLight*segmentLength;t+=segmentLength;}light*=SUN_INTENSITY;if(hitGround){vec3 hitPoint=cameraPosition+rayDirection*distanceToGround;vec3 up=hitPoint/length(hitPoint);float diffuseAngle=max(dot(up,lightDirection),0.0);float lightAngle=dot(up,lightDirection);light+=transmittanceCamera*GROUND_ALBEDO*multipleScatteringContributionFromTexture(height,lightAngle)*SUN_INTENSITY;light+=transmittanceCamera*transmittanceLight*GROUND_ALBEDO*diffuseAngle*SUN_INTENSITY;}}float distanceToGround=0.0;bool hitGround=intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(!hitGround){vec3 sunLum=sunWithBloom(rayDirection,lightDirection)*vec3(1.0,1.0,0.8);sunLum=smoothstep(0.002,1.0,sunLum);light+=sunLum*SUN_INTENSITY*transmittanceFromCameraToSpace;}fragColor=vec4(pow(light*8.0,vec3(1.0/2.2)),clamp(opacity,0.0,1.0));}void main(void){mainImage(gl_FragColor);}";class bc extends te{constructor(e={}){super({name:"Atmosphere",...e}),this._transmittanceBuffer=null,this._scatteringBuffer=null,this.opacity=1,this._parameters={ATMOS_HEIGHT:e.height||1e5,RAYLEIGH_SCALE:e.rayleighScale||.08,MIE_SCALE:e.mieScale||.012,GROUND_ALBEDO:e.groundAlbedo||.05,BOTTOM_RADIUS:e.bottomRadius||6356752314245179e-9,rayleighScatteringCoefficient_0:e.rayleighScatteringCoefficient_0||5.802,rayleighScatteringCoefficient_1:e.rayleighScatteringCoefficient_1||13.558,rayleighScatteringCoefficient_2:e.rayleighScatteringCoefficient_2||33.1,mieScatteringCoefficient:e.mieScatteringCoefficient||3.996,mieExtinctionCoefficient:e.mieExtinctionCoefficient||4.44,ozoneAbsorptionCoefficient_0:e.ozoneAbsorptionCoefficient_0||.65,ozoneAbsorptionCoefficient_1:e.ozoneAbsorptionCoefficient_1||1.881,ozoneAbsorptionCoefficient_2:e.ozoneAbsorptionCoefficient_2||.085,SUN_ANGULAR_RADIUS:e.sunAngularRadius||.004685,SUN_INTENSITY:e.sunIntensity||1,ozoneDensityHeight:e.ozoneDensityHeight||25e3,ozoneDensityWide:e.ozoneDensityWide||15e3}}setParameters(e){this._parameters=JSON.parse(JSON.stringify(e)),this.initLookupTexturesShaders(),this.drawLookupTextures(),this.removeLookupTexturesShaders(),this.initPlanetAtmosphereShader()}get parameters(){return JSON.parse(JSON.stringify(this._parameters))}initPlanetAtmosphereShader(){var e;(e=this.planet)==null||e.initAtmosphereShader(this._parameters)}oninit(){this.renderer&&(this._initLookupTextures(),this.initLookupTexturesShaders(),this.drawLookupTextures(),this.removeLookupTexturesShaders(),this.initBackgroundShader(),this.activate())}initLookupTexturesShaders(){var e,t;this.renderer&&(this.renderer.handler.addProgram((e=this._parameters,new X("transmittance",{uniforms:{iResolution:"vec2"},attributes:{a_position:"vec2"},vertexShader:"attribute vec2 a_position;void main(void){gl_Position=vec4(a_position,0.0,1.0);}",fragmentShader:Qt("precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform vec2 iResolution;void main(void){vec2 uv=gl_FragCoord.xy/iResolution.xy;float height=uv.y*ATMOS_HEIGHT;float angle=uv.x*2.0-1.0;gl_FragColor=vec4(transmittance(height,angle),1.0);}",e)})),!0),this.renderer.handler.addProgram((t=this._parameters,new X("scattering",{uniforms:{iResolution:"vec2",transmittanceTexture:"sampler2d"},attributes:{a_position:"vec2"},vertexShader:"attribute vec2 a_position;void main(void){gl_Position=vec4(a_position,0.0,1.0);}",fragmentShader:Qt("precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform sampler2D transmittanceTexture;uniform vec2 iResolution;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(transmittanceTexture,vec2(u,v)).xyz;}void main(void){vec2 uv=gl_FragCoord.xy/iResolution.xy;float height=uv.y*ATMOS_HEIGHT;float angle=uv.x*2.0-1.0;vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 up=rayOrigin/length(rayOrigin);vec3 lightDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);const float isotropicPhase=1.0/(4.0*PI);vec3 light=vec3(0.0);vec3 lightTransferFactor=vec3(0.0);for(int i=0;i<SQRT_SAMPLE_COUNT;i++){for(int j=0;j<SQRT_SAMPLE_COUNT;j++){float u=((0.5+float(i))/float(SQRT_SAMPLE_COUNT))*2.0-1.0;float v=(0.5+float(j))/float(SQRT_SAMPLE_COUNT);float r=sqrt(1.0-u*u);float theta=2.0*PI*v;vec3 rayDirection=vec3(cos(theta)*r,sin(theta)*r,u);float rayAngle=dot(up,rayDirection);bool cameraBelow=rayAngle<0.0;vec3 transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float offset=0.0;float distanceToSpace=0.0;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,offset,distanceToSpace);float distanceToGround=0.0;bool hitGround=intersectSphere(rayOrigin,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;float segmentLength=(hitGround ? distanceToGround : distanceToSpace)/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int k=0;k<SAMPLE_COUNT;k++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDirection);float distanceToGround;float shadow=intersectSphere(position,lightDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>=0.0 ? 0.0 : 1.0;vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y)*isotropicPhase;light+=shadow*transmittanceCamera*scatteredLight*segmentLength;lightTransferFactor+=transmittanceCamera*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y)*segmentLength;t+=segmentLength;}if(hitGround){vec3 hitPoint=rayOrigin+rayDirection*distanceToGround;vec3 normal=normalize(hitPoint);float diffuseAngle=max(dot(normal,lightDirection),0.0);light+=transmittanceCamera*transmittanceLight*GROUND_ALBEDO*diffuseAngle;}}}light/=float(SAMPLE_COUNT);lightTransferFactor/=float(SAMPLE_COUNT);vec3 color=light/(1.0-lightTransferFactor);gl_FragColor=vec4(color,1.0);}",t)})),!0))}initBackgroundShader(){var e;this.renderer&&this.renderer.handler.addProgram((e=this._parameters,new X("atmosphereBackground",{uniforms:{iResolution:"vec2",fov:"float",camPos:"vec3",viewMatrix:"mat4",transmittanceTexture:"sampler2D",scatteringTexture:"sampler2D",sunPos:"vec3",opacity:"float"},attributes:{corners:"vec3"},vertexShader:yc,fragmentShader:Qt(xc,e)})),!0)}removeBackgroundShader(){this.renderer&&this.renderer.handler.removeProgram("atmosphereBackground")}removeLookupTexturesShaders(){var e,t;if(this.renderer){let i=this.renderer.handler;(e=this._scatteringBuffer)!=null&&e.isComplete()&&i.removeProgram("scattering"),(t=this._transmittanceBuffer)!=null&&t.isComplete()&&i.removeProgram("transmittance")}}onactivate(){super.onactivate(),this.planet&&this.planet.events.on("draw",this._drawBackground,this)}ondeactivate(){super.ondeactivate(),this.planet&&this.planet.events.off("draw",this._drawBackground)}_initLookupTextures(){this._transmittanceBuffer=new Me(this.renderer.handler,{width:1024,height:1024,useDepth:!1,targets:[{filter:"LINEAR",type:"FLOAT",internalFormat:"RGBA16F"}]}),this._transmittanceBuffer.init(),this._scatteringBuffer=new Me(this.renderer.handler,{width:1024,height:1024,useDepth:!1,targets:[{filter:"LINEAR",type:"FLOAT",internalFormat:"RGBA16F"}]}),this._scatteringBuffer.init()}_renderLookupTextures(){if(!this.renderer)return;let e=this.renderer.screenFramePositionBuffer,t=this.renderer.handler,i=t.gl;if(this._transmittanceBuffer){this._transmittanceBuffer.activate();let s=t.programs.transmittance,r=s._program.attributes,n=s._program.uniforms;s.activate(),i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform2fv(n.iResolution,[this._transmittanceBuffer.width,this._transmittanceBuffer.height]),i.bindBuffer(i.ARRAY_BUFFER,e),i.vertexAttribPointer(r.a_position,e.itemSize,i.FLOAT,!1,0,0),i.drawArrays(i.TRIANGLE_STRIP,0,e.numItems),this._transmittanceBuffer.deactivate()}if(this._scatteringBuffer&&this._transmittanceBuffer){this._scatteringBuffer.activate();let s=t.programs.scattering,r=s._program.attributes,n=s._program.uniforms;s.activate(),i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform2fv(n.iResolution,[this._scatteringBuffer.width,this._scatteringBuffer.height]),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._transmittanceBuffer.textures[0]),i.uniform1i(n.transmittanceTexture,0),i.bindBuffer(i.ARRAY_BUFFER,e),i.vertexAttribPointer(r.a_position,e.itemSize,i.FLOAT,!1,0,0),i.drawArrays(i.TRIANGLE_STRIP,0,e.numItems),this._scatteringBuffer.deactivate()}}drawLookupTextures(){this._renderLookupTextures()}_drawBackground(){let e=this.renderer.handler,t=e.programs.atmosphereBackground,i=t._program,s=i.uniforms,r=e.gl,n=this.renderer,o=this.planet.camera;r.disable(r.DEPTH_TEST),t.activate(),r.bindBuffer(r.ARRAY_BUFFER,n.screenFramePositionBuffer),r.vertexAttribPointer(i.attributes.corners,2,r.FLOAT,!1,0,0),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this._transmittanceBuffer.textures[0]),r.uniform1i(s.transmittanceTexture,0),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this._scatteringBuffer.textures[0]),r.uniform1i(s.scatteringTexture,1),r.uniformMatrix4fv(s.viewMatrix,!1,o.getViewMatrix());let l=this.planet.sunPos;r.uniform3fv(s.sunPos,[l.x,l.y,l.z]),r.uniform3fv(s.camPos,[o.eye.x,o.eye.y,o.eye.z]),r.uniform2fv(s.iResolution,[n.sceneFramebuffer.width,n.sceneFramebuffer.height]),r.uniform1f(s.fov,o.getViewAngle()),r.uniform1f(s.opacity,this.opacity),r.drawArrays(r.TRIANGLE_STRIP,0,4),r.enable(r.DEPTH_TEST)}}const ta="degrees",wc="m";let Cc=0;class sr{constructor(e){this.id=Cc++,this.code=e.code,this.units=e.units}equal(e){return e.id===this.id}}const rr=new sr({code:"epsg:3857",units:wc});class Tc{constructor(e){this.segment=e,this.layers=[],this.tileOffsetArr=new Float32Array(e.planet.SLICE_SIZE_4),this.layerOpacityArr=new Float32Array(e.planet.SLICE_SIZE)}clear(){this.layers=null,this.tileOffsetArr=null,this.layerOpacityArr=null}append(e,t){let i=this.layers.length;this.layers.push(e),this.layerOpacityArr[i]=e.screenOpacity;let s=4*i,r=e.applyMaterial(t);this.tileOffsetArr[s]=r[0],this.tileOffsetArr[s+1]=r[1],this.tileOffsetArr[s+2]=r[2],this.tileOffsetArr[s+3]=r[3]}}function We(a,e,t){return Math.floor(Math.abs(t-a)/e)}function nr(a,e,t,i){let s=1/(1<<t),r=i.getWidth()*s,n=i.getHeight()*s,o=i.southWest.lon+a*r,l=i.northEast.lat-e*n;return new G(new A(o,l-n),new A(o+r,l))}const Ec=20,Ct=300;let Tt=new v,Et=new v,or=new v,gi=new v,pi=new v,ar=new v,mi=new U,Qi=new U;const vi=new Array(4);vi[0]=0,vi[1]=1,vi[2]=1,vi[3]=0;const yi=new Array(4);yi[0]=!1,yi[1]=!0,yi[2]=!1,yi[3]=!0;class ia{constructor(e,t,i,s){this.isPole=!1,this._tileGroup=0,this._projection=rr,this.node=e,this.planet=t,this.handler=t.renderer.handler,this.bsphere=new Ve,this._plainRadius=0,this.bbox=new qr,this._sw=new v,this._nw=new v,this._se=new v,this._ne=new v,this.centerNormal=new v,this._extent=this._extentMerc=s,this._extentLonLat=new G,this.gridSize=t.terrain.gridSizeByZoom[i],this.fileGridSize=0,this.tileZoom=i,this.powTileZoom=1<<i,this.tileX=0,this.tileXE=0,this.tileXW=0,this.tileYN=0,this.tileYS=0,this.tileY=0,this.tileIndex="",this.elevationData=null,this._assignTileIndexes(),this.materials=[],this.plainReady=!1,this.initialized=!1,this.normalMapReady=!1,this.terrainReady=!1,this.terrainIsLoading=!1,this.terrainExists=!1,this.passReady=!1,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapTexture=null,this.normalMapTextureBias=new Float32Array(3),this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null,this._globalTextureCoordinates=new Float32Array(4),this._inTheQueue=!1,this._appliedNeighborsZoom=[0,0,0,0],this._slices=[],this._indexBuffer=null,this.readyToEngage=!1,this.plainProcessing=!1,this.normalMapTexturePtr=null,this._transitionOpacity=1,this._transitionTimestamp=0}checkZoom(){return this.tileZoom<this.planet.terrain._maxNodeZoom}getEntityTerrainPoint(e,t){return this.getTerrainPoint(e._cartesian,this.getInsideLonLat(e),t)}getInsideLonLat(e){return e._lonLatMerc}isEntityInside(e){return this._extentLonLat.isInside(e._lonLat)}getTerrainPoint(e,t,i){let s=this.tempVertices;if(s&&s.length){let r=this.planet.ellipsoid.getSurfaceNormal3v(e);mi.set(e,r.negateTo());let n=this._extent.northEast,o=this._extent.southWest,l=Math.sqrt(s.length/3)-1,h=n.lon,c=n.lat,d=o.lon,u=o.lat,g=(h-d)/l,f=(c-u)/l,p=t.lon-d,_=t.lat-u,m=Math.floor(p/g),y=Math.floor(l-_/f),x=3*((l+1)*y+m),w=3*((l+1)*(y+1)+m);or.set(s[x],s[x+1],s[x+2]),gi.set(s[x+3],s[x+4],s[x+5]),pi.set(s[w],s[w+1],s[w+2]);let b=mi.hitTriangleRes(or,gi,pi,i);return b===U.INSIDE?e.distance(i):b===U.AWAY&&(Qi.set(e,r),Qi.hitTriangleRes(or,gi,pi,i)===U.INSIDE)?-e.distance(i):(ar.set(s[w+3],s[w+4],s[w+5]),b=mi.hitTriangleRes(gi,ar,pi,i),b===U.INSIDE?e.distance(i):b===U.AWAY&&(Qi.set(e,r),Qi.hitTriangleRes(gi,ar,pi,i)===U.INSIDE)||b===U.AWAY?-e.distance(i):e.distance(i))}return e.distance(this.planet.ellipsoid.hitRay(mi.origin,mi.direction))}projectNative(e){return e.forwardMercator()}loadTerrain(e=!1){this.tileZoom<this.planet.terrain.minZoom||this.planet.terrain.isEmpty?(this.terrainIsLoading=!0,this.elevationsNotExists(),this._inTheQueue||this.planet._normalMapCreator.queue(this)):this.tileZoom>this.planet.terrain.maxZoom?this.elevationsNotExists():this.terrainIsLoading||this.terrainReady||this.planet.terrain.loadTerrain(this,e)}elevationsExists(e){if(this.plainReady&&this.terrainIsLoading){let t=new Float32Array(e.length);t.set(e),this.elevationData=new Float32Array(e.length),this.elevationData.set(e),this.planet._terrainWorker.make({segment:this,elevations:t}),this.plainVerticesHigh=null,this.plainVerticesLow=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.planet.terrain.equalizeVertices||(this.tempVerticesHigh=null,this.tempVerticesLow=null)}}elevationsNotExists(){if(this.planet&&this.tileZoom<=this.planet.terrain.maxNativeZoom){if(this.plainReady&&this.terrainIsLoading){this.terrainIsLoading=!1;let e=this.node;e.appliedTerrainNodeId=this.node.nodeId,e.equalizedSideWithNodeId[0]=e.equalizedSideWithNodeId[1]=e.equalizedSideWithNodeId[2]=e.equalizedSideWithNodeId[3]=e.appliedTerrainNodeId,this.planet.lightEnabled&&!this._inTheQueue&&this.planet._normalMapCreator.queue(this),this.readyToEngage=!0}this.terrainVertices=this.plainVertices,this.terrainVerticesHigh=this.plainVerticesHigh,this.terrainVerticesLow=this.plainVerticesLow,this.tempVertices=this.terrainVertices,this.tempVerticesHigh=this.terrainVerticesHigh,this.tempVerticesLow=this.terrainVerticesLow,this.noDataVertices=null,this.fileGridSize=Math.sqrt(this.terrainVertices.length/3)-1,this.gridSize=this.fileGridSize,this.terrainReady=!0,this.terrainExists=!1}else if(this.plainReady&&this.terrainIsLoading){this.terrainIsLoading=!1;let e=this.node;e.appliedTerrainNodeId=this.node.nodeId,e.equalizedSideWithNodeId[0]=e.equalizedSideWithNodeId[1]=e.equalizedSideWithNodeId[2]=e.equalizedSideWithNodeId[3]=e.appliedTerrainNodeId,this.readyToEngage=!0,this.terrainReady=!0,this.passReady=!0,this.terrainExists=!1}}_checkEqualization(e,t){return t&&t.segment&&this.tileZoom>=t.segment.tileZoom&&this.node.equalizedSideWithNodeId[e]!==t.equalizedSideWithNodeId[ei[e]]}equalize(){if(this.tileZoom<2||this.gridSize<2)return;this.readyToEngage=!0;let e=this.node.neighbors,t=this.tempVertices,i=this.tempVerticesHigh,s=this.tempVerticesLow,r=this.gridSize,n=r+1,o=e[0][0];if(this._checkEqualization(0,o)){this.node.equalizedSideWithNodeId[0]=o.equalizedSideWithNodeId[2],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,0),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(r/(u*f),1),_=Math.max(u*f/r,1);for(let m=0,y=l*u;m<n;m+=p,y+=_){const x=3*m,w=3*(g*u+y);t[x]=h[w],t[x+1]=h[w+1],t[x+2]=h[w+2],i[x]=c[w],i[x+1]=c[w+1],i[x+2]=c[w+2],s[x]=d[w],s[x+1]=d[w+1],s[x+2]=d[w+2]}}if(o=e[1][0],this._checkEqualization(1,o)){this.node.equalizedSideWithNodeId[1]=o.equalizedSideWithNodeId[3],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,1),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(r/(u*f),1),_=Math.max(u*f/r,1);for(let m=0,y=l*u;m<n;m+=p,y+=_){const x=3*(n*m+r),w=g*y*3;t[x]=h[w],t[x+1]=h[w+1],t[x+2]=h[w+2],i[x]=c[w],i[x+1]=c[w+1],i[x+2]=c[w+2],s[x]=d[w],s[x+1]=d[w+1],s[x+2]=d[w+2]}}if(o=e[2][0],this._checkEqualization(2,o)){this.node.equalizedSideWithNodeId[2]=o.equalizedSideWithNodeId[0],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,2),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=1/(1<<this.tileZoom-o.segment.tileZoom),f=Math.max(r/(u*g),1),p=Math.max(u*g/r,1);for(let _=0,m=l*u;_<n;_+=f,m+=p){const y=3*(n*r+_),x=3*m;t[y]=h[x],t[y+1]=h[x+1],t[y+2]=h[x+2],i[y]=c[x],i[y+1]=c[x+1],i[y+2]=c[x+2],s[y]=d[x],s[y+1]=d[x+1],s[y+2]=d[x+2]}}if(o=e[3][0],this._checkEqualization(3,o)){this.node.equalizedSideWithNodeId[3]=o.equalizedSideWithNodeId[1],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,3),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(r/(u*f),1),_=Math.max(u*f/r,1);for(let m=0,y=l*u;m<n;m+=p,y+=_){const x=n*m*3,w=3*(g*y+u);t[x]=h[w],t[x+1]=h[w+1],t[x+2]=h[w+2],i[x]=c[w],i[x+1]=c[w+1],i[x+2]=c[w+2],s[x]=d[w],s[x+1]=d[w+1],s[x+2]=d[w+2]}}}engage(){this.readyToEngage=!1,this.createCoordsBuffers(this.tempVerticesHigh,this.tempVerticesLow,this.gridSize)}_terrainWorkerCallback(e){if(this.plainReady){this.readyToEngage=!0,this.normalMapNormals=null,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapNormals=e.normalMapNormals,this.normalMapVertices=e.normalMapVertices,this.normalMapVerticesHigh=e.normalMapVerticesHigh,this.normalMapVerticesLow=e.normalMapVerticesLow,this.terrainVertices=e.terrainVertices,this.terrainVerticesHigh=e.terrainVerticesHigh,this.terrainVerticesLow=e.terrainVerticesLow,this.noDataVertices=e.noDataVertices,this.tempVertices=this.terrainVertices,this.tempVerticesHigh=this.terrainVerticesHigh,this.tempVerticesLow=this.terrainVerticesLow,this.setBoundingVolumeArr(e.bounds),this.gridSize=Math.sqrt(this.terrainVertices.length/3)-1;let t=this.node;if(t.appliedTerrainNodeId=t.nodeId,t.equalizedSideWithNodeId[0]=t.equalizedSideWithNodeId[1]=t.equalizedSideWithNodeId[2]=t.equalizedSideWithNodeId[3]=t.appliedTerrainNodeId,this.terrainReady=!0,this.terrainIsLoading=!1,this.terrainExists=!0,!this.normalMapTexturePtr){const i=this.planet._normalMapCreator;this.normalMapTexturePtr=this.planet.renderer.handler.createEmptyTexture_l(i.width,i.height)}this.planet.lightEnabled&&this.planet._normalMapCreator.queue(this)}}_normalMapEdgeEqualize(e){let t=this.node.neighbors,i=t[e],s=i&&i[0],r=this.planet.terrain.maxZoom;this.tileZoom===r&&i&&!(t[0].length||t[1].length||t[2].length||t[3].length)&&(s=this.node.getEqualNeighbor(e));let n=s&&s.segment,o=this;if(s&&n&&n.terrainReady&&n.terrainExists&&n.tileZoom<=r&&o._appliedNeighborsZoom[e]!==n.tileZoom){o._appliedNeighborsZoom[e]=n.tileZoom;let l=o.normalMapNormals,h=n.normalMapNormals;if(!l||!h)return;let c=o.normalMapNormals,d=n.normalMapNormals,u=Math.sqrt(l.length/3),g=u-1;const f=g*vi[e];let p,_,m,y;if(o.tileZoom===n.tileZoom){const x=g-f;if(yi[e])for(let w=0;w<u;w++){let b=3*(w*u+f),E=3*(w*u+x);p=c[b]+d[E],_=c[b+1]+d[E+1],m=c[b+2]+d[E+2],y=1/Math.sqrt(p*p+_*_+m*m),h[E]=l[b]=p*y,h[E+1]=l[b+1]=_*y,h[E+2]=l[b+2]=m*y}else for(let w=0;w<u;w++){let b=3*(f*u+w),E=3*(x*u+w);p=c[b]+d[E],_=c[b+1]+d[E+1],m=c[b+2]+d[E+2],y=1/Math.sqrt(p*p+_*_+m*m),h[E]=l[b]=p*y,h[E+1]=l[b+1]=_*y,h[E+2]=l[b+2]=m*y}n._inTheQueue||n._appliedNeighborsZoom[ei[e]]===o.tileZoom||(n._appliedNeighborsZoom[ei[e]]=o.tileZoom,o.planet._normalMapCreator.queue(n))}}}applyTerrain(e){e?this.elevationsExists(e):this.elevationsNotExists()}deleteBuffers(){const e=this.handler.gl;e.deleteBuffer(this.vertexNormalBuffer),e.deleteBuffer(this.vertexPositionBuffer),e.deleteBuffer(this.vertexPositionBufferHigh),e.deleteBuffer(this.vertexPositionBufferLow),this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null}deleteMaterials(){let e=this.materials;for(let t=0;t<e.length;t++){let i=e[t];i&&i.clear()}this.materials.length=0}deleteElevations(){this.terrainExists=!1,this.terrainReady=!1,this.terrainIsLoading=!1,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.normalMapReady&&(this.handler.gl.deleteTexture(this.normalMapTexture),this.normalMapReady=!1),this._appliedNeighborsZoom=[0,0,0,0],this.normalMapTextureBias[0]=0,this.normalMapTextureBias[1]=0,this.normalMapTextureBias[2]=1,this._inTheQueue=!1}clearSegment(){this.plainReady=!1,this.initialized=!1,this.deleteBuffers(),this.deleteMaterials(),this.deleteElevations()}childrenInitialized(){let e=this.node.nodes;return e.length===4&&e[0].segment.initialized&&e[1].segment.initialized&&e[2].segment.initialized&&e[3].segment.initialized}destroySegment(){this.clearSegment();let e=this._slices.length;for(;e--;)this._slices[e].clear();this._slices=null,this.node=null,this.planet=null,this.handler=null,this.bbox=null,this.bsphere=null,this._extent=null,this.materials=null,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapTextureBias=null,this.normalMapTexture=null,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null,this._projection=null,this._appliedNeighborsZoom=null,this._globalTextureCoordinates=null}_setExtentLonLat(){this._extentLonLat=this._extent.inverseMercator()}_createExtentNormals(){const e=this.planet.ellipsoid,t=this._extentLonLat,i=e.geodeticToCartesian(t.southWest.lon,t.southWest.lat),s=e.geodeticToCartesian(t.northEast.lon,t.northEast.lat),r=e.geodeticToCartesian(t.southWest.lon,t.northEast.lat),n=e.geodeticToCartesian(t.northEast.lon,t.southWest.lat);this._sw.copy(i),this._nw.copy(r),this._ne.copy(s),this._se.copy(n)}createBoundsByExtent(){this._createExtentNormals(),this.setBoundingVolume3v(this._sw,this._ne)}createBoundsByParent(){let e=this.node;for(;e.parentNode&&!e.segment.terrainReady;)e=e.parentNode;let t=1<<this.tileZoom-e.segment.tileZoom,i=this.tileX-e.segment.tileX*t,s=this.tileY-e.segment.tileY*t;if(e.segment.terrainReady&&e.segment.tileZoom>=this.planet.terrain.minZoom){let r=e.segment.gridSize/t;if(r>=1){this.bsphere.center.x=e.segment.bsphere.center.x,this.bsphere.center.y=e.segment.bsphere.center.y,this.bsphere.center.z=e.segment.bsphere.center.z,this.bsphere.radius=e.segment.bsphere.radius;let n=r*s,o=r*i,l=e.segment.gridSize+1,h=3*((n+r)*l+o),c=3*(n*l+o),d=3*(n*l+o+r),u=3*((n+r)*l+o+r),g=e.segment.tempVertices,f=new v(g[h],g[h+1],g[h+2]),p=new v(g[d],g[d+1],g[d+2]),_=new v(g[c],g[c+1],g[c+2]),m=new v(g[u],g[u+1],g[u+2]);this._sw.copy(f),this._nw.copy(_),this._ne.copy(p),this._se.copy(m)}else{let n,o=e.segment,l=Math.floor(r*s),h=Math.floor(r*i),c=1/r,d=s-c*l,u=i-c*h;n=o.gridSize===1?o.tempVertices:ps(o.tempVertices,o.gridSize,l,h,1);let g,f,p=new v(n[0],n[1],n[2]),_=new v(n[9],n[10],n[11]),m=new v(n[3]-n[0],n[4]-n[1],n[5]-n[2]),y=new v(n[6]-n[0],n[7]-n[1],n[8]-n[2]),x=new v(n[3]-n[9],n[4]-n[10],n[5]-n[11]),w=new v(n[6]-n[9],n[7]-n[10],n[8]-n[11]),b=d,E=u;g=b+E<c?v.add(m.scaleTo(E/c),y.scaleTo(b/c)).addA(p):v.add(w.scaleTo(1-E/c),x.scaleTo(1-b/c)).addA(_),b=d+1,E=u+1,f=b+E<c?v.add(m.scaleTo(E/c),y.scaleTo(b/c)).addA(p):v.add(w.scaleTo(1-E/c),x.scaleTo(1-b/c)).addA(_),this._createExtentNormals(),this.setBoundingVolume3v(g,f)}}else this.createBoundsByExtent()}setBoundingSphere(e,t,i,s){this.bsphere.center.x=e,this.bsphere.center.y=t,this.bsphere.center.z=i,this.bsphere.radius=this.bsphere.center.distance(s)}setBoundingVolume(e,t,i,s,r,n){this.bbox.setFromBoundsArr([e,t,i,s,r,n]);let o=e+.5*(s-e),l=t+.5*(r-t),h=i+.5*(n-i);this.bsphere.center.set(o,l,h),this.bsphere.radius=this.bsphere.center.distance(new v(e,t,i))}setBoundingVolume3v(e,t){this.bbox.setFromBoundsArr([e.x,e.y,e.z,t.x,t.y,t.z]);let i=e.x+.5*(t.x-e.x),s=e.y+.5*(t.y-e.y),r=e.z+.5*(t.z-e.z);this.bsphere.center.set(i,s,r),this.bsphere.radius=this.bsphere.center.distance(new v(e.x,e.y,e.z))}setBoundingVolumeArr(e){this.bbox.setFromBoundsArr(e);let t=e[0]+.5*(e[3]-e[0]),i=e[1]+.5*(e[4]-e[1]),s=e[2]+.5*(e[5]-e[2]);this.bsphere.center.set(t,i,s),this.bsphere.radius=this.bsphere.center.distance(new v(e[0],e[1],e[2]))}createCoordsBuffers(e,t,i){const s=(i+1)*(i+1),r=this.handler;this.vertexPositionBufferHigh&&this.vertexPositionBufferHigh.numItems===s?(r.setStreamArrayBuffer(this.vertexPositionBufferHigh,e),r.setStreamArrayBuffer(this.vertexPositionBufferLow,t)):(r.gl.deleteBuffer(this.vertexPositionBufferHigh),r.gl.deleteBuffer(this.vertexPositionBufferLow),this.vertexTextureCoordBuffer=this.planet._textureCoordsBufferCache[Math.log2(i)],this.vertexPositionBufferHigh=r.createArrayBuffer(e,3,s),this.vertexPositionBufferLow=r.createArrayBuffer(t,3,s))}_addViewExtent(){const e=this._extentLonLat;let t=this.planet._viewExtent;e.southWest.lon<t.southWest.lon&&(t.southWest.lon=e.southWest.lon),e.northEast.lon>t.northEast.lon&&(t.northEast.lon=e.northEast.lon),e.southWest.lat<t.southWest.lat&&(t.southWest.lat=e.southWest.lat),e.northEast.lat>t.northEast.lat&&(t.northEast.lat=e.northEast.lat)}_assignTileIndexes(){this._tileGroup=0;const e=this.tileZoom,t=this._extent,i=Ee;this.tileX=We(t.getCenter().lon,t.getWidth(),-2003750834e-2),this.tileY=We(t.getCenter().lat,t.getHeight(),i);const s=this.powTileZoom;this.tileXE=(this.tileX+1)%s,this.tileXW=(s+this.tileX-1)%s,this.tileYN=this.tileY-1,this.tileYS=this.tileY+1,this.tileIndex=qe.getTileIndex(this.tileX,this.tileY,e,this._tileGroup)}initialize(){const e=this.planet,t=this.node;if(this.gridSize=e.terrain.gridSizeByZoom[this.tileZoom]||e.terrain.plainGridSize,t.sideSizeLog2[0]=t.sideSizeLog2[1]=t.sideSizeLog2[2]=t.sideSizeLog2[3]=Math.log2(this.gridSize),this.tileZoom<=e.terrain.maxZoom){const i=this.planet._normalMapCreator;this.normalMapTexturePtr=e.renderer.handler.createEmptyTexture_l(i.width,i.height)}this.normalMapTexture=this.planet.transparentTexture,this._assignGlobalTextureCoordinates(),this.initialized=!0}_assignGlobalTextureCoordinates(){const e=this._extent;this._globalTextureCoordinates[0]=(e.southWest.lon+Ee)*$t,this._globalTextureCoordinates[1]=(Ee-e.northEast.lat)*$t,this._globalTextureCoordinates[2]=(e.northEast.lon+Ee)*$t,this._globalTextureCoordinates[3]=(Ee-e.southWest.lat)*$t}createPlainSegmentAsync(){let e=this.planet,t=e.terrain;t.isReady()&&!this.plainReady&&this.tileZoom<=t.maxZoom&&(this.plainProcessing=!0,e._plainSegmentWorker.make(this))}_plainSegmentWorkerCallback(e){this.plainProcessing=!1,this.initialized&&!this.terrainReady&&(this.plainReady=!0,this.plainVertices=e.plainVertices,this.plainVerticesHigh=e.plainVerticesHigh,this.plainVerticesLow=e.plainVerticesLow,this.plainNormals=e.plainNormals,this._plainRadius=e.plainRadius,this.normalMapNormals=e.normalMapNormals,this.normalMapVertices=e.normalMapVertices,this.normalMapVerticesHigh=e.normalMapVerticesHigh,this.normalMapVerticesLow=e.normalMapVerticesLow,this.fileGridSize=Math.sqrt(e.normalMapVertices.length/3)-1)}createPlainSegment(){this.initialize(),this._createPlainVertices(),this.readyToEngage=!0}_projToDeg(e,t){return A.inverseMercator(e,t)}_createPlainVertices(){const e=this.planet.terrain.gridSizeByZoom[this.tileZoom],t=this.planet.terrain.plainGridSize,i=Math.max(t,e),s=this._extent,r=s.getWidth()/i,n=s.getHeight()/i,o=s.southWest.lon,l=s.northEast.lat,h=Math.max(t/e,1),c=i+1,d=this.planet.ellipsoid._invRadii2,u=c*c,g=(e+1)*(e+1)*3;let f=0,p=0;this.plainNormals=new Float32Array(g),this.plainVertices=new Float64Array(g),this.plainVerticesHigh=new Float32Array(g),this.plainVerticesLow=new Float32Array(g),this.normalMapNormals=new Float32Array(3*u),this.normalMapVertices=new Float64Array(3*u),this.normalMapVerticesHigh=new Float32Array(3*u),this.normalMapVerticesLow=new Float32Array(3*u);let _=this.plainVertices,m=this.plainVerticesHigh,y=this.plainVerticesLow,x=this.plainNormals,w=this.normalMapVertices,b=this.normalMapVerticesHigh,E=this.normalMapVerticesLow,C=this.normalMapNormals;for(let T=0;T<u;T++){let L=T%c,M=~~(T/c),R=this.planet.ellipsoid.lonLatToCartesian(this._projToDeg(o+L*r,l-M*n)),z=R.x*d.x,F=R.y*d.y,P=R.z*d.z,D=1/Math.sqrt(z*z+F*F+P*P),I=z*D,k=F*D,B=P*D;v.doubleToTwoFloats(R,Tt,Et),w[p]=R.x,b[p]=Tt.x,E[p]=Et.x,C[p++]=I,w[p]=R.y,b[p]=Tt.y,E[p]=Et.y,C[p++]=k,w[p]=R.z,b[p]=Tt.z,E[p]=Et.z,C[p++]=B,M%h==0&&L%h==0&&(_[f]=R.x,m[f]=Tt.x,y[f]=Et.x,x[f++]=I,_[f]=R.y,m[f]=Tt.y,y[f]=Et.y,x[f++]=k,_[f]=R.z,m[f]=Tt.z,y[f]=Et.z,x[f++]=B)}this.terrainVertices=_,this.terrainVerticesHigh=m,this.terrainVerticesLow=y,this.plainReady=!0}getMaterialByLayer(e){return this.materials[e.__id]}_getLayerExtentOffset(e){const t=e._extentMerc,i=this._extent,s=t.northEast.lon-t.southWest.lon,r=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/s,(t.northEast.lat-i.northEast.lat)/r,(i.northEast.lon-i.southWest.lon)/s,(i.northEast.lat-i.southWest.lat)/r]}initSlice(e){let t=this._slices[e];return t?t.layers=[]:t=this._slices[e]=new Tc(this),t}screenRendering(e,t,i,s,r=!1,n){const o=this.handler.gl,l=e.attributes,h=e.uniforms,c=this.materials,d=this.planet;let u,g;t&&t.length?(g=t[0],u=g._height):u=0,o.activeTexture(o.TEXTURE0+d.SLICE_SIZE+2),o.bindTexture(o.TEXTURE_2D,s||this.getDefaultTexture()),o.uniform1i(h.defaultTexture,d.SLICE_SIZE+2);let f=0,p=0,_=!1,m=this.initSlice(i);for(this._indexBuffer=this._getIndexBuffer();g;){if(this.layerOverlap(g)&&(g._fading&&g._fadingOpacity>0||(g.minZoom>=d.minCurrZoom||g.maxZoom>=d.minCurrZoom)&&(g.minZoom<=d.maxCurrZoom||g.maxZoom<=d.maxCurrZoom))){_=!0;let y=c[g.__id];y||(y=c[g.__id]=g.createMaterial(this)),y.isReady||(this.planet._renderCompleted=!1),m.append(g,y),d._samplerArr[f]=f,o.activeTexture(o.TEXTURE0+f),o.bindTexture(o.TEXTURE_2D,y.texture||d.transparentTexture),f++}p++,g=t[p]}!_&&r||(o.uniform1f(h.transitionOpacity,n||this._transitionOpacity>1?1:this._transitionOpacity),o.uniform1i(h.samplerCount,f),o.uniform1f(h.height,u),o.uniform1iv(h.samplerArr,d._samplerArr),o.uniform4fv(h.tileOffsetArr,m.tileOffsetArr),o.uniform1fv(h.layerOpacityArr,m.layerOpacityArr),d.lightEnabled&&(o.activeTexture(o.TEXTURE0+d.SLICE_SIZE+3),o.bindTexture(o.TEXTURE_2D,this.normalMapTexture||d.transparentTexture),o.uniform1i(h.uNormalMap,d.SLICE_SIZE+3),o.uniform3fv(h.uNormalMapBias,this.normalMapTextureBias),o.uniform4fv(h.uGlobalTextureCoord,this._globalTextureCoordinates)),o.bindBuffer(o.ARRAY_BUFFER,this.vertexPositionBufferHigh),o.vertexAttribPointer(l.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.vertexPositionBufferLow),o.vertexAttribPointer(l.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.vertexTextureCoordBuffer),o.vertexAttribPointer(l.aTextureCoord,2,o.UNSIGNED_SHORT,!0,0,0),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,this._indexBuffer),o.drawElements(d.drawMode,this._indexBuffer.numItems,o.UNSIGNED_INT,0))}heightPickingRendering(e,t){const i=this.handler.gl,s=e.attributes,r=e.uniforms;let n;n=t&&t.length?t[0]._height:0,i.uniform1f(r.height,n),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferHigh),i.vertexAttribPointer(s.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferLow),i.vertexAttribPointer(s.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,this._indexBuffer.numItems,i.UNSIGNED_INT,0)}increaseTransitionOpacity(){this._transitionOpacity+=(window.performance.now()-this._transitionTimestamp)/this.planet.transitionTime,this._transitionTimestamp=window.performance.now(),this._transitionOpacity>2&&(this._transitionOpacity=2);let e=this.node._fadingNodes.length;for(;e--;){let t=this.node._fadingNodes[e];if(!t.segment){this._transitionOpacity=1;break}t.segment._transitionOpacity>0&&!this.planet._fadingNodes.has(t.__id)&&(this.planet._fadingNodes.set(t.__id,t),t.segment._transitionOpacity=2-this._transitionOpacity,t.segment._transitionOpacity===0&&this.node._fadingNodes.splice(e,1))}}fadingTransitionOpacity(){this._transitionOpacity-=.01,this._transitionTimestamp=window.performance.now(),this._transitionOpacity<0&&(this._transitionOpacity=0)}colorPickingRendering(e,t,i,s,r=!1){const n=this.handler.gl,o=e.attributes,l=e.uniforms;let h,c=this.materials,d=this.planet;h=t&&t.length?t[0]._height:0;let u=!1,g=this._slices[i],f=g.layers.length;for(let p=0;p<f;p++){u=!0;let _=g.layers[p],m=4*p;d._pickingColorArr[m]=_._pickingColor.x/255,d._pickingColorArr[m+1]=_._pickingColor.y/255,d._pickingColorArr[m+2]=_._pickingColor.z/255,d._pickingColorArr[m+3]=Number(_._pickingEnabled),d._samplerArr[p]=p,n.activeTexture(n.TEXTURE0+p),n.bindTexture(n.TEXTURE_2D,c[_.__id].texture||this.planet.transparentTexture),d._pickingMaskArr[p]=p+d.SLICE_SIZE,n.activeTexture(n.TEXTURE0+p+d.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,c[_.__id].pickingMask||this.planet.transparentTexture)}!u&&r||(n.uniform1i(l.samplerCount,f),n.uniform1f(l.height,h),n.uniform1iv(l.samplerArr,d._samplerArr),n.uniform1iv(l.pickingMaskArr,d._pickingMaskArr),n.uniform4fv(l.pickingColorArr,d._pickingColorArr),n.uniform4fv(l.tileOffsetArr,g.tileOffsetArr),n.uniform1fv(l.layerOpacityArr,g.layerOpacityArr),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBufferHigh),n.vertexAttribPointer(o.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBufferLow),n.vertexAttribPointer(o.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this.vertexTextureCoordBuffer),n.vertexAttribPointer(o.aTextureCoord,2,n.UNSIGNED_SHORT,!0,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this._indexBuffer),n.drawElements(n.TRIANGLE_STRIP,this._indexBuffer.numItems,n.UNSIGNED_INT,0))}depthRendering(e,t){const i=this.handler.gl,s=e.attributes,r=e.uniforms;var n;n=t&&t.length?t[0]._height:0,i.uniform1f(r.height,n),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferHigh),i.vertexAttribPointer(s.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferLow),i.vertexAttribPointer(s.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,this._indexBuffer.numItems,i.UNSIGNED_INT,0)}_getIndexBuffer(){const e=this.node.sideSizeLog2;let t=this.planet._indexesCache[Math.log2(this.gridSize)][e[0]][e[1]][e[2]][e[3]];if(!t.buffer){let i=Zi().createSegmentIndexes(Math.log2(this.gridSize),[e[0],e[1],e[2],e[3]]);t.buffer=this.planet.renderer.handler.createElementArrayBuffer(i,1),this.planet._indexesCacheToRemoveCounter++}return t.buffer}layerOverlap(e){return this._extent.overlaps(e._extentMerc)}getDefaultTexture(){return this.planet.solidTextureOne}getExtentLonLat(){return this._extentLonLat}getExtentMerc(){return this._extentMerc}getExtent(){return this._extent}getNeighborSide(e){if(this.tileY===e.tileY){if(this.tileX===e.tileXE)return 3;if(this.tileX===e.tileXW)return 1}else if(this.tileX===e.tileX){if(this.tileY===e.tileYS)return 0;if(this.tileY===e.tileYN)return 2}return-1}}let Ki=new v,Ji=new v;const At=[new N(0,0),new N(1,0),new N(0,1),new N(1,1)],Ac=Math.sqrt(At.length)-1;let oe={xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0},Lc=0;class ft{constructor(e,t,i,s,r,n){t._createdNodesCount++,this.__id=Lc++,this.SegmentPrototype=e,this.planet=t,this.parentNode=s,this.partId=i,this.nodeId=i+(s?4*s.nodeId+1:0),this.state=null,this.prevState=null,this.appliedTerrainNodeId=-1,this.sideSizeLog2=[0,0,0,0],this.ready=!1,this.neighbors=[[],[],[],[]],this.equalizedSideWithNodeId=[this.nodeId,this.nodeId,this.nodeId,this.nodeId],this.nodes=[],this.segment=new e(this,t,r,n),this._cameraInside=!1,this.inFrustum=0,this._fadingNodes=[],this.createBounds()}createChildNodes(){this.ready=!0;const e=this.planet,t=this.segment,i=t._extent,s=t.tileZoom+1,r=.5*i.getWidth(),n=.5*i.getHeight(),o=i.northEast,l=i.southWest,h=new A(l.lon+r,l.lat+n),c=this.nodes;c[0]=new ft(this.SegmentPrototype,e,0,this,s,new G(new A(l.lon,l.lat+n),new A(l.lon+r,o.lat))),c[1]=new ft(this.SegmentPrototype,e,1,this,s,new G(h,new A(o.lon,o.lat))),c[2]=new ft(this.SegmentPrototype,e,2,this,s,new G(new A(l.lon,l.lat),h)),c[3]=new ft(this.SegmentPrototype,e,3,this,s,new G(new A(l.lon+r,l.lat),new A(o.lon,l.lat+n)))}createBounds(){let e=this.segment;e._setExtentLonLat(),e.tileZoom===0?e.setBoundingSphere(0,0,0,new v(0,0,e.planet.ellipsoid.equatorialSize)):e.tileZoom<e.planet.terrain.minZoom?e.createBoundsByExtent():e.createBoundsByParent();let t=e.bsphere.center.x,i=e.bsphere.center.y,s=e.bsphere.center.z,r=1/Math.sqrt(t*t+i*i+s*s);e.centerNormal.x=t*r,e.centerNormal.y=i*r,e.centerNormal.z=s*r}getState(){if(this.state===-1)return this.state;let e=this.parentNode;for(;e;){if(e.state!==2)return 0;e=e.parentNode}return this.state}getEqualNeighbor(e){let t=this,i=Kr[e][t.partId];if(i!==-1)return t.parentNode.nodes[i];{let s=[];for(;t.parentNode;)if(s.push(t.partId),i=Kr[e][t.partId],t=t.parentNode,i!==-1){let r=s.length;for(e=ei[e];t&&r--;)i=gl[e][s[r]],t=t.nodes[i];return t}}}traverseNodes(e,t,i,s,r){this.ready||this.createChildNodes();let n=this.nodes;n[0].renderTree(e,t,i,s,r),n[1].renderTree(e,t,i,s,r),n[2].renderTree(e,t,i,s,r),n[3].renderTree(e,t,i,s,r)}renderTree(e,t,i,s,r){if(this.planet._renderedNodes.length>=1e3)return;(!t||r&&this.segment.tileZoom>r.segment.tileZoom)&&(this.prevState=this.state),this.state=2,this.clearNeighbors();let n=this.segment,o=this.planet;if(this._cameraInside=!1,!this.parentNode||this.parentNode._cameraInside){let c;c=n._projection.id===rr.id?n._extent.isInside(e._lonLatMerc):n._extent.isInside(e._lonLat),c&&(e._insideSegment=n,this._cameraInside=!0)}this.inFrustum=0;let l=e.frustums,h=l.length;if(n.tileZoom<6)for(let c=0;c<h;c++)l[c].containsSphere(n.bsphere)&&(this.inFrustum|=1<<c);else for(let c=0;c<h;c++)n.terrainReady?l[c].containsBox(n.bbox)&&(this.inFrustum|=1<<c):l[c].containsSphere(n.bsphere)&&(this.inFrustum|=1<<c);if(this.inFrustum||this._cameraInside||n.tileZoom<3){let c=Math.abs(e._lonLat.height),d=e.eye.length2()-o.ellipsoid.polarSizeSqr;d=d<10687647287563281e-5*o._heightFactor?10687647287563281e-5*o._heightFactor:d;let u=n.tileZoom<2||n.tileZoom>19||n.tileZoom<6&&!n.terrainReady;u=u||e.eye.distance2(n._sw)<d||e.eye.distance2(n._nw)<d||e.eye.distance2(n._ne)<d||e.eye.distance2(n._se)<d,(this.inFrustum&&(u||c>1e4)||this._cameraInside)&&o.quadTreeStrategy.collectVisibleNode(this),n.tileZoom<2?this.traverseNodes(e,t,i,s,r):n.terrainReady&&(!t&&e.projectedSize(n.bsphere.center,n._plainRadius)<o.lodSize||t&&(n.tileZoom===t||!u))?u?(n.passReady=!0,this.renderNode(this.inFrustum,!this.inFrustum,i,s)):this.state=0:n.terrainReady&&n.checkZoom()&&(!t||e.projectedSize(n.bsphere.center,n.bsphere.radius)>this.planet._maxLodSize)?this.traverseNodes(e,t,n,s,r):u?(n.passReady=!!t&&n.terrainReady,this.renderNode(this.inFrustum,!this.inFrustum,i,s)):this.state=0}else this.state=0}renderNode(e,t,i,s){let r=this.segment;r.terrainReady||(r.initialized||r.initialize(),this.whileTerrainLoading(i),r.plainProcessing||r.createPlainSegmentAsync(),r.plainReady&&!s&&r.loadTerrain()),r.planet.lightEnabled&&!r.normalMapReady&&this.whileNormalMapCreating(),t?this.state=-1:(!this._cameraInside&&r.tileZoom>this.planet.maxCurrZoom&&(this.planet.maxCurrZoom=r.tileZoom),r.tileZoom<this.planet.minCurrZoom&&(this.planet.minCurrZoom=r.tileZoom),r._addViewExtent(),this.addToRender(e))}childrenPrevStateEquals(e){let t=this.nodes;return t.length===4&&t[0].prevState===e&&t[1].prevState===e&&t[2].prevState===e&&t[3].prevState===e}isFading(){let e=this.nodes;return this.state===2&&this.segment._transitionOpacity>0&&e.length===4&&e[0].state===1&&e[1].state===1&&e[2].state===1&&e[3].state===1}_collectFadingNodes(){if(this.segment.tileZoom<3)this.segment._transitionOpacity=1;else if(this.prevState!==1){this.segment._transitionOpacity=0,this._fadingNodes=[];let e=window.performance.now();if(this.segment._transitionTimestamp=e,this.parentNode){if(this.parentNode.prevState===1){let t=this.parentNode.parentNode;for(;t;){if(t.isFading()){for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment._transitionOpacity=1,t.nodes[i]._fadingNodes=[];t.segment._transitionOpacity=0;break}t=t.parentNode}this.parentNode.whileTerrainLoading(),this._fadingNodes.push(this.parentNode),this.parentNode.segment._transitionOpacity=2,this.parentNode.segment._transitionTimestamp=e}else if(this.segment.childrenInitialized()&&this.childrenPrevStateEquals(1))for(let t=0;t<this.nodes.length;t++){let i=this.nodes[t];i.whileTerrainLoading(),this._fadingNodes.push(i),i.segment._transitionOpacity=2,i.segment._transitionTimestamp=e,i.prevState=i.state,i.state=0}}}}clearNeighbors(){this.neighbors&&(this.neighbors[0]=this.neighbors[1]=this.neighbors[2]=this.neighbors[3]=null,this.neighbors[0]=[],this.neighbors[1]=[],this.neighbors[2]=[],this.neighbors[3]=[])}_refreshTransitionOpacity(){if(this._fadingNodes.length===0)this.segment._transitionOpacity=1;else if(this._fadingNodes.length!==4||this.childrenPrevStateEquals(1)){for(let e=0;e<this._fadingNodes.length;e++)this.segment._transitionOpacity<1&&this._fadingNodes[e].segment._transitionOpacity===0&&(this._fadingNodes[e].segment._transitionOpacity=0,this.segment._transitionOpacity=1);this.segment.increaseTransitionOpacity()}else this.segment._transitionOpacity=1,this._fadingNodes=[]}addToRender(e){this.state=1;let t=this.planet._renderedNodes;this.planet._transitionOpacityEnabled?gs(t,this,(r,n)=>r.segment.tileZoom-n.segment.tileZoom):(this.getRenderedNodesNeighbors(t),t.push(this)),this.segment.terrainReady||(this.planet._renderCompleted=!1,this.planet._terrainCompleted=!1);let i=0,s=this.planet._renderedNodesInFrustum;for(;e;)1&e&&s[i].push(this),i++,e>>=1}applyNeighbor(e,t){const i=ei[t];if(this.neighbors[t].length===0||e.neighbors[i].length===0){const s=this.segment,r=e.segment,n=s.gridSize/(r.gridSize*Math.pow(2,r.tileZoom-s.tileZoom));let o=s.gridSize,l=r.gridSize;n>1?(o=Math.ceil(s.gridSize/n),l=r.gridSize):n<1&&(o=s.gridSize,l=Math.ceil(r.gridSize*n)),this.sideSizeLog2[t]=Math.log2(o),e.sideSizeLog2[i]=Math.log2(l)}this.neighbors[t].push(e),e.neighbors[i].push(this)}getRenderedNodesNeighbors(e){for(let t=e.length-1;t>=0;--t){let i=e[t],s=this.getCommonSide(i);s!==-1&&this.applyNeighbor(i,s)}}getCommonSide(e){const t=this.segment,i=e.segment;if(t.tileZoom===i.tileZoom&&t._tileGroup===i._tileGroup)return t.getNeighborSide(i);{const s=t._extentLonLat,r=i._extentLonLat;let n=s.northEast,o=s.southWest,l=r.northEast,h=r.southWest,c=n.lon,d=n.lat,u=o.lon,g=o.lat,f=l.lon,p=l.lat,_=h.lon,m=h.lat;if(t._tileGroup===i._tileGroup){if(c===_&&(d<=p&&g>=m||d>=p&&g<=m))return 1;if(u===f&&(d<=p&&g>=m||d>=p&&g<=m))return 3;if(d===m&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(g===p&&(u>=_&&c<=f||u<=_&&c>=f))return 2;if(i.tileX===0&&_===-c&&(d<=p&&g>=m||d>=p&&g<=m))return 1;if(t.tileX===0&&u===-f&&(d<=p&&g>=m||d>=p&&g<=m))return 3}if(t._tileGroup===0&&i._tileGroup===20&&t.tileY===0&&i.tileY===i.powTileZoom-1&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(t._tileGroup===0&&i._tileGroup===Ct&&t.tileY===t.powTileZoom-1&&i.tileY===0&&(u>=_&&c<=f||u<=_&&c>=f))return 2;if(t._tileGroup===Ct&&i._tileGroup===0&&t.tileY===0&&i.tileY===i.powTileZoom-1&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(t._tileGroup===20&&i._tileGroup===0&&t.tileY===t.powTileZoom-1&&i.tileY===0&&(u>=_&&c<=f||u<=_&&c>=f))return 2}return-1}whileNormalMapCreating(){const e=this.segment;e.terrainIsLoading||!e.terrainExists||e._inTheQueue||e.planet._normalMapCreator.queue(e);let t=this;for(;t.parentNode&&!t.segment.normalMapReady;)t=t.parentNode;const i=2<<e.tileZoom-t.segment.tileZoom-1;e.normalMapTexture=t.segment.normalMapTexture,e.normalMapTextureBias[0]=e.tileX-t.segment.tileX*i,e.normalMapTextureBias[1]=e.tileY-t.segment.tileY*i,e.normalMapTextureBias[2]=1/i}whileTerrainLoading(e){const t=this.segment;let i=this;if(e&&e.terrainReady)i=e.node;else for(;i.parentNode&&!i.segment.terrainReady;)i=i.parentNode;if(i.segment.terrainReady&&this.appliedTerrainNodeId!==i.nodeId){let s=2<<t.tileZoom-i.segment.tileZoom-1,r=t.tileX-i.segment.tileX*s,n=t.tileY-i.segment.tileY*s;const o=i.segment;let l,h,c,d;this.appliedTerrainNodeId=i.nodeId,this.equalizedSideWithNodeId[0]=this.equalizedSideWithNodeId[1]=this.equalizedSideWithNodeId[2]=this.equalizedSideWithNodeId[3]=this.appliedTerrainNodeId;let u=i.segment.gridSize/s,g=i.segment.fileGridSize/s;if(oe.xmin=ye,oe.xmax=Te,oe.ymin=ye,oe.ymax=Te,oe.zmin=ye,oe.zmax=Te,u>=1){t.gridSize=u;let f=(u+1)*(u+1)*3;l=new Float64Array(f),h=new Float32Array(f),c=new Float32Array(f),o.noDataVertices&&(d=new Uint8Array(f/3)),ms(o.terrainVertices,o.terrainVerticesHigh,o.terrainVerticesLow,o.noDataVertices,o.gridSize,u*n,u*r,u,l,h,c,oe,d)}else if(g>=1&&i.segment.terrainExists){t.gridSize=g;let f=(g+1)*(g+1)*3;l=new Float64Array(f),h=new Float32Array(f),c=new Float32Array(f),o.noDataVertices&&(d=new Uint8Array(f/3)),ms(o.normalMapVertices,o.normalMapVerticesHigh,o.normalMapVerticesLow,o.noDataVertices,i.segment.fileGridSize,g*n,g*r,g,l,h,c,oe,d)}else{t.gridSize=Ac;let f,p=Math.floor(u*n),_=Math.floor(u*r);f=o.gridSize===1?o.terrainVertices:ps(o.terrainVertices,o.gridSize,p,_,1);let m=1/u,y=n-m*p,x=r-m*_,w=new v(f[0],f[1],f[2]),b=new v(f[9],f[10],f[11]),E=new v(f[3]-f[0],f[4]-f[1],f[5]-f[2]),C=new v(f[6]-f[0],f[7]-f[1],f[8]-f[2]),T=new v(f[3]-f[9],f[4]-f[10],f[5]-f[11]),L=new v(f[6]-f[9],f[7]-f[10],f[8]-f[11]),M=new v;l=new Float64Array(3*At.length),h=new Float32Array(3*At.length),c=new Float32Array(3*At.length);for(let R=0;R<At.length;R++){let z=At[R].y+y,F=At[R].x+x,P=F*u,D=z*u;M=z+F<m?E.scaleTo(P).addA(C.scaleTo(D)).addA(w):L.scaleTo(1-P).addA(T.scaleTo(1-D)).addA(b),v.doubleToTwoFloats(M,Ki,Ji);let I=3*R;l[I]=M.x,l[I+1]=M.y,l[I+2]=M.z,h[I]=Ki.x,h[I+1]=Ki.y,h[I+2]=Ki.z,c[I]=Ji.x,c[I+1]=Ji.y,c[I+2]=Ji.z,M.x<oe.xmin&&(oe.xmin=M.x),M.x>oe.xmax&&(oe.xmax=M.x),M.y<oe.ymin&&(oe.ymin=M.y),M.y>oe.ymax&&(oe.ymax=M.y),M.z<oe.zmin&&(oe.zmin=M.z),M.z>oe.zmax&&(oe.zmax=M.z)}}if(t.readyToEngage=!0,t.terrainVertices=l,t.terrainVerticesHigh=h,t.terrainVerticesLow=c,t.tempVertices=l,t.tempVerticesHigh=h,t.tempVerticesLow=c,t.noDataVertices=d,t.setBoundingVolume(oe.xmin,oe.ymin,oe.zmin,oe.xmax,oe.ymax,oe.zmax),t.tileZoom>t.planet.terrain.maxZoom&&i.segment.tileZoom>=t.planet.terrain.maxZoom&&(t._plainRadius=i.segment._plainRadius/s,t.terrainReady=!0,t.terrainIsLoading=!1,t.terrainVertices=l,t.terrainVerticesHigh=h,t.terrainVerticesLow=c,t.passReady=!0,this.appliedTerrainNodeId=this.nodeId,this.equalizedSideWithNodeId[0]=this.equalizedSideWithNodeId[1]=this.equalizedSideWithNodeId[2]=this.equalizedSideWithNodeId[3]=this.appliedTerrainNodeId,i.segment.terrainExists)){t.normalMapVertices=l,t.fileGridSize=Math.sqrt(l.length/3)-1;let f=Math.sqrt(o.normalMapNormals.length/3)-1,p=f/s;t.normalMapNormals=f>1?Nr(o.normalMapNormals,f,p*n,p*r,p):o.normalMapNormals}}}destroy(){this.prevState=this.state=0,this.segment.destroySegment();let e=this.neighbors;for(let t=0,i=e.length;t<i;t++){let s=e[t];if(s)for(let r=0;r<s.length;r++){let n=s[r];n&&n.neighbors&&n.clearNeighbors()}}this.neighbors=null,this.parentNode=null,this.sideSizeLog2=null,this.segment=null}clearTree(){const e=this.getState();if(e===0||e===1)this.destroyBranches();else for(let t=0;t<this.nodes.length;t++)this.nodes[t]&&this.nodes[t].clearTree()}clearBranches(){for(let e=0;e<this.nodes.length;e++)this.nodes[e].clearBranches(),this.nodes[e].segment.deleteMaterials()}destroyBranches(){if(this.ready){let e,t=[];for(e=0;e<this.nodes.length;e++)t[e]=this.nodes[e];for(this.ready=!1,this.nodes=[],e=0;e<t.length;e++)t[e].destroyBranches(),t[e].destroy(),t[e]=null;t.length=0,t=null}}traverseTree(e){if(e(this),this.ready)for(let t=0;t<this.nodes.length;t++)this.nodes[t].traverseTree(e)}getOffsetOppositeNeighbourSide(e,t){let i=this,s=e.segment.tileZoom,r=0;for(;i.segment.tileZoom>s;)r+=pl[i.partId][t]/(1<<i.segment.tileZoom-s),i=i.parentNode;return r}}class lr{constructor(e=2048){this._size=e,this._array=new Array(this._size),this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}reset(){this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}clear(){this._array.length=0,this._array=new Array(this._size),this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}push(e){this.length++,this._array[this._popIndex++]=e}pop(){if(this.length){this.length--;let e=this._array[--this._popIndex];return this._array[this._popIndex]=null,this._array[this._popIndex-1]||(this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex),e}}unshift(e){this.length++,this._array[--this._shiftIndex]=e}shift(){if(this.length){this.length--;let e=this._array[this._shiftIndex];return this._array[this._shiftIndex++]=null,this._array[this._shiftIndex]||(this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex),e}}forEach(e){for(let t=this._shiftIndex;t<this._popIndex;t++)e(this._array[t])}}class sa{constructor(e,t){this._layer=e,this._nodeCapacity=t,this._secondPASS=[],this._counter=0,this._deferredEntitiesPendingQueue=new lr,this._renderingNodes={}}insertEntity(e,t=!1){}setPickingEnabled(e){}dispose(){}insertEntities(e){}collectVisibleEntityCollections(e){}_queueDeferredNode(e){this._layer.getVisibility()&&(e._inTheQueue=!0,this._counter>=1?this._deferredEntitiesPendingQueue.push(e):this._execDeferredNode(e))}_execDeferredNode(e){this._counter++,requestAnimationFrame(()=>{if(e.applyCollection(),this._counter--,this._deferredEntitiesPendingQueue.length&&this._counter<1)for(;this._deferredEntitiesPendingQueue.length;){let t=this._deferredEntitiesPendingQueue.pop();if(t._inTheQueue=!1,t.isVisible())return void this._execDeferredNode(t)}})}}class Pc{constructor(e,t="",i=rr){this.name=t,this.projection=i,this._planet=e,this._quadTreeList=[],this._visibleNodes={}}createEntitiCollectionsTreeStrategy(e,t){return new sa(e,t)}destroyBranches(){for(let e=0,t=this._quadTreeList.length;e<t;e++)this._quadTreeList[e].destroyBranches()}clearLayerMaterial(e){let t=e.__id;for(let i=0,s=this._quadTreeList.length;i<s;i++)this._quadTreeList[i].traverseTree(function(r){let n=r.segment.materials;n[t]&&(n[t].clear(),n[t]=null)})}get planet(){return this._planet}init(){}preRender(){for(let e=0;e<this._quadTreeList.length;e++){let t=this._quadTreeList[e];t.createChildNodes(),t.segment.createPlainSegment();for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment.createPlainSegment()}}preLoad(){for(let e=0;e<this._quadTreeList.length;e++){let t=this._quadTreeList[e];t.segment.passReady=!0,t.renderNode(1),this._planet.normalMapCreator.drawSingle(t.segment);for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment.passReady=!0,t.nodes[i].renderNode(1),this._planet._normalMapCreator.drawSingle(t.nodes[i].segment)}}_clearVisibleNodes(){this._visibleNodes={}}collectRenderNodes(){this._clearVisibleNodes();for(let e=0;e<this._quadTreeList.length;e++)this._quadTreeList[e].renderTree(this._planet.camera,0,null)}clear(){for(let e=0;e<this._quadTreeList.length;e++)this._quadTreeList[e].clearTree()}get quadTreeList(){return this._quadTreeList}getTileXY(e,t){let i=t,s=-1,r=-1,n=1<<i;return s=We(e.lon,360/n,-180),r=We(e.lat,180/n,90),[s,r,i,0]}getLonLatTileOffset(e,t,i,s,r){let n=e,o=new G;o=nr(t,i,s,G.createFromArray([-180,-90,180,90]));let l=o.getWidth()/(r-1),h=o.getHeight()/(r-1);return[r-Math.ceil((n.lat-o.southWest.lat)/h)-1,Math.floor((n.lon-o.southWest.lon)/l)]}collectVisibleNode(e){this._visibleNodes[e.nodeId]=e}}const ra=new sr({code:"epsg:4326",units:ta}),na=(90-ue)/Math.pow(2,7);class oa extends ia{constructor(e,t,i,s){super(e,t,i,s),this._projection=ra,this._extentLonLat=this._extent,this._extentMerc=new G(s.southWest.forwardMercatorEPS01(),s.northEast.forwardMercatorEPS01()),this._isNorth=this._extent.northEast.lat>0,this.isPole=!0}_setExtentLonLat(){this._extentLonLat=this._extent}projectNative(e){return e}getInsideLonLat(e){return e._lonLat}_getMaxZoom(){let e=0;if(this._isNorth){let t=Math.floor((90-this._extent.northEast.lat)/na);e=Math.floor(t/16)+7}else{let t=Math.floor((Ne-this._extent.northEast.lat)/na);e=12-Math.floor(t/16)}return e}checkZoom(){return super.checkZoom()&&this.tileZoom<=this._getMaxZoom()}_assignTileIndexes(){this._assignTileXIndexes(this._extent),this._assignTileYIndexes(this._extent),this.tileIndex=qe.getTileIndex(this.tileX,this.tileY,this.tileZoom,this._tileGroup)}_assignTileXIndexes(e){this.tileX=We(e.getCenter().lon,e.getWidth(),-180);let t=1<<this.tileZoom;this.tileXE=(this.tileX+1)%t,this.tileXW=(t+this.tileX-1)%t}_assignTileYIndexes(e){const t=e.getCenter().lat;t>0?(this._tileGroup=20,this.tileY=We(t,e.getHeight(),90)):(this._tileGroup=Ct,this.tileY=We(t,e.getHeight(),Ne)),this.tileYN=this.tileY-1,this.tileYS=this.tileY+1}_projToDeg(e,t){return new A(e,t)}_assignGlobalTextureCoordinates(){const e=this._extent;this._globalTextureCoordinates[0]=(e.southWest.lon+180)/360,this._globalTextureCoordinates[1]=(90-e.northEast.lat)/180,this._globalTextureCoordinates[2]=(e.northEast.lon+180)/360,this._globalTextureCoordinates[3]=(90-e.southWest.lat)/180}_getLayerExtentOffset(e){const t=e._extent,i=this._extent,s=t.northEast.lon-t.southWest.lon,r=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/s,(t.northEast.lat-i.northEast.lat)/r,(i.northEast.lon-i.southWest.lon)/s,(i.northEast.lat-i.southWest.lat)/r]}layerOverlap(e){return this._extent.overlaps(e._extent)}getDefaultTexture(){return this._isNorth?this.planet.solidTextureOne:this.planet.solidTextureTwo}getExtentLonLat(){return this._extent}}class Lt{constructor(e,t,i,s,r,n){this.strategy=e,this.layer=e._layer,this.parentNode=i,this.childNodes=[],this.partId=t,this.nodeId=t+(i?4*i.nodeId+1:0),this.state=null,this.extent=s,this.count=0,this.deferredEntities=[],this.entityCollection=null,this.zoom=n,this._inTheQueue=!1,this.bsphere=new Ve,r&&this._setExtentBounds()}insertEntity(e,t=!1){this.buildTree([e],t)}_addEntitiesToCollection(e,t=!1){if(e.length){const i=this.layer,s=i._planet;let r=this.entityCollection;r||(r=new ut({pickingEnabled:i._pickingEnabled,labelMaxLetters:i.labelMaxLetters}),r._layer=this.layer,r.addTo(s,!0),r._quadNode=this,i._bindEventsDefault(r),this.entityCollection=r),t||!i.async?this.entityCollection.addEntities(e):this.deferredEntities.push.apply(this.deferredEntities,e)}}_setExtentBounds(){this.nodeId?this.bsphere.setFromExtent(this.layer._planet.ellipsoid,this.extent.inverseMercator()):(this.bsphere.radius=this.layer._planet.ellipsoid.equatorialSize,this.bsphere.center=new v)}__setLonLat__(e){return e._lonLat.isZero()&&!e._cartesian.isZero()&&(e._lonLat=this.layer._planet.ellipsoid.cartesianToLonLat(e._cartesian)),Math.abs(e._lonLat.lat)<ue?e._lonLatMerc=e._lonLat.forwardMercator():e._lonLatMerc=new A,e._lonLatMerc}buildTree(e,t=!1){if(this.count+=e.length,e.length>this.layer._nodeCapacity){const i=this.childNodes;i.length||this.createChildNodes();let s=[],r=[],n=[],o=[],l=e.length;for(;l--;){const h=e[l];i[0].isInside(h)?(h._nodePtr=i[0],s.push(h)):i[1].isInside(h)?(h._nodePtr=i[1],r.push(h)):i[2].isInside(h)?(h._nodePtr=i[2],n.push(h)):i[3].isInside(h)&&(h._nodePtr=i[3],o.push(h))}s.length&&i[0].buildTree(s,t),r.length&&i[1].buildTree(r,t),n.length&&i[2].buildTree(n,t),o.length&&i[3].buildTree(o,t)}else this._addEntitiesToCollection(e,t)}isInside(e){return!!e._lonLatMerc&&this.extent.isInside(e._lonLatMerc)}createChildNodes(){const e=this.strategy,t=this.extent,i=.5*t.getWidth(),s=.5*t.getHeight(),r=t.northEast,n=t.southWest,o=new A(n.lon+i,n.lat+s),l=this.childNodes,h=this.layer._planet,c=this.zoom+1;l[0]=new Lt(e,0,this,new G(new A(n.lon,n.lat+s),new A(n.lon+i,r.lat)),h,c),l[1]=new Lt(e,1,this,new G(o,new A(r.lon,r.lat)),h,c),l[2]=new Lt(e,2,this,new G(new A(n.lon,n.lat),o),h,c),l[3]=new Lt(e,3,this,new G(new A(n.lon+i,n.lat),new A(r.lon,n.lat+s)),h,c)}collectRenderCollectionsPASS1(e,t){const i=e[this.nodeId];if(i){const s=this.childNodes;this.entityCollection?this.renderCollection(t,e):s.length&&(i.state===1?this.strategy._secondPASS.push(this):(s[0].collectRenderCollectionsPASS1(e,t),s[1].collectRenderCollectionsPASS1(e,t),s[2].collectRenderCollectionsPASS1(e,t),s[3].collectRenderCollectionsPASS1(e,t)))}}collectRenderCollectionsPASS2(e,t,i){const s=this.layer._planet.camera,r=s.eye.distance(this.bsphere.center)-this.bsphere.radius<3570*Math.sqrt(s._lonLat.height)||s._lonLat.height>1e4;if(this.count>0&&r&&s.containsSphere(this.bsphere)){const n=this.childNodes;this.entityCollection?this.renderCollection(t,e,i):n.length&&(n[0].collectRenderCollectionsPASS2(e,t,i),n[1].collectRenderCollectionsPASS2(e,t,i),n[2].collectRenderCollectionsPASS2(e,t,i),n[3].collectRenderCollectionsPASS2(e,t,i))}}applyCollection(){this.entityCollection.addEntities(this.deferredEntities),this.deferredEntities.length=0,this.deferredEntities=[],this._inTheQueue=!1}traverseTree(e){const t=this.childNodes;this.entityCollection?e(this):t.length&&(t[0].traverseTree(e),t[1].traverseTree(e),t[2].traverseTree(e),t[3].traverseTree(e))}renderCollection(e,t,i){const s=this.strategy;s._renderingNodes[this.nodeId]=!0,this.deferredEntities.length&&!this._inTheQueue&&(this.layer.async?s._queueDeferredNode(this):this.applyCollection());let r=this.entityCollection,n=this.layer;if(r._fadingOpacity=n._fadingOpacity,r.scaleByDistance=n.scaleByDistance,r.pickingScale=n.pickingScale,r.polygonOffsetUnits=n.polygonOffsetUnits,e.push(r),n.clampToGround||n.relativeToGround){const o=r._entities;let l=o.length;if(t[this.nodeId]&&t[this.nodeId].state===1)for(;l--;){let h=o[l];this.alignEntityToTheGround(h,t[this.nodeId].segment)}else if(i)for(;l--;){let h=o[l];this.alignEntityToTheGround(h,t[i].segment)}else{const h=n._planet._renderedNodes;for(;l--;){let c=o[l],d=h.length;for(;d--;)if(h[d].segment.isEntityInside(c)){this.alignEntityToTheGround(c,h[d].segment);break}}}}}alignEntityToTheGround(e,t){let i=new v;t.getEntityTerrainPoint(e,i);let s=Number(this.layer.relativeToGround)&&e._altitude||0;if(s){let r=this.layer._planet.ellipsoid.getSurfaceNormal3v(i);e._setCartesian3vSilent(i.addA(r.scale(s)))}else e._setCartesian3vSilent(i)}isVisible(){return!!this.strategy._renderingNodes[this.nodeId]}}class Pt extends Lt{constructor(e,t,i,s,r,n){super(e,t,i,s,r,n),this.strategy=e,this.isNorth=!1}createChildNodes(){const e=this.strategy,t=this.extent,i=.5*t.getWidth(),s=.5*t.getHeight(),r=t.northEast,n=t.southWest,o=new A(n.lon+i,n.lat+s),l=this.childNodes,h=this.layer._planet,c=this.zoom+1;l[0]=new Pt(e,0,this,new G(new A(n.lon,n.lat+s),new A(n.lon+i,r.lat)),h,c),l[1]=new Pt(e,1,this,new G(o,new A(r.lon,r.lat)),h,c),l[2]=new Pt(e,2,this,new G(new A(n.lon,n.lat),o),h,c),l[3]=new Pt(e,3,this,new G(new A(n.lon+i,n.lat),new A(r.lon,n.lat+s)),h,c)}_setExtentBounds(){this.extent.northEast.lat>0&&(this.isNorth=!0),this.bsphere.setFromExtent(this.layer._planet.ellipsoid,this.extent)}__setLonLat__(e){return e._lonLat.isZero()&&(e._lonLat=this.layer._planet.ellipsoid.cartesianToLonLat(e._cartesian)),e._lonLat}isVisible(){return!(!this.isNorth||!this.strategy._renderingNodesNorth[this.nodeId])||!!this.strategy._renderingNodesSouth[this.nodeId]}isInside(e){return this.extent.isInside(e._lonLat)}renderCollection(e,t,i){this.isNorth?this.strategy._renderingNodesNorth[this.nodeId]=!0:this.strategy._renderingNodesSouth[this.nodeId]=!0,this.deferredEntities.length&&!this._inTheQueue&&(this.layer.async?this.strategy._queueDeferredNode(this):this.applyCollection());const s=this.entityCollection;s._fadingOpacity=this.layer._fadingOpacity,s.scaleByDistance=this.layer.scaleByDistance,s.pickingScale=this.layer.pickingScale,s.isEmpty()||e.push(s)}}class Sc extends sa{constructor(e,t){super(e,t);let i=e._planet;this._entityCollectionsTree=new Lt(this,0,null,G.createFromArray([-2003750834e-2,-2003750834e-2,2003750834e-2,2003750834e-2]),i,0),this._entityCollectionsTreeNorth=new Pt(this,0,null,G.createFromArray([-180,ue,180,90]),i,0),this._entityCollectionsTreeSouth=new Pt(this,0,null,G.createFromArray([-180,-90,180,Ne]),i,0),this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={}}insertEntity(e,t=!1){e._lonLat.lat>ue?(this._entityCollectionsTreeNorth.__setLonLat__(e),this._entityCollectionsTreeNorth.insertEntity(e,t)):e._lonLat.lat<Ne?(this._entityCollectionsTreeSouth.__setLonLat__(e),this._entityCollectionsTreeSouth.insertEntity(e,t)):(this._entityCollectionsTree.__setLonLat__(e),this._entityCollectionsTree.insertEntity(e,t))}setPickingEnabled(e){this._entityCollectionsTree&&this._entityCollectionsTree.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)}),this._entityCollectionsTreeNorth&&this._entityCollectionsTreeNorth.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)}),this._entityCollectionsTreeSouth&&this._entityCollectionsTreeSouth.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)})}dispose(){this._entityCollectionsTree=null,this._entityCollectionsTreeNorth=null,this._entityCollectionsTreeSouth=null,this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={}}insertEntities(e){let t=[],i=[],s=[];for(let r=0,n=e.length;r<n;r++){let o=e[r];o._lonLat.lat>ue?(t.push(o),this._entityCollectionsTreeNorth.__setLonLat__(o)):o._lonLat.lat<Ne?(i.push(o),this._entityCollectionsTreeSouth.__setLonLat__(o)):(s.push(o),this._entityCollectionsTree.__setLonLat__(o))}this._entityCollectionsTree.buildTree(s),this._entityCollectionsTreeNorth.buildTree(t),this._entityCollectionsTreeSouth.buildTree(i)}collectVisibleEntityCollections(e){this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={};let t=this._layer._planet.quadTreeStrategy;this._secondPASS=[],this._entityCollectionsTree.collectRenderCollectionsPASS1(t._visibleNodes,e);let i=this._secondPASS.length;for(;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodes,e,this._secondPASS[i].nodeId);for(this._secondPASS=[],this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(t._visibleNodesNorth,e),i=this._secondPASS.length;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodesNorth,e,this._secondPASS[i].nodeId);for(this._secondPASS=[],this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(t._visibleNodesSouth,e),i=this._secondPASS.length;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodesSouth,e,this._secondPASS[i].nodeId)}}class Mc extends Pc{constructor(e){super(e,"Earth"),this._visibleNodesNorth={},this._visibleNodesSouth={}}collectVisibleNode(e){let t=e.segment._tileGroup;t===20?this._visibleNodesNorth[e.nodeId]=e:t===Ct?this._visibleNodesSouth[e.nodeId]=e:this._visibleNodes[e.nodeId]=e}_clearVisibleNodes(){super._clearVisibleNodes(),this._visibleNodesNorth={},this._visibleNodesSouth={}}createEntitiCollectionsTreeStrategy(e,t){return new Sc(e,t)}init(){this._quadTreeList=[new ft(ia,this.planet,0,null,0,G.createFromArray([-2003750834e-2,-2003750834e-2,2003750834e-2,2003750834e-2])),new ft(oa,this.planet,0,null,0,G.createFromArray([-180,ue,180,90])),new ft(oa,this.planet,0,null,0,G.createFromArray([-180,-90,180,Ne]))]}getTileXY(e,t){let i=function(l,h=ue){return l>h?20:l<-h?Ct:0}(e.lat,ue),s=t,r=-1,n=-1,o=1<<s;if(i===20)r=We(e.lon,360/o,-180),n=We(e.lat,(90-ue)/o,90);else if(i===Ct)r=We(e.lon,360/o,-180),n=We(e.lat,(90-ue)/o,Ne);else{let l=Ii(e);r=We(l.lon,Bi/o,-2003750834e-2),n=We(l.lat,Bi/o,Ee)}return[r,n,s,i]}getLonLatTileOffset(e,t,i,s,r){let n=e,o=new G;e.lat>ue?o=nr(t,i,s,G.createFromArray([-180,ue,180,90])):e.lat<Ne?o=nr(t,i,s,G.createFromArray([-180,-90,180,Ne])):(n=Ii(e),o=kt(t,i,s));let l=o.getWidth()/(r-1),h=o.getHeight()/(r-1);return[r-Math.ceil((n.lat-o.southWest.lat)/h)-1,Math.floor((n.lon-o.southWest.lon)/l)]}}class aa{constructor(e={}){this.model=e.model||null,this.src=e.src||null,this._cached_ix=0,this._cached_iy=0,this._v00=0,this._v01=0,this._v10=0,this._v11=0,this._t=0}static loadModel(e){return e?fetch(e,{}).then(t=>{if(!t.ok)throw Error("Geoid model file: HTTP error "+t.status);return t.arrayBuffer()}).then(t=>{if(t)return new Uint8Array(t);throw Error("Geoid model file: no data from "+e)}).then(function(t){if(t[0]!==80||t[1]!==53||(t[2]!==13||t[3]!==10)&&t[2]!==10)throw new Error("Geoid model file: no PGM header");var i,s,r=t[2]===13?4:3,n=null,o=null;function l(){let d=r;for(var u=r;;u++){if(u>=t.length)throw new Error("Geoid model file: missing newline in header");if(t[u]===10){r=u+1;break}}return u>d&&t[u-1]===13&&u--,String.fromCharCode.apply(null,t.slice(d,u))}for(;(s=l())[0]==="#";)if(i=s.match(/^# Offset (.*)$/)){if(n=parseInt(i[1],10),!isFinite(n))throw new Error("Geoid model file: bad offset "+i[1])}else if((i=s.match(/^# Scale (.*)$/))&&(o=parseFloat(i[1]),!isFinite(o)))throw new Error("Geoid model file: bad scale "+i[1]);let h=0,c=0;if((i=s.match(/^\s*(\d+)\s+(\d+)\s*$/))&&(h=parseInt(i[1],10),c=parseInt(i[2],10)),!(i&&h>=0&&c>=0))throw new Error("Geoid model file: bad PGM width&height line");if(parseInt(l())!=65535)throw new Error("Geoid model file: PGM file must have 65535 gray levels");if(n===null)throw new Error("Geoid model file: PGM file does not contain offset");if(o===null)throw new Error("Geoid model file: PGM file does not contain scale");if(h<2||c<2)throw new Error("Geoid model file: Raster size too small");if(t.length-r!=h*c*2)throw new Error("Geoid model file: File has the wrong length");return{scale:o,offset:n,width:h,height:c,rlonres:h/360,rlatres:(c-1)/180,i:r,rawfile:t}}):new Promise(t=>{t(null)})}setModel(e){this.model=e}_rawval(e,t){let i=this.model;t<0?(t=-t,e+=i.width/2):t>=i.height&&(t=2*(i.height-1)-t,e+=i.width/2),e<0?e+=i.width:e>=i.width&&(e-=i.width);let s=2*(t*i.width+e)+i.i;return i.rawfile[s]<<8|i.rawfile[s+1]}getHeightLonLat(e){return this.getHeight(e.lon,e.lat)}getHeight(e,t){if(!this.model)return 0;let i=this.model;e<0&&(e+=360);let s=(90-t)*i.rlatres,r=e*i.rlonres,n=Math.floor(s),o=Math.floor(r);r-=o,s-=n,n===i.height-1&&n--,this._cached_ix===o&&this._cached_iy===n||(this._cached_ix=o,this._cached_iy=n,this._v00=this._rawval(o,n),this._v01=this._rawval(o+1,n),this._v10=this._rawval(o,n+1),this._v11=this._rawval(o+1,n+1));let l=(1-s)*((1-r)*this._v00+r*this._v01)+s*((1-r)*this._v10+r*this._v11);return i.offset+i.scale*l}}class Rc{constructor(e,t=5){this.MAX_FRAMES=t,this._gridSize=64,this._planet=e,this._framebuffer=null,this._framebufferMercProj=null,this._texCoordsBuffer=null,this._indexBuffer=null,this._currentFrame=0,this._queue=[],this._animate=[],this._quadTexCoordsBuffer=null,this._quadVertexBuffer=null}init(){this._initShaders(),this._initBuffers()}createGridBuffer(e,t=!1){let i=this._gridSize,s=new A((e[3].lon-e[0].lon)/i,(e[3].lat-e[0].lat)/i),r=new A((e[2].lon-e[1].lon)/i,(e[2].lat-e[1].lat)/i),n=new A((e[1].lon-e[0].lon)/i,(e[1].lat-e[0].lat)/i),o=new A((e[2].lon-e[3].lon)/i,(e[2].lat-e[3].lat)/i);const l=(i+1)*(i+1)*2,h=l/2;let c=new Float32Array(l),d=new Float32Array(l),u=new Array(h),g=0,f=0,p=0,_=new Float32Array(2);for(let m=0;m<=i;m++){let y=new A(e[0].lon+m*s.lon,e[0].lat+m*s.lat),x=new A(e[1].lon+m*r.lon,e[1].lat+m*r.lat);for(let w=0;w<=i;w++){let b=Fr(y,x,new A(e[0].lon+w*n.lon,e[0].lat+w*n.lat),new A(e[3].lon+w*o.lon,e[3].lat+w*o.lat));lt(b.lon,_),c[g++]=_[0],d[f++]=_[1],lt(b.lat,_),c[g++]=_[0],d[f++]=_[1],u[p++]=b}}if(t)for(let m=0;m<h;m++){let y=u[m].forwardMercator();lt(y.lon,_),c[2*m]=_[0],d[2*m]=_[1],lt(y.lat,_),c[2*m+1]=_[0],d[2*m+1]=_[1]}return[this._planet.renderer.handler.createArrayBuffer(c,2,h),this._planet.renderer.handler.createArrayBuffer(d,2,h)]}frame(){let e=this.MAX_FRAMES;for(;e--&&this._queue.length;){const t=this._queue.shift();t._isRendering=!1,t.rendering(),t.events.dispatch(t.events.loadend)}for(e=this._animate.length;e--;)this._animate[e].rendering()}add(e){e._isRendering||(e._isRendering=!0,e._animate?this._animate.push(e):this._queue.push(e))}remove(e){if(e._isRendering){let t;e._creationProceeding=!1,e._isRendering=!1,t=e._animate?this._animate:this._queue;for(let i=0;i<t.length;i++)if(t[i].isEqual(e))return void t.splice(i,1)}}_initBuffers(){let e=this._planet.renderer.handler;this._framebuffer=new Me(e,{width:2,height:2,useDepth:!1}),this._framebuffer.init(),this._framebufferMercProj=new Me(e,{width:2,height:2,useDepth:!1}),this._framebufferMercProj.init();let t=Math.log2(this._gridSize);this._texCoordsBuffer=this._planet._textureCoordsBufferCache[t],this._indexBuffer=this._planet._indexesCache[t][t][t][t][t].buffer,this._quadTexCoordsBuffer=e.createArrayBuffer(new Float32Array([0,1,1,1,0,0,1,0]),2,4),this._quadVertexBuffer=e.createArrayBuffer(new Float32Array([-1,1,1,1,-1,-1,1,-1]),2,4)}_initShaders(){this._planet.renderer.handler.addProgram(new X("geoImageTransform",{uniforms:{sourceTexture:"sampler2d",extentParamsHigh:"vec4",extentParamsLow:"vec4",isFullExtent:"bool"},attributes:{cornersHigh:"vec2",cornersLow:"vec2",texCoords:"vec2"},vertexShader:`attribute vec2 cornersHigh;
660
+ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec3 lightPosition;uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform float camHeight;varying vec4 vTextureCoord;varying vec3 v_vertex;varying vec3 cameraPosition;varying vec2 vGlobalTextureCoord;varying float v_height;vec3 sunPos;void main(void){sunPos=lightPosition;vec3 texNormal=texture2D(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);float overGround=1.0-step(0.1,v_height);float shininess=texture2D(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture2D(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+diffuse*diffuseLightWeighting+night,1.0);gl_FragColor=texture2D(defaultTexture,vTextureCoord.xy);if(samplerCount==0){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}vec4 src;blend(gl_FragColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);return;}blend(gl_FragColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);gl_FragColor=gl_FragColor*lightWeighting+vec4(spec,0.0);}`})}function to(a){return new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",transmittanceTexture:"sampler2D",scatteringTexture:"sampler2D",camHeight:"float",nightTextureCoefficient:"float",maxMinOpacity:"vec2",transitionOpacity:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:`#version 300 es
661
+ precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec4 uGlobalTextureCoord;uniform vec3 uNormalMapBias;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;out vec4 vTextureCoord;out vec3 v_vertex;out vec3 cameraPosition;out vec2 vGlobalTextureCoord;out float v_height;void main(void){vec3 aVertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 nh=height*normalize(aVertexPosition);vTextureCoord.xy=aTextureCoord;vGlobalTextureCoord=uGlobalTextureCoord.xy+(uGlobalTextureCoord.zw-uGlobalTextureCoord.xy)*aTextureCoord;vTextureCoord.zw=uNormalMapBias.z*(aTextureCoord+uNormalMapBias.xy);cameraPosition=eyePositionHigh+eyePositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);v_height=height;v_vertex=aVertexPosition+nh;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}`,fragmentShader:Zt("#version 300 es\nprecision highp float;\n#ifdef WEBGL2\n#define TEXTURE_FUNC texture\n#else\n#define TEXTURE_FUNC texture2D\n#endif\n#define SLICE_SIZE 5\n#define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;\n#define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);\nconst vec3 nightStep=10.0*vec3(0.58,0.48,0.25);float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform vec3 lightPosition;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D transmittanceTexture;uniform sampler2D scatteringTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform vec2 maxMinOpacity;uniform float camHeight;uniform float transitionOpacity;in vec4 vTextureCoord;in vec3 v_vertex;in vec3 cameraPosition;in vec2 vGlobalTextureCoord;in float v_height;vec3 sunPos;layout(location=0)out vec4 diffuseColor;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture(transmittanceTexture,vec2(u,v)).xyz;}vec3 multipleScatteringContributionFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture(scatteringTexture,vec2(u,v)).xyz;}void getSunIlluminance(in vec3 point,in vec3 lightDir,out vec3 sunIlluminance){float mu_s=dot(normalize(point),lightDir);float height=length(point)-BOTTOM_RADIUS;sunIlluminance=SUN_INTENSITY*transmittanceFromTexture(height,mu_s);}void atmosGroundColor(out vec4 fragColor,in vec3 normal){vec3 cameraPosition=cameraPosition;if(length(cameraPosition*SPHERE_TO_ELLIPSOID_SCALE)<BOTTOM_RADIUS+1.0){cameraPosition=normalize(cameraPosition*SPHERE_TO_ELLIPSOID_SCALE)*(BOTTOM_RADIUS+1.0)/SPHERE_TO_ELLIPSOID_SCALE;}vec3 rayDirection=normalize(v_vertex-cameraPosition);vec3 lightDir=normalize(sunPos);rayDirection=normalize(rayDirection*SPHERE_TO_ELLIPSOID_SCALE);vec3 camPos=cameraPosition*SPHERE_TO_ELLIPSOID_SCALE;lightDir=normalize(lightDir*SPHERE_TO_ELLIPSOID_SCALE);vec3 light=vec3(0.0);vec3 transmittanceFromCameraToSpace=vec3(1.0);float offset=0.0;float distanceToSpace=0.0;intersectSphere(camPos,rayDirection,TOP_RADIUS,offset,distanceToSpace);vec3 rayOrigin=camPos;if(offset>0.0){rayOrigin+=rayDirection*offset;}float height=length(rayOrigin)-BOTTOM_RADIUS;float rayAngle=dot(rayOrigin,rayDirection)/length(rayOrigin);bool cameraBelow=rayAngle<0.0;transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float phaseAngle=dot(lightDir,rayDirection);float rayleighPhase=rayleighPhase(phaseAngle);float miePhase=miePhase(phaseAngle);float distanceToGround=0.0;bool hitGround=intersectSphere(camPos,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(length(v_vertex*SPHERE_TO_ELLIPSOID_SCALE)>BOTTOM_RADIUS){distanceToGround=distance(camPos,v_vertex*SPHERE_TO_ELLIPSOID_SCALE);}float segmentLength=(distanceToGround-max(offset,0.0))/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDir);vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x*rayleighPhase+mieScatteringCoefficient*opticalDensity.y*miePhase);scatteredLight+=multipleScatteringContributionFromTexture(height,lightAngle)*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y);light+=transmittanceCamera*scatteredLight*segmentLength;t+=segmentLength;}light*=SUN_INTENSITY;vec3 hitPoint=camPos+rayDirection*distanceToGround;vec3 up=normalize(hitPoint);float diffuseAngle=max(dot(up,lightDir),0.0);float lightAngle=dot(normal,lightDir);vec3 tA=transmittanceCamera*GROUND_ALBEDO*SUN_INTENSITY;vec3 scatteringLight=multipleScatteringContributionFromTexture(height,lightAngle);vec3 diffuseTransmittanceLight=transmittanceLight*diffuseAngle;light+=tA*(scatteringLight+diffuseTransmittanceLight);fragColor=vec4(pow(light*8.0,vec3(1.0/2.2)),1.0);}void getAtmosFadingOpacity(out float opacity){float c=length(cameraPosition);float maxDist=sqrt(c*c-BOTTOM_RADIUS*BOTTOM_RADIUS);float minDist=c-BOTTOM_RADIUS;float vertDist=distance(cameraPosition,v_vertex);opacity=clamp(maxMinOpacity.y+(maxMinOpacity.x-maxMinOpacity.y)*getLerpValue(minDist,maxDist,vertDist),0.0,1.0);}void main(void){sunPos=lightPosition;vec3 texNormal=texture(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);vec4 atmosColor;atmosGroundColor(atmosColor,normal);vec3 sunIlluminance;getSunIlluminance(v_vertex*SPHERE_TO_ELLIPSOID_SCALE,lightDir*SPHERE_TO_ELLIPSOID_SCALE,sunIlluminance);float overGround=1.0-step(0.1,v_height);float shininess=texture(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=sunIlluminance*specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+sunIlluminance*diffuse*diffuseLightWeighting+night,1.0);float fadingOpacity;getAtmosFadingOpacity(fadingOpacity);getSunIlluminance(cameraPosition,viewDir*SPHERE_TO_ELLIPSOID_SCALE,sunIlluminance);spec*=sunIlluminance;diffuseColor=texture(defaultTexture,vTextureCoord.xy);if(samplerCount==0){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}vec4 src;blend(diffuseColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);diffuseColor=mix(diffuseColor*lightWeighting,atmosColor*diffuseColor.a,fadingOpacity)+vec4(spec,0.0);diffuseColor*=transitionOpacity;}",a)})}var vc="attribute vec2 corners;void main(void){gl_Position=vec4(corners,0.0,1.0);}",yc="precision lowp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform mat4 viewMatrix;uniform vec3 sunPos;uniform vec3 camPos;uniform vec2 iResolution;uniform float fov;uniform float opacity;uniform sampler2D transmittanceTexture;uniform sampler2D scatteringTexture;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(transmittanceTexture,vec2(u,v)).xyz;}vec3 multipleScatteringContributionFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(scatteringTexture,vec2(u,v)).xyz;}bool intersectEllipsoidToSphere(in vec3 ro,in vec3 rd,in vec3 ellRadii,in float sphereRadius,out float t1,out float t2){float offset=0.0,distanceToSpace=0.0;if(intersectEllipsoid(ro,rd,ellRadii,offset,distanceToSpace)){vec3 hitEll=ro+rd*offset;vec3 nEll=normalEllipsoid(hitEll,ellRadii);float t=0.0;bool intersectsSphere=intersectSphere(hitEll,nEll,sphereRadius,t);vec3 hitSphere=hitEll+nEll*t;t1=length(hitSphere-ro);hitEll=ro+rd*distanceToSpace;nEll=normalEllipsoid(hitEll,ellRadii);t=0.0;intersectsSphere=intersectSphere(hitEll,nEll,sphereRadius,t);hitSphere=hitEll+nEll*t;t2=length(hitSphere-ro);return true;}return false;}mat4 transpose(in mat4 m){vec4 i0=m[0];vec4 i1=m[1];vec4 i2=m[2];vec4 i3=m[3];mat4 outMatrix=mat4(vec4(i0.x,i1.x,i2.x,i3.x),vec4(i0.y,i1.y,i2.y,i3.y),vec4(i0.z,i1.z,i2.z,i3.z),vec4(i0.w,i1.w,i2.w,i3.w));return outMatrix;}void mainImage(out vec4 fragColor){vec3 cameraPosition=camPos;vec3 lightDirection=normalize(sunPos);vec2 uv=(2.0*gl_FragCoord.xy-iResolution.xy)/iResolution.y;float fieldOfView=fov;float z=1.0/tan(fieldOfView*0.5*PI/180.0);vec3 rayDirection=normalize(vec3(uv,-z));vec4 rd=transpose(viewMatrix)*vec4(rayDirection,1.0);rayDirection=rd.xyz;vec3 light=vec3(0.0);vec3 transmittanceFromCameraToSpace=vec3(1.0);float offset=0.0;float distanceToSpace=0.0;rayDirection=normalize(rayDirection*SPHERE_TO_ELLIPSOID_SCALE);cameraPosition*=SPHERE_TO_ELLIPSOID_SCALE;lightDirection=normalize(lightDirection*SPHERE_TO_ELLIPSOID_SCALE);if(length(cameraPosition)<BOTTOM_RADIUS+100.0){cameraPosition=normalize(cameraPosition)*(BOTTOM_RADIUS+100.0);}if(intersectSphere(cameraPosition,rayDirection,TOP_RADIUS,offset,distanceToSpace)){vec3 rayOrigin=cameraPosition;if(offset>0.0){rayOrigin=cameraPosition+rayDirection*offset;}float height=length(rayOrigin)-BOTTOM_RADIUS;float rayAngle=dot(rayOrigin,rayDirection)/length(rayOrigin);bool cameraBelow=rayAngle<0.0;transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float phaseAngle=dot(lightDirection,rayDirection);float rayleighPhase=rayleighPhase(phaseAngle);float miePhase=miePhase(phaseAngle);float distanceToGround=0.0;bool hitGround=intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS-100000.0,distanceToGround)&&hitGround){discard;}float segmentLength=((hitGround ? distanceToGround : distanceToSpace)-max(offset,0.0))/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDirection);vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x*rayleighPhase+mieScatteringCoefficient*opticalDensity.y*miePhase);scatteredLight+=multipleScatteringContributionFromTexture(height,lightAngle)*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y);light+=transmittanceCamera*scatteredLight*segmentLength;t+=segmentLength;}light*=SUN_INTENSITY;if(hitGround){vec3 hitPoint=cameraPosition+rayDirection*distanceToGround;vec3 up=hitPoint/length(hitPoint);float diffuseAngle=max(dot(up,lightDirection),0.0);float lightAngle=dot(up,lightDirection);light+=transmittanceCamera*GROUND_ALBEDO*multipleScatteringContributionFromTexture(height,lightAngle)*SUN_INTENSITY;light+=transmittanceCamera*transmittanceLight*GROUND_ALBEDO*diffuseAngle*SUN_INTENSITY;}}float distanceToGround=0.0;bool hitGround=intersectSphere(cameraPosition,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;if(!hitGround){vec3 sunLum=sunWithBloom(rayDirection,lightDirection)*vec3(1.0,1.0,0.8);sunLum=smoothstep(0.002,1.0,sunLum);light+=sunLum*SUN_INTENSITY*transmittanceFromCameraToSpace;}fragColor=vec4(pow(light*8.0,vec3(1.0/2.2)),clamp(opacity,0.0,1.0));}void main(void){mainImage(gl_FragColor);}";class xc extends ee{constructor(e={}){super({name:"Atmosphere",...e}),this._transmittanceBuffer=null,this._scatteringBuffer=null,this.opacity=1,this._parameters={ATMOS_HEIGHT:e.height||1e5,RAYLEIGH_SCALE:e.rayleighScale||.08,MIE_SCALE:e.mieScale||.012,GROUND_ALBEDO:e.groundAlbedo||.05,BOTTOM_RADIUS:e.bottomRadius||6356752314245179e-9,rayleighScatteringCoefficient_0:e.rayleighScatteringCoefficient_0||5.802,rayleighScatteringCoefficient_1:e.rayleighScatteringCoefficient_1||13.558,rayleighScatteringCoefficient_2:e.rayleighScatteringCoefficient_2||33.1,mieScatteringCoefficient:e.mieScatteringCoefficient||3.996,mieExtinctionCoefficient:e.mieExtinctionCoefficient||4.44,ozoneAbsorptionCoefficient_0:e.ozoneAbsorptionCoefficient_0||.65,ozoneAbsorptionCoefficient_1:e.ozoneAbsorptionCoefficient_1||1.881,ozoneAbsorptionCoefficient_2:e.ozoneAbsorptionCoefficient_2||.085,SUN_ANGULAR_RADIUS:e.sunAngularRadius||.004685,SUN_INTENSITY:e.sunIntensity||1,ozoneDensityHeight:e.ozoneDensityHeight||25e3,ozoneDensityWide:e.ozoneDensityWide||15e3}}setParameters(e){this._parameters=JSON.parse(JSON.stringify(e)),this.initLookupTexturesShaders(),this.drawLookupTextures(),this.removeLookupTexturesShaders(),this.initPlanetAtmosphereShader()}get parameters(){return JSON.parse(JSON.stringify(this._parameters))}initPlanetAtmosphereShader(){var e;(e=this.planet)==null||e.initAtmosphereShader(this._parameters)}oninit(){this.renderer&&(this._initLookupTextures(),this.initLookupTexturesShaders(),this.drawLookupTextures(),this.removeLookupTexturesShaders(),this.initBackgroundShader(),this.activate())}initLookupTexturesShaders(){var e,t;this.renderer&&(this.renderer.handler.addProgram((e=this._parameters,new X("transmittance",{uniforms:{iResolution:"vec2"},attributes:{a_position:"vec2"},vertexShader:"attribute vec2 a_position;void main(void){gl_Position=vec4(a_position,0.0,1.0);}",fragmentShader:Zt("precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform vec2 iResolution;void main(void){vec2 uv=gl_FragCoord.xy/iResolution.xy;float height=uv.y*ATMOS_HEIGHT;float angle=uv.x*2.0-1.0;gl_FragColor=vec4(transmittance(height,angle),1.0);}",e)}))),this.renderer.handler.addProgram((t=this._parameters,new X("scattering",{uniforms:{iResolution:"vec2",transmittanceTexture:"sampler2d"},attributes:{a_position:"vec2"},vertexShader:"attribute vec2 a_position;void main(void){gl_Position=vec4(a_position,0.0,1.0);}",fragmentShader:Zt("precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}\n#define PI 3.1415926538\n#define ATMOS_HEIGHT float(${ATMOS_HEIGHT})\n#define RAYLEIGH_SCALE float(${RAYLEIGH_SCALE})\n#define MIE_SCALE float(${MIE_SCALE})\n#define SAMPLE_COUNT 16\n#define SQRT_SAMPLE_COUNT 4\nconst float GROUND_ALBEDO=float(${GROUND_ALBEDO})/PI;const float BOTTOM_RADIUS=float(${BOTTOM_RADIUS});const float TOP_RADIUS=BOTTOM_RADIUS+ATMOS_HEIGHT;const float EQUATORIAL_RADIUS=6378137.0;const vec3 bottomRadii=vec3(EQUATORIAL_RADIUS,EQUATORIAL_RADIUS,BOTTOM_RADIUS);const vec3 topRadii=bottomRadii+ATMOS_HEIGHT;const vec3 SPHERE_TO_ELLIPSOID_SCALE=vec3(BOTTOM_RADIUS)/bottomRadii;const vec2 rayleighMieHeights=vec2(RAYLEIGH_SCALE,MIE_SCALE)*ATMOS_HEIGHT;const vec3 rayleighScatteringCoefficient=vec3(float(${rayleighScatteringCoefficient_0}),float(${rayleighScatteringCoefficient_1}),float(${rayleighScatteringCoefficient_2}))*1e-6;const float mieScatteringCoefficient=float(${mieScatteringCoefficient})*1e-6;const float mieExtinctionCoefficient=float(${mieExtinctionCoefficient})*1e-6;const vec3 ozoneAbsorptionCoefficient=vec3(float(${ozoneAbsorptionCoefficient_0}),float(${ozoneAbsorptionCoefficient_1}),float(${ozoneAbsorptionCoefficient_2}))*1e-6;const float SUN_ANGULAR_RADIUS=float(${SUN_ANGULAR_RADIUS});const float SUN_INTENSITY=float(${SUN_INTENSITY});const float ozoneDensityHeight=float(${ozoneDensityHeight});const float ozoneDensityWide=float(${ozoneDensityWide});vec3 sunWithBloom(vec3 rayDir,vec3 sunDir){float minSunCosTheta=cos(SUN_ANGULAR_RADIUS);float cosTheta=dot(rayDir,sunDir);if(cosTheta>=minSunCosTheta)return vec3(1.0);float offset=minSunCosTheta-cosTheta;float gaussianBloom=exp(-offset*15000.0)*0.7;float invBloom=1.0/(0.09+offset*200.0)*0.01;return vec3(gaussianBloom+invBloom);}float rayleighPhase(float angle){return 3.0/(16.0*PI)*(1.0+(angle*angle));}float miePhase(float angle){float g=0.8;return 3.0/(8.0*PI)*((1.0-g*g)*(1.0+angle*angle))/((2.0+g*g)*pow(1.0+g*g-2.0*g*angle,1.5));}vec3 opticalDepth(float height,float angle){vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 rayDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);float t1,t2;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,t1,t2);float segmentLength=t2/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 opticalDepth=vec3(0.0);for(int i=0;i<SAMPLE_COUNT;i++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;opticalDepth.xy+=exp(-height/rayleighMieHeights)*segmentLength;opticalDepth.z+=(1.0-min(abs(height-ozoneDensityHeight)/ozoneDensityWide,1.0))*segmentLength;t+=segmentLength;}return opticalDepth;}vec3 transmittance(float height,float angle){vec3 opticalDepth=opticalDepth(height,angle);return exp(-(rayleighScatteringCoefficient*opticalDepth.x+mieExtinctionCoefficient*opticalDepth.y+ozoneAbsorptionCoefficient*opticalDepth.z));}uniform sampler2D transmittanceTexture;uniform vec2 iResolution;vec3 transmittanceFromTexture(float height,float angle){float u=(angle+1.0)*0.5;float v=height/ATMOS_HEIGHT;return texture2D(transmittanceTexture,vec2(u,v)).xyz;}void main(void){vec2 uv=gl_FragCoord.xy/iResolution.xy;float height=uv.y*ATMOS_HEIGHT;float angle=uv.x*2.0-1.0;vec3 rayOrigin=vec3(0.0,BOTTOM_RADIUS+height,0.0);vec3 up=rayOrigin/length(rayOrigin);vec3 lightDirection=vec3(sqrt(1.0-angle*angle),angle,0.0);const float isotropicPhase=1.0/(4.0*PI);vec3 light=vec3(0.0);vec3 lightTransferFactor=vec3(0.0);for(int i=0;i<SQRT_SAMPLE_COUNT;i++){for(int j=0;j<SQRT_SAMPLE_COUNT;j++){float u=((0.5+float(i))/float(SQRT_SAMPLE_COUNT))*2.0-1.0;float v=(0.5+float(j))/float(SQRT_SAMPLE_COUNT);float r=sqrt(1.0-u*u);float theta=2.0*PI*v;vec3 rayDirection=vec3(cos(theta)*r,sin(theta)*r,u);float rayAngle=dot(up,rayDirection);bool cameraBelow=rayAngle<0.0;vec3 transmittanceFromCameraToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);float offset=0.0;float distanceToSpace=0.0;intersectSphere(rayOrigin,rayDirection,TOP_RADIUS,offset,distanceToSpace);float distanceToGround=0.0;bool hitGround=intersectSphere(rayOrigin,rayDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>0.0;float segmentLength=(hitGround ? distanceToGround : distanceToSpace)/float(SAMPLE_COUNT);float t=segmentLength*0.5;vec3 transmittanceCamera;vec3 transmittanceLight;for(int k=0;k<SAMPLE_COUNT;k++){vec3 position=rayOrigin+t*rayDirection;float height=length(position)-BOTTOM_RADIUS;vec3 up=position/length(position);float rayAngle=dot(up,rayDirection);float lightAngle=dot(up,lightDirection);float distanceToGround;float shadow=intersectSphere(position,lightDirection,BOTTOM_RADIUS,distanceToGround)&&distanceToGround>=0.0 ? 0.0 : 1.0;vec3 transmittanceToSpace=transmittanceFromTexture(height,cameraBelow ?-rayAngle : rayAngle);transmittanceCamera=cameraBelow ?(transmittanceToSpace/transmittanceFromCameraToSpace):(transmittanceFromCameraToSpace/transmittanceToSpace);transmittanceLight=transmittanceFromTexture(height,lightAngle);vec2 opticalDensity=exp(-height/rayleighMieHeights);vec3 scatteredLight=transmittanceLight*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y)*isotropicPhase;light+=shadow*transmittanceCamera*scatteredLight*segmentLength;lightTransferFactor+=transmittanceCamera*(rayleighScatteringCoefficient*opticalDensity.x+mieScatteringCoefficient*opticalDensity.y)*segmentLength;t+=segmentLength;}if(hitGround){vec3 hitPoint=rayOrigin+rayDirection*distanceToGround;vec3 normal=normalize(hitPoint);float diffuseAngle=max(dot(normal,lightDirection),0.0);light+=transmittanceCamera*transmittanceLight*GROUND_ALBEDO*diffuseAngle;}}}light/=float(SAMPLE_COUNT);lightTransferFactor/=float(SAMPLE_COUNT);vec3 color=light/(1.0-lightTransferFactor);gl_FragColor=vec4(color,1.0);}",t)}))))}initBackgroundShader(){var e;this.renderer&&this.renderer.handler.addProgram((e=this._parameters,new X("atmosphereBackground",{uniforms:{iResolution:"vec2",fov:"float",camPos:"vec3",viewMatrix:"mat4",transmittanceTexture:"sampler2D",scatteringTexture:"sampler2D",sunPos:"vec3",opacity:"float"},attributes:{corners:"vec3"},vertexShader:vc,fragmentShader:Zt(yc,e)})))}removeBackgroundShader(){this.renderer&&this.renderer.handler.removeProgram("atmosphereBackground")}removeLookupTexturesShaders(){var e,t;if(this.renderer){let i=this.renderer.handler;(e=this._scatteringBuffer)!=null&&e.isComplete()&&i.removeProgram("scattering"),(t=this._transmittanceBuffer)!=null&&t.isComplete()&&i.removeProgram("transmittance")}}onactivate(){super.onactivate(),this.planet&&this.planet.events.on("draw",this._drawBackground,this)}ondeactivate(){super.ondeactivate(),this.planet&&this.planet.events.off("draw",this._drawBackground)}_initLookupTextures(){this._transmittanceBuffer=new Se(this.renderer.handler,{width:1024,height:1024,useDepth:!1,targets:[{filter:"LINEAR",type:"FLOAT",internalFormat:"RGBA16F"}]}),this._transmittanceBuffer.init(),this._scatteringBuffer=new Se(this.renderer.handler,{width:1024,height:1024,useDepth:!1,targets:[{filter:"LINEAR",type:"FLOAT",internalFormat:"RGBA16F"}]}),this._scatteringBuffer.init()}_renderLookupTextures(){if(!this.renderer)return;let e=this.renderer.screenFramePositionBuffer,t=this.renderer.handler,i=t.gl;if(this._transmittanceBuffer){this._transmittanceBuffer.activate();let r=t.programs.transmittance,s=r._program.attributes,n=r._program.uniforms;r.activate(),i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform2fv(n.iResolution,[this._transmittanceBuffer.width,this._transmittanceBuffer.height]),i.bindBuffer(i.ARRAY_BUFFER,e),i.vertexAttribPointer(s.a_position,e.itemSize,i.FLOAT,!1,0,0),i.drawArrays(i.TRIANGLE_STRIP,0,e.numItems),this._transmittanceBuffer.deactivate()}if(this._scatteringBuffer&&this._transmittanceBuffer){this._scatteringBuffer.activate();let r=t.programs.scattering,s=r._program.attributes,n=r._program.uniforms;r.activate(),i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform2fv(n.iResolution,[this._scatteringBuffer.width,this._scatteringBuffer.height]),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._transmittanceBuffer.textures[0]),i.uniform1i(n.transmittanceTexture,0),i.bindBuffer(i.ARRAY_BUFFER,e),i.vertexAttribPointer(s.a_position,e.itemSize,i.FLOAT,!1,0,0),i.drawArrays(i.TRIANGLE_STRIP,0,e.numItems),this._scatteringBuffer.deactivate()}}drawLookupTextures(){this._renderLookupTextures()}_drawBackground(){let e=this.renderer.handler,t=e.programs.atmosphereBackground,i=t._program,r=i.uniforms,s=e.gl,n=this.renderer,o=this.planet.camera;s.disable(s.DEPTH_TEST),t.activate(),s.bindBuffer(s.ARRAY_BUFFER,n.screenFramePositionBuffer),s.vertexAttribPointer(i.attributes.corners,2,s.FLOAT,!1,0,0),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._transmittanceBuffer.textures[0]),s.uniform1i(r.transmittanceTexture,0),s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this._scatteringBuffer.textures[0]),s.uniform1i(r.scatteringTexture,1),s.uniformMatrix4fv(r.viewMatrix,!1,o.getViewMatrix());let l=this.planet.sunPos;s.uniform3fv(r.sunPos,[l.x,l.y,l.z]),s.uniform3fv(r.camPos,[o.eye.x,o.eye.y,o.eye.z]),s.uniform2fv(r.iResolution,[n.sceneFramebuffer.width,n.sceneFramebuffer.height]),s.uniform1f(r.fov,o.getViewAngle()),s.uniform1f(r.opacity,this.opacity),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.enable(s.DEPTH_TEST)}}const io="degrees",bc="m";let wc=0;class ss{constructor(e){this.id=wc++,this.code=e.code,this.units=e.units}equal(e){return e.id===this.id}}const ns=new ss({code:"epsg:3857",units:bc});class Cc{constructor(e){this.segment=e,this.layers=[],this.tileOffsetArr=new Float32Array(e.planet.SLICE_SIZE_4),this.layerOpacityArr=new Float32Array(e.planet.SLICE_SIZE)}clear(){this.layers=null,this.tileOffsetArr=null,this.layerOpacityArr=null}append(e,t){let i=this.layers.length;this.layers.push(e),this.layerOpacityArr[i]=e.screenOpacity;let r=4*i,s=e.applyMaterial(t);this.tileOffsetArr[r]=s[0],this.tileOffsetArr[r+1]=s[1],this.tileOffsetArr[r+2]=s[2],this.tileOffsetArr[r+3]=s[3]}}function We(a,e,t){return Math.floor(Math.abs(t-a)/e)}function as(a,e,t,i){let r=1/(1<<t),s=i.getWidth()*r,n=i.getHeight()*r,o=i.southWest.lon+a*s,l=i.northEast.lat-e*n;return new j(new A(o,l-n),new A(o+s,l))}const Tc=20,wt=300;let Ct=new m,Tt=new m,os=new m,fi=new m,gi=new m,ls=new m,pi=new H,Qi=new H;const mi=new Array(4);mi[0]=0,mi[1]=1,mi[2]=1,mi[3]=0;const vi=new Array(4);vi[0]=!1,vi[1]=!0,vi[2]=!1,vi[3]=!0;class ro{constructor(e,t,i,r){this.isPole=!1,this._tileGroup=0,this._projection=ns,this.node=e,this.quadTreeStrategy=t,this.planet=t.planet,this.handler=t.planet.renderer.handler,this.bsphere=new He,this._plainRadius=0,this.bbox=new Ws,this._sw=new m,this._nw=new m,this._se=new m,this._ne=new m,this.centerNormal=new m,this._extent=this._extentMerc=r,this._extentLonLat=new j,this.gridSize=this.planet.terrain.gridSizeByZoom[i],this.fileGridSize=0,this.tileZoom=i,this.powTileZoom=1<<i,this.tileX=0,this.tileXE=0,this.tileXW=0,this.tileYN=0,this.tileYS=0,this.tileY=0,this.tileIndex="",this.elevationData=null,this._assignTileIndexes(),this.materials=[],this.plainReady=!1,this.initialized=!1,this.normalMapReady=!1,this.terrainReady=!1,this.terrainIsLoading=!1,this.terrainExists=!1,this.passReady=!1,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapTexture=null,this.normalMapTextureBias=new Float32Array(3),this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null,this._globalTextureCoordinates=new Float32Array(4),this._inTheQueue=!1,this._appliedNeighborsZoom=[0,0,0,0],this._slices=[],this._indexBuffer=null,this.readyToEngage=!1,this.plainProcessing=!1,this.normalMapTexturePtr=null,this._transitionOpacity=1,this._transitionTimestamp=0}checkZoom(){return this.tileZoom<this.planet.terrain._maxNodeZoom}getEntityTerrainPoint(e,t){return this.getTerrainPoint(e._cartesian,this.getInsideLonLat(e),t)}getInsideLonLat(e){return e._lonLatMerc}isEntityInside(e){return this._extentLonLat.isInside(e._lonLat)}getTerrainPoint(e,t,i){let r=this.tempVertices;if(r&&r.length){let s=this.planet.ellipsoid.getSurfaceNormal3v(e);pi.set(e,s.negateTo());let n=this._extent.northEast,o=this._extent.southWest,l=Math.sqrt(r.length/3)-1,h=n.lon,c=n.lat,d=o.lon,u=o.lat,g=(h-d)/l,f=(c-u)/l,p=t.lon-d,_=t.lat-u,v=Math.floor(p/g),x=Math.floor(l-_/f),y=3*((l+1)*x+v),w=3*((l+1)*(x+1)+v);os.set(r[y],r[y+1],r[y+2]),fi.set(r[y+3],r[y+4],r[y+5]),gi.set(r[w],r[w+1],r[w+2]);let b=pi.hitTriangleRes(os,fi,gi,i);return b===H.INSIDE?e.distance(i):b===H.AWAY&&(Qi.set(e,s),Qi.hitTriangleRes(os,fi,gi,i)===H.INSIDE)?-e.distance(i):(ls.set(r[w+3],r[w+4],r[w+5]),b=pi.hitTriangleRes(fi,ls,gi,i),b===H.INSIDE?e.distance(i):b===H.AWAY&&(Qi.set(e,s),Qi.hitTriangleRes(fi,ls,gi,i)===H.INSIDE)||b===H.AWAY?-e.distance(i):e.distance(i))}return e.distance(this.planet.ellipsoid.hitRay(pi.origin,pi.direction))}projectNative(e){return e.forwardMercator()}loadTerrain(e=!1){this.tileZoom<this.planet.terrain.minZoom||this.planet.terrain.isEmpty?(this.terrainIsLoading=!0,this.elevationsNotExists(),this._inTheQueue||this.planet._normalMapCreator.queue(this)):this.tileZoom>this.planet.terrain.maxZoom?this.elevationsNotExists():this.terrainIsLoading||this.terrainReady||this.planet.terrain.loadTerrain(this,e)}elevationsExists(e){if(this.plainReady&&this.terrainIsLoading){let t=new Float32Array(e.length);t.set(e),this.elevationData=new Float32Array(e.length),this.elevationData.set(e),this.planet._terrainWorker.make({segment:this,elevations:t}),this.plainVerticesHigh=null,this.plainVerticesLow=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.planet.terrain.equalizeVertices||(this.tempVerticesHigh=null,this.tempVerticesLow=null)}}elevationsNotExists(){if(this.planet&&this.tileZoom<=this.planet.terrain.maxNativeZoom){if(this.plainReady&&this.terrainIsLoading){this.terrainIsLoading=!1;let e=this.node;e.appliedTerrainNodeId=this.node.nodeId,e.equalizedSideWithNodeId[0]=e.equalizedSideWithNodeId[1]=e.equalizedSideWithNodeId[2]=e.equalizedSideWithNodeId[3]=e.appliedTerrainNodeId,this.planet.lightEnabled&&!this._inTheQueue&&this.planet._normalMapCreator.queue(this),this.readyToEngage=!0}this.terrainVertices=this.plainVertices,this.terrainVerticesHigh=this.plainVerticesHigh,this.terrainVerticesLow=this.plainVerticesLow,this.tempVertices=this.terrainVertices,this.tempVerticesHigh=this.terrainVerticesHigh,this.tempVerticesLow=this.terrainVerticesLow,this.noDataVertices=null,this.fileGridSize=Math.sqrt(this.terrainVertices.length/3)-1,this.gridSize=this.fileGridSize,this.terrainReady=!0,this.terrainExists=!1}else if(this.plainReady&&this.terrainIsLoading){this.terrainIsLoading=!1;let e=this.node;e.appliedTerrainNodeId=this.node.nodeId,e.equalizedSideWithNodeId[0]=e.equalizedSideWithNodeId[1]=e.equalizedSideWithNodeId[2]=e.equalizedSideWithNodeId[3]=e.appliedTerrainNodeId,this.readyToEngage=!0,this.terrainReady=!0,this.passReady=!0,this.terrainExists=!1}}_checkEqualization(e,t){return t&&t.segment&&this.tileZoom>=t.segment.tileZoom&&this.node.equalizedSideWithNodeId[e]!==t.equalizedSideWithNodeId[Jt[e]]}equalize(){if(this.tileZoom<2||this.gridSize<2)return;this.readyToEngage=!0;let e=this.node.neighbors,t=this.tempVertices,i=this.tempVerticesHigh,r=this.tempVerticesLow,s=this.gridSize,n=s+1,o=e[0][0];if(this._checkEqualization(0,o)){this.node.equalizedSideWithNodeId[0]=o.equalizedSideWithNodeId[2],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,0),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(s/(u*f),1),_=Math.max(u*f/s,1);for(let v=0,x=l*u;v<n;v+=p,x+=_){const y=3*v,w=3*(g*u+x);t[y]=h[w],t[y+1]=h[w+1],t[y+2]=h[w+2],i[y]=c[w],i[y+1]=c[w+1],i[y+2]=c[w+2],r[y]=d[w],r[y+1]=d[w+1],r[y+2]=d[w+2]}}if(o=e[1][0],this._checkEqualization(1,o)){this.node.equalizedSideWithNodeId[1]=o.equalizedSideWithNodeId[3],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,1),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(s/(u*f),1),_=Math.max(u*f/s,1);for(let v=0,x=l*u;v<n;v+=p,x+=_){const y=3*(n*v+s),w=g*x*3;t[y]=h[w],t[y+1]=h[w+1],t[y+2]=h[w+2],i[y]=c[w],i[y+1]=c[w+1],i[y+2]=c[w+2],r[y]=d[w],r[y+1]=d[w+1],r[y+2]=d[w+2]}}if(o=e[2][0],this._checkEqualization(2,o)){this.node.equalizedSideWithNodeId[2]=o.equalizedSideWithNodeId[0],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,2),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=1/(1<<this.tileZoom-o.segment.tileZoom),f=Math.max(s/(u*g),1),p=Math.max(u*g/s,1);for(let _=0,v=l*u;_<n;_+=f,v+=p){const x=3*(n*s+_),y=3*v;t[x]=h[y],t[x+1]=h[y+1],t[x+2]=h[y+2],i[x]=c[y],i[x+1]=c[y+1],i[x+2]=c[y+2],r[x]=d[y],r[x+1]=d[y+1],r[x+2]=d[y+2]}}if(o=e[3][0],this._checkEqualization(3,o)){this.node.equalizedSideWithNodeId[3]=o.equalizedSideWithNodeId[1],this.readyToEngage=!0;let l=this.node.getOffsetOppositeNeighbourSide(o,3),h=o.segment.tempVertices,c=o.segment.tempVerticesHigh,d=o.segment.tempVerticesLow,u=o.segment.gridSize,g=u+1,f=1/(1<<this.tileZoom-o.segment.tileZoom),p=Math.max(s/(u*f),1),_=Math.max(u*f/s,1);for(let v=0,x=l*u;v<n;v+=p,x+=_){const y=n*v*3,w=3*(g*x+u);t[y]=h[w],t[y+1]=h[w+1],t[y+2]=h[w+2],i[y]=c[w],i[y+1]=c[w+1],i[y+2]=c[w+2],r[y]=d[w],r[y+1]=d[w+1],r[y+2]=d[w+2]}}}engage(){this.readyToEngage=!1,this.createCoordsBuffers(this.tempVerticesHigh,this.tempVerticesLow,this.gridSize)}_terrainWorkerCallback(e){if(this.plainReady){this.readyToEngage=!0,this.normalMapNormals=null,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapNormals=e.normalMapNormals,this.normalMapVertices=e.normalMapVertices,this.normalMapVerticesHigh=e.normalMapVerticesHigh,this.normalMapVerticesLow=e.normalMapVerticesLow,this.terrainVertices=e.terrainVertices,this.terrainVerticesHigh=e.terrainVerticesHigh,this.terrainVerticesLow=e.terrainVerticesLow,this.noDataVertices=e.noDataVertices,this.tempVertices=this.terrainVertices,this.tempVerticesHigh=this.terrainVerticesHigh,this.tempVerticesLow=this.terrainVerticesLow,this.setBoundingVolumeArr(e.bounds),this.gridSize=Math.sqrt(this.terrainVertices.length/3)-1;let t=this.node;if(t.appliedTerrainNodeId=t.nodeId,t.equalizedSideWithNodeId[0]=t.equalizedSideWithNodeId[1]=t.equalizedSideWithNodeId[2]=t.equalizedSideWithNodeId[3]=t.appliedTerrainNodeId,this.terrainReady=!0,this.terrainIsLoading=!1,this.terrainExists=!0,!this.normalMapTexturePtr){const i=this.planet._normalMapCreator;this.normalMapTexturePtr=this.planet.renderer.handler.createEmptyTexture_l(i.width,i.height)}this.planet.lightEnabled&&this.planet._normalMapCreator.queue(this)}}_normalMapEdgeEqualize(e){let t=this.node.neighbors,i=t[e],r=i&&i[0],s=this.planet.terrain.maxZoom;this.tileZoom===s&&i&&!(t[0].length||t[1].length||t[2].length||t[3].length)&&(r=this.node.getEqualNeighbor(e));let n=r&&r.segment,o=this;if(r&&n&&n.terrainReady&&n.terrainExists&&n.tileZoom<=s&&o._appliedNeighborsZoom[e]!==n.tileZoom){o._appliedNeighborsZoom[e]=n.tileZoom;let l=o.normalMapNormals,h=n.normalMapNormals;if(!l||!h)return;let c=o.normalMapNormals,d=n.normalMapNormals,u=Math.sqrt(l.length/3),g=u-1;const f=g*mi[e];let p,_,v,x;if(o.tileZoom===n.tileZoom){const y=g-f;if(vi[e])for(let w=0;w<u;w++){let b=3*(w*u+f),E=3*(w*u+y);p=c[b]+d[E],_=c[b+1]+d[E+1],v=c[b+2]+d[E+2],x=1/Math.sqrt(p*p+_*_+v*v),h[E]=l[b]=p*x,h[E+1]=l[b+1]=_*x,h[E+2]=l[b+2]=v*x}else for(let w=0;w<u;w++){let b=3*(f*u+w),E=3*(y*u+w);p=c[b]+d[E],_=c[b+1]+d[E+1],v=c[b+2]+d[E+2],x=1/Math.sqrt(p*p+_*_+v*v),h[E]=l[b]=p*x,h[E+1]=l[b+1]=_*x,h[E+2]=l[b+2]=v*x}n._inTheQueue||n._appliedNeighborsZoom[Jt[e]]===o.tileZoom||(n._appliedNeighborsZoom[Jt[e]]=o.tileZoom,o.planet._normalMapCreator.queue(n))}}}applyTerrain(e){e?this.elevationsExists(e):this.elevationsNotExists()}deleteBuffers(){const e=this.handler.gl;e.deleteBuffer(this.vertexNormalBuffer),e.deleteBuffer(this.vertexPositionBuffer),e.deleteBuffer(this.vertexPositionBufferHigh),e.deleteBuffer(this.vertexPositionBufferLow),this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null}deleteMaterials(){let e=this.materials;for(let t=0;t<e.length;t++){let i=e[t];i&&i.clear()}this.materials.length=0}deleteElevations(){this.terrainExists=!1,this.terrainReady=!1,this.terrainIsLoading=!1,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.normalMapReady&&(this.handler.gl.deleteTexture(this.normalMapTexture),this.normalMapReady=!1),this._appliedNeighborsZoom=[0,0,0,0],this.normalMapTextureBias[0]=0,this.normalMapTextureBias[1]=0,this.normalMapTextureBias[2]=1,this._inTheQueue=!1}clearSegment(){this.plainReady=!1,this.initialized=!1,this.deleteBuffers(),this.deleteMaterials(),this.deleteElevations()}childrenInitialized(){let e=this.node.nodes;return e.length===4&&e[0].segment.initialized&&e[1].segment.initialized&&e[2].segment.initialized&&e[3].segment.initialized}destroySegment(){this.clearSegment();let e=this._slices.length;for(;e--;)this._slices[e].clear();this._slices=null,this.node=null,this.planet=null,this.handler=null,this.bbox=null,this.bsphere=null,this._extent=null,this.materials=null,this.plainVertices=null,this.plainVerticesHigh=null,this.plainVerticesLow=null,this.plainNormals=null,this.terrainVertices=null,this.terrainVerticesHigh=null,this.terrainVerticesLow=null,this.noDataVertices=null,this.tempVertices=null,this.tempVerticesHigh=null,this.tempVerticesLow=null,this.normalMapTextureBias=null,this.normalMapTexture=null,this.normalMapVertices=null,this.normalMapVerticesHigh=null,this.normalMapVerticesLow=null,this.normalMapNormals=null,this.vertexNormalBuffer=null,this.vertexPositionBuffer=null,this.vertexPositionBufferHigh=null,this.vertexPositionBufferLow=null,this.vertexTextureCoordBuffer=null,this._projection=null,this._appliedNeighborsZoom=null,this._globalTextureCoordinates=null}_setExtentLonLat(){this._extentLonLat=this._extent.inverseMercator()}_createExtentNormals(){const e=this.planet.ellipsoid,t=this._extentLonLat,i=e.geodeticToCartesian(t.southWest.lon,t.southWest.lat),r=e.geodeticToCartesian(t.northEast.lon,t.northEast.lat),s=e.geodeticToCartesian(t.southWest.lon,t.northEast.lat),n=e.geodeticToCartesian(t.northEast.lon,t.southWest.lat);this._sw.copy(i),this._nw.copy(s),this._ne.copy(r),this._se.copy(n)}createBoundsByExtent(){this._createExtentNormals(),this.setBoundingVolume3v(this._sw,this._ne)}createBoundsByParent(){let e=this.node;for(;e.parentNode&&!e.segment.terrainReady;)e=e.parentNode;let t=1<<this.tileZoom-e.segment.tileZoom,i=this.tileX-e.segment.tileX*t,r=this.tileY-e.segment.tileY*t;if(e.segment.terrainReady&&e.segment.tileZoom>=this.planet.terrain.minZoom){let s=e.segment.gridSize/t;if(s>=1){this.bsphere.center.x=e.segment.bsphere.center.x,this.bsphere.center.y=e.segment.bsphere.center.y,this.bsphere.center.z=e.segment.bsphere.center.z,this.bsphere.radius=e.segment.bsphere.radius;let n=s*r,o=s*i,l=e.segment.gridSize+1,h=3*((n+s)*l+o),c=3*(n*l+o),d=3*(n*l+o+s),u=3*((n+s)*l+o+s),g=e.segment.tempVertices,f=new m(g[h],g[h+1],g[h+2]),p=new m(g[d],g[d+1],g[d+2]),_=new m(g[c],g[c+1],g[c+2]),v=new m(g[u],g[u+1],g[u+2]);this._sw.copy(f),this._nw.copy(_),this._ne.copy(p),this._se.copy(v)}else{let n,o=e.segment,l=Math.floor(s*r),h=Math.floor(s*i),c=1/s,d=r-c*l,u=i-c*h;n=o.gridSize===1?o.tempVertices:mr(o.tempVertices,o.gridSize,l,h,1);let g,f,p=new m(n[0],n[1],n[2]),_=new m(n[9],n[10],n[11]),v=new m(n[3]-n[0],n[4]-n[1],n[5]-n[2]),x=new m(n[6]-n[0],n[7]-n[1],n[8]-n[2]),y=new m(n[3]-n[9],n[4]-n[10],n[5]-n[11]),w=new m(n[6]-n[9],n[7]-n[10],n[8]-n[11]),b=d,E=u;g=b+E<c?m.add(v.scaleTo(E/c),x.scaleTo(b/c)).addA(p):m.add(w.scaleTo(1-E/c),y.scaleTo(1-b/c)).addA(_),b=d+1,E=u+1,f=b+E<c?m.add(v.scaleTo(E/c),x.scaleTo(b/c)).addA(p):m.add(w.scaleTo(1-E/c),y.scaleTo(1-b/c)).addA(_),this._createExtentNormals(),this.setBoundingVolume3v(g,f)}}else this.createBoundsByExtent()}setBoundingSphere(e,t,i,r){this.bsphere.center.x=e,this.bsphere.center.y=t,this.bsphere.center.z=i,this.bsphere.radius=this.bsphere.center.distance(r)}setBoundingVolume(e,t,i,r,s,n){this.bbox.setFromBoundsArr([e,t,i,r,s,n]);let o=e+.5*(r-e),l=t+.5*(s-t),h=i+.5*(n-i);this.bsphere.center.set(o,l,h),this.bsphere.radius=this.bsphere.center.distance(new m(e,t,i))}setBoundingVolume3v(e,t){this.bbox.setFromBoundsArr([e.x,e.y,e.z,t.x,t.y,t.z]);let i=e.x+.5*(t.x-e.x),r=e.y+.5*(t.y-e.y),s=e.z+.5*(t.z-e.z);this.bsphere.center.set(i,r,s),this.bsphere.radius=this.bsphere.center.distance(new m(e.x,e.y,e.z))}setBoundingVolumeArr(e){this.bbox.setFromBoundsArr(e);let t=e[0]+.5*(e[3]-e[0]),i=e[1]+.5*(e[4]-e[1]),r=e[2]+.5*(e[5]-e[2]);this.bsphere.center.set(t,i,r),this.bsphere.radius=this.bsphere.center.distance(new m(e[0],e[1],e[2]))}createCoordsBuffers(e,t,i){const r=(i+1)*(i+1),s=this.handler;this.vertexPositionBufferHigh&&this.vertexPositionBufferHigh.numItems===r?(s.setStreamArrayBuffer(this.vertexPositionBufferHigh,e),s.setStreamArrayBuffer(this.vertexPositionBufferLow,t)):(s.gl.deleteBuffer(this.vertexPositionBufferHigh),s.gl.deleteBuffer(this.vertexPositionBufferLow),this.vertexTextureCoordBuffer=this.planet._textureCoordsBufferCache[Math.log2(i)],this.vertexPositionBufferHigh=s.createArrayBuffer(e,3,r),this.vertexPositionBufferLow=s.createArrayBuffer(t,3,r))}_addViewExtent(){const e=this._extentLonLat;let t=this.quadTreeStrategy._viewExtent;e.southWest.lon<t.southWest.lon&&(t.southWest.lon=e.southWest.lon),e.northEast.lon>t.northEast.lon&&(t.northEast.lon=e.northEast.lon),e.southWest.lat<t.southWest.lat&&(t.southWest.lat=e.southWest.lat),e.northEast.lat>t.northEast.lat&&(t.northEast.lat=e.northEast.lat)}_assignTileIndexes(){this._tileGroup=0;const e=this.tileZoom,t=this._extent,i=Ee;this.tileX=We(t.getCenter().lon,t.getWidth(),-2003750834e-2),this.tileY=We(t.getCenter().lat,t.getHeight(),i);const r=this.powTileZoom;this.tileXE=(this.tileX+1)%r,this.tileXW=(r+this.tileX-1)%r,this.tileYN=this.tileY-1,this.tileYS=this.tileY+1,this.tileIndex=Ye.getTileIndex(this.tileX,this.tileY,e,this._tileGroup)}initialize(){const e=this.planet,t=this.node;if(this.gridSize=e.terrain.gridSizeByZoom[this.tileZoom]||e.terrain.plainGridSize,t.sideSizeLog2[0]=t.sideSizeLog2[1]=t.sideSizeLog2[2]=t.sideSizeLog2[3]=Math.log2(this.gridSize),this.tileZoom<=e.terrain.maxZoom){const i=this.planet._normalMapCreator;this.normalMapTexturePtr=e.renderer.handler.createEmptyTexture_l(i.width,i.height)}this.normalMapTexture=this.planet.transparentTexture,this._assignGlobalTextureCoordinates(),this.initialized=!0}_assignGlobalTextureCoordinates(){const e=this._extent;this._globalTextureCoordinates[0]=(e.southWest.lon+Ee)*Wt,this._globalTextureCoordinates[1]=(Ee-e.northEast.lat)*Wt,this._globalTextureCoordinates[2]=(e.northEast.lon+Ee)*Wt,this._globalTextureCoordinates[3]=(Ee-e.southWest.lat)*Wt}createPlainSegmentAsync(){let e=this.planet,t=e.terrain;t.isReady()&&!this.plainReady&&this.tileZoom<=t.maxZoom&&(this.plainProcessing=!0,e._plainSegmentWorker.make(this))}_plainSegmentWorkerCallback(e){this.plainProcessing=!1,this.initialized&&!this.terrainReady&&(this.plainReady=!0,this.plainVertices=e.plainVertices,this.plainVerticesHigh=e.plainVerticesHigh,this.plainVerticesLow=e.plainVerticesLow,this.plainNormals=e.plainNormals,this._plainRadius=e.plainRadius,this.normalMapNormals=e.normalMapNormals,this.normalMapVertices=e.normalMapVertices,this.normalMapVerticesHigh=e.normalMapVerticesHigh,this.normalMapVerticesLow=e.normalMapVerticesLow,this.fileGridSize=Math.sqrt(e.normalMapVertices.length/3)-1)}createPlainSegment(){this.initialize(),this._createPlainVertices(),this.readyToEngage=!0}_projToDeg(e,t){return A.inverseMercator(e,t)}_createPlainVertices(){const e=this.planet.terrain.gridSizeByZoom[this.tileZoom],t=this.planet.terrain.plainGridSize,i=Math.max(t,e),r=this._extent,s=r.getWidth()/i,n=r.getHeight()/i,o=r.southWest.lon,l=r.northEast.lat,h=Math.max(t/e,1),c=i+1,d=this.planet.ellipsoid._invRadii2,u=c*c,g=(e+1)*(e+1)*3;let f=0,p=0;this.plainNormals=new Float32Array(g),this.plainVertices=new Float64Array(g),this.plainVerticesHigh=new Float32Array(g),this.plainVerticesLow=new Float32Array(g),this.normalMapNormals=new Float32Array(3*u),this.normalMapVertices=new Float64Array(3*u),this.normalMapVerticesHigh=new Float32Array(3*u),this.normalMapVerticesLow=new Float32Array(3*u);let _=this.plainVertices,v=this.plainVerticesHigh,x=this.plainVerticesLow,y=this.plainNormals,w=this.normalMapVertices,b=this.normalMapVerticesHigh,E=this.normalMapVerticesLow,C=this.normalMapNormals;for(let T=0;T<u;T++){let L=T%c,M=~~(T/c),R=this.planet.ellipsoid.lonLatToCartesian(this._projToDeg(o+L*s,l-M*n)),z=R.x*d.x,F=R.y*d.y,P=R.z*d.z,D=1/Math.sqrt(z*z+F*F+P*P),k=z*D,I=F*D,B=P*D;m.doubleToTwoFloats(R,Ct,Tt),w[p]=R.x,b[p]=Ct.x,E[p]=Tt.x,C[p++]=k,w[p]=R.y,b[p]=Ct.y,E[p]=Tt.y,C[p++]=I,w[p]=R.z,b[p]=Ct.z,E[p]=Tt.z,C[p++]=B,M%h==0&&L%h==0&&(_[f]=R.x,v[f]=Ct.x,x[f]=Tt.x,y[f++]=k,_[f]=R.y,v[f]=Ct.y,x[f]=Tt.y,y[f++]=I,_[f]=R.z,v[f]=Ct.z,x[f]=Tt.z,y[f++]=B)}this.terrainVertices=_,this.terrainVerticesHigh=v,this.terrainVerticesLow=x,this.plainReady=!0}getMaterialByLayer(e){return this.materials[e.__id]}_getLayerExtentOffset(e){const t=e._extentMerc,i=this._extent,r=t.northEast.lon-t.southWest.lon,s=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/r,(t.northEast.lat-i.northEast.lat)/s,(i.northEast.lon-i.southWest.lon)/r,(i.northEast.lat-i.southWest.lat)/s]}initSlice(e){let t=this._slices[e];return t?t.layers=[]:t=this._slices[e]=new Cc(this),t}screenRendering(e,t,i,r,s=!1,n){const o=this.handler.gl,l=e.attributes,h=e.uniforms,c=this.materials,d=this.planet,u=this.quadTreeStrategy;let g,f;t&&t.length?(f=t[0],g=f._height):g=0,o.activeTexture(o.TEXTURE0+d.SLICE_SIZE+2),o.bindTexture(o.TEXTURE_2D,r||this.getDefaultTexture()),o.uniform1i(h.defaultTexture,d.SLICE_SIZE+2);let p=0,_=0,v=!1,x=this.initSlice(i);for(this._indexBuffer=this._getIndexBuffer();f;){if(this.layerOverlap(f)&&(f._fading&&f._fadingOpacity>0||(f.minZoom>=u.minCurrZoom||f.maxZoom>=u.minCurrZoom)&&(f.minZoom<=u.maxCurrZoom||f.maxZoom<=u.maxCurrZoom))){v=!0;let y=c[f.__id];y||(y=c[f.__id]=f.createMaterial(this)),y.isReady||(u._renderCompleted=!1),x.append(f,y),d._samplerArr[p]=p,o.activeTexture(o.TEXTURE0+p),o.bindTexture(o.TEXTURE_2D,y.texture||d.transparentTexture),p++}_++,f=t[_]}!v&&s||(o.uniform1f(h.transitionOpacity,n||this._transitionOpacity>1?1:this._transitionOpacity),o.uniform1i(h.samplerCount,p),o.uniform1f(h.height,g),o.uniform1iv(h.samplerArr,d._samplerArr),o.uniform4fv(h.tileOffsetArr,x.tileOffsetArr),o.uniform1fv(h.layerOpacityArr,x.layerOpacityArr),d.lightEnabled&&(o.activeTexture(o.TEXTURE0+d.SLICE_SIZE+3),o.bindTexture(o.TEXTURE_2D,this.normalMapTexture||d.transparentTexture),o.uniform1i(h.uNormalMap,d.SLICE_SIZE+3),o.uniform3fv(h.uNormalMapBias,this.normalMapTextureBias),o.uniform4fv(h.uGlobalTextureCoord,this._globalTextureCoordinates)),o.bindBuffer(o.ARRAY_BUFFER,this.vertexPositionBufferHigh),o.vertexAttribPointer(l.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.vertexPositionBufferLow),o.vertexAttribPointer(l.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.vertexTextureCoordBuffer),o.vertexAttribPointer(l.aTextureCoord,2,o.UNSIGNED_SHORT,!0,0,0),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,this._indexBuffer),o.drawElements(d.drawMode,this._indexBuffer.numItems,o.UNSIGNED_INT,0))}increaseTransitionOpacity(){this._transitionOpacity+=(window.performance.now()-this._transitionTimestamp)/this.planet.transitionTime,this._transitionTimestamp=window.performance.now(),this._transitionOpacity>2&&(this._transitionOpacity=2);let e=this.node._fadingNodes.length;for(;e--;){let t=this.node._fadingNodes[e];if(!t.segment){this._transitionOpacity=1;break}t.segment._transitionOpacity>0&&!this.quadTreeStrategy._fadingNodes.has(t.__id)&&(this.quadTreeStrategy._fadingNodes.set(t.__id,t),t.segment._transitionOpacity=2-this._transitionOpacity,t.segment._transitionOpacity===0&&this.node._fadingNodes.splice(e,1))}}fadingTransitionOpacity(){this._transitionOpacity-=.01,this._transitionTimestamp=window.performance.now(),this._transitionOpacity<0&&(this._transitionOpacity=0)}colorPickingRendering(e,t,i,r,s=!1){const n=this.handler.gl,o=e.attributes,l=e.uniforms;let h,c=this.materials,d=this.planet;h=t&&t.length?t[0]._height:0;let u=!1,g=this._slices[i],f=g.layers.length;for(let p=0;p<f;p++){u=!0;let _=g.layers[p],v=4*p;d._pickingColorArr[v]=_._pickingColor.x/255,d._pickingColorArr[v+1]=_._pickingColor.y/255,d._pickingColorArr[v+2]=_._pickingColor.z/255,d._pickingColorArr[v+3]=Number(_._pickingEnabled),d._samplerArr[p]=p,n.activeTexture(n.TEXTURE0+p),n.bindTexture(n.TEXTURE_2D,c[_.__id].texture||this.planet.transparentTexture),d._pickingMaskArr[p]=p+d.SLICE_SIZE,n.activeTexture(n.TEXTURE0+p+d.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,c[_.__id].pickingMask||this.planet.transparentTexture)}!u&&s||(n.uniform1i(l.samplerCount,f),n.uniform1f(l.height,h),n.uniform1iv(l.samplerArr,d._samplerArr),n.uniform1iv(l.pickingMaskArr,d._pickingMaskArr),n.uniform4fv(l.pickingColorArr,d._pickingColorArr),n.uniform4fv(l.tileOffsetArr,g.tileOffsetArr),n.uniform1fv(l.layerOpacityArr,g.layerOpacityArr),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBufferHigh),n.vertexAttribPointer(o.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBufferLow),n.vertexAttribPointer(o.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this.vertexTextureCoordBuffer),n.vertexAttribPointer(o.aTextureCoord,2,n.UNSIGNED_SHORT,!0,0,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this._indexBuffer),n.drawElements(n.TRIANGLE_STRIP,this._indexBuffer.numItems,n.UNSIGNED_INT,0))}depthRendering(e,t){const i=this.handler.gl,r=e.attributes,s=e.uniforms;var n;n=t&&t.length?t[0]._height:0,i.uniform1f(s.height,n),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferHigh),i.vertexAttribPointer(r.aVertexPositionHigh,this.vertexPositionBufferHigh.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this.vertexPositionBufferLow),i.vertexAttribPointer(r.aVertexPositionLow,this.vertexPositionBufferLow.itemSize,i.FLOAT,!1,0,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.drawElements(i.TRIANGLE_STRIP,this._indexBuffer.numItems,i.UNSIGNED_INT,0)}_getIndexBuffer(){const e=this.node.sideSizeLog2;let t=this.planet._indexesCache[Math.log2(this.gridSize)][e[0]][e[1]][e[2]][e[3]];if(!t.buffer){let i=Zi().createSegmentIndexes(Math.log2(this.gridSize),[e[0],e[1],e[2],e[3]]);t.buffer=this.planet.renderer.handler.createElementArrayBuffer(i,1),this.planet._indexesCacheToRemoveCounter++}return t.buffer}layerOverlap(e){return this._extent.overlaps(e._extentMerc)}getDefaultTexture(){return this.planet.solidTextureOne}getExtentLonLat(){return this._extentLonLat}getExtentMerc(){return this._extentMerc}getExtent(){return this._extent}getNeighborSide(e){if(this.tileY===e.tileY){if(this.tileX===e.tileXE)return 3;if(this.tileX===e.tileXW)return 1}else if(this.tileX===e.tileX){if(this.tileY===e.tileYS)return 0;if(this.tileY===e.tileYN)return 2}return-1}}let Ki=new m,Ji=new m;const Et=[new N(0,0),new N(1,0),new N(0,1),new N(1,1)],Ec=Math.sqrt(Et.length)-1;let ae={xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0},Ac=0;class ft{constructor(e,t,i,r,s,n){t.planet._createdNodesCount++,this.__id=Ac++,this.SegmentPrototype=e,this.quadTreeStrategy=t,this.parentNode=r,this.partId=i,this.nodeId=i+(r?4*r.nodeId+1:0),this.state=null,this.prevState=null,this.appliedTerrainNodeId=-1,this.sideSizeLog2=[0,0,0,0],this.ready=!1,this.neighbors=[[],[],[],[]],this.equalizedSideWithNodeId=[this.nodeId,this.nodeId,this.nodeId,this.nodeId],this.nodes=[],this.segment=new e(this,t,s,n),this._cameraInside=!1,this.inFrustum=0,this._fadingNodes=[],this.createBounds()}createChildNodes(){this.ready=!0;const e=this.quadTreeStrategy,t=this.segment,i=t._extent,r=t.tileZoom+1,s=.5*i.getWidth(),n=.5*i.getHeight(),o=i.northEast,l=i.southWest,h=new A(l.lon+s,l.lat+n),c=this.nodes;c[0]=new ft(this.SegmentPrototype,e,0,this,r,new j(new A(l.lon,l.lat+n),new A(l.lon+s,o.lat))),c[1]=new ft(this.SegmentPrototype,e,1,this,r,new j(h,new A(o.lon,o.lat))),c[2]=new ft(this.SegmentPrototype,e,2,this,r,new j(new A(l.lon,l.lat),h)),c[3]=new ft(this.SegmentPrototype,e,3,this,r,new j(new A(l.lon+s,l.lat),new A(o.lon,l.lat+n)))}createBounds(){let e=this.segment;e._setExtentLonLat(),e.tileZoom===0?e.setBoundingSphere(0,0,0,new m(0,0,e.planet.ellipsoid.equatorialSize)):e.tileZoom<e.planet.terrain.minZoom?e.createBoundsByExtent():e.createBoundsByParent();let t=e.bsphere.center.x,i=e.bsphere.center.y,r=e.bsphere.center.z,s=1/Math.sqrt(t*t+i*i+r*r);e.centerNormal.x=t*s,e.centerNormal.y=i*s,e.centerNormal.z=r*s}getState(){if(this.state===-1)return this.state;let e=this.parentNode;for(;e;){if(e.state!==2)return 0;e=e.parentNode}return this.state}getEqualNeighbor(e){let t=this,i=Js[e][t.partId];if(i!==-1)return t.parentNode.nodes[i];{let r=[];for(;t.parentNode;)if(r.push(t.partId),i=Js[e][t.partId],t=t.parentNode,i!==-1){let s=r.length;for(e=Jt[e];t&&s--;)i=gl[e][r[s]],t=t.nodes[i];return t}}}traverseNodes(e,t,i,r,s){this.ready||this.createChildNodes();let n=this.nodes;n[0].renderTree(e,t,i,r,s),n[1].renderTree(e,t,i,r,s),n[2].renderTree(e,t,i,r,s),n[3].renderTree(e,t,i,r,s)}renderTree(e,t,i,r,s){if(this.quadTreeStrategy._renderedNodes.length>=1e3)return;(!t||s&&this.segment.tileZoom>s.segment.tileZoom)&&(this.prevState=this.state),this.state=2,this.clearNeighbors();let n=this.segment,o=this.quadTreeStrategy.planet;if(this._cameraInside=!1,!this.parentNode||this.parentNode._cameraInside){let c;c=n._projection.id===ns.id?n._extent.isInside(e._lonLatMerc):n._extent.isInside(e._lonLat),c&&(e._insideSegment=n,this._cameraInside=!0)}this.inFrustum=0;let l=e.frustums,h=l.length;if(n.tileZoom<6)for(let c=0;c<h;c++)l[c].containsSphere(n.bsphere)&&(this.inFrustum|=1<<c);else for(let c=0;c<h;c++)n.terrainReady?l[c].containsBox(n.bbox)&&(this.inFrustum|=1<<c):l[c].containsSphere(n.bsphere)&&(this.inFrustum|=1<<c);if(this.inFrustum||this._cameraInside||n.tileZoom<3){let c=Math.abs(e._lonLat.height),d=e.eye.length2()-o.ellipsoid.polarSizeSqr;d=d<10687647287563281e-5*o._heightFactor?10687647287563281e-5*o._heightFactor:d;let u=n.tileZoom<2||n.tileZoom>19||n.tileZoom<6&&!n.terrainReady;u=u||e.eye.distance2(n._sw)<d||e.eye.distance2(n._nw)<d||e.eye.distance2(n._ne)<d||e.eye.distance2(n._se)<d,(this.inFrustum&&(u||c>1e4)||this._cameraInside)&&this.quadTreeStrategy.collectVisibleNode(this),n.tileZoom<2?this.traverseNodes(e,t,i,r,s):n.terrainReady&&(!t&&e.projectedSize(n.bsphere.center,n._plainRadius)<this.quadTreeStrategy.lodSize||t&&(n.tileZoom===t||!u))?u?(n.passReady=!0,this.renderNode(this.inFrustum,!this.inFrustum,i,r)):this.state=0:n.terrainReady&&n.checkZoom()&&(!t||e.projectedSize(n.bsphere.center,n.bsphere.radius)>this.quadTreeStrategy._maxLodSize)?this.traverseNodes(e,t,n,r,s):u?(n.passReady=!!t&&n.terrainReady,this.renderNode(this.inFrustum,!this.inFrustum,i,r)):this.state=0}else this.state=0}renderNode(e,t,i,r){let s=this.segment;s.terrainReady||(s.initialized||s.initialize(),this.whileTerrainLoading(i),s.plainProcessing||s.createPlainSegmentAsync(),s.plainReady&&!r&&s.loadTerrain()),s.planet.lightEnabled&&!s.normalMapReady&&this.whileNormalMapCreating(),t?this.state=-1:(!this._cameraInside&&s.tileZoom>this.quadTreeStrategy.maxCurrZoom&&(this.quadTreeStrategy.maxCurrZoom=s.tileZoom),s.tileZoom<this.quadTreeStrategy.minCurrZoom&&(this.quadTreeStrategy.minCurrZoom=s.tileZoom),s._addViewExtent(),this.addToRender(e))}childrenPrevStateEquals(e){let t=this.nodes;return t.length===4&&t[0].prevState===e&&t[1].prevState===e&&t[2].prevState===e&&t[3].prevState===e}isFading(){let e=this.nodes;return this.state===2&&this.segment._transitionOpacity>0&&e.length===4&&e[0].state===1&&e[1].state===1&&e[2].state===1&&e[3].state===1}_collectFadingNodes(){if(this.segment.tileZoom<3)this.segment._transitionOpacity=1;else if(this.prevState!==1){this.segment._transitionOpacity=0,this._fadingNodes=[];let e=window.performance.now();if(this.segment._transitionTimestamp=e,this.parentNode){if(this.parentNode.prevState===1){let t=this.parentNode.parentNode;for(;t;){if(t.isFading()){for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment._transitionOpacity=1,t.nodes[i]._fadingNodes=[];t.segment._transitionOpacity=0;break}t=t.parentNode}this.parentNode.whileTerrainLoading(),this._fadingNodes.push(this.parentNode),this.parentNode.segment._transitionOpacity=2,this.parentNode.segment._transitionTimestamp=e}else if(this.segment.childrenInitialized()&&this.childrenPrevStateEquals(1))for(let t=0;t<this.nodes.length;t++){let i=this.nodes[t];i.whileTerrainLoading(),this._fadingNodes.push(i),i.segment._transitionOpacity=2,i.segment._transitionTimestamp=e,i.prevState=i.state,i.state=0}}}}clearNeighbors(){this.neighbors&&(this.neighbors[0]=this.neighbors[1]=this.neighbors[2]=this.neighbors[3]=null,this.neighbors[0]=[],this.neighbors[1]=[],this.neighbors[2]=[],this.neighbors[3]=[])}_refreshTransitionOpacity(){if(this._fadingNodes.length===0)this.segment._transitionOpacity=1;else if(this._fadingNodes.length!==4||this.childrenPrevStateEquals(1)){for(let e=0;e<this._fadingNodes.length;e++)this.segment._transitionOpacity<1&&this._fadingNodes[e].segment._transitionOpacity===0&&(this._fadingNodes[e].segment._transitionOpacity=0,this.segment._transitionOpacity=1);this.segment.increaseTransitionOpacity()}else this.segment._transitionOpacity=1,this._fadingNodes=[]}addToRender(e){this.state=1;let t=this.quadTreeStrategy._renderedNodes;this.quadTreeStrategy._transitionOpacityEnabled?pr(t,this,(s,n)=>s.segment.tileZoom-n.segment.tileZoom):(this.getRenderedNodesNeighbors(t),t.push(this)),this.segment.terrainReady||(this.quadTreeStrategy._renderCompleted=!1,this.quadTreeStrategy._terrainCompleted=!1);let i=0,r=this.quadTreeStrategy._renderedNodesInFrustum;for(;e;)1&e&&r[i].push(this),i++,e>>=1}applyNeighbor(e,t){const i=Jt[t];if(this.neighbors[t].length===0||e.neighbors[i].length===0){const r=this.segment,s=e.segment,n=r.gridSize/(s.gridSize*Math.pow(2,s.tileZoom-r.tileZoom));let o=r.gridSize,l=s.gridSize;n>1?(o=Math.ceil(r.gridSize/n),l=s.gridSize):n<1&&(o=r.gridSize,l=Math.ceil(s.gridSize*n)),this.sideSizeLog2[t]=Math.log2(o),e.sideSizeLog2[i]=Math.log2(l)}this.neighbors[t].push(e),e.neighbors[i].push(this)}getRenderedNodesNeighbors(e){for(let t=e.length-1;t>=0;--t){let i=e[t],r=this.getCommonSide(i);r!==-1&&this.applyNeighbor(i,r)}}getCommonSide(e){const t=this.segment,i=e.segment;if(t.tileZoom===i.tileZoom&&t._tileGroup===i._tileGroup)return t.getNeighborSide(i);{const r=t._extentLonLat,s=i._extentLonLat;let n=r.northEast,o=r.southWest,l=s.northEast,h=s.southWest,c=n.lon,d=n.lat,u=o.lon,g=o.lat,f=l.lon,p=l.lat,_=h.lon,v=h.lat;if(t._tileGroup===i._tileGroup){if(c===_&&(d<=p&&g>=v||d>=p&&g<=v))return 1;if(u===f&&(d<=p&&g>=v||d>=p&&g<=v))return 3;if(d===v&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(g===p&&(u>=_&&c<=f||u<=_&&c>=f))return 2;if(i.tileX===0&&_===-c&&(d<=p&&g>=v||d>=p&&g<=v))return 1;if(t.tileX===0&&u===-f&&(d<=p&&g>=v||d>=p&&g<=v))return 3}if(t._tileGroup===0&&i._tileGroup===20&&t.tileY===0&&i.tileY===i.powTileZoom-1&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(t._tileGroup===0&&i._tileGroup===wt&&t.tileY===t.powTileZoom-1&&i.tileY===0&&(u>=_&&c<=f||u<=_&&c>=f))return 2;if(t._tileGroup===wt&&i._tileGroup===0&&t.tileY===0&&i.tileY===i.powTileZoom-1&&(u>=_&&c<=f||u<=_&&c>=f))return 0;if(t._tileGroup===20&&i._tileGroup===0&&t.tileY===t.powTileZoom-1&&i.tileY===0&&(u>=_&&c<=f||u<=_&&c>=f))return 2}return-1}whileNormalMapCreating(){const e=this.segment;e.terrainIsLoading||!e.terrainExists||e._inTheQueue||e.planet._normalMapCreator.queue(e);let t=this;for(;t.parentNode&&!t.segment.normalMapReady;)t=t.parentNode;const i=2<<e.tileZoom-t.segment.tileZoom-1;e.normalMapTexture=t.segment.normalMapTexture,e.normalMapTextureBias[0]=e.tileX-t.segment.tileX*i,e.normalMapTextureBias[1]=e.tileY-t.segment.tileY*i,e.normalMapTextureBias[2]=1/i}whileTerrainLoading(e){const t=this.segment;let i=this;if(e&&e.terrainReady)i=e.node;else for(;i.parentNode&&!i.segment.terrainReady;)i=i.parentNode;if(i.segment.terrainReady&&this.appliedTerrainNodeId!==i.nodeId){let r=2<<t.tileZoom-i.segment.tileZoom-1,s=t.tileX-i.segment.tileX*r,n=t.tileY-i.segment.tileY*r;const o=i.segment;let l,h,c,d;this.appliedTerrainNodeId=i.nodeId,this.equalizedSideWithNodeId[0]=this.equalizedSideWithNodeId[1]=this.equalizedSideWithNodeId[2]=this.equalizedSideWithNodeId[3]=this.appliedTerrainNodeId;let u=i.segment.gridSize/r,g=i.segment.fileGridSize/r;if(ae.xmin=ye,ae.xmax=Te,ae.ymin=ye,ae.ymax=Te,ae.zmin=ye,ae.zmax=Te,u>=1){t.gridSize=u;let f=(u+1)*(u+1)*3;l=new Float64Array(f),h=new Float32Array(f),c=new Float32Array(f),o.noDataVertices&&(d=new Uint8Array(f/3)),vr(o.terrainVertices,o.terrainVerticesHigh,o.terrainVerticesLow,o.noDataVertices,o.gridSize,u*n,u*s,u,l,h,c,ae,d)}else if(g>=1&&i.segment.terrainExists){t.gridSize=g;let f=(g+1)*(g+1)*3;l=new Float64Array(f),h=new Float32Array(f),c=new Float32Array(f),o.noDataVertices&&(d=new Uint8Array(f/3)),vr(o.normalMapVertices,o.normalMapVerticesHigh,o.normalMapVerticesLow,o.noDataVertices,i.segment.fileGridSize,g*n,g*s,g,l,h,c,ae,d)}else{t.gridSize=Ec;let f,p=Math.floor(u*n),_=Math.floor(u*s);f=o.gridSize===1?o.terrainVertices:mr(o.terrainVertices,o.gridSize,p,_,1);let v=1/u,x=n-v*p,y=s-v*_,w=new m(f[0],f[1],f[2]),b=new m(f[9],f[10],f[11]),E=new m(f[3]-f[0],f[4]-f[1],f[5]-f[2]),C=new m(f[6]-f[0],f[7]-f[1],f[8]-f[2]),T=new m(f[3]-f[9],f[4]-f[10],f[5]-f[11]),L=new m(f[6]-f[9],f[7]-f[10],f[8]-f[11]),M=new m;l=new Float64Array(3*Et.length),h=new Float32Array(3*Et.length),c=new Float32Array(3*Et.length);for(let R=0;R<Et.length;R++){let z=Et[R].y+x,F=Et[R].x+y,P=F*u,D=z*u;M=z+F<v?E.scaleTo(P).addA(C.scaleTo(D)).addA(w):L.scaleTo(1-P).addA(T.scaleTo(1-D)).addA(b),m.doubleToTwoFloats(M,Ki,Ji);let k=3*R;l[k]=M.x,l[k+1]=M.y,l[k+2]=M.z,h[k]=Ki.x,h[k+1]=Ki.y,h[k+2]=Ki.z,c[k]=Ji.x,c[k+1]=Ji.y,c[k+2]=Ji.z,M.x<ae.xmin&&(ae.xmin=M.x),M.x>ae.xmax&&(ae.xmax=M.x),M.y<ae.ymin&&(ae.ymin=M.y),M.y>ae.ymax&&(ae.ymax=M.y),M.z<ae.zmin&&(ae.zmin=M.z),M.z>ae.zmax&&(ae.zmax=M.z)}}if(t.readyToEngage=!0,t.terrainVertices=l,t.terrainVerticesHigh=h,t.terrainVerticesLow=c,t.tempVertices=l,t.tempVerticesHigh=h,t.tempVerticesLow=c,t.noDataVertices=d,t.setBoundingVolume(ae.xmin,ae.ymin,ae.zmin,ae.xmax,ae.ymax,ae.zmax),t.tileZoom>t.planet.terrain.maxZoom&&i.segment.tileZoom>=t.planet.terrain.maxZoom&&(t._plainRadius=i.segment._plainRadius/r,t.terrainReady=!0,t.terrainIsLoading=!1,t.terrainVertices=l,t.terrainVerticesHigh=h,t.terrainVerticesLow=c,t.passReady=!0,this.appliedTerrainNodeId=this.nodeId,this.equalizedSideWithNodeId[0]=this.equalizedSideWithNodeId[1]=this.equalizedSideWithNodeId[2]=this.equalizedSideWithNodeId[3]=this.appliedTerrainNodeId,i.segment.terrainExists)){t.normalMapVertices=l,t.fileGridSize=Math.sqrt(l.length/3)-1;let f=Math.sqrt(o.normalMapNormals.length/3)-1,p=f/r;t.normalMapNormals=f>1?Hs(o.normalMapNormals,f,p*n,p*s,p):o.normalMapNormals}}}destroy(){this.prevState=this.state=0,this.segment.destroySegment();let e=this.neighbors;for(let t=0,i=e.length;t<i;t++){let r=e[t];if(r)for(let s=0;s<r.length;s++){let n=r[s];n&&n.neighbors&&n.clearNeighbors()}}this.neighbors=null,this.parentNode=null,this.sideSizeLog2=null,this.segment=null}clearTree(){const e=this.getState();if(e===0||e===1)this.destroyBranches();else for(let t=0;t<this.nodes.length;t++)this.nodes[t]&&this.nodes[t].clearTree()}clearBranches(){for(let e=0;e<this.nodes.length;e++)this.nodes[e].clearBranches(),this.nodes[e].segment.deleteMaterials()}destroyBranches(){if(this.ready){let e,t=[];for(e=0;e<this.nodes.length;e++)t[e]=this.nodes[e];for(this.ready=!1,this.nodes=[],e=0;e<t.length;e++)t[e].destroyBranches(),t[e].destroy(),t[e]=null;t.length=0,t=null}}traverseTree(e){if(e(this),this.ready)for(let t=0;t<this.nodes.length;t++)this.nodes[t].traverseTree(e)}getOffsetOppositeNeighbourSide(e,t){let i=this,r=e.segment.tileZoom,s=0;for(;i.segment.tileZoom>r;)s+=pl[i.partId][t]/(1<<i.segment.tileZoom-r),i=i.parentNode;return s}}class hs{constructor(e=2048){this._size=e,this._array=new Array(this._size),this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}reset(){this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}clear(){this._array.length=0,this._array=new Array(this._size),this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex,this.length=0}push(e){this.length++,this._array[this._popIndex++]=e}pop(){if(this.length){this.length--;let e=this._array[--this._popIndex];return this._array[this._popIndex]=null,this._array[this._popIndex-1]||(this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex),e}}unshift(e){this.length++,this._array[--this._shiftIndex]=e}shift(){if(this.length){this.length--;let e=this._array[this._shiftIndex];return this._array[this._shiftIndex++]=null,this._array[this._shiftIndex]||(this._popIndex=Math.floor(.5*this._size),this._shiftIndex=this._popIndex),e}}forEach(e){for(let t=this._shiftIndex;t<this._popIndex;t++)e(this._array[t])}}class so{constructor(e,t,i){this.quadTreeStrategy=e,this._layer=t,this._nodeCapacity=i,this._secondPASS=[],this._counter=0,this._deferredEntitiesPendingQueue=new hs,this._renderingNodes={}}insertEntity(e,t=!1){}setPickingEnabled(e){}dispose(){}insertEntities(e){}collectVisibleEntityCollections(e){}_queueDeferredNode(e){this._layer.getVisibility()&&(e._inTheQueue=!0,this._counter>=1?this._deferredEntitiesPendingQueue.push(e):this._execDeferredNode(e))}_execDeferredNode(e){this._counter++,requestAnimationFrame(()=>{if(e.applyCollection(),this._counter--,this._deferredEntitiesPendingQueue.length&&this._counter<1)for(;this._deferredEntitiesPendingQueue.length;){let t=this._deferredEntitiesPendingQueue.pop();if(t._inTheQueue=!1,t.isVisible())return void this._execDeferredNode(t)}})}}class Lc{constructor(e){this._skipPreRender=!1,this.events=le(Pc),this.name=e.name||"",this.projection=e.proj||ns,this.planet=e.planet,this._quadTreeList=[],this._visibleNodes={},this._renderedNodes=[],this._renderedNodesInFrustum=[],this._fadingNodes=new Map,this._fadingNodesInFrustum=[],this._fadingOpaqueSegments=[],this.minCurrZoom=ye,this.maxCurrZoom=Te,this._viewExtent=new j(new A(180,180),new A(-180,-180)),this._lodSize=256,this._curLodSize=256,this._minLodSize=512,this._maxLodSize=256,this.maxEqualZoomAltitude=e.maxEqualZoomAltitude||15e6,this.minEqualZoomAltitude=e.minEqualZoomAltitude||1e4,this.minEqualZoomCameraSlope=e.minEqualZoomCameraSlope||.8,this._renderCompleted=!1,this._renderCompletedActivated=!1,this._terrainCompleted=!1,this._terrainCompletedActivated=!1,this._transitionOpacityEnabled=e.transitionOpacityEnabled==null||e.transitionOpacityEnabled}get lodSize(){return this._lodSize}setLodSize(e,t,i){this._maxLodSize=i||this._maxLodSize,this._minLodSize=t||this._minLodSize,this._curLodSize=e,this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1}createEntityCollectionsTreeStrategy(e,t){return new so(this,e,t)}destroyBranches(){this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1;for(let e=0,t=this._quadTreeList.length;e<t;e++)this._quadTreeList[e].destroyBranches()}clearLayerMaterial(e){let t=e.__id;for(let i=0,r=this._quadTreeList.length;i<r;i++)this._quadTreeList[i].traverseTree(function(s){let n=s.segment.materials;n[t]&&(n[t].clear(),n[t]=null)})}get terrainReady(){return this._terrainCompleted&&this._terrainCompletedActivated}_checkRendercompleted(){this._renderCompleted?this._renderCompletedActivated||(this._renderCompletedActivated=!0,this.events.dispatch(this.events.rendercompleted,!0)):this._renderCompletedActivated=!1,this._renderCompleted=!0,this._terrainCompleted?this._terrainCompletedActivated||(this._terrainCompletedActivated=!0,this.events.dispatch(this.events.terraincompleted,!0)):this._terrainCompletedActivated=!1,this._terrainCompleted=!0}_initEvents(){this.planet.renderer.events.on("resize",()=>{this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1}),this.planet.renderer.events.on("postdraw",()=>{this._checkRendercompleted()})}init(e){this._initEvents(),this._renderedNodesInFrustum=new Array(e.frustums.length);for(let t=0,i=this._renderedNodesInFrustum.length;t<i;t++)this._renderedNodesInFrustum[t]=[];this.preRender(),this.clearRenderedNodes(),this.preLoad()}clearRenderedNodes(){this._clearRenderedNodeList(),this._clearRenderNodesInFrustum()}_clearRenderedNodeList(){this._renderedNodes.length=0,this._renderedNodes=[]}_clearRenderNodesInFrustum(){for(let e=0,t=this._renderedNodesInFrustum.length;e<t;e++)this._renderedNodesInFrustum[e].length=0,this._renderedNodesInFrustum[e]=[]}_collectRenderedNodesMaxZoom(e){if(e.slope>this.minEqualZoomCameraSlope&&e._lonLat.height<this.maxEqualZoomAltitude&&e._lonLat.height>this.minEqualZoomAltitude){this.minCurrZoom=this.maxCurrZoom;let t=this._renderedNodes,i=this._renderedNodesInFrustum,r=[];this._clearRenderNodesInFrustum(),this._renderedNodes=[];for(let s=0,n=t.length;s<n;s++){let o=t[s],l=o.segment.centerNormal.dot(e.getBackward());if(o.segment.tileZoom===this.maxCurrZoom||l<.81){this._renderedNodes.push(o);let h=0,c=o.inFrustum;for(;c;)1&c&&i[h].push(o),h++,c>>=1}else r.push(o)}for(let s=0,n=r.length;s<n;s++)r[s].renderTree(e,this.maxCurrZoom,null,!1,r[s])}}set transitionOpacityEnabled(e){this._transitionOpacityEnabled=e}get transitionOpacityEnabled(){return this._transitionOpacityEnabled}collectRenderNodes(e){if(this._skipPreRender&&(this._lodSize=Es(e.slope<0?0:e.slope,this._curLodSize,this._minLodSize),e._insideSegment=null,this._clearRenderedNodeList(),this._clearRenderNodesInFrustum(),this._viewExtent.southWest.set(180,180),this._viewExtent.northEast.set(-180,-180),this.minCurrZoom=ye,this.maxCurrZoom=Te,this._collectRenderNodes(e),this._collectRenderedNodesMaxZoom(e),this._fadingNodes.clear(),this._transitionOpacityEnabled)){let t=[];for(let i=0;i<this._renderedNodes.length;i++){let r=this._renderedNodes[i];if(r._collectFadingNodes(),r._refreshTransitionOpacity(),r.segment._transitionOpacity>=1)r.clearNeighbors(),r.getRenderedNodesNeighbors(t),t.push(r);else for(let s=0;s<r._fadingNodes.length;s++){let n=r._fadingNodes[s];n.segment&&n.segment._transitionOpacity>=1&&(n.clearNeighbors(),n.getRenderedNodesNeighbors(t),t.push(n))}}}this._skipPreRender=!0}preRender(){this._skipPreRender=!1;for(let e=0;e<this._quadTreeList.length;e++){let t=this._quadTreeList[e];t.createChildNodes(),t.segment.createPlainSegment();for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment.createPlainSegment()}}preLoad(){for(let e=0;e<this._quadTreeList.length;e++){let t=this._quadTreeList[e];t.segment.passReady=!0,t.renderNode(1),this.planet.normalMapCreator.drawSingle(t.segment);for(let i=0;i<t.nodes.length;i++)t.nodes[i].segment.passReady=!0,t.nodes[i].renderNode(1),this.planet._normalMapCreator.drawSingle(t.nodes[i].segment)}}_clearVisibleNodes(){this._visibleNodes={}}_collectRenderNodes(e){this._clearVisibleNodes();for(let t=0;t<this._quadTreeList.length;t++)this._quadTreeList[t].renderTree(e,0,null)}clear(){for(let e=0;e<this._quadTreeList.length;e++)this._quadTreeList[e].clearTree()}get quadTreeList(){return this._quadTreeList}getTileXY(e,t){let i,r,s=t,n=1<<s;return i=We(e.lon,360/n,-180),r=We(e.lat,180/n,90),[i,r,s,0]}getLonLatTileOffset(e,t,i,r,s){let n;n=as(t,i,r,j.createFromArray([-180,-90,180,90]));let o=n.getWidth()/(s-1),l=n.getHeight()/(s-1);return[s-Math.ceil((e.lat-n.southWest.lat)/l)-1,Math.floor((e.lon-n.southWest.lon)/o)]}collectVisibleNode(e){this._visibleNodes[e.nodeId]=e}}const Pc=["rendercompleted","terraincompleted"],no=new ss({code:"epsg:4326",units:io}),ao=(90-de)/Math.pow(2,7);class oo extends ro{constructor(e,t,i,r){super(e,t,i,r),this._projection=no,this._extentLonLat=this._extent,this._extentMerc=new j(r.southWest.forwardMercatorEPS01(),r.northEast.forwardMercatorEPS01()),this._isNorth=this._extent.northEast.lat>0,this.isPole=!0}_setExtentLonLat(){this._extentLonLat=this._extent}projectNative(e){return e}getInsideLonLat(e){return e._lonLat}_getMaxZoom(){let e;if(this._isNorth){let t=Math.floor((90-this._extent.northEast.lat)/ao);e=Math.floor(t/16)+7}else{let t=Math.floor((Oe-this._extent.northEast.lat)/ao);e=12-Math.floor(t/16)}return e}checkZoom(){return super.checkZoom()&&this.tileZoom<=this._getMaxZoom()}_assignTileIndexes(){this._assignTileXIndexes(this._extent),this._assignTileYIndexes(this._extent),this.tileIndex=Ye.getTileIndex(this.tileX,this.tileY,this.tileZoom,this._tileGroup)}_assignTileXIndexes(e){this.tileX=We(e.getCenter().lon,e.getWidth(),-180);let t=1<<this.tileZoom;this.tileXE=(this.tileX+1)%t,this.tileXW=(t+this.tileX-1)%t}_assignTileYIndexes(e){const t=e.getCenter().lat;t>0?(this._tileGroup=20,this.tileY=We(t,e.getHeight(),90)):(this._tileGroup=wt,this.tileY=We(t,e.getHeight(),Oe)),this.tileYN=this.tileY-1,this.tileYS=this.tileY+1}_projToDeg(e,t){return new A(e,t)}_assignGlobalTextureCoordinates(){const e=this._extent;this._globalTextureCoordinates[0]=(e.southWest.lon+180)/360,this._globalTextureCoordinates[1]=(90-e.northEast.lat)/180,this._globalTextureCoordinates[2]=(e.northEast.lon+180)/360,this._globalTextureCoordinates[3]=(90-e.southWest.lat)/180}_getLayerExtentOffset(e){const t=e._extent,i=this._extent,r=t.northEast.lon-t.southWest.lon,s=t.northEast.lat-t.southWest.lat;return[(i.southWest.lon-t.southWest.lon)/r,(t.northEast.lat-i.northEast.lat)/s,(i.northEast.lon-i.southWest.lon)/r,(i.northEast.lat-i.southWest.lat)/s]}layerOverlap(e){return this._extent.overlaps(e._extent)}getDefaultTexture(){return this._isNorth?this.planet.solidTextureOne:this.planet.solidTextureTwo}getExtentLonLat(){return this._extent}}class At{constructor(e,t,i,r,s,n){this.strategy=e,this.layer=e._layer,this.parentNode=i,this.childNodes=[],this.partId=t,this.nodeId=t+(i?4*i.nodeId+1:0),this.state=null,this.extent=r,this.count=0,this.deferredEntities=[],this.entityCollection=null,this.zoom=n,this._inTheQueue=!1,this.bsphere=new He,s&&this._setExtentBounds()}insertEntity(e,t=!1){this.buildTree([e],t)}_addEntitiesToCollection(e,t=!1){if(e.length){const i=this.layer,r=i._planet;let s=this.entityCollection;s||(s=new ut({pickingEnabled:i._pickingEnabled,labelMaxLetters:i.labelMaxLetters}),s._layer=this.layer,s.addTo(r,!0),s._quadNode=this,i._bindEventsDefault(s),this.entityCollection=s),t||!i.async?this.entityCollection.addEntities(e):this.deferredEntities.push.apply(this.deferredEntities,e)}}_setExtentBounds(){this.nodeId?this.bsphere.setFromExtent(this.layer._planet.ellipsoid,this.extent.inverseMercator()):(this.bsphere.radius=this.layer._planet.ellipsoid.equatorialSize,this.bsphere.center=new m)}__setLonLat__(e){return e._lonLat.isZero()&&!e._cartesian.isZero()&&(e._lonLat=this.layer._planet.ellipsoid.cartesianToLonLat(e._cartesian)),Math.abs(e._lonLat.lat)<de?e._lonLatMerc=e._lonLat.forwardMercator():e._lonLatMerc=new A,e._lonLatMerc}buildTree(e,t=!1){if(this.count+=e.length,e.length>this.layer._nodeCapacity){const i=this.childNodes;i.length||this.createChildNodes();let r=[],s=[],n=[],o=[],l=e.length;for(;l--;){const h=e[l];i[0].isInside(h)?(h._nodePtr=i[0],r.push(h)):i[1].isInside(h)?(h._nodePtr=i[1],s.push(h)):i[2].isInside(h)?(h._nodePtr=i[2],n.push(h)):i[3].isInside(h)&&(h._nodePtr=i[3],o.push(h))}r.length&&i[0].buildTree(r,t),s.length&&i[1].buildTree(s,t),n.length&&i[2].buildTree(n,t),o.length&&i[3].buildTree(o,t)}else this._addEntitiesToCollection(e,t)}isInside(e){return!!e._lonLatMerc&&this.extent.isInside(e._lonLatMerc)}createChildNodes(){const e=this.strategy,t=this.extent,i=.5*t.getWidth(),r=.5*t.getHeight(),s=t.northEast,n=t.southWest,o=new A(n.lon+i,n.lat+r),l=this.childNodes,h=this.layer._planet,c=this.zoom+1;l[0]=new At(e,0,this,new j(new A(n.lon,n.lat+r),new A(n.lon+i,s.lat)),h,c),l[1]=new At(e,1,this,new j(o,new A(s.lon,s.lat)),h,c),l[2]=new At(e,2,this,new j(new A(n.lon,n.lat),o),h,c),l[3]=new At(e,3,this,new j(new A(n.lon+i,n.lat),new A(s.lon,n.lat+r)),h,c)}collectRenderCollectionsPASS1(e,t){const i=e[this.nodeId];if(i){const r=this.childNodes;this.entityCollection?this.renderCollection(t,e):r.length&&(i.state===1?this.strategy._secondPASS.push(this):(r[0].collectRenderCollectionsPASS1(e,t),r[1].collectRenderCollectionsPASS1(e,t),r[2].collectRenderCollectionsPASS1(e,t),r[3].collectRenderCollectionsPASS1(e,t)))}}collectRenderCollectionsPASS2(e,t,i){const r=this.layer._planet.camera,s=r.eye.distance(this.bsphere.center)-this.bsphere.radius<3570*Math.sqrt(r._lonLat.height)||r._lonLat.height>1e4;if(this.count>0&&s&&r.containsSphere(this.bsphere)){const n=this.childNodes;this.entityCollection?this.renderCollection(t,e,i):n.length&&(n[0].collectRenderCollectionsPASS2(e,t,i),n[1].collectRenderCollectionsPASS2(e,t,i),n[2].collectRenderCollectionsPASS2(e,t,i),n[3].collectRenderCollectionsPASS2(e,t,i))}}applyCollection(){this.entityCollection.addEntities(this.deferredEntities),this.deferredEntities.length=0,this.deferredEntities=[],this._inTheQueue=!1}traverseTree(e){const t=this.childNodes;this.entityCollection?e(this):t.length&&(t[0].traverseTree(e),t[1].traverseTree(e),t[2].traverseTree(e),t[3].traverseTree(e))}renderCollection(e,t,i){const r=this.strategy;r._renderingNodes[this.nodeId]=!0,this.deferredEntities.length&&!this._inTheQueue&&(this.layer.async?r._queueDeferredNode(this):this.applyCollection());let s=this.entityCollection,n=this.layer;if(s._fadingOpacity=n._fadingOpacity,s.scaleByDistance=n.scaleByDistance,s.pickingScale=n.pickingScale,s.polygonOffsetUnits=n.polygonOffsetUnits,e.push(s),n.clampToGround||n.relativeToGround){const o=s._entities;let l=o.length;if(t[this.nodeId]&&t[this.nodeId].state===1)for(;l--;){let h=o[l];this.alignEntityToTheGround(h,t[this.nodeId].segment)}else if(i)for(;l--;){let h=o[l];this.alignEntityToTheGround(h,t[i].segment)}else{const h=this.strategy.quadTreeStrategy._renderedNodes;for(;l--;){let c=o[l],d=h.length;for(;d--;)if(h[d].segment.isEntityInside(c)){this.alignEntityToTheGround(c,h[d].segment);break}}}}}alignEntityToTheGround(e,t){let i=new m;t.getEntityTerrainPoint(e,i);let r=Number(this.layer.relativeToGround)&&e._altitude||0;if(r){let s=this.layer._planet.ellipsoid.getSurfaceNormal3v(i);e._setCartesian3vSilent(i.addA(s.scale(r)))}else e._setCartesian3vSilent(i)}isVisible(){return!!this.strategy._renderingNodes[this.nodeId]}}class Lt extends At{constructor(e,t,i,r,s,n){super(e,t,i,r,s,n),this.strategy=e,this.isNorth=!1}createChildNodes(){const e=this.strategy,t=this.extent,i=.5*t.getWidth(),r=.5*t.getHeight(),s=t.northEast,n=t.southWest,o=new A(n.lon+i,n.lat+r),l=this.childNodes,h=this.layer._planet,c=this.zoom+1;l[0]=new Lt(e,0,this,new j(new A(n.lon,n.lat+r),new A(n.lon+i,s.lat)),h,c),l[1]=new Lt(e,1,this,new j(o,new A(s.lon,s.lat)),h,c),l[2]=new Lt(e,2,this,new j(new A(n.lon,n.lat),o),h,c),l[3]=new Lt(e,3,this,new j(new A(n.lon+i,n.lat),new A(s.lon,n.lat+r)),h,c)}_setExtentBounds(){this.extent.northEast.lat>0&&(this.isNorth=!0),this.bsphere.setFromExtent(this.layer._planet.ellipsoid,this.extent)}__setLonLat__(e){return e._lonLat.isZero()&&(e._lonLat=this.layer._planet.ellipsoid.cartesianToLonLat(e._cartesian)),e._lonLat}isVisible(){return!(!this.isNorth||!this.strategy._renderingNodesNorth[this.nodeId])||!!this.strategy._renderingNodesSouth[this.nodeId]}isInside(e){return this.extent.isInside(e._lonLat)}renderCollection(e,t,i){this.isNorth?this.strategy._renderingNodesNorth[this.nodeId]=!0:this.strategy._renderingNodesSouth[this.nodeId]=!0,this.deferredEntities.length&&!this._inTheQueue&&(this.layer.async?this.strategy._queueDeferredNode(this):this.applyCollection());const r=this.entityCollection;r._fadingOpacity=this.layer._fadingOpacity,r.scaleByDistance=this.layer.scaleByDistance,r.pickingScale=this.layer.pickingScale,r.isEmpty()||e.push(r)}}class Sc extends so{constructor(e,t,i){super(e,t,i);let r=t._planet;this._entityCollectionsTree=new At(this,0,null,j.createFromArray([-2003750834e-2,-2003750834e-2,2003750834e-2,2003750834e-2]),r,0),this._entityCollectionsTreeNorth=new Lt(this,0,null,j.createFromArray([-180,de,180,90]),r,0),this._entityCollectionsTreeSouth=new Lt(this,0,null,j.createFromArray([-180,-90,180,Oe]),r,0),this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={}}insertEntity(e,t=!1){e._lonLat.lat>de?(this._entityCollectionsTreeNorth.__setLonLat__(e),this._entityCollectionsTreeNorth.insertEntity(e,t)):e._lonLat.lat<Oe?(this._entityCollectionsTreeSouth.__setLonLat__(e),this._entityCollectionsTreeSouth.insertEntity(e,t)):(this._entityCollectionsTree.__setLonLat__(e),this._entityCollectionsTree.insertEntity(e,t))}setPickingEnabled(e){this._entityCollectionsTree&&this._entityCollectionsTree.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)}),this._entityCollectionsTreeNorth&&this._entityCollectionsTreeNorth.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)}),this._entityCollectionsTreeSouth&&this._entityCollectionsTreeSouth.traverseTree(t=>{t.entityCollection.setPickingEnabled(e)})}dispose(){this._entityCollectionsTree=null,this._entityCollectionsTreeNorth=null,this._entityCollectionsTreeSouth=null,this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={}}insertEntities(e){let t=[],i=[],r=[];for(let s=0,n=e.length;s<n;s++){let o=e[s];o._lonLat.lat>de?(t.push(o),this._entityCollectionsTreeNorth.__setLonLat__(o)):o._lonLat.lat<Oe?(i.push(o),this._entityCollectionsTreeSouth.__setLonLat__(o)):(r.push(o),this._entityCollectionsTree.__setLonLat__(o))}this._entityCollectionsTree.buildTree(r),this._entityCollectionsTreeNorth.buildTree(t),this._entityCollectionsTreeSouth.buildTree(i)}collectVisibleEntityCollections(e){this._renderingNodes={},this._renderingNodesNorth={},this._renderingNodesSouth={};let t=this._layer._planet.quadTreeStrategy;this._secondPASS=[],this._entityCollectionsTree.collectRenderCollectionsPASS1(t._visibleNodes,e);let i=this._secondPASS.length;for(;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodes,e,this._secondPASS[i].nodeId);for(this._secondPASS=[],this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(t._visibleNodesNorth,e),i=this._secondPASS.length;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodesNorth,e,this._secondPASS[i].nodeId);for(this._secondPASS=[],this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(t._visibleNodesSouth,e),i=this._secondPASS.length;i--;)this._secondPASS[i].collectRenderCollectionsPASS2(t._visibleNodesSouth,e,this._secondPASS[i].nodeId)}}class Mc extends Lc{constructor(e){super({name:"Earth",...e}),this._visibleNodesNorth={},this._visibleNodesSouth={}}collectVisibleNode(e){let t=e.segment._tileGroup;t===20?this._visibleNodesNorth[e.nodeId]=e:t===wt?this._visibleNodesSouth[e.nodeId]=e:this._visibleNodes[e.nodeId]=e}_clearVisibleNodes(){super._clearVisibleNodes(),this._visibleNodesNorth={},this._visibleNodesSouth={}}createEntityCollectionsTreeStrategy(e,t){return new Sc(this,e,t)}init(e){this._quadTreeList=[new ft(ro,this,0,null,0,j.createFromArray([-2003750834e-2,-2003750834e-2,2003750834e-2,2003750834e-2])),new ft(oo,this,0,null,0,j.createFromArray([-180,de,180,90])),new ft(oo,this,0,null,0,j.createFromArray([-180,-90,180,Oe]))],super.init(e)}getTileXY(e,t){let i,r,s=function(l,h=de){return l>h?20:l<-h?wt:0}(e.lat,de),n=t,o=1<<n;if(s===20)i=We(e.lon,360/o,-180),r=We(e.lat,(90-de)/o,90);else if(s===wt)i=We(e.lon,360/o,-180),r=We(e.lat,(90-de)/o,Oe);else{let l=Ii(e);i=We(l.lon,Bi/o,-2003750834e-2),r=We(l.lat,Bi/o,Ee)}return[i,r,n,s]}getLonLatTileOffset(e,t,i,r,s){let n,o=e;e.lat>de?n=as(t,i,r,j.createFromArray([-180,de,180,90])):e.lat<Oe?n=as(t,i,r,j.createFromArray([-180,-90,180,Oe])):(o=Ii(e),n=Bt(t,i,r));let l=n.getWidth()/(s-1),h=n.getHeight()/(s-1);return[s-Math.ceil((o.lat-n.southWest.lat)/h)-1,Math.floor((o.lon-n.southWest.lon)/l)]}}class lo{constructor(e={}){this.model=e.model||null,this.src=e.src||null,this._cached_ix=0,this._cached_iy=0,this._v00=0,this._v01=0,this._v10=0,this._v11=0,this._t=0}static loadModel(e){return e?fetch(e,{}).then(t=>{if(!t.ok)throw Error("Geoid model file: HTTP error "+t.status);return t.arrayBuffer()}).then(t=>{if(t)return new Uint8Array(t);throw Error("Geoid model file: no data from "+e)}).then(function(t){if(t[0]!==80||t[1]!==53||(t[2]!==13||t[3]!==10)&&t[2]!==10)throw new Error("Geoid model file: no PGM header");var i,r,s=t[2]===13?4:3,n=null,o=null;function l(){let d=s;for(var u=s;;u++){if(u>=t.length)throw new Error("Geoid model file: missing newline in header");if(t[u]===10){s=u+1;break}}return u>d&&t[u-1]===13&&u--,String.fromCharCode.apply(null,t.slice(d,u))}for(;(r=l())[0]==="#";)if(i=r.match(/^# Offset (.*)$/)){if(n=parseInt(i[1],10),!isFinite(n))throw new Error("Geoid model file: bad offset "+i[1])}else if((i=r.match(/^# Scale (.*)$/))&&(o=parseFloat(i[1]),!isFinite(o)))throw new Error("Geoid model file: bad scale "+i[1]);let h=0,c=0;if((i=r.match(/^\s*(\d+)\s+(\d+)\s*$/))&&(h=parseInt(i[1],10),c=parseInt(i[2],10)),!(i&&h>=0&&c>=0))throw new Error("Geoid model file: bad PGM width&height line");if(parseInt(l())!=65535)throw new Error("Geoid model file: PGM file must have 65535 gray levels");if(n===null)throw new Error("Geoid model file: PGM file does not contain offset");if(o===null)throw new Error("Geoid model file: PGM file does not contain scale");if(h<2||c<2)throw new Error("Geoid model file: Raster size too small");if(t.length-s!=h*c*2)throw new Error("Geoid model file: File has the wrong length");return{scale:o,offset:n,width:h,height:c,rlonres:h/360,rlatres:(c-1)/180,i:s,rawfile:t}}):new Promise(t=>{t(null)})}setModel(e){this.model=e}_rawval(e,t){let i=this.model;t<0?(t=-t,e+=i.width/2):t>=i.height&&(t=2*(i.height-1)-t,e+=i.width/2),e<0?e+=i.width:e>=i.width&&(e-=i.width);let r=2*(t*i.width+e)+i.i;return i.rawfile[r]<<8|i.rawfile[r+1]}getHeightLonLat(e){return this.getHeight(e.lon,e.lat)}getHeight(e,t){if(!this.model)return 0;let i=this.model;e<0&&(e+=360);let r=(90-t)*i.rlatres,s=e*i.rlonres,n=Math.floor(r),o=Math.floor(s);s-=o,r-=n,n===i.height-1&&n--,this._cached_ix===o&&this._cached_iy===n||(this._cached_ix=o,this._cached_iy=n,this._v00=this._rawval(o,n),this._v01=this._rawval(o+1,n),this._v10=this._rawval(o,n+1),this._v11=this._rawval(o+1,n+1));let l=(1-r)*((1-s)*this._v00+s*this._v01)+r*((1-s)*this._v10+s*this._v11);return i.offset+i.scale*l}}class Rc{constructor(e,t=5){this.MAX_FRAMES=t,this._gridSize=64,this._planet=e,this._framebuffer=null,this._framebufferMercProj=null,this._texCoordsBuffer=null,this._indexBuffer=null,this._currentFrame=0,this._queue=[],this._animate=[],this._quadTexCoordsBuffer=null,this._quadVertexBuffer=null}init(){this._initShaders(),this._initBuffers()}createGridBuffer(e,t=!1){let i=this._gridSize,r=new A((e[3].lon-e[0].lon)/i,(e[3].lat-e[0].lat)/i),s=new A((e[2].lon-e[1].lon)/i,(e[2].lat-e[1].lat)/i),n=new A((e[1].lon-e[0].lon)/i,(e[1].lat-e[0].lat)/i),o=new A((e[2].lon-e[3].lon)/i,(e[2].lat-e[3].lat)/i);const l=(i+1)*(i+1)*2,h=l/2;let c=new Float32Array(l),d=new Float32Array(l),u=new Array(h),g=0,f=0,p=0,_=new Float32Array(2);for(let v=0;v<=i;v++){let x=new A(e[0].lon+v*r.lon,e[0].lat+v*r.lat),y=new A(e[1].lon+v*s.lon,e[1].lat+v*s.lat);for(let w=0;w<=i;w++){let b=Os(x,y,new A(e[0].lon+w*n.lon,e[0].lat+w*n.lat),new A(e[3].lon+w*o.lon,e[3].lat+w*o.lat));lt(b.lon,_),c[g++]=_[0],d[f++]=_[1],lt(b.lat,_),c[g++]=_[0],d[f++]=_[1],u[p++]=b}}if(t)for(let v=0;v<h;v++){let x=u[v].forwardMercator();lt(x.lon,_),c[2*v]=_[0],d[2*v]=_[1],lt(x.lat,_),c[2*v+1]=_[0],d[2*v+1]=_[1]}return[this._planet.renderer.handler.createArrayBuffer(c,2,h),this._planet.renderer.handler.createArrayBuffer(d,2,h)]}frame(){let e=this.MAX_FRAMES;for(;e--&&this._queue.length;){const t=this._queue.shift();t._isRendering=!1,t.rendering(),t.events.dispatch(t.events.loadend)}for(e=this._animate.length;e--;)this._animate[e].rendering()}add(e){e._isRendering||(e._isRendering=!0,e._animate?this._animate.push(e):this._queue.push(e))}remove(e){if(e._isRendering){let t;e._creationProceeding=!1,e._isRendering=!1,t=e._animate?this._animate:this._queue;for(let i=0;i<t.length;i++)if(t[i].isEqual(e))return void t.splice(i,1)}}_initBuffers(){let e=this._planet.renderer.handler;this._framebuffer=new Se(e,{width:2,height:2,useDepth:!1}),this._framebuffer.init(),this._framebufferMercProj=new Se(e,{width:2,height:2,useDepth:!1}),this._framebufferMercProj.init();let t=Math.log2(this._gridSize);this._texCoordsBuffer=this._planet._textureCoordsBufferCache[t],this._indexBuffer=this._planet._indexesCache[t][t][t][t][t].buffer,this._quadTexCoordsBuffer=e.createArrayBuffer(new Float32Array([0,1,1,1,0,0,1,0]),2,4),this._quadVertexBuffer=e.createArrayBuffer(new Float32Array([-1,1,1,1,-1,-1,1,-1]),2,4)}_initShaders(){this._planet.renderer.handler.addProgram(new X("geoImageTransform",{uniforms:{sourceTexture:"sampler2d",extentParamsHigh:"vec4",extentParamsLow:"vec4",isFullExtent:"bool"},attributes:{cornersHigh:"vec2",cornersLow:"vec2",texCoords:"vec2"},vertexShader:`attribute vec2 cornersHigh;
662
662
  attribute vec2 cornersLow;
663
663
  attribute vec2 texCoords;
664
664
  uniform vec4 extentParamsHigh;
@@ -679,7 +679,7 @@ precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in
679
679
  discard;
680
680
  }
681
681
  gl_FragColor = texture2D(sourceTexture, v_texCoords);
682
- }`}))}}const Bc=["loadend","layerloadend"];class la{constructor(e=24){this.MAX_REQUESTS=e,this.events=he(Bc),this._loading=0,this._queue=[],this._senderRequestCounter=[],this._promises={json:t=>t.json(),blob:t=>t.blob(),arrayBuffer:t=>t.arrayBuffer(),imageBitmap:t=>t.blob().then(i=>createImageBitmap(i,{premultiplyAlpha:"premultiply"})),text:t=>t.text()}}load(e,t){e.sender&&(this._senderRequestCounter[e.sender.__id]||(this._senderRequestCounter[e.sender.__id]={sender:e.sender,counter:0,__requestCounterFrame__:0}),this._senderRequestCounter[e.sender.__id].counter++),this._queue.push({params:e,callback:t}),this._exec()}fetch(e){return fetch(e.src,e.options||{}).then(t=>{if(!t.ok)throw Error(`Unable to load '${e.src}'`);return this._promises[e.type||"blob"](t)}).then(t=>({status:"ready",data:t})).catch(t=>({status:"error",msg:t.toString()}))}getRequestCounter(e){if(e){let t=this._senderRequestCounter[e.__id];if(t)return t.counter}return 0}isIdle(e){return e.isIdle}_checkLoadend(e,t){e.counter!==0||t._planet&&!t._planet._terrainCompletedActivated?e.__requestCounterFrame__=requestAnimationFrame(()=>{this._checkLoadend(e,t)}):(t.events.dispatch(t.events.loadend,t),this.events.dispatch(this.events.layerloadend,t),e.__requestCounterFrame__=0)}_handleResponse(e,t){e.callback(t);let i=e.params.sender;if(i&&(i.events.loadend.handlers.length||this.events.layerloadend.handlers.length)){let s=this._senderRequestCounter[i.__id];s&&s.counter>0&&(s.counter--,cancelAnimationFrame(s.__requestCounterFrame__),s.__requestCounterFrame__=requestAnimationFrame(()=>{this._checkLoadend(s,i)}))}this._exec()}_exec(){if(this._queue.length>0&&this._loading<this.MAX_REQUESTS){let e=this._queue.pop();if(!e)return;let t=e.params;if(!t.filter||t.filter(t))return this._loading++,fetch(t.src,t.options||{}).then(i=>{if(!i.ok)throw Error(`Unable to load '${t.src}'`);return this._promises[t.type||"blob"](i)}).then(i=>{this._loading--,this._handleResponse(e,{status:"ready",data:i})}).catch(i=>{this._loading--,this._handleResponse(e,{status:"error",msg:i.toString()})});this._handleResponse(e,{status:"abort"})}else this._loading===0&&this.events.dispatch(this.events.loadend)}abort(e){this._senderRequestCounter[e.__id]&&(this._senderRequestCounter[e.__id].counter=0,cancelAnimationFrame(this._senderRequestCounter[e.__id].__requestCounterFrame__),this._senderRequestCounter[e.__id].__requestCounterFrame__=0);for(let t=0,i=this._queue.length;t<i;t++){let s=this._queue[t];s&&s.params.sender&&e.isEqual(s.params.sender)&&(s.callback({status:"abort"}),this._queue[t]=null)}}abortAll(){for(let e=0,t=this._queue.length;e<t;e++){let i=this._queue[e];if(i){let s=i.params.sender;s&&this._senderRequestCounter[s.__id]&&(this._senderRequestCounter[s.__id].counter=0,cancelAnimationFrame(this._senderRequestCounter[s.__id].__requestCounterFrame__),this._senderRequestCounter[s.__id].__requestCounterFrame__=0),i.callback({status:"abort"}),this._queue[e]=null}}this._queue=[]}get loading(){return this._loading}get queue(){return this._queue}}class kc{constructor(e,t={}){this._minTabelSize=t.minTableSize||1,this._maxTableSize=t.maxTableSize||8,this._planet=e,this._handler=null,this._verticesBufferArray=[],this._indexBufferArray=[],this._positionBuffer=null,this._framebuffer=null,this._normalMapVerticesTexture=null,this._width=t.width||128,this._height=t.height||128,this._queue=new lr(1024),this._lock=new Os}get width(){return this._width}get height(){return this._height}init(){this._maxTableSize=this._planet.maxGridSize||8,this._handler=this._planet.renderer.handler;const e=new X("normalMapBlur",{attributes:{a_position:"vec2"},uniforms:{s_texture:"sampler2d"},vertexShader:`attribute vec2 a_position;
682
+ }`}))}}const Bc=["loadend","layerloadend"];class ho{constructor(e=24){this.MAX_REQUESTS=e,this.events=le(Bc),this._loading=0,this._queue=[],this._senderRequestCounter=[],this._promises={json:t=>t.json(),blob:t=>t.blob(),arrayBuffer:t=>t.arrayBuffer(),imageBitmap:t=>t.blob().then(i=>createImageBitmap(i,{premultiplyAlpha:"premultiply"})),text:t=>t.text()}}load(e,t){e.sender&&(this._senderRequestCounter[e.sender.__id]||(this._senderRequestCounter[e.sender.__id]={sender:e.sender,counter:0,__requestCounterFrame__:0}),this._senderRequestCounter[e.sender.__id].counter++),this._queue.push({params:e,callback:t}),this._exec()}fetch(e){return fetch(e.src,e.options||{}).then(t=>{if(!t.ok)throw Error(`Unable to load '${e.src}'`);return this._promises[e.type||"blob"](t)}).then(t=>({status:"ready",data:t})).catch(t=>({status:"error",msg:t.toString()}))}getRequestCounter(e){if(e){let t=this._senderRequestCounter[e.__id];if(t)return t.counter}return 0}isIdle(e){return e.isIdle}_checkLoadend(e,t){e.counter===0&&(!t._planet||t.quadTreeStrategy&&t.quadTreeStrategy._terrainCompletedActivated)?(t.events.dispatch(t.events.loadend,t),this.events.dispatch(this.events.layerloadend,t),e.__requestCounterFrame__=0):e.__requestCounterFrame__=requestAnimationFrame(()=>{this._checkLoadend(e,t)})}_handleResponse(e,t){e.callback(t);let i=e.params.sender;if(i&&(i.events.loadend.handlers.length||this.events.layerloadend.handlers.length)){let r=this._senderRequestCounter[i.__id];r&&r.counter>0&&(r.counter--,cancelAnimationFrame(r.__requestCounterFrame__),r.__requestCounterFrame__=requestAnimationFrame(()=>{this._checkLoadend(r,i)}))}this._exec()}_exec(){if(this._queue.length>0&&this._loading<this.MAX_REQUESTS){let e=this._queue.pop();if(!e)return;let t=e.params;if(!t.filter||t.filter(t))return this._loading++,fetch(t.src,t.options||{}).then(i=>{if(!i.ok)throw Error(`Unable to load '${t.src}'`);return this._promises[t.type||"blob"](i)}).then(i=>{this._loading--,this._handleResponse(e,{status:"ready",data:i})}).catch(i=>{this._loading--,this._handleResponse(e,{status:"error",msg:i.toString()})});this._handleResponse(e,{status:"abort"})}else this._loading===0&&this.events.dispatch(this.events.loadend)}abort(e){this._senderRequestCounter[e.__id]&&(this._senderRequestCounter[e.__id].counter=0,cancelAnimationFrame(this._senderRequestCounter[e.__id].__requestCounterFrame__),this._senderRequestCounter[e.__id].__requestCounterFrame__=0);for(let t=0,i=this._queue.length;t<i;t++){let r=this._queue[t];r&&r.params.sender&&e.isEqual(r.params.sender)&&(r.callback({status:"abort"}),this._queue[t]=null)}}abortAll(){for(let e=0,t=this._queue.length;e<t;e++){let i=this._queue[e];if(i){let r=i.params.sender;r&&this._senderRequestCounter[r.__id]&&(this._senderRequestCounter[r.__id].counter=0,cancelAnimationFrame(this._senderRequestCounter[r.__id].__requestCounterFrame__),this._senderRequestCounter[r.__id].__requestCounterFrame__=0),i.callback({status:"abort"}),this._queue[e]=null}}this._queue=[]}get loading(){return this._loading}get queue(){return this._queue}}class kc{constructor(e,t={}){this._minTabelSize=t.minTableSize||1,this._maxTableSize=t.maxTableSize||8,this._planet=e,this._handler=null,this._verticesBufferArray=[],this._indexBufferArray=[],this._positionBuffer=null,this._framebuffer=null,this._normalMapVerticesTexture=null,this._width=t.width||128,this._height=t.height||128,this._queue=new hs(1024),this._lock=new Nr}get width(){return this._width}get height(){return this._height}init(){this._maxTableSize=this._planet.maxGridSize||8,this._handler=this._planet.renderer.handler;const e=new X("normalMapBlur",{attributes:{a_position:"vec2"},uniforms:{s_texture:"sampler2d"},vertexShader:`attribute vec2 a_position;
683
683
  attribute vec2 a_texCoord;
684
684
 
685
685
  varying vec2 blurCoordinates[5];
@@ -724,11 +724,11 @@ precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in
724
724
 
725
725
  void main () {
726
726
  gl_FragColor = vec4(v_color, 1.0);
727
- }`});this._handler.addProgram(e),this._handler.addProgram(t),this._framebuffer=new Me(this._handler,{width:this._width,height:this._height,useDepth:!1}),this._framebuffer.init(),this._normalMapVerticesTexture=this._handler.createEmptyTexture_l(this._width,this._height);for(let s=this._minTabelSize;s<=this._maxTableSize;s++){const r=1<<s,n=r/2;let o=new Float32Array((r+1)*(r+1)*2);for(let l=0;l<=r;l++)for(let h=0;h<=r;h++){let c=2*(l*(r+1)+h);o[c]=h/n-1,o[c+1]=l/n-1}this._verticesBufferArray[r]=this._handler.createArrayBuffer(o,2,o.length/2),this._indexBufferArray[r]=this._planet._indexesCache[Math.log2(r)][Math.log2(r)][Math.log2(r)][Math.log2(r)][Math.log2(r)].buffer}const i=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this._positionBuffer=this._handler.createArrayBuffer(i,2,i.length/2)}_drawNormalMapBlur(e){let t=e.normalMapNormals;if(e.node&&e.node.getState()!==0&&t&&t.length){const i=t.length/3,s=Math.sqrt(i)-1;let r=this._verticesBufferArray[s];if(r){e.planet.terrain.equalizeNormals&&(e._normalMapEdgeEqualize(0),e._normalMapEdgeEqualize(2),e._normalMapEdgeEqualize(3),e._normalMapEdgeEqualize(1));let n=e.normalMapTexturePtr;const o=this._handler,l=o.gl;let h=o.createArrayBuffer(t,3,i,l.DYNAMIC_DRAW);const c=this._framebuffer;let d=o.programs.normalMap,u=d._program.attributes;return c.bindOutputTexture(this._normalMapVerticesTexture),d.activate(),l.bindBuffer(l.ARRAY_BUFFER,r),l.vertexAttribPointer(u.a_position,r.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,h),l.vertexAttribPointer(u.a_normal,h.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this._indexBufferArray[s]),l.drawElements(l.TRIANGLE_STRIP,this._indexBufferArray[s].numItems,l.UNSIGNED_INT,0),l.deleteBuffer(h),c.bindOutputTexture(n),d=o.programs.normalMapBlur,d.activate(),l.bindBuffer(l.ARRAY_BUFFER,this._positionBuffer),l.vertexAttribPointer(d._program.attributes.a_position,this._positionBuffer.itemSize,l.FLOAT,!1,0,0),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,this._normalMapVerticesTexture),l.uniform1i(d._program.uniforms.s_texture,0),l.drawArrays(l.TRIANGLE_STRIP,0,this._positionBuffer.numItems),!0}return!0}return!1}_drawNormalMapNoBlur(e){let t=e.normalMapNormals;if(e.node&&e.node.getState()!==0&&t&&t.length){const i=t.length/3,s=Math.sqrt(i)-1;let r=this._verticesBufferArray[s];if(r){e.planet.terrain.equalizeNormals&&(e._normalMapEdgeEqualize(0),e._normalMapEdgeEqualize(2),e._normalMapEdgeEqualize(3),e._normalMapEdgeEqualize(1));let n=e.normalMapTexturePtr;const o=this._handler,l=o.gl;let h=o.createArrayBuffer(t,3,i,l.DYNAMIC_DRAW);const c=this._framebuffer,d=o.programs.normalMap,u=d._program.attributes;return c.bindOutputTexture(n),d.activate(),l.bindBuffer(l.ARRAY_BUFFER,r),l.vertexAttribPointer(u.a_position,r.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,h),l.vertexAttribPointer(u.a_normal,h.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this._indexBufferArray[s]),l.drawElements(l.TRIANGLE_STRIP,this._indexBufferArray[s].numItems,l.UNSIGNED_INT,0),l.deleteBuffer(h),!0}return!0}return!1}_drawNormalMap(e){return e.planet.terrain.isBlur(e)?this._drawNormalMapBlur(e):this._drawNormalMapNoBlur(e)}drawSingle(e){const t=this._handler.gl;this._framebuffer.activate(),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.BLEND),e.terrainReady&&this._drawNormalMap(e)&&(e.normalMapReady=!0,e.normalMapTexture=e.normalMapTexturePtr,e.normalMapTextureBias[0]=0,e.normalMapTextureBias[1]=0,e.normalMapTextureBias[2]=1),e._inTheQueue=!1,t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),t.enable(t.BLEND),this._framebuffer.deactivate()}frame(){if(this._queue.length){const e=this._handler.gl;this._framebuffer.activate(),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND);let t=0,i=window.performance.now();for(;this._lock.isFree()&&this._queue.length&&t<.25;){const s=this._queue.shift();s.terrainReady&&this._drawNormalMap(s)&&(s.normalMapReady=!0,s.normalMapTexture=s.normalMapTexturePtr,s.normalMapTextureBias[0]=0,s.normalMapTextureBias[1]=0,s.normalMapTextureBias[2]=1),s._inTheQueue=!1,t=window.performance.now()-i}e.enable(e.BLEND),e.enable(e.DEPTH_TEST),e.enable(e.CULL_FACE),this._framebuffer.deactivate()}}get queueSize(){return this._queue.length}queue(e){e._inTheQueue=!0,this._queue.push(e)}unshift(e){e._inTheQueue=!0,this._queue.unshift(e)}remove(e){}clear(){for(;this._queue.length;)this._queue.pop()._inTheQueue=!1}lock(e){this._lock.lock(e)}free(e){this._lock.free(e)}}const Ic=new sr({code:"equi",units:ta}),ha=`(function(){"use strict";let l=null,K=null,O=null,Q=null,S=null,T=null,U=null;function P(a,t){t<0?(t=-t,a+=l.width/2):t>=l.height&&(t=2*(l.height-1)-t,a+=l.width/2),a<0?a+=l.width:a>=l.width&&(a-=l.width);var n=2*(t*l.width+a)+l.i;return l.rawfile[n]<<8|l.rawfile[n+1]}const sa=.5*Math.PI,W=2003750834e-2,ia=Math.PI/W,ua=180/W,X=180/Math.PI,Ma=X*sa,Y=Math.PI/180,da=2*X;let k=0,Z=0,_=null;const B=function(a,t,n){this.x=a,this.y=t,this.z=n};var $=function(a,t,n,o){let f=function(c,C){if(!l)return 0;c<0&&(c+=360);var w=(90-C)*l.rlatres,M=c*l.rlonres,u=Math.floor(w),d=Math.floor(M);M-=d,w-=u,u===l.height-1&&u--,K===d&&O===u||(K=d,O=u,Q=P(d,u),S=P(d+1,u),T=P(d,u+1),U=P(d+1,u+1));let L=null;return L=(1-w)*((1-M)*Q+M*S)+w*((1-M)*T+M*U),l.offset+l.scale*L}(a,t)*n,h=Y*t,r=Y*a,m=Math.sin(h),x=Z/Math.sqrt(1-k*m*m),H=(x+f)*Math.cos(h);o.x=H*Math.cos(r),o.y=H*Math.sin(r),o.z=(x*(1-k)+f)*m},ma=function(a,t,n,o){$(a*ua,da*Math.atan(Math.exp(t*ia))-Ma,n,o)},e=new B(0,0,0),p=new B(0,0,0),y=new B(0,0,0),pa=function(a,t,n){let o=a.x,f=a.y,h=a.z;var r;o>=0?(r=65536*Math.floor(o/65536),t.x=Math.fround(r),n.x=Math.fround(o-r)):(r=65536*Math.floor(-o/65536),t.x=Math.fround(-r),n.x=Math.fround(o+r)),f>=0?(r=65536*Math.floor(f/65536),t.y=Math.fround(r),n.y=Math.fround(f-r)):(r=65536*Math.floor(-f/65536),t.y=Math.fround(-r),n.y=Math.fround(f+r)),h>=0?(r=65536*Math.floor(h/65536),t.z=Math.fround(r),n.z=Math.fround(h-r)):(r=65536*Math.floor(-h/65536),t.z=Math.fround(-r),n.z=Math.fround(h+r))};self.onmessage=function(a){if(a.data.model)l=a.data.model,l.rawfile=a.data.rawfile;else if(a.data.params){let t=549755748352,n=-549755748352,o=549755748352,f=-549755748352,h=549755748352,r=-549755748352;k=a.data.params[8],Z=a.data.params[9];let m=a.data.params[2],x=a.data.params[3],H=a.data.params[10],c=a.data.params[11],C=a.data.params[12],w=a.data.params[13];_=a.data.params[1]===0?ma:$;let M=Math.max(x,m),u=(a.data.params[6]-a.data.params[4])/M,d=(a.data.params[7]-a.data.params[5])/M,L=a.data.params[4],ya=a.data.params[7],aa=Math.max(x/m,1),N=M+1;const z=N*N,R=(m+1)*(m+1)*3;let b=new Float32Array(R),A=new Float64Array(R),F=new Float32Array(R),g=new Float32Array(R),V=new Float32Array(3*z),q=new Float64Array(3*z),v=new Float32Array(3*z),I=new Float32Array(3*z),s=0,i=0;for(let j=0;j<z;j++){let la=j%N,na=~~(j/N);_(L+la*u,ya-na*d,w,e);let D=e.x*H,E=e.y*c,G=e.z*C,J=1/Math.sqrt(D*D+E*E+G*G),oa=D*J,fa=E*J,ha=G*J;pa(e,p,y),q[i]=e.x,v[i]=p.x,I[i]=y.x,V[i++]=oa,q[i]=e.y,v[i]=p.y,I[i]=y.y,V[i++]=fa,q[i]=e.z,v[i]=p.z,I[i]=y.z,V[i++]=ha,na%aa==0&&la%aa==0&&(A[s]=e.x,F[s]=p.x,g[s]=y.x,b[s++]=oa,A[s]=e.y,F[s]=p.y,g[s]=y.y,b[s++]=fa,A[s]=e.z,F[s]=p.z,g[s]=y.z,b[s++]=ha,e.x<t&&(t=e.x),e.x>n&&(n=e.x),e.y<o&&(o=e.y),e.y>f&&(f=e.y),e.z<h&&(h=e.z),e.z>r&&(r=e.z))}let ta=.5*(n-t),ra=.5*(f-o),ea=.5*(r-h),wa=Math.sqrt(ta*ta+ra*ra+ea*ea);self.postMessage({id:a.data.params[0],plainVertices:A,plainVerticesHigh:F,plainVerticesLow:g,plainNormals:b,normalMapNormals:V,normalMapVertices:q,normalMapVerticesHigh:v,normalMapVerticesLow:I,plainRadius:wa},[A.buffer,F.buffer,g.buffer,b.buffer,V.buffer,q.buffer,v.buffer,I.buffer])}}})();
727
+ }`});this._handler.addProgram(e),this._handler.addProgram(t),this._framebuffer=new Se(this._handler,{width:this._width,height:this._height,useDepth:!1}),this._framebuffer.init(),this._normalMapVerticesTexture=this._handler.createEmptyTexture_l(this._width,this._height);for(let r=this._minTabelSize;r<=this._maxTableSize;r++){const s=1<<r,n=s/2;let o=new Float32Array((s+1)*(s+1)*2);for(let l=0;l<=s;l++)for(let h=0;h<=s;h++){let c=2*(l*(s+1)+h);o[c]=h/n-1,o[c+1]=l/n-1}this._verticesBufferArray[s]=this._handler.createArrayBuffer(o,2,o.length/2),this._indexBufferArray[s]=this._planet._indexesCache[Math.log2(s)][Math.log2(s)][Math.log2(s)][Math.log2(s)][Math.log2(s)].buffer}const i=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this._positionBuffer=this._handler.createArrayBuffer(i,2,i.length/2)}_drawNormalMapBlur(e){let t=e.normalMapNormals;if(e.node&&e.node.getState()!==0&&t&&t.length){const i=t.length/3,r=Math.sqrt(i)-1;let s=this._verticesBufferArray[r];if(s){e.planet.terrain.equalizeNormals&&(e._normalMapEdgeEqualize(0),e._normalMapEdgeEqualize(2),e._normalMapEdgeEqualize(3),e._normalMapEdgeEqualize(1));let n=e.normalMapTexturePtr;const o=this._handler,l=o.gl;let h=o.createArrayBuffer(t,3,i,l.DYNAMIC_DRAW);const c=this._framebuffer;let d=o.programs.normalMap,u=d._program.attributes;return c.bindOutputTexture(this._normalMapVerticesTexture),d.activate(),l.bindBuffer(l.ARRAY_BUFFER,s),l.vertexAttribPointer(u.a_position,s.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,h),l.vertexAttribPointer(u.a_normal,h.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this._indexBufferArray[r]),l.drawElements(l.TRIANGLE_STRIP,this._indexBufferArray[r].numItems,l.UNSIGNED_INT,0),l.deleteBuffer(h),c.bindOutputTexture(n),d=o.programs.normalMapBlur,d.activate(),l.bindBuffer(l.ARRAY_BUFFER,this._positionBuffer),l.vertexAttribPointer(d._program.attributes.a_position,this._positionBuffer.itemSize,l.FLOAT,!1,0,0),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,this._normalMapVerticesTexture),l.uniform1i(d._program.uniforms.s_texture,0),l.drawArrays(l.TRIANGLE_STRIP,0,this._positionBuffer.numItems),!0}return!0}return!1}_drawNormalMapNoBlur(e){let t=e.normalMapNormals;if(e.node&&e.node.getState()!==0&&t&&t.length){const i=t.length/3,r=Math.sqrt(i)-1;let s=this._verticesBufferArray[r];if(s){e.planet.terrain.equalizeNormals&&(e._normalMapEdgeEqualize(0),e._normalMapEdgeEqualize(2),e._normalMapEdgeEqualize(3),e._normalMapEdgeEqualize(1));let n=e.normalMapTexturePtr;const o=this._handler,l=o.gl;let h=o.createArrayBuffer(t,3,i,l.DYNAMIC_DRAW);const c=this._framebuffer,d=o.programs.normalMap,u=d._program.attributes;return c.bindOutputTexture(n),d.activate(),l.bindBuffer(l.ARRAY_BUFFER,s),l.vertexAttribPointer(u.a_position,s.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,h),l.vertexAttribPointer(u.a_normal,h.itemSize,l.FLOAT,!1,0,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this._indexBufferArray[r]),l.drawElements(l.TRIANGLE_STRIP,this._indexBufferArray[r].numItems,l.UNSIGNED_INT,0),l.deleteBuffer(h),!0}return!0}return!1}_drawNormalMap(e){return e.planet.terrain.isBlur(e)?this._drawNormalMapBlur(e):this._drawNormalMapNoBlur(e)}drawSingle(e){const t=this._handler.gl;this._framebuffer.activate(),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.BLEND),e.terrainReady&&this._drawNormalMap(e)&&(e.normalMapReady=!0,e.normalMapTexture=e.normalMapTexturePtr,e.normalMapTextureBias[0]=0,e.normalMapTextureBias[1]=0,e.normalMapTextureBias[2]=1),e._inTheQueue=!1,t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),t.enable(t.BLEND),this._framebuffer.deactivate()}frame(){if(this._queue.length){const e=this._handler.gl;this._framebuffer.activate(),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND);let t=0,i=window.performance.now();for(;this._lock.isFree()&&this._queue.length&&t<.25;){const r=this._queue.shift();r.terrainReady&&this._drawNormalMap(r)&&(r.normalMapReady=!0,r.normalMapTexture=r.normalMapTexturePtr,r.normalMapTextureBias[0]=0,r.normalMapTextureBias[1]=0,r.normalMapTextureBias[2]=1),r._inTheQueue=!1,t=window.performance.now()-i}e.enable(e.BLEND),e.enable(e.DEPTH_TEST),e.enable(e.CULL_FACE),this._framebuffer.deactivate()}}get queueSize(){return this._queue.length}queue(e){e._inTheQueue=!0,this._queue.push(e)}unshift(e){e._inTheQueue=!0,this._queue.unshift(e)}remove(e){}clear(){for(;this._queue.length;)this._queue.pop()._inTheQueue=!1}lock(e){this._lock.lock(e)}free(e){this._lock.free(e)}}const Ic=new ss({code:"equi",units:io}),co=`(function(){"use strict";let l=null,K=null,O=null,Q=null,S=null,T=null,U=null;function P(a,t){t<0?(t=-t,a+=l.width/2):t>=l.height&&(t=2*(l.height-1)-t,a+=l.width/2),a<0?a+=l.width:a>=l.width&&(a-=l.width);var n=2*(t*l.width+a)+l.i;return l.rawfile[n]<<8|l.rawfile[n+1]}const sa=.5*Math.PI,W=2003750834e-2,ia=Math.PI/W,ua=180/W,X=180/Math.PI,Ma=X*sa,Y=Math.PI/180,da=2*X;let k=0,Z=0,_=null;const B=function(a,t,n){this.x=a,this.y=t,this.z=n};var $=function(a,t,n,o){let f=function(c,C){if(!l)return 0;c<0&&(c+=360);var w=(90-C)*l.rlatres,M=c*l.rlonres,u=Math.floor(w),d=Math.floor(M);M-=d,w-=u,u===l.height-1&&u--,K===d&&O===u||(K=d,O=u,Q=P(d,u),S=P(d+1,u),T=P(d,u+1),U=P(d+1,u+1));let L=null;return L=(1-w)*((1-M)*Q+M*S)+w*((1-M)*T+M*U),l.offset+l.scale*L}(a,t)*n,h=Y*t,r=Y*a,m=Math.sin(h),x=Z/Math.sqrt(1-k*m*m),H=(x+f)*Math.cos(h);o.x=H*Math.cos(r),o.y=H*Math.sin(r),o.z=(x*(1-k)+f)*m},ma=function(a,t,n,o){$(a*ua,da*Math.atan(Math.exp(t*ia))-Ma,n,o)},e=new B(0,0,0),p=new B(0,0,0),y=new B(0,0,0),pa=function(a,t,n){let o=a.x,f=a.y,h=a.z;var r;o>=0?(r=65536*Math.floor(o/65536),t.x=Math.fround(r),n.x=Math.fround(o-r)):(r=65536*Math.floor(-o/65536),t.x=Math.fround(-r),n.x=Math.fround(o+r)),f>=0?(r=65536*Math.floor(f/65536),t.y=Math.fround(r),n.y=Math.fround(f-r)):(r=65536*Math.floor(-f/65536),t.y=Math.fround(-r),n.y=Math.fround(f+r)),h>=0?(r=65536*Math.floor(h/65536),t.z=Math.fround(r),n.z=Math.fround(h-r)):(r=65536*Math.floor(-h/65536),t.z=Math.fround(-r),n.z=Math.fround(h+r))};self.onmessage=function(a){if(a.data.model)l=a.data.model,l.rawfile=a.data.rawfile;else if(a.data.params){let t=549755748352,n=-549755748352,o=549755748352,f=-549755748352,h=549755748352,r=-549755748352;k=a.data.params[8],Z=a.data.params[9];let m=a.data.params[2],x=a.data.params[3],H=a.data.params[10],c=a.data.params[11],C=a.data.params[12],w=a.data.params[13];_=a.data.params[1]===0?ma:$;let M=Math.max(x,m),u=(a.data.params[6]-a.data.params[4])/M,d=(a.data.params[7]-a.data.params[5])/M,L=a.data.params[4],ya=a.data.params[7],aa=Math.max(x/m,1),N=M+1;const z=N*N,R=(m+1)*(m+1)*3;let b=new Float32Array(R),A=new Float64Array(R),F=new Float32Array(R),g=new Float32Array(R),V=new Float32Array(3*z),q=new Float64Array(3*z),v=new Float32Array(3*z),I=new Float32Array(3*z),s=0,i=0;for(let j=0;j<z;j++){let la=j%N,na=~~(j/N);_(L+la*u,ya-na*d,w,e);let D=e.x*H,E=e.y*c,G=e.z*C,J=1/Math.sqrt(D*D+E*E+G*G),oa=D*J,fa=E*J,ha=G*J;pa(e,p,y),q[i]=e.x,v[i]=p.x,I[i]=y.x,V[i++]=oa,q[i]=e.y,v[i]=p.y,I[i]=y.y,V[i++]=fa,q[i]=e.z,v[i]=p.z,I[i]=y.z,V[i++]=ha,na%aa==0&&la%aa==0&&(A[s]=e.x,F[s]=p.x,g[s]=y.x,b[s++]=oa,A[s]=e.y,F[s]=p.y,g[s]=y.y,b[s++]=fa,A[s]=e.z,F[s]=p.z,g[s]=y.z,b[s++]=ha,e.x<t&&(t=e.x),e.x>n&&(n=e.x),e.y<o&&(o=e.y),e.y>f&&(f=e.y),e.z<h&&(h=e.z),e.z>r&&(r=e.z))}let ta=.5*(n-t),ra=.5*(f-o),ea=.5*(r-h),wa=Math.sqrt(ta*ta+ra*ra+ea*ea);self.postMessage({id:a.data.params[0],plainVertices:A,plainVerticesHigh:F,plainVerticesLow:g,plainNormals:b,normalMapNormals:V,normalMapVertices:q,normalMapVerticesHigh:v,normalMapVerticesLow:I,plainRadius:wa},[A.buffer,F.buffer,g.buffer,b.buffer,V.buffer,q.buffer,v.buffer,I.buffer])}}})();
728
728
  //# sourceMappingURL=PlainSegmentWorker.worker-CT1cj8jj.js.map
729
- `,ca=typeof self<"u"&&self.Blob&&new Blob([ha],{type:"text/javascript;charset=utf-8"});function zc(a){let e;try{if(e=ca&&(self.URL||self.webkitURL).createObjectURL(ca),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ha),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class Dc extends Ms{constructor(e=2){super(e,zc)}_onMessage(e){this._source.get(e.data.id)._plainSegmentWorkerCallback(e.data),e.data.plainVertices=null,e.data.plainVerticesHigh=null,e.data.plainVerticesLow=null,e.data.plainNormals=null,e.data.normalMapNormals=null,e.data.normalMapVertices=null,e.data.normalMapVerticesHigh=null,e.data.normalMapVerticesLow=null,this._source.delete(e.data.id)}setGeoid(e){if(e.model){let t=e.model,i={scale:t.scale,offset:t.offset,width:t.width,height:t.height,rlonres:t.rlonres,rlatres:t.rlatres,i:t.i};this._workerQueue.forEach(s=>{let r=new Uint8Array(t.rawfile.length);r.set(t.rawfile),s.postMessage({model:i,rawfile:r},[r.buffer])})}else this._workerQueue.forEach(t=>{t.postMessage({model:null})})}make(e){if(e.initialized)if(this._workerQueue.length){let t=this._workerQueue.pop();this._source.set(this._sourceId,e);let i=e._projection.id===ra.id||e._projection.id===Ic.id?1:0,s=new Float64Array([this._sourceId,i,e.planet.terrain.gridSizeByZoom[e.tileZoom],e.planet.terrain.plainGridSize,e._extent.southWest.lon,e._extent.southWest.lat,e._extent.northEast.lon,e._extent.northEast.lat,e.planet.ellipsoid._e2,e.planet.ellipsoid.equatorialSize,e.planet.ellipsoid._invRadii2.x,e.planet.ellipsoid._invRadii2.y,e.planet.ellipsoid._invRadii2.z,e.planet._heightFactor]);this._sourceId++,t.postMessage({params:s},[s.buffer])}else this._pendingQueue.push(e);else this.check()}}const da=`(function(){"use strict";function H(r,e){return function(z,b){let v=0,N=z.length-1;for(;v<=N;){let n=Math.floor(.5*(v+N));if(Math.abs(z[n]-b)<.001)return n;z[n]<b?v=n+1:N=n-1}return-1}(r,e)!==-1}var y=function(r,e,z){this.x=r,this.y=e,this.z=z},Y=function(r,e,z){let b=r.x,v=r.y,N=r.z;var n;b>=0?(n=65536*Math.floor(b/65536),e.x=Math.fround(n),z.x=Math.fround(b-n)):(n=65536*Math.floor(-b/65536),e.x=Math.fround(-n),z.x=Math.fround(b+n)),v>=0?(n=65536*Math.floor(v/65536),e.y=Math.fround(n),z.y=Math.fround(v-n)):(n=65536*Math.floor(-v/65536),e.y=Math.fround(-n),z.y=Math.fround(v+n)),N>=0?(n=65536*Math.floor(N/65536),e.z=Math.fround(n),z.z=Math.fround(N-n)):(n=65536*Math.floor(-N/65536),e.z=Math.fround(-n),z.z=Math.fround(N+n))};y.prototype.sub=function(r){return new y(this.x-r.x,this.y-r.y,this.z-r.z)},y.prototype.add=function(r){return new y(this.x+r.x,this.y+r.y,this.z+r.z)},y.prototype.cross=function(r){return new y(this.y*r.z-this.z*r.y,this.z*r.x-this.x*r.z,this.x*r.y-this.y*r.x)},y.prototype.normalize=function(r){var e=this.x,z=this.y,b=this.z,v=1/Math.sqrt(e*e+z*z+b*b);return this.x=e*v,this.y=z*v,this.z=b*v,this},y.prototype.distance=function(r){return this.sub(r).length()},y.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};var x=new y(0,0,0),i=new y(0,0,0),t=new y(0,0,0);self.onmessage=function(r){var e=r.data.elevations,z=r.data.this_plainVertices,b=r.data.this_plainNormals,v=r.data.this_normalMapVertices,N=r.data.this_normalMapNormals,n=r.data.heightFactor,Dr=r.data.gridSize,D=r.data.noDataValues,Hr=r.data.id,Q=549755748352,W=-549755748352,T=549755748352,$=-549755748352,Z=549755748352,X=-549755748352;const J=Math.sqrt(e.length)-1,K=J+1,R=K*K,C=Dr,vr=J/C,L=C+1,tr=n;var a,d,p,m,yr,sr,S=0,xr=0,U=L*L*3,h=new Float64Array(U),j=new Float32Array(U),k=new Float32Array(U),lr=new Uint8Array(L*L),u=v,g=N;if(J>=C){a=new Float32Array(3*R),d=new Float64Array(3*R),p=new Float32Array(3*R),m=new Float32Array(3*R);for(let f=0;f<R;f++){var Ar=f%K,Fr=~~(f/K),ur=f,o=3*ur,rr=e[ur];H(D,rr)&&(rr=0);var Mr=tr*rr,s=new y(u[o]+Mr*g[o],u[o+1]+Mr*g[o+1],u[o+2]+Mr*g[o+2]);if(Y(s,i,t),d[o]=s.x,d[o+1]=s.y,d[o+2]=s.z,p[o]=i.x,p[o+1]=i.y,p[o+2]=i.z,m[o]=t.x,m[o+1]=t.y,m[o+2]=t.z,Fr%vr==0&&Ar%vr==0){let A=new y(u[o],u[o+1],u[o+2]),V=new y(u[o+3],u[o+4],u[o+5]),F=e[ur+1];H(D,F)&&(F=0);let q=!1;if(D.length===0){let _=A.distance(V);q=Math.abs(rr-F)/_>10||rr<-5e3}q?lr[xr]=1:(lr[xr]=0,s.x<Q&&(Q=s.x),s.x>W&&(W=s.x),s.y<T&&(T=s.y),s.y>$&&($=s.y),s.z<Z&&(Z=s.z),s.z>X&&(X=s.z)),j[S]=i.x,k[S]=t.x,h[S++]=s.x,j[S]=i.y,k[S]=t.y,h[S++]=s.y,j[S]=i.z,k[S]=t.z,h[S++]=s.z,xr++}if(Fr!==J&&Ar!==J){var gr=f+1,M=3*gr,B=e[gr];H(D,B)&&(B=0);var cr=tr*B,ar=new y(u[M]+cr*g[M],u[M+1]+cr*g[M+1],u[M+2]+cr*g[M+2]);Y(ar,i,t),d[M]=ar.x,d[M+1]=ar.y,d[M+2]=ar.z,p[M]=i.x,p[M+1]=i.y,p[M+2]=i.z,m[M]=t.x,m[M+1]=t.y,m[M+2]=t.z;var Vr=f+K,c=3*Vr;H(D,B=e[Vr])&&(B=0);var wr=tr*B,nr=new y(u[c]+wr*g[c],u[c+1]+wr*g[c+1],u[c+2]+wr*g[c+2]);Y(nr,i,t),d[c]=nr.x,d[c+1]=nr.y,d[c+2]=nr.z,p[c]=i.x,p[c+1]=i.y,p[c+2]=i.z,m[c]=t.x,m[c+1]=t.y,m[c+2]=t.z;var qr=f+K+1,w=3*qr;H(D,B=e[qr])&&(B=0);var dr=tr*B,er=new y(u[w]+dr*g[w],u[w+1]+dr*g[w+1],u[w+2]+dr*g[w+2]);Y(er,i,t),d[w]=er.x,d[w+1]=er.y,d[w+2]=er.z,p[w]=i.x,p[w+1]=i.y,p[w+2]=i.z,m[w]=t.x,m[w+1]=t.y,m[w+2]=t.z;var Lr=ar.sub(s),Sr=nr.sub(s),Nr=er.sub(s),hr=Sr.cross(Nr).normalize(),zr=Nr.cross(Lr).normalize(),O=zr.add(hr).normalize();a[o]+=O.x,a[o+1]+=O.y,a[o+2]+=O.z,a[M]+=zr.x,a[M+1]+=zr.y,a[M+2]+=zr.z,a[c]+=hr.x,a[c+1]+=hr.y,a[c+2]+=hr.z,a[w]+=O.x,a[w+1]+=O.y,a[w+2]+=O.z}}}else{a=new Float32Array(U),d=new Float64Array(U),p=new Float32Array(U),m=new Float32Array(U),a=new Float32Array(U);var E=C/J,_r=U/3,pr=J+1;for(let f=0;f<_r;f++){let A=Math.floor(f/L),V=f%L,F=A%E,q=V%E,_=Math.floor(A/E)*pr+Math.floor(V/E);V===C&&(_-=1,q=E),A===C&&(_-=pr,F=E);let mr=_+1,fr=_+pr,br=fr+1,or=e[_],ir=e[mr],P=e[fr],G=e[br];H(D,or)&&(or=0),H(D,ir)&&(ir=0),H(D,P)&&(P=0),H(D,G)&&(G=0);let I=or*(1-(yr=q/E))*(1-(sr=F/E))+ir*yr*(1-sr)+P*(1-yr)*sr+G*yr*sr,l=3*f;x.x=z[l]+I*b[l],x.y=z[l+1]+I*b[l+1],x.z=z[l+2]+I*b[l+2],Y(x,i,t),h[l]=x.x,h[l+1]=x.y,h[l+2]=x.z,j[l]=i.x,j[l+1]=i.y,j[l+2]=i.z,k[l]=t.x,k[l+1]=t.y,k[l+2]=t.z,x.x<Q&&(Q=x.x),x.x>W&&(W=x.x),x.y<T&&(T=x.y),x.y>$&&($=x.y),x.z<Z&&(Z=x.z),x.z>X&&(X=x.z)}d.set(h),p.set(j),m.set(k);for(let f=0;f<_r;f++)if(~~(f/L)!==C&&f%L!==C){let A=3*f,V=A+3,F=A+3*L,q=F+3,_=new y(h[A],h[A+1],h[A+2]),mr=new y(h[V],h[V+1],h[V+2]),fr=new y(h[F],h[F+1],h[F+2]),br=new y(h[q],h[q+1],h[q+2]),or=mr.sub(_).normalize(),ir=fr.sub(_).normalize(),P=br.sub(_).normalize(),G=ir.cross(P).normalize(),I=P.cross(or).normalize(),l=I.add(G).normalize();a[A]+=l.x,a[A+1]+=l.y,a[A+2]+=l.z,a[V]+=I.x,a[V+1]+=I.y,a[V+2]+=I.z,a[F]+=G.x,a[F+1]+=G.y,a[F+2]+=G.z,a[q]+=l.x,a[q+1]+=l.y,a[q+2]+=l.z}}self.postMessage({id:Hr,normalMapNormals:a,normalMapVertices:d,normalMapVerticesHigh:p,normalMapVerticesLow:m,terrainVertices:h,terrainVerticesHigh:j,terrainVerticesLow:k,noDataVertices:lr,bounds:[Q,T,Z,W,$,X]},[a.buffer,d.buffer,p.buffer,m.buffer,h.buffer,j.buffer,k.buffer,lr.buffer])}})();
729
+ `,uo=typeof self<"u"&&self.Blob&&new Blob([co],{type:"text/javascript;charset=utf-8"});function zc(a){let e;try{if(e=uo&&(self.URL||self.webkitURL).createObjectURL(uo),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(co),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class Dc extends Rr{constructor(e=2){super(e,zc)}_onMessage(e){this._source.get(e.data.id)._plainSegmentWorkerCallback(e.data),e.data.plainVertices=null,e.data.plainVerticesHigh=null,e.data.plainVerticesLow=null,e.data.plainNormals=null,e.data.normalMapNormals=null,e.data.normalMapVertices=null,e.data.normalMapVerticesHigh=null,e.data.normalMapVerticesLow=null,this._source.delete(e.data.id)}setGeoid(e){if(e.model){let t=e.model,i={scale:t.scale,offset:t.offset,width:t.width,height:t.height,rlonres:t.rlonres,rlatres:t.rlatres,i:t.i};this._workerQueue.forEach(r=>{let s=new Uint8Array(t.rawfile.length);s.set(t.rawfile),r.postMessage({model:i,rawfile:s},[s.buffer])})}else this._workerQueue.forEach(t=>{t.postMessage({model:null})})}make(e){if(e.initialized)if(this._workerQueue.length){let t=this._workerQueue.pop();this._source.set(this._sourceId,e);let i=e._projection.id===no.id||e._projection.id===Ic.id?1:0,r=new Float64Array([this._sourceId,i,e.planet.terrain.gridSizeByZoom[e.tileZoom],e.planet.terrain.plainGridSize,e._extent.southWest.lon,e._extent.southWest.lat,e._extent.northEast.lon,e._extent.northEast.lat,e.planet.ellipsoid._e2,e.planet.ellipsoid.equatorialSize,e.planet.ellipsoid._invRadii2.x,e.planet.ellipsoid._invRadii2.y,e.planet.ellipsoid._invRadii2.z,e.planet._heightFactor]);this._sourceId++,t.postMessage({params:r},[r.buffer])}else this._pendingQueue.push(e);else this.check()}}const _o=`(function(){"use strict";function H(r,e){return function(z,b){let v=0,N=z.length-1;for(;v<=N;){let n=Math.floor(.5*(v+N));if(Math.abs(z[n]-b)<.001)return n;z[n]<b?v=n+1:N=n-1}return-1}(r,e)!==-1}var y=function(r,e,z){this.x=r,this.y=e,this.z=z},Y=function(r,e,z){let b=r.x,v=r.y,N=r.z;var n;b>=0?(n=65536*Math.floor(b/65536),e.x=Math.fround(n),z.x=Math.fround(b-n)):(n=65536*Math.floor(-b/65536),e.x=Math.fround(-n),z.x=Math.fround(b+n)),v>=0?(n=65536*Math.floor(v/65536),e.y=Math.fround(n),z.y=Math.fround(v-n)):(n=65536*Math.floor(-v/65536),e.y=Math.fround(-n),z.y=Math.fround(v+n)),N>=0?(n=65536*Math.floor(N/65536),e.z=Math.fround(n),z.z=Math.fround(N-n)):(n=65536*Math.floor(-N/65536),e.z=Math.fround(-n),z.z=Math.fround(N+n))};y.prototype.sub=function(r){return new y(this.x-r.x,this.y-r.y,this.z-r.z)},y.prototype.add=function(r){return new y(this.x+r.x,this.y+r.y,this.z+r.z)},y.prototype.cross=function(r){return new y(this.y*r.z-this.z*r.y,this.z*r.x-this.x*r.z,this.x*r.y-this.y*r.x)},y.prototype.normalize=function(r){var e=this.x,z=this.y,b=this.z,v=1/Math.sqrt(e*e+z*z+b*b);return this.x=e*v,this.y=z*v,this.z=b*v,this},y.prototype.distance=function(r){return this.sub(r).length()},y.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};var x=new y(0,0,0),i=new y(0,0,0),t=new y(0,0,0);self.onmessage=function(r){var e=r.data.elevations,z=r.data.this_plainVertices,b=r.data.this_plainNormals,v=r.data.this_normalMapVertices,N=r.data.this_normalMapNormals,n=r.data.heightFactor,Dr=r.data.gridSize,D=r.data.noDataValues,Hr=r.data.id,Q=549755748352,W=-549755748352,T=549755748352,$=-549755748352,Z=549755748352,X=-549755748352;const J=Math.sqrt(e.length)-1,K=J+1,R=K*K,C=Dr,vr=J/C,L=C+1,tr=n;var a,d,p,m,yr,sr,S=0,xr=0,U=L*L*3,h=new Float64Array(U),j=new Float32Array(U),k=new Float32Array(U),lr=new Uint8Array(L*L),u=v,g=N;if(J>=C){a=new Float32Array(3*R),d=new Float64Array(3*R),p=new Float32Array(3*R),m=new Float32Array(3*R);for(let f=0;f<R;f++){var Ar=f%K,Fr=~~(f/K),ur=f,o=3*ur,rr=e[ur];H(D,rr)&&(rr=0);var Mr=tr*rr,s=new y(u[o]+Mr*g[o],u[o+1]+Mr*g[o+1],u[o+2]+Mr*g[o+2]);if(Y(s,i,t),d[o]=s.x,d[o+1]=s.y,d[o+2]=s.z,p[o]=i.x,p[o+1]=i.y,p[o+2]=i.z,m[o]=t.x,m[o+1]=t.y,m[o+2]=t.z,Fr%vr==0&&Ar%vr==0){let A=new y(u[o],u[o+1],u[o+2]),V=new y(u[o+3],u[o+4],u[o+5]),F=e[ur+1];H(D,F)&&(F=0);let q=!1;if(D.length===0){let _=A.distance(V);q=Math.abs(rr-F)/_>10||rr<-5e3}q?lr[xr]=1:(lr[xr]=0,s.x<Q&&(Q=s.x),s.x>W&&(W=s.x),s.y<T&&(T=s.y),s.y>$&&($=s.y),s.z<Z&&(Z=s.z),s.z>X&&(X=s.z)),j[S]=i.x,k[S]=t.x,h[S++]=s.x,j[S]=i.y,k[S]=t.y,h[S++]=s.y,j[S]=i.z,k[S]=t.z,h[S++]=s.z,xr++}if(Fr!==J&&Ar!==J){var gr=f+1,M=3*gr,B=e[gr];H(D,B)&&(B=0);var cr=tr*B,ar=new y(u[M]+cr*g[M],u[M+1]+cr*g[M+1],u[M+2]+cr*g[M+2]);Y(ar,i,t),d[M]=ar.x,d[M+1]=ar.y,d[M+2]=ar.z,p[M]=i.x,p[M+1]=i.y,p[M+2]=i.z,m[M]=t.x,m[M+1]=t.y,m[M+2]=t.z;var Vr=f+K,c=3*Vr;H(D,B=e[Vr])&&(B=0);var wr=tr*B,nr=new y(u[c]+wr*g[c],u[c+1]+wr*g[c+1],u[c+2]+wr*g[c+2]);Y(nr,i,t),d[c]=nr.x,d[c+1]=nr.y,d[c+2]=nr.z,p[c]=i.x,p[c+1]=i.y,p[c+2]=i.z,m[c]=t.x,m[c+1]=t.y,m[c+2]=t.z;var qr=f+K+1,w=3*qr;H(D,B=e[qr])&&(B=0);var dr=tr*B,er=new y(u[w]+dr*g[w],u[w+1]+dr*g[w+1],u[w+2]+dr*g[w+2]);Y(er,i,t),d[w]=er.x,d[w+1]=er.y,d[w+2]=er.z,p[w]=i.x,p[w+1]=i.y,p[w+2]=i.z,m[w]=t.x,m[w+1]=t.y,m[w+2]=t.z;var Lr=ar.sub(s),Sr=nr.sub(s),Nr=er.sub(s),hr=Sr.cross(Nr).normalize(),zr=Nr.cross(Lr).normalize(),O=zr.add(hr).normalize();a[o]+=O.x,a[o+1]+=O.y,a[o+2]+=O.z,a[M]+=zr.x,a[M+1]+=zr.y,a[M+2]+=zr.z,a[c]+=hr.x,a[c+1]+=hr.y,a[c+2]+=hr.z,a[w]+=O.x,a[w+1]+=O.y,a[w+2]+=O.z}}}else{a=new Float32Array(U),d=new Float64Array(U),p=new Float32Array(U),m=new Float32Array(U),a=new Float32Array(U);var E=C/J,_r=U/3,pr=J+1;for(let f=0;f<_r;f++){let A=Math.floor(f/L),V=f%L,F=A%E,q=V%E,_=Math.floor(A/E)*pr+Math.floor(V/E);V===C&&(_-=1,q=E),A===C&&(_-=pr,F=E);let mr=_+1,fr=_+pr,br=fr+1,or=e[_],ir=e[mr],P=e[fr],G=e[br];H(D,or)&&(or=0),H(D,ir)&&(ir=0),H(D,P)&&(P=0),H(D,G)&&(G=0);let I=or*(1-(yr=q/E))*(1-(sr=F/E))+ir*yr*(1-sr)+P*(1-yr)*sr+G*yr*sr,l=3*f;x.x=z[l]+I*b[l],x.y=z[l+1]+I*b[l+1],x.z=z[l+2]+I*b[l+2],Y(x,i,t),h[l]=x.x,h[l+1]=x.y,h[l+2]=x.z,j[l]=i.x,j[l+1]=i.y,j[l+2]=i.z,k[l]=t.x,k[l+1]=t.y,k[l+2]=t.z,x.x<Q&&(Q=x.x),x.x>W&&(W=x.x),x.y<T&&(T=x.y),x.y>$&&($=x.y),x.z<Z&&(Z=x.z),x.z>X&&(X=x.z)}d.set(h),p.set(j),m.set(k);for(let f=0;f<_r;f++)if(~~(f/L)!==C&&f%L!==C){let A=3*f,V=A+3,F=A+3*L,q=F+3,_=new y(h[A],h[A+1],h[A+2]),mr=new y(h[V],h[V+1],h[V+2]),fr=new y(h[F],h[F+1],h[F+2]),br=new y(h[q],h[q+1],h[q+2]),or=mr.sub(_).normalize(),ir=fr.sub(_).normalize(),P=br.sub(_).normalize(),G=ir.cross(P).normalize(),I=P.cross(or).normalize(),l=I.add(G).normalize();a[A]+=l.x,a[A+1]+=l.y,a[A+2]+=l.z,a[V]+=I.x,a[V+1]+=I.y,a[V+2]+=I.z,a[F]+=G.x,a[F+1]+=G.y,a[F+2]+=G.z,a[q]+=l.x,a[q+1]+=l.y,a[q+2]+=l.z}}self.postMessage({id:Hr,normalMapNormals:a,normalMapVertices:d,normalMapVerticesHigh:p,normalMapVerticesLow:m,terrainVertices:h,terrainVerticesHigh:j,terrainVerticesLow:k,noDataVertices:lr,bounds:[Q,T,Z,W,$,X]},[a.buffer,d.buffer,p.buffer,m.buffer,h.buffer,j.buffer,k.buffer,lr.buffer])}})();
730
730
  //# sourceMappingURL=TerrainWorker.worker-DmikdfB2.js.map
731
- `,ua=typeof self<"u"&&self.Blob&&new Blob([da],{type:"text/javascript;charset=utf-8"});function Fc(a){let e;try{if(e=ua&&(self.URL||self.webkitURL).createObjectURL(ua),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(da),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class Oc extends Ms{constructor(e=2){super(e,Fc)}_onMessage(e){this._source.get(e.data.id).segment._terrainWorkerCallback(e.data),this._source.delete(e.data.id),e.data.normalMapNormals=null,e.data.normalMapVertices=null,e.data.normalMapVerticesHigh=null,e.data.normalMapVerticesLow=null,e.data.terrainVertices=null,e.data.terrainVerticesHigh=null,e.data.terrainVerticesLow=null}make(e){if(e.segment.plainReady&&e.segment.terrainIsLoading)if(this._workerQueue.length){const t=this._workerQueue.pop();this._source.set(this._sourceId,e);let i=e.segment;t.postMessage({elevations:e.elevations,this_plainVertices:i.plainVertices,this_plainNormals:i.plainNormals,this_normalMapVertices:i.normalMapVertices,this_normalMapNormals:i.normalMapNormals,heightFactor:i.planet._heightFactor,gridSize:i.planet.terrain.gridSizeByZoom[i.tileZoom],noDataValues:i.planet.terrain.noDataValues,id:this._sourceId},[e.elevations.buffer,i.plainVertices.buffer,i.plainNormals.buffer,i.normalMapVertices.buffer,i.normalMapNormals.buffer]),this._sourceId++}else this._pendingQueue.push(e);else this.check()}}let Gt=new Float32Array(2);class Nc{constructor(e,t=256,i=256){this._width=t,this._height=i,this._planet=e,this._framebuffer=null,this._queue=[],this._handler=null}init(){this._handler=this._planet.renderer.handler,this._handler.programs.vectorTileLineRasterization||this._handler.addProgram(new X("vectorTileLineRasterization",{uniforms:{viewport:"vec2",thicknessOutline:"float",alpha:"float",extentParamsHigh:"vec4",extentParamsLow:"vec4"},attributes:{prevHigh:"vec2",currentHigh:"vec2",nextHigh:"vec2",prevLow:"vec2",currentLow:"vec2",nextLow:"vec2",order:"float",color:"vec4",thickness:"float"},vertexShader:`attribute vec2 prevHigh;
731
+ `,fo=typeof self<"u"&&self.Blob&&new Blob([_o],{type:"text/javascript;charset=utf-8"});function Fc(a){let e;try{if(e=fo&&(self.URL||self.webkitURL).createObjectURL(fo),!e)throw"";const t=new Worker(e,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(_o),{name:a==null?void 0:a.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class Oc extends Rr{constructor(e=2){super(e,Fc)}_onMessage(e){this._source.get(e.data.id).segment._terrainWorkerCallback(e.data),this._source.delete(e.data.id),e.data.normalMapNormals=null,e.data.normalMapVertices=null,e.data.normalMapVerticesHigh=null,e.data.normalMapVerticesLow=null,e.data.terrainVertices=null,e.data.terrainVerticesHigh=null,e.data.terrainVerticesLow=null}make(e){if(e.segment.plainReady&&e.segment.terrainIsLoading)if(this._workerQueue.length){const t=this._workerQueue.pop();this._source.set(this._sourceId,e);let i=e.segment;t.postMessage({elevations:e.elevations,this_plainVertices:i.plainVertices,this_plainNormals:i.plainNormals,this_normalMapVertices:i.normalMapVertices,this_normalMapNormals:i.normalMapNormals,heightFactor:i.planet._heightFactor,gridSize:i.planet.terrain.gridSizeByZoom[i.tileZoom],noDataValues:i.planet.terrain.noDataValues,id:this._sourceId},[e.elevations.buffer,i.plainVertices.buffer,i.plainNormals.buffer,i.normalMapVertices.buffer,i.normalMapNormals.buffer]),this._sourceId++}else this._pendingQueue.push(e);else this.check()}}let Ut=new Float32Array(2);class Nc{constructor(e,t=256,i=256){this._width=t,this._height=i,this._planet=e,this._framebuffer=null,this._queue=[],this._handler=null}init(){this._handler=this._planet.renderer.handler,this._handler.programs.vectorTileLineRasterization||this._handler.addProgram(new X("vectorTileLineRasterization",{uniforms:{viewport:"vec2",thicknessOutline:"float",alpha:"float",extentParamsHigh:"vec4",extentParamsLow:"vec4"},attributes:{prevHigh:"vec2",currentHigh:"vec2",nextHigh:"vec2",prevLow:"vec2",currentLow:"vec2",nextLow:"vec2",order:"float",color:"vec4",thickness:"float"},vertexShader:`attribute vec2 prevHigh;
732
732
  attribute vec2 currentHigh;
733
733
  attribute vec2 nextHigh;
734
734
 
@@ -835,7 +835,7 @@ precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in
835
835
  varying vec4 color;
836
836
  void main () {
837
837
  gl_FragColor = color;
838
- }`})),this._framebuffer=new Me(this._handler,{width:this._width,height:this._height,useDepth:!1}),this._framebuffer.init()}frame(){if(this._planet.layerLock.isFree()&&this._queue.length){let e=this._handler,t=e.gl;t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST);let i=e.programs.vectorTileLineRasterization,s=e.programs.vectorTilePolygonRasterization,r=this._width,n=this._height,o=r,l=n,h=o<<1,c=l<<1,d=new Float32Array(4),u=new Float32Array(4),g=this._framebuffer.activate(),f=0,p=window.performance.now();for(;this._queue.length&&f<25;){let _=this._queue.shift();if(_.isLoading&&_.segment.node.getState()===1){let m=_.layer._pickingEnabled;_.segment.tileZoom<4?(o=h,l=c):(o=r,l=n);let y=_._updateTexture||e.createEmptyTexture_l(o,l),x=m?_._updatePickingMask||e.createEmptyTexture_n(o,l):null;_.applyTexture(y,x),g.setSize(o,l),g.bindOutputTexture(y),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);let w=_.segment.getExtentMerc();lt(w.southWest.lon,Gt),d[0]=Gt[0],u[0]=Gt[1],lt(w.southWest.lat,Gt),d[1]=Gt[0],u[1]=Gt[1],d[2]=2/w.getWidth(),d[3]=2/w.getHeight(),s.activate();let b=s._program,E=b.attributes,C=b.uniforms,T=_.layer._geometryHandler;t.uniform4fv(C.extentParamsHigh,d),t.uniform4fv(C.extentParamsLow,u),t.bindBuffer(t.ARRAY_BUFFER,T._polyVerticesHighBufferMerc),t.vertexAttribPointer(E.coordinatesHigh,T._polyVerticesHighBufferMerc.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._polyVerticesLowBufferMerc),t.vertexAttribPointer(E.coordinatesLow,T._polyVerticesLowBufferMerc.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._polyColorsBuffer),t.vertexAttribPointer(E.colors,T._polyColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,T._polyIndexesBuffer),t.drawElements(t.TRIANGLES,T._polyIndexesBuffer.numItems,t.UNSIGNED_INT,0),m&&(g.bindOutputTexture(x),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindBuffer(t.ARRAY_BUFFER,T._polyPickingColorsBuffer),t.vertexAttribPointer(E.colors,T._polyPickingColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,T._polyIndexesBuffer.numItems,t.UNSIGNED_INT,0)),g.bindOutputTexture(y),i.activate(),b=i._program,E=b.attributes,C=b.uniforms,t.uniform2fv(C.viewport,[o,l]),t.uniform4fv(C.extentParamsHigh,d),t.uniform4fv(C.extentParamsLow,u);let L=T._lineVerticesHighBufferMerc;t.bindBuffer(t.ARRAY_BUFFER,L),t.vertexAttribPointer(E.prevHigh,L.itemSize,t.FLOAT,!1,8,0),t.vertexAttribPointer(E.currentHigh,L.itemSize,t.FLOAT,!1,8,32),t.vertexAttribPointer(E.nextHigh,L.itemSize,t.FLOAT,!1,8,64),L=T._lineVerticesLowBufferMerc,t.bindBuffer(t.ARRAY_BUFFER,L),t.vertexAttribPointer(E.prevLow,L.itemSize,t.FLOAT,!1,8,0),t.vertexAttribPointer(E.currentLow,L.itemSize,t.FLOAT,!1,8,32),t.vertexAttribPointer(E.nextLow,L.itemSize,t.FLOAT,!1,8,64),t.bindBuffer(t.ARRAY_BUFFER,T._lineOrdersBuffer),t.vertexAttribPointer(E.order,T._lineOrdersBuffer.itemSize,t.FLOAT,!1,4,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,T._lineIndexesBuffer),t.bindBuffer(t.ARRAY_BUFFER,T._lineStrokesBuffer),t.vertexAttribPointer(E.thickness,T._lineStrokesBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineStrokeColorsBuffer),t.vertexAttribPointer(E.color,T._lineStrokeColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(C.thicknessOutline,2),t.uniform1f(C.alpha,.54),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.uniform1f(C.thicknessOutline,1),t.uniform1f(C.alpha,1),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineThicknessBuffer),t.vertexAttribPointer(E.thickness,T._lineThicknessBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineColorsBuffer),t.vertexAttribPointer(E.color,T._lineColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(C.thicknessOutline,2),t.uniform1f(C.alpha,.54),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.uniform1f(C.thicknessOutline,1),t.uniform1f(C.alpha,1),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),m&&(g.bindOutputTexture(x),t.uniform1f(C.thicknessOutline,8),t.bindBuffer(t.ARRAY_BUFFER,T._linePickingColorsBuffer),t.vertexAttribPointer(E.color,T._linePickingColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0))}else _.isLoading=!1;f=window.performance.now()-p}t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),g.deactivate()}}add(e){this._queue.push(e)}remove(e){}get queueSize(){return this._queue.length}}class _a extends at{constructor(e={}){super(e.name),this._minDistanceBeforeMemClear=0,this._renderingFadingNodes=(n,o,l,h,c,d,u)=>{let g=c===0,f=this.terrain.equalizeVertices;for(let p=0,_=l._fadingNodes.length;p<_;p++){let m=l._fadingNodes[p].segment;this._fadingNodes.has(l._fadingNodes[0].__id)&&!n.has(m.node.__id)&&(n.set(m.node.__id,!0),m._transitionOpacity<1?d.push(m):g?(f&&m.equalize(),m.readyToEngage&&m.engage(),m.screenRendering(o,h,c),u.push(m)):m.screenRendering(o,h,c,this.transparentTexture,!0))}},this._renderingFadingNodesNoDepth=(n,o,l,h,c,d)=>{let u=c===0,g=this.terrain.equalizeVertices,f=o.gl;f.disable(f.DEPTH_TEST);for(let p=0,_=l._fadingNodes.length;p<_;p++){let m=l._fadingNodes[p].segment;this._fadingNodes.has(l._fadingNodes[0].__id)&&!n.has(m.node.__id)&&(n.set(m.node.__id,!0),u?(g&&m.equalize(),m.readyToEngage&&m.engage(),m.screenRendering(o,h,c),d.push(m)):m.screenRendering(o,h,c,this.transparentTexture,!0))}f.enable(f.DEPTH_TEST)},this._atmosphere=new bc(e.atmosphereParameters),this.transitionTime=580,this.ellipsoid=e.ellipsoid||Br,this.lightEnabled=!0,this._planetRadius2=(this.ellipsoid.getPolarSize()-1e4)*(this.ellipsoid.getPolarSize()-1e4),this._layers=[],this._updateLayers=!1,this.visibleTileLayers=[],this.visibleVectorLayers=[],this._visibleVectorLayersByDepthOrder=[],this._visibleTileLayerSlices=[],this._visibleEntityCollections=[[]],this.baseLayer=null,this.terrain=null,this.camera=new Go(this,{frustums:e.frustums,eye:new v(25e6,0,0),look:v.ZERO,up:v.NORTH,minAltitude:e.minAltitude,maxAltitude:e.maxAltitude}),this.maxEqualZoomAltitude=e.maxEqualZoomAltitude||15e6,this.minEqualZoomAltitude=e.minEqualZoomAltitude||1e4,this.minEqualZoomCameraSlope=e.minEqualZoomCameraSlope||.8,this.mousePositionOnEarth=new v,this.emptyTexture=null,this.transparentTexture=null,this.defaultTexture=null,this.minCurrZoom=ye,this.maxCurrZoom=Te,this._viewExtent=new G(new A(180,180),new A(-180,-180)),this._skipPreRender=!1,this._initialViewExtent=null,this._createdNodesCount=0,this._renderedNodes=[],this._renderedNodesInFrustum=[],this._fadingNodes=new Map,this._fadingNodesInFrustum=[],this._fadingOpaqueSegments=[],this.layerLock=new Os,this.terrainLock=new Os,this._heightFactor=1,this._indexesCache=[],this._indexesCacheToRemove=[],this._indexesCacheToRemoveCounter=0,this._textureCoordsBufferCache=[],this.quadTreeStrategy=e.quadTreeStrategyPrototype?new e.quadTreeStrategyPrototype(this):new Mc(this),this._nightTexture=null,this._specularTexture=null;let t=Ye(e.ambient,new v(.2,.2,.3)),i=Ye(e.diffuse,new v(1,1,1)),s=Ye(e.specular,new v(63e-5,55e-5,32e-5)),r=e.shininess||18;this._ambient=new Float32Array([t.x,t.y,t.z]),this._diffuse=new Float32Array([i.x,i.y,i.z]),this._specular=new Float32Array([s.x,s.y,s.z,r]),this._maxGridSize=Math.log2(e.maxGridSize||256),this.SLICE_SIZE=4,this.SLICE_SIZE_4=4*this.SLICE_SIZE,this.SLICE_SIZE_3=3*this.SLICE_SIZE,this._lodSize=256,this._curLodSize=256,this._minLodSize=512,this._maxLodSize=256,this._maxNodes=e.maxNodesCount||200,this._pickingColorArr=new Float32Array(this.SLICE_SIZE_4),this._samplerArr=new Int32Array(this.SLICE_SIZE),this._pickingMaskArr=new Int32Array(this.SLICE_SIZE),this._geoImageCreator=new Rc(this),this._vectorTileCreator=new Nc(this,e.vectorTileSize,e.vectorTileSize),this._normalMapCreator=new kc(this),this._terrainWorker=new Oc(3),this._plainSegmentWorker=new Dc(3),this._tileLoader=new la(e.maxLoadingRequests||12),this._memKey=new di,this.events=he(Hc),this._distBeforeMemClear=0,this._prevCamEye=new v,this._initialized=!1,this._renderCompleted=!1,this._renderCompletedActivated=!1,this._terrainCompleted=!1,this._terrainCompletedActivated=!1,this._collectRenderNodesIsActive=!0,this.nightTextureCoefficient=2,this._renderScreenNodesPASS=this._renderScreenNodesPASSNoAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSNoAtmos,this._atmosphereEnabled=e.atmosphereEnabled||!1,this._atmosphereMaxMinOpacity=new Float32Array([.95,.28]),this.solidTextureOne=null,this.solidTextureTwo=null,this._nightTextureSrc=e.nightTextureSrc||null,this._specularTextureSrc=e.specularTextureSrc||null,this._transitionOpacityEnabled=e.transitionOpacityEnabled==null||e.transitionOpacityEnabled}get terrainReady(){return this._terrainCompleted&&this._terrainCompletedActivated}get maxGridSize(){return this._maxGridSize}getNorthFrameRotation(e){return this.getFrameRotation(e)}getFrameRotation(e){return this.ellipsoid.getNorthFrameRotation(e)}set atmosphereMaxOpacity(e){this._atmosphereMaxMinOpacity[0]=e}get atmosphereMaxOpacity(){return this._atmosphereMaxMinOpacity[0]}set atmosphereMinOpacity(e){this._atmosphereMaxMinOpacity[1]=e}get atmosphereMinOpacity(){return this._atmosphereMaxMinOpacity[1]}set atmosphereEnabled(e){e!=this._atmosphereEnabled&&(this._atmosphereEnabled=e,this._initializeAtmosphere())}get atmosphereEnabled(){return this._atmosphereEnabled}set diffuse(e){let t=Ye(e);this._diffuse=new Float32Array(t.toArray())}set ambient(e){let t=Ye(e);this._ambient=new Float32Array(t.toArray())}set specular(e){let t=Ye(e);this._specular=new Float32Array([t.x,t.y,t.y,this._specular[3]])}set shininess(e){this._specular[3]=e}get normalMapCreator(){return this._normalMapCreator}get layers(){return[...this._layers]}getLayers(){return this.layers}get sun(){if(this.renderer&&this.renderer.controls.sun)return this.renderer.controls.sun}get sunPos(){return this.sun.sunlight.getPosition()}addControl(e){e.planet=this,e.addTo(this.renderer)}get lodSize(){return this._lodSize}setLodSize(e,t,i){this._maxLodSize=i||this._maxLodSize,this._minLodSize=t||this._minLodSize,this._curLodSize=e,this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1}addControls(e){for(let t=0;t<e.length;t++)this.addControl(e[t])}getLayerByName(e){for(let t=0,i=this._layers.length;t<i;t++)if(e===this._layers[t].name)return this._layers[t]}addLayer(e){e.addTo(this)}_onLayerVisibilityChanged(e){this.events.dispatch(this.events.layervisibilitychange,e)}addLayers(e){for(let t=0,i=e.length;t<i;t++)this.addLayer(e[t])}removeLayer(e){e.remove()}_clearLayerMaterial(e){this.quadTreeStrategy.clearLayerMaterial(e)}setBaseLayer(e){this.baseLayer?this.baseLayer.isEqual(e)||(this.baseLayer.setVisibility(!1),this.baseLayer=e,e.setVisibility(!0),this.events.dispatch(this.events.baselayerchange,e)):(this.baseLayer=e,this.baseLayer.setVisibility(!0),this.events.dispatch(this.events.baselayerchange,e))}setHeightFactor(e){this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1,this._heightFactor!==e&&(this._heightFactor=e,this.quadTreeStrategy.destroyBranches(),this._clearRenderedNodeList(),this._clearRenderNodesInFrustum())}getHeightFactor(){return this._heightFactor}setTerrain(e){this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1,this._initialized&&this.memClear(),this.terrain&&(this.terrain.abortLoading(),this.terrain.clearCache(),this.terrain._planet=null),this.terrain=e,this.terrain._planet=this,this.quadTreeStrategy.destroyBranches(),e._geoid.model?(this._plainSegmentWorker.setGeoid(e.getGeoid()),e._isReady=!0):aa.loadModel(e.geoid.src).then(t=>{e.geoid.setModel(t),this._plainSegmentWorker.setGeoid(e.getGeoid()),e._isReady=!0}).catch(t=>{console.warn(t)})}initAtmosphereShader(e){if(this.renderer&&this.renderer.handler&&this._atmosphereEnabled){let t=this.renderer.handler;t.isWebGl2()?(t.removeProgram("drawnode_screen_wl"),t.addProgram(ea(e),!0)):console.warn("Atmosphere WebGL2 only")}}get atmosphereControl(){return this._atmosphere}_initializeAtmosphere(){if(!this.renderer)return;let e=this.renderer.handler;e.removeProgram("drawnode_screen_wl"),this._atmosphereEnabled?(this._renderScreenNodesPASS=this._renderScreenNodesPASSAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSAtmos,this.renderer.controls.Atmosphere||this.addControl(this._atmosphere),this._atmosphere.activate(),e.isWebGl2()?e.addProgram(ea(this._atmosphere.parameters),!0):e.addProgram(Jo(),!0),this.renderer.controls.SimpleSkyBackground&&this.renderer.controls.SimpleSkyBackground.deactivate()):(this._renderScreenNodesPASS=this._renderScreenNodesPASSNoAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSNoAtmos,this._atmosphere.deactivate(),this.renderer.controls.SimpleSkyBackground?this.renderer.controls.SimpleSkyBackground.activate():this.addControl(new bo),e.isWebGl2()?e.addProgram(new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",camHeight:"float",nightTextureCoefficient:"float",transitionOpacity:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:`#version 300 es
838
+ }`})),this._framebuffer=new Se(this._handler,{width:this._width,height:this._height,useDepth:!1}),this._framebuffer.init()}frame(){if(this._planet.layerLock.isFree()&&this._queue.length){let e=this._handler,t=e.gl;t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST);let i=e.programs.vectorTileLineRasterization,r=e.programs.vectorTilePolygonRasterization,s=this._width,n=this._height,o=s,l=n,h=o<<1,c=l<<1,d=new Float32Array(4),u=new Float32Array(4),g=this._framebuffer.activate(),f=0,p=window.performance.now();for(;this._queue.length&&f<25;){let _=this._queue.shift();if(_.isLoading&&_.segment.node.getState()===1){let v=_.layer._pickingEnabled;_.segment.tileZoom<4?(o=h,l=c):(o=s,l=n);let x=_._updateTexture||e.createEmptyTexture_l(o,l),y=v?_._updatePickingMask||e.createEmptyTexture_n(o,l):null;_.applyTexture(x,y),g.setSize(o,l),g.bindOutputTexture(x),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);let w=_.segment.getExtentMerc();lt(w.southWest.lon,Ut),d[0]=Ut[0],u[0]=Ut[1],lt(w.southWest.lat,Ut),d[1]=Ut[0],u[1]=Ut[1],d[2]=2/w.getWidth(),d[3]=2/w.getHeight(),r.activate();let b=r._program,E=b.attributes,C=b.uniforms,T=_.layer._geometryHandler;t.uniform4fv(C.extentParamsHigh,d),t.uniform4fv(C.extentParamsLow,u),t.bindBuffer(t.ARRAY_BUFFER,T._polyVerticesHighBufferMerc),t.vertexAttribPointer(E.coordinatesHigh,T._polyVerticesHighBufferMerc.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._polyVerticesLowBufferMerc),t.vertexAttribPointer(E.coordinatesLow,T._polyVerticesLowBufferMerc.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._polyColorsBuffer),t.vertexAttribPointer(E.colors,T._polyColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,T._polyIndexesBuffer),t.drawElements(t.TRIANGLES,T._polyIndexesBuffer.numItems,t.UNSIGNED_INT,0),v&&(g.bindOutputTexture(y),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindBuffer(t.ARRAY_BUFFER,T._polyPickingColorsBuffer),t.vertexAttribPointer(E.colors,T._polyPickingColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,T._polyIndexesBuffer.numItems,t.UNSIGNED_INT,0)),g.bindOutputTexture(x),i.activate(),b=i._program,E=b.attributes,C=b.uniforms,t.uniform2fv(C.viewport,[o,l]),t.uniform4fv(C.extentParamsHigh,d),t.uniform4fv(C.extentParamsLow,u);let L=T._lineVerticesHighBufferMerc;t.bindBuffer(t.ARRAY_BUFFER,L),t.vertexAttribPointer(E.prevHigh,L.itemSize,t.FLOAT,!1,8,0),t.vertexAttribPointer(E.currentHigh,L.itemSize,t.FLOAT,!1,8,32),t.vertexAttribPointer(E.nextHigh,L.itemSize,t.FLOAT,!1,8,64),L=T._lineVerticesLowBufferMerc,t.bindBuffer(t.ARRAY_BUFFER,L),t.vertexAttribPointer(E.prevLow,L.itemSize,t.FLOAT,!1,8,0),t.vertexAttribPointer(E.currentLow,L.itemSize,t.FLOAT,!1,8,32),t.vertexAttribPointer(E.nextLow,L.itemSize,t.FLOAT,!1,8,64),t.bindBuffer(t.ARRAY_BUFFER,T._lineOrdersBuffer),t.vertexAttribPointer(E.order,T._lineOrdersBuffer.itemSize,t.FLOAT,!1,4,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,T._lineIndexesBuffer),t.bindBuffer(t.ARRAY_BUFFER,T._lineStrokesBuffer),t.vertexAttribPointer(E.thickness,T._lineStrokesBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineStrokeColorsBuffer),t.vertexAttribPointer(E.color,T._lineStrokeColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(C.thicknessOutline,2),t.uniform1f(C.alpha,.54),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.uniform1f(C.thicknessOutline,1),t.uniform1f(C.alpha,1),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineThicknessBuffer),t.vertexAttribPointer(E.thickness,T._lineThicknessBuffer.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,T._lineColorsBuffer),t.vertexAttribPointer(E.color,T._lineColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.uniform1f(C.thicknessOutline,2),t.uniform1f(C.alpha,.54),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),t.uniform1f(C.thicknessOutline,1),t.uniform1f(C.alpha,1),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0),v&&(g.bindOutputTexture(y),t.uniform1f(C.thicknessOutline,8),t.bindBuffer(t.ARRAY_BUFFER,T._linePickingColorsBuffer),t.vertexAttribPointer(E.color,T._linePickingColorsBuffer.itemSize,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLE_STRIP,T._lineIndexesBuffer.numItems,t.UNSIGNED_INT,0))}else _.isLoading=!1;f=window.performance.now()-p}t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),g.deactivate()}}add(e){this._queue.push(e)}remove(e){}get queueSize(){return this._queue.length}}class yi extends ot{constructor(e={}){super(e.name),this._minDistanceBeforeMemClear=0,this._renderingFadingNodes=(o,l,h,c,d,u,g,f)=>{let p=u===0,_=this.terrain.equalizeVertices;for(let v=0,x=c._fadingNodes.length;v<x;v++){let y=c._fadingNodes[v].segment;o._fadingNodes.has(c._fadingNodes[0].__id)&&!l.has(y.node.__id)&&(l.set(y.node.__id,!0),y._transitionOpacity<1?g.push(y):p?(_&&y.equalize(),y.readyToEngage&&y.engage(),y.screenRendering(h,d,u),f.push(y)):y.screenRendering(h,d,u,this.transparentTexture,!0))}},this._renderingFadingNodesNoDepth=(o,l,h,c,d,u,g)=>{let f=u===0,p=this.terrain.equalizeVertices,_=h.gl;_.disable(_.DEPTH_TEST);for(let v=0,x=c._fadingNodes.length;v<x;v++){let y=c._fadingNodes[v].segment;o._fadingNodes.has(c._fadingNodes[0].__id)&&!l.has(y.node.__id)&&(l.set(y.node.__id,!0),f?(p&&y.equalize(),y.readyToEngage&&y.engage(),y.screenRendering(h,d,u),g.push(y)):y.screenRendering(h,d,u,this.transparentTexture,!0))}_.enable(_.DEPTH_TEST)},this._createdNodesCount=0,this._atmosphere=new xc(e.atmosphereParameters),this.transitionTime=580,this.ellipsoid=e.ellipsoid||ks,this.lightEnabled=!0,this._planetRadius2=(this.ellipsoid.getPolarSize()-1e4)*(this.ellipsoid.getPolarSize()-1e4),this._layers=[],this._updateLayers=!1,this.visibleTileLayers=[],this.visibleVectorLayers=[],this._visibleVectorLayersByDepthOrder=[],this._visibleTileLayerSlices=[],this._visibleEntityCollections=[[]],this.baseLayer=null,this.terrain=null,this.camera=new ja(this,{frustums:e.frustums,eye:new m(25e6,0,0),look:m.ZERO,up:m.NORTH,minAltitude:e.minAltitude,maxAltitude:e.maxAltitude}),this.mousePositionOnEarth=new m,this.emptyTexture=null,this.transparentTexture=null,this.defaultTexture=null,this._initialViewExtent=null,this.layerLock=new Nr,this.terrainLock=new Nr,this._heightFactor=1,this._indexesCache=[],this._indexesCacheToRemove=[],this._indexesCacheToRemoveCounter=0,this._textureCoordsBufferCache=[];const t={planet:this,maxEqualZoomAltitude:e.maxEqualZoomAltitude,minEqualZoomAltitude:e.minEqualZoomAltitude,minEqualZoomCameraSlope:e.minEqualZoomCameraSlope,transitionOpacityEnabled:e.transitionOpacityEnabled};this.quadTreeStrategyPrototype=e.quadTreeStrategyPrototype||Mc,this.quadTreeStrategy=new this.quadTreeStrategyPrototype(t),this._nightTexture=null,this._specularTexture=null;let i=qe(e.ambient,new m(.2,.2,.3)),r=qe(e.diffuse,new m(1,1,1)),s=qe(e.specular,new m(63e-5,55e-5,32e-5)),n=e.shininess||18;this._ambient=new Float32Array([i.x,i.y,i.z]),this._diffuse=new Float32Array([r.x,r.y,r.z]),this._specular=new Float32Array([s.x,s.y,s.z,n]),this._maxGridSize=Math.log2(e.maxGridSize||256),this.SLICE_SIZE=4,this.SLICE_SIZE_4=4*this.SLICE_SIZE,this.SLICE_SIZE_3=3*this.SLICE_SIZE,this._maxNodes=e.maxNodesCount||200,this._pickingColorArr=new Float32Array(this.SLICE_SIZE_4),this._samplerArr=new Int32Array(this.SLICE_SIZE),this._pickingMaskArr=new Int32Array(this.SLICE_SIZE),this._geoImageCreator=new Rc(this),this._vectorTileCreator=new Nc(this,e.vectorTileSize,e.vectorTileSize),this._normalMapCreator=new kc(this),this._terrainWorker=new Oc(3),this._plainSegmentWorker=new Dc(3),this._tileLoader=new ho(e.maxLoadingRequests||12),this._memKey=new ci,this.events=le(Hc),this._distBeforeMemClear=0,this._prevCamEye=new m,this._initialized=!1,this._collectRenderNodesIsActive=!0,this.nightTextureCoefficient=2,this._renderScreenNodesPASS=this._renderScreenNodesPASSNoAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSNoAtmos,this._atmosphereEnabled=e.atmosphereEnabled||!1,this._atmosphereMaxMinOpacity=new Float32Array([.95,.28]),this.solidTextureOne=null,this.solidTextureTwo=null,this._nightTextureSrc=e.nightTextureSrc||null,this._specularTextureSrc=e.specularTextureSrc||null}get terrainReady(){return this.quadTreeStrategy.terrainReady}get maxGridSize(){return this._maxGridSize}getNorthFrameRotation(e){return this.getFrameRotation(e)}getFrameRotation(e){return this.ellipsoid.getNorthFrameRotation(e)}set atmosphereMaxOpacity(e){this._atmosphereMaxMinOpacity[0]=e}get atmosphereMaxOpacity(){return this._atmosphereMaxMinOpacity[0]}set atmosphereMinOpacity(e){this._atmosphereMaxMinOpacity[1]=e}get atmosphereMinOpacity(){return this._atmosphereMaxMinOpacity[1]}set atmosphereEnabled(e){e!=this._atmosphereEnabled&&(this._atmosphereEnabled=e,this._initializeAtmosphere())}get atmosphereEnabled(){return this._atmosphereEnabled}set diffuse(e){let t=qe(e);this._diffuse=new Float32Array(t.toArray())}set ambient(e){let t=qe(e);this._ambient=new Float32Array(t.toArray())}set specular(e){let t=qe(e);this._specular=new Float32Array([t.x,t.y,t.y,this._specular[3]])}set shininess(e){this._specular[3]=e}get normalMapCreator(){return this._normalMapCreator}get layers(){return[...this._layers]}get sun(){if(this.renderer&&this.renderer.controls.sun)return this.renderer.controls.sun}get sunPos(){return this.sun.sunlight.getPosition()}addControl(e){e.planet=this,e.addTo(this.renderer)}addControls(e){for(let t=0;t<e.length;t++)this.addControl(e[t])}getLayerByName(e){for(let t=0,i=this._layers.length;t<i;t++)if(e===this._layers[t].name)return this._layers[t]}addLayer(e){e.addTo(this)}_onLayerVisibilityChanged(e){this.events.dispatch(this.events.layervisibilitychange,e)}addLayers(e){for(let t=0,i=e.length;t<i;t++)this.addLayer(e[t])}removeLayer(e){e.remove()}_clearLayerMaterial(e){this.quadTreeStrategy.clearLayerMaterial(e)}setBaseLayer(e){this.baseLayer?this.baseLayer.isEqual(e)||(this.baseLayer.setVisibility(!1),this.baseLayer=e,e.setVisibility(!0),this.events.dispatch(this.events.baselayerchange,e)):(this.baseLayer=e,this.baseLayer.setVisibility(!0),this.events.dispatch(this.events.baselayerchange,e))}setHeightFactor(e){this._heightFactor!==e&&(this._heightFactor=e,this.quadTreeStrategy.destroyBranches(),this.quadTreeStrategy.clearRenderedNodes())}getHeightFactor(){return this._heightFactor}setTerrain(e){this._initialized&&this.memClear(),this.terrain&&(this.terrain.abortLoading(),this.terrain.clearCache(),this.terrain._planet=null),this.terrain=e,this.terrain._planet=this,this.quadTreeStrategy.destroyBranches(),e._geoid.model?(this._plainSegmentWorker.setGeoid(e.getGeoid()),e._isReady=!0):lo.loadModel(e.geoid.src).then(t=>{e.geoid.setModel(t),this._plainSegmentWorker.setGeoid(e.getGeoid()),e._isReady=!0}).catch(t=>{console.warn(t)})}initAtmosphereShader(e){if(this.renderer&&this.renderer.handler&&this._atmosphereEnabled){let t=this.renderer.handler;t.isWebGl2()?(t.removeProgram("drawnode_screen_wl"),t.addProgram(to(e))):console.warn("Atmosphere WebGL2 only")}}get atmosphereControl(){return this._atmosphere}_initializeAtmosphere(){if(!this.renderer)return;let e=this.renderer.handler;e.removeProgram("drawnode_screen_wl"),this._atmosphereEnabled?(this._renderScreenNodesPASS=this._renderScreenNodesPASSAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSAtmos,this.renderer.controls.Atmosphere||this.addControl(this._atmosphere),this._atmosphere.activate(),e.isWebGl2()?e.addProgram(to(this._atmosphere.parameters)):e.addProgram(eo()),this.renderer.controls.SimpleSkyBackground&&this.renderer.controls.SimpleSkyBackground.deactivate()):(this._renderScreenNodesPASS=this._renderScreenNodesPASSNoAtmos,this._renderScreenNodesWithHeightPASS=this._renderScreenNodesWithHeightPASSNoAtmos,this._atmosphere.deactivate(),this.renderer.controls.SimpleSkyBackground?this.renderer.controls.SimpleSkyBackground.activate():this.addControl(new ba),e.isWebGl2()?e.addProgram(new X("drawnode_screen_wl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",height:"float",uGlobalTextureCoord:"vec4",uNormalMapBias:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",uNormalMap:"sampler2d",nightTexture:"sampler2d",specularTexture:"sampler2d",lightPosition:"vec3",diffuse:"vec3",ambient:"vec3",specular:"vec4",camHeight:"float",nightTextureCoefficient:"float",transitionOpacity:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:`#version 300 es
839
839
  precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;in vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec4 uGlobalTextureCoord;uniform vec3 uNormalMapBias;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;out vec4 vTextureCoord;out vec3 v_vertex;out vec3 cameraPosition;out vec2 vGlobalTextureCoord;out float v_height;void main(void){vec3 aVertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 nh=height*normalize(aVertexPosition);vTextureCoord.xy=aTextureCoord;vGlobalTextureCoord=uGlobalTextureCoord.xy+(uGlobalTextureCoord.zw-uGlobalTextureCoord.xy)*aTextureCoord;vTextureCoord.zw=uNormalMapBias.z*(aTextureCoord+uNormalMapBias.xy);cameraPosition=eyePositionHigh+eyePositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);v_height=height;v_vertex=aVertexPosition+nh;gl_Position=projectionMatrix*viewMatrixRTE*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}`,fragmentShader:`#version 300 es
840
840
  precision highp float;float getLerpValue(in float min,in float max,in float between){return(clamp(between,min,max)-min)/(max-min);}vec3 aces(vec3 color){float a=2.51;float b=0.03;float c=2.43;float d=0.59;float e=0.14;return clamp((color*(a*color+b))/(color*(c*color+d)+e),0.0,1.0);}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t1,inout float t2){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t1=-b-sqrt(d);t2=-b+sqrt(d);return true;}bool intersectSphere(vec3 rayOrigin,vec3 rayDirection,float radius,inout float t){float b=dot(rayDirection,rayOrigin);float c=dot(rayOrigin,rayOrigin)-radius*radius;float d=b*b-c;if(d<0.0){return false;}t=-b-sqrt(d);return true;}float intersectSphere(vec3 ro,vec3 rd,vec4 sph){vec3 oc=ro-sph.xyz;float b=dot(oc,rd);float c=dot(oc,oc)-sph.w*sph.w;float h=b*b-c;if(h<0.0)return-1.0;h=sqrt(h);return-b-h;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}t=(-b-sqrt(h))/a;return true;}bool intersectEllipsoid(in vec3 ro,in vec3 rd,in vec3 ra,inout float t1,inout float t2){vec3 ocn=ro/ra;vec3 rdn=rd/ra;float a=dot(rdn,rdn);float b=dot(ocn,rdn);float c=dot(ocn,ocn);float h=b*b-a*(c-1.0);if(h<0.0){return false;}h=sqrt(h);t1=(-b-h)/a;t2=(-b+h)/a;return true;}vec3 normalEllipsoid(in vec3 pos,in vec3 ra){return normalize(pos/(ra*ra));}
841
841
  #ifdef WEBGL2
@@ -846,7 +846,7 @@ precision highp float;float getLerpValue(in float min,in float max,in float betw
846
846
  #define SLICE_SIZE 5
847
847
  #define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;
848
848
  #define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);
849
- const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec3 lightPosition;uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform float transitionOpacity;uniform float camHeight;in vec4 vTextureCoord;in vec3 v_vertex;in vec3 cameraPosition;in vec2 vGlobalTextureCoord;in float v_height;vec3 sunPos;layout(location=0)out vec4 diffuseColor;void main(void){sunPos=lightPosition;vec3 texNormal=texture(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);float overGround=1.0-step(0.1,v_height);float shininess=texture(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+diffuse*diffuseLightWeighting+night,1.0);diffuseColor=texture(defaultTexture,vTextureCoord.xy);if(samplerCount==0){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}vec4 src;blend(diffuseColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;}`}),!0):e.addProgram(Jo(),!0))}_initializeShaders(){let e=this.renderer.handler;e.addProgram(new X("drawnode_screen_nl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",height:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"precision highp float;attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec2 vTextureCoord;void main(void){vTextureCoord=aTextureCoord;vec3 nh=height*normalize(aVertexPositionHigh+aVertexPositionLow);mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);mat4 m=projectionMatrix*viewMatrixRTE;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;gl_Position=m*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;
849
+ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 specular;uniform vec3 diffuse;uniform vec3 ambient;uniform sampler2D uNormalMap;uniform sampler2D nightTexture;uniform sampler2D specularTexture;uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec3 lightPosition;uniform float layerOpacityArr[SLICE_SIZE];uniform int samplerCount;uniform float nightTextureCoefficient;uniform float transitionOpacity;uniform float camHeight;in vec4 vTextureCoord;in vec3 v_vertex;in vec3 cameraPosition;in vec2 vGlobalTextureCoord;in float v_height;vec3 sunPos;layout(location=0)out vec4 diffuseColor;void main(void){sunPos=lightPosition;vec3 texNormal=texture(uNormalMap,vTextureCoord.zw).rgb;vec3 normal=normalize((texNormal-0.5)*2.0);float minH=1200000.0;float maxH=minH*3.0;float nightCoef=getLerpValue(minH,maxH,camHeight)*nightTextureCoefficient;vec3 lightDir=normalize(sunPos);vec3 viewDir=normalize(cameraPosition-v_vertex);float overGround=1.0-step(0.1,v_height);float shininess=texture(specularTexture,vGlobalTextureCoord.st).r*255.0*overGround;vec3 reflectionDirection=reflect(-lightDir,normal);float reflection=max(dot(reflectionDirection,viewDir),0.0);vec3 spec=specular.rgb*pow(reflection,specular.w)*shininess;float diffuseLightWeighting=max(dot(normal,lightDir),0.0);vec4 nightImageColor=texture(nightTexture,vGlobalTextureCoord.st);vec3 night=nightStep*(.18-diffuseLightWeighting*3.0)*nightImageColor.rgb*nightCoef;night*=overGround*step(0.0,night);vec4 lightWeighting=vec4(ambient+diffuse*diffuseLightWeighting+night,1.0);diffuseColor=texture(defaultTexture,vTextureCoord.xy);if(samplerCount==0){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}vec4 src;blend(diffuseColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4){diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;return;}blend(diffuseColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);diffuseColor=diffuseColor*lightWeighting+vec4(spec,0.0);diffuseColor*=transitionOpacity;}`})):e.addProgram(eo()))}_initializeShaders(){if(!this.renderer)throw new Error("Renderer is not initialized");let e=this.renderer,t=e.handler;t.addProgram(new X("drawnode_screen_nl",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",samplerCount:"int",tileOffsetArr:"vec4",layerOpacityArr:"float",samplerArr:"sampler2darray",defaultTexture:"sampler2d",height:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"precision highp float;attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec2 vTextureCoord;void main(void){vTextureCoord=aTextureCoord;vec3 nh=height*normalize(aVertexPositionHigh+aVertexPositionLow);mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);mat4 m=projectionMatrix*viewMatrixRTE;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;gl_Position=m*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;
850
850
  #ifdef WEBGL2
851
851
  #define TEXTURE_FUNC texture
852
852
  #else
@@ -855,7 +855,7 @@ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 specular;uniform vec
855
855
  #define SLICE_SIZE 5
856
856
  #define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;
857
857
  #define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);
858
- const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 tileOffsetArr[SLICE_SIZE];uniform float layerOpacityArr[SLICE_SIZE];uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform int samplerCount;varying vec2 vTextureCoord;void main(void){gl_FragColor=texture2D(defaultTexture,vTextureCoord);if(samplerCount==0)return;vec4 src;blend(gl_FragColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1)return;blend(gl_FragColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2)return;blend(gl_FragColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3)return;blend(gl_FragColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4)return;blend(gl_FragColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);}`}),!0),e.addProgram(new X("drawnode_colorPicking",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",samplerCount:"int",tileOffsetArr:"vec4",samplerArr:"sampler2darray",pickingMaskArr:"sampler2darray",pickingColorArr:"vec4",height:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"precision highp float;attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec2 vTextureCoord;void main(void){vTextureCoord=aTextureCoord;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);mat4 m=projectionMatrix*viewMatrixRTE;vec3 nh=height*normalize(aVertexPositionHigh+aVertexPositionLow);vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;gl_Position=m*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;
858
+ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 tileOffsetArr[SLICE_SIZE];uniform float layerOpacityArr[SLICE_SIZE];uniform sampler2D defaultTexture;uniform sampler2D samplerArr[SLICE_SIZE];uniform int samplerCount;varying vec2 vTextureCoord;void main(void){gl_FragColor=texture2D(defaultTexture,vTextureCoord);if(samplerCount==0)return;vec4 src;blend(gl_FragColor,samplerArr[0],tileOffsetArr[0],layerOpacityArr[0]);if(samplerCount==1)return;blend(gl_FragColor,samplerArr[1],tileOffsetArr[1],layerOpacityArr[1]);if(samplerCount==2)return;blend(gl_FragColor,samplerArr[2],tileOffsetArr[2],layerOpacityArr[2]);if(samplerCount==3)return;blend(gl_FragColor,samplerArr[3],tileOffsetArr[3],layerOpacityArr[3]);if(samplerCount==4)return;blend(gl_FragColor,samplerArr[4],tileOffsetArr[4],layerOpacityArr[4]);}`})),t.addProgram(new X("drawnode_colorPicking",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",eyePositionHigh:"vec3",eyePositionLow:"vec3",samplerCount:"int",tileOffsetArr:"vec4",samplerArr:"sampler2darray",pickingMaskArr:"sampler2darray",pickingColorArr:"vec4",height:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3",aTextureCoord:"vec2"},vertexShader:"precision highp float;attribute vec3 aVertexPositionHigh;attribute vec3 aVertexPositionLow;attribute vec2 aTextureCoord;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;varying vec2 vTextureCoord;void main(void){vTextureCoord=aTextureCoord;mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);mat4 m=projectionMatrix*viewMatrixRTE;vec3 nh=height*normalize(aVertexPositionHigh+aVertexPositionLow);vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;gl_Position=m*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}",fragmentShader:`precision highp float;
859
859
  #ifdef WEBGL2
860
860
  #define TEXTURE_FUNC texture
861
861
  #else
@@ -864,9 +864,9 @@ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 tileOffsetArr[SLICE_
864
864
  #define SLICE_SIZE 5
865
865
  #define blend(DEST, SAMPLER, OFFSET, OPACITY) src = TEXTURE_FUNC(SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw); DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;
866
866
  #define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; t = TEXTURE_FUNC(SAMPLER, tc); p = TEXTURE_FUNC(MASK, tc); DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0: 1.0) * COLOR.a);
867
- const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec4 pickingColorArr[SLICE_SIZE];uniform sampler2D samplerArr[SLICE_SIZE];uniform sampler2D pickingMaskArr[SLICE_SIZE];uniform int samplerCount;varying vec2 vTextureCoord;void main(void){gl_FragColor=vec4(0.0);if(samplerCount==0)return;vec2 tc;vec4 t;vec4 p;blendPicking(gl_FragColor,tileOffsetArr[0],samplerArr[0],pickingMaskArr[0],pickingColorArr[0],1.0);if(samplerCount==1)return;blendPicking(gl_FragColor,tileOffsetArr[1],samplerArr[1],pickingMaskArr[1],pickingColorArr[1],1.0);if(samplerCount==2)return;blendPicking(gl_FragColor,tileOffsetArr[2],samplerArr[2],pickingMaskArr[2],pickingColorArr[2],1.0);if(samplerCount==3)return;blendPicking(gl_FragColor,tileOffsetArr[3],samplerArr[3],pickingMaskArr[3],pickingColorArr[3],1.0);if(samplerCount==4)return;blendPicking(gl_FragColor,tileOffsetArr[4],samplerArr[4],pickingMaskArr[4],pickingColorArr[4],1.0);}`}),!0),e.addProgram(new X("drawnode_depth",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",height:"float",eyePositionHigh:"vec3",eyePositionLow:"vec3",frustumPickingColor:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3"},vertexShader:`#version 300 es
867
+ const vec3 nightStep=10.0*vec3(0.58,0.48,0.25);uniform vec4 tileOffsetArr[SLICE_SIZE];uniform vec4 pickingColorArr[SLICE_SIZE];uniform sampler2D samplerArr[SLICE_SIZE];uniform sampler2D pickingMaskArr[SLICE_SIZE];uniform int samplerCount;varying vec2 vTextureCoord;void main(void){gl_FragColor=vec4(0.0);if(samplerCount==0)return;vec2 tc;vec4 t;vec4 p;blendPicking(gl_FragColor,tileOffsetArr[0],samplerArr[0],pickingMaskArr[0],pickingColorArr[0],1.0);if(samplerCount==1)return;blendPicking(gl_FragColor,tileOffsetArr[1],samplerArr[1],pickingMaskArr[1],pickingColorArr[1],1.0);if(samplerCount==2)return;blendPicking(gl_FragColor,tileOffsetArr[2],samplerArr[2],pickingMaskArr[2],pickingColorArr[2],1.0);if(samplerCount==3)return;blendPicking(gl_FragColor,tileOffsetArr[3],samplerArr[3],pickingMaskArr[3],pickingColorArr[3],1.0);if(samplerCount==4)return;blendPicking(gl_FragColor,tileOffsetArr[4],samplerArr[4],pickingMaskArr[4],pickingColorArr[4],1.0);}`})),t.addProgram(new X("drawnode_depth",{uniforms:{projectionMatrix:"mat4",viewMatrix:"mat4",height:"float",eyePositionHigh:"vec3",eyePositionLow:"vec3",frustumPickingColor:"float"},attributes:{aVertexPositionHigh:"vec3",aVertexPositionLow:"vec3"},vertexShader:`#version 300 es
868
868
  precision highp float;in vec3 aVertexPositionHigh;in vec3 aVertexPositionLow;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform vec3 eyePositionHigh;uniform vec3 eyePositionLow;uniform float height;void main(void){mat4 viewMatrixRTE=viewMatrix;viewMatrixRTE[3]=vec4(0.0,0.0,0.0,1.0);mat4 m=projectionMatrix*viewMatrixRTE;vec3 nh=height*normalize(aVertexPositionHigh+aVertexPositionLow);vec3 eyePosition=eyePositionHigh+eyePositionLow;vec3 vertexPosition=aVertexPositionHigh+aVertexPositionLow;vec3 highDiff=aVertexPositionHigh-eyePositionHigh;vec3 lowDiff=aVertexPositionLow-eyePositionLow+nh;gl_Position=m*vec4(highDiff*step(1.0,length(highDiff))+lowDiff,1.0);}`,fragmentShader:`#version 300 es
869
- precision highp float;uniform float frustumPickingColor;layout(location=0)out vec4 frustumColor;layout(location=1)out vec4 depthColor;void main(void){frustumColor=vec4(frustumPickingColor,frustumPickingColor,frustumPickingColor,1.0);depthColor=vec4(gl_FragCoord.z,gl_FragCoord.z,gl_FragCoord.z,1.0);}`}),!0),this.renderer.addPickingCallback(this,this._renderColorPickingFramebufferPASS),this.renderer.addDepthCallback(this,this._renderDepthFramebufferPASS)}_onLayerLoadend(e){this.events.dispatch(this.events.layerloadend,e)}init(){this._tileLoader.events.on("layerloadend",this._onLayerLoadend,this),Zi().setMaxGridSize(this._maxGridSize);const e=this._maxGridSize;let t=0;for(let s=0;s<=e;s++){!this._indexesCache[s]&&(this._indexesCache[s]=new Array(e));for(let r=0;r<=e;r++){!this._indexesCache[s][r]&&(this._indexesCache[s][r]=new Array(e));for(let n=0;n<=e;n++){!this._indexesCache[s][r][n]&&(this._indexesCache[s][r][n]=new Array(e));for(let o=0;o<=e;o++){!this._indexesCache[s][r][n][o]&&(this._indexesCache[s][r][n][o]=new Array(e));for(let l=0;l<=e;l++){let h={buffer:null};if(s>=1&&s===r&&s===n&&s===o&&s===l){let c=Zi().createSegmentIndexes(s,[r,n,o,l]);h.buffer=this.renderer.handler.createElementArrayBuffer(c,1)}else this._indexesCacheToRemove[t++]=h;this._indexesCache[s][r][n][o][l]=h}}}}}this.renderer.events.on("resize",()=>{this._renderCompletedActivated=!1,this._terrainCompletedActivated=!1}),this.renderer.events.on("drawtransparent",()=>{this._renderScreenNodesWithHeightPASS()}),this._textureCoordsBufferCache=[];let i=Zi().initTextureCoordsTable(e+1);for(let s=0;s<=e;s++)this._textureCoordsBufferCache[s]=this.renderer.handler.createArrayBuffer(i[s],2,(1+(1<<s))*(1+(1<<s)));this.renderer.handler.createDefaultTexture(null,s=>{this.solidTextureOne=s,this.solidTextureTwo=s}),this.transparentTexture=this.renderer.handler.transparentTexture,this._renderedNodesInFrustum=new Array(this.camera.frustums.length);for(let s=0,r=this._renderedNodesInFrustum.length;s<r;s++)this._renderedNodesInFrustum[s]=[];if(this.quadTreeStrategy.init(),this.drawMode=this.renderer.handler.gl.TRIANGLE_STRIP,this._initializeShaders(),this._initializeAtmosphere(),this._updateVisibleLayers(),this._nightTextureSrc){let s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{this._nightTexture=this.renderer.handler.createTextureDefault(s),this._nightTexture.default=!0},s.src=this._nightTextureSrc}if(this._specularTextureSrc){let s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{this._specularTexture=this.renderer.handler.createTextureDefault(s),this._specularTexture.default=!0},s.src=this._specularTextureSrc}this._geoImageCreator.init(),this._vectorTileCreator.init(),this._normalMapCreator.init(),this.renderer.events.on("draw",this._globalPreDraw,this,-100),this._preRender(),this.renderer.events.on("postdraw",()=>{this._checkRendercompleted()}),this.initLayers(),this._initialized=!0,this._initialViewExtent&&this.viewExtent(this._initialViewExtent),this.renderer.activeCamera=this.camera,this.camera.bindFrustumsPickingColors(this.renderer),this.camera.update()}initLayers(){let e=[...this._layers];for(let t=0;t<e.length;t++)this.removeLayer(e[t]),this.addLayer(e[t])}_clearIndexesCache(){this._indexesCacheToRemoveCounter=0;let e=this._indexesCacheToRemove,t=this.renderer.handler.gl;for(let i=0,s=e.length;i<s;i++){let r=e[i];t.deleteBuffer(r.buffer),r.buffer=null}}_preRender(){this.quadTreeStrategy.preRender(),this._preLoad()}_preLoad(){this._clearRenderedNodeList(),this._skipPreRender=!1,this.quadTreeStrategy.preLoad()}createDefaultTextures(e,t){this.renderer.handler.gl.deleteTexture(this.solidTextureOne),this.renderer.handler.gl.deleteTexture(this.solidTextureTwo),this.renderer.handler.createDefaultTexture(e,i=>{this.solidTextureOne=i}),this.renderer.handler.createDefaultTexture(t,i=>{this.solidTextureTwo=i})}_getLayerAttributionHTML(e){return`<div class="og-attribution__layer">${e.getAttribution()}</div>`}updateAttributionsList(){let e="";for(let t=0,i=this._layers.length;t<i;t++){let s=this._layers[t];s.getVisibility()&&s.getAttribution().length&&(e+=this._getLayerAttributionHTML(s))}this._applyAttribution(e)}updateVisibleLayers(){this._updateLayers=!0}_updateVisibleLayers(){this.visibleTileLayers=[],this.visibleTileLayers.length=0,this.visibleVectorLayers=[],this.visibleVectorLayers.length=0;let e="";for(let t=0,i=this._layers.length;t<i;t++){let s=this._layers[t];s.getVisibility()?(s.isBaseLayer()&&(this.createDefaultTextures(s._defaultTextures[0],s._defaultTextures[1]),this.baseLayer=s),s.hasImageryTiles()&&this.visibleTileLayers.push(s),s.isVector&&this.visibleVectorLayers.push(s),s.getAttribution().length&&(e+=this._getLayerAttributionHTML(s))):s._fading&&s._fadingOpacity>0&&(s.hasImageryTiles()&&this.visibleTileLayers.push(s),s.isVector&&this.visibleVectorLayers.push(s))}this._applyAttribution(e),this._sortLayers()}_applyAttribution(e){this.renderer&&this.renderer.div&&(e.length?this.renderer.div.attributions.innerHTML!==e&&(this.renderer.div.attributions.innerHTML=e):this.renderer.div.attributions.innerHTML="")}_sortLayers(){this.visibleVectorLayers.sort((t,i)=>t.getZIndex()-i.getZIndex()||t.getHeight()-i.getHeight());let e={0:[]};for(const t of this.visibleVectorLayers)e[t.depthOrder]||(e[t.depthOrder]=[]),e[t.depthOrder].push(t);if(this._visibleVectorLayersByDepthOrder.length=0,this._visibleVectorLayersByDepthOrder=[],this._visibleVectorLayersByDepthOrder=Object.keys(e).sort((t,i)=>Number(t)-Number(i)).map(t=>e[Number(t)]),this._visibleTileLayerSlices=[],this._visibleTileLayerSlices.length=0,this.visibleTileLayers.length){this.visibleTileLayers.sort((s,r)=>s.getHeight()-r.getHeight()||s.getZIndex()-r.getZIndex());let t=-1,i=this.visibleTileLayers[0].getHeight();for(let s=0,r=this.visibleTileLayers.length;s<r;s++)s%this.SLICE_SIZE!=0&&this.visibleTileLayers[s].getHeight()===i||(t++,this._visibleTileLayerSlices[t]=[],i=this.visibleTileLayers[s].getHeight()),this._visibleTileLayerSlices[t].push(this.visibleTileLayers[s])}}_clearRenderedNodeList(){this._renderedNodes.length=0,this._renderedNodes=[]}_clearRenderNodesInFrustum(){for(let e=0,t=this._renderedNodesInFrustum.length;e<t;e++)this._renderedNodesInFrustum[e].length=0,this._renderedNodesInFrustum[e]=[]}_collectRenderedNodesMaxZoom(e){if(e.slope>this.minEqualZoomCameraSlope&&e._lonLat.height<this.maxEqualZoomAltitude&&e._lonLat.height>this.minEqualZoomAltitude){this.minCurrZoom=this.maxCurrZoom;let t=this._renderedNodes,i=this._renderedNodesInFrustum,s=[];this._clearRenderNodesInFrustum(),this._renderedNodes=[];for(let r=0,n=t.length;r<n;r++){let o=t[r],l=o.segment.centerNormal.dot(e.getBackward());if(o.segment.tileZoom===this.maxCurrZoom||l<.81){this._renderedNodes.push(o);let h=0,c=o.inFrustum;for(;c;)1&c&&i[h].push(o),h++,c>>=1}else s.push(o)}for(let r=0,n=s.length;r<n;r++)s[r].renderTree(e,this.maxCurrZoom,null,!1,s[r])}}set transitionOpacityEnabled(e){this._transitionOpacityEnabled=e}get transitionOpacityEnabled(){return this._transitionOpacityEnabled}_collectRenderNodes(e){if(this._lodSize=Tr(e.slope<0?0:e.slope,this._curLodSize,this._minLodSize),e._insideSegment=null,this._clearRenderedNodeList(),this._clearRenderNodesInFrustum(),this._viewExtent.southWest.set(180,180),this._viewExtent.northEast.set(-180,-180),this.minCurrZoom=ye,this.maxCurrZoom=Te,this.quadTreeStrategy.collectRenderNodes(),this._collectRenderedNodesMaxZoom(e),this._fadingNodes.clear(),this._transitionOpacityEnabled){let t=[];for(let i=0;i<this._renderedNodes.length;i++){let s=this._renderedNodes[i];if(s._collectFadingNodes(),s._refreshTransitionOpacity(),s.segment._transitionOpacity>=1)s.clearNeighbors(),s.getRenderedNodesNeighbors(t),t.push(s);else for(let r=0;r<s._fadingNodes.length;r++){let n=s._fadingNodes[r];n.segment&&n.segment._transitionOpacity>=1&&(n.clearNeighbors(),n.getRenderedNodesNeighbors(t),t.push(n))}}}}_renderScreenNodesPASSNoAtmos(){let e=this.renderer.activeCamera,t=this._setUniformsNoAtmos(e);this._renderingScreenNodes(t,e,this._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesPASSAtmos(){let e=this.renderer.activeCamera,t=this._setUniformsAtmos(e);this._renderingScreenNodes(t,e,this._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesWithHeightPASSNoAtmos(){let e=this.renderer.activeCamera,t=this._setUniformsNoAtmos(e);this._renderingScreenNodesWithHeight(t,e,this._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesWithHeightPASSAtmos(){let e=this.renderer.activeCamera,t=this._setUniformsAtmos(e);this._renderingScreenNodesWithHeight(t,e,this._renderedNodesInFrustum[e.currentFrustumIndex])}_globalPreDraw(){let e=this.camera;this._distBeforeMemClear+=this._prevCamEye.distance(e.eye),this._prevCamEye.copy(e.eye),e.checkFly(),this._createdNodesCount>this._maxNodes&&this._distBeforeMemClear>this._minDistanceBeforeMemClear&&(this.terrain.clearCache(),this.memClear()),this._indexesCacheToRemoveCounter>600&&this._clearIndexesCache()}preFrame(){this._updateLayers&&(this._updateLayers=!1,this._updateVisibleLayers()),this.camera.isFirstPass&&(this.camera.update(),this._skipPreRender&&this._collectRenderNodesIsActive&&this._collectRenderNodes(this.camera),this._skipPreRender=!0,this._normalMapCreator.frame(),this._geoImageCreator.frame(),this._vectorTileCreator.frame(),this.camera.checkTerrainCollision(),this.camera.update(),this.events.dispatch(this.events.draw,this),this._collectVectorLayerCollections());for(let e=0;e<this._visibleEntityCollections.length;e++)this.drawEntityCollections(this._visibleEntityCollections[e],e)}frame(){this._renderScreenNodesPASS()}_checkRendercompleted(){this._renderCompleted?this._renderCompletedActivated||(this._renderCompletedActivated=!0,this.events.dispatch(this.events.rendercompleted,!0)):this._renderCompletedActivated=!1,this._renderCompleted=!0,this._terrainCompleted?this._terrainCompletedActivated||(this._terrainCompletedActivated=!0,this.events.dispatch(this.events.terraincompleted,!0)):this._terrainCompletedActivated=!1,this._terrainCompleted=!0}lockQuadTree(){this._collectRenderNodesIsActive=!1,this.camera.setTerrainCollisionActivity(!1)}unlockQuadTree(){this._collectRenderNodesIsActive=!0,this.camera.setTerrainCollisionActivity(!0)}_setUniformsNoAtmos(e){let t,i,s=this.renderer,r=s.handler,n=r.gl;return n.enable(n.CULL_FACE),s.enableBlendOneSrcAlpha(),this.lightEnabled?(r.programs.drawnode_screen_wl.activate(),t=r.programs.drawnode_screen_wl._program,i=t.uniforms,n.uniform3fv(i.lightPosition,this._lightPosition),n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix()),this.baseLayer?(n.uniform3fv(i.diffuse,this.baseLayer._diffuse||this._diffuse),n.uniform3fv(i.ambient,this.baseLayer._ambient||this._ambient),n.uniform4fv(i.specular,this.baseLayer._specular||this._specular),n.uniform1f(i.nightTextureCoefficient,this.baseLayer.nightTextureCoefficient||this.nightTextureCoefficient)):(n.uniform3fv(i.diffuse,this._diffuse),n.uniform3fv(i.ambient,this._ambient),n.uniform4fv(i.specular,this._specular),n.uniform1f(i.nightTextureCoefficient,this.nightTextureCoefficient)),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,this._nightTexture||this.transparentTexture),n.uniform1i(i.nightTexture,this.SLICE_SIZE),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+1),n.bindTexture(n.TEXTURE_2D,this._specularTexture||this.transparentTexture),n.uniform1i(i.specularTexture,this.SLICE_SIZE+1),n.uniform1f(i.camHeight,e.getHeight())):(r.programs.drawnode_screen_nl.activate(),t=r.programs.drawnode_screen_nl._program,i=t.uniforms,n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix())),n.uniform3fv(i.eyePositionHigh,e.eyeHigh),n.uniform3fv(i.eyePositionLow,e.eyeLow),t}_setUniformsAtmos(e){let t,i,s=this.renderer,r=s.handler,n=r.gl;return n.enable(n.CULL_FACE),s.enableBlendOneSrcAlpha(),this.lightEnabled?(r.programs.drawnode_screen_wl.activate(),t=r.programs.drawnode_screen_wl._program,i=t.uniforms,n.uniform3fv(i.lightPosition,this._lightPosition),n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix()),this.baseLayer?(n.uniform3fv(i.diffuse,this.baseLayer._diffuse||this._diffuse),n.uniform3fv(i.ambient,this.baseLayer._ambient||this._ambient),n.uniform4fv(i.specular,this.baseLayer._specular||this._specular),n.uniform1f(i.nightTextureCoefficient,this.baseLayer.nightTextureCoefficient||this.nightTextureCoefficient)):(n.uniform3fv(i.diffuse,this._diffuse),n.uniform3fv(i.ambient,this._ambient),n.uniform4fv(i.specular,this._specular),n.uniform1f(i.nightTextureCoefficient,this.nightTextureCoefficient)),n.uniform2fv(i.maxMinOpacity,this._atmosphereMaxMinOpacity),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,this._nightTexture||this.transparentTexture),n.uniform1i(i.nightTexture,this.SLICE_SIZE),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+1),n.bindTexture(n.TEXTURE_2D,this._specularTexture||this.transparentTexture),n.uniform1i(i.specularTexture,this.SLICE_SIZE+1),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+4),n.bindTexture(n.TEXTURE_2D,s.controls.Atmosphere._transmittanceBuffer.textures[0]),n.uniform1i(i.transmittanceTexture,this.SLICE_SIZE+4),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+5),n.bindTexture(n.TEXTURE_2D,s.controls.Atmosphere._scatteringBuffer.textures[0]),n.uniform1i(i.scatteringTexture,this.SLICE_SIZE+5),n.uniform1f(i.camHeight,e.getHeight())):(r.programs.drawnode_screen_nl.activate(),t=r.programs.drawnode_screen_nl._program,i=t.uniforms,n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix())),n.uniform3fv(i.eyePositionHigh,e.eyeHigh),n.uniform3fv(i.eyePositionLow,e.eyeLow),t}_renderingScreenNodes(e,t,i){let s=t.isFirstPass,r=this._visibleTileLayerSlices;if(r.length){let c=r[0];for(let d=c.length-1;d>=0;--d){let u=c[d];u._fading&&s&&u._refreshFadingOpacity()&&c.splice(d,1)}}let n=new Map,o=[],l=this.terrain.equalizeVertices,h=i.length;if(this._fadingOpaqueSegments=[],t.slope>.8||!this.terrain||this.terrain.isEmpty)for(;h--;){let c=i[h],d=c.segment;this._renderingFadingNodesNoDepth(n,e,c,r[0],0,this._fadingOpaqueSegments),l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(e,r[0],0)}else{for(;h--;){let c=i[h],d=c.segment;this._renderingFadingNodes(n,e,c,r[0],0,o,this._fadingOpaqueSegments),d._transitionOpacity<1?o.push(d):(l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(e,r[0],0))}for(let c=0;c<o.length;c++){let d=o[c];l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(e,r[0],0)}}}_renderingScreenNodesWithHeight(e,t,i){let s=this.renderer.handler.gl,r=t.isFirstPass,n=this._visibleTileLayerSlices;s.enable(s.POLYGON_OFFSET_FILL),s.disable(s.CULL_FACE);let o=new Map,l=[];for(let h=1,c=n.length;h<c;h++){let d=n[h];for(let g=d.length-1;g>=0;--g){let f=d[g];f._fading&&r&&f._refreshFadingOpacity()&&d.splice(g,1)}s.polygonOffset(0,-h);let u=i.length;for(;u--;){let g=i[u];this._renderingFadingNodes(o,e,g,n[h],h,l),g.segment._transitionOpacity<1?g.segment.initSlice(h):g.segment.screenRendering(e,n[h],h,this.transparentTexture,!0)}}s.disable(s.POLYGON_OFFSET_FILL),s.enable(s.CULL_FACE)}_renderColorPickingFramebufferPASS(){let e,t=this.renderer,i=t.handler,s=i.gl;i.programs.drawnode_colorPicking.activate(),e=i.programs.drawnode_colorPicking._program;let r=e.uniforms,n=t.activeCamera;s.enable(s.CULL_FACE),s.uniformMatrix4fv(r.viewMatrix,!1,n.getViewMatrix()),s.uniformMatrix4fv(r.projectionMatrix,!1,n.getProjectionMatrix()),s.uniform3fv(r.eyePositionHigh,n.eyeHigh),s.uniform3fv(r.eyePositionLow,n.eyeLow);let o=this._renderedNodesInFrustum[n.getCurrentFrustum()],l=this._visibleTileLayerSlices,h=o.length;for(;h--;)o[h].segment._transitionOpacity>=1&&o[h].segment.colorPickingRendering(e,l[0],0);for(let c=0;c<this._fadingOpaqueSegments.length;++c)this._fadingOpaqueSegments[c].colorPickingRendering(e,l[0],0);t.enableBlendDefault(),s.enable(s.POLYGON_OFFSET_FILL);for(let c=1,d=l.length;c<d;c++)for(h=o.length,s.polygonOffset(0,-c);h--;)o[h].segment.colorPickingRendering(e,l[c],c,this.transparentTexture,!0);s.disable(s.POLYGON_OFFSET_FILL)}_renderDepthFramebufferPASS(){let e,t=this.renderer,i=t.handler,s=i.gl;i.programs.drawnode_depth.activate(),e=i.programs.drawnode_depth._program;let r=e.uniforms,n=t.activeCamera;s.disable(s.BLEND),s.disable(s.POLYGON_OFFSET_FILL),s.uniformMatrix4fv(r.viewMatrix,!1,n.getViewMatrix()),s.uniformMatrix4fv(r.projectionMatrix,!1,n.getProjectionMatrix()),s.uniform3fv(r.eyePositionHigh,n.eyeHigh),s.uniform3fv(r.eyePositionLow,n.eyeLow),s.uniform1f(r.frustumPickingColor,n.frustumColorIndex);let o=this._renderedNodesInFrustum[n.getCurrentFrustum()],l=this._visibleTileLayerSlices,h=o.length;for(;h--;)o[h].segment._transitionOpacity>=1&&o[h].segment.depthRendering(e,l[0]);for(let c=0;c<this._fadingOpaqueSegments.length;++c)this._fadingOpaqueSegments[c].depthRendering(e,l[0]);s.enable(s.BLEND)}_collectVectorLayerCollections(){let e=this._visibleVectorLayersByDepthOrder.length;this._visibleEntityCollections.length=0,this._visibleEntityCollections=new Array(e);for(let t=0;t<this._visibleEntityCollections.length;t++)this._visibleEntityCollections[t]=[];for(;e--;){let t=this._visibleVectorLayersByDepthOrder[e],i=t.length;for(;i--;){let s=t[i];s._fading&&s._refreshFadingOpacity()&&(t.splice(i,1),t.length===0&&this._visibleVectorLayersByDepthOrder.splice(e,1)),s.collectVisibleCollections(this._visibleEntityCollections[e]),s.update()}}}memClear(){this._distBeforeMemClear=0,this.camera._insideSegment=null,this.layerLock.lock(this._memKey),this.terrainLock.lock(this._memKey),this._normalMapCreator.lock(this._memKey),this._normalMapCreator.clear(),this.terrain.abortLoading(),this._tileLoader.abortAll(),this.quadTreeStrategy.clear(),this.layerLock.free(this._memKey),this.terrainLock.free(this._memKey),this._normalMapCreator.free(this._memKey),this._createdNodesCount=0}getRayIntersectionEllipsoid(e){return this.ellipsoid.hitRay(e.origin,e.direction)}getCartesianFromPixelEllipsoid(e){let t=this.renderer.activeCamera;return this.ellipsoid.hitRay(t.eye,t.unproject(e.x,e.y))}getLonLatFromPixelEllipsoid(e){let t=this.getCartesianFromPixelEllipsoid(e);if(t)return this.ellipsoid.cartesianToLonLat(t)}getCartesianFromMouseTerrain(){let e=this.renderer.events.mouseState,t=this.getDistanceFromPixel(e);if(t)return e.direction.scaleTo(t).addA(this.renderer.activeCamera.eye)}getCartesianFromPixelTerrain(e){let t=this.getDistanceFromPixel(e);if(t)return(e.direction||this.renderer.activeCamera.unproject(e.x,e.y)).scaleTo(t).addA(this.renderer.activeCamera.eye)}getLonLatFromPixelTerrain(e){let t=this.getCartesianFromPixelTerrain(e);if(t)return this.ellipsoid.cartesianToLonLat(t)}getPixelFromCartesian(e){return this.renderer.activeCamera.project3v(e)}getPixelFromLonLat(e){let t=this.ellipsoid.lonLatToCartesian(e);if(t)return this.renderer.activeCamera.project3v(t)}getDistanceFromPixelEllipsoid(e){let t=this.getCartesianFromPixelEllipsoid(e);if(t)return t.distance(this.renderer.activeCamera.eye)}getDistanceFromPixel(e){return this.renderer.getDistanceFromPixel(e)||this.getDistanceFromPixelEllipsoid(e)||0}viewExtent(e){this.camera?this.camera.viewExtent(e):this._initialViewExtent=e}viewExtentArr(e){this.viewExtent(new G(new A(e[0],e[1]),new A(e[2],e[3])))}getExtent(){if(this.renderer){let e=this.renderer.handler.getWidth(),t=this.renderer.handler.getHeight(),i=[this.getLonLatFromPixelTerrain(new N(0,0)),this.getLonLatFromPixelTerrain(new N(e,0)),this.getLonLatFromPixelTerrain(new N(e,t)),this.getLonLatFromPixelTerrain(new N(0,t))];if(i[0]&&i[1]&&i[2]&&i[3]){let s=i[0].lon,r=i[2].lat,n=i[1].lon,o=i[0].lat;for(let l=0;l<i.length;l++)i[l].lon>n&&(n=i[l].lon),i[l].lat>o&&(o=i[l].lat),i[l].lon<s&&(s=i[l].lon),i[l].lat<r&&(r=i[l].lat);return new G(new A(s,r),new A(n,o))}}return this._viewExtent}getViewExtent(){return this._viewExtent}viewLonLat(e,t,i){this.camera.setLonLat(e,t,i)}flyExtent(e,t,i,s,r=800,n=bt,o,l,h){this.camera.flyExtent(e,t,i,s,r,n,o,l,h)}flyCartesian(e,t,i,s,r=800,n=bt,o,l,h){this.camera.flyCartesian(e,t,i,s,r,n,o,l,h)}flyLonLat(e,t,i,s,r=800,n=bt,o,l,h){this.camera.flyLonLat(e,t,i,s,r,n,o,l,h)}stopFlying(){this.camera.stopFlying()}updateBillboardsTexCoords(){for(let t=0;t<this.entityCollections.length;t++)this.entityCollections[t].billboardHandler.refreshTexCoordsArr();let e={};for(let t=0;t<this._layers.length;t++){let i=this._layers[t];i instanceof ge&&i.each(function(s){s._entityCollection&&!e[s._entityCollection.id]&&(s._entityCollection.billboardHandler.refreshTexCoordsArr(),e[s._entityCollection.id]=!0)})}}getEntityTerrainPoint(e,t){let i=this._renderedNodes,s=i.length;for(;s--;)if(i[s].segment.isEntityInside(e))return i[s].segment.getEntityTerrainPoint(e,t)}async getHeightDefault(e){return new Promise(t=>{this.terrain?this.terrain.getHeightAsync(e.clone(),i=>{t(i)}):t(0)})}async getHeightAboveELL(e){return new Promise(t=>{this.terrain?this.terrain.getHeightAsync(e.clone(),i=>{t(i+this.terrain.geoid.getHeightLonLat(e))}):t(0)})}onremove(){this.memClear(),this.quadTreeStrategy.destroyBranches(),this._renderedNodes=[]}}const Hc=["draw","layeradd","baselayerchange","layerremove","layervisibilitychange","rendercompleted","terraincompleted","layerloadend"];class hr extends at{constructor(e){super("skybox"),this.params=e,this.vertexPositionBuffer=null,this.texture=null}static createDefault(e){return new hr({nx:e+"skybox/gal/_nx.jpg",px:e+"skybox/gal/_px.jpg",py:e+"skybox/gal/_py.jpg",ny:e+"skybox/gal/_ny.jpg",pz:e+"skybox/gal/_pz.jpg",nz:e+"skybox/gal/_nz.jpg"})}init(){this.renderer.handler.addProgram(new X("skybox",{uniforms:{projectionViewMatrix:{type:_e.MAT4},uSampler:{type:_e.SAMPLERCUBE},pos:{type:_e.VEC3}},attributes:{aVertexPosition:{type:_e.VEC3,enableArray:!0}},vertexShader:`attribute vec3 aVertexPosition;
869
+ precision highp float;uniform float frustumPickingColor;layout(location=0)out vec4 frustumColor;layout(location=1)out vec4 depthColor;void main(void){frustumColor=vec4(frustumPickingColor,frustumPickingColor,frustumPickingColor,1.0);depthColor=vec4(gl_FragCoord.z,gl_FragCoord.z,gl_FragCoord.z,1.0);}`})),e.addPickingCallback(this,this._renderColorPickingFramebufferPASS),e.addDepthCallback(this,()=>{this.renderDepthFramebuffer(this.camera,this.quadTreeStrategy)})}_onLayerLoadend(e){this.events.dispatch(this.events.layerloadend,e)}init(){this._tileLoader.events.on("layerloadend",this._onLayerLoadend,this),Zi().setMaxGridSize(this._maxGridSize);const e=this._maxGridSize;let t=0;for(let r=0;r<=e;r++){!this._indexesCache[r]&&(this._indexesCache[r]=new Array(e));for(let s=0;s<=e;s++){!this._indexesCache[r][s]&&(this._indexesCache[r][s]=new Array(e));for(let n=0;n<=e;n++){!this._indexesCache[r][s][n]&&(this._indexesCache[r][s][n]=new Array(e));for(let o=0;o<=e;o++){!this._indexesCache[r][s][n][o]&&(this._indexesCache[r][s][n][o]=new Array(e));for(let l=0;l<=e;l++){let h={buffer:null};if(r>=1&&r===s&&r===n&&r===o&&r===l){let c=Zi().createSegmentIndexes(r,[s,n,o,l]);h.buffer=this.renderer.handler.createElementArrayBuffer(c,1)}else this._indexesCacheToRemove[t++]=h;this._indexesCache[r][s][n][o][l]=h}}}}}this.renderer.events.on("drawtransparent",()=>{this._renderScreenNodesWithHeightPASS()}),this._textureCoordsBufferCache=[];let i=Zi().initTextureCoordsTable(e+1);for(let r=0;r<=e;r++)this._textureCoordsBufferCache[r]=this.renderer.handler.createArrayBuffer(i[r],2,(1+(1<<r))*(1+(1<<r)));if(this.renderer.handler.createDefaultTexture(null,r=>{this.solidTextureOne=r,this.solidTextureTwo=r}),this.transparentTexture=this.renderer.handler.transparentTexture,this.drawMode=this.renderer.handler.gl.TRIANGLE_STRIP,this._initializeShaders(),this._initializeAtmosphere(),this._updateVisibleLayers(),this._nightTextureSrc){let r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{this._nightTexture=this.renderer.handler.createTextureDefault(r),this._nightTexture.default=!0},r.src=this._nightTextureSrc}if(this._specularTextureSrc){let r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{this._specularTexture=this.renderer.handler.createTextureDefault(r),this._specularTexture.default=!0},r.src=this._specularTextureSrc}this._geoImageCreator.init(),this._vectorTileCreator.init(),this._normalMapCreator.init(),this.renderer.events.on("draw",this._globalPreDraw,this,-100),this.quadTreeStrategy.init(this.camera),this.initLayers(),this._initialized=!0,this._initialViewExtent&&this.viewExtent(this._initialViewExtent),this.renderer.activeCamera=this.camera,this.camera.bindFrustumsPickingColors(this.renderer),this.camera.update()}initLayers(){let e=[...this._layers];for(let t=0;t<e.length;t++)this.removeLayer(e[t]),this.addLayer(e[t])}_clearIndexesCache(){this._indexesCacheToRemoveCounter=0;let e=this._indexesCacheToRemove,t=this.renderer.handler.gl;for(let i=0,r=e.length;i<r;i++){let s=e[i];t.deleteBuffer(s.buffer),s.buffer=null}}createDefaultTextures(e,t){this.renderer.handler.gl.deleteTexture(this.solidTextureOne),this.renderer.handler.gl.deleteTexture(this.solidTextureTwo),this.renderer.handler.createDefaultTexture(e,i=>{this.solidTextureOne=i}),this.renderer.handler.createDefaultTexture(t,i=>{this.solidTextureTwo=i})}_getLayerAttributionHTML(e){return`<div class="og-attribution__layer">${e.getAttribution()}</div>`}updateAttributionsList(){let e="";for(let t=0,i=this._layers.length;t<i;t++){let r=this._layers[t];r.getVisibility()&&r.getAttribution().length&&(e+=this._getLayerAttributionHTML(r))}this._applyAttribution(e)}updateVisibleLayers(){this._updateLayers=!0}_updateVisibleLayers(){this.visibleTileLayers=[],this.visibleTileLayers.length=0,this.visibleVectorLayers=[],this.visibleVectorLayers.length=0;let e="";for(let t=0,i=this._layers.length;t<i;t++){let r=this._layers[t];r.getVisibility()?(r.isBaseLayer()&&(this.createDefaultTextures(r._defaultTextures[0],r._defaultTextures[1]),this.baseLayer=r),r.hasImageryTiles()&&this.visibleTileLayers.push(r),r.isVector&&this.visibleVectorLayers.push(r),r.getAttribution().length&&(e+=this._getLayerAttributionHTML(r))):r._fading&&r._fadingOpacity>0&&(r.hasImageryTiles()&&this.visibleTileLayers.push(r),r.isVector&&this.visibleVectorLayers.push(r))}this._applyAttribution(e),this._sortLayers()}_applyAttribution(e){this.renderer&&this.renderer.div&&(e.length?this.renderer.div.attributions.innerHTML!==e&&(this.renderer.div.attributions.innerHTML=e):this.renderer.div.attributions.innerHTML="")}_sortLayers(){this.visibleVectorLayers.sort((t,i)=>t.getZIndex()-i.getZIndex()||t.getHeight()-i.getHeight());let e={0:[]};for(const t of this.visibleVectorLayers)e[t.depthOrder]||(e[t.depthOrder]=[]),e[t.depthOrder].push(t);if(this._visibleVectorLayersByDepthOrder.length=0,this._visibleVectorLayersByDepthOrder=[],this._visibleVectorLayersByDepthOrder=Object.keys(e).sort((t,i)=>Number(t)-Number(i)).map(t=>e[Number(t)]),this._visibleTileLayerSlices=[],this._visibleTileLayerSlices.length=0,this.visibleTileLayers.length){this.visibleTileLayers.sort((r,s)=>r.getHeight()-s.getHeight()||r.getZIndex()-s.getZIndex());let t=-1,i=this.visibleTileLayers[0].getHeight();for(let r=0,s=this.visibleTileLayers.length;r<s;r++)r%this.SLICE_SIZE!=0&&this.visibleTileLayers[r].getHeight()===i||(t++,this._visibleTileLayerSlices[t]=[],i=this.visibleTileLayers[r].getHeight()),this._visibleTileLayerSlices[t].push(this.visibleTileLayers[r])}}_renderScreenNodesPASSNoAtmos(){let e=this.camera,t=this._setUniformsNoAtmos(e);this._renderingScreenNodes(this.quadTreeStrategy,t,e,this.quadTreeStrategy._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesPASSAtmos(){let e=this.camera,t=this._setUniformsAtmos(e);this._renderingScreenNodes(this.quadTreeStrategy,t,e,this.quadTreeStrategy._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesWithHeightPASSNoAtmos(){let e=this.camera,t=this._setUniformsNoAtmos(e);this._renderingScreenNodesWithHeight(this.quadTreeStrategy,t,e,this.quadTreeStrategy._renderedNodesInFrustum[e.currentFrustumIndex])}_renderScreenNodesWithHeightPASSAtmos(){let e=this.camera,t=this._setUniformsAtmos(e);this._renderingScreenNodesWithHeight(this.quadTreeStrategy,t,e,this.quadTreeStrategy._renderedNodesInFrustum[e.currentFrustumIndex])}_globalPreDraw(){let e=this.camera;this._distBeforeMemClear+=this._prevCamEye.distance(e.eye),this._prevCamEye.copy(e.eye),this._createdNodesCount>this._maxNodes&&this._distBeforeMemClear>this._minDistanceBeforeMemClear&&(this.terrain.clearCache(),this.memClear()),this._indexesCacheToRemoveCounter>600&&this._clearIndexesCache()}preFrame(){this._updateLayers&&(this._updateLayers=!1,this._updateVisibleLayers()),this.camera.isFirstPass&&(this.camera.update(),this._collectRenderNodesIsActive&&this.quadTreeStrategy.collectRenderNodes(this.camera),this._normalMapCreator.frame(),this._geoImageCreator.frame(),this._vectorTileCreator.frame(),this.camera.checkTerrainCollision(),this.camera.update(),this.events.dispatch(this.events.draw,this),this._collectVectorLayerCollections());for(let e=0;e<this._visibleEntityCollections.length;e++)this.drawEntityCollections(this._visibleEntityCollections[e],e)}frame(){this._renderScreenNodesPASS()}lockQuadTree(){this._collectRenderNodesIsActive=!1,this.camera.setTerrainCollisionActivity(!1)}unlockQuadTree(){this._collectRenderNodesIsActive=!0,this.camera.setTerrainCollisionActivity(!0)}_setUniformsNoAtmos(e){let t,i,r=this.renderer,s=r.handler,n=s.gl;return n.enable(n.CULL_FACE),r.enableBlendOneSrcAlpha(),this.lightEnabled?(s.programs.drawnode_screen_wl.activate(),t=s.programs.drawnode_screen_wl._program,i=t.uniforms,n.uniform3fv(i.lightPosition,this._lightPosition),n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix()),this.baseLayer?(n.uniform3fv(i.diffuse,this.baseLayer._diffuse||this._diffuse),n.uniform3fv(i.ambient,this.baseLayer._ambient||this._ambient),n.uniform4fv(i.specular,this.baseLayer._specular||this._specular),n.uniform1f(i.nightTextureCoefficient,this.baseLayer.nightTextureCoefficient||this.nightTextureCoefficient)):(n.uniform3fv(i.diffuse,this._diffuse),n.uniform3fv(i.ambient,this._ambient),n.uniform4fv(i.specular,this._specular),n.uniform1f(i.nightTextureCoefficient,this.nightTextureCoefficient)),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,this._nightTexture||this.transparentTexture),n.uniform1i(i.nightTexture,this.SLICE_SIZE),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+1),n.bindTexture(n.TEXTURE_2D,this._specularTexture||this.transparentTexture),n.uniform1i(i.specularTexture,this.SLICE_SIZE+1),n.uniform1f(i.camHeight,e.getHeight())):(s.programs.drawnode_screen_nl.activate(),t=s.programs.drawnode_screen_nl._program,i=t.uniforms,n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix())),n.uniform3fv(i.eyePositionHigh,e.eyeHigh),n.uniform3fv(i.eyePositionLow,e.eyeLow),t}_setUniformsAtmos(e){let t,i,r=this.renderer,s=r.handler,n=s.gl;return n.enable(n.CULL_FACE),r.enableBlendOneSrcAlpha(),this.lightEnabled?(s.programs.drawnode_screen_wl.activate(),t=s.programs.drawnode_screen_wl._program,i=t.uniforms,n.uniform3fv(i.lightPosition,this._lightPosition),n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix()),this.baseLayer?(n.uniform3fv(i.diffuse,this.baseLayer._diffuse||this._diffuse),n.uniform3fv(i.ambient,this.baseLayer._ambient||this._ambient),n.uniform4fv(i.specular,this.baseLayer._specular||this._specular),n.uniform1f(i.nightTextureCoefficient,this.baseLayer.nightTextureCoefficient||this.nightTextureCoefficient)):(n.uniform3fv(i.diffuse,this._diffuse),n.uniform3fv(i.ambient,this._ambient),n.uniform4fv(i.specular,this._specular),n.uniform1f(i.nightTextureCoefficient,this.nightTextureCoefficient)),n.uniform2fv(i.maxMinOpacity,this._atmosphereMaxMinOpacity),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE),n.bindTexture(n.TEXTURE_2D,this._nightTexture||this.transparentTexture),n.uniform1i(i.nightTexture,this.SLICE_SIZE),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+1),n.bindTexture(n.TEXTURE_2D,this._specularTexture||this.transparentTexture),n.uniform1i(i.specularTexture,this.SLICE_SIZE+1),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+4),n.bindTexture(n.TEXTURE_2D,r.controls.Atmosphere._transmittanceBuffer.textures[0]),n.uniform1i(i.transmittanceTexture,this.SLICE_SIZE+4),n.activeTexture(n.TEXTURE0+this.SLICE_SIZE+5),n.bindTexture(n.TEXTURE_2D,r.controls.Atmosphere._scatteringBuffer.textures[0]),n.uniform1i(i.scatteringTexture,this.SLICE_SIZE+5),n.uniform1f(i.camHeight,e.getHeight())):(s.programs.drawnode_screen_nl.activate(),t=s.programs.drawnode_screen_nl._program,i=t.uniforms,n.uniformMatrix4fv(i.viewMatrix,!1,e.getViewMatrix()),n.uniformMatrix4fv(i.projectionMatrix,!1,e.getProjectionMatrix())),n.uniform3fv(i.eyePositionHigh,e.eyeHigh),n.uniform3fv(i.eyePositionLow,e.eyeLow),t}static __refreshLayersFadingOpacity__(e,t,i){for(let r=e.length-1;r>=0;--r){let s=e[r];s._fading&&s._refreshFadingOpacity(t,i)&&e.splice(r,1)}}_renderingScreenNodes(e,t,i,r){let s=this._visibleTileLayerSlices;s.length&&i.isFirstPass&&yi.__refreshLayersFadingOpacity__(s[0],e.minCurrZoom,e.maxCurrZoom);let n=new Map,o=[],l=this.terrain.equalizeVertices,h=r.length;if(e._fadingOpaqueSegments=[],i.slope>.8||!this.terrain||this.terrain.isEmpty)for(;h--;){let c=r[h],d=c.segment;this._renderingFadingNodesNoDepth(e,n,t,c,s[0],0,e._fadingOpaqueSegments),l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(t,s[0],0)}else{for(;h--;){let c=r[h],d=c.segment;this._renderingFadingNodes(e,n,t,c,s[0],0,o,e._fadingOpaqueSegments),d._transitionOpacity<1?o.push(d):(l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(t,s[0],0))}for(let c=0;c<o.length;c++){let d=o[c];l&&d.equalize(),d.readyToEngage&&d.engage(),d.screenRendering(t,s[0],0)}}}_renderingScreenNodesWithHeight(e,t,i,r){let s=this.renderer.handler.gl;s.enable(s.POLYGON_OFFSET_FILL),s.disable(s.CULL_FACE);let n=new Map,o=[],l=this._visibleTileLayerSlices;for(let h=1,c=l.length;h<c;h++){i.isFirstPass&&yi.__refreshLayersFadingOpacity__(l[h],e.minCurrZoom,e.maxCurrZoom),s.polygonOffset(0,-h);let d=r.length;for(;d--;){let u=r[d];this._renderingFadingNodes(e,n,t,u,l[h],h,o),u.segment._transitionOpacity<1?u.segment.initSlice(h):u.segment.screenRendering(t,l[h],h,this.transparentTexture,!0)}}s.disable(s.POLYGON_OFFSET_FILL),s.enable(s.CULL_FACE)}_renderColorPickingFramebufferPASS(){let e,t=this.renderer,i=t.handler,r=i.gl;i.programs.drawnode_colorPicking.activate(),e=i.programs.drawnode_colorPicking._program;let s=e.uniforms,n=t.activeCamera;r.enable(r.CULL_FACE),r.uniformMatrix4fv(s.viewMatrix,!1,n.getViewMatrix()),r.uniformMatrix4fv(s.projectionMatrix,!1,n.getProjectionMatrix()),r.uniform3fv(s.eyePositionHigh,n.eyeHigh),r.uniform3fv(s.eyePositionLow,n.eyeLow);let o=this.quadTreeStrategy._renderedNodesInFrustum[n.getCurrentFrustum()],l=this._visibleTileLayerSlices,h=o.length;for(;h--;)o[h].segment._transitionOpacity>=1&&o[h].segment.colorPickingRendering(e,l[0],0);for(let c=0;c<this.quadTreeStrategy._fadingOpaqueSegments.length;++c)this.quadTreeStrategy._fadingOpaqueSegments[c].colorPickingRendering(e,l[0],0);t.enableBlendDefault(),r.enable(r.POLYGON_OFFSET_FILL);for(let c=1,d=l.length;c<d;c++)for(h=o.length,r.polygonOffset(0,-c);h--;)o[h].segment.colorPickingRendering(e,l[c],c,this.transparentTexture,!0);r.disable(r.POLYGON_OFFSET_FILL)}renderDepthFramebuffer(e,t){let i,r=this.renderer.handler,s=r.gl;r.programs.drawnode_depth.activate(),i=r.programs.drawnode_depth._program;let n=i.uniforms;s.disable(s.BLEND),s.disable(s.POLYGON_OFFSET_FILL),s.uniformMatrix4fv(n.viewMatrix,!1,e.getViewMatrix()),s.uniformMatrix4fv(n.projectionMatrix,!1,e.getProjectionMatrix()),s.uniform3fv(n.eyePositionHigh,e.eyeHigh),s.uniform3fv(n.eyePositionLow,e.eyeLow),s.uniform1f(n.frustumPickingColor,e.frustumColorIndex);let o=t._renderedNodesInFrustum[e.getCurrentFrustum()],l=this._visibleTileLayerSlices,h=o.length;for(;h--;)o[h].segment._transitionOpacity>=1&&o[h].segment.depthRendering(i,l[0]);for(let c=0;c<t._fadingOpaqueSegments.length;++c)t._fadingOpaqueSegments[c].depthRendering(i,l[0]);s.enable(s.BLEND)}_collectVectorLayerCollections(){let e=this._visibleVectorLayersByDepthOrder.length;this._visibleEntityCollections.length=0,this._visibleEntityCollections=new Array(e);for(let t=0;t<this._visibleEntityCollections.length;t++)this._visibleEntityCollections[t]=[];for(;e--;){let t=this._visibleVectorLayersByDepthOrder[e],i=t.length;for(;i--;){let r=t[i];r._fading&&r._refreshFadingOpacity(this.quadTreeStrategy.minCurrZoom,this.quadTreeStrategy.maxCurrZoom)&&(t.splice(i,1),t.length===0&&this._visibleVectorLayersByDepthOrder.splice(e,1)),r.collectVisibleCollections(this._visibleEntityCollections[e]),r.update()}}}memClear(){this._distBeforeMemClear=0,this.camera._insideSegment=null,this.layerLock.lock(this._memKey),this.terrainLock.lock(this._memKey),this._normalMapCreator.lock(this._memKey),this._normalMapCreator.clear(),this.terrain.abortLoading(),this._tileLoader.abortAll(),this.quadTreeStrategy.clear(),this.layerLock.free(this._memKey),this.terrainLock.free(this._memKey),this._normalMapCreator.free(this._memKey),this._createdNodesCount=0}getRayIntersectionEllipsoid(e){return this.ellipsoid.hitRay(e.origin,e.direction)}getCartesianFromPixelEllipsoid(e){let t=this.renderer.activeCamera;return this.ellipsoid.hitRay(t.eye,t.unproject(e.x,e.y))}getLonLatFromPixelEllipsoid(e){let t=this.getCartesianFromPixelEllipsoid(e);if(t)return this.ellipsoid.cartesianToLonLat(t)}getCartesianFromMouseTerrain(){let e=this.renderer.events.mouseState,t=this.getDistanceFromPixel(e);if(t)return e.direction.scaleTo(t).addA(this.renderer.activeCamera.eye)}getCartesianFromPixelTerrain(e){let t=this.getDistanceFromPixel(e);if(t)return(e.direction||this.renderer.activeCamera.unproject(e.x,e.y)).scaleTo(t).addA(this.renderer.activeCamera.eye)}getLonLatFromPixelTerrain(e){let t=this.getCartesianFromPixelTerrain(e);if(t)return this.ellipsoid.cartesianToLonLat(t)}getPixelFromCartesian(e){return this.renderer.activeCamera.project3v(e)}getPixelFromLonLat(e){let t=this.ellipsoid.lonLatToCartesian(e);if(t)return this.renderer.activeCamera.project3v(t)}getDistanceFromPixelEllipsoid(e){let t=this.getCartesianFromPixelEllipsoid(e);if(t)return t.distance(this.renderer.activeCamera.eye)}getDistanceFromPixel(e){return this.renderer.getDistanceFromPixel(e)||this.getDistanceFromPixelEllipsoid(e)||0}viewExtent(e){this.camera?this.camera.viewExtent(e):this._initialViewExtent=e}viewExtentArr(e){this.viewExtent(new j(new A(e[0],e[1]),new A(e[2],e[3])))}getExtent(){if(this.renderer){let e=this.renderer.handler.getWidth(),t=this.renderer.handler.getHeight(),i=[this.getLonLatFromPixelTerrain(new N(0,0)),this.getLonLatFromPixelTerrain(new N(e,0)),this.getLonLatFromPixelTerrain(new N(e,t)),this.getLonLatFromPixelTerrain(new N(0,t))];if(i[0]&&i[1]&&i[2]&&i[3]){let r=i[0].lon,s=i[2].lat,n=i[1].lon,o=i[0].lat;for(let l=0;l<i.length;l++)i[l].lon>n&&(n=i[l].lon),i[l].lat>o&&(o=i[l].lat),i[l].lon<r&&(r=i[l].lon),i[l].lat<s&&(s=i[l].lat);return new j(new A(r,s),new A(n,o))}}return this.quadTreeStrategy._viewExtent}getViewExtent(){return this.quadTreeStrategy._viewExtent}viewLonLat(e,t,i){this.camera.setLonLat(e,t,i)}flyExtent(e,t,i={}){this.camera.flyExtent(e,t,i)}flyCartesian(e,t){this.camera.flyCartesian(e,t)}flyLonLat(e,t={}){this.camera.flyLonLat(e,t)}stopFlying(){this.camera.stopFlying()}updateBillboardsTexCoords(){for(let t=0;t<this.entityCollections.length;t++)this.entityCollections[t].billboardHandler.refreshTexCoordsArr();let e={};for(let t=0;t<this._layers.length;t++){let i=this._layers[t];i instanceof fe&&i.each(function(r){r._entityCollection&&!e[r._entityCollection.id]&&(r._entityCollection.billboardHandler.refreshTexCoordsArr(),e[r._entityCollection.id]=!0)})}}getEntityTerrainPoint(e,t){let i=this.quadTreeStrategy._renderedNodes,r=i.length;for(;r--;)if(i[r].segment.isEntityInside(e))return i[r].segment.getEntityTerrainPoint(e,t)}async getHeightDefault(e){return new Promise(t=>{this.terrain?this.terrain.getHeightAsync(e.clone(),i=>{t(i)}):t(0)})}async getHeightAboveELL(e){return new Promise(t=>{this.terrain?this.terrain.getHeightAsync(e.clone(),i=>{t(i+this.terrain.geoid.getHeightLonLat(e))}):t(0)})}onremove(){this.memClear(),this.quadTreeStrategy.destroyBranches(),this.quadTreeStrategy.clearRenderedNodes()}}const Hc=["draw","layeradd","baselayerchange","layerremove","layervisibilitychange","rendercompleted","terraincompleted","layerloadend"];class cs extends ot{constructor(e){super("skybox"),this.params=e,this.vertexPositionBuffer=null,this.texture=null}static createDefault(e){return new cs({nx:e+"skybox/gal/_nx.jpg",px:e+"skybox/gal/_px.jpg",py:e+"skybox/gal/_py.jpg",ny:e+"skybox/gal/_ny.jpg",pz:e+"skybox/gal/_pz.jpg",nz:e+"skybox/gal/_nz.jpg"})}init(){this.renderer.handler.addProgram(new X("skybox",{uniforms:{projectionViewMatrix:{type:ue.MAT4},uSampler:{type:ue.SAMPLERCUBE},pos:{type:ue.VEC3}},attributes:{aVertexPosition:{type:ue.VEC3,enableArray:!0}},vertexShader:`attribute vec3 aVertexPosition;
870
870
  uniform mat4 projectionViewMatrix;
871
871
  uniform vec3 pos;
872
872
  varying vec3 vTextureCoord;
@@ -878,7 +878,7 @@ precision highp float;uniform float frustumPickingColor;layout(location=0)out ve
878
878
  uniform samplerCube uSampler;
879
879
  void main(void) {
880
880
  gl_FragColor = textureCube(uSampler, vTextureCoord);
881
- }`}),!0),this.texture=this.renderer.handler.loadCubeMapTexture(this.params),this._createBuffers(),this.drawMode=this.renderer.handler.gl.TRIANGLES}frame(){let e=this.renderer.handler,t=e.gl,i=this.renderer.activeCamera;t.disable(t.DEPTH_TEST),e.programs.skybox.activate();let s=e.programs.skybox._program,r=s.uniforms;t.uniformMatrix4fv(r.projectionViewMatrix,!1,i.getProjectionViewMatrix()),t.uniform3fv(r.pos,i.eye.toArray()),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_CUBE_MAP,this.texture),t.uniform1i(r.uSampler,0);let n=this.vertexPositionBuffer;t.bindBuffer(t.ARRAY_BUFFER,n),t.vertexAttribPointer(s.attributes.aVertexPosition,n.itemSize,t.FLOAT,!1,0,0),t.drawArrays(this.drawMode,0,n.numItems),t.enable(t.DEPTH_TEST)}_createBuffers(){const e=new Float32Array([-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,1e8,-1e8,1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,1e8,-1e8,1e8]);this.vertexPositionBuffer=this.renderer.handler.createArrayBuffer(e,3,e.length/3)}}Object.freeze(Object.defineProperty({__proto__:null,Axes:class extends at{constructor(a=100){super("Axes"),this.size=a,this.axesBuffer=null,this.axesColorBuffer=null}init(){this.createAxesBuffer(this.size),this.drawMode=this.renderer.handler.gl.LINES,this.renderer.handler.addProgram(new X("axesShader",{uniforms:{projectionViewMatrix:"mat4"},attributes:{aVertexPosition:"vec3",aVertexColor:"vec4"},vertexShader:`attribute vec3 aVertexPosition;
881
+ }`})),this.texture=this.renderer.handler.loadCubeMapTexture(this.params),this._createBuffers(),this.drawMode=this.renderer.handler.gl.TRIANGLES}frame(){let e=this.renderer.handler,t=e.gl,i=this.renderer.activeCamera;t.disable(t.DEPTH_TEST),e.programs.skybox.activate();let r=e.programs.skybox._program,s=r.uniforms;t.uniformMatrix4fv(s.projectionViewMatrix,!1,i.getProjectionViewMatrix()),t.uniform3fv(s.pos,i.eye.toArray()),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_CUBE_MAP,this.texture),t.uniform1i(s.uSampler,0);let n=this.vertexPositionBuffer;t.bindBuffer(t.ARRAY_BUFFER,n),t.vertexAttribPointer(r.attributes.aVertexPosition,n.itemSize,t.FLOAT,!1,0,0),t.drawArrays(this.drawMode,0,n.numItems),t.enable(t.DEPTH_TEST)}_createBuffers(){const e=new Float32Array([-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,1e8,-1e8,1e8,-1e8,1e8,1e8,-1e8,1e8,1e8,1e8,1e8,1e8,1e8,-1e8,1e8,1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,-1e8,-1e8,1e8,1e8,-1e8,-1e8,1e8,-1e8,-1e8,-1e8,-1e8,1e8,1e8,-1e8,1e8]);this.vertexPositionBuffer=this.renderer.handler.createArrayBuffer(e,3,e.length/3)}}Object.freeze(Object.defineProperty({__proto__:null,Axes:class extends ot{constructor(a=100){super("Axes"),this.size=a,this.axesBuffer=null,this.axesColorBuffer=null}init(){this.createAxesBuffer(this.size),this.drawMode=this.renderer.handler.gl.LINES,this.renderer.handler.addProgram(new X("axesShader",{uniforms:{projectionViewMatrix:"mat4"},attributes:{aVertexPosition:"vec3",aVertexColor:"vec4"},vertexShader:`attribute vec3 aVertexPosition;
882
882
  attribute vec4 aVertexColor;
883
883
  uniform mat4 projectionViewMatrix;
884
884
  varying vec4 vColor;
@@ -889,7 +889,7 @@ precision highp float;uniform float frustumPickingColor;layout(location=0)out ve
889
889
  varying vec4 vColor;
890
890
  void main(void) {
891
891
  gl_FragColor = vColor;
892
- }`}))}frame(){this.renderer.handler.programs.axesShader.activate().set({projectionViewMatrix:this.renderer.activeCamera.getProjectionViewMatrix(),aVertexPosition:this.axesBuffer,aVertexColor:this.axesColorBuffer}),this.renderer.handler.programs.axesShader.drawArrays(this.drawMode,this.axesBuffer.numItems)}createAxesBuffer(a){const e=[0,0,0,a-1,0,0,0,0,0,0,a-1,0,0,0,0,0,0,a-1];this.axesBuffer=this.renderer.handler.createArrayBuffer(new Float32Array(e),3,6),this.axesColorBuffer=this.renderer.handler.createArrayBuffer(new Float32Array([1,0,0,1,1,0,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,0,1]),4,6)}},Planet:_a,RenderNode:at,SkyBox:hr},Symbol.toStringTag,{value:"Module"}));const fa=class Za{constructor(e={}){this.__id=Za.__counter__++,this.equalizeVertices=e.equalizeVertices||!1,this.equalizeNormals=!1,this.isEmpty=!0,this.name=e.name||"empty",this.minZoom=e.minZoom||2,this.maxZoom=e.maxZoom||19,this.maxNativeZoom=e.maxNativeZoom||this.maxZoom,this.gridSizeByZoom=e.gridSizeByZoom||[64,32,16,8,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],this._maxNodeZoom=this.gridSizeByZoom.length-1,this.plainGridSize=2,this.noDataValues=[],this._planet=null,this._geoid=e.geoid||new aa({src:e.geoidSrc||null}),this._isReady=!1}setUrlRewriteCallback(e){}get isIdle(){return!0}isEqual(e){return e.__id===this.__id}static checkNoDataValue(e,t){return fs(e,t)!==-1}isBlur(e){return!1}set maxNodeZoom(e){e>this.gridSizeByZoom.length-1&&(e=this.gridSizeByZoom.length-1),this._maxNodeZoom=e}get maxNodeZoom(){return this._maxNodeZoom}set geoid(e){this._geoid=e}get geoid(){return this._geoid}getGeoid(){return this._geoid}handleSegmentTerrain(e){e.terrainIsLoading=!1,e.terrainReady=!0,e.terrainExists=!0}isReady(){return this._isReady}abortLoading(){}clearCache(){}getHeightAsync(e,t){return t(0),!0}loadTerrain(e,t=!1){}};fa.__counter__=0;let cr=fa;class dr extends cr{constructor(e="",t={}){super({geoidSrc:"https://openglobus.org/geoid/egm84-30.pgm",maxNativeZoom:t.maxNativeZoom||14,...t}),this._s=t.subdomains||["a","b","c"],this.events=he(Vc,this),this._requestCount=0,this._requestsPeerSubdomain=4,this.isEmpty=!1,this.equalizeNormals=!0,this.name=e||"openglobus",this.url=t.url||"https://{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm",this.gridSizeByZoom=t.gridSizeByZoom||[64,32,32,16,16,8,8,8,16,16,16,32,32,32,32,16,8,4,2,2,2,2,2,2],this._heightFactor=t.heightFactor!=null?t.heightFactor:1,this.noDataValues=t.noDataValues||[];for(let i=0;i<this.noDataValues.length;i++)this.noDataValues[i]*=this._heightFactor;this.plainGridSize=t.plainGridSize||32,this._extent=_s(t.extent,new G(new A(-180,-90),new A(180,90))),this._dataType="arrayBuffer",this._maxNodeZoom=this.gridSizeByZoom.length-1,this._elevationCache={},this._fetchCache={},this._cache=t.cache||"default",this._loader=new la,this._urlRewriteCallback=t.urlRewrite||null}get loader(){return this._loader}clearCache(){for(let e in this._elevationCache)this._elevationCache[e].heights=null,this._elevationCache[e].extent=null,delete this._elevationCache[e];this._elevationCache=null,this._elevationCache={};for(let e in this._fetchCache)this._fetchCache[e]=null,delete this._fetchCache[e];this._fetchCache=null,this._fetchCache={}}isBlur(e){return e.tileZoom>=6}setElevationCache(e,t){this._elevationCache[e]=t}getElevationCache(e){return this._elevationCache[e]}getHeightAsync(e,t,i,s){if(!e||e.lat>ue||e.lat<Ne)return t(0),!0;s=s==null||s;const[r,n,o,l]=this._planet.quadTreeStrategy.getTileXY(e,i||this.maxZoom);let h=qe.getTileIndex(r,n,o,l),c=this.getElevationCache(h),d=Ii(e);if(c)return c.heights?t(this._getGroundHeightMerc(d,c)):t(0),!0;{let u=this._fetchCache[h];u||(u=this._loader.fetch({src:this._urlRewriteCallback&&this._urlRewriteCallback(r,n,o,l)||this.buildURL(r,n,o,l),type:this._dataType,options:{cache:this._cache}}),this._fetchCache[h]=u),u.then(g=>{let f=kt(r,n,o);if(g.status==="ready"){let p={heights:this._createHeights(g.data,null,l,r,n,o,f),extent:f};this.setElevationCache(h,p),t(this._getGroundHeightMerc(d,p))}else if(g.status==="error"){if(s&&o>this.maxNativeZoom)return s=!1,void this.getHeightAsync(e,t,this.maxNativeZoom,!1);this.setElevationCache(h,{heights:null,extent:f}),t(0)}else this._fetchCache[h]=null,delete this._fetchCache[h]})}return!1}_getGroundHeightMerc(e,t){if(!t.extent||!t.heights)return 0;let i=t.extent.getWidth(),s=Math.sqrt(t.heights.length),r=i/(s-1),n=s-Math.ceil((e.lat-t.extent.southWest.lat)/r)-1,o=Math.floor((e.lon-t.extent.southWest.lon)/r),l=(n+1)*s+o,h=l+1,c=n*s+o,d=c+1,u=t.heights[l],g=t.heights[h],f=t.heights[c],p=t.heights[d],_=new v(t.extent.southWest.lon+r*o,u,t.extent.northEast.lat-r*n-r),m=new v(_.x+r,g,_.z),y=new v(_.x,f,_.z+r),x=new v(_.x+r,p,_.z+r),w=new v(e.lon,1e5,e.lat),b=new U(w,new v(0,-1,0)),E=new v,C=b.hitTriangleRes(_,m,y,E);return C===U.INSIDE?E.y:(C=b.hitTriangleRes(m,x,y,E),C===U.INSIDE?E.y:0)}abortLoading(){this._loader.abortAll()}setUrl(e){this.url=e}setName(e){this.name=e}isReadyToLoad(e){return e._tileGroup===0&&this._extent.overlaps(e.getExtentLonLat())}loadTerrain(e,t=!1){if(this._planet.terrainLock.isFree())if(e.terrainReady=!1,e.terrainIsLoading=!0,this.isReadyToLoad(e)){let i=this.getElevationCache(e.tileIndex);i?this._applyElevationsData(e,i.heights):this._loader.load({sender:this,src:this._getHTTPRequestString(e),segment:e,type:this._dataType,options:{cache:this._cache},filter:()=>e.plainReady&&e.node.getState()!==0||t},s=>{if(s.status==="ready"){let r=this._createHeights(s.data,e,e._tileGroup,e.tileX,e.tileY,e.tileZoom,e.getExtent(),e.tileZoom===this.maxZoom);this.setElevationCache(e.tileIndex,{heights:r,extent:e.getExtent()}),this._applyElevationsData(e,r)}else s.status==="abort"?e.terrainIsLoading=!1:s.status==="error"?this._applyElevationsData(e,null):e.terrainIsLoading=!1})}else e.elevationsNotExists();else e.terrainIsLoading=!1}_getSubdomain(){return this._requestCount++,this._s[Math.floor(this._requestCount%(this._requestsPeerSubdomain*this._s.length)/this._requestsPeerSubdomain)]}buildURL(e,t,i,s){return He(this.url,{s:this._getSubdomain(),x:e.toString(),y:t.toString(),z:i.toString()})}_createUrl(e){return this.buildURL(e.tileX,e.tileY,e.tileZoom,e._tileGroup)}_getHTTPRequestString(e){return this._urlRewriteCallback&&this._urlRewriteCallback(e.tileX,e.tileY,e.tileZoom,e._tileGroup)||this._createUrl(e)}setUrlRewriteCallback(e){this._urlRewriteCallback=e}_createHeights(e,t,i,s,r,n,o,l){if(this._heightFactor!==1){let h=new Float32Array(e);for(let c=0,d=h.length;c<d;c++)h[c]=h[c]*this._heightFactor;return h}return new Float32Array(e)}_applyElevationsData(e,t){if(e){let i=this.events.load;i.handlers.length&&this.events.dispatch(i,{elevations:t,segment:e}),e.applyTerrain(t)}}}const Vc=["load","loadend"];class xi extends qe{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(Uc),this.url=t.url||"",this._s=t.subdomains||["a","b","c"],this.minNativeZoom=t.minNativeZoom||0,this.maxNativeZoom=t.maxNativeZoom||19,this._urlRewriteCallback=t.urlRewrite||null,this._requestsPeerSubdomains=4,this._requestCount=0,this._cache=t.cache||"default"}get isIdle(){return super.isIdle&&this._planet._tileLoader.getRequestCounter(this)===0}get instanceName(){return"XYZ"}abortLoading(){this._planet&&this._planet._tileLoader.abort(this)}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),e||this.abortLoading())}remove(){return this.abortLoading(),super.remove(),this}setUrl(e){this.url=e}_checkSegment(e){return e._projection.id===this._planet.quadTreeStrategy.projection.id}loadMaterial(e,t=!1){let i=e.segment;this._isBaseLayer?e.texture=i.getDefaultTexture():e.texture=i.planet.transparentTexture,(this._planet.layerLock.isFree()||e.segment.tileZoom<2)&&(e.isReady=!1,e.isLoading=!0,this._checkSegment(i)?(e.loadingAttempts++,this._planet._tileLoader.load({sender:this,src:this._getHTTPRequestString(e.segment),type:"imageBitmap",filter:()=>i.initialized&&i.node.getState()===1||t,options:{cache:this._cache}},s=>{if(s.status==="ready"){if(e.isLoading){let r=this.events.load;r.handlers.length&&this.events.dispatch(r,e),e.applyImage(s.data),s.data=null}}else s.status==="abort"?e.isLoading=!1:s.status==="error"&&e.isLoading&&e.textureNotExists()})):e.textureNotExists())}_createUrl(e){return He(this.url,{s:this._getSubdomain(),x:e.tileX.toString(),y:e.tileY.toString(),z:e.tileZoom.toString()})}_getSubdomain(){return this._requestCount++,this._s[Math.floor(this._requestCount%(this._requestsPeerSubdomains*this._s.length)/this._requestsPeerSubdomains)]}_getHTTPRequestString(e){return this._urlRewriteCallback?this._urlRewriteCallback(e,this.url):this._createUrl(e)}setUrlRewriteCallback(e){this._urlRewriteCallback=e}applyMaterial(e,t=!1){if(e.isReady)return e.texOffset;if(e.segment.tileZoom<this.minNativeZoom)e.textureNotExists();else{let i=e.segment,s=i.node,r=!1,n=this.__id,o=e;for(;s.parentNode;)if(s=s.parentNode,o=s.segment.materials[n],o&&o.textureExists){r=!0;break}if(i.passReady){let l=e.layer.maxNativeZoom;if(s.segment.tileZoom===l)e.textureNotExists();else if(e.segment.tileZoom<=l)!e.isLoading&&!e.isReady&&this.loadMaterial(e,t);else{let h=i.node;for(;h.segment.tileZoom>e.layer.maxNativeZoom;)h=h.parentNode;let c=h.segment.materials[e.layer.__id];c?!c.isLoading&&!c.isReady&&this.loadMaterial(c,!0):(c=h.segment.materials[e.layer.__id]=e.layer.createMaterial(h.segment),this.loadMaterial(c,!0))}}if(r){e.appliedNode=s,e.appliedNodeId=s.nodeId,e.texture=o.texture;let l=1/(2<<i.tileZoom-s.segment.tileZoom-1);e.texOffset[0]=i.tileX*l-s.segment.tileX,e.texOffset[1]=i.tileY*l-s.segment.tileY,e.texOffset[2]=l,e.texOffset[3]=l}else e.texture=i.planet.transparentTexture,e.texOffset[0]=0,e.texOffset[1]=0,e.texOffset[2]=1,e.texOffset[3]=1}return e.texOffset}clearMaterial(e){e.isReady&&e.textureExists&&(!e.texture.default&&e.segment.handler.gl.deleteTexture(e.texture),e.texture=null),e.isReady=!1,e.textureExists=!1,e.isLoading=!1}_correctFullExtent(){let e=this._extent,t=this._extentMerc;e.northEast.lat===90&&(t.northEast.lat=2008750834e-2),e.northEast.lon===180&&(t.northEast.lon=2008750834e-2),e.southWest.lat===-90&&(t.southWest.lat=-2008750834e-2),e.southWest.lon===-180&&(t.southWest.lon=-2008750834e-2)}}const Uc=["load","loadend"];class gt extends xi{constructor(e,t){super(e,t),this._extra=new URLSearchParams(t.extra).toString(),t.extent||this.setExtent(new G(new A(-180,-90),new A(180,90))),this.layers=t.layers,this.imageWidth=t.imageWidth||256,this.imageHeight=t.imageHeight||256,this._getBbox=gt.get_bbox_v1_1_1,this._version="",this.setVersion(t.version)}static createRequestUrl(e,t,i="image/png",s="1.1.1",r="GetMap",n,o,l=256,h=256,c){return`${e}?LAYERS=${t}&FORMAT=${i}&SERVICE=WMS&VERSION=${s}&REQUEST=${r}&SRS=${n}&BBOX=${o}&WIDTH=${l}&HEIGHT=${h}`+(c?`&${c}`:"")}static get_bbox_v1_1_1(e){return`${e.getWest()},${e.getSouth()},${e.getEast()},${e.getNorth()}`}static get_bbox_v1_3_0(e){return`${e.getSouth()},${e.getWest()},${e.getNorth()},${e.getEast()}`}_checkSegment(e){return!0}get instanceName(){return"WMS"}_createUrl(e){return gt.createRequestUrl(this.url,this.layers,"image/png",this._version,"GetMap",e._projection.code,this._getBbox(e.getExtent()),this.imageWidth,this.imageHeight,this._extra)}setVersion(e){this._version=e||"1.1.1",this._version==="1.1.1"?this._getBbox=gt.get_bbox_v1_1_1:e==="1.3.0"&&(this._getBbox=gt.get_bbox_v1_3_0)}_correctFullExtent(){const e=this._extent,t=this._extentMerc;e.northEast.lat===90&&(t.northEast.lat=2008750834e-2),e.northEast.lon===180&&(t.northEast.lon=2008750834e-2),e.southWest.lat===-90&&(t.southWest.lat=-2008750834e-2),e.southWest.lon===-180&&(t.southWest.lon=-2008750834e-2)}}class jt extends dr{constructor(e={}){super("BilTerrain",e),this.equalizeVertices=!0,this.equalizeNormals=!0,this.minZoom=e.minZoom||2,this.maxZoom=e.maxZoom||14,this.noDataValues=e.noDataValues||[-9999,32767],this.url=e.url||"",this._format="application/bil16",this._layers=e.layers||"",this._imageSize=e.imageSize||256,this.plainGridSize=e.plainGridSize!=null?e.plainGridSize:Mi(this._imageSize)?this._imageSize/2:Mt(this._imageSize)/2,this._dataType="arrayBuffer"}isBlur(e){return e.tileZoom>=18}_createUrl(e){return gt.createRequestUrl(this.url,this._layers,this._format,"1.1.1","GetMap",e._projection.code,gt.get_bbox_v1_1_1(e.getExtent()),this._imageSize,this._imageSize)}_createHeights(e,t,i,s,r,n,o,l){let h=new Int16Array(e);if(!Mi(this._imageSize)){let p=new Float32Array(h.length);return function(_,m){for(let y=0,x=m.length;y<x;y++)m[y]=_[y]}(h,p),p}let c=(this.plainGridSize+1)*(this.plainGridSize+1),d=new Array(4);for(let p=0;p<4;p++){d[p]=[];for(let _=0;_<4;_++)d[p][_]=new Float32Array(c)}let u=new Float32Array(c);(function(p,_,m,y){let x=Math.sqrt(m.length)-1,w=x+1,b=Math.sqrt(p.length),E=b/x,C=0,T=0;for(let L=0,M=0,R=p.length;L<R;L++){let z=p[L],F=jt.checkNoDataValue(_,z),P=!1,D=!1,I=Math.floor(L/b),k=L%b,B=Math.floor(k/x),H=Math.floor(I/x),Ce=y[H][B],ce=I%x,Be=k%x,ke=(ce+H)*w+Be+B;if(Ce[ke]=z,(I+H)%E==0&&(k+B)%E==0&&(m[M++]=z),(k+1)%x==0&&k!==b-1){C=p[L],P=jt.checkNoDataValue(_,C);let ie=z;F||P||(ie=.5*(z+C)),ke=(ce+H)*w+Be+1,Ce[ke]=ie,(I+H)%E==0&&(m[M++]=ie);let Ue=(ce+H)*w+(Be+1)%x;y[H][B+1][Ue]=ie}if((I+1)%x==0&&I!==b-1){T=p[L+b],D=jt.checkNoDataValue(_,T);let ie=z;F||D||(ie=.5*(z+T)),ke=(ce+1)*w+Be+B,Ce[ke]=ie,(k+B)%E==0&&(m[M++]=ie);let Ue=(ce+1)%x*w+Be+B;y[H+1][B][Ue]=ie}if((k+1)%x==0&&k!==b-1&&(I+1)%x==0&&I!==b-1){let ie=p[L+b+1],Ue=jt.checkNoDataValue(_,ie),Fe=z;F||P||D||Ue||(Fe=.25*(z+C+T+ie)),ke=(ce+1)*w+(Be+1),Ce[ke]=Fe,m[M++]=Fe;let Ei=(ce+1)*w;y[H][B+1][Ei]=Fe;let Ai=x;y[H+1][B][Ai]=Fe;let Li=0;y[H+1][B+1][Li]=Fe}}})(h,this.noDataValues,u,d);let g=qe.getTileIndex(s,r,n,i);this.setElevationCache(g,{heights:u,extent:o});let f=this._imageSize/this.plainGridSize;for(let p=0;p<f;p++)for(let _=0;_<f;_++){let m=2*s+_,y=2*r+p,x=n+1,w=qe.getTileIndex(m,y,x,i);this.setElevationCache(w,{heights:d[p][_],extent:kt(m,y,x)})}return u}}class Re extends dr{constructor(e,t={}){super(e||"RgbTerrain",{equalizeVertices:t.equalizeVertices==null||t.equalizeVertices,maxZoom:t.maxZoom||17,noDataValues:t.noDataValues||[t.minHeight!=null?t.minHeight:-1e4],plainGridSize:t.plainGridSize||128,url:t.url!=null?t.url:`//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${t.key||"<key>"}`,gridSizeByZoom:t.gridSizeByZoom||[64,32,16,8,8,8,16,16,16,32,32,32,32,32,32,64,64,64,32,32,16,8],...t}),this.equalizeNormals=t.equalizeNormals||!1,this._dataType="imageBitmap",this._imageSize=t.imageSize||256,this._ctx=this._createTemporalCanvas(this._imageSize),this._imageDataCache={},this._minHeight=t.minHeight||-1e4,this._resolution=t.resolution||.1}static checkNoDataValue(e,t){return t>5e4||fs(e,t)!==-1}rgb2Height(e,t,i){return e===255?this._minHeight:this._minHeight+this._resolution*(256*e*256+256*t+i)}isBlur(e){return e.tileZoom>=16}_createTemporalCanvas(e){let t=document.createElement("canvas");return t.width=e,t.height=e,t.getContext("2d",{willReadFrequently:!0})}_createHeights(e,t,i,s,r,n,o,l){this._ctx.clearRect(0,0,this._imageSize,this._imageSize),this._ctx.drawImage(e,0,0);let h=this._ctx.getImageData(0,0,this._imageSize,this._imageSize).data;const c=e.width;let d=0,u=0,g=0,f=null,p=!1;if(t&&t.tileZoom>this.maxNativeZoom){let b=t.node;for(;b&&!b.segment.terrainExists;)b=b.parentNode;b&&(d=b.segment.tileX,u=b.segment.tileY,g=b.segment.tileZoom,f=b.segment.elevationData,p=g<=8)}if(!Mi(this._imageSize)&&c===this._imageSize){let b=new Float32Array(c*c);return this.extractElevationTilesRgbNonPowerOfTwo(h,b,this._heightFactor),b}if(this._imageSize===this.plainGridSize){let b=(this.plainGridSize+1)*(this.plainGridSize+1),E=new Float32Array(b),[C,T,L]=t?ur(t.tileX,t.tileY,t.tileZoom,d,u,g):[0,0,0];return this.extractElevationSimple(h,this.noDataValues,f,C,T,L,p,E,this._heightFactor,this._imageSize),E}let _=(this.plainGridSize+1)*(this.plainGridSize+1),m=c/this.plainGridSize,y=new Float32Array(_),x=new Array(m);for(let b=0;b<m;b++){x[b]=[];for(let E=0;E<m;E++)x[b][E]=new Float32Array(_)}if(l)this.extractElevationTilesRgbNoChildren(h,this._heightFactor,this.noDataValues,f,d,u,g,t?t.tileX:0,t?t.tileY:0,t?t.tileZoom:0,p,y);else{this.extractElevationTilesRgb(h,this._heightFactor,this.noDataValues,f,d,u,g,t?t.tileX:0,t?t.tileY:0,t?t.tileZoom:0,p,y,x);for(let b=0;b<m;b++)for(let E=0;E<m;E++){let[C,T,L]=[2*s+E,2*r+b,n+1],M=qe.getTileIndex(C,T,L,i);this.setElevationCache(M,{heights:x[b][E],extent:kt(C,T,L)})}}let w=qe.getTileIndex(s,r,n,i);return this.setElevationCache(w,{heights:y,extent:o}),y}getHeightAsync(e,t,i){if((i=i??this.maxZoom)===0)return t(0),!0;const s=this._planet.quadTreeStrategy,[r,n,o,l]=s.getTileXY(e,i),[h,c]=s.getLonLatTileOffset(e,r,n,o,this._imageSize),d=4*(h*this._imageSize+c),u=qe.getTileIndex(r,n,o,l);if(this._imageDataCache[u]){let f=this._imageDataCache[u],p=this._heightFactor*this.rgb2Height(f[d],f[d+1],f[d+2]);return Re.checkNoDataValue(this.noDataValues,p)?this.getHeightAsync(e,t,i-1):(t(this._heightFactor*this.rgb2Height(f[d],f[d+1],f[d+2])),!0)}let g=this._fetchCache[u];return g||(g=this._loader.fetch({src:this._urlRewriteCallback&&this._urlRewriteCallback(r,n,o,l)||this.buildURL(r,n,o,l),type:this._dataType,options:{cache:this._cache}}),this._fetchCache[u]=g),g.then(f=>{if(f.status==="ready"){this._ctx.clearRect(0,0,this._imageSize,this._imageSize),this._ctx.drawImage(f.data,0,0);let p=this._ctx.getImageData(0,0,256,256).data;this._imageDataCache[u]=p;let _=this._heightFactor*this.rgb2Height(p[d],p[d+1],p[d+2]);if(Re.checkNoDataValue(this.noDataValues,_))return this.getHeightAsync(e,t,i-1);t(this._heightFactor*this.rgb2Height(p[d],p[d+1],p[d+2]))}else{if(f.status==="error")return this.getHeightAsync(e,t,i-1);this._fetchCache[u]=null,delete this._fetchCache[u]}}),!1}extractElevationSimple(e,t,i=null,s,r,n,o,l,h=1,c){for(let u=0,g=c*c;u<g;u++){let f=u%c,p=Math.floor(u/c),_=4*u,m=h*this.rgb2Height(e[_],e[_+1],e[_+2]);(Re.checkNoDataValue(t,m)||m===0)&&i&&(m=$e(n,s,r,i,p,f,o)),l[p*(c+1)+f]=m}for(let u=0,g=c;u<g;u++){let f=c-1,p=4*(u*c+f),_=h*this.rgb2Height(e[p],e[p+1],e[p+2]);(Re.checkNoDataValue(t,_)||_===0)&&i&&(_=$e(n,s,r,i,u,f,o)),l[u*(c+1)+c]=_}for(let u=0,g=c;u<g;u++){let f=c-1,p=4*(f*c+u),_=h*this.rgb2Height(e[p],e[p+1],e[p+2]);(Re.checkNoDataValue(t,_)||_===0)&&i&&(_=$e(n,s,r,i,f,u,o)),l[c*(c+1)+u]=_}let d=h*this.rgb2Height(e[e.length-4],e[e.length-3],e[e.length-2]);(Re.checkNoDataValue(t,d)||d===0)&&i&&(d=$e(n,s,r,i,c-1,c-1,o)),l[l.length-1]=d}extractElevationTilesRgbNonPowerOfTwo(e,t,i=1){for(let s=0,r=t.length;s<r;s++){let n=4*s;t[s]=i*this.rgb2Height(e[n],e[n+1],e[n+2])}}extractElevationTilesRgb(e,t,i,s=null,r,n,o,l,h,c,d,u,g){let f=Math.sqrt(u.length)-1,p=f+1,_=Math.sqrt(e.length/4),m=_/f,y=0,x=0,w=0,[b,E,C]=ur(l,h,c,r,n,o);for(let T=0,L=0,M=e.length/4;T<M;T++){let R=4*T,z=t*this.rgb2Height(e[R],e[R+1],e[R+2]),F=Re.checkNoDataValue(i,z),P=!1,D=!1,I=Math.floor(T/_),k=T%_;(F||z===0)&&s&&(z=$e(C,b,E,s,Math.floor(I/m),Math.floor(k/m),d));let B=Math.floor(k/f),H=Math.floor(I/f),Ce=g[H][B],ce=I%f,Be=k%f,ke=(ce+H)*p+Be+B;if(Ce[ke]=z,(I+H)%m==0&&(k+B)%m==0&&(u[L++]=z),(k+1)%f==0&&k!==_-1){y=t*this.rgb2Height(e[R+4],e[R+5],e[R+6]),P=Re.checkNoDataValue(i,y),(P||y===0)&&s&&(y=$e(C,b,E,s,Math.floor(I/m),Math.floor((k+1)/m),d));let ie=z;F||P||(ie=.5*(z+y)),ke=(ce+H)*p+Be+1,Ce[ke]=ie,(I+H)%m==0&&(u[L++]=ie);let Ue=(ce+H)*p+(Be+1)%f;g[H][B+1][Ue]=ie}if((I+1)%f==0&&I!==_-1){w=4*_,x=t*this.rgb2Height(e[R+w],e[R+w+1],e[R+w+2]),D=Re.checkNoDataValue(i,x),(D||x===0)&&s&&(x=$e(C,b,E,s,Math.floor((I+1)/m),Math.floor(k/m),d));let ie=.5*(z+x);F||D||(ie=.5*(z+x)),ke=(ce+1)*p+Be+B,Ce[ke]=ie,(k+B)%m==0&&(u[L++]=ie);let Ue=(ce+1)%f*p+Be+B;g[H+1][B][Ue]=ie}if((k+1)%f==0&&k!==_-1&&(I+1)%f==0&&I!==_-1){let ie=t*this.rgb2Height(e[R+w+4],e[R+w+5],e[R+w+6]),Ue=Re.checkNoDataValue(i,ie);(Ue||ie===0)&&s&&(ie=$e(C,b,E,s,Math.floor((I+1)/m),Math.floor((k+1)/m),d));let Fe=z;F||P||D||Ue||(Fe=.25*(z+y+x+ie)),ke=(ce+1)*p+(Be+1),Ce[ke]=Fe,u[L++]=Fe;let Ei=(ce+1)*p;g[H][B+1][Ei]=Fe;let Ai=f;g[H+1][B][Ai]=Fe;let Li=0;g[H+1][B+1][Li]=Fe}}}extractElevationTilesRgbNoChildren(e,t,i,s=null,r,n,o,l,h,c,d,u){let g=Math.sqrt(u.length)-1,f=g+1,p=Math.sqrt(e.length/4),_=p/g,m=0,y=0,x=0,[w,b,E]=ur(l,h,c,r,n,o);for(let C=0,T=0,L=e.length/4;C<L;C++){let M=4*C,R=t*this.rgb2Height(e[M],e[M+1],e[M+2]),z=Re.checkNoDataValue(i,R),F=!1,P=!1,D=Math.floor(C/p),I=C%p;(z||R===0)&&s&&(R=$e(E,w,b,s,Math.floor(T/f),T%f,d));let k=Math.floor(I/g),B=Math.floor(D/g);if((D+B)%_==0&&(I+k)%_==0&&(u[T++]=R),(I+1)%g==0&&I!==p-1){m=t*this.rgb2Height(e[M+4],e[M+5],e[M+6]),F=Re.checkNoDataValue(i,m),(F||m===0)&&s&&(m=$e(E,w,b,s,Math.floor(T/f),T%f,d));let H=R;z||F||(H=.5*(R+m)),(D+B)%_==0&&(u[T++]=H)}if((D+1)%g==0&&D!==p-1){x=4*p,y=t*this.rgb2Height(e[M+x],e[M+x+1],e[M+x+2]),P=Re.checkNoDataValue(i,y),(P||y===0)&&s&&(y=$e(E,w,b,s,Math.floor(T/f),T%f,d));let H=.5*(R+y);z||P||(H=.5*(R+y)),(I+k)%_==0&&(u[T++]=H)}if((I+1)%g==0&&I!==p-1&&(D+1)%g==0&&D!==p-1){let H=t*this.rgb2Height(e[M+x+4],e[M+x+5],e[M+x+6]),Ce=Re.checkNoDataValue(i,H);(Ce||H===0)&&s&&(H=$e(E,w,b,s,Math.floor(T/f),T%f,d));let ce=R;z||F||P||Ce||(ce=.25*(R+m+y+H)),u[T++]=ce}}}}function ur(a,e,t,i,s,r){let n=2<<t-r-1;return[a-n*i,e-n*s,1/n]}function $e(a,e,t,i,s,r,n){let o=Math.sqrt(i.length),l=i[Math.floor(t*a*o+s*a)*o+Math.floor(e*a*o+r*a)];return n&&l>0?0:l}const Gc={[Ec]:"north",[Ct]:"south"},jc=(a,e,t,i)=>{let s=Gc[i];if(s)return`https://terrain.openglobus.org/poles/${s}/${t}/${a}/${e}.png`};class ga extends Re{constructor(e,t){super(e||"GlobusEarthRgb",{maxNativeZoom:6,maxZoom:17,url:"https://{s}.terrain.openglobus.org/all/{z}/{x}/{y}.png",urlRewrite:jc,...t})}isReadyToLoad(e){return this._extent.overlaps(e.getExtentLonLat())}}Object.freeze(Object.defineProperty({__proto__:null,BilTerrain:jt,EmptyTerrain:cr,GlobusRgbTerrain:ga,GlobusTerrain:dr,RgbTerrain:Re},Symbol.toStringTag,{value:"Module"}));class Yc extends ci{constructor(e,t={}){super(e,t),this._sourceTexture=t.texture||null,t.texture&&(this._sourceReady=!0,this._sourceCreated=!0),this._frameWidth=t.frameWidth!=null?Mt(t.frameWidth):256,this._frameHeight=t.frameHeight!=null?Mt(t.frameHeight):256,this._animate=!0}get instanceName(){return"GeoTexture2d"}loadMaterial(e){this._planet._geoImageCreator.add(this)}bindTexture(e){this._sourceReady=!0,this._sourceCreated=!0,this._sourceTexture=e}setSize(e,t){this._frameWidth=e,this._frameHeight=t,this._frameCreated=!1}abortMaterialLoading(e){this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}class pa extends ci{constructor(e,t={}){super(e,t),this._animate=!0,this._video=t.videoElement||null,this._src=t.src||null}get instanceName(){return"GeoVideo"}setSrc(e){this._planet&&this._planet._geoImageCreator.remove(this),this._src=e,this._sourceReady=!1}setVideoElement(e){this._planet&&this._planet._geoImageCreator.remove(this),this._video=e,this._src=e.src,this._sourceReady=!1}setVisibility(e){e!=this._visibility&&(super.setVisibility(e),this._planet&&(e?(this._sourceReady&&this._planet._geoImageCreator.add(this),this._video&&this._video.play()):(this._sourceReady&&this._planet._geoImageCreator.remove(this),this._video&&this._video.pause())))}_createSourceTexture(){let e=this._planet.renderer.handler.gl;this._sourceCreated?(e.bindTexture(e.TEXTURE_2D,this._sourceTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._video)):(this._sourceTexture=this._planet.renderer.handler.createTexture_n_webgl1(this._video),this._sourceCreated=!0)}_onCanPlay(e){this._frameWidth=e.videoWidth,this._frameHeight=e.videoHeight,e.width=e.videoWidth,e.height=e.videoHeight,e.play(),this._sourceReady=!0,this._planet._geoImageCreator.add(this)}_onError(e){let t="unknown error";switch(e.error.code){case 1:t="video loading aborted";break;case 2:t="network loading error";break;case 3:t="video decoding failed / corrupted data or unsupported codec";break;case 4:t="video not supported"}console.warn(`Error: ${t} error-code=${e.error.code})`)}loadMaterial(e){if(e.isLoading=!0,this._creationProceeding=!0,!this._sourceReady&&this._src){if(this._video){if(this._video.readyState===this._video.HAVE_ENOUGH_DATA)this._onCanPlay(this._video);else if(this._video.src){let t=this;this._video.addEventListener("canplay",function(i){t._onCanPlay(this)})}}else{this._video=document.createElement("video"),this._video.crossOrigin="Anonymous";let t=this;this._video.addEventListener("canplay",function(){t._onCanPlay(this)}),this._video.addEventListener("error",function(){t._onError(this)})}this._video.autoplay=!0,this._video.loop=!0,this._video.src=this._src,this._video.muted=!0,this._video.setAttribute("playsinline","true"),this._video.setAttribute("webkit-playsinline","true")}else this._planet._geoImageCreator.add(this)}abortMaterialLoading(e){this._video&&(this._video.src=""),this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}class qc extends ge{constructor(e,t={}){super(e,t),this._billboard=t.billboard||{src:"https://openglobus.org/examples/billboards/carrot.png"},this._color=t.color||"#6689db"}get instanceName(){return"KML"}_extractCoordonatesFromKml(e){return Array.from(e.getElementsByTagName("coordinates")).map(t=>t.textContent.trim()).map(t=>t.replace(/\n/g," ").replace(/\t/g," ").replace(/ +/g," ").split(" ").map(i=>i.split(",").map(parseFloat)))}_AGBRtoRGBA(e){if(!e||e.length!=8)return;const t=parseInt(e.slice(0,2),16)/255,i=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16);return`rgba(${parseInt(e.slice(6,8),16)},${s},${i},${t})`}_parseKMLcoordinates(e){return e.innerHTML.trim().replace(/\n/g," ").replace(/\t/g," ").replace(/ +/g," ").split(" ").map(t=>t.split(",").map(parseFloat))}_kmlPlacemarkToEntity(e,t){if(!e)return;const i=Array.from(e.getElementsByTagName("name")),s=i&&i.length>0?i[0].innerHTML.trim():"",{iconHeading:r,iconURL:n,iconColor:o,lineWidth:l,lineColor:h}=this._extractStyle(e),c=[];for(const d of e.getElementsByTagName("coordinates")){const u=this._parseKMLcoordinates(d)||[[0,0,0]];for(const g of u){const[f,p,_]=g;c.push(new A(f,p,_)),f<t.southWest.lon&&(t.southWest.lon=f),p<t.southWest.lat&&(t.southWest.lat=p),f>t.northEast.lon&&(t.northEast.lon=f),p>t.northEast.lat&&(t.northEast.lat=p)}}if(c.length===1){const d=.01745329*r;return new V({name:s,lonlat:c[0],billboard:{src:n,size:[24,24],color:o,rotation:d},properties:{color:o,heading:r}})}return new V({polyline:{pathLonLat:[c],thickness:l,color:h,isClosed:!1}})}_extractStyle(e){let t,i,s,r,n;const o=e.getElementsByTagName("Style")[0];if(o){let l=o.getElementsByTagName("IconStyle")[0];if(l){let c=l.getElementsByTagName("color")[0];c&&(t=this._AGBRtoRGBA(c.innerHTML.trim()));let d=l.getElementsByTagName("heading")[0];if(d){const g=parseFloat(d.innerHTML.trim());g>=0&&g<=360&&(i=g%360)}let u=l.getElementsByTagName("Icon")[0];if(u){let g=u.getElementsByTagName("href")[0];g&&(s=g.innerHTML.trim())}}let h=o.getElementsByTagName("LineStyle")[0];if(h){let c=h.getElementsByTagName("color")[0];c&&(r=this._AGBRtoRGBA(c.innerHTML.trim()));let d=h.getElementsByTagName("width")[0];d!==void 0&&(n=parseFloat(d.innerHTML.trim()))}}return t||(t="#FFFFFF"),i||(i=0),s||(s="https://openglobus.org/examples/billboards/carrot.png"),r||(r="#FFFFFF"),n||(n=1),{iconHeading:i,iconURL:s,iconColor:t,lineWidth:n,lineColor:r}}_parseKML(e,t,i){if(i||(i=[]),e.documentElement.nodeName!=="kml")return i;for(const s of e.getElementsByTagName("Placemark")){const r=this._kmlPlacemarkToEntity(s,t);r&&i.push(r)}return i}_convertKMLintoEntities(e){const t=new G(new A(180,90),new A(-180,-90));return{entities:this._parseKML(e,t),extent:t}}_convertCoordonatesIntoEntities(e,t,i){const s=new G(new A(180,90),new A(-180,-90)),r=o=>{const l=o[0],h=o[1];l<s.southWest.lon&&(s.southWest.lon=l),h<s.southWest.lat&&(s.southWest.lat=h),l>s.northEast.lon&&(s.northEast.lon=l),h>s.northEast.lat&&(s.northEast.lat=h)},n=[];return e.forEach(o=>o.forEach(l=>n.push(l))),{entities:n.map(o=>{if(o.length===1){const l=o[0],h=new V({lonlat:l,billboard:i});return r(l),h}if(o.length>1){const l=o.map(h=>(r(h),new A(h[0],h[1],h[2])));return new V({polyline:{pathLonLat:[l],thickness:3,color:t,isClosed:!1}})}}),extent:s}}_getXmlContent(e){return new Promise(t=>{const i=new FileReader;i.onload=async s=>t(new DOMParser().parseFromString(s.target.result,"text/xml")),i.readAsText(e)})}_expandExtents(e,t){return e?(t.southWest.lon<e.southWest.lon&&(e.southWest.lon=t.southWest.lon),t.southWest.lat<e.southWest.lat&&(e.southWest.lat=t.southWest.lat),t.northEast.lon>e.northEast.lon&&(e.northEast.lon=t.northEast.lon),t.northEast.lat>e.northEast.lat&&(e.northEast.lat=t.northEast.lat),e):t}async addKmlFromFiles(e,t,i){if(!Array.isArray(e))return null;const s=(await Promise.all(e.map(this._getXmlContent))).map(this._extractCoordonatesFromKml),{entities:r,extent:n}=this._convertCoordonatesIntoEntities(s,t||this._color,i||this._billboard);return this._extent=this._expandExtents(this._extent,n),r.forEach(this.add.bind(this)),{entities:r,extent:n}}setColor(e){this._color=e,this._billboard.color=e}_getKmlFromUrl(e){return new Promise((t,i)=>{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="document",s.overrideMimeType("text/xml"),s.onload=()=>{s.readyState===s.DONE&&s.status===200?t(s.responseXML):i(new Error("no valid kml file"))},s.send()})}async addKmlFromUrl(e,t,i){const s=await this._getKmlFromUrl(e),{entities:r,extent:n}=this._convertKMLintoEntities(s);return this._extent=this._expandExtents(this._extent,n),r.forEach(this.add.bind(this)),{entities:r,extent:n}}}class ma extends xi{constructor(e,t={}){super(e||"OpenStreetMap",{iconSrc:"https://tile.openstreetmap.org/8/138/95.png",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"Data @ OpenStreetMap contributors, ODbL",isBaseLayer:!0,maxNativeZoom:19,defaultTextures:[{color:"#AAD3DF"},{color:"#F2EFE9"}],isSRGB:!1,shininess:18,specular:[63e-5,55e-5,32e-5],ambient:[.2,.2,.3],diffuse:[.9,.9,.7],...t})}}function Wc(a,e,t){var i="";for(let n=t;n>0;n--){var s=0,r=1<<n-1;a&r&&s++,e&r&&(s+=2),i+=s.toString()}return i}class va extends xi{constructor(e,t={}){super(e||"Bing",{iconSrc:"https://ecn.t0.tiles.virtualearth.net/tiles/a120.jpeg?n=z&g=7146",subdomains:["t0","t1","t2","t3"],url:"https://ecn.{s}.tiles.virtualearth.net/tiles/a{quad}.jpeg?n=z&g=7146",isBaseLayer:!0,textureFilter:"LINEAR",maxNativeZoom:17,defaultTextures:[{color:"#001522"},{color:"#E4E6F3"}],attribution:'<div style="transform: scale(0.8); margin-top:-2px;"><a href="https://www.bing.com" target="_blank"><img style="position: relative; top: 2px;" title="Bing Imagery" src="https://sandcastle.cesium.com/CesiumUnminified/Assets/Images/bing_maps_credit.png"></a> © 2021 Microsoft Corporation</div>',urlRewrite:(i,s)=>He(s,{s:this._getSubdomain(),quad:Wc(i.tileX,i.tileY,i.tileZoom)}),specular:[63e-5,55e-5,32e-5],ambient:[.35,.35,.35],diffuse:[1.5,1.5,1.5],shininess:20,nightTextureCoefficient:2.7,...t})}}Object.freeze(Object.defineProperty({__proto__:null,Bing:va,CanvasTiles:sn,GeoImage:ir,GeoTexture2d:Yc,GeoVideo:pa,KML:qc,LAYER_EVENTS:tn,Layer:qe,Material:Jr,OpenStreetMap:ma,Vector:ge,WMS:gt,XYZ:xi},Symbol.toStringTag,{value:"Module"}));const _r=function(a,e){return+(a.priority<e.priority)};class $c{constructor(){this._currentlyPressedKeys={},this._pressedKeysCallbacks={},this._unpressedKeysCallbacks={},this._charkeysCallbacks={},this._anykeyCallback=null,this._event=null,this._active=!0,this._stampCache={},document.onkeydown=e=>{this._event=e,this._active&&this.handleKeyDown()},document.onkeyup=e=>{this._event=e,this._active&&this.handleKeyUp()}}getcurrentlyPressedKeys(){return this._currentlyPressedKeys}getPressedKeysCallbacks(){return this._pressedKeysCallbacks}getUnpressedKeysCallbacks(){return this._unpressedKeysCallbacks}getCharkeysCallbacks(){return this._charkeysCallbacks}removeEvent(e,t,i){let s=this._getStamp(e,t,i._openglobus_id);i._openglobus_id&&this._stampCache[s]&&(delete this._stampCache[s],e==="keypress"?this._removeCallback(this._pressedKeysCallbacks[t],i):e==="keyfree"?this._removeCallback(this._unpressedKeysCallbacks[t],i):e==="charkeypress"&&this._removeCallback(this._charkeysCallbacks[t],i))}_removeCallback(e,t){for(let i=0;i<e.length;i++)e[i].callback._openglobus_id===t._openglobus_id&&e.splice(i,1)}_getStamp(e,t,i){return`${e}_${t}_${i}`}_stamp(e,t,i){const s=cs(i),r=this._getStamp(e,t,s);return!this._stampCache[r]&&(this._stampCache[r]=s,!0)}setActivity(e){this._active=e}releaseKeys(){this._currentlyPressedKeys={}}addEvent(e,t,i,s,r){if(this._stamp(e,t,i))switch(r===void 0&&(r=1600),e){case"keyfree":this._unpressedKeysCallbacks[t]||(this._unpressedKeysCallbacks[t]=[]),this._unpressedKeysCallbacks[t].push({callback:i,sender:s,priority:r}),this._unpressedKeysCallbacks[t].sort(_r);break;case"keypress":t==null?this._anykeyCallback={callback:i,sender:s||this}:(this._pressedKeysCallbacks[t]||(this._pressedKeysCallbacks[t]=[]),this._pressedKeysCallbacks[t].push({callback:i,sender:s,priority:r}),this._pressedKeysCallbacks[t].sort(_r));break;case"charkeypress":this._charkeysCallbacks[t]||(this._charkeysCallbacks[t]=[]),this._charkeysCallbacks[t].push({callback:i,sender:s,priority:r}),this._charkeysCallbacks[t].sort(_r)}}isKeyPressed(e){return this._currentlyPressedKeys[e]}handleKeyDown(){this._anykeyCallback&&this._anykeyCallback.callback.call(this._anykeyCallback.sender,this._event),this._currentlyPressedKeys[this._event.keyCode]=!0;for(let e in this._charkeysCallbacks)if(String.fromCharCode(this._event.keyCode)===String.fromCharCode(Number(e))){let t=this._charkeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}this._event.keyCode!=W.KEY_ALT&&this._event.keyCode!=W.KEY_SHIFT||this._event.preventDefault()}handleKeyUp(){if(this._currentlyPressedKeys[this._event.keyCode]||this._event.keyCode===W.KEY_PRINTSCREEN){for(let e in this._unpressedKeysCallbacks)if(this._currentlyPressedKeys[e]||this._event.keyCode===W.KEY_PRINTSCREEN&&Number(e)===W.KEY_PRINTSCREEN){let t=this._unpressedKeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}}this._currentlyPressedKeys[this._event.keyCode]=!1}handleEvents(){for(let e in this._pressedKeysCallbacks)if(this._currentlyPressedKeys[e]){let t=this._pressedKeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}}}class Xc{constructor(e){this._htmlObject=e}setEvent(e,t,i){switch(e){case"mousewheel":this._htmlObject.addEventListener("wheel",s=>{let r=s.deltaY||s.detail||s.wheelDelta||0;var n;s.wheelDelta==null&&(s.wheelDelta=-120*r),s.isTouchPad=(n=s).deltaMode===0&&Math.abs(n.deltaY)<50,i.call(t,s),s.preventDefault()},!1);break;case"mousedown":this._htmlObject.addEventListener("mousedown",function(s){let r=this.getBoundingClientRect();i.call(t,s,{button:s.button,clientX:s.clientX-r.left,clientY:s.clientY-r.top})}),this._htmlObject.addEventListener("contextmenu",function(s){return s.preventDefault(),!1});break;case"mouseup":this._htmlObject.addEventListener("mouseup",function(s){let r=this.getBoundingClientRect();i.call(t,s,{button:s.button,clientX:s.clientX-r.left,clientY:s.clientY-r.top})});break;case"mousemove":this._htmlObject.addEventListener("mousemove",function(s){let r=this.getBoundingClientRect();i.call(t,s,{clientX:s.clientX-r.left,clientY:s.clientY-r.top})});break;case"mouseleave":this._htmlObject.addEventListener("mouseleave",function(s){i.call(t,s)});break;case"mouseout":this._htmlObject.addEventListener("mouseout",function(s){i.call(t,s)});break;case"mouseover":this._htmlObject.addEventListener("mouseover",function(s){i.call(t,s)});break;case"mouseenter":this._htmlObject.addEventListener("mouseenter",function(s){i.call(t,s)})}}}class Zc{constructor(e){this._htmlObject=e}setEvent(e,t,i){switch(e){case"touchcancel":this._htmlObject.addEventListener("touchcancel",function(s){s.preventDefault();const r=this.getBoundingClientRect(),n=Object.assign(s,{offsetLeft:r.left,offsetTop:r.top});i.call(t,n)});break;case"touchstart":this._htmlObject.addEventListener("touchstart",function(s){s.preventDefault();const r=this.getBoundingClientRect(),n=Object.assign(s,{offsetLeft:r.left,offsetTop:r.top});i.call(t,n)});break;case"touchend":this._htmlObject.addEventListener("touchend",function(s){s.preventDefault();const r=this.getBoundingClientRect(),n=Object.assign(s,{offsetLeft:r.left,offsetTop:r.top});i.call(t,n)});break;case"touchmove":this._htmlObject.addEventListener("touchmove",function(s){s.preventDefault();const r=this.getBoundingClientRect(),n=Object.assign(s,{offsetLeft:r.left,offsetTop:r.top});i.call(t,n)})}}}let pt=new Uint8Array(4),bi=new Uint8Array(4),wi=new Uint8Array(4);class Qc extends Ps{constructor(e){super(Kc),this.renderer=e,this._touchHandler=new Zc(e.handler.canvas),this._mouseHandler=new Xc(e.handler.canvas),this._keyboardHandler=new $c,this._active=!0,this.clickRadius=15,this.mouseState={clientX:0,clientY:0,pos:new N,x:0,y:0,nx:0,ny:0,prev_x:0,prev_y:0,direction:new v,leftButtonUp:!1,rightButtonUp:!1,middleButtonUp:!1,leftButtonDown:!1,rightButtonDown:!1,middleButtonDown:!1,leftButtonHold:!1,rightButtonHold:!1,middleButtonHold:!1,leftButtonDoubleClick:!1,rightButtonDoubleClick:!1,middleButtonDoubleClick:!1,leftButtonClick:!1,rightButtonClick:!1,middleButtonClick:!1,moving:!1,justStopped:!1,doubleClickDelay:500,clickDelay:200,wheelDelta:0,sys:null,pickingObject:null,renderer:e,isTouchPad:!1},this.touchState={touching:!1,moving:!1,touchEnd:!1,touchStart:!1,touchCancel:!1,doubleTouch:!1,doubleTouchDelay:550,doubleTouchRadius:10,clientX:0,clientY:0,pos:new N,x:0,y:0,nx:0,ny:0,prev_x:0,prev_y:0,direction:new v,sys:null,pickingObject:null,renderer:e},this._isMouseInside=!0,this._entityPickingEventsActive=!0,this._dblTchCoords=new N,this._oneTouchStart=!1,this._dblTchBegins=0,this._mousestopThread=null,this._ldblClkBegins=0,this._rdblClkBegins=0,this._mdblClkBegins=0,this._lClkBegins=0,this._rClkBegins=0,this._mClkBegins=0,this._lclickX=0,this._lclickY=0,this._rclickX=0,this._rclickY=0,this._mclickX=0,this._mclickY=0}pointerEvent(){let e=this.mouseState,t=this.touchState;return e.moving||e.justStopped||t.moving||t.touchStart||t.touchEnd||e.wheelDelta!==0}get active(){return this._active}set active(e){this._active=e,this._keyboardHandler.setActivity(e)}handleEvents(){this._active&&(this.mouseState.direction=this.renderer.activeCamera.unproject(this.mouseState.x,this.mouseState.y),this.touchState.direction=this.renderer.activeCamera.unproject(this.touchState.x,this.touchState.y),this._keyboardHandler.handleEvents(),this.handleMouseEvents(),this.handleTouchEvents(),this.entityPickingEvents())}on(e,t,i,s,r){e==="keypress"||e==="charkeypress"||e==="keyfree"?this._keyboardHandler.addEvent(e,t,i,s,r):super.on(e,t,i,s)}off(e,t,i){e==="keypress"||e==="charkeypress"||e==="keyfree"?this._keyboardHandler.removeEvent(e,t,i):super.off(e,t)}isKeyPressed(e){return this._keyboardHandler.isKeyPressed(e)}releaseKeys(){this._keyboardHandler.releaseKeys()}initialize(){this._mouseHandler.setEvent("mouseup",this,this.onMouseUp),this._mouseHandler.setEvent("mousemove",this,this.onMouseMove),this._mouseHandler.setEvent("mousedown",this,this.onMouseDown),this._mouseHandler.setEvent("mousewheel",this,this.onMouseWheel),this._mouseHandler.setEvent("mouseleave",this,this.onMouseLeave),this._mouseHandler.setEvent("mouseenter",this,this.onMouseEnter),this._touchHandler.setEvent("touchstart",this,this.onTouchStart),this._touchHandler.setEvent("touchend",this,this.onTouchEnd),this._touchHandler.setEvent("touchcancel",this,this.onTouchCancel),this._touchHandler.setEvent("touchmove",this,this.onTouchMove)}onMouseWheel(e){this.mouseState.isTouchPad=e.isTouchPad||!1,this.mouseState.sys=e,this.mouseState.wheelDelta=e.wheelDelta||0}updateButtonsStates(e){let t=this.mouseState;1&e&&t.leftButtonDown?t.leftButtonDown=!0:(t.leftButtonHold=!1,t.leftButtonDown=!1),2&e&&t.rightButtonDown?t.rightButtonDown=!0:(t.rightButtonHold=!1,t.rightButtonDown=!1),4&e&&t.middleButtonDown?t.middleButtonDown=!0:(t.middleButtonHold=!1,t.middleButtonDown=!1)}onMouseMove(e,t){let i=this.mouseState;this.updateButtonsStates(e.buttons),i.sys=e;let s=t.clientX,r=t.clientY,n=this.clickRadius;if(Math.abs(this._lclickX-s)>=n&&Math.abs(this._lclickY-r)>=n&&(this._ldblClkBegins=0,this._lClkBegins=0),Math.abs(this._rclickX-s)>=n&&Math.abs(this._rclickY-r)>=n&&(this._rdblClkBegins=0,this._rClkBegins=0),Math.abs(this._mclickX-s)>=n&&Math.abs(this._mclickY-r)>=n&&(this._mdblClkBegins=0,this._mClkBegins=0),i.clientX===t.clientX&&i.clientY===t.clientY)return;i.clientX=t.clientX,i.clientY=t.clientY;let o=this.renderer.handler;i.pos.x=i.x=t.clientX*o.pixelRatio,i.pos.y=i.y=t.clientY*o.pixelRatio,i.nx=i.x/o.canvas.width,i.ny=i.y/o.canvas.height,i.moving=!0,clearTimeout(this._mousestopThread),this._mousestopThread=setTimeout(function(){i.justStopped=!0},100)}onMouseLeave(e){this._isMouseInside=!1,this.mouseState.sys=e,this.dispatch(this.mouseleave,this.mouseState)}onMouseEnter(e){this._isMouseInside=!0,this.mouseState.sys=e,this.dispatch(this.mouseenter,this.mouseState)}onMouseDown(e,t){t.button===W.MB_LEFT?(this._lClkBegins=window.performance.now(),this._lclickX=t.clientX,this._lclickY=t.clientY,this.mouseState.sys=e,this.mouseState.leftButtonDown=!0):t.button===W.MB_RIGHT?(this._rClkBegins=window.performance.now(),this._rclickX=t.clientX,this._rclickY=t.clientY,this.mouseState.sys=e,this.mouseState.rightButtonDown=!0):t.button===W.MB_MIDDLE&&(this._mClkBegins=window.performance.now(),this._mclickX=t.clientX,this._mclickY=t.clientY,this.mouseState.sys=e,this.mouseState.middleButtonDown=!0)}onMouseUp(e,t){let i=this.mouseState;i.sys=e;let s=window.performance.now();t.button===W.MB_LEFT?(i.leftButtonDown=!1,i.leftButtonUp=!0,Math.abs(this._lclickX-t.clientX)<this.clickRadius&&Math.abs(this._lclickY-t.clientY)<this.clickRadius&&s-this._lClkBegins<=i.clickDelay&&(this._ldblClkBegins?(window.performance.now()-this._ldblClkBegins<=i.doubleClickDelay&&(i.leftButtonDoubleClick=!0),this._ldblClkBegins=0):this._ldblClkBegins=window.performance.now(),i.leftButtonClick=!0,this._lClkBegins=0)):t.button===W.MB_RIGHT?(i.rightButtonDown=!1,i.rightButtonUp=!0,Math.abs(this._rclickX-t.clientX)<this.clickRadius&&Math.abs(this._rclickY-t.clientY)<this.clickRadius&&s-this._rClkBegins<=i.clickDelay&&(this._rdblClkBegins?(window.performance.now()-this._rdblClkBegins<=i.doubleClickDelay&&(i.rightButtonDoubleClick=!0),this._rdblClkBegins=0):this._rdblClkBegins=window.performance.now(),i.rightButtonClick=!0,this._rClkBegins=0)):t.button===W.MB_MIDDLE&&(i.middleButtonDown=!1,i.middleButtonUp=!0,Math.abs(this._mclickX-t.clientX)<this.clickRadius&&Math.abs(this._mclickY-t.clientY)<this.clickRadius&&s-this._mClkBegins<=i.clickDelay)&&(this._mdblClkBegins?(window.performance.now()-this._mdblClkBegins<=i.doubleClickDelay&&(i.middleButtonDoubleClick=!0),this._mdblClkBegins=0):this._mdblClkBegins=window.performance.now(),i.middleButtonClick=!0,this._mClkBegins=0)}onTouchStart(e){let t=this.touchState;t.sys=e,t.clientX=e.touches.item(0).clientX-e.offsetLeft,t.clientY=e.touches.item(0).clientY-e.offsetTop;let i=this.renderer.handler;t.pos.x=t.x=t.clientX*i.pixelRatio,t.pos.y=t.y=t.clientY*i.pixelRatio,t.nx=t.x/i.canvas.width,t.ny=t.y/i.canvas.height,t.prev_x=t.x,t.prev_y=t.y,t.touchStart=!0,t.touching=!0,e.touches.length===1?(this._dblTchCoords.x=t.x,this._dblTchCoords.y=t.y,this._oneTouchStart=!0):this._oneTouchStart=!1}onTouchEnd(e){let t=this.touchState;t.sys=e,t.touchEnd=!0,e.touches.length===0&&(t.prev_x=t.x,t.prev_y=t.y,this._oneTouchStart)&&(this._dblTchBegins&&(window.performance.now()-this._dblTchBegins<=t.doubleTouchDelay&&(t.doubleTouch=!0),this._dblTchBegins=0),this._dblTchBegins=window.performance.now(),this._oneTouchStart=!1)}onTouchCancel(e){let t=this.touchState;t.sys=e,t.touchCancel=!0}onTouchMove(e){let t=this.touchState;t.clientX=e.touches.item(0).clientX-e.offsetLeft,t.clientY=e.touches.item(0).clientY-e.offsetTop;let i=this.renderer.handler;t.x=t.clientX*i.pixelRatio,t.y=t.clientY*i.pixelRatio,t.nx=t.x/i.canvas.width,t.ny=t.y/i.canvas.height,t.sys=e,t.moving=!0;let s=t.x-t.prev_x,r=t.y-t.prev_y;(Math.abs(s)>9||Math.abs(r)>9)&&(this._dblTchBegins=0,this._oneTouchStart=!1)}entityPickingEvents(){let e=this.touchState,t=this.mouseState;if(this._isMouseInside!==this._entityPickingEventsActive&&(this._entityPickingEventsActive=this._isMouseInside,!this._entityPickingEventsActive)){let s=this.renderer,r=pt,n=s.getPickingObjectArr(r);if(n){let o=n.rendererEvents;t.pickingObject=n,o&&o.dispatch(o.mouseleave,t),e.pickingObject=n,o&&o.dispatch(o.touchleave,e)}pt[0]=pt[1]=pt[2]=pt[3]=wi[0]=wi[1]=wi[2]=wi[3]=bi[0]=bi[1]=bi[2]=bi[3]=0}if(this._isMouseInside&&!(t.leftButtonHold||t.rightButtonHold||t.middleButtonHold)){let s=this.renderer,r=pt,n=wi,o=bi;e.x||e.y?s.readPickingColor(e.nx,1-e.ny,o):s.readPickingColor(t.nx,1-t.ny,o),n[0]=r[0],n[1]=r[1],n[2]=r[2],r[0]=o[0],r[1]=o[1],r[2]=o[2],t.pickingObject=null,e.pickingObject=null;let l=s.getPickingObjectArr(r);if(t.pickingObject=l,e.pickingObject=l,r[0]!==n[0]||r[1]!==n[1]||r[2]!==n[2])if((i=r)[0]||i[1]||i[2]){if((h=>!!(h[0]||h[1]||h[2]))(n)){let h=s.getPickingObjectArr(n);if(h){let c=h.rendererEvents;t.pickingObject=h,c&&c.dispatch(c.mouseleave,t),e.pickingObject=h,c&&c.dispatch(c.touchleave,e)}}if(l){let h=l.rendererEvents;t.pickingObject=l,h&&h.dispatch(h.mouseenter,t),e.pickingObject=l,h&&h.dispatch(h.touchenter,e)}}else{let h=s.getPickingObjectArr(n);if(h){let c=h.rendererEvents;t.pickingObject=h,c&&c.dispatch(c.mouseleave,t),e.pickingObject=h,c&&c.dispatch(c.touchleave,e)}}}var i}handleMouseEvents(){let e=this,t=this.mouseState,i=t.pickingObject,s=null;t.leftButtonClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.lclick,t)),this.dispatch(e.lclick,t),t.leftButtonClick=!1),t.rightButtonClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.rclick,t)),this.dispatch(e.rclick,t),t.rightButtonClick=!1),t.middleButtonClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.mclick,t)),this.dispatch(e.mclick,t),t.middleButtonClick=!1),t.leftButtonDown&&(t.leftButtonHold?(i&&(s=i.rendererEvents,s&&s.dispatch(s.lhold,t)),this.dispatch(e.lhold,t)):(t.leftButtonHold=!0,i&&(s=i.rendererEvents,s&&s.dispatch(s.ldown,t)),this.dispatch(e.ldown,t))),t.rightButtonDown&&(t.rightButtonHold?(i&&(s=i.rendererEvents,s&&s.dispatch(s.rhold,t)),this.dispatch(e.rhold,t)):(t.rightButtonHold=!0,i&&(s=i.rendererEvents,s&&s.dispatch(s.rdown,t)),this.dispatch(e.rdown,t))),t.middleButtonDown&&(t.middleButtonHold?(i&&(s=i.rendererEvents,s&&s.dispatch(s.mhold,t)),this.dispatch(e.mhold,t)):(t.middleButtonHold=!0,i&&(s=i.rendererEvents,s&&s.dispatch(s.mdown,t)),this.dispatch(e.mdown,t))),t.leftButtonUp&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.lup,t)),this.dispatch(e.lup,t),t.leftButtonUp=!1,t.leftButtonHold=!1),t.rightButtonUp&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.rup,t)),this.dispatch(e.rup,t),t.rightButtonUp=!1,t.rightButtonHold=!1),t.middleButtonUp&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.mup,t)),this.dispatch(e.mup,t),t.middleButtonUp=!1,t.middleButtonHold=!1),t.leftButtonDoubleClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.ldblclick,t)),this.dispatch(e.ldblclick,t),t.leftButtonDoubleClick=!1),t.rightButtonDoubleClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.rdblclick,t)),this.dispatch(e.rdblclick,t),t.rightButtonDoubleClick=!1),t.middleButtonDoubleClick&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.mdblclick,t)),this.dispatch(e.mdblclick,t),t.middleButtonDoubleClick=!1),t.wheelDelta&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.mousewheel,t)),this.dispatch(e.mousewheel,t)),t.moving&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.mousemove,t)),this.dispatch(e.mousemove,t),t.prev_x=t.x,t.prev_y=t.y),t.justStopped&&this.dispatch(e.mousestop,t)}handleTouchEvents(){let e=this,t=this.touchState,i=t.pickingObject,s=null;if(t.touchCancel&&(this.dispatch(e.touchcancel,t),t.touchCancel=!1),t.touchStart){let r=this.renderer;r.readPickingColor(t.nx,1-t.ny,pt);let n=r.getPickingObjectArr(pt);i=t.pickingObject=n,i&&(s=i.rendererEvents,s&&s.dispatch(s.touchstart,t)),this.dispatch(e.touchstart,t),t.touchStart=!1}t.doubleTouch&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.doubletouch,t)),this.dispatch(e.doubletouch,t),t.doubleTouch=!1),t.touchEnd&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.touchend,t)),this.dispatch(e.touchend,t),t.x=0,t.y=0,t.touchEnd=!1,t.touching=!1),t.moving&&(i&&(s=i.rendererEvents,s&&s.dispatch(s.touchmove,t)),this.dispatch(e.touchmove,t),t.prev_x=t.x,t.prev_y=t.y)}}const Kc=["changerelativecenter","draw","drawtransparent","postdraw","resize","resizeend","mouseenter","mouseleave","mousemove","mousestop","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchstart","touchend","touchcancel","touchmove","doubletouch","touchleave","touchenter"];class Ci{constructor(e=0,t=0,i=0,s=0){this.left=e,this.right=i,this.top=t,this.bottom=s}set(e=0,t=0,i=0,s=0){this.left=e,this.right=i,this.top=t,this.bottom=s}clone(){return new Ci(this.left,this.top,this.right,this.bottom)}getWidth(){return Math.abs(this.right-this.left)}getHeight(){return Math.abs(this.bottom-this.top)}getSquare(){return this.getHeight()*this.getWidth()}getDiagonal(){let e=this.getWidth(),t=this.getHeight();return Math.sqrt(t*t+e*e)}fit(e,t){return this.getWidth()===e&&this.getHeight()===t}isInside(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}}class Jc{constructor(){this.imagesCache={},this._counter=0,this._pendingsQueue=new lr,this._imageIndexCounter=0}load(e,t){if(this.imagesCache[e])t(this.imagesCache[e]);else{let i={src:e,success:t};this._counter>=1?this._pendingsQueue.unshift(i):this._exec(i)}}_exec(e){this._counter++;const t=this;let i=new Image;i.crossOrigin="",i.onload=function(){t.imagesCache[e.src]=i,i.__nodeIndex=t._imageIndexCounter++,e.success(i),t._dequeueRequest()},i.onerror=function(){t._dequeueRequest()},i.src=e.src}_dequeueRequest(){if(this._counter--,this._pendingsQueue.length&&this._counter<1)for(;this._pendingsQueue.length;){let e=this._pendingsQueue.pop();if(e){if(!this.imagesCache[e.src]){this._exec(e);break}this._counter<=0?this._counter=0:this._counter--,e.success(this.imagesCache[e.src])}}}}class fr{constructor(e=1024,t=1024){this.nodes=new Map,this.texture=null,this.canvas=new fi(e,t),this.clearCanvas(),this._handler=null,this._images=[],this._btree=null,this._imagesCacheManager=new Jc,this.borderSize=4}getImage(){return this.canvas.getImage()}getCanvas(){return this.canvas.getCanvas()}clearCanvas(){this.canvas.fillEmpty()}assignHandler(e){this._handler=e,this.createTexture()}getDiagonal(e){let t=e.atlasWidth||e.width,i=e.atlasHeight||e.height;return Math.sqrt(t*t+i*i)}addImage(e,t=!1){if(e.width&&e.height)return this._images.push(e),this._makeAtlas(t),e.__nodeIndex!=null?this.get(e.__nodeIndex):void 0}_completeNode(e,t){if(t){let i=this.canvas.getWidth(),s=this.canvas.getHeight(),r=t.image,n=t.rect,o=Math.round(.5*this.borderSize);this.canvas.drawImage(r,n.left+o,n.top+o,r.atlasWidth||0,r.atlasHeight||0);let l=t.texCoords;l[0]=(n.left+o)/i,l[1]=(n.top+o)/s,l[2]=(n.left+o)/i,l[3]=(n.bottom-o)/s,l[4]=(n.right-o)/i,l[5]=(n.bottom-o)/s,l[6]=(n.right-o)/i,l[7]=(n.bottom-o)/s,l[8]=(n.right-o)/i,l[9]=(n.top+o)/s,l[10]=(n.left+o)/i,l[11]=(n.top+o)/s,e.set(r.__nodeIndex,t)}}_makeAtlas(e=!1){if(e&&this._btree){let t=this._images[this._images.length-1];this._completeNode(this.nodes,this._btree.insert(t))}else{let t=this._images.slice(0);t.sort(function(s,r){return(r.atlasWidth||r.width)-(s.atlasWidth||s.width)||(r.atlasHeight||r.height)-(s.atlasHeight||s.height)}),this._btree=new Ti(new Ci(0,0,this.canvas.getWidth(),this.canvas.getHeight())),this._btree.atlas=this,this.clearCanvas();let i=new Map;for(let s=0;s<t.length;s++)this._completeNode(i,this._btree.insert(t[s]));this.nodes=null,this.nodes=i}}get(e){return this.nodes.get(e)}set(e,t){this.nodes.set(e,t)}createTexture(e,t){this._handler&&(this._handler.gl.deleteTexture(this.texture),e&&(this.canvas.resize(e.width,e.height),this.canvas.drawImage(e,0,0,e.width,e.height)),this.texture=this._handler.createTexture_l(this.canvas.getCanvas(),t))}loadImage(e,t){this._imagesCacheManager.load(e,t)}getImageTexCoordinates(e){if(e.__nodeIndex!=null){let t=this.get(e.__nodeIndex);if(t)return t.texCoords}}}class Ti{constructor(e,t){this.childNodes=null,this.image=null,this.rect=e||new Ci,this.texCoords=t||[],this.atlas=null}insert(e){if(this.childNodes)return this.childNodes[0].insert(e)||this.childNodes[1].insert(e);{if(this.image!=null)return;let t=this.rect;const i=(e.atlasWidth||e.width)+this.atlas.borderSize,s=(e.atlasHeight||e.height)+this.atlas.borderSize;return i>t.getWidth()||s>t.getHeight()?void 0:t.fit(i,s)?(this.image=e,this):(this.childNodes=new Array(2),this.childNodes[0]=new Ti,this.childNodes[0].atlas=this.atlas,this.childNodes[1]=new Ti,this.childNodes[1].atlas=this.atlas,t.getWidth()-i>t.getHeight()-s?(this.childNodes[0].rect.set(t.left,t.top,t.left+i,t.bottom),this.childNodes[1].rect.set(t.left+i,t.top,t.right,t.bottom)):(this.childNodes[0].rect.set(t.left,t.top,t.right,t.top+s),this.childNodes[1].rect.set(t.left,t.top+s,t.right,t.bottom)),this.childNodes[0].insert(e))}}}class ya extends fr{constructor(e,t){super(e,t),this.width=0,this.height=0,this.gliphSize=0,this.distanceRange=0,this.nodes=new Map,this.kernings={}}get(e){return this.nodes.get(e)}}class ed extends Ti{constructor(e,t){super(e,t),this.emptySize=1,this.metrics={id:0,char:"",width:0,height:0,x:0,y:0,chnl:0,index:0,page:0,xadvance:0,xoffset:0,yoffset:0,nChar:"",nCode:0,nWidth:0,nHeight:0,nAdvance:0,nXOffset:0,nYOffset:0}}}class td{constructor(e){this.atlasesArr=[],this.atlasIndexes={},this.atlasIndexesDeferred={},this.tokenImageSize=64,this.samplerArr=new Uint32Array(11),this.sdfParamsArr=new Float32Array(44),this._handler=null,this.catalogSrc=e||"./"}assignHandler(e){this._handler=e}getFontIndex(e){let t=this.getFullIndex(e);return this.atlasIndexes[t]||this.loadFont(e,this.catalogSrc,`${e}.json`),this.atlasIndexesDeferred[t]||(this.atlasIndexesDeferred[t]=new ui),this.atlasIndexesDeferred[t].promise}getFullIndex(e){return e.trim().toLowerCase()}_applyFontDataToAtlas(e,t,i=0){let s=t.chars;e.height=t.common.scaleH,e.width=t.common.scaleW,e.gliphSize=t.info.size,e.distanceRange=t.distanceField.distanceRange;let r=e.width,n=e.height,o=e.gliphSize;this.sdfParamsArr[4*i]=r,this.sdfParamsArr[4*i+1]=n,this.sdfParamsArr[4*i+2]=o,this.sdfParamsArr[4*i+3]=e.distanceRange;let l={};for(let h=0;h<s.length;h++){let c=s[h],d=c.char;l[c.id]=d;let u=new Ci(c.x,c.y,c.x+c.width,c.y+c.height),g=new Array(12);g[0]=u.left/r,g[1]=u.top/n,g[2]=u.left/r,g[3]=u.bottom/n,g[4]=u.right/r,g[5]=u.bottom/n,g[6]=u.right/r,g[7]=u.bottom/n,g[8]=u.right/r,g[9]=u.top/n,g[10]=u.left/r,g[11]=u.top/n;let f=new ed(u,g),p=c.char.normalize("NFKC"),_=p.charCodeAt(0),m=f.metrics;m.id=c.id,m.char=c.char,m.width=c.width,m.height=c.height,m.x=c.x,m.y=c.y,m.chnl=c.chnl,m.index=c.index,m.page=c.page,m.xadvance=c.xadvance,m.xoffset=c.xoffset,m.yoffset=c.yoffset,m.nChar=p,m.nCode=_,m.nWidth=f.metrics.width/o,m.nHeight=f.metrics.height/o,m.nAdvance=f.metrics.xadvance/o,m.nXOffset=f.metrics.xoffset/o,m.nYOffset=1-f.metrics.yoffset/o,f.emptySize=1,e.nodes.set(p.charCodeAt(0),f)}e.kernings={};for(let h=0;h<t.kernings.length;h++){let c=t.kernings[h],d=c.first,u=c.second;e.kernings[d]||(e.kernings[d]={}),e.kernings[d][u]=c.amount/o}}initFont(e,t,i){let s=this.atlasesArr.length,r=this.getFullIndex(e);this.atlasIndexes[r]=s;let n=this.atlasIndexesDeferred[r];n||(n=this.atlasIndexesDeferred[r]=new ui),this.samplerArr[this.atlasesArr.length]=s;let o=new ya;o.height=0,o.width=0,o.gliphSize=0,o.distanceRange=0,o.kernings={},o.assignHandler(this._handler),this.atlasesArr[s]=o,this._applyFontDataToAtlas(o,t,s);let l=new Image;l.onload=()=>{this._createTexture(o,l),n.resolve(s)},l.src=i}_createTexture(e,t){e.createTexture(t)}loadFont(e,t,i){let s=this.atlasesArr.length,r=this.getFullIndex(e);this.atlasIndexes[r]=s;let n=this.atlasIndexesDeferred[r];n||(n=this.atlasIndexesDeferred[r]=new ui),this.samplerArr[this.atlasesArr.length]=s;let o=new ya;o.height=0,o.width=0,o.gliphSize=0,o.distanceRange=0,o.kernings={},o.assignHandler(this._handler),this.atlasesArr[s]=o,fetch(`${t}/${i}`).then(l=>{if(!l.ok)throw Error(`Unable to load "${t}/${i}"`);return l.json()}).then(l=>{this._applyFontDataToAtlas(o,l,s);let h=new Image;h.onload=()=>{this._createTexture(o,h),n.resolve(s)},h.src=`${t}/${l.pages[0]}`,h.crossOrigin="Anonymous"}).catch(l=>(n.reject(),{status:"error",msg:l.toString()}))}}let id=0,sd=0,Yt=new Float32Array(2);class rd{constructor(e,t={}){var i,s;if(this.div=null,this.handler=e instanceof wt?e:new wt(e,{pixelRatio:t.dpi||window.devicePixelRatio+.15,autoActivate:!0}),this.exposure=t.exposure||3.01,this.gamma=t.gamma||.47,this.whitepoint=1,this.brightThreshold=.9,this._renderNodesArr=[],this.renderNodes={},this.activeCamera=new Js({width:(i=this.handler.canvas)==null?void 0:i.width,height:(s=this.handler.canvas)==null?void 0:s.height,eye:new v(0,0,0),look:new v(0,0,-1),up:new v(0,1,0)}),this.events=new Qc(this),this.controls={},t.controls)for(let o in t.controls)this.controls[t.controls[o].name]=t.controls[o];this.controlsBag={},this.colorObjects=new Map,this._pickingCallbacks=[],this.pickingFramebuffer=null,this._depthCallbacks=[],this.depthFramebuffer=null;let r=new URLSearchParams(location.search),n=r.get("og_msaa");this._msaa=n?Number(r.get("og_msaa")):t.msaa!=null?t.msaa:0,this._internalFormat="RGBA16F",this._format="RGBA",this._type="FLOAT",this.sceneFramebuffer=null,this.blitFramebuffer=null,this.toneMappingFramebuffer=null,this._initialized=!1,this.billboardsTextureAtlas=new fr,this.geoObjectsTextureAtlas=new fr,this.fontAtlas=new td(t.fontsSrc),this._entityCollections=[[]],this._currentOutput="screen",this._fnScreenFrame=null,this.labelWorker=new xl(4),this.screenDepthFramebuffer=null,this.screenFramePositionBuffer=null,this.screenTexture={},this.outputTexture=null,this._readPickingBuffer=this._readPickingBuffer_webgl2,(t.autoActivate||Ge(t.autoActivate))&&this.start()}enableBlendOneSrcAlpha(){let e=this.handler.gl;e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}enableBlendDefault(){let e=this.handler.gl;e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE)}setRelativeCenter(e){this.events.dispatch(this.events.changerelativecenter,e||this.activeCamera.eye)}setEventsActivity(e){this.events.active=e}addDepthCallback(e,t){let i=sd++;return this._depthCallbacks.push({id:i,callback:t,sender:e}),i}removeDepthCallback(e){for(let t=0;t<this._depthCallbacks.length;t++)if(e===this._depthCallbacks[t].id){this._depthCallbacks.splice(t,1);break}}addPickingCallback(e,t){let i=id++;return this._pickingCallbacks.push({id:i,callback:t,sender:e}),i}removePickingCallback(e){for(let t=0;t<this._pickingCallbacks.length;t++)if(e===this._pickingCallbacks[t].id){this._pickingCallbacks.splice(t,1);break}}getPickingObject(e,t,i){return this.colorObjects.get(`${e}_${t}_${i}`)}getPickingObjectArr(e){return this.colorObjects.get(`${e[0]}_${e[1]}_${e[2]}`)}getPickingObject3v(e){return this.colorObjects.get(`${e.x}_${e.y}_${e.z}`)}assignPickingColor(e){if(!e._pickingColor||e._pickingColor.isZero()){let t=0,i=0,s=0,r="0_0_0";for(;!(t||i||s)||this.colorObjects.has(r);)t=Ri(1,255),i=Ri(1,255),s=Ri(1,255),r=`${t}_${i}_${s}`;e._pickingColor?e._pickingColor.set(t,i,s):e._pickingColor=new v(t,i,s),e._pickingColorU=new Float32Array([t/255,i/255,s/255]),this.colorObjects.set(r,e)}}clearPickingColor(e){if(e._pickingColor&&!e._pickingColor.isZero()){let t=e._pickingColor;t.isZero()||(this.colorObjects.delete(`${t.x}_${t.y}_${t.z}`),t.x=t.y=t.z=0)}}getWidth(){return this.handler.canvas.clientWidth}getHeight(){return this.handler.canvas.clientHeight}getCenter(){let e=this.handler.canvas;return new N(Math.round(.5*e.width),Math.round(.5*e.height))}getClientCenter(){let e=this.handler.canvas;return new N(Math.round(.5*e.clientWidth),Math.round(.5*e.clientHeight))}addControl(e){e.addTo(this)}addControls(e){for(let t=0;t<e.length;t++)e[t].addTo(this)}removeControl(e){e.remove()}isInitialized(){return this._initialized}initialize(){if(!this._initialized){if(this._initialized=!0,this.handler.initialize(),this.billboardsTextureAtlas.assignHandler(this.handler),this.geoObjectsTextureAtlas.assignHandler(this.handler),this.fontAtlas.assignHandler(this.handler),this.handler.setFrameCallback(()=>{this.draw()}),this.events.initialize(),this.events.on("charkeypress",W.KEY_APOSTROPHE,function(){Qe.setVisibility(!Qe.getVisibility())}),this.handler.addProgram(new X("screenFrame",{uniforms:{texture:"sampler2d"},attributes:{corners:"vec3"},vertexShader:`attribute vec2 corners;
892
+ }`}))}frame(){this.renderer.handler.programs.axesShader.activate().set({projectionViewMatrix:this.renderer.activeCamera.getProjectionViewMatrix(),aVertexPosition:this.axesBuffer,aVertexColor:this.axesColorBuffer}),this.renderer.handler.programs.axesShader.drawArrays(this.drawMode,this.axesBuffer.numItems)}createAxesBuffer(a){const e=[0,0,0,a-1,0,0,0,0,0,0,a-1,0,0,0,0,0,0,a-1];this.axesBuffer=this.renderer.handler.createArrayBuffer(new Float32Array(e),3,6),this.axesColorBuffer=this.renderer.handler.createArrayBuffer(new Float32Array([1,0,0,1,1,0,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,0,1]),4,6)}},Planet:yi,RenderNode:ot,SkyBox:cs},Symbol.toStringTag,{value:"Module"}));const go=class Qo{constructor(e={}){this.__id=Qo.__counter__++,this.equalizeVertices=e.equalizeVertices||!1,this.equalizeNormals=!1,this.isEmpty=!0,this.name=e.name||"empty",this.minZoom=e.minZoom||2,this.maxZoom=e.maxZoom||19,this.maxNativeZoom=e.maxNativeZoom||this.maxZoom,this.gridSizeByZoom=e.gridSizeByZoom||[64,32,16,8,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],this._maxNodeZoom=this.gridSizeByZoom.length-1,this.plainGridSize=2,this.noDataValues=[],this._planet=null,this._geoid=e.geoid||new lo({src:e.geoidSrc||null}),this._isReady=!1}setUrlRewriteCallback(e){}get isIdle(){return!0}isEqual(e){return e.__id===this.__id}static checkNoDataValue(e,t){return gr(e,t)!==-1}isBlur(e){return!1}set maxNodeZoom(e){e>this.gridSizeByZoom.length-1&&(e=this.gridSizeByZoom.length-1),this._maxNodeZoom=e}get maxNodeZoom(){return this._maxNodeZoom}set geoid(e){this._geoid=e}get geoid(){return this._geoid}getGeoid(){return this._geoid}handleSegmentTerrain(e){e.terrainIsLoading=!1,e.terrainReady=!0,e.terrainExists=!0}isReady(){return this._isReady}abortLoading(){}clearCache(){}getHeightAsync(e,t){return t(0),!0}loadTerrain(e,t=!1){}};go.__counter__=0;let ds=go;class us extends ds{constructor(e="",t={}){super({geoidSrc:"https://openglobus.org/geoid/egm84-30.pgm",maxNativeZoom:t.maxNativeZoom||14,...t}),this._s=t.subdomains||["a","b","c"],this.events=le(Vc,this),this._requestCount=0,this._requestsPeerSubdomain=4,this.isEmpty=!1,this.equalizeNormals=!0,this.name=e||"openglobus",this.url=t.url||"https://{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm",this.gridSizeByZoom=t.gridSizeByZoom||[64,32,32,16,16,8,8,8,16,16,16,32,32,32,32,16,8,4,2,2,2,2,2,2],this._heightFactor=t.heightFactor!=null?t.heightFactor:1,this.noDataValues=t.noDataValues||[];for(let i=0;i<this.noDataValues.length;i++)this.noDataValues[i]*=this._heightFactor;this.plainGridSize=t.plainGridSize||32,this._extent=fr(t.extent,new j(new A(-180,-90),new A(180,90))),this._dataType="arrayBuffer",this._maxNodeZoom=this.gridSizeByZoom.length-1,this._elevationCache={},this._fetchCache={},this._cache=t.cache||"default",this._loader=new ho,this._urlRewriteCallback=t.urlRewrite||null}get loader(){return this._loader}clearCache(){for(let e in this._elevationCache)this._elevationCache[e].heights=null,this._elevationCache[e].extent=null,delete this._elevationCache[e];this._elevationCache=null,this._elevationCache={};for(let e in this._fetchCache)this._fetchCache[e]=null,delete this._fetchCache[e];this._fetchCache=null,this._fetchCache={}}isBlur(e){return e.tileZoom>=6}setElevationCache(e,t){this._elevationCache[e]=t}getElevationCache(e){return this._elevationCache[e]}getHeightAsync(e,t,i,r){if(!e||e.lat>de||e.lat<Oe)return t(0),!0;r=r==null||r;const[s,n,o,l]=this._planet.quadTreeStrategy.getTileXY(e,i||this.maxZoom);let h=Ye.getTileIndex(s,n,o,l),c=this.getElevationCache(h),d=Ii(e);if(c)return c.heights?t(this._getGroundHeightMerc(d,c)):t(0),!0;{let u=this._fetchCache[h];u||(u=this._loader.fetch({src:this._urlRewriteCallback&&this._urlRewriteCallback(s,n,o,l)||this.buildURL(s,n,o,l),type:this._dataType,options:{cache:this._cache}}),this._fetchCache[h]=u),u.then(g=>{let f=Bt(s,n,o);if(g.status==="ready"){let p={heights:this._createHeights(g.data,null,l,s,n,o,f),extent:f};this.setElevationCache(h,p),t(this._getGroundHeightMerc(d,p))}else if(g.status==="error"){if(r&&o>this.maxNativeZoom)return r=!1,void this.getHeightAsync(e,t,this.maxNativeZoom,!1);this.setElevationCache(h,{heights:null,extent:f}),t(0)}else this._fetchCache[h]=null,delete this._fetchCache[h]})}return!1}_getGroundHeightMerc(e,t){if(!t.extent||!t.heights)return 0;let i=t.extent.getWidth(),r=Math.sqrt(t.heights.length),s=i/(r-1),n=r-Math.ceil((e.lat-t.extent.southWest.lat)/s)-1,o=Math.floor((e.lon-t.extent.southWest.lon)/s),l=(n+1)*r+o,h=l+1,c=n*r+o,d=c+1,u=t.heights[l],g=t.heights[h],f=t.heights[c],p=t.heights[d],_=new m(t.extent.southWest.lon+s*o,u,t.extent.northEast.lat-s*n-s),v=new m(_.x+s,g,_.z),x=new m(_.x,f,_.z+s),y=new m(_.x+s,p,_.z+s),w=new m(e.lon,1e5,e.lat),b=new H(w,new m(0,-1,0)),E=new m,C=b.hitTriangleRes(_,v,x,E);return C===H.INSIDE?E.y:(C=b.hitTriangleRes(v,y,x,E),C===H.INSIDE?E.y:0)}abortLoading(){this._loader.abortAll()}setUrl(e){this.url=e}setName(e){this.name=e}isReadyToLoad(e){return e._tileGroup===0&&this._extent.overlaps(e.getExtentLonLat())}loadTerrain(e,t=!1){if(this._planet.terrainLock.isFree())if(e.terrainReady=!1,e.terrainIsLoading=!0,this.isReadyToLoad(e)){let i=this.getElevationCache(e.tileIndex);i?this._applyElevationsData(e,i.heights):this._loader.load({sender:this,src:this._getHTTPRequestString(e),segment:e,type:this._dataType,options:{cache:this._cache},filter:()=>e.plainReady&&e.node.getState()!==0||t},r=>{if(r.status==="ready"){let s=this._createHeights(r.data,e,e._tileGroup,e.tileX,e.tileY,e.tileZoom,e.getExtent(),e.tileZoom===this.maxZoom);this.setElevationCache(e.tileIndex,{heights:s,extent:e.getExtent()}),this._applyElevationsData(e,s)}else r.status==="abort"?e.terrainIsLoading=!1:r.status==="error"?this._applyElevationsData(e,null):e.terrainIsLoading=!1})}else e.elevationsNotExists();else e.terrainIsLoading=!1}_getSubdomain(){return this._requestCount++,this._s[Math.floor(this._requestCount%(this._requestsPeerSubdomain*this._s.length)/this._requestsPeerSubdomain)]}buildURL(e,t,i,r){return Ne(this.url,{s:this._getSubdomain(),x:e.toString(),y:t.toString(),z:i.toString()})}_createUrl(e){return this.buildURL(e.tileX,e.tileY,e.tileZoom,e._tileGroup)}_getHTTPRequestString(e){return this._urlRewriteCallback&&this._urlRewriteCallback(e.tileX,e.tileY,e.tileZoom,e._tileGroup)||this._createUrl(e)}setUrlRewriteCallback(e){this._urlRewriteCallback=e}_createHeights(e,t,i,r,s,n,o,l){if(this._heightFactor!==1){let h=new Float32Array(e);for(let c=0,d=h.length;c<d;c++)h[c]=h[c]*this._heightFactor;return h}return new Float32Array(e)}_applyElevationsData(e,t){if(e){let i=this.events.load;i.handlers.length&&this.events.dispatch(i,{elevations:t,segment:e}),e.applyTerrain(t)}}}const Vc=["load","loadend"];class xi extends Ye{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(Uc),this.url=t.url||"",this._s=t.subdomains||["a","b","c"],this.minNativeZoom=t.minNativeZoom||0,this.maxNativeZoom=t.maxNativeZoom||19,this._urlRewriteCallback=t.urlRewrite||null,this._requestsPeerSubdomains=4,this._requestCount=0,this._cache=t.cache||"default"}get isIdle(){return super.isIdle&&this._planet._tileLoader.getRequestCounter(this)===0}get instanceName(){return"XYZ"}abortLoading(){this._planet&&this._planet._tileLoader.abort(this)}setVisibility(e){e!==this._visibility&&(super.setVisibility(e),e||this.abortLoading())}remove(){return this.abortLoading(),super.remove(),this}setUrl(e){this.url=e}_checkSegment(e){return e._projection.id===this._planet.quadTreeStrategy.projection.id}loadMaterial(e,t=!1){let i=e.segment;this._isBaseLayer?e.texture=i.getDefaultTexture():e.texture=i.planet.transparentTexture,(this._planet.layerLock.isFree()||e.segment.tileZoom<2)&&(e.isReady=!1,e.isLoading=!0,this._checkSegment(i)?(e.loadingAttempts++,this._planet._tileLoader.load({sender:this,src:this._getHTTPRequestString(e.segment),type:"imageBitmap",filter:()=>i.initialized&&i.node.getState()===1||t,options:{cache:this._cache}},r=>{if(r.status==="ready"){if(e.isLoading){let s=this.events.load;s.handlers.length&&this.events.dispatch(s,e),e.applyImage(r.data),r.data=null}}else r.status==="abort"?e.isLoading=!1:r.status==="error"&&e.isLoading&&e.textureNotExists()})):e.textureNotExists())}_createUrl(e){return Ne(this.url,{s:this._getSubdomain(),x:e.tileX.toString(),y:e.tileY.toString(),z:e.tileZoom.toString()})}_getSubdomain(){return this._requestCount++,this._s[Math.floor(this._requestCount%(this._requestsPeerSubdomains*this._s.length)/this._requestsPeerSubdomains)]}_getHTTPRequestString(e){return this._urlRewriteCallback?this._urlRewriteCallback(e,this.url):this._createUrl(e)}setUrlRewriteCallback(e){this._urlRewriteCallback=e}applyMaterial(e,t=!1){if(e.isReady)return e.texOffset;if(e.segment.tileZoom<this.minNativeZoom)e.textureNotExists();else{let i=e.segment,r=i.node,s=!1,n=this.__id,o=e;for(;r.parentNode;)if(r=r.parentNode,o=r.segment.materials[n],o&&o.textureExists){s=!0;break}if(i.passReady){let l=e.layer.maxNativeZoom;if(r.segment.tileZoom===l)e.textureNotExists();else if(e.segment.tileZoom<=l)!e.isLoading&&!e.isReady&&this.loadMaterial(e,t);else{let h=i.node;for(;h.segment.tileZoom>e.layer.maxNativeZoom;)h=h.parentNode;let c=h.segment.materials[e.layer.__id];c?!c.isLoading&&!c.isReady&&this.loadMaterial(c,!0):(c=h.segment.materials[e.layer.__id]=e.layer.createMaterial(h.segment),this.loadMaterial(c,!0))}}if(s){e.appliedNode=r,e.appliedNodeId=r.nodeId,e.texture=o.texture;let l=1/(2<<i.tileZoom-r.segment.tileZoom-1);e.texOffset[0]=i.tileX*l-r.segment.tileX,e.texOffset[1]=i.tileY*l-r.segment.tileY,e.texOffset[2]=l,e.texOffset[3]=l}else e.texture=i.planet.transparentTexture,e.texOffset[0]=0,e.texOffset[1]=0,e.texOffset[2]=1,e.texOffset[3]=1}return e.texOffset}clearMaterial(e){e.isReady&&e.textureExists&&(!e.texture.default&&e.segment.handler.gl.deleteTexture(e.texture),e.texture=null),e.isReady=!1,e.textureExists=!1,e.isLoading=!1}_correctFullExtent(){let e=this._extent,t=this._extentMerc;e.northEast.lat===90&&(t.northEast.lat=2008750834e-2),e.northEast.lon===180&&(t.northEast.lon=2008750834e-2),e.southWest.lat===-90&&(t.southWest.lat=-2008750834e-2),e.southWest.lon===-180&&(t.southWest.lon=-2008750834e-2)}}const Uc=["load","loadend"];class gt extends xi{constructor(e,t){super(e,t),this._extra=new URLSearchParams(t.extra).toString(),t.extent||this.setExtent(new j(new A(-180,-90),new A(180,90))),this.layers=t.layers,this.imageWidth=t.imageWidth||256,this.imageHeight=t.imageHeight||256,this._getBbox=gt.get_bbox_v1_1_1,this._version="",this.setVersion(t.version)}static createRequestUrl(e,t,i="image/png",r="1.1.1",s="GetMap",n,o,l=256,h=256,c){return`${e}?LAYERS=${t}&FORMAT=${i}&SERVICE=WMS&VERSION=${r}&REQUEST=${s}&SRS=${n}&BBOX=${o}&WIDTH=${l}&HEIGHT=${h}`+(c?`&${c}`:"")}static get_bbox_v1_1_1(e){return`${e.getWest()},${e.getSouth()},${e.getEast()},${e.getNorth()}`}static get_bbox_v1_3_0(e){return`${e.getSouth()},${e.getWest()},${e.getNorth()},${e.getEast()}`}_checkSegment(e){return!0}get instanceName(){return"WMS"}_createUrl(e){return gt.createRequestUrl(this.url,this.layers,"image/png",this._version,"GetMap",e._projection.code,this._getBbox(e.getExtent()),this.imageWidth,this.imageHeight,this._extra)}setVersion(e){this._version=e||"1.1.1",this._version==="1.1.1"?this._getBbox=gt.get_bbox_v1_1_1:e==="1.3.0"&&(this._getBbox=gt.get_bbox_v1_3_0)}_correctFullExtent(){const e=this._extent,t=this._extentMerc;e.northEast.lat===90&&(t.northEast.lat=2008750834e-2),e.northEast.lon===180&&(t.northEast.lon=2008750834e-2),e.southWest.lat===-90&&(t.southWest.lat=-2008750834e-2),e.southWest.lon===-180&&(t.southWest.lon=-2008750834e-2)}}class Gt extends us{constructor(e={}){super("BilTerrain",e),this.equalizeVertices=!0,this.equalizeNormals=!0,this.minZoom=e.minZoom||2,this.maxZoom=e.maxZoom||14,this.noDataValues=e.noDataValues||[-9999,32767],this.url=e.url||"",this._format="application/bil16",this._layers=e.layers||"",this._imageSize=e.imageSize||256,this.plainGridSize=e.plainGridSize!=null?e.plainGridSize:Mi(this._imageSize)?this._imageSize/2:St(this._imageSize)/2,this._dataType="arrayBuffer"}isBlur(e){return e.tileZoom>=18}_createUrl(e){return gt.createRequestUrl(this.url,this._layers,this._format,"1.1.1","GetMap",e._projection.code,gt.get_bbox_v1_1_1(e.getExtent()),this._imageSize,this._imageSize)}_createHeights(e,t,i,r,s,n,o,l){let h=new Int16Array(e);if(!Mi(this._imageSize)){let p=new Float32Array(h.length);return function(_,v){for(let x=0,y=v.length;x<y;x++)v[x]=_[x]}(h,p),p}let c=(this.plainGridSize+1)*(this.plainGridSize+1),d=new Array(4);for(let p=0;p<4;p++){d[p]=[];for(let _=0;_<4;_++)d[p][_]=new Float32Array(c)}let u=new Float32Array(c);(function(p,_,v,x){let y=Math.sqrt(v.length)-1,w=y+1,b=Math.sqrt(p.length),E=b/y,C=0,T=0;for(let L=0,M=0,R=p.length;L<R;L++){let z=p[L],F=Gt.checkNoDataValue(_,z),P=!1,D=!1,k=Math.floor(L/b),I=L%b,B=Math.floor(I/y),G=Math.floor(k/y),Ve=x[G][B],ve=k%y,ze=I%y,Re=(ve+G)*w+ze+B;if(Ve[Re]=z,(k+G)%E==0&&(I+B)%E==0&&(v[M++]=z),(I+1)%y==0&&I!==b-1){C=p[L],P=Gt.checkNoDataValue(_,C);let ie=z;F||P||(ie=.5*(z+C)),Re=(ve+G)*w+ze+1,Ve[Re]=ie,(k+G)%E==0&&(v[M++]=ie);let Ue=(ve+G)*w+(ze+1)%y;x[G][B+1][Ue]=ie}if((k+1)%y==0&&k!==b-1){T=p[L+b],D=Gt.checkNoDataValue(_,T);let ie=z;F||D||(ie=.5*(z+T)),Re=(ve+1)*w+ze+B,Ve[Re]=ie,(I+B)%E==0&&(v[M++]=ie);let Ue=(ve+1)%y*w+ze+B;x[G+1][B][Ue]=ie}if((I+1)%y==0&&I!==b-1&&(k+1)%y==0&&k!==b-1){let ie=p[L+b+1],Ue=Gt.checkNoDataValue(_,ie),De=z;F||P||D||Ue||(De=.25*(z+C+T+ie)),Re=(ve+1)*w+(ze+1),Ve[Re]=De,v[M++]=De;let Ei=(ve+1)*w;x[G][B+1][Ei]=De;let Ai=y;x[G+1][B][Ai]=De;let Li=0;x[G+1][B+1][Li]=De}}})(h,this.noDataValues,u,d);let g=Ye.getTileIndex(r,s,n,i);this.setElevationCache(g,{heights:u,extent:o});let f=this._imageSize/this.plainGridSize;for(let p=0;p<f;p++)for(let _=0;_<f;_++){let v=2*r+_,x=2*s+p,y=n+1,w=Ye.getTileIndex(v,x,y,i);this.setElevationCache(w,{heights:d[p][_],extent:Bt(v,x,y)})}return u}}class Me extends us{constructor(e,t={}){super(e||"RgbTerrain",{equalizeVertices:t.equalizeVertices==null||t.equalizeVertices,maxZoom:t.maxZoom||17,noDataValues:t.noDataValues||[t.minHeight!=null?t.minHeight:-1e4],plainGridSize:t.plainGridSize||128,url:t.url!=null?t.url:`//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${t.key||"<key>"}`,gridSizeByZoom:t.gridSizeByZoom||[64,32,16,8,8,8,16,16,16,32,32,32,32,32,32,64,64,64,32,32,16,8],...t}),this.equalizeNormals=t.equalizeNormals||!1,this._dataType="imageBitmap",this._imageSize=t.imageSize||256,this._ctx=this._createTemporalCanvas(this._imageSize),this._imageDataCache={},this._minHeight=t.minHeight||-1e4,this._resolution=t.resolution||.1}static checkNoDataValue(e,t){return t>5e4||gr(e,t)!==-1}rgb2Height(e,t,i){return e===255?this._minHeight:this._minHeight+this._resolution*(256*e*256+256*t+i)}isBlur(e){return e.tileZoom>=16}_createTemporalCanvas(e){let t=document.createElement("canvas");return t.width=e,t.height=e,t.getContext("2d",{willReadFrequently:!0})}_createHeights(e,t,i,r,s,n,o,l){this._ctx.clearRect(0,0,this._imageSize,this._imageSize),this._ctx.drawImage(e,0,0);let h=this._ctx.getImageData(0,0,this._imageSize,this._imageSize).data;const c=e.width;let d=0,u=0,g=0,f=null,p=!1;if(t&&t.tileZoom>this.maxNativeZoom){let b=t.node;for(;b&&!b.segment.terrainExists;)b=b.parentNode;b&&(d=b.segment.tileX,u=b.segment.tileY,g=b.segment.tileZoom,f=b.segment.elevationData,p=g<=8)}if(!Mi(this._imageSize)&&c===this._imageSize){let b=new Float32Array(c*c);return this.extractElevationTilesRgbNonPowerOfTwo(h,b,this._heightFactor),b}if(this._imageSize===this.plainGridSize){let b=(this.plainGridSize+1)*(this.plainGridSize+1),E=new Float32Array(b),[C,T,L]=t?_s(t.tileX,t.tileY,t.tileZoom,d,u,g):[0,0,0];return this.extractElevationSimple(h,this.noDataValues,f,C,T,L,p,E,this._heightFactor,this._imageSize),E}let _=(this.plainGridSize+1)*(this.plainGridSize+1),v=c/this.plainGridSize,x=new Float32Array(_),y=new Array(v);for(let b=0;b<v;b++){y[b]=[];for(let E=0;E<v;E++)y[b][E]=new Float32Array(_)}if(l)this.extractElevationTilesRgbNoChildren(h,this._heightFactor,this.noDataValues,f,d,u,g,t?t.tileX:0,t?t.tileY:0,t?t.tileZoom:0,p,x);else{this.extractElevationTilesRgb(h,this._heightFactor,this.noDataValues,f,d,u,g,t?t.tileX:0,t?t.tileY:0,t?t.tileZoom:0,p,x,y);for(let b=0;b<v;b++)for(let E=0;E<v;E++){let[C,T,L]=[2*r+E,2*s+b,n+1],M=Ye.getTileIndex(C,T,L,i);this.setElevationCache(M,{heights:y[b][E],extent:Bt(C,T,L)})}}let w=Ye.getTileIndex(r,s,n,i);return this.setElevationCache(w,{heights:x,extent:o}),x}getHeightAsync(e,t,i){if((i=i??this.maxZoom)===0)return t(0),!0;const r=this._planet.quadTreeStrategy,[s,n,o,l]=r.getTileXY(e,i),[h,c]=r.getLonLatTileOffset(e,s,n,o,this._imageSize),d=4*(h*this._imageSize+c),u=Ye.getTileIndex(s,n,o,l);if(this._imageDataCache[u]){let f=this._imageDataCache[u],p=this._heightFactor*this.rgb2Height(f[d],f[d+1],f[d+2]);return Me.checkNoDataValue(this.noDataValues,p)?this.getHeightAsync(e,t,i-1):(t(this._heightFactor*this.rgb2Height(f[d],f[d+1],f[d+2])),!0)}let g=this._fetchCache[u];return g||(g=this._loader.fetch({src:this._urlRewriteCallback&&this._urlRewriteCallback(s,n,o,l)||this.buildURL(s,n,o,l),type:this._dataType,options:{cache:this._cache}}),this._fetchCache[u]=g),g.then(f=>{if(f.status==="ready"){this._ctx.clearRect(0,0,this._imageSize,this._imageSize),this._ctx.drawImage(f.data,0,0);let p=this._ctx.getImageData(0,0,256,256).data;this._imageDataCache[u]=p;let _=this._heightFactor*this.rgb2Height(p[d],p[d+1],p[d+2]);if(Me.checkNoDataValue(this.noDataValues,_))return this.getHeightAsync(e,t,i-1);t(this._heightFactor*this.rgb2Height(p[d],p[d+1],p[d+2]))}else{if(f.status==="error")return this.getHeightAsync(e,t,i-1);this._fetchCache[u]=null,delete this._fetchCache[u]}}),!1}extractElevationSimple(e,t,i=null,r,s,n,o,l,h=1,c){for(let u=0,g=c*c;u<g;u++){let f=u%c,p=Math.floor(u/c),_=4*u,v=h*this.rgb2Height(e[_],e[_+1],e[_+2]);(Me.checkNoDataValue(t,v)||v===0)&&i&&(v=$e(n,r,s,i,p,f,o)),l[p*(c+1)+f]=v}for(let u=0,g=c;u<g;u++){let f=c-1,p=4*(u*c+f),_=h*this.rgb2Height(e[p],e[p+1],e[p+2]);(Me.checkNoDataValue(t,_)||_===0)&&i&&(_=$e(n,r,s,i,u,f,o)),l[u*(c+1)+c]=_}for(let u=0,g=c;u<g;u++){let f=c-1,p=4*(f*c+u),_=h*this.rgb2Height(e[p],e[p+1],e[p+2]);(Me.checkNoDataValue(t,_)||_===0)&&i&&(_=$e(n,r,s,i,f,u,o)),l[c*(c+1)+u]=_}let d=h*this.rgb2Height(e[e.length-4],e[e.length-3],e[e.length-2]);(Me.checkNoDataValue(t,d)||d===0)&&i&&(d=$e(n,r,s,i,c-1,c-1,o)),l[l.length-1]=d}extractElevationTilesRgbNonPowerOfTwo(e,t,i=1){for(let r=0,s=t.length;r<s;r++){let n=4*r;t[r]=i*this.rgb2Height(e[n],e[n+1],e[n+2])}}extractElevationTilesRgb(e,t,i,r=null,s,n,o,l,h,c,d,u,g){let f=Math.sqrt(u.length)-1,p=f+1,_=Math.sqrt(e.length/4),v=_/f,x=0,y=0,w=0,[b,E,C]=_s(l,h,c,s,n,o);for(let T=0,L=0,M=e.length/4;T<M;T++){let R=4*T,z=t*this.rgb2Height(e[R],e[R+1],e[R+2]),F=Me.checkNoDataValue(i,z),P=!1,D=!1,k=Math.floor(T/_),I=T%_;(F||z===0)&&r&&(z=$e(C,b,E,r,Math.floor(k/v),Math.floor(I/v),d));let B=Math.floor(I/f),G=Math.floor(k/f),Ve=g[G][B],ve=k%f,ze=I%f,Re=(ve+G)*p+ze+B;if(Ve[Re]=z,(k+G)%v==0&&(I+B)%v==0&&(u[L++]=z),(I+1)%f==0&&I!==_-1){x=t*this.rgb2Height(e[R+4],e[R+5],e[R+6]),P=Me.checkNoDataValue(i,x),(P||x===0)&&r&&(x=$e(C,b,E,r,Math.floor(k/v),Math.floor((I+1)/v),d));let ie=z;F||P||(ie=.5*(z+x)),Re=(ve+G)*p+ze+1,Ve[Re]=ie,(k+G)%v==0&&(u[L++]=ie);let Ue=(ve+G)*p+(ze+1)%f;g[G][B+1][Ue]=ie}if((k+1)%f==0&&k!==_-1){w=4*_,y=t*this.rgb2Height(e[R+w],e[R+w+1],e[R+w+2]),D=Me.checkNoDataValue(i,y),(D||y===0)&&r&&(y=$e(C,b,E,r,Math.floor((k+1)/v),Math.floor(I/v),d));let ie=.5*(z+y);F||D||(ie=.5*(z+y)),Re=(ve+1)*p+ze+B,Ve[Re]=ie,(I+B)%v==0&&(u[L++]=ie);let Ue=(ve+1)%f*p+ze+B;g[G+1][B][Ue]=ie}if((I+1)%f==0&&I!==_-1&&(k+1)%f==0&&k!==_-1){let ie=t*this.rgb2Height(e[R+w+4],e[R+w+5],e[R+w+6]),Ue=Me.checkNoDataValue(i,ie);(Ue||ie===0)&&r&&(ie=$e(C,b,E,r,Math.floor((k+1)/v),Math.floor((I+1)/v),d));let De=z;F||P||D||Ue||(De=.25*(z+x+y+ie)),Re=(ve+1)*p+(ze+1),Ve[Re]=De,u[L++]=De;let Ei=(ve+1)*p;g[G][B+1][Ei]=De;let Ai=f;g[G+1][B][Ai]=De;let Li=0;g[G+1][B+1][Li]=De}}}extractElevationTilesRgbNoChildren(e,t,i,r=null,s,n,o,l,h,c,d,u){let g=Math.sqrt(u.length)-1,f=g+1,p=Math.sqrt(e.length/4),_=p/g,v=0,x=0,y=0,[w,b,E]=_s(l,h,c,s,n,o);for(let C=0,T=0,L=e.length/4;C<L;C++){let M=4*C,R=t*this.rgb2Height(e[M],e[M+1],e[M+2]),z=Me.checkNoDataValue(i,R),F=!1,P=!1,D=Math.floor(C/p),k=C%p;(z||R===0)&&r&&(R=$e(E,w,b,r,Math.floor(T/f),T%f,d));let I=Math.floor(k/g),B=Math.floor(D/g);if((D+B)%_==0&&(k+I)%_==0&&(u[T++]=R),(k+1)%g==0&&k!==p-1){v=t*this.rgb2Height(e[M+4],e[M+5],e[M+6]),F=Me.checkNoDataValue(i,v),(F||v===0)&&r&&(v=$e(E,w,b,r,Math.floor(T/f),T%f,d));let G=R;z||F||(G=.5*(R+v)),(D+B)%_==0&&(u[T++]=G)}if((D+1)%g==0&&D!==p-1){y=4*p,x=t*this.rgb2Height(e[M+y],e[M+y+1],e[M+y+2]),P=Me.checkNoDataValue(i,x),(P||x===0)&&r&&(x=$e(E,w,b,r,Math.floor(T/f),T%f,d));let G=.5*(R+x);z||P||(G=.5*(R+x)),(k+I)%_==0&&(u[T++]=G)}if((k+1)%g==0&&k!==p-1&&(D+1)%g==0&&D!==p-1){let G=t*this.rgb2Height(e[M+y+4],e[M+y+5],e[M+y+6]),Ve=Me.checkNoDataValue(i,G);(Ve||G===0)&&r&&(G=$e(E,w,b,r,Math.floor(T/f),T%f,d));let ve=R;z||F||P||Ve||(ve=.25*(R+v+x+G)),u[T++]=ve}}}}function _s(a,e,t,i,r,s){let n=2<<t-s-1;return[a-n*i,e-n*r,1/n]}function $e(a,e,t,i,r,s,n){let o=Math.sqrt(i.length),l=i[Math.floor(t*a*o+r*a)*o+Math.floor(e*a*o+s*a)];return n&&l>0?0:l}const Gc={[Tc]:"north",[wt]:"south"},jc=(a,e,t,i)=>{let r=Gc[i];if(r)return`https://terrain.openglobus.org/poles/${r}/${t}/${a}/${e}.png`};class po extends Me{constructor(e,t){super(e||"GlobusEarthRgb",{maxNativeZoom:6,maxZoom:17,url:"https://{s}.terrain.openglobus.org/all/{z}/{x}/{y}.png",urlRewrite:jc,...t})}isReadyToLoad(e){return this._extent.overlaps(e.getExtentLonLat())}}Object.freeze(Object.defineProperty({__proto__:null,BilTerrain:Gt,EmptyTerrain:ds,GlobusRgbTerrain:po,GlobusTerrain:us,RgbTerrain:Me},Symbol.toStringTag,{value:"Module"}));class qc extends hi{constructor(e,t={}){super(e,t),this._sourceTexture=t.texture||null,t.texture&&(this._sourceReady=!0,this._sourceCreated=!0),this._frameWidth=t.frameWidth!=null?St(t.frameWidth):256,this._frameHeight=t.frameHeight!=null?St(t.frameHeight):256,this._animate=!0}get instanceName(){return"GeoTexture2d"}loadMaterial(e){this._planet._geoImageCreator.add(this)}bindTexture(e){this._sourceReady=!0,this._sourceCreated=!0,this._sourceTexture=e}setSize(e,t){this._frameWidth=e,this._frameHeight=t,this._frameCreated=!1}abortMaterialLoading(e){this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}class mo extends hi{constructor(e,t={}){super(e,t),this._animate=!0,this._video=t.videoElement||null,this._src=t.src||null}get instanceName(){return"GeoVideo"}setSrc(e){this._planet&&this._planet._geoImageCreator.remove(this),this._src=e,this._sourceReady=!1}setVideoElement(e){this._planet&&this._planet._geoImageCreator.remove(this),this._video=e,this._src=e.src,this._sourceReady=!1}setVisibility(e){e!=this._visibility&&(super.setVisibility(e),this._planet&&(e?(this._sourceReady&&this._planet._geoImageCreator.add(this),this._video&&this._video.play()):(this._sourceReady&&this._planet._geoImageCreator.remove(this),this._video&&this._video.pause())))}_createSourceTexture(){let e=this._planet.renderer.handler.gl;this._sourceCreated?(e.bindTexture(e.TEXTURE_2D,this._sourceTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._video)):(this._sourceTexture=this._planet.renderer.handler.createTexture_n_webgl1(this._video),this._sourceCreated=!0)}_onCanPlay(e){this._frameWidth=e.videoWidth,this._frameHeight=e.videoHeight,e.width=e.videoWidth,e.height=e.videoHeight,e.play(),this._sourceReady=!0,this._planet._geoImageCreator.add(this)}_onError(e){let t="unknown error";switch(e.error.code){case 1:t="video loading aborted";break;case 2:t="network loading error";break;case 3:t="video decoding failed / corrupted data or unsupported codec";break;case 4:t="video not supported"}console.warn(`Error: ${t} error-code=${e.error.code})`)}loadMaterial(e){if(e.isLoading=!0,this._creationProceeding=!0,!this._sourceReady&&this._src){if(this._video){if(this._video.readyState===this._video.HAVE_ENOUGH_DATA)this._onCanPlay(this._video);else if(this._video.src){let t=this;this._video.addEventListener("canplay",function(i){t._onCanPlay(this)})}}else{this._video=document.createElement("video"),this._video.crossOrigin="Anonymous";let t=this;this._video.addEventListener("canplay",function(){t._onCanPlay(this)}),this._video.addEventListener("error",function(){t._onError(this)})}this._video.autoplay=!0,this._video.loop=!0,this._video.src=this._src,this._video.muted=!0,this._video.setAttribute("playsinline","true"),this._video.setAttribute("webkit-playsinline","true")}else this._planet._geoImageCreator.add(this)}abortMaterialLoading(e){this._video&&(this._video.src=""),this._creationProceeding=!1,e.isLoading=!1,e.isReady=!1}}class Yc extends fe{constructor(e,t={}){super(e,t),this._billboard=t.billboard||{src:"https://openglobus.org/examples/billboards/carrot.png"},this._color=t.color||"#6689db"}get instanceName(){return"KML"}_extractCoordonatesFromKml(e){return Array.from(e.getElementsByTagName("coordinates")).map(t=>t.textContent.trim()).map(t=>t.replace(/\n/g," ").replace(/\t/g," ").replace(/ +/g," ").split(" ").map(i=>i.split(",").map(parseFloat)))}_AGBRtoRGBA(e){if(!e||e.length!=8)return;const t=parseInt(e.slice(0,2),16)/255,i=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return`rgba(${parseInt(e.slice(6,8),16)},${r},${i},${t})`}_parseKMLcoordinates(e){return e.innerHTML.trim().replace(/\n/g," ").replace(/\t/g," ").replace(/ +/g," ").split(" ").map(t=>t.split(",").map(parseFloat))}_kmlPlacemarkToEntity(e,t){if(!e)return;const i=Array.from(e.getElementsByTagName("name")),r=i&&i.length>0?i[0].innerHTML.trim():"",{iconHeading:s,iconURL:n,iconColor:o,lineWidth:l,lineColor:h}=this._extractStyle(e),c=[];for(const d of e.getElementsByTagName("coordinates")){const u=this._parseKMLcoordinates(d)||[[0,0,0]];for(const g of u){const[f,p,_]=g;c.push(new A(f,p,_)),f<t.southWest.lon&&(t.southWest.lon=f),p<t.southWest.lat&&(t.southWest.lat=p),f>t.northEast.lon&&(t.northEast.lon=f),p>t.northEast.lat&&(t.northEast.lat=p)}}if(c.length===1){const d=.01745329*s;return new V({name:r,lonlat:c[0],billboard:{src:n,size:[24,24],color:o,rotation:d},properties:{color:o,heading:s}})}return new V({name:r,polyline:{pathLonLat:[c],thickness:l,color:h,isClosed:!1},properties:{name:r}})}_extractStyle(e){let t,i,r,s,n;const o=e.getElementsByTagName("Style")[0];if(o){let l=o.getElementsByTagName("IconStyle")[0];if(l){let c=l.getElementsByTagName("color")[0];c&&(t=this._AGBRtoRGBA(c.innerHTML.trim()));let d=l.getElementsByTagName("heading")[0];if(d){const g=parseFloat(d.innerHTML.trim());g>=0&&g<=360&&(i=g%360)}let u=l.getElementsByTagName("Icon")[0];if(u){let g=u.getElementsByTagName("href")[0];g&&(r=g.innerHTML.trim())}}let h=o.getElementsByTagName("LineStyle")[0];if(h){let c=h.getElementsByTagName("color")[0];c&&(s=this._AGBRtoRGBA(c.innerHTML.trim()));let d=h.getElementsByTagName("width")[0];d!==void 0&&(n=parseFloat(d.innerHTML.trim()))}}return t||(t="#FFFFFF"),i||(i=0),r||(r="https://openglobus.org/examples/billboards/carrot.png"),s||(s="#FFFFFF"),n||(n=1),{iconHeading:i,iconURL:r,iconColor:t,lineWidth:n,lineColor:s}}_parseKML(e,t,i){if(i||(i=[]),e.documentElement.nodeName!=="kml")return i;for(const r of e.getElementsByTagName("Placemark")){const s=this._kmlPlacemarkToEntity(r,t);s&&i.push(s)}return i}_convertKMLintoEntities(e){const t=new j(new A(180,90),new A(-180,-90));return{entities:this._parseKML(e,t),extent:t}}_convertCoordonatesIntoEntities(e,t,i){const r=new j(new A(180,90),new A(-180,-90)),s=o=>{const l=o[0],h=o[1];l<r.southWest.lon&&(r.southWest.lon=l),h<r.southWest.lat&&(r.southWest.lat=h),l>r.northEast.lon&&(r.northEast.lon=l),h>r.northEast.lat&&(r.northEast.lat=h)},n=[];return e.forEach(o=>o.forEach(l=>n.push(l))),{entities:n.map(o=>{if(o.length===1){const l=o[0],h=new V({lonlat:l,billboard:i});return s(l),h}if(o.length>1){const l=o.map(h=>(s(h),new A(h[0],h[1],h[2])));return new V({polyline:{pathLonLat:[l],thickness:3,color:t,isClosed:!1}})}}),extent:r}}_getXmlContent(e){return new Promise(t=>{const i=new FileReader;i.onload=async r=>t(new DOMParser().parseFromString(r.target.result,"text/xml")),i.readAsText(e)})}_expandExtents(e,t){return e?(t.southWest.lon<e.southWest.lon&&(e.southWest.lon=t.southWest.lon),t.southWest.lat<e.southWest.lat&&(e.southWest.lat=t.southWest.lat),t.northEast.lon>e.northEast.lon&&(e.northEast.lon=t.northEast.lon),t.northEast.lat>e.northEast.lat&&(e.northEast.lat=t.northEast.lat),e):t}async addKmlFromFiles(e,t,i){if(!Array.isArray(e))return null;const r=(await Promise.all(e.map(this._getXmlContent))).map(this._extractCoordonatesFromKml),{entities:s,extent:n}=this._convertCoordonatesIntoEntities(r,t||this._color,i||this._billboard);return this._extent=this._expandExtents(this._extent,n),s.forEach(this.add.bind(this)),{entities:s,extent:n}}setColor(e){this._color=e,this._billboard.color=e}_getKmlFromUrl(e){return new Promise((t,i)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="document",r.overrideMimeType("text/xml"),r.onload=()=>{r.readyState===r.DONE&&r.status===200?t(r.responseXML):i(new Error("no valid kml file"))},r.send()})}async addKmlFromUrl(e,t,i){const r=await this._getKmlFromUrl(e),{entities:s,extent:n}=this._convertKMLintoEntities(r);return this._extent=this._expandExtents(this._extent,n),s.forEach(this.add.bind(this)),{entities:s,extent:n}}}class vo extends xi{constructor(e,t={}){super(e||"OpenStreetMap",{iconSrc:"https://tile.openstreetmap.org/8/138/95.png",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"Data @ OpenStreetMap contributors, ODbL",isBaseLayer:!0,maxNativeZoom:19,defaultTextures:[{color:"#AAD3DF"},{color:"#F2EFE9"}],isSRGB:!1,shininess:18,specular:[63e-5,55e-5,32e-5],ambient:[.2,.2,.3],diffuse:[.9,.9,.7],...t})}}function Wc(a,e,t){var i="";for(let n=t;n>0;n--){var r=0,s=1<<n-1;a&s&&r++,e&s&&(r+=2),i+=r.toString()}return i}class yo extends xi{constructor(e,t={}){super(e||"Bing",{iconSrc:"https://ecn.t0.tiles.virtualearth.net/tiles/a120.jpeg?n=z&g=7146",subdomains:["t0","t1","t2","t3"],url:"https://ecn.{s}.tiles.virtualearth.net/tiles/a{quad}.jpeg?n=z&g=7146",isBaseLayer:!0,textureFilter:"LINEAR",maxNativeZoom:17,defaultTextures:[{color:"#001522"},{color:"#E4E6F3"}],attribution:'<div style="transform: scale(0.8); margin-top:-2px;"><a href="https://www.bing.com" target="_blank"><img style="position: relative; top: 2px;" title="Bing Imagery" src="https://sandcastle.cesium.com/CesiumUnminified/Assets/Images/bing_maps_credit.png"></a> © 2021 Microsoft Corporation</div>',urlRewrite:(i,r)=>Ne(r,{s:this._getSubdomain(),quad:Wc(i.tileX,i.tileY,i.tileZoom)}),specular:[63e-5,55e-5,32e-5],ambient:[.35,.35,.35],diffuse:[1.5,1.5,1.5],shininess:20,nightTextureCoefficient:2.7,...t})}}Object.freeze(Object.defineProperty({__proto__:null,Bing:yo,CanvasTiles:sn,GeoImage:rs,GeoTexture2d:qc,GeoVideo:mo,KML:Yc,LAYER_EVENTS:rn,Layer:Ye,Material:en,OpenStreetMap:vo,Vector:fe,WMS:gt,XYZ:xi},Symbol.toStringTag,{value:"Module"}));const fs=function(a,e){return+(a.priority<e.priority)};class $c{constructor(){this._currentlyPressedKeys={},this._pressedKeysCallbacks={},this._unpressedKeysCallbacks={},this._charkeysCallbacks={},this._anykeyCallback=null,this._event=null,this._active=!0,this._stampCache={},document.onkeydown=e=>{this._event=e,this._active&&this.handleKeyDown()},document.onkeyup=e=>{this._event=e,this._active&&this.handleKeyUp()}}getcurrentlyPressedKeys(){return this._currentlyPressedKeys}getPressedKeysCallbacks(){return this._pressedKeysCallbacks}getUnpressedKeysCallbacks(){return this._unpressedKeysCallbacks}getCharkeysCallbacks(){return this._charkeysCallbacks}removeEvent(e,t,i){let r=this._getStamp(e,t,i._openglobus_id);i._openglobus_id&&this._stampCache[r]&&(delete this._stampCache[r],e==="keypress"?this._removeCallback(this._pressedKeysCallbacks[t],i):e==="keyfree"?this._removeCallback(this._unpressedKeysCallbacks[t],i):e==="charkeypress"&&this._removeCallback(this._charkeysCallbacks[t],i))}_removeCallback(e,t){for(let i=0;i<e.length;i++)e[i].callback._openglobus_id===t._openglobus_id&&e.splice(i,1)}_getStamp(e,t,i){return`${e}_${t}_${i}`}_stamp(e,t,i){const r=dr(i),s=this._getStamp(e,t,r);return!this._stampCache[s]&&(this._stampCache[s]=r,!0)}setActivity(e){this._active=e}releaseKeys(){this._currentlyPressedKeys={}}addEvent(e,t,i,r,s){if(this._stamp(e,t,i))switch(s===void 0&&(s=1600),e){case"keyfree":this._unpressedKeysCallbacks[t]||(this._unpressedKeysCallbacks[t]=[]),this._unpressedKeysCallbacks[t].push({callback:i,sender:r,priority:s}),this._unpressedKeysCallbacks[t].sort(fs);break;case"keypress":t==null?this._anykeyCallback={callback:i,sender:r||this}:(this._pressedKeysCallbacks[t]||(this._pressedKeysCallbacks[t]=[]),this._pressedKeysCallbacks[t].push({callback:i,sender:r,priority:s}),this._pressedKeysCallbacks[t].sort(fs));break;case"charkeypress":this._charkeysCallbacks[t]||(this._charkeysCallbacks[t]=[]),this._charkeysCallbacks[t].push({callback:i,sender:r,priority:s}),this._charkeysCallbacks[t].sort(fs)}}isKeyPressed(e){return this._currentlyPressedKeys[e]}handleKeyDown(){this._anykeyCallback&&this._anykeyCallback.callback.call(this._anykeyCallback.sender,this._event),this._currentlyPressedKeys[this._event.keyCode]=!0;for(let e in this._charkeysCallbacks)if(String.fromCharCode(this._event.keyCode)===String.fromCharCode(Number(e))){let t=this._charkeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}this._event.keyCode!=W.KEY_ALT&&this._event.keyCode!=W.KEY_SHIFT||this._event.preventDefault()}handleKeyUp(){if(this._currentlyPressedKeys[this._event.keyCode]||this._event.keyCode===W.KEY_PRINTSCREEN){for(let e in this._unpressedKeysCallbacks)if(this._currentlyPressedKeys[e]||this._event.keyCode===W.KEY_PRINTSCREEN&&Number(e)===W.KEY_PRINTSCREEN){let t=this._unpressedKeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}}this._currentlyPressedKeys[this._event.keyCode]=!1}handleEvents(){for(let e in this._pressedKeysCallbacks)if(this._currentlyPressedKeys[e]){let t=this._pressedKeysCallbacks[e];for(let i=0;i<t.length;i++)t[i].callback.call(t[i].sender,this._event)}}}class Xc{constructor(e){this._htmlObject=e}setEvent(e,t,i){switch(e){case"mousewheel":this._htmlObject.addEventListener("wheel",r=>{let s=r.deltaY||r.detail||r.wheelDelta||0;var n;r.wheelDelta==null&&(r.wheelDelta=-120*s),r.isTouchPad=(n=r).deltaMode===0&&Math.abs(n.deltaY)<50,i.call(t,r),r.preventDefault()},!1);break;case"mousedown":this._htmlObject.addEventListener("mousedown",function(r){let s=this.getBoundingClientRect();i.call(t,r,{button:r.button,clientX:r.clientX-s.left,clientY:r.clientY-s.top})}),this._htmlObject.addEventListener("contextmenu",function(r){return r.preventDefault(),!1});break;case"mouseup":this._htmlObject.addEventListener("mouseup",function(r){let s=this.getBoundingClientRect();i.call(t,r,{button:r.button,clientX:r.clientX-s.left,clientY:r.clientY-s.top})});break;case"mousemove":this._htmlObject.addEventListener("mousemove",function(r){let s=this.getBoundingClientRect();i.call(t,r,{clientX:r.clientX-s.left,clientY:r.clientY-s.top})});break;case"mouseleave":this._htmlObject.addEventListener("mouseleave",function(r){i.call(t,r)});break;case"mouseout":this._htmlObject.addEventListener("mouseout",function(r){i.call(t,r)});break;case"mouseover":this._htmlObject.addEventListener("mouseover",function(r){i.call(t,r)});break;case"mouseenter":this._htmlObject.addEventListener("mouseenter",function(r){i.call(t,r)})}}}class Zc{constructor(e){this._htmlObject=e}setEvent(e,t,i){switch(e){case"touchcancel":this._htmlObject.addEventListener("touchcancel",function(r){r.preventDefault();const s=this.getBoundingClientRect(),n=Object.assign(r,{offsetLeft:s.left,offsetTop:s.top});i.call(t,n)});break;case"touchstart":this._htmlObject.addEventListener("touchstart",function(r){r.preventDefault();const s=this.getBoundingClientRect(),n=Object.assign(r,{offsetLeft:s.left,offsetTop:s.top});i.call(t,n)});break;case"touchend":this._htmlObject.addEventListener("touchend",function(r){r.preventDefault();const s=this.getBoundingClientRect(),n=Object.assign(r,{offsetLeft:s.left,offsetTop:s.top});i.call(t,n)});break;case"touchmove":this._htmlObject.addEventListener("touchmove",function(r){r.preventDefault();const s=this.getBoundingClientRect(),n=Object.assign(r,{offsetLeft:s.left,offsetTop:s.top});i.call(t,n)})}}}let pt=new Uint8Array(4),bi=new Uint8Array(4),wi=new Uint8Array(4);class Qc extends Sr{constructor(e){super(Kc),this.renderer=e,this._touchHandler=new Zc(e.handler.canvas),this._mouseHandler=new Xc(e.handler.canvas),this._keyboardHandler=new $c,this._active=!0,this.clickRadius=15,this.mouseState={clientX:0,clientY:0,pos:new N,x:0,y:0,nx:0,ny:0,prev_x:0,prev_y:0,direction:new m,leftButtonUp:!1,rightButtonUp:!1,middleButtonUp:!1,leftButtonDown:!1,rightButtonDown:!1,middleButtonDown:!1,leftButtonHold:!1,rightButtonHold:!1,middleButtonHold:!1,leftButtonDoubleClick:!1,rightButtonDoubleClick:!1,middleButtonDoubleClick:!1,leftButtonClick:!1,rightButtonClick:!1,middleButtonClick:!1,moving:!1,justStopped:!1,doubleClickDelay:500,clickDelay:200,wheelDelta:0,sys:null,pickingObject:null,renderer:e,isTouchPad:!1},this.touchState={touching:!1,moving:!1,touchEnd:!1,touchStart:!1,touchCancel:!1,doubleTouch:!1,doubleTouchDelay:550,doubleTouchRadius:10,clientX:0,clientY:0,pos:new N,x:0,y:0,nx:0,ny:0,prev_x:0,prev_y:0,direction:new m,sys:null,pickingObject:null,renderer:e},this._isMouseInside=!0,this._entityPickingEventsActive=!0,this._dblTchCoords=new N,this._oneTouchStart=!1,this._dblTchBegins=0,this._mousestopThread=null,this._ldblClkBegins=0,this._rdblClkBegins=0,this._mdblClkBegins=0,this._lClkBegins=0,this._rClkBegins=0,this._mClkBegins=0,this._lclickX=0,this._lclickY=0,this._rclickX=0,this._rclickY=0,this._mclickX=0,this._mclickY=0}pointerEvent(){let e=this.mouseState,t=this.touchState;return e.moving||e.justStopped||t.moving||t.touchStart||t.touchEnd||e.wheelDelta!==0}get active(){return this._active}set active(e){this._active=e,this._keyboardHandler.setActivity(e)}handleEvents(){this._active&&(this.mouseState.direction=this.renderer.activeCamera.unproject(this.mouseState.x,this.mouseState.y),this.touchState.direction=this.renderer.activeCamera.unproject(this.touchState.x,this.touchState.y),this._keyboardHandler.handleEvents(),this.handleMouseEvents(),this.handleTouchEvents(),this.entityPickingEvents())}on(e,t,i,r,s){e==="keypress"||e==="charkeypress"||e==="keyfree"?this._keyboardHandler.addEvent(e,t,i,r,s):super.on(e,t,i,r)}off(e,t,i){e==="keypress"||e==="charkeypress"||e==="keyfree"?this._keyboardHandler.removeEvent(e,t,i):super.off(e,t)}isKeyPressed(e){return this._keyboardHandler.isKeyPressed(e)}releaseKeys(){this._keyboardHandler.releaseKeys()}initialize(){this._mouseHandler.setEvent("mouseup",this,this.onMouseUp),this._mouseHandler.setEvent("mousemove",this,this.onMouseMove),this._mouseHandler.setEvent("mousedown",this,this.onMouseDown),this._mouseHandler.setEvent("mousewheel",this,this.onMouseWheel),this._mouseHandler.setEvent("mouseleave",this,this.onMouseLeave),this._mouseHandler.setEvent("mouseenter",this,this.onMouseEnter),this._touchHandler.setEvent("touchstart",this,this.onTouchStart),this._touchHandler.setEvent("touchend",this,this.onTouchEnd),this._touchHandler.setEvent("touchcancel",this,this.onTouchCancel),this._touchHandler.setEvent("touchmove",this,this.onTouchMove)}onMouseWheel(e){this.mouseState.isTouchPad=e.isTouchPad||!1,this.mouseState.sys=e,this.mouseState.wheelDelta=e.wheelDelta||0}updateButtonsStates(e){let t=this.mouseState;1&e&&t.leftButtonDown?t.leftButtonDown=!0:(t.leftButtonHold=!1,t.leftButtonDown=!1),2&e&&t.rightButtonDown?t.rightButtonDown=!0:(t.rightButtonHold=!1,t.rightButtonDown=!1),4&e&&t.middleButtonDown?t.middleButtonDown=!0:(t.middleButtonHold=!1,t.middleButtonDown=!1)}onMouseMove(e,t){let i=this.mouseState;this.updateButtonsStates(e.buttons),i.sys=e;let r=t.clientX,s=t.clientY,n=this.clickRadius;if(Math.abs(this._lclickX-r)>=n&&Math.abs(this._lclickY-s)>=n&&(this._ldblClkBegins=0,this._lClkBegins=0),Math.abs(this._rclickX-r)>=n&&Math.abs(this._rclickY-s)>=n&&(this._rdblClkBegins=0,this._rClkBegins=0),Math.abs(this._mclickX-r)>=n&&Math.abs(this._mclickY-s)>=n&&(this._mdblClkBegins=0,this._mClkBegins=0),i.clientX===t.clientX&&i.clientY===t.clientY)return;i.clientX=t.clientX,i.clientY=t.clientY;let o=this.renderer.handler;i.pos.x=i.x=t.clientX*o.pixelRatio,i.pos.y=i.y=t.clientY*o.pixelRatio,i.nx=i.x/o.canvas.width,i.ny=i.y/o.canvas.height,i.moving=!0,clearTimeout(this._mousestopThread),this._mousestopThread=setTimeout(function(){i.justStopped=!0},100)}onMouseLeave(e){this._isMouseInside=!1,this.mouseState.sys=e,this.dispatch(this.mouseleave,this.mouseState)}onMouseEnter(e){this._isMouseInside=!0,this.mouseState.sys=e,this.dispatch(this.mouseenter,this.mouseState)}onMouseDown(e,t){t.button===W.MB_LEFT?(this._lClkBegins=window.performance.now(),this._lclickX=t.clientX,this._lclickY=t.clientY,this.mouseState.sys=e,this.mouseState.leftButtonDown=!0):t.button===W.MB_RIGHT?(this._rClkBegins=window.performance.now(),this._rclickX=t.clientX,this._rclickY=t.clientY,this.mouseState.sys=e,this.mouseState.rightButtonDown=!0):t.button===W.MB_MIDDLE&&(this._mClkBegins=window.performance.now(),this._mclickX=t.clientX,this._mclickY=t.clientY,this.mouseState.sys=e,this.mouseState.middleButtonDown=!0)}onMouseUp(e,t){let i=this.mouseState;i.sys=e;let r=window.performance.now();t.button===W.MB_LEFT?(i.leftButtonDown=!1,i.leftButtonUp=!0,Math.abs(this._lclickX-t.clientX)<this.clickRadius&&Math.abs(this._lclickY-t.clientY)<this.clickRadius&&r-this._lClkBegins<=i.clickDelay&&(this._ldblClkBegins?(window.performance.now()-this._ldblClkBegins<=i.doubleClickDelay&&(i.leftButtonDoubleClick=!0),this._ldblClkBegins=0):this._ldblClkBegins=window.performance.now(),i.leftButtonClick=!0,this._lClkBegins=0)):t.button===W.MB_RIGHT?(i.rightButtonDown=!1,i.rightButtonUp=!0,Math.abs(this._rclickX-t.clientX)<this.clickRadius&&Math.abs(this._rclickY-t.clientY)<this.clickRadius&&r-this._rClkBegins<=i.clickDelay&&(this._rdblClkBegins?(window.performance.now()-this._rdblClkBegins<=i.doubleClickDelay&&(i.rightButtonDoubleClick=!0),this._rdblClkBegins=0):this._rdblClkBegins=window.performance.now(),i.rightButtonClick=!0,this._rClkBegins=0)):t.button===W.MB_MIDDLE&&(i.middleButtonDown=!1,i.middleButtonUp=!0,Math.abs(this._mclickX-t.clientX)<this.clickRadius&&Math.abs(this._mclickY-t.clientY)<this.clickRadius&&r-this._mClkBegins<=i.clickDelay)&&(this._mdblClkBegins?(window.performance.now()-this._mdblClkBegins<=i.doubleClickDelay&&(i.middleButtonDoubleClick=!0),this._mdblClkBegins=0):this._mdblClkBegins=window.performance.now(),i.middleButtonClick=!0,this._mClkBegins=0)}onTouchStart(e){let t=this.touchState;t.sys=e,t.clientX=e.touches.item(0).clientX-e.offsetLeft,t.clientY=e.touches.item(0).clientY-e.offsetTop;let i=this.renderer.handler;t.pos.x=t.x=t.clientX*i.pixelRatio,t.pos.y=t.y=t.clientY*i.pixelRatio,t.nx=t.x/i.canvas.width,t.ny=t.y/i.canvas.height,t.prev_x=t.x,t.prev_y=t.y,t.touchStart=!0,t.touching=!0,e.touches.length===1?(this._dblTchCoords.x=t.x,this._dblTchCoords.y=t.y,this._oneTouchStart=!0):this._oneTouchStart=!1}onTouchEnd(e){let t=this.touchState;t.sys=e,t.touchEnd=!0,e.touches.length===0&&(t.prev_x=t.x,t.prev_y=t.y,this._oneTouchStart)&&(this._dblTchBegins&&(window.performance.now()-this._dblTchBegins<=t.doubleTouchDelay&&(t.doubleTouch=!0),this._dblTchBegins=0),this._dblTchBegins=window.performance.now(),this._oneTouchStart=!1)}onTouchCancel(e){let t=this.touchState;t.sys=e,t.touchCancel=!0}onTouchMove(e){let t=this.touchState;t.clientX=e.touches.item(0).clientX-e.offsetLeft,t.clientY=e.touches.item(0).clientY-e.offsetTop;let i=this.renderer.handler;t.x=t.clientX*i.pixelRatio,t.y=t.clientY*i.pixelRatio,t.nx=t.x/i.canvas.width,t.ny=t.y/i.canvas.height,t.sys=e,t.moving=!0;let r=t.x-t.prev_x,s=t.y-t.prev_y;(Math.abs(r)>9||Math.abs(s)>9)&&(this._dblTchBegins=0,this._oneTouchStart=!1)}entityPickingEvents(){let e=this.touchState,t=this.mouseState;if(this._isMouseInside!==this._entityPickingEventsActive&&(this._entityPickingEventsActive=this._isMouseInside,!this._entityPickingEventsActive)){let r=this.renderer,s=pt,n=r.getPickingObjectArr(s);if(n){let o=n.rendererEvents;t.pickingObject=n,o&&o.dispatch(o.mouseleave,t),e.pickingObject=n,o&&o.dispatch(o.touchleave,e)}pt[0]=pt[1]=pt[2]=pt[3]=wi[0]=wi[1]=wi[2]=wi[3]=bi[0]=bi[1]=bi[2]=bi[3]=0}if(this._isMouseInside&&!(t.leftButtonHold||t.rightButtonHold||t.middleButtonHold)){let r=this.renderer,s=pt,n=wi,o=bi;e.x||e.y?r.readPickingColor(e.nx,1-e.ny,o):r.readPickingColor(t.nx,1-t.ny,o),n[0]=s[0],n[1]=s[1],n[2]=s[2],s[0]=o[0],s[1]=o[1],s[2]=o[2],t.pickingObject=null,e.pickingObject=null;let l=r.getPickingObjectArr(s);if(t.pickingObject=l,e.pickingObject=l,s[0]!==n[0]||s[1]!==n[1]||s[2]!==n[2])if((i=s)[0]||i[1]||i[2]){if((h=>!!(h[0]||h[1]||h[2]))(n)){let h=r.getPickingObjectArr(n);if(h){let c=h.rendererEvents;t.pickingObject=h,c&&c.dispatch(c.mouseleave,t),e.pickingObject=h,c&&c.dispatch(c.touchleave,e)}}if(l){let h=l.rendererEvents;t.pickingObject=l,h&&h.dispatch(h.mouseenter,t),e.pickingObject=l,h&&h.dispatch(h.touchenter,e)}}else{let h=r.getPickingObjectArr(n);if(h){let c=h.rendererEvents;t.pickingObject=h,c&&c.dispatch(c.mouseleave,t),e.pickingObject=h,c&&c.dispatch(c.touchleave,e)}}}var i}handleMouseEvents(){let e=this,t=this.mouseState,i=t.pickingObject,r=null;t.leftButtonClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.lclick,t)),this.dispatch(e.lclick,t),t.leftButtonClick=!1),t.rightButtonClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.rclick,t)),this.dispatch(e.rclick,t),t.rightButtonClick=!1),t.middleButtonClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.mclick,t)),this.dispatch(e.mclick,t),t.middleButtonClick=!1),t.leftButtonDown&&(t.leftButtonHold?(i&&(r=i.rendererEvents,r&&r.dispatch(r.lhold,t)),this.dispatch(e.lhold,t)):(t.leftButtonHold=!0,i&&(r=i.rendererEvents,r&&r.dispatch(r.ldown,t)),this.dispatch(e.ldown,t))),t.rightButtonDown&&(t.rightButtonHold?(i&&(r=i.rendererEvents,r&&r.dispatch(r.rhold,t)),this.dispatch(e.rhold,t)):(t.rightButtonHold=!0,i&&(r=i.rendererEvents,r&&r.dispatch(r.rdown,t)),this.dispatch(e.rdown,t))),t.middleButtonDown&&(t.middleButtonHold?(i&&(r=i.rendererEvents,r&&r.dispatch(r.mhold,t)),this.dispatch(e.mhold,t)):(t.middleButtonHold=!0,i&&(r=i.rendererEvents,r&&r.dispatch(r.mdown,t)),this.dispatch(e.mdown,t))),t.leftButtonUp&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.lup,t)),this.dispatch(e.lup,t),t.leftButtonUp=!1,t.leftButtonHold=!1),t.rightButtonUp&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.rup,t)),this.dispatch(e.rup,t),t.rightButtonUp=!1,t.rightButtonHold=!1),t.middleButtonUp&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.mup,t)),this.dispatch(e.mup,t),t.middleButtonUp=!1,t.middleButtonHold=!1),t.leftButtonDoubleClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.ldblclick,t)),this.dispatch(e.ldblclick,t),t.leftButtonDoubleClick=!1),t.rightButtonDoubleClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.rdblclick,t)),this.dispatch(e.rdblclick,t),t.rightButtonDoubleClick=!1),t.middleButtonDoubleClick&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.mdblclick,t)),this.dispatch(e.mdblclick,t),t.middleButtonDoubleClick=!1),t.wheelDelta&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.mousewheel,t)),this.dispatch(e.mousewheel,t)),t.moving&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.mousemove,t)),this.dispatch(e.mousemove,t),t.prev_x=t.x,t.prev_y=t.y),t.justStopped&&this.dispatch(e.mousestop,t)}handleTouchEvents(){let e=this,t=this.touchState,i=t.pickingObject,r=null;if(t.touchCancel&&(this.dispatch(e.touchcancel,t),t.touchCancel=!1),t.touchStart){let s=this.renderer;s.readPickingColor(t.nx,1-t.ny,pt);let n=s.getPickingObjectArr(pt);i=t.pickingObject=n,i&&(r=i.rendererEvents,r&&r.dispatch(r.touchstart,t)),this.dispatch(e.touchstart,t),t.touchStart=!1}t.doubleTouch&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.doubletouch,t)),this.dispatch(e.doubletouch,t),t.doubleTouch=!1),t.touchEnd&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.touchend,t)),this.dispatch(e.touchend,t),t.x=0,t.y=0,t.touchEnd=!1,t.touching=!1),t.moving&&(i&&(r=i.rendererEvents,r&&r.dispatch(r.touchmove,t)),this.dispatch(e.touchmove,t),t.prev_x=t.x,t.prev_y=t.y)}}const Kc=["projchanged","changerelativecenter","draw","drawtransparent","postdraw","resize","resizeend","mouseenter","mouseleave","mousemove","mousestop","lclick","rclick","mclick","ldblclick","rdblclick","mdblclick","lup","rup","mup","ldown","rdown","mdown","lhold","rhold","mhold","mousewheel","touchstart","touchend","touchcancel","touchmove","doubletouch","touchleave","touchenter"];class Ci{constructor(e=0,t=0,i=0,r=0){this.left=e,this.right=i,this.top=t,this.bottom=r}set(e=0,t=0,i=0,r=0){this.left=e,this.right=i,this.top=t,this.bottom=r}clone(){return new Ci(this.left,this.top,this.right,this.bottom)}getWidth(){return Math.abs(this.right-this.left)}getHeight(){return Math.abs(this.bottom-this.top)}getSquare(){return this.getHeight()*this.getWidth()}getDiagonal(){let e=this.getWidth(),t=this.getHeight();return Math.sqrt(t*t+e*e)}fit(e,t){return this.getWidth()===e&&this.getHeight()===t}isInside(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}}class Jc{constructor(){this.imagesCache={},this._counter=0,this._pendingsQueue=new hs,this._imageIndexCounter=0}load(e,t){if(this.imagesCache[e])t(this.imagesCache[e]);else{let i={src:e,success:t};this._counter>=1?this._pendingsQueue.unshift(i):this._exec(i)}}_exec(e){this._counter++;const t=this;let i=new Image;i.crossOrigin="",i.onload=function(){t.imagesCache[e.src]=i,i.__nodeIndex=t._imageIndexCounter++,e.success(i),t._dequeueRequest()},i.onerror=function(){t._dequeueRequest()},i.src=e.src}_dequeueRequest(){if(this._counter--,this._pendingsQueue.length&&this._counter<1)for(;this._pendingsQueue.length;){let e=this._pendingsQueue.pop();if(e){if(!this.imagesCache[e.src]){this._exec(e);break}this._counter<=0?this._counter=0:this._counter--,e.success(this.imagesCache[e.src])}}}}class gs{constructor(e=1024,t=1024){this.nodes=new Map,this.texture=null,this.canvas=new _i(e,t),this.clearCanvas(),this._handler=null,this._images=[],this._btree=null,this._imagesCacheManager=new Jc,this.borderSize=4}getImage(){return this.canvas.getImage()}getCanvas(){return this.canvas.getCanvas()}clearCanvas(){this.canvas.fillEmpty()}assignHandler(e){this._handler=e,this.createTexture()}getDiagonal(e){let t=e.atlasWidth||e.width,i=e.atlasHeight||e.height;return Math.sqrt(t*t+i*i)}addImage(e,t=!1){if(e.width&&e.height)return this._images.push(e),this._makeAtlas(t),e.__nodeIndex!=null?this.get(e.__nodeIndex):void 0}_completeNode(e,t){if(t){let i=this.canvas.getWidth(),r=this.canvas.getHeight(),s=t.image,n=t.rect,o=Math.round(.5*this.borderSize);this.canvas.drawImage(s,n.left+o,n.top+o,s.atlasWidth||0,s.atlasHeight||0);let l=t.texCoords;l[0]=(n.left+o)/i,l[1]=(n.top+o)/r,l[2]=(n.left+o)/i,l[3]=(n.bottom-o)/r,l[4]=(n.right-o)/i,l[5]=(n.bottom-o)/r,l[6]=(n.right-o)/i,l[7]=(n.bottom-o)/r,l[8]=(n.right-o)/i,l[9]=(n.top+o)/r,l[10]=(n.left+o)/i,l[11]=(n.top+o)/r,e.set(s.__nodeIndex,t)}}_makeAtlas(e=!1){if(e&&this._btree){let t=this._images[this._images.length-1];this._completeNode(this.nodes,this._btree.insert(t))}else{let t=this._images.slice(0);t.sort(function(r,s){return(s.atlasWidth||s.width)-(r.atlasWidth||r.width)||(s.atlasHeight||s.height)-(r.atlasHeight||r.height)}),this._btree=new Ti(new Ci(0,0,this.canvas.getWidth(),this.canvas.getHeight())),this._btree.atlas=this,this.clearCanvas();let i=new Map;for(let r=0;r<t.length;r++)this._completeNode(i,this._btree.insert(t[r]));this.nodes=null,this.nodes=i}}get(e){return this.nodes.get(e)}set(e,t){this.nodes.set(e,t)}createTexture(e,t){this._handler&&(this._handler.gl.deleteTexture(this.texture),e&&(this.canvas.resize(e.width,e.height),this.canvas.drawImage(e,0,0,e.width,e.height)),this.texture=this._handler.createTexture_l(this.canvas.getCanvas(),t))}loadImage(e,t){this._imagesCacheManager.load(e,t)}getImageTexCoordinates(e){if(e.__nodeIndex!=null){let t=this.get(e.__nodeIndex);if(t)return t.texCoords}}}class Ti{constructor(e,t){this.childNodes=null,this.image=null,this.rect=e||new Ci,this.texCoords=t||[],this.atlas=null}insert(e){if(this.childNodes)return this.childNodes[0].insert(e)||this.childNodes[1].insert(e);{if(this.image!=null)return;let t=this.rect;const i=(e.atlasWidth||e.width)+this.atlas.borderSize,r=(e.atlasHeight||e.height)+this.atlas.borderSize;return i>t.getWidth()||r>t.getHeight()?void 0:t.fit(i,r)?(this.image=e,this):(this.childNodes=new Array(2),this.childNodes[0]=new Ti,this.childNodes[0].atlas=this.atlas,this.childNodes[1]=new Ti,this.childNodes[1].atlas=this.atlas,t.getWidth()-i>t.getHeight()-r?(this.childNodes[0].rect.set(t.left,t.top,t.left+i,t.bottom),this.childNodes[1].rect.set(t.left+i,t.top,t.right,t.bottom)):(this.childNodes[0].rect.set(t.left,t.top,t.right,t.top+r),this.childNodes[1].rect.set(t.left,t.top+r,t.right,t.bottom)),this.childNodes[0].insert(e))}}}class xo extends gs{constructor(e,t){super(e,t),this.width=0,this.height=0,this.gliphSize=0,this.distanceRange=0,this.nodes=new Map,this.kernings={}}get(e){return this.nodes.get(e)}}class ed extends Ti{constructor(e,t){super(e,t),this.emptySize=1,this.metrics={id:0,char:"",width:0,height:0,x:0,y:0,chnl:0,index:0,page:0,xadvance:0,xoffset:0,yoffset:0,nChar:"",nCode:0,nWidth:0,nHeight:0,nAdvance:0,nXOffset:0,nYOffset:0}}}class td{constructor(e){this.atlasesArr=[],this.atlasIndexes={},this.atlasIndexesDeferred={},this.tokenImageSize=64,this.samplerArr=new Uint32Array(11),this.sdfParamsArr=new Float32Array(44),this._handler=null,this.catalogSrc=e||"./"}assignHandler(e){this._handler=e}getFontIndex(e){let t=this.getFullIndex(e);return this.atlasIndexes[t]||this.loadFont(e,this.catalogSrc,`${e}.json`),this.atlasIndexesDeferred[t]||(this.atlasIndexesDeferred[t]=new di),this.atlasIndexesDeferred[t].promise}getFullIndex(e){return e.trim().toLowerCase()}_applyFontDataToAtlas(e,t,i=0){let r=t.chars;e.height=t.common.scaleH,e.width=t.common.scaleW,e.gliphSize=t.info.size,e.distanceRange=t.distanceField.distanceRange;let s=e.width,n=e.height,o=e.gliphSize;this.sdfParamsArr[4*i]=s,this.sdfParamsArr[4*i+1]=n,this.sdfParamsArr[4*i+2]=o,this.sdfParamsArr[4*i+3]=e.distanceRange;let l={};for(let h=0;h<r.length;h++){let c=r[h],d=c.char;l[c.id]=d;let u=new Ci(c.x,c.y,c.x+c.width,c.y+c.height),g=new Array(12);g[0]=u.left/s,g[1]=u.top/n,g[2]=u.left/s,g[3]=u.bottom/n,g[4]=u.right/s,g[5]=u.bottom/n,g[6]=u.right/s,g[7]=u.bottom/n,g[8]=u.right/s,g[9]=u.top/n,g[10]=u.left/s,g[11]=u.top/n;let f=new ed(u,g),p=c.char.normalize("NFKC"),_=p.charCodeAt(0),v=f.metrics;v.id=c.id,v.char=c.char,v.width=c.width,v.height=c.height,v.x=c.x,v.y=c.y,v.chnl=c.chnl,v.index=c.index,v.page=c.page,v.xadvance=c.xadvance,v.xoffset=c.xoffset,v.yoffset=c.yoffset,v.nChar=p,v.nCode=_,v.nWidth=f.metrics.width/o,v.nHeight=f.metrics.height/o,v.nAdvance=f.metrics.xadvance/o,v.nXOffset=f.metrics.xoffset/o,v.nYOffset=1-f.metrics.yoffset/o,f.emptySize=1,e.nodes.set(p.charCodeAt(0),f)}e.kernings={};for(let h=0;h<t.kernings.length;h++){let c=t.kernings[h],d=c.first,u=c.second;e.kernings[d]||(e.kernings[d]={}),e.kernings[d][u]=c.amount/o}}initFont(e,t,i){let r=this.atlasesArr.length,s=this.getFullIndex(e);this.atlasIndexes[s]=r;let n=this.atlasIndexesDeferred[s];n||(n=this.atlasIndexesDeferred[s]=new di),this.samplerArr[this.atlasesArr.length]=r;let o=new xo;o.height=0,o.width=0,o.gliphSize=0,o.distanceRange=0,o.kernings={},o.assignHandler(this._handler),this.atlasesArr[r]=o,this._applyFontDataToAtlas(o,t,r);let l=new Image;l.onload=()=>{this._createTexture(o,l),n.resolve(r)},l.src=i}_createTexture(e,t){e.createTexture(t)}loadFont(e,t,i){let r=this.atlasesArr.length,s=this.getFullIndex(e);this.atlasIndexes[s]=r;let n=this.atlasIndexesDeferred[s];n||(n=this.atlasIndexesDeferred[s]=new di),this.samplerArr[this.atlasesArr.length]=r;let o=new xo;o.height=0,o.width=0,o.gliphSize=0,o.distanceRange=0,o.kernings={},o.assignHandler(this._handler),this.atlasesArr[r]=o,fetch(`${t}/${i}`).then(l=>{if(!l.ok)throw Error(`Unable to load "${t}/${i}"`);return l.json()}).then(l=>{this._applyFontDataToAtlas(o,l,r);let h=new Image;h.onload=()=>{this._createTexture(o,h),n.resolve(r)},h.src=`${t}/${l.pages[0]}`,h.crossOrigin="Anonymous"}).catch(l=>(n.reject(),{status:"error",msg:l.toString()}))}}let id=0,rd=0,jt=new Float32Array(2);class sd{constructor(e,t={}){var i,r;if(this.div=null,this.handler=e instanceof bt?e:new bt(e,{pixelRatio:t.dpi||window.devicePixelRatio+.15,autoActivate:!0}),this.exposure=t.exposure||3.01,this.gamma=t.gamma||.47,this.whitepoint=1,this.brightThreshold=.9,this._renderNodesArr=[],this.renderNodes={},this.activeCamera=new es({width:(i=this.handler.canvas)==null?void 0:i.width,height:(r=this.handler.canvas)==null?void 0:r.height,eye:new m(0,0,0),look:new m(0,0,-1),up:new m(0,1,0)}),this.events=new Qc(this),this.controls={},t.controls)for(let o in t.controls)this.controls[t.controls[o].name]=t.controls[o];this.controlsBag={},this.colorObjects=new Map,this._pickingCallbacks=[],this.pickingFramebuffer=null,this._depthCallbacks=[],this.depthFramebuffer=null;let s=new URLSearchParams(location.search),n=s.get("og_msaa");this._msaa=n?Number(s.get("og_msaa")):t.msaa!=null?t.msaa:0,this._internalFormat="RGBA16F",this._format="RGBA",this._type="FLOAT",this.sceneFramebuffer=null,this.blitFramebuffer=null,this.toneMappingFramebuffer=null,this._initialized=!1,this.billboardsTextureAtlas=new gs,this.geoObjectsTextureAtlas=new gs,this.fontAtlas=new td(t.fontsSrc),this._entityCollections=[[]],this._currentOutput="screen",this._fnScreenFrame=null,this.labelWorker=new xl(4),this.screenDepthFramebuffer=null,this.screenFramePositionBuffer=null,this.screenTexture={},this.outputTexture=null,this._readPickingBuffer=this._readPickingBuffer_webgl2,(t.autoActivate||Ge(t.autoActivate))&&this.start()}enableBlendOneSrcAlpha(){let e=this.handler.gl;e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}enableBlendDefault(){let e=this.handler.gl;e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE)}setRelativeCenter(e){this.events.dispatch(this.events.changerelativecenter,e||this.activeCamera.eye)}setEventsActivity(e){this.events.active=e}addDepthCallback(e,t){let i=rd++;return this._depthCallbacks.push({id:i,callback:t,sender:e}),i}removeDepthCallback(e){for(let t=0;t<this._depthCallbacks.length;t++)if(e===this._depthCallbacks[t].id){this._depthCallbacks.splice(t,1);break}}addPickingCallback(e,t){let i=id++;return this._pickingCallbacks.push({id:i,callback:t,sender:e}),i}removePickingCallback(e){for(let t=0;t<this._pickingCallbacks.length;t++)if(e===this._pickingCallbacks[t].id){this._pickingCallbacks.splice(t,1);break}}getPickingObject(e,t,i){return this.colorObjects.get(`${e}_${t}_${i}`)}getPickingObjectArr(e){return this.colorObjects.get(`${e[0]}_${e[1]}_${e[2]}`)}getPickingObject3v(e){return this.colorObjects.get(`${e.x}_${e.y}_${e.z}`)}assignPickingColor(e){if(!e._pickingColor||e._pickingColor.isZero()){let t=0,i=0,r=0,s="0_0_0";for(;!(t||i||r)||this.colorObjects.has(s);)t=Ri(1,255),i=Ri(1,255),r=Ri(1,255),s=`${t}_${i}_${r}`;e._pickingColor?e._pickingColor.set(t,i,r):e._pickingColor=new m(t,i,r),e._pickingColorU=new Float32Array([t/255,i/255,r/255]),this.colorObjects.set(s,e)}}clearPickingColor(e){if(e._pickingColor&&!e._pickingColor.isZero()){let t=e._pickingColor;t.isZero()||(this.colorObjects.delete(`${t.x}_${t.y}_${t.z}`),t.x=t.y=t.z=0)}}getWidth(){return this.handler.canvas.clientWidth}getHeight(){return this.handler.canvas.clientHeight}getCenter(){let e=this.handler.canvas;return new N(Math.round(.5*e.width),Math.round(.5*e.height))}getClientCenter(){let e=this.handler.canvas;return new N(Math.round(.5*e.clientWidth),Math.round(.5*e.clientHeight))}addControl(e){e.addTo(this)}addControls(e){for(let t=0;t<e.length;t++)e[t].addTo(this)}removeControl(e){e.remove()}isInitialized(){return this._initialized}initialize(){if(!this._initialized){if(this._initialized=!0,this.handler.initialize(),this.billboardsTextureAtlas.assignHandler(this.handler),this.geoObjectsTextureAtlas.assignHandler(this.handler),this.fontAtlas.assignHandler(this.handler),this.handler.setFrameCallback(()=>{this.draw()}),this.events.initialize(),this.events.on("charkeypress",W.KEY_APOSTROPHE,function(){Ke.setVisibility(!Ke.getVisibility())}),this.handler.addProgram(new X("screenFrame",{uniforms:{texture:"sampler2d"},attributes:{corners:"vec3"},vertexShader:`attribute vec2 corners;
893
893
 
894
894
  varying vec2 tc;
895
895
  void main(void) {
@@ -902,7 +902,7 @@ precision highp float;uniform float frustumPickingColor;layout(location=0)out ve
902
902
 
903
903
  void main(void) {
904
904
  gl_FragColor = texture2D( texture, tc );
905
- }`})),this.pickingFramebuffer=new Me(this.handler,{width:640,height:480,targets:[{readAsync:!0}]}),this.pickingFramebuffer.init(),this.depthFramebuffer=new Me(this.handler,{width:640,height:480,targets:[{internalFormat:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT",readAsync:!0},{internalFormat:"RGBA16F",type:"FLOAT",attachment:"COLOR_ATTACHMENT",readAsync:!0}],useDepth:!0}),this.depthFramebuffer.init(),this.screenDepthFramebuffer=new Me(this.handler,{useDepth:!1}),this.screenDepthFramebuffer.init(),this.handler.gl.type==="webgl")this._readPickingBuffer=this._readPickingBuffer_webgl1,this.sceneFramebuffer=new Me(this.handler),this.sceneFramebuffer.init(),this._fnScreenFrame=this._screenFrameNoMSAA,this.screenTexture={screen:this.sceneFramebuffer.textures[0],picking:this.pickingFramebuffer.textures[0],depth:this.screenDepthFramebuffer.textures[0]};else{let e=this.getMaxMSAA(this._internalFormat);this._msaa>e&&(this._msaa=e),this.handler.addPrograms([new X("toneMapping",{uniforms:{hdrBuffer:"sampler2d",exposure:"float",gamma:"float",whitepoint:"float"},attributes:{corners:"vec3"},vertexShader:`#version 300 es
905
+ }`})),this.pickingFramebuffer=new Se(this.handler,{width:640,height:480,targets:[{readAsync:!0}]}),this.pickingFramebuffer.init(),this.depthFramebuffer=new Se(this.handler,{width:640,height:480,targets:[{internalFormat:"RGBA",type:"UNSIGNED_BYTE",attachment:"COLOR_ATTACHMENT",readAsync:!0},{internalFormat:"RGBA16F",type:"FLOAT",attachment:"COLOR_ATTACHMENT",readAsync:!0}],useDepth:!0}),this.depthFramebuffer.init(),this.screenDepthFramebuffer=new Se(this.handler,{useDepth:!1}),this.screenDepthFramebuffer.init(),this.handler.gl.type==="webgl")this._readPickingBuffer=this._readPickingBuffer_webgl1,this.sceneFramebuffer=new Se(this.handler),this.sceneFramebuffer.init(),this._fnScreenFrame=this._screenFrameNoMSAA,this.screenTexture={screen:this.sceneFramebuffer.textures[0],picking:this.pickingFramebuffer.textures[0],depth:this.screenDepthFramebuffer.textures[0]};else{let e=this.getMaxMSAA(this._internalFormat);this._msaa>e&&(this._msaa=e),this.handler.addPrograms([new X("toneMapping",{uniforms:{hdrBuffer:"sampler2d",exposure:"float",gamma:"float",whitepoint:"float"},attributes:{corners:"vec3"},vertexShader:`#version 300 es
906
906
  in vec2 corners;out vec2 tc;void main(void){gl_Position=vec4(corners,0.0,1.0);tc=corners*0.5+0.5;}`,fragmentShader:`#version 300 es
907
907
  precision highp float;
908
908
  #ifndef saturate
@@ -937,5 +937,5 @@ vec3 Uncharted2ToneMapping(vec3 color){color*=exposure;return saturate(Uncharted
937
937
  void main(void) {
938
938
  float c = LinearizeDepth(tc);
939
939
  fragColor = vec4(c, c, c, 1.0);
940
- }`})]),this.sceneFramebuffer=new Zo(this.handler,{size:1,msaa:this._msaa,internalFormat:this._internalFormat,filter:"LINEAR"}),this.sceneFramebuffer.init(),this.blitFramebuffer=new Me(this.handler,{size:1,useDepth:!1,targets:[{internalFormat:this._internalFormat,format:this._format,type:this._type,filter:"NEAREST"}]}),this.blitFramebuffer.init(),this.toneMappingFramebuffer=new Me(this.handler,{useDepth:!1}),this.toneMappingFramebuffer.init(),this._fnScreenFrame=this._screenFrameMSAA,this.screenTexture={screen:this.toneMappingFramebuffer.textures[0],picking:this.pickingFramebuffer.textures[0],depth:this.screenDepthFramebuffer.textures[0],frustum:this.depthFramebuffer.textures[0]}}this.handler.ONCANVASRESIZE=()=>{this._resizeStart(),this.events.dispatch(this.events.resize,this.handler.canvas),this._resizeEnd(),this.events.dispatch(this.events.resizeend,this.handler.canvas)},this.screenFramePositionBuffer=this.handler.createArrayBuffer(new Float32Array([1,1,-1,1,1,-1,-1,-1]),2,4),this.outputTexture=this.screenTexture.screen,this._initializeRenderNodes(),this._initializeControls()}}_initializeControls(){let e=this.controls;this.controls={};for(let t in e)this.addControl(e[t])}resize(){this._resizeEnd()}setCurrentScreen(e){this._currentOutput=e,this.screenTexture[e]&&(this.outputTexture=this.screenTexture[e])}_resizeStart(){let e=this.handler.canvas;this.activeCamera.setViewportSize(e.width,e.height),this.sceneFramebuffer.setSize(.5*e.width,.5*e.height),this.blitFramebuffer&&this.blitFramebuffer.setSize(.5*e.width,.5*e.height,!0)}_resizeEnd(){let e=this.handler.canvas;this.activeCamera.setViewportSize(e.width,e.height),this.sceneFramebuffer.setSize(e.width,e.height),this.blitFramebuffer&&this.blitFramebuffer.setSize(e.width,e.height,!0),this.toneMappingFramebuffer&&this.toneMappingFramebuffer.setSize(e.width,e.height,!0),this.screenDepthFramebuffer&&this.screenDepthFramebuffer.setSize(e.clientWidth,e.clientHeight,!0),this.handler.gl.type==="webgl"?(this.screenTexture.screen=this.sceneFramebuffer.textures[0],this.screenTexture.picking=this.pickingFramebuffer.textures[0],this.screenTexture.depth=this.screenDepthFramebuffer.textures[0],this.screenTexture.frustum=this.depthFramebuffer.textures[0]):(this.screenTexture.screen=this.toneMappingFramebuffer.textures[0],this.screenTexture.picking=this.pickingFramebuffer.textures[0],this.screenTexture.depth=this.screenDepthFramebuffer.textures[0],this.screenTexture.frustum=this.depthFramebuffer.textures[0]),this.setCurrentScreen(this._currentOutput)}removeNode(e){e.remove()}addNode(e){this.renderNodes[e.name]?Qe.logWrn(`Node name ${e.name} already exists.`):(e.assign(this),this._renderNodesArr.unshift(e),this.renderNodes[e.name]=e)}_initializeRenderNodes(){for(let e=0;e<this._renderNodesArr.length;e++)this._renderNodesArr[e].initialize()}addNodeBefore(e,t){if(this.renderNodes[e.name])Qe.logWrn(`Node name ${e.name} already exists.`);else{e.assign(this),this.renderNodes[e.name]=e;for(let i=0;i<this._renderNodesArr.length;i++)if(this._renderNodesArr[i].isEqual(t)){this._renderNodesArr.splice(i,0,e);break}this._renderNodesArr.unshift(e)}}addNodes(e){for(let t=0;t<e.length;t++)this.addNode(e[t])}getMaxMSAA(e){let t=this.handler.gl;return t.getInternalformatParameter(t.RENDERBUFFER,t[e],t.SAMPLES)[0]}getMSAA(){return this._msaa}enqueueEntityCollectionsToDraw(e,t=0){this._entityCollections[t]||(this._entityCollections[t]=[]),this._entityCollections[t].push(...e)}_drawEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=this.handler.gl;this.enableBlendDefault();let s=t.length;for(;s--;)t[s]._fadingOpacity&&t[s].pointCloudHandler.draw();for(s=t.length;s--;){let n=t[s];t[s]._fadingOpacity&&(n.events.dispatch(n.events.draw,n),t[s].geoObjectHandler.draw())}for(i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this.billboardsTextureAtlas.texture),s=t.length;s--;){let n=t[s];n._fadingOpacity&&n.billboardHandler.draw()}let r=this.fontAtlas.atlasesArr;for(s=0;s<r.length;s++)i.activeTexture(i.TEXTURE0+s),i.bindTexture(i.TEXTURE_2D,r[s].texture);for(s=t.length;s--;)t[s]._fadingOpacity&&t[s].labelHandler.draw();for(s=t.length;s--;)t[s]._fadingOpacity&&t[s].rayHandler.draw();for(s=t.length;s--;)t[s]._fadingOpacity&&t[s].polylineHandler.draw();for(s=t.length;s--;)t[s]._fadingOpacity&&t[s].stripHandler.draw()}}_drawPickingEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=t.length;for(;i--;)t[i]._fadingOpacity&&t[i].billboardHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].geoObjectHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].labelHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].rayHandler.drawPicking();for(i=t.length;i--;)t[i]._visibility&&t[i].polylineHandler.drawPicking();for(i=t.length;i--;)t[i]._visibility&&t[i].stripHandler.drawPicking()}}_drawDepthEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=t.length;for(;i--;)t[i]._fadingOpacity&&t[i].geoObjectHandler.drawDepth()}}_clearEntityCollectionQueue(e){this._entityCollections[e].length=0,this._entityCollections[e]=[]}draw(){this.activeCamera.checkMoveEnd();let e=this.events;e.handleEvents();let t=this.sceneFramebuffer;t.activate();let i=this.handler.gl;i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),this.enableBlendDefault(),e.dispatch(e.draw,this);let s=this.activeCamera.frustums,r=e.pointerEvent(),n=!(e.mouseState.leftButtonDown||e.mouseState.rightButtonDown||e.touchState.touching||e.touchState.moving),o=this._renderNodesArr,l=s.length;for(;l--;){this.activeCamera.setCurrentFrustum(l),i.clear(i.DEPTH_BUFFER_BIT);let h=o.length;for(;h--;)o[h].preDrawNode();for(h=o.length;h--;)this.enableBlendDefault(),o[h].drawNode();this._drawEntityCollections(0),e.dispatch(e.drawtransparent,this),r&&n&&this._drawPickingBuffer(0),this._drawDepthBuffer(0),this._clearEntityCollectionQueue(0)}for(let h=1;h<this._entityCollections.length;h++){i.clear(i.DEPTH_BUFFER_BIT);let c=s.length;for(;c--;)this.activeCamera.setCurrentFrustum(c),this._drawEntityCollections(h),r&&n&&this._drawPickingBuffer(h),this._drawDepthBuffer(h);this._clearEntityCollectionQueue(h)}t.deactivate(),this.blitFramebuffer&&t.blitTo(this.blitFramebuffer,0),r&&n&&(this._readPickingBuffer(),this._readDepthBuffer()),this._fnScreenFrame(),e.dispatch(e.postdraw,this),e.mouseState.wheelDelta=0,e.mouseState.justStopped=!1,e.mouseState.moving=!1,e.touchState.moving=!1}getImageDataURL(e="image/png",t=1){return this.draw(),this.handler.canvas?this.handler.canvas.toDataURL(e,t):""}_screenFrameMSAA(){let e=this.handler,t=e.programs.toneMapping,i=t._program,s=e.gl;s.disable(s.DEPTH_TEST),s.bindBuffer(s.ARRAY_BUFFER,this.screenFramePositionBuffer),s.vertexAttribPointer(i.attributes.corners,2,s.FLOAT,!1,0,0),this.toneMappingFramebuffer.activate(),t.activate(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.blitFramebuffer.textures[0]),s.uniform1i(i.uniforms.hdrBuffer,0),s.uniform1f(i.uniforms.gamma,this.gamma),s.uniform1f(i.uniforms.exposure,this.exposure),s.uniform1f(i.uniforms.whitepoint,this.whitepoint),s.drawArrays(s.TRIANGLE_STRIP,0,4),this.toneMappingFramebuffer.deactivate(),t=e.programs.screenFrame,i=t._program,t.activate(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.outputTexture),s.uniform1i(i.uniforms.texture,0),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.enable(s.DEPTH_TEST)}_screenFrameNoMSAA(){let e=this.handler,t=e.programs.screenFrame,i=t._program,s=e.gl;s.disable(s.DEPTH_TEST),t.activate(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.outputTexture),s.uniform1i(i.uniforms.texture,0),s.bindBuffer(s.ARRAY_BUFFER,this.screenFramePositionBuffer),s.vertexAttribPointer(i.attributes.corners,2,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.enable(s.DEPTH_TEST)}_drawPickingBuffer(e){this.pickingFramebuffer.activate();let t=this.handler.gl;if(this.activeCamera.isFirstPass&&e===0?(t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)):t.clear(t.DEPTH_BUFFER_BIT),t.disable(t.BLEND),e===0){let i=this._pickingCallbacks;for(let s=0,r=i.length;s<r;s++)i[s].callback.call(i[s].sender)}this._drawPickingEntityCollections(e),t.enable(t.BLEND),this.pickingFramebuffer.deactivate()}_drawDepthBuffer(e){this.depthFramebuffer.activate();let t=this.handler,i=t.gl;if(i.disable(i.BLEND),this.activeCamera.isFirstPass&&e===0?(i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)):i.clear(i.DEPTH_BUFFER_BIT),e===0){let s=this._depthCallbacks,r=s.length;for(;r--;)s[r].callback.call(s[r].sender)}if(this._drawDepthEntityCollections(e),this.depthFramebuffer.deactivate(),this._currentOutput==="depth"||this._currentOutput==="frustum"){this.screenDepthFramebuffer.activate();let s=t.programs.depth,r=s._program;i.bindBuffer(i.ARRAY_BUFFER,this.screenFramePositionBuffer),i.vertexAttribPointer(r.attributes.corners,2,i.FLOAT,!1,0,0),s.activate(),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this.depthFramebuffer.textures[1]),i.uniform1i(r.uniforms.depthTexture,0),i.drawArrays(i.TRIANGLE_STRIP,0,4),this.screenDepthFramebuffer.deactivate(),i.enable(i.BLEND)}}_readDepthBuffer(){this.depthFramebuffer.readPixelBuffersAsync()}_readPickingBuffer_webgl1(){this.pickingFramebuffer.readPixelBuffersAsync()}_readPickingBuffer_webgl2(){this.pickingFramebuffer.readPixelBuffersAsync()}readPickingColor(e,t,i){var s;let r=this.pickingFramebuffer.width,n=this.pickingFramebuffer.height;e=Math.round(e*r);let o=4*((t=Math.round(t*n))*r+e),l=(s=this.pickingFramebuffer)==null?void 0:s.pixelBuffers[0].data;l&&(i[0]=l[o],i[1]=l[o+1],i[2]=l[o+2])}readDepth(e,t,i){let s=new Float32Array(4),r=new Uint8Array(4);this.depthFramebuffer.readData(e,t,r,0),this.depthFramebuffer.readData(e,t,s,1),i[0]=s[0],i[1]=Math.round(r[0]/10)-1}getDistanceFromPixel(e){let t=this.activeCamera,i=this.handler.canvas,s=e.x/i.width,r=(i.height-e.y)/i.height;Yt[0]=Yt[1]=0;let n=0;if(this.readDepth(s,r,Yt),Yt[1]===-1)return;let o=Yt[0],l=t.frustums[Yt[1]];if(!l)return;let h=new ee(2*s-1,2*r-1,2*o-1,1),c=l.inverseProjectionMatrix.mulVec4(h),d=e.direction||t.unproject(e.x,e.y);return n=-c.z/c.w/d.dot(t.getForward()),n}getCartesianFromPixel(e){let t=this.getDistanceFromPixel(e);if(t)return(e.direction||this.activeCamera.unproject(e.x,e.y)).scaleTo(t).addA(this.activeCamera.eye)}start(){this._initialized||this.initialize(),this.handler.start()}destroy(){for(let e in this.controls)this.controls[e].remove();for(let e=0;e<this._renderNodesArr.length;e++)this._renderNodesArr[e].remove();this.div=null,this._renderNodesArr=[],this.renderNodes={},this.activeCamera=null,this.controls={},this.controlsBag={},this.colorObjects.clear(),this.colorObjects=null,this._pickingCallbacks=[],this.pickingFramebuffer=null,this._tempPickingPix_=null,this._depthCallbacks=[],this.depthFramebuffer=null,this.sceneFramebuffer=null,this.blitFramebuffer=null,this.toneMappingFramebuffer=null,this._entityCollections=[[]],this.handler.ONCANVASRESIZE=null,this.handler.destroy(),this.handler=null,this._initialized=!1}}const xa="/res",ba=class es{constructor(e){this.$target=null,this._instanceID=`__globus${es.__counter__++?es.__counter__:""}__`,window[this._instanceID]=this,this._canvas=document.createElement("canvas"),this._canvas.id=`canvas${this._instanceID}`,this._canvas.style.width="100%",this._canvas.style.height="100%",this._canvas.style.display="block",this._canvas.style.opacity="0.0",this._canvas.style.transition="opacity 150ms",this.$inner=document.createElement("div"),this.$inner.classList.add("og-inner"),this.$inner.appendChild(this._canvas),this.$inner.attributions=document.createElement("div"),e.attributionContainer?e.attributionContainer.appendChild(this.$inner.attributions):(this.$inner.attributions.classList.add("og-attribution"),this.$inner.appendChild(this.$inner.attributions)),e.target&&this.attachTo(e.target);const t=n=>{n.preventDefault()};this._canvas.onmouseenter=function(){document.addEventListener("mousewheel",t,{capture:!1,passive:!1})},this._canvas.onmouseleave=function(){document.removeEventListener("mousewheel",t)},this.renderer=new rd(new wt(this._canvas,{autoActivate:!1,pixelRatio:e.dpi||window.devicePixelRatio+.15,context:{antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1}}),{autoActivate:!1,msaa:e.msaa,fontsSrc:e.fontsSrc,gamma:e.gamma,exposure:e.exposure}),this.renderer.div=this.$inner,e.skybox&&this.renderer.addNode(e.skybox),this._planetName=e.name?e.name:"globus_planet_"+es.__counter__,this.planet=new _a({name:this._planetName,frustums:e.frustums,ellipsoid:e.ellipsoid,maxGridSize:e.maxGridSize,nightTextureSrc:e.nightTextureSrc===null?null:e.nightTextureSrc||`${e.resourcesSrc||xa}/night.png`,specularTextureSrc:e.specularTextureSrc===null?null:e.specularTextureSrc||`${e.resourcesSrc||xa}/spec.png`,minAltitude:e.minAltitude,maxAltitude:e.maxAltitude||15e6,maxEqualZoomAltitude:e.maxEqualZoomAltitude,minEqualZoomAltitude:e.minEqualZoomAltitude,minEqualZoomCameraSlope:e.minEqualZoomCameraSlope,quadTreeStrategyPrototype:e.quadTreeStrategyPrototype,maxLoadingRequests:e.maxLoadingRequests,atmosphereEnabled:e.atmosphereEnabled,transitionOpacityEnabled:e.transitionOpacityEnabled,atmosphereParameters:e.atmosphereParameters,minDistanceBeforeMemClear:e.minDistanceBeforeMemClear,vectorTileSize:e.vectorTileSize,maxNodesCount:e.maxNodesCount}),e.terrain?Array.isArray(e.terrain)?this.planet.setTerrain(e.terrain[0]):this.planet.setTerrain(e.terrain):this.planet.setTerrain(new cr),this.renderer.addNode(this.planet),e.controls?this.planet.addControls(e.controls):this.planet.addControls([new To,new uo,new Co,new lo,new xo,new Zr,new Ks]);const i=this.renderer.controls;let s;for(let n in i)if(i[n]instanceof js){s=i[n];break}s?this.sun=s:(this.sun=new js,this.planet.addControl(this.sun)),e.sun&&(e.sun.active===void 0||e.sun.active||this.sun.deactivate(),e.sun.stopped===!0&&this.sun.stop()),e.layers&&this.planet.addLayers(e.layers);let r=e.viewExtent;r&&(r instanceof Array?this.planet.viewExtentArr(r):this.planet.viewExtent(r)),(e.autoActivate||Ge(e.autoActivate))&&this.start()}start(){this.renderer.start(),this.fadeIn()}fadeIn(){this._canvas.style.opacity="1.0"}fadeOut(){this._canvas.style.opacity="0"}attachTo(e,t){let i;this.detach(),i=e instanceof HTMLElement?e:document.getElementById(e)||document.querySelector(e),i?(this.$target=i,t&&this.$target.firstChild?this.$target.insertBefore(this.$inner,this.$target.firstChild):i.appendChild(this.$inner)):console.warn(`Target container not found. Provided target: ${e}`)}detach(){this.$target&&(this.$target.removeChild(this.$inner),this.$target=null)}destroy(){this.detach(),this.planet.layers.forEach(e=>e.remove()),this.planet.destroy(),this.renderer.destroy(),window[this._instanceID]=null}};ba.__counter__=0;let nd=ba;new hs(3396200,3389508),new hs(1737400,1737400);var od=(a=>(a[a.byte=5120]="byte",a[a.ubyte=5121]="ubyte",a[a.short=5122]="short",a[a.ushort=5123]="ushort",a[a.uint=5125]="uint",a[a.float=5126]="float",a))(od||{}),ad=(a=>(a.scalar="SCALAR",a.vec2="VEC2",a.vec3="VEC3",a.vec4="VEC4",a.mat2="MAT2",a.mat3="MAT3",a.mat4="MAT4",a))(ad||{}),ld=(a=>(a[a.points=0]="points",a[a.lines=1]="lines",a[a.lineLoop=2]="lineLoop",a[a.lineStrip=3]="lineStrip",a[a.triangles=4]="triangles",a[a.triangleStrip=5]="triangleStrip",a[a.triangleFan=6]="triangleFan",a))(ld||{});const hd=({children:a,onDraw:e,...t})=>{const i=S.useRef(null),{setGlobe:s}=dt(),[r,n]=S.useState(t),o=S.useRef(null);return S.useEffect(()=>{if(o&&o.current&&t.viewExtent!==void 0){const l=t.viewExtent instanceof G?t.viewExtent:new G(new A(t.viewExtent[0],t.viewExtent[1]),new A(t.viewExtent[2],t.viewExtent[3]));o.current.planet.viewExtent(l)}},[t.viewExtent]),S.useEffect(()=>{o&&o.current&&t.atmosphereEnabled!==void 0&&(o.current.planet.atmosphereEnabled=t.atmosphereEnabled)},[t.atmosphereEnabled]),S.useEffect(()=>{var l,h;o&&o.current&&t.sunActive!==void 0&&(t.sunActive?(l=o.current)==null||l.sun.activate():(h=o.current)==null||h.sun.deactivate())},[t.sunActive]),S.useEffect(()=>{if(o.current)i.current=o.current.$target;else{const l=new ma("OSM"),h=new va("Microsoft Bing");o.current=new nd({target:i.current,name:"Earth",terrain:new ga,layers:[l,h],autoActivate:!0,atmosphereEnabled:!0,...r}),e&&o.current.planet.events.on("draw",e)}return s(o.current),()=>{o.current&&(e&&o.current.planet.events.off("draw",e),o.current.destroy(),o.current=null)}},[r]),Oe.createElement("div",{style:{width:"100%",height:"100%"},ref:i},a)},cd=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var s;typeof e.src=="string"&&i.current&&((s=i.current)==null||s.setSrc(e.src))},[e.src]),S.useEffect(()=>{if(t)return i.current=new ir(a,e),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),null},dd=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var s;typeof e.src=="string"&&i.current&&((s=i.current)==null||s.setSrc(e.src))},[e.src]),S.useEffect(()=>{if(t)return i.current=new pa(a,e),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),null},ud=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var s;typeof e.url=="string"&&i.current&&((s=i.current)==null||s.setUrl(e.url))},[e.url]),S.useEffect(()=>{if(t)return i.current=new xi(a,{...e}),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),Oe.createElement(gr,{layerRef:i,name:a,...e})},gr=({opacity:a,children:e,name:t,layerRef:i,...s})=>{const[r,n]=Oe.useState(!1);return S.useEffect(()=>{i&&i.current&&typeof a=="number"&&r&&(i.current.opacity=a)},[a]),S.useEffect(()=>{var o,l,h,c,d,u,g,f,p,_,m,y,x,w,b,E,C,T,L,M,R,z,F,P,D,I;return r&&i&&i.current&&(s.onVisibilityChange&&((o=i.current)==null||o.events.on("visibilitychange",s.onVisibilityChange)),s.onAdd&&((l=i.current)==null||l.events.on("add",s.onAdd)),s.onRemove&&((h=i.current)==null||h.events.on("remove",s.onRemove)),s.onMouseMove&&((c=i.current)==null||c.events.on("mousemove",s.onMouseMove)),s.onMouseEnter&&((d=i.current)==null||d.events.on("mouseenter",s.onMouseEnter)),s.onMouseLeave&&((u=i.current)==null||u.events.on("mouseleave",s.onMouseLeave)),s.onLclick&&((g=i.current)==null||g.events.on("lclick",s.onLclick)),s.onRclick&&((f=i.current)==null||f.events.on("rclick",s.onRclick)),s.onMclick&&((p=i.current)==null||p.events.on("mclick",s.onMclick)),s.onLdblclick&&((_=i.current)==null||_.events.on("ldblclick",s.onLdblclick)),s.onRdblclick&&((m=i.current)==null||m.events.on("rdblclick",s.onRdblclick)),s.onMdblclick&&((y=i.current)==null||y.events.on("mdblclick",s.onMdblclick)),s.onLup&&((x=i.current)==null||x.events.on("lup",s.onLup)),s.onRup&&((w=i.current)==null||w.events.on("rup",s.onRup)),s.onMup&&((b=i.current)==null||b.events.on("mup",s.onMup)),s.onLdown&&((E=i.current)==null||E.events.on("ldown",s.onLdown)),s.onRdown&&((C=i.current)==null||C.events.on("rdown",s.onRdown)),s.onMdown&&((T=i.current)==null||T.events.on("mdown",s.onMdown)),s.onLhold&&((L=i.current)==null||L.events.on("lhold",s.onLhold)),s.onRhold&&((M=i.current)==null||M.events.on("rhold",s.onRhold)),s.onMhold&&((R=i.current)==null||R.events.on("mhold",s.onMhold)),s.onMouseWheel&&((z=i.current)==null||z.events.on("mousewheel",s.onMouseWheel)),s.onTouchMove&&((F=i.current)==null||F.events.on("touchmove",s.onTouchMove)),s.onTouchStart&&((P=i.current)==null||P.events.on("touchstart",s.onTouchStart)),s.onTouchEnd&&((D=i.current)==null||D.events.on("touchend",s.onTouchEnd)),s.onDoubleTouch&&((I=i.current)==null||I.events.on("doubletouch",s.onDoubleTouch))),()=>{var k;s.onLclick&&((k=i==null?void 0:i.current)==null||k.events.off("lclick",s.onLclick)),n(!1)}},[r]),i!=null&&i.current&&!r&&n(!0),Oe.createElement(Oe.Fragment,null,e)},pr=S.createContext({addEntity:()=>{},removeEntity:()=>{},addLabel:()=>{},removeLabel:()=>{},addBillboard:()=>{},removeBillboard:()=>{},addGeoObject:()=>{},removeGeoObject:()=>{},addGeometry:()=>{},removeGeometry:()=>{},addPolyline:()=>{},removePolyline:()=>{},addStrip:()=>{},removeStrip:()=>{}}),_d=({visibility:a,children:e,name:t,...i})=>{const{globe:s}=dt(),r=S.useRef(null),[n,o]=S.useState([]),l=S.useRef(new Set);S.useEffect(()=>{typeof a=="boolean"&&r.current&&r.current.setVisibility(a)},[a]),S.useEffect(()=>{var C,T;if(s)return r.current=new ge(t,i),s.planet.addLayer(r.current),i.onDraw&&((C=r.current)==null||C.events.on("draw",i.onDraw)),i.onMouseEnter&&((T=r.current)==null||T.events.on("mouseenter",i.onMouseEnter)),()=>{var L,M;r.current&&(s.planet.removeLayer(r.current),i.onDraw&&((L=r.current)==null||L.events.off("draw",i.onDraw)),i.onMouseEnter&&((M=r.current)==null||M.events.off("mouseenter",i.onMouseEnter)))}},[s]),S.useEffect(()=>{if(r.current&&n.length>0){const C=n.filter(T=>!l.current.has(T));r.current.addEntities(C),C.forEach(T=>l.current.add(T))}},[n]);const h=S.useCallback(C=>{o(T=>T.includes(C)?T:[...T,C])},[]),c=S.useCallback(C=>{o(T=>T.filter(L=>L!==C)),r.current&&(r.current.removeEntity(C),l.current.delete(C))},[]),d=S.useCallback((C,T)=>{C.setBillboard(T)},[]),u=S.useCallback(C=>{var T;(T=C.billboard)==null||T.remove()},[]),g=S.useCallback((C,T)=>{C.setGeoObject(T)},[]),f=S.useCallback(C=>{var T;(T=C.geoObject)==null||T.remove()},[]),p=S.useCallback((C,T)=>{C.setLabel(T)},[]),_=S.useCallback(C=>{var T;(T=C.label)==null||T.remove()},[]),m=S.useCallback((C,T)=>{C.setGeometry(T)},[]),y=S.useCallback(C=>{var T;(T=C.geometry)==null||T.remove()},[]),x=S.useCallback((C,T)=>{C.setPolyline(T)},[]),w=S.useCallback(C=>{var T;(T=C.polyline)==null||T.remove()},[]),b=S.useCallback((C,T)=>{C.setStrip(T)},[]),E=S.useCallback(C=>{var T;(T=C.strip)==null||T.remove()},[]);return Oe.createElement(pr.Provider,{value:{addEntity:h,removeEntity:c,addBillboard:d,removeBillboard:u,addGeoObject:g,removeGeoObject:f,addLabel:p,removeLabel:_,addGeometry:m,removeGeometry:y,addPolyline:x,removePolyline:w,addStrip:b,removeStrip:E}},Oe.createElement(gr,{layerRef:r,name:t,...i},e))},fd=({visibility:a,src:e,size:t,color:i,rotation:s,offset:r,_addBillboard:n,_removeBillboard:o,...l})=>{const h=S.useRef(null);return S.useEffect(()=>{var c;typeof a=="boolean"&&h.current&&((c=h.current)==null||c.setVisibility(a))},[a]),S.useEffect(()=>{var c;typeof e=="string"&&h.current&&((c=h.current)==null||c.setSrc(e))},[e]),S.useEffect(()=>{var c;typeof s=="number"&&h.current&&((c=h.current)==null||c.setRotation(s*Math.PI/180))},[s]),S.useEffect(()=>{var c,d,u;r&&h.current&&(r instanceof v?(c=h.current)==null||c.setOffset(r.x,r.y,r.z):r instanceof N?(d=h.current)==null||d.setOffset(r.x,r.y):(u=h.current)==null||u.setOffset(r[0],r[1],r[2]))},[r]),S.useEffect(()=>{var c;t&&h.current&&((c=h.current)==null||c.setSize(t[0],t[1]))},[t]),S.useEffect(()=>{var c;typeof i=="string"&&h.current&&((c=h.current)==null||c.setColorHTML(i))},[i]),S.useEffect(()=>(h.current=new hn({...l,color:i,size:t,src:e,offset:r,visibility:a,rotation:s?s*Math.PI/180:0}),h.current&&n&&n(h.current),()=>{h.current&&o&&o(h.current)}),[n,o]),null},gd=({color:a,objSrc:e,scale:t,visibility:i,_addGeoObject:s,_removeGeoObject:r,...n})=>{const o=S.useRef(null);return S.useEffect(()=>{var l;t&&o.current&&((l=o.current)==null||l.setScale(t))},[t]),S.useEffect(()=>{var l,h,c;o.current&&(typeof a=="string"?(l=o.current)==null||l.setColorHTML(a):a instanceof ee?(h=o.current)==null||h.setColor4v(a):Array.isArray(a)&&((c=o.current)==null||c.setColor(...a)))},[a]),S.useEffect(()=>{var l;e&&o.current&&((l=o.current)==null||l.setObjectSrc(e))},[e]),S.useEffect(()=>{var l;typeof i=="boolean"&&o.current&&((l=o.current)==null||l.setVisibility(i))},[i]),S.useEffect(()=>(o.current=new fn({color:a,objSrc:e,scale:t,visibility:i,...n}),o.current&&s&&s(o.current),()=>{o.current&&r&&r(o.current)}),[s,r]),null},pd=({visibility:a,size:e,color:t,rotation:i,offset:s,text:r,face:n,isRTL:o,align:l,outline:h,outlineColor:c,opacity:d,_addLabel:u,_removeLabel:g,...f})=>{const p=S.useRef(null);return S.useEffect(()=>{var _;typeof a=="boolean"&&p.current&&((_=p.current)==null||_.setVisibility(a))},[a]),S.useEffect(()=>{var _;typeof i=="number"&&p.current&&((_=p.current)==null||_.setRotation(i*Math.PI/180))},[i]),S.useEffect(()=>{var _;typeof e=="number"&&p.current&&((_=p.current)==null||_.setSize(e))},[e]),S.useEffect(()=>{var _;typeof h=="number"&&p.current&&((_=p.current)==null||_.setOutline(h))},[h]),S.useEffect(()=>{var _;typeof d=="number"&&p.current&&((_=p.current)==null||_.setOpacity(d))},[d]),S.useEffect(()=>{var _;typeof o=="boolean"&&p.current&&((_=p.current)==null||_.setRtl(o))},[o]),S.useEffect(()=>{var _,m,y;s&&p.current&&(s instanceof v?(_=p.current)==null||_.setOffset(s.x,s.y,s.z):s instanceof N?(m=p.current)==null||m.setOffset(s.x,s.y):(y=p.current)==null||y.setOffset(s[0],s[1],s[2]))},[s]),S.useEffect(()=>{var _;typeof r=="string"&&p.current&&((_=p.current)==null||_.setText(r))},[r]),S.useEffect(()=>{var _;typeof n=="string"&&p.current&&((_=p.current)==null||_.setFace(n))},[n]),S.useEffect(()=>{var _;typeof l=="string"&&p.current&&((_=p.current)==null||_.setAlign(l))},[l]),S.useEffect(()=>{var _;typeof t=="string"&&p.current&&((_=p.current)==null||_.setColorHTML(t))},[t]),S.useEffect(()=>{var _;typeof c=="string"&&p.current&&((_=p.current)==null||_.setOutlineColorHTML(c))},[c]),S.useEffect(()=>(p.current=new pn({...f,color:t,size:e,text:r,face:n,isRTL:o,align:l,outline:h,outlineColor:c,opacity:d,offset:s,visibility:a,rotation:i?i*Math.PI/180:0}),p.current&&u&&u(p.current),()=>{p.current&&g&&g(p.current)}),[u,g]),null};function md(a){switch(a.type){case"POINT":return Array.isArray(a.coordinates)&&a.coordinates.length>=2&&typeof a.coordinates[0]=="number";case"LINESTRING":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.length>=2&&typeof e[0]=="number");case"POLYGON":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="number"));case"MULTIPOLYGON":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.every(i=>Array.isArray(i)&&i.length>=2&&typeof i[0]=="number")));case"MULTILINESTRING":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="number"));default:return!1}}const vd=a=>{const{visibility:e,fillColor:t,lineColor:i,strokeColor:s,lineWidth:r,strokeWidth:n,type:o,coordinates:l,_addGeometry:h,_removeGeometry:c}=a,d=S.useRef(null);if(!md({type:o,coordinates:l}))throw new Error(`Invalid coordinates for type ${o}`);return S.useEffect(()=>{typeof e=="boolean"&&d.current&&d.current.setVisibility(e)},[e]),S.useEffect(()=>{if(t!==void 0&&d.current){if(t instanceof ee)d.current.setFillColor4v(t);else if(Array.isArray(t))d.current.setFillColor(...t);else if(typeof t=="string"&&d.current){const u=Hi.htmlColorToRgba(t);d.current.setFillColor4v(u)}}},[t]),S.useEffect(()=>{if(i!==void 0&&d.current){if(i instanceof ee)d.current.setLineColor4v(i);else if(Array.isArray(i))d.current.setLineColor(...i);else if(typeof i=="string"&&d.current){const u=Hi.htmlColorToRgba(i);d.current.setLineColor4v(u)}}},[i]),S.useEffect(()=>{if(s!==void 0&&d.current){if(s instanceof ee)d.current.setStrokeColor4v(s);else if(Array.isArray(s))d.current.setStrokeColor(...s);else if(typeof s=="string"&&d.current){const u=Hi.htmlColorToRgba(s);d.current.setStrokeColor4v(u)}}},[s]),S.useEffect(()=>{typeof r=="number"&&d.current&&d.current.setLineWidth(r)},[r]),S.useEffect(()=>{typeof n=="number"&&d.current&&d.current.setStrokeWidth(n)},[n]),S.useEffect(()=>(d.current=new dn({...a,type:o,coordinates:l,style:{fillColor:t,lineColor:i,strokeColor:s,lineWidth:r,strokeWidth:n},visibility:e}),d.current&&h&&h(d.current),()=>{d.current&&c&&c(d.current)}),[h,c]),null},wa=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof v,Ca=a=>Array.isArray(a)&&a.length>0&&(a[0][0]instanceof A||a[0][0]instanceof Array),yd=a=>a.map(e=>e.map(t=>A.createFromArray(t))),xd=a=>typeof a=="string"||Array.isArray(a),Ta=a=>Array.isArray(a)&&a.every(e=>Array.isArray(e)&&e.every(xd)),bd=a=>Array.isArray(a)&&a.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length===4&&t.every(i=>typeof i=="number"))),Ea=a=>Ta(a)?a.map(e=>e.map(t=>{const i=Hi.htmlColorToRgba(t);return[i.x,i.y,i.z,i.w]})):a,wd=({visibility:a,color:e,altitude:t,thickness:i,opacity:s,isClosed:r,pathColors:n,path:o,_addPolyline:l,_removePolyline:h,...c})=>{const d=S.useRef(null);return S.useEffect(()=>{var u;typeof a=="boolean"&&d.current&&((u=d.current)==null||u.setVisibility(a))},[a]),S.useEffect(()=>{var u;typeof e=="string"&&d.current&&((u=d.current)==null||u.setColorHTML(e))},[e]),S.useEffect(()=>{var u;typeof t=="number"&&d.current&&((u=d.current)==null||u.setAltitude(t))},[t]),S.useEffect(()=>{var u;typeof i=="number"&&d.current&&((u=d.current)==null||u.setThickness(i))},[i]),S.useEffect(()=>{var u;typeof s=="number"&&d.current&&((u=d.current)==null||u.setOpacity(s))},[s]),S.useEffect(()=>{var u,g,f;if(d.current&&o!==void 0)if(Ca(o))(u=d.current)==null||u.setPathLonLat(o);else if(wa(o))(g=d.current)==null||g.setPath3v(o);else{const p=yd(o);p&&((f=d.current)==null||f.setPathLonLat(p))}},[o]),S.useEffect(()=>{var u,g;if(n&&Array.isArray(n)&&n.length>0)if(Ta(n)){const f=Ea(n);f&&((u=d.current)==null||u.setPathColors(f))}else bd(n)&&((g=d.current)==null||g.setPathColors(n))},[n]),S.useEffect(()=>(d.current=new yn({...c,color:e,visibility:a,opacity:s,thickness:i,pathLonLat:o&&Ca(o)?o:void 0,path3v:o&&wa(o)?o:void 0,pathColors:Ea(n),altitude:t}),d.current&&l&&l(d.current),()=>{d.current&&h&&h(d.current)}),[l,h]),null},Cd=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof v,Td=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof A,Aa=(a,e)=>e?Cd(e)?e:Td(e)?e.map(t=>t.map(i=>a.lonLatToCartesian(i))):e.map(t=>t.map(i=>a.lonLatToCartesian(A.createFromArray(i)))):[],Ed=({visibility:a,color:e,opacity:t,path:i,_addStrip:s,_removeStrip:r,...n})=>{const o=S.useRef(null),{globe:l}=dt();return S.useEffect(()=>{var h;typeof a=="boolean"&&o.current&&((h=o.current)==null||h.setVisibility(a))},[a]),S.useEffect(()=>{var h;typeof t=="number"&&o.current&&((h=o.current)==null||h.setOpacity(t))},[t]),S.useEffect(()=>{var h;l&&i!==void 0&&o.current&&((h=o.current)==null||h.setPath(Aa(l.planet.ellipsoid,i)))},[i]),S.useEffect(()=>{var h;typeof e=="string"&&o.current&&((h=o.current)==null||h.setColorHTML(e))},[e]),S.useEffect(()=>(l&&(o.current=new wn({...n,color:e,visibility:a,path:Aa(l.planet.ellipsoid,i),opacity:t}),o.current&&s&&s(o.current)),()=>{o.current&&r&&r(o.current)}),[s,r,l]),null},Ad=({visibility:a,lon:e,lat:t,alt:i,lonlat:s,name:r,children:n,...o})=>{const{globe:l}=dt(),{addEntity:h,removeEntity:c,addBillboard:d,removeBillboard:u,addGeoObject:g,removeGeoObject:f,addLabel:p,removeLabel:_,addGeometry:m,removeGeometry:y,addPolyline:x,removePolyline:w,addStrip:b,removeStrip:E}=S.useContext(pr),C=S.useRef(null),[T,L]=S.useState(null),[M,R]=S.useState(null),[z,F]=S.useState(null),[P,D]=S.useState(null),[I,k]=S.useState(null),[B,H]=S.useState(null);S.useEffect(()=>{var $;s&&(s instanceof A||(s=A.createFromArray(s)),($=C.current)==null||$.setLonLat(s))},[s,T]),S.useEffect(()=>{var $;r&&(($=C.current)==null||$.setLonLat2(e,t,i))},[e,t,i]),S.useEffect(()=>{var $;typeof a=="boolean"&&C.current&&(($=C.current)==null||$.setVisibility(a))},[a]),S.useEffect(()=>{if(l)return C.current=new V({lonlat:s||new A(e,t,i),name:r,...o}),h(C.current),()=>{l&&C.current&&c(C.current)}},[l,h,c]),S.useEffect(()=>{var $,Ie;T&&!(($=C.current)!=null&&$.billboard)&&((Ie=C.current)==null||Ie.setBillboard(T))},[T]),S.useEffect(()=>{var $,Ie;M&&!(($=C.current)!=null&&$.geoObject)&&((Ie=C.current)==null||Ie.setGeoObject(M))},[M]),S.useEffect(()=>{var $,Ie;z&&!(($=C.current)!=null&&$.label)&&((Ie=C.current)==null||Ie.setLabel(z))},[z]),S.useEffect(()=>{var $,Ie;P&&!(($=C.current)!=null&&$.geometry)&&((Ie=C.current)==null||Ie.setGeometry(P))},[P]),S.useEffect(()=>{var $,Ie;I&&!(($=C.current)!=null&&$.polyline)&&((Ie=C.current)==null||Ie.setPolyline(I))},[I]),S.useEffect(()=>{var $,Ie;B&&!(($=C.current)!=null&&$.strip)&&((Ie=C.current)==null||Ie.setStrip(B))},[B]);const Ce=S.useCallback($=>{L($),C.current&&d(C.current,$)},[d]),ce=S.useCallback(()=>{C.current&&u(C.current),L(null)},[u]),Be=S.useCallback($=>{R($),C.current&&g(C.current,$)},[g]),ke=S.useCallback(()=>{C.current&&f(C.current),R(null)},[f]),ie=S.useCallback($=>{F($),C.current&&p(C.current,$)},[p]),Ue=S.useCallback(()=>{C.current&&_(C.current),R(null)},[_]),Fe=S.useCallback($=>{D($),C.current&&m(C.current,$)},[m]),Ei=S.useCallback(()=>{C.current&&y(C.current),R(null)},[y]),Ai=S.useCallback($=>{k($),C.current&&x(C.current,$)},[x]),Li=S.useCallback(()=>{C.current&&w(C.current),k(null)},[w]),Pd=S.useCallback($=>{H($),C.current&&b(C.current,$)},[b]),Sd=S.useCallback(()=>{C.current&&E(C.current),H(null)},[E]),La={_addGeometry:Fe,_removeGeometry:Ei,_addLabel:ie,_removeLabel:Ue,_addBillboard:Ce,_removeBillboard:ce,_addGeoObject:Be,_removeGeoObject:ke,_addPolyline:Ai,_removePolyline:Li,_addStrip:Pd,_removeStrip:Sd};return n?Oe.createElement(Oe.Fragment,null,Array.isArray(n)?n.map($=>Oe.isValidElement($)?Oe.cloneElement($,La):$):Oe.isValidElement(n)?Oe.cloneElement(n,La):n):null},Ld=({lon:a,lat:e,alt:t,lookLon:i,lookLat:s,lookAlt:r,viewAngle:n,...o})=>{const{globe:l}=dt();return S.useEffect(()=>{l&&typeof a=="number"&&typeof e=="number"&&typeof t=="number"&&l.planet.flyLonLat(new A(a,e,t),new A(i,s,r))},[a,e,t,i,s,r,l]),S.useEffect(()=>{l&&typeof n=="number"&&l.planet.camera.setViewAngle(n)},[n,l]),null};de.Billboard=fd,de.Entity=Ad,de.GeoImage=cd,de.GeoObject=gd,de.GeoVideo=dd,de.Geometry=vd,de.Globe=hd,de.GlobeContextProvider=Ka,de.Label=pd,de.Layer=gr,de.PlanetCamera=Ld,de.Polyline=wd,de.Strip=Ed,de.Vector=_d,de.VectorContext=pr,de.XYZ=ud,de.useGlobeContext=dt,Object.defineProperty(de,Symbol.toStringTag,{value:"Module"})});
940
+ }`})]),this.sceneFramebuffer=new Qa(this.handler,{size:1,msaa:this._msaa,internalFormat:this._internalFormat,filter:"LINEAR"}),this.sceneFramebuffer.init(),this.blitFramebuffer=new Se(this.handler,{size:1,useDepth:!1,targets:[{internalFormat:this._internalFormat,format:this._format,type:this._type,filter:"NEAREST"}]}),this.blitFramebuffer.init(),this.toneMappingFramebuffer=new Se(this.handler,{useDepth:!1}),this.toneMappingFramebuffer.init(),this._fnScreenFrame=this._screenFrameMSAA,this.screenTexture={screen:this.toneMappingFramebuffer.textures[0],picking:this.pickingFramebuffer.textures[0],depth:this.screenDepthFramebuffer.textures[0],frustum:this.depthFramebuffer.textures[0]}}this.handler.ONCANVASRESIZE=()=>{this._resizeStart(),this.events.dispatch(this.events.resize,this.handler.canvas),this._resizeEnd(),this.events.dispatch(this.events.resizeend,this.handler.canvas)},this.screenFramePositionBuffer=this.handler.createArrayBuffer(new Float32Array([1,1,-1,1,1,-1,-1,-1]),2,4),this.outputTexture=this.screenTexture.screen,this._initializeRenderNodes(),this._initializeControls()}}_initializeControls(){let e=this.controls;this.controls={};for(let t in e)this.addControl(e[t])}resize(){this._resizeEnd()}setCurrentScreen(e){this._currentOutput=e,this.screenTexture[e]&&(this.outputTexture=this.screenTexture[e])}_resizeStart(){let e=this.handler.canvas;this.activeCamera.setViewportSize(e.width,e.height),this.sceneFramebuffer.setSize(.5*e.width,.5*e.height),this.blitFramebuffer&&this.blitFramebuffer.setSize(.5*e.width,.5*e.height,!0)}_resizeEnd(){let e=this.handler.canvas;this.activeCamera.setViewportSize(e.width,e.height),this.sceneFramebuffer.setSize(e.width,e.height),this.blitFramebuffer&&this.blitFramebuffer.setSize(e.width,e.height,!0),this.toneMappingFramebuffer&&this.toneMappingFramebuffer.setSize(e.width,e.height,!0),this.screenDepthFramebuffer&&this.screenDepthFramebuffer.setSize(e.clientWidth,e.clientHeight,!0),this.handler.gl.type==="webgl"?(this.screenTexture.screen=this.sceneFramebuffer.textures[0],this.screenTexture.picking=this.pickingFramebuffer.textures[0],this.screenTexture.depth=this.screenDepthFramebuffer.textures[0],this.screenTexture.frustum=this.depthFramebuffer.textures[0]):(this.screenTexture.screen=this.toneMappingFramebuffer.textures[0],this.screenTexture.picking=this.pickingFramebuffer.textures[0],this.screenTexture.depth=this.screenDepthFramebuffer.textures[0],this.screenTexture.frustum=this.depthFramebuffer.textures[0]),this.setCurrentScreen(this._currentOutput)}removeNode(e){e.remove()}addNode(e){this.renderNodes[e.name]?Ke.logWrn(`Node name ${e.name} already exists.`):(e.assign(this),this._renderNodesArr.unshift(e),this.renderNodes[e.name]=e)}_initializeRenderNodes(){for(let e=0;e<this._renderNodesArr.length;e++)this._renderNodesArr[e].initialize()}addNodeBefore(e,t){if(this.renderNodes[e.name])Ke.logWrn(`Node name ${e.name} already exists.`);else{e.assign(this),this.renderNodes[e.name]=e;for(let i=0;i<this._renderNodesArr.length;i++)if(this._renderNodesArr[i].isEqual(t)){this._renderNodesArr.splice(i,0,e);break}this._renderNodesArr.unshift(e)}}addNodes(e){for(let t=0;t<e.length;t++)this.addNode(e[t])}getMaxMSAA(e){let t=this.handler.gl;return t.getInternalformatParameter(t.RENDERBUFFER,t[e],t.SAMPLES)[0]}getMSAA(){return this._msaa}enqueueEntityCollectionsToDraw(e,t=0){this._entityCollections[t]||(this._entityCollections[t]=[]),this._entityCollections[t].push(...e)}_drawEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=this.handler.gl;this.enableBlendDefault();let r=t.length;for(;r--;)t[r]._fadingOpacity&&t[r].pointCloudHandler.draw();for(r=t.length;r--;){let n=t[r];t[r]._fadingOpacity&&(n.events.dispatch(n.events.draw,n),t[r].geoObjectHandler.draw())}for(i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this.billboardsTextureAtlas.texture),r=t.length;r--;){let n=t[r];n._fadingOpacity&&n.billboardHandler.draw()}let s=this.fontAtlas.atlasesArr;for(r=0;r<s.length;r++)i.activeTexture(i.TEXTURE0+r),i.bindTexture(i.TEXTURE_2D,s[r].texture);for(r=t.length;r--;)t[r]._fadingOpacity&&t[r].labelHandler.draw();for(r=t.length;r--;)t[r]._fadingOpacity&&t[r].rayHandler.draw();for(r=t.length;r--;)t[r]._fadingOpacity&&t[r].polylineHandler.draw();for(r=t.length;r--;)t[r]._fadingOpacity&&t[r].stripHandler.draw()}}_drawPickingEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=t.length;for(;i--;)t[i]._fadingOpacity&&t[i].billboardHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].geoObjectHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].labelHandler.drawPicking();for(i=t.length;i--;)t[i]._fadingOpacity&&t[i].rayHandler.drawPicking();for(i=t.length;i--;)t[i]._visibility&&t[i].polylineHandler.drawPicking();for(i=t.length;i--;)t[i]._visibility&&t[i].stripHandler.drawPicking()}}_drawDepthEntityCollections(e){let t=this._entityCollections[e];if(t.length){let i=t.length;for(;i--;)t[i]._fadingOpacity&&t[i].geoObjectHandler.drawDepth()}}_clearEntityCollectionQueue(e){this._entityCollections[e].length=0,this._entityCollections[e]=[]}draw(){this.activeCamera.checkMoveEnd();let e=this.events;e.handleEvents();let t=this.sceneFramebuffer;t.activate();let i=this.handler.gl;i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),this.enableBlendDefault(),e.dispatch(e.draw,this),this.activeCamera.checkFly();let r=this.activeCamera.frustums,s=e.pointerEvent(),n=!(e.mouseState.leftButtonDown||e.mouseState.rightButtonDown||e.touchState.touching||e.touchState.moving),o=this._renderNodesArr,l=r.length;for(;l--;){this.activeCamera.setCurrentFrustum(l),i.clear(i.DEPTH_BUFFER_BIT);let h=o.length;for(;h--;)o[h].preDrawNode();for(h=o.length;h--;)this.enableBlendDefault(),o[h].drawNode();this._drawEntityCollections(0),e.dispatch(e.drawtransparent,this),s&&n&&this._drawPickingBuffer(0),this._drawDepthBuffer(0),this._clearEntityCollectionQueue(0)}for(let h=1;h<this._entityCollections.length;h++){i.clear(i.DEPTH_BUFFER_BIT);let c=r.length;for(;c--;)this.activeCamera.setCurrentFrustum(c),this._drawEntityCollections(h),s&&n&&this._drawPickingBuffer(h),this._drawDepthBuffer(h);this._clearEntityCollectionQueue(h)}t.deactivate(),this.blitFramebuffer&&t.blitTo(this.blitFramebuffer,0),s&&n&&(this._readPickingBuffer(),this._readDepthBuffer()),this._fnScreenFrame(),e.dispatch(e.postdraw,this),e.mouseState.wheelDelta=0,e.mouseState.justStopped=!1,e.mouseState.moving=!1,e.touchState.moving=!1}getImageDataURL(e="image/png",t=1){return this.draw(),this.handler.canvas?this.handler.canvas.toDataURL(e,t):""}_screenFrameMSAA(){let e=this.handler,t=e.programs.toneMapping,i=t._program,r=e.gl;r.disable(r.DEPTH_TEST),r.bindBuffer(r.ARRAY_BUFFER,this.screenFramePositionBuffer),r.vertexAttribPointer(i.attributes.corners,2,r.FLOAT,!1,0,0),this.toneMappingFramebuffer.activate(),t.activate(),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.blitFramebuffer.textures[0]),r.uniform1i(i.uniforms.hdrBuffer,0),r.uniform1f(i.uniforms.gamma,this.gamma),r.uniform1f(i.uniforms.exposure,this.exposure),r.uniform1f(i.uniforms.whitepoint,this.whitepoint),r.drawArrays(r.TRIANGLE_STRIP,0,4),this.toneMappingFramebuffer.deactivate(),t=e.programs.screenFrame,i=t._program,t.activate(),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.outputTexture),r.uniform1i(i.uniforms.texture,0),r.drawArrays(r.TRIANGLE_STRIP,0,4),r.enable(r.DEPTH_TEST)}_screenFrameNoMSAA(){let e=this.handler,t=e.programs.screenFrame,i=t._program,r=e.gl;r.disable(r.DEPTH_TEST),t.activate(),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.outputTexture),r.uniform1i(i.uniforms.texture,0),r.bindBuffer(r.ARRAY_BUFFER,this.screenFramePositionBuffer),r.vertexAttribPointer(i.attributes.corners,2,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLE_STRIP,0,4),r.enable(r.DEPTH_TEST)}_drawPickingBuffer(e){this.pickingFramebuffer.activate();let t=this.handler.gl;if(this.activeCamera.isFirstPass&&e===0?(t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)):t.clear(t.DEPTH_BUFFER_BIT),t.disable(t.BLEND),e===0){let i=this._pickingCallbacks;for(let r=0,s=i.length;r<s;r++)i[r].callback.call(i[r].sender)}this._drawPickingEntityCollections(e),t.enable(t.BLEND),this.pickingFramebuffer.deactivate()}_drawDepthBuffer(e){this.depthFramebuffer.activate();let t=this.handler,i=t.gl;if(i.disable(i.BLEND),this.activeCamera.isFirstPass&&e===0?(i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)):i.clear(i.DEPTH_BUFFER_BIT),e===0){let r=this._depthCallbacks,s=r.length;for(;s--;)r[s].callback.call(r[s].sender)}if(this._drawDepthEntityCollections(e),this.depthFramebuffer.deactivate(),this._currentOutput==="depth"||this._currentOutput==="frustum"){this.screenDepthFramebuffer.activate();let r=t.programs.depth,s=r._program;i.bindBuffer(i.ARRAY_BUFFER,this.screenFramePositionBuffer),i.vertexAttribPointer(s.attributes.corners,2,i.FLOAT,!1,0,0),r.activate(),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this.depthFramebuffer.textures[1]),i.uniform1i(s.uniforms.depthTexture,0),i.drawArrays(i.TRIANGLE_STRIP,0,4),this.screenDepthFramebuffer.deactivate(),i.enable(i.BLEND)}}_readDepthBuffer(e){this.depthFramebuffer.readPixelBuffersAsync(e)}_readPickingBuffer_webgl1(){this.pickingFramebuffer.readPixelBuffersAsync()}_readPickingBuffer_webgl2(){this.pickingFramebuffer.readPixelBuffersAsync()}readPickingColor(e,t,i){var r;let s=this.pickingFramebuffer.width,n=this.pickingFramebuffer.height;e=Math.round(e*s);let o=4*((t=Math.round(t*n))*s+e),l=(r=this.pickingFramebuffer)==null?void 0:r.pixelBuffers[0].data;l&&(i[0]=l[o],i[1]=l[o+1],i[2]=l[o+2])}readDepth(e,t,i){let r=new Float32Array(4),s=new Uint8Array(4);this.depthFramebuffer.readData(e,t,s,0),this.depthFramebuffer.readData(e,t,r,1),i[0]=r[0],i[1]=Math.round(s[0]/10)-1}getDistanceFromPixel(e){let t=this.activeCamera,i=this.handler.canvas,r=e.x/i.width,s=(i.height-e.y)/i.height;if(jt[0]=jt[1]=0,this.readDepth(r,s,jt),jt[1]===-1)return;let n=jt[0],o=t.frustums[jt[1]];if(!o)return;let l=new te(2*r-1,2*s-1,2*n-1,1),h=o.inverseProjectionMatrix.mulVec4(l),c=-h.z/h.w;if(t.isOrthographic)return c;let d=e.direction||t.unproject(e.x,e.y);return c/Math.max(1e-6,d.dot(t.getForward()))}getCartesianFromPixel(e){let t=this.getDistanceFromPixel(e);if(t){if(this.activeCamera.isOrthographic){let i=new m;return this.activeCamera.unproject(e.x,e.y,t,i),i}return(e.direction||this.activeCamera.unproject(e.x,e.y)).scaleTo(t).addA(this.activeCamera.eye)}}getDepthMinDistance(){let e=this.handler.canvas,t=e.width,i=e.height,r=tr,s=i*t,n=new N;for(let o=0;o<s;o++){n.x=o%t,n.y=Math.floor(o/t);let l=this.getDistanceFromPixel(n);l&&l<r&&(r=l)}return r<tr?r:0}getDepthMinDistanceAsync(){return new Promise((e,t)=>{this._readDepthBuffer(()=>{e(this.getDepthMinDistance())})})}async setOrthographicProjection(e){if(e!==this.activeCamera.isOrthographic){let t=await this.getDepthMinDistanceAsync();t&&e&&(this.activeCamera.focusDistance=t),this.activeCamera.isOrthographic=e,this.events.dispatch(this.events.projchanged,this.activeCamera)}}start(){this._initialized||this.initialize(),this.handler.start()}destroy(){for(let e in this.controls)this.controls[e].remove();for(let e=0;e<this._renderNodesArr.length;e++)this._renderNodesArr[e].remove();this.div=null,this._renderNodesArr=[],this.renderNodes={},this.activeCamera=null,this.controls={},this.controlsBag={},this.colorObjects.clear(),this.colorObjects=null,this._pickingCallbacks=[],this.pickingFramebuffer=null,this._tempPickingPix_=null,this._depthCallbacks=[],this.depthFramebuffer=null,this.sceneFramebuffer=null,this.blitFramebuffer=null,this.toneMappingFramebuffer=null,this._entityCollections=[[]],this.handler.ONCANVASRESIZE=null,this.handler.destroy(),this.handler=null,this._initialized=!1}}const bo="/res",wo=class er{constructor(e){this.$target=null,this._instanceID=`__globus${er.__counter__++?er.__counter__:""}__`,window[this._instanceID]=this,this._canvas=document.createElement("canvas"),this._canvas.id=`canvas${this._instanceID}`,this._canvas.style.width="100%",this._canvas.style.height="100%",this._canvas.style.display="block",this._canvas.style.opacity="0.0",this._canvas.style.transition="opacity 150ms",this.$inner=document.createElement("div"),this.$inner.classList.add("og-inner"),this.$inner.appendChild(this._canvas),this.$inner.attributions=document.createElement("div"),e.attributionContainer?e.attributionContainer.appendChild(this.$inner.attributions):(this.$inner.attributions.classList.add("og-attribution"),this.$inner.appendChild(this.$inner.attributions)),e.target&&this.attachTo(e.target);const t=n=>{n.preventDefault()};this._canvas.onmouseenter=function(){document.addEventListener("mousewheel",t,{capture:!1,passive:!1})},this._canvas.onmouseleave=function(){document.removeEventListener("mousewheel",t)},this.renderer=new sd(new bt(this._canvas,{autoActivate:!1,pixelRatio:e.dpi||window.devicePixelRatio+.15,context:{antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1}}),{autoActivate:!1,msaa:e.msaa,fontsSrc:e.fontsSrc,gamma:e.gamma,exposure:e.exposure}),this.renderer.div=this.$inner,e.skybox&&this.renderer.addNode(e.skybox),this._planetName=e.name?e.name:"globus_planet_"+er.__counter__,this.planet=new yi({name:this._planetName,frustums:e.frustums,ellipsoid:e.ellipsoid,maxGridSize:e.maxGridSize,nightTextureSrc:e.nightTextureSrc===null?null:e.nightTextureSrc||`${e.resourcesSrc||bo}/night.png`,specularTextureSrc:e.specularTextureSrc===null?null:e.specularTextureSrc||`${e.resourcesSrc||bo}/spec.png`,minAltitude:e.minAltitude,maxAltitude:e.maxAltitude||15e6,maxEqualZoomAltitude:e.maxEqualZoomAltitude,minEqualZoomAltitude:e.minEqualZoomAltitude,minEqualZoomCameraSlope:e.minEqualZoomCameraSlope,quadTreeStrategyPrototype:e.quadTreeStrategyPrototype,maxLoadingRequests:e.maxLoadingRequests,atmosphereEnabled:e.atmosphereEnabled,transitionOpacityEnabled:e.transitionOpacityEnabled,atmosphereParameters:e.atmosphereParameters,minDistanceBeforeMemClear:e.minDistanceBeforeMemClear,vectorTileSize:e.vectorTileSize,maxNodesCount:e.maxNodesCount}),e.terrain?Array.isArray(e.terrain)?this.planet.setTerrain(e.terrain[0]):this.planet.setTerrain(e.terrain):this.planet.setTerrain(new ds),this.renderer.addNode(this.planet),e.controls?this.planet.addControls(e.controls):this.planet.addControls([new Ta,new ua,new Ca,new ha,new xa,new Qs,new Jr]);const i=this.renderer.controls;let r;for(let n in i)if(i[n]instanceof qr){r=i[n];break}r?this.sun=r:(this.sun=new qr,this.planet.addControl(this.sun)),e.sun&&(e.sun.active===void 0||e.sun.active||this.sun.deactivate(),e.sun.stopped===!0&&this.sun.stop()),e.layers&&this.planet.addLayers(e.layers);let s=e.viewExtent;s&&(s instanceof Array?this.planet.viewExtentArr(s):this.planet.viewExtent(s)),(e.autoActivate||Ge(e.autoActivate))&&this.start()}start(){this.renderer.start(),this.fadeIn()}fadeIn(){this._canvas.style.opacity="1.0"}fadeOut(){this._canvas.style.opacity="0"}attachTo(e,t){let i;this.detach(),i=e instanceof HTMLElement?e:document.getElementById(e)||document.querySelector(e),i?(this.$target=i,t&&this.$target.firstChild?this.$target.insertBefore(this.$inner,this.$target.firstChild):i.appendChild(this.$inner)):console.warn(`Target container not found. Provided target: ${e}`)}detach(){this.$target&&(this.$target.removeChild(this.$inner),this.$target=null)}destroy(){this.detach(),this.planet.layers.forEach(e=>e.remove()),this.planet.destroy(),this.renderer.destroy(),window[this._instanceID]=null}};wo.__counter__=0;let nd=wo;new cr(3396200,3389508),new cr(1737400,1737400);var ad=(a=>(a[a.byte=5120]="byte",a[a.ubyte=5121]="ubyte",a[a.short=5122]="short",a[a.ushort=5123]="ushort",a[a.uint=5125]="uint",a[a.float=5126]="float",a))(ad||{}),od=(a=>(a.scalar="SCALAR",a.vec2="VEC2",a.vec3="VEC3",a.vec4="VEC4",a.mat2="MAT2",a.mat3="MAT3",a.mat4="MAT4",a))(od||{}),ld=(a=>(a[a.points=0]="points",a[a.lines=1]="lines",a[a.lineLoop=2]="lineLoop",a[a.lineStrip=3]="lineStrip",a[a.triangles=4]="triangles",a[a.triangleStrip=5]="triangleStrip",a[a.triangleFan=6]="triangleFan",a))(ld||{});const hd=({children:a,onDraw:e,...t})=>{const i=S.useRef(null),{setGlobe:r}=dt(),[s,n]=S.useState(t),o=S.useRef(null);return S.useEffect(()=>{if(o&&o.current&&t.viewExtent!==void 0){const l=t.viewExtent instanceof j?t.viewExtent:new j(new A(t.viewExtent[0],t.viewExtent[1]),new A(t.viewExtent[2],t.viewExtent[3]));o.current.planet.viewExtent(l)}},[t.viewExtent]),S.useEffect(()=>{o&&o.current&&t.atmosphereEnabled!==void 0&&(o.current.planet.atmosphereEnabled=t.atmosphereEnabled)},[t.atmosphereEnabled]),S.useEffect(()=>{var l,h;o&&o.current&&t.sunActive!==void 0&&(t.sunActive?(l=o.current)==null||l.sun.activate():(h=o.current)==null||h.sun.deactivate())},[t.sunActive]),S.useEffect(()=>{if(o.current)i.current=o.current.$target;else{const l=new vo("OSM"),h=new yo("Microsoft Bing");o.current=new nd({target:i.current,name:"Earth",terrain:new po,layers:[l,h],autoActivate:!0,atmosphereEnabled:!0,...s}),e&&o.current.planet.events.on("draw",e)}return r(o.current),()=>{o.current&&(e&&o.current.planet.events.off("draw",e),o.current.destroy(),o.current=null)}},[s]),Fe.createElement("div",{style:{width:"100%",height:"100%"},ref:i},a)},cd=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var r;typeof e.src=="string"&&i.current&&((r=i.current)==null||r.setSrc(e.src))},[e.src]),S.useEffect(()=>{if(t)return i.current=new rs(a,e),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),null},dd=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var r;typeof e.src=="string"&&i.current&&((r=i.current)==null||r.setSrc(e.src))},[e.src]),S.useEffect(()=>{if(t)return i.current=new mo(a,e),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),null},ud=({name:a,...e})=>{const{globe:t}=dt(),i=S.useRef(null);return S.useEffect(()=>{var r;typeof e.url=="string"&&i.current&&((r=i.current)==null||r.setUrl(e.url))},[e.url]),S.useEffect(()=>{if(t)return i.current=new xi(a,{...e}),t.planet.addLayer(i.current),()=>{i.current&&t.planet.removeLayer(i.current)}},[t]),Fe.createElement(ps,{layerRef:i,name:a,...e})},ps=({opacity:a,children:e,name:t,layerRef:i,...r})=>{const[s,n]=Fe.useState(!1);return S.useEffect(()=>{i&&i.current&&typeof a=="number"&&s&&(i.current.opacity=a)},[a]),S.useEffect(()=>{var o,l,h,c,d,u,g,f,p,_,v,x,y,w,b,E,C,T,L,M,R,z,F,P,D,k;return s&&i&&i.current&&(r.onVisibilityChange&&((o=i.current)==null||o.events.on("visibilitychange",r.onVisibilityChange)),r.onAdd&&((l=i.current)==null||l.events.on("add",r.onAdd)),r.onRemove&&((h=i.current)==null||h.events.on("remove",r.onRemove)),r.onMouseMove&&((c=i.current)==null||c.events.on("mousemove",r.onMouseMove)),r.onMouseEnter&&((d=i.current)==null||d.events.on("mouseenter",r.onMouseEnter)),r.onMouseLeave&&((u=i.current)==null||u.events.on("mouseleave",r.onMouseLeave)),r.onLclick&&((g=i.current)==null||g.events.on("lclick",r.onLclick)),r.onRclick&&((f=i.current)==null||f.events.on("rclick",r.onRclick)),r.onMclick&&((p=i.current)==null||p.events.on("mclick",r.onMclick)),r.onLdblclick&&((_=i.current)==null||_.events.on("ldblclick",r.onLdblclick)),r.onRdblclick&&((v=i.current)==null||v.events.on("rdblclick",r.onRdblclick)),r.onMdblclick&&((x=i.current)==null||x.events.on("mdblclick",r.onMdblclick)),r.onLup&&((y=i.current)==null||y.events.on("lup",r.onLup)),r.onRup&&((w=i.current)==null||w.events.on("rup",r.onRup)),r.onMup&&((b=i.current)==null||b.events.on("mup",r.onMup)),r.onLdown&&((E=i.current)==null||E.events.on("ldown",r.onLdown)),r.onRdown&&((C=i.current)==null||C.events.on("rdown",r.onRdown)),r.onMdown&&((T=i.current)==null||T.events.on("mdown",r.onMdown)),r.onLhold&&((L=i.current)==null||L.events.on("lhold",r.onLhold)),r.onRhold&&((M=i.current)==null||M.events.on("rhold",r.onRhold)),r.onMhold&&((R=i.current)==null||R.events.on("mhold",r.onMhold)),r.onMouseWheel&&((z=i.current)==null||z.events.on("mousewheel",r.onMouseWheel)),r.onTouchMove&&((F=i.current)==null||F.events.on("touchmove",r.onTouchMove)),r.onTouchStart&&((P=i.current)==null||P.events.on("touchstart",r.onTouchStart)),r.onTouchEnd&&((D=i.current)==null||D.events.on("touchend",r.onTouchEnd)),r.onDoubleTouch&&((k=i.current)==null||k.events.on("doubletouch",r.onDoubleTouch))),()=>{var I;r.onLclick&&((I=i==null?void 0:i.current)==null||I.events.off("lclick",r.onLclick)),n(!1)}},[s]),i!=null&&i.current&&!s&&n(!0),Fe.createElement(Fe.Fragment,null,e)},ms=S.createContext({addEntity:()=>{},removeEntity:()=>{},addLabel:()=>{},removeLabel:()=>{},addBillboard:()=>{},removeBillboard:()=>{},addGeoObject:()=>{},removeGeoObject:()=>{},addGeometry:()=>{},removeGeometry:()=>{},addPolyline:()=>{},removePolyline:()=>{},addStrip:()=>{},removeStrip:()=>{}}),_d=({visibility:a,children:e,name:t,...i})=>{const{globe:r}=dt(),s=S.useRef(null),[n,o]=S.useState([]),l=S.useRef(new Set);S.useEffect(()=>{typeof a=="boolean"&&s.current&&s.current.setVisibility(a)},[a]),S.useEffect(()=>{var C,T;if(r)return s.current=new fe(t,i),r.planet.addLayer(s.current),i.onDraw&&((C=s.current)==null||C.events.on("draw",i.onDraw)),i.onMouseEnter&&((T=s.current)==null||T.events.on("mouseenter",i.onMouseEnter)),()=>{var L,M;s.current&&(r.planet.removeLayer(s.current),i.onDraw&&((L=s.current)==null||L.events.off("draw",i.onDraw)),i.onMouseEnter&&((M=s.current)==null||M.events.off("mouseenter",i.onMouseEnter)))}},[r]),S.useEffect(()=>{if(s.current&&n.length>0){const C=n.filter(T=>!l.current.has(T));s.current.addEntities(C),C.forEach(T=>l.current.add(T))}},[n]);const h=S.useCallback(C=>{o(T=>T.includes(C)?T:[...T,C])},[]),c=S.useCallback(C=>{o(T=>T.filter(L=>L!==C)),s.current&&(s.current.removeEntity(C),l.current.delete(C))},[]),d=S.useCallback((C,T)=>{C.setBillboard(T)},[]),u=S.useCallback(C=>{var T;(T=C.billboard)==null||T.remove()},[]),g=S.useCallback((C,T)=>{C.setGeoObject(T)},[]),f=S.useCallback(C=>{var T;(T=C.geoObject)==null||T.remove()},[]),p=S.useCallback((C,T)=>{C.setLabel(T)},[]),_=S.useCallback(C=>{var T;(T=C.label)==null||T.remove()},[]),v=S.useCallback((C,T)=>{C.setGeometry(T)},[]),x=S.useCallback(C=>{var T;(T=C.geometry)==null||T.remove()},[]),y=S.useCallback((C,T)=>{C.setPolyline(T)},[]),w=S.useCallback(C=>{var T;(T=C.polyline)==null||T.remove()},[]),b=S.useCallback((C,T)=>{C.setStrip(T)},[]),E=S.useCallback(C=>{var T;(T=C.strip)==null||T.remove()},[]);return Fe.createElement(ms.Provider,{value:{addEntity:h,removeEntity:c,addBillboard:d,removeBillboard:u,addGeoObject:g,removeGeoObject:f,addLabel:p,removeLabel:_,addGeometry:v,removeGeometry:x,addPolyline:y,removePolyline:w,addStrip:b,removeStrip:E}},Fe.createElement(ps,{layerRef:s,name:t,...i},e))},fd=({visibility:a,src:e,size:t,color:i,rotation:r,offset:s,_addBillboard:n,_removeBillboard:o,...l})=>{const h=S.useRef(null);return S.useEffect(()=>{var c;typeof a=="boolean"&&h.current&&((c=h.current)==null||c.setVisibility(a))},[a]),S.useEffect(()=>{var c;typeof e=="string"&&h.current&&((c=h.current)==null||c.setSrc(e))},[e]),S.useEffect(()=>{var c;typeof r=="number"&&h.current&&((c=h.current)==null||c.setRotation(r*Math.PI/180))},[r]),S.useEffect(()=>{var c,d,u;s&&h.current&&(s instanceof m?(c=h.current)==null||c.setOffset(s.x,s.y,s.z):s instanceof N?(d=h.current)==null||d.setOffset(s.x,s.y):(u=h.current)==null||u.setOffset(s[0],s[1],s[2]))},[s]),S.useEffect(()=>{var c;t&&h.current&&((c=h.current)==null||c.setSize(t[0],t[1]))},[t]),S.useEffect(()=>{var c;typeof i=="string"&&h.current&&((c=h.current)==null||c.setColorHTML(i))},[i]),S.useEffect(()=>(h.current=new cn({...l,color:i,size:t,src:e,offset:s,visibility:a,rotation:r?r*Math.PI/180:0}),h.current&&n&&n(h.current),()=>{h.current&&o&&o(h.current)}),[n,o]),null},gd=({color:a,objSrc:e,scale:t,visibility:i,_addGeoObject:r,_removeGeoObject:s,...n})=>{const o=S.useRef(null);return S.useEffect(()=>{var l;t&&o.current&&((l=o.current)==null||l.setScale(t))},[t]),S.useEffect(()=>{var l,h,c;o.current&&(typeof a=="string"?(l=o.current)==null||l.setColorHTML(a):a instanceof te?(h=o.current)==null||h.setColor4v(a):Array.isArray(a)&&((c=o.current)==null||c.setColor(...a)))},[a]),S.useEffect(()=>{var l;e&&o.current&&((l=o.current)==null||l.setObjectSrc(e))},[e]),S.useEffect(()=>{var l;typeof i=="boolean"&&o.current&&((l=o.current)==null||l.setVisibility(i))},[i]),S.useEffect(()=>(o.current=new gn({color:a,objSrc:e,scale:t,visibility:i,...n}),o.current&&r&&r(o.current),()=>{o.current&&s&&s(o.current)}),[r,s]),null},pd=({visibility:a,size:e,color:t,rotation:i,offset:r,text:s,face:n,isRTL:o,align:l,outline:h,outlineColor:c,opacity:d,_addLabel:u,_removeLabel:g,...f})=>{const p=S.useRef(null);return S.useEffect(()=>{var _;typeof a=="boolean"&&p.current&&((_=p.current)==null||_.setVisibility(a))},[a]),S.useEffect(()=>{var _;typeof i=="number"&&p.current&&((_=p.current)==null||_.setRotation(i*Math.PI/180))},[i]),S.useEffect(()=>{var _;typeof e=="number"&&p.current&&((_=p.current)==null||_.setSize(e))},[e]),S.useEffect(()=>{var _;typeof h=="number"&&p.current&&((_=p.current)==null||_.setOutline(h))},[h]),S.useEffect(()=>{var _;typeof d=="number"&&p.current&&((_=p.current)==null||_.setOpacity(d))},[d]),S.useEffect(()=>{var _;typeof o=="boolean"&&p.current&&((_=p.current)==null||_.setRtl(o))},[o]),S.useEffect(()=>{var _,v,x;r&&p.current&&(r instanceof m?(_=p.current)==null||_.setOffset(r.x,r.y,r.z):r instanceof N?(v=p.current)==null||v.setOffset(r.x,r.y):(x=p.current)==null||x.setOffset(r[0],r[1],r[2]))},[r]),S.useEffect(()=>{var _;typeof s=="string"&&p.current&&((_=p.current)==null||_.setText(s))},[s]),S.useEffect(()=>{var _;typeof n=="string"&&p.current&&((_=p.current)==null||_.setFace(n))},[n]),S.useEffect(()=>{var _;typeof l=="string"&&p.current&&((_=p.current)==null||_.setAlign(l))},[l]),S.useEffect(()=>{var _;typeof t=="string"&&p.current&&((_=p.current)==null||_.setColorHTML(t))},[t]),S.useEffect(()=>{var _;typeof c=="string"&&p.current&&((_=p.current)==null||_.setOutlineColorHTML(c))},[c]),S.useEffect(()=>(p.current=new mn({...f,color:t,size:e,text:s,face:n,isRTL:o,align:l,outline:h,outlineColor:c,opacity:d,offset:r,visibility:a,rotation:i?i*Math.PI/180:0}),p.current&&u&&u(p.current),()=>{p.current&&g&&g(p.current)}),[u,g]),null};function md(a){switch(a.type){case"POINT":return Array.isArray(a.coordinates)&&a.coordinates.length>=2&&typeof a.coordinates[0]=="number";case"LINESTRING":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.length>=2&&typeof e[0]=="number");case"POLYGON":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="number"));case"MULTIPOLYGON":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.every(i=>Array.isArray(i)&&i.length>=2&&typeof i[0]=="number")));case"MULTILINESTRING":return Array.isArray(a.coordinates)&&a.coordinates.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="number"));default:return!1}}const vd=a=>{const{visibility:e,fillColor:t,lineColor:i,strokeColor:r,lineWidth:s,strokeWidth:n,type:o,coordinates:l,_addGeometry:h,_removeGeometry:c}=a,d=S.useRef(null);if(!md({type:o,coordinates:l}))throw new Error(`Invalid coordinates for type ${o}`);return S.useEffect(()=>{typeof e=="boolean"&&d.current&&d.current.setVisibility(e)},[e]),S.useEffect(()=>{if(t!==void 0&&d.current){if(t instanceof te)d.current.setFillColor4v(t);else if(Array.isArray(t))d.current.setFillColor(...t);else if(typeof t=="string"&&d.current){const u=Hi.htmlColorToRgba(t);d.current.setFillColor4v(u)}}},[t]),S.useEffect(()=>{if(i!==void 0&&d.current){if(i instanceof te)d.current.setLineColor4v(i);else if(Array.isArray(i))d.current.setLineColor(...i);else if(typeof i=="string"&&d.current){const u=Hi.htmlColorToRgba(i);d.current.setLineColor4v(u)}}},[i]),S.useEffect(()=>{if(r!==void 0&&d.current){if(r instanceof te)d.current.setStrokeColor4v(r);else if(Array.isArray(r))d.current.setStrokeColor(...r);else if(typeof r=="string"&&d.current){const u=Hi.htmlColorToRgba(r);d.current.setStrokeColor4v(u)}}},[r]),S.useEffect(()=>{typeof s=="number"&&d.current&&d.current.setLineWidth(s)},[s]),S.useEffect(()=>{typeof n=="number"&&d.current&&d.current.setStrokeWidth(n)},[n]),S.useEffect(()=>(d.current=new un({...a,type:o,coordinates:l,style:{fillColor:t,lineColor:i,strokeColor:r,lineWidth:s,strokeWidth:n},visibility:e}),d.current&&h&&h(d.current),()=>{d.current&&c&&c(d.current)}),[h,c]),null},Co=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof m,To=a=>Array.isArray(a)&&a.length>0&&(a[0][0]instanceof A||a[0][0]instanceof Array),yd=a=>a.map(e=>e.map(t=>A.createFromArray(t))),xd=a=>typeof a=="string"||Array.isArray(a),Eo=a=>Array.isArray(a)&&a.every(e=>Array.isArray(e)&&e.every(xd)),bd=a=>Array.isArray(a)&&a.every(e=>Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length===4&&t.every(i=>typeof i=="number"))),Ao=a=>Eo(a)?a.map(e=>e.map(t=>{const i=Hi.htmlColorToRgba(t);return[i.x,i.y,i.z,i.w]})):a,wd=({visibility:a,color:e,altitude:t,thickness:i,opacity:r,isClosed:s,pathColors:n,path:o,_addPolyline:l,_removePolyline:h,...c})=>{const d=S.useRef(null);return S.useEffect(()=>{var u;typeof a=="boolean"&&d.current&&((u=d.current)==null||u.setVisibility(a))},[a]),S.useEffect(()=>{var u;typeof e=="string"&&d.current&&((u=d.current)==null||u.setColorHTML(e))},[e]),S.useEffect(()=>{var u;typeof t=="number"&&d.current&&((u=d.current)==null||u.setAltitude(t))},[t]),S.useEffect(()=>{var u;typeof i=="number"&&d.current&&((u=d.current)==null||u.setThickness(i))},[i]),S.useEffect(()=>{var u;typeof r=="number"&&d.current&&((u=d.current)==null||u.setOpacity(r))},[r]),S.useEffect(()=>{var u,g,f;if(d.current&&o!==void 0)if(To(o))(u=d.current)==null||u.setPathLonLat(o);else if(Co(o))(g=d.current)==null||g.setPath3v(o);else{const p=yd(o);p&&((f=d.current)==null||f.setPathLonLat(p))}},[o]),S.useEffect(()=>{var u,g;if(n&&Array.isArray(n)&&n.length>0)if(Eo(n)){const f=Ao(n);f&&((u=d.current)==null||u.setPathColors(f))}else bd(n)&&((g=d.current)==null||g.setPathColors(n))},[n]),S.useEffect(()=>(d.current=new xn({...c,color:e,visibility:a,opacity:r,thickness:i,pathLonLat:o&&To(o)?o:void 0,path3v:o&&Co(o)?o:void 0,pathColors:Ao(n),altitude:t}),d.current&&l&&l(d.current),()=>{d.current&&h&&h(d.current)}),[l,h]),null},Cd=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof m,Td=a=>Array.isArray(a)&&a.length>0&&a[0][0]instanceof A,Lo=(a,e)=>e?Cd(e)?e:Td(e)?e.map(t=>t.map(i=>a.lonLatToCartesian(i))):e.map(t=>t.map(i=>a.lonLatToCartesian(A.createFromArray(i)))):[],Ed=({visibility:a,color:e,opacity:t,path:i,_addStrip:r,_removeStrip:s,...n})=>{const o=S.useRef(null),{globe:l}=dt();return S.useEffect(()=>{var h;typeof a=="boolean"&&o.current&&((h=o.current)==null||h.setVisibility(a))},[a]),S.useEffect(()=>{var h;typeof t=="number"&&o.current&&((h=o.current)==null||h.setOpacity(t))},[t]),S.useEffect(()=>{var h;l&&i!==void 0&&o.current&&((h=o.current)==null||h.setPath(Lo(l.planet.ellipsoid,i)))},[i]),S.useEffect(()=>{var h;typeof e=="string"&&o.current&&((h=o.current)==null||h.setColorHTML(e))},[e]),S.useEffect(()=>(l&&(o.current=new Cn({...n,color:e,visibility:a,path:Lo(l.planet.ellipsoid,i),opacity:t}),o.current&&r&&r(o.current)),()=>{o.current&&s&&s(o.current)}),[r,s,l]),null},Ad=({visibility:a,lon:e,lat:t,alt:i,lonlat:r,name:s,children:n,...o})=>{const{globe:l}=dt(),{addEntity:h,removeEntity:c,addBillboard:d,removeBillboard:u,addGeoObject:g,removeGeoObject:f,addLabel:p,removeLabel:_,addGeometry:v,removeGeometry:x,addPolyline:y,removePolyline:w,addStrip:b,removeStrip:E}=S.useContext(ms),C=S.useRef(null),[T,L]=S.useState(null),[M,R]=S.useState(null),[z,F]=S.useState(null),[P,D]=S.useState(null),[k,I]=S.useState(null),[B,G]=S.useState(null);S.useEffect(()=>{var $;r&&(r instanceof A||(r=A.createFromArray(r)),($=C.current)==null||$.setLonLat(r))},[r,T]),S.useEffect(()=>{var $;s&&(($=C.current)==null||$.setLonLat2(e,t,i))},[e,t,i]),S.useEffect(()=>{var $;typeof a=="boolean"&&C.current&&(($=C.current)==null||$.setVisibility(a))},[a]),S.useEffect(()=>{if(l)return C.current=new V({lonlat:r||new A(e,t,i),name:s,...o}),h(C.current),()=>{l&&C.current&&c(C.current)}},[l,h,c]),S.useEffect(()=>{var $,Be;T&&!(($=C.current)!=null&&$.billboard)&&((Be=C.current)==null||Be.setBillboard(T))},[T]),S.useEffect(()=>{var $,Be;M&&!(($=C.current)!=null&&$.geoObject)&&((Be=C.current)==null||Be.setGeoObject(M))},[M]),S.useEffect(()=>{var $,Be;z&&!(($=C.current)!=null&&$.label)&&((Be=C.current)==null||Be.setLabel(z))},[z]),S.useEffect(()=>{var $,Be;P&&!(($=C.current)!=null&&$.geometry)&&((Be=C.current)==null||Be.setGeometry(P))},[P]),S.useEffect(()=>{var $,Be;k&&!(($=C.current)!=null&&$.polyline)&&((Be=C.current)==null||Be.setPolyline(k))},[k]),S.useEffect(()=>{var $,Be;B&&!(($=C.current)!=null&&$.strip)&&((Be=C.current)==null||Be.setStrip(B))},[B]);const Ve=S.useCallback($=>{L($),C.current&&d(C.current,$)},[d]),ve=S.useCallback(()=>{C.current&&u(C.current),L(null)},[u]),ze=S.useCallback($=>{R($),C.current&&g(C.current,$)},[g]),Re=S.useCallback(()=>{C.current&&f(C.current),R(null)},[f]),ie=S.useCallback($=>{F($),C.current&&p(C.current,$)},[p]),Ue=S.useCallback(()=>{C.current&&_(C.current),R(null)},[_]),De=S.useCallback($=>{D($),C.current&&v(C.current,$)},[v]),Ei=S.useCallback(()=>{C.current&&x(C.current),R(null)},[x]),Ai=S.useCallback($=>{I($),C.current&&y(C.current,$)},[y]),Li=S.useCallback(()=>{C.current&&w(C.current),I(null)},[w]),Pd=S.useCallback($=>{G($),C.current&&b(C.current,$)},[b]),Sd=S.useCallback(()=>{C.current&&E(C.current),G(null)},[E]),Po={_addGeometry:De,_removeGeometry:Ei,_addLabel:ie,_removeLabel:Ue,_addBillboard:Ve,_removeBillboard:ve,_addGeoObject:ze,_removeGeoObject:Re,_addPolyline:Ai,_removePolyline:Li,_addStrip:Pd,_removeStrip:Sd};return n?Fe.createElement(Fe.Fragment,null,Array.isArray(n)?n.map($=>Fe.isValidElement($)?Fe.cloneElement($,Po):$):Fe.isValidElement(n)?Fe.cloneElement(n,Po):n):null},Ld=({lon:a,lat:e,alt:t,lookLon:i,lookLat:r,lookAlt:s,viewAngle:n,...o})=>{const{globe:l}=dt();return S.useEffect(()=>{l&&typeof a=="number"&&typeof e=="number"&&typeof t=="number"&&l.planet.flyLonLat(new A(a,e,t),new A(i,r,s))},[a,e,t,i,r,s,l]),S.useEffect(()=>{l&&typeof n=="number"&&l.planet.camera.setViewAngle(n)},[n,l]),null};ce.Billboard=fd,ce.Entity=Ad,ce.GeoImage=cd,ce.GeoObject=gd,ce.GeoVideo=dd,ce.Geometry=vd,ce.Globe=hd,ce.GlobeContextProvider=Jo,ce.Label=pd,ce.Layer=ps,ce.PlanetCamera=Ld,ce.Polyline=wd,ce.Strip=Ed,ce.Vector=_d,ce.VectorContext=ms,ce.XYZ=ud,ce.useGlobeContext=dt,Object.defineProperty(ce,Symbol.toStringTag,{value:"Module"})});
941
941
  //# sourceMappingURL=index.umd.cjs.map