@openglobus/openglobus-react 0.4.6 → 0.4.7

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.
@@ -89,7 +89,7 @@
89
89
  `,fn=typeof self<"u"&&self.Blob&&new Blob([_n],{type:"text/javascript;charset=utf-8"});function ql(o){let e;try{if(e=fn&&(self.URL||self.webkitURL).createObjectURL(fn),!e)throw"";const t=new Worker(e,{name:o?.name});return t.addEventListener("error",(()=>{(self.URL||self.webkitURL).revokeObjectURL(e)})),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(_n),{name:o?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}class Yl extends Fr{constructor(e=4){super(e,ql)}_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 gn=class nl{constructor(e={}){this.__id=nl.__counter__++,this._position=Ge(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=it(e.color),this._alignedAxis=Ge(e.alignedAxis),this._offset=Ge(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(tt(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}};gn.__counter__=0;let pn=gn;class mn extends pn{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 oi=(o=>(o[o.POINT=1]="POINT",o[o.LINESTRING=2]="LINESTRING",o[o.POLYGON=3]="POLYGON",o[o.MULTIPOLYGON=4]="MULTIPOLYGON",o[o.MULTILINESTRING=5]="MULTILINESTRING",o))(oi||{});const Wl={POINT:1,LINESTRING:2,POLYGON:3,MULTIPOLYGON:4,MULTILINESTRING:5},vn=class It{constructor(e={}){this.__id=It.__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&&It.getType(e.type)||1,this._coordinates=e.coordinates||[],this._extent=It.getExtent({type:e.type||"POINT",coordinates:e.coordinates||[]},this._coordinates),e.style=e.style||{},this._style={fillColor:it(e.style.fillColor,new te(.19,.62,.85,.4)),lineColor:it(e.style.lineColor,new te(.19,.62,.85,1)),strokeColor:it(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 Wl[e.toUpperCase()]}static getExtent(e,t){let i=new j(new P(180,90),new P(-180,-90)),r=It.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 a=s[n][0],l=s[n][1];a<i.southWest.lon&&(i.southWest.lon=a),l<i.southWest.lat&&(i.southWest.lat=l),a>i.northEast.lon&&(i.northEast.lon=a),l>i.northEast.lat&&(i.northEast.lat=l),t&&(t[n]=[a,l])}}else if(r===3){let s=e.coordinates;for(let n=0;n<s.length;n++){let a=s[n];t&&(t[n]=[]);for(let l=0;l<a.length;l++){let h=a[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 a=s[n];t&&(t[n]=[]);for(let l=0;l<a.length;l++){let h=a[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 a=s[n];t&&(t[n]=[]);for(let l=0;l<a.length;l++){let h=a[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=It.getType(e.type||"Point"),this._extent=It.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}};vn.__counter__=0;let yn=vn;class Ze{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,a=t.x,l=t.y,h=t.z,c=i.x-a,d=i.y-l,u=i.z-h,g=c*c+d*d+u*u,f=2*(a*c+l*d+h*u-c*r-d*s-u*n),p=f*f-4*g*(a*a-2*a*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)<et&&Math.abs(s.y)<et&&Math.abs(s.z)<et)return!1;let n=this.p1.sub(this.p0);if(Math.abs(n.x)<et&&Math.abs(n.y)<et&&Math.abs(n.z)<et)return!1;let a=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)<et)return!1;let u=(a*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=(a+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 pe{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 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 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,a=s.y>=0?s.y:-s.y,l=s.z>=0?s.z:-s.z;if(n+a+l<Ms){let u=t.p.sub(e.p);return e.n.dot(u)==0?1:0}r=n>a?n>l?1:3:a>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),a=s.cross(n),l=this.origin.sub(e),h=-a.dot(l),c=a.dot(this.direction);if(Math.abs(c)<et)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)<et)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 a=(-r-n)/(2*i);return a<0&&(a=(-r+n)/(2*i)),a<0?null:m.add(this.origin,this.direction.scaleTo(a))}hitBox(e){}};function Or(o){let e=o.split("/"),t=e[e.length-1],i=e[e.length-2];return`${i?i+"/":""}${t}`}class xn{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}/${Or(t)}`},map_Bump:(e,t)=>{this.material.normalTexture=`${this._path}/${Or(t)}`},map_Ns:(e,t)=>{this.material.metallicRoughnessTexture=`${this._path}/${Or(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],a=n.length,l=this.objVertexData[i][s],h=l.length;this.vertexData[i].length=a+h;for(let c=0;c<h;c++)n[a+c]=l[c]}}_innerParser(e,t){const i=/(\w*)(?: )*(.*)/,r=e.split(`
90
90
  `);for(let s=0;s<r.length;++s){const n=r[s].trim();if(n===""||n.startsWith("#"))continue;const a=i.exec(n);if(!a)continue;const[,l,h]=a,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(),a="";for(;!n;){const h=(a+r.decode(s,{stream:!0})).split(`
91
91
  `);a=h.pop();for(const c of h)this._innerParser(c,e);({value:s,done:n}=await i.read())}a&&this._innerParser(a,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 a=(n+i.decode(r,{stream:!0})).split(`
92
- `);n=a.pop();for(const l of a)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 Ut(o){let e=new Float32Array([1,1,1]);if(o instanceof Array)e[0]=o[0],e[1]=o[1],e[2]=o[2];else if(typeof o=="string"){let t=gt(o);e[0]=t[0],e[1]=t[1],e[2]=t[2]}return e}class ${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"?gt(t):new Float32Array([.5,.5,.5,1]),this.ambient=Ut(e.ambient),this.diffuse=Ut(e.diffuse),this.specular=Ut(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,$.scale(this._vertices,i)}if(e.center&&$.centering(this._vertices),this.center=$.getCenter(this._vertices),e.indices)this._indices=e.indices,this._normals=e.normals||[];else{this._normals=e.normals||$.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=be,i=be,r=be,s=Ae,n=Ae,a=Ae;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>a&&(a=u)}return new m(t+.5*(s-t),i+.5*(n-i),r+.5*(a-r))}static centering(e){let t=$.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=Ut(e.ambient)),e.diffuse&&(this.diffuse=Ut(e.diffuse)),e.specular&&(this.specular=Ut(e.specular)),e.shininess!==void 0&&(this.shininess=e.shininess),this}centering(){return $.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 $.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,a=-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>a&&(a=d)}return[t+.5*(s-t),i+.5*(n-i),r+.5*(a-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,a=e[r],l=e[r+1],h=e[r+2],c=e[s]-a,d=e[s+1]-l,u=e[s+2]-h,g=e[n]-a,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 a=[],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),a.push(i*v),a.push(i*x),a.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 $({vertices:a,normals:h,indices:l})}static createDisc(e=1,t=0,i=8,r=!0,s=0,n=0,a=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+a,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+a,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 $({vertices:h,normals:d,indices:c})}static getFrustumScaleByCameraAngles(e,t,i){return new m(2*e*Math.tan($e*t),2*e*Math.tan($e*i),e)}static getFrustumScaleByCameraAspectRatio(e,t,i){let r=or*Math.atan(Math.tan($e*t)/i);return $.getFrustumScaleByCameraAngles(e,t,r)}static createFrustum(e=1,t=1,i=1,r=0,s=0,n=0){return new $({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,a=!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,C=b*(t-e)+e;for(let E=0;E<=r;E++){let T=E/r*f+0,L=Math.sin(T),S=Math.cos(T);d.push(C*L+l,-b*i+i+h,C*S+c),v.set(L,x,S).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],C=_[w+1][y],E=_[w+1][y+1],T=_[w][y+1];u.push(b,C,T),u.push(C,E,T)}if(e!==0&&n){let y=$.createDisc(e,i,r,!0,p,l,h,c);d.push(...y.vertices),g.push(...y.normals),u.push(...y.indices)}if(t!==0&&a){let y=$.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 $({vertices:d,normals:g,indices:u})}static createCube(e=1,t=1,i=1,r=0,s=0,n=0){let a=.5*e+r,l=.5*t+s,h=.5*i+n;return new $({vertices:[-a,-l,h,a,-l,-h,a,-l,h,-a,-l,h,-a,-l,-h,a,-l,-h,-a,l,h,a,l,h,a,l,-h,-a,l,h,a,l,-h,-a,l,-h,-a,-l,h,a,-l,h,-a,l,h,-a,l,h,a,-l,h,a,l,h,-a,-l,-h,-a,l,-h,a,-l,-h,-a,l,-h,a,l,-h,a,-l,-h,a,-l,h,a,-l,-h,a,l,h,a,l,h,a,-l,-h,a,l,-h,-a,-l,h,-a,l,h,-a,-l,-h,-a,l,h,-a,l,-h,-a,-l,-h]})}static createPlane(e=1,t=1,i=0,r=0,s=0){let n=.5*e,a=.5*t;return new $({vertices:[-n+i,r,a+s,n+i,r,-a+s,n+i,r,a+s,-n+i,r,a+s,-n+i,r,-a+s,n+i,r,-a+s,-n+i,r,a+s,n+i,r,a+s,n+i,r,-a+s,-n+i,r,a+s,n+i,r,-a+s,-n+i,r,-a+s]})}static createArrow(e=0,t=2.1,i=-15){return new $({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 xn().readFile(e,t);let s=r.materials;return r.geometries.map((n=>{let a=s[n.material]||{};return new $({name:n.object,vertices:n.data.vertices,normals:n.data.normals,texCoords:n.data.texCoords,ambient:a.ambient,diffuse:a.diffuse,specular:a.specular,shininess:a.shininess,color:a.color,colorTextureSrc:i?`${i}/${a.colorTexture}`:a.colorTexture,normalTextureSrc:i?`${i}/${a.normalTexture}`:a.normalTexture,metallicRoughnessTextureSrc:i?`${i}/${a.metallicRoughnessTexture}`:a.metallicRoughnessTexture})}))}static async loadObj(e){const t=await new xn().load(e);let i=t.materials;return t.geometries.map((r=>{let s=i[r.material]||{};return new $({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 $,r=t||e.length;for(let s=0;s<r;s++)i.merge(e[s]);return i}}const $l=new m(0,0,-1),bn=class al{constructor(e){var t,i;this._handlerIndex=-1,this._tag=e.tag||"tag_"+al.__counter__++,this._entity=null,this._position=Ge(e.position),this._rtcPositionHigh=new m,this._rtcPositionLow=new m,this._scale=Ge(e.scale,new m(1,1,1)),this._translate=Ge(e.translate,new m),this._localPosition=new m;const[r=.15,s=.15,n=.15,a=1]=(t=e.object3d)!=null&&t.color?Array.from(e.object3d.color):[];this._color=it(e.color,new te(r,s,n,a)),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 $),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(tt(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($l,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()}};bn.__counter__=0;let wn=bn;const li={RIGHT:0,LEFT:1,CENTER:2},Cn={left:li.LEFT,right:li.RIGHT,center:li.CENTER};class Tn extends pn{constructor(e={}){super(e),this._handler=null,this._text=e.text||"",this._face=js(e.face,"arial"),this._size=e.size||24,this._outline=e.outline!=null?e.outline:0,this._outlineColor=it(e.outlineColor,new te(0,0,0,1)),this._align=e.align&&Cn[e.align.trim().toLowerCase()]||li.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=Cn[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(tt(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 En=class ol{constructor(e={}){this.__id=ol.__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}}};En.__counter__=0;let Xl=En;const An=class Es{constructor(e={}){this.__id=Es.__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=gt(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?Er(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=Ge(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,a,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 C=x[0],E=x[1]||C;C instanceof Array&&(C=new m(C[0],C[1],C[2])),E instanceof Array&&(E=new m(E[0],E[1],E[2])),w=new m(C.x+C.x-E.x,C.y+C.y-E.y,C.z+C.z-E.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 B=F[0],D=F[1],A=F[2],I=F[3]!=null?F[3]:1;R>0&&f.push(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.push(1,-1,2,-2);for(let k=0,U=x.length;k<U;k++){var T=x[k];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[k]&&(F=y[k]),B=F[0],D=F[1],A=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(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.push(1,-1,2,-2),l.push(p++,p++,p++,p++)}var S;if(r)(S=x[0])instanceof Array&&(S=new m(S[0],S[1],S[2])),l.push(b,b+1,b+1,b+1);else{let k=x[x.length-1],U=x[x.length-2]||k;k instanceof Array&&(k=new m(k[0],k[1],k[2])),U instanceof Array&&(U=new m(U[0],U[1],U[2])),S=new m(k.x+k.x-U.x,k.y+k.y-U.y,k.z+k.z-U.z),l.push(p-1,p-1,p-1,p-1)}y&&y[x.length-1]&&(F=y[x.length-1]),B=F[0],D=F[1],A=F[2],I=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(S,_,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(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.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,a,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],C=r[1],E=r[2],T=r[3]!=null?r[3]:1,L=i[e.length-1];if(L[w]?(L[w][0]=b,L[w][1]=C,L[w][2]=E,L[w][3]=T):L.push(r),w===1){var S;if(s)(S=y[w-1])instanceof Array&&(S=new m(S[0],S[1],S[2]));else{let k=y[0],U=y[1]||k;k instanceof Array&&(k=new m(k[0],k[1],k[2])),U instanceof Array&&(U=new m(U[0],U[1],U[2])),S=new m(k.x+k.x-U.x,k.y+k.y-U.y,k.z+k.z-U.z)}this.__doubleToTwoFloats(S,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,a[I]=_.x,a[I+1]=_.y,a[I+2]=_.z,a[I+3]=_.x,a[I+4]=_.y,a[I+5]=_.z,a[I+6]=_.x,a[I+7]=_.y,a[I+8]=_.z,a[I+9]=_.x,a[I+10]=_.y,a[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 B=n.length-12;n[B]=p.x,n[B+1]=p.y,n[B+2]=p.z,n[B+3]=p.x,n[B+4]=p.y,n[B+5]=p.z,n[B+6]=p.x,n[B+7]=p.y,n[B+8]=p.z,n[B+9]=p.x,n[B+10]=p.y,n[B+11]=p.z,a[B]=_.x,a[B+1]=_.y,a[B+2]=_.z,a[B+3]=_.x,a[B+4]=_.y,a[B+5]=_.z,a[B+6]=_.x,a[B+7]=_.y,a[B+8]=_.z,a[B+9]=_.x,a[B+10]=_.y,a[B+11]=_.z;let D=l.length-16;var A;if(l[D]=b,l[D+1]=C,l[D+2]=E,l[D+3]=T,l[D+4]=b,l[D+5]=C,l[D+6]=E,l[D+7]=T,l[D+8]=b,l[D+9]=C,l[D+10]=E,l[D+11]=T,l[D+12]=b,l[D+13]=C,l[D+14]=E,l[D+15]=T,c[v]=x++,c[v+1]=x++,c[v+2]=x++,c[v+3]=x++,s)A=y[0],c.push(R,R+1,R+1,R+1);else{let I=y[y.length-1],k=y[y.length-2]||I;A=new m(I.x+I.x-k.x,I.y+I.y-k.y,I.z+I.z-k.z),c.push(x-1,x-1,x-1,x-1)}this.__doubleToTwoFloats(A,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),a.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),l.push(b,C,E,T,b,C,E,T,b,C,E,T,b,C,E,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 a=s[p];a instanceof Array&&(a=new P(a[0],a[1],a[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,a,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,S=e.length;L<S;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 A=x[x.length-1];w=A instanceof Array?h.lonLatToCartesian(new P(A[0],A[1],A[2])):h.lonLatToCartesian(A)}else{let A,I,k=x[0];A=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),k=x[1],k||(k=x[0]),I=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),w=new m(A.x+A.x-I.x,A.y+A.y-I.y,A.z+A.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],B=R[2],D=R[3]!=null?R[3]:1;L>0&&f.push(z,F,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.push(1,-1,2,-2);for(let A=0,I=x.length;A<I;A++){var C=x[A];C instanceof Array&&(C=new P(C[0],C[1],C[2])),y&&y[A]&&(R=y[A]),z=R[0],F=R[1],B=R[2],D=R[3]!=null?R[3]:1;var E=h.lonLatToCartesian(C);c[L].push(E),d[L].push(C),u[L].push(C.forwardMercator()),this.__doubleToTwoFloats(E,_,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,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.push(1,-1,2,-2),l.push(p++,p++,p++,p++),C.lon<g.southWest.lon&&(g.southWest.lon=C.lon),C.lat<g.southWest.lat&&(g.southWest.lat=C.lat),C.lon>g.northEast.lon&&(g.northEast.lon=C.lon),C.lat>g.northEast.lat&&(g.northEast.lat=C.lat)}var T;if(r){let A=x[0];T=A instanceof Array?h.lonLatToCartesian(new P(A[0],A[1],A[2])):h.lonLatToCartesian(A),l.push(b,b+1,b+1,b+1)}else{let A,I,k=x[x.length-1];A=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),k=x[x.length-2],k||(k=x[0]),I=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),T=new m(A.x+A.x-I.x,A.y+A.y-I.y,A.z+A.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],B=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,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.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,a=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]=_,a[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,a=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(),a[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,a=s[d].lat;n>r.northEast.lon&&(r.northEast.lon=n),a>r.northEast.lat&&(r.northEast.lat=a),n<r.southWest.lon&&(r.southWest.lon=n),a<r.southWest.lat&&(r.southWest.lat=a)}}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,a=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 C=this._closedLine||b.length===1;var g;if((t===0||t===1)&&(g=C?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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.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 E=0;E<c.length;E++){var _=c[E];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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.z,t===b.length-1||t===b.length-2){var y;if(C)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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.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 a=[].concat(this._pathColors);if(n.splice(t,0,e),i){let l=a[r];l||(l=new Array(n.length)),l.splice(t,0,i)}this.setPath3v(s,a)}else this.addPoint3v(e,r)}appendPoint3v(e,t,i){this._path3v.length!==0&&this._renderNode?(this._verticesHigh=Ht(this._verticesHigh),this._verticesLow=Ht(this._verticesLow),this._colors=Ht(this._colors),this._orders=Ht(this._orders),this._indexes=Ht(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),Es.setPathColors(this._pathLonLat,e,this._defaultColor,this._colors),this._changedBuffers[2]=!0)}setColorHTML(e){this._defaultColor=gt(e);let t=tt(e),i=this._pathColors;for(let s=0,n=i.length;s<n;s++){let a=i[s];for(let l=0,h=a.length;l<h;l++)a[l][0]=t.x,a[l][1]=t.y,a[l][2]=t.z,a[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,a=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,a.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*a._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,a=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,a.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*a.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=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}};An.__counter__=0;let Ln=An;const Pn=class ll{constructor(e={}){this.__id=ll.__counter__++,this._thickness=e.thickness||2,this._startPosition=Ge(e.startPosition),this._startPositionHigh=new m,this._startPositionLow=new m,m.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._endPosition=Ge(e.endPosition),this._endPositionHigh=new m,this._endPositionLow=new m,m.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._startColor=it(e.startColor),this._endColor=it(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=tt(e)),t&&(this._endColor=tt(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)}};Pn.__counter__=0;let Zl=Pn,me=new m,ve=new m;const Sn=class hl{constructor(e={}){if(this.__id=hl.__counter__++,this.visibility=e.visibility==null||e.visibility,this.color=new Float32Array([1,1,1,.5]),e.color){let t=it(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(tt(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,a=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 Ze(_,v).intersects(new Ze(w,b),c):c=b,u=d+f*h+x,m.doubleToTwoFloats(c,me,ve);let C=3*u;n[C]=me.x,n[C+1]=me.y,n[C+2]=me.z,a[C]=ve.x,a[C+1]=ve.y,a[C+2]=ve.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,a=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),C=e.lerp(t,w);f!==1?new Ze(v,x).intersects(new Ze(b,C),a):a=C,g=u+p*s+y,m.doubleToTwoFloats(a,me,ve);let E=3*g;l[E]=me.x,l[E+1]=me.y,l[E+2]=me.z,h[E]=ve.x,h[E+1]=ve.y,h[E+2]=ve.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 Ze(p,_).intersects(new Ze(y,w),a),c=g*s+v,m.doubleToTwoFloats(a,me,ve);let b=3*c;l[b]=me.x,l[b+1]=me.y,l[b+2]=me.z,h[b]=ve.x,h[b+1]=ve.y,h[b+2]=ve.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),C=d.lerp(t,x);for(let E=0;E<s;E++){let T=E/r,L=c.lerp(d,T),S=e.lerp(t,T);new Ze(y,C).intersects(new Ze(L,S),a);let R=v*s+E;_=p+R,m.doubleToTwoFloats(a,me,ve);let z=3*_;l[z]=me.x,l[z+1]=me.y,l[z+2]=me.z,h[z]=ve.x,h[z+1]=ve.y,h[z+2]=ve.z;let F=u.lerp(g,T);S=e.lerp(t,T),new Ze(b,w).intersects(new Ze(S,F),a),_=f+R,m.doubleToTwoFloats(a,me,ve),z=3*_,l[z]=me.x,l[z+1]=me.y,l[z+2]=me.z,h[z]=ve.x,h[z+1]=ve.y,h[z+2]=ve.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)}};Sn.__counter__=0;let Mn=Sn;const Rn=class cl{constructor(e={}){e.properties=e.properties||{},this.__id=cl.__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=Ge(e.cartesian),this._rootCartesian=new m,this._localPosition=Ge(e.localPosition),this._absoluteLocalPosition=new m,this._lonLat=Ui(e.lonlat),this._lonLatMerc=new P,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=Ge(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:[mn,this.setBillboard],label:[Tn,this.setLabel],polyline:[Ln,this.setPolyline],pointCloud:[Xl,this.setPointCloud],geometry:[yn,this.setGeometry],geoObject:[wn,this.setGeoObject],strip:[Mn,this.setStrip],ray:[Zl,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]*ki(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 P(t.lon,t.lat),new P(t.lon,t.lat)):new j(new P(180,90),new P(-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}};Rn.__counter__=0;let V=Rn;const Bn=class dl{constructor(e){this.__id=dl.__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}};Bn.__counter__=0;let Ql=Bn;class at extends Ql{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(o){this._visibility!=o&&(this._visibility=o,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(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-error"),e.innerHTML="error: "+o,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}logWrn(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-warning"),e.innerHTML="warning: "+o,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}log(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.innerHTML=o,console.trace(o),this._container.appendChild(e),this.show()}};let hi=["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 o=0;o<hi.length;o++)ue[hi[o]]=o;const Nr={};for(let o=0;o<hi.length;o++)Nr[hi[o].toLowerCase()]=ue[hi[o]];const Me={u:[],a:[]};Me.u[ue.MAT4]=function(o,e){o.gl.uniformMatrix4fv(e._pName,!1,e.value)},Me.u[ue.MAT3]=function(o,e){o.gl.uniformMatrix3fv(e._pName,!1,e.value)},Me.u[ue.FLOAT]=function(o,e){o.gl.uniform1f(e._pName,e.value)},Me.u[ue.INT]=function(o,e){o.gl.uniform1i(e._pName,e.value)},Me.u[ue.VEC2]=function(o,e){o.gl.uniform2fv(e._pName,e.value)},Me.u[ue.VEC3]=function(o,e){o.gl.uniform3fv(e._pName,e.value)},Me.u[ue.VEC4]=function(o,e){o.gl.uniform4fv(e._pName,e.value)},Me.u[ue.SAMPLER2D]=function(o,e){let t=o.gl;t.activeTexture(t.TEXTURE0+o._textureID),t.bindTexture(t.TEXTURE_2D,e.value),t.uniform1i(e._pName,o._textureID),o._textureID++},Me.u[ue.SAMPLERCUBE]=function(o,e){let t=o.gl;t.activeTexture(t.TEXTURE0+o._textureID),t.bindTexture(t.TEXTURE_CUBE_MAP,e.value),t.uniform1i(e._pName,o._textureID),o._textureID++},Me.u[ue.SAMPLER2DARRAY]=function(o,e){let t=e.value,i=o.gl,r=t.length,s=new Int32Array(r);for(let n=0;n<r;n++)i.activeTexture(i.TEXTURE0+o._textureID+n),i.bindTexture(i.TEXTURE_2D,t[n]),s[n]=n;i.uniform1iv(e._pName,s)},Me.u[ue.INTXX]=function(o,e){o.gl.uniform1iv(e._pName,e.value)},Me.u[ue.FLOATXX]=function(o,e){o.gl.uniform1fv(e._pName,e.value)},Me.a[ue.FLOAT]=function(o,e){o.gl.vertexAttrib1f(e._pName,e.value)},Me.a[ue.VEC2]=function(o,e){o.gl.vertexAttrib2fv(e._pName,e.value)},Me.a[ue.VEC3]=function(o,e){o.gl.vertexAttrib3fv(e._pName,e.value)};const Kl=["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(`
92
+ `);n=a.pop();for(const l of a)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 Ut(o){let e=new Float32Array([1,1,1]);if(o instanceof Array)e[0]=o[0],e[1]=o[1],e[2]=o[2];else if(typeof o=="string"){let t=gt(o);e[0]=t[0],e[1]=t[1],e[2]=t[2]}return e}class ${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"?gt(t):new Float32Array([.5,.5,.5,1]),this.ambient=Ut(e.ambient),this.diffuse=Ut(e.diffuse),this.specular=Ut(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,$.scale(this._vertices,i)}if(e.center&&$.centering(this._vertices),this.center=$.getCenter(this._vertices),e.indices)this._indices=e.indices,this._normals=e.normals||[];else{this._normals=e.normals||$.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=be,i=be,r=be,s=Ae,n=Ae,a=Ae;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>a&&(a=u)}return new m(t+.5*(s-t),i+.5*(n-i),r+.5*(a-r))}static centering(e){let t=$.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=Ut(e.ambient)),e.diffuse&&(this.diffuse=Ut(e.diffuse)),e.specular&&(this.specular=Ut(e.specular)),e.shininess!==void 0&&(this.shininess=e.shininess),this}centering(){return $.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 $.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,a=-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>a&&(a=d)}return[t+.5*(s-t),i+.5*(n-i),r+.5*(a-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,a=e[r],l=e[r+1],h=e[r+2],c=e[s]-a,d=e[s+1]-l,u=e[s+2]-h,g=e[n]-a,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 a=[],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),a.push(i*v),a.push(i*x),a.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 $({vertices:a,normals:h,indices:l})}static createDisc(e=1,t=0,i=8,r=!0,s=0,n=0,a=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+a,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+a,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 $({vertices:h,normals:d,indices:c})}static getFrustumScaleByCameraAngles(e,t,i){return new m(2*e*Math.tan($e*t),2*e*Math.tan($e*i),e)}static getFrustumScaleByCameraAspectRatio(e,t,i){let r=or*Math.atan(Math.tan($e*t)/i);return $.getFrustumScaleByCameraAngles(e,t,r)}static createFrustum(e=1,t=1,i=1,r=0,s=0,n=0){return new $({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,a=!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,C=b*(t-e)+e;for(let E=0;E<=r;E++){let T=E/r*f+0,L=Math.sin(T),S=Math.cos(T);d.push(C*L+l,-b*i+i+h,C*S+c),v.set(L,x,S).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],C=_[w+1][y],E=_[w+1][y+1],T=_[w][y+1];u.push(b,C,T),u.push(C,E,T)}if(e!==0&&n){let y=$.createDisc(e,i,r,!0,p,l,h,c);d.push(...y.vertices),g.push(...y.normals),u.push(...y.indices)}if(t!==0&&a){let y=$.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 $({vertices:d,normals:g,indices:u})}static createCube(e=1,t=1,i=1,r=0,s=0,n=0){let a=.5*e+r,l=.5*t+s,h=.5*i+n;return new $({vertices:[-a,-l,h,a,-l,-h,a,-l,h,-a,-l,h,-a,-l,-h,a,-l,-h,-a,l,h,a,l,h,a,l,-h,-a,l,h,a,l,-h,-a,l,-h,-a,-l,h,a,-l,h,-a,l,h,-a,l,h,a,-l,h,a,l,h,-a,-l,-h,-a,l,-h,a,-l,-h,-a,l,-h,a,l,-h,a,-l,-h,a,-l,h,a,-l,-h,a,l,h,a,l,h,a,-l,-h,a,l,-h,-a,-l,h,-a,l,h,-a,-l,-h,-a,l,h,-a,l,-h,-a,-l,-h]})}static createPlane(e=1,t=1,i=0,r=0,s=0){let n=.5*e,a=.5*t;return new $({vertices:[-n+i,r,a+s,n+i,r,-a+s,n+i,r,a+s,-n+i,r,a+s,-n+i,r,-a+s,n+i,r,-a+s,-n+i,r,a+s,n+i,r,a+s,n+i,r,-a+s,-n+i,r,a+s,n+i,r,-a+s,-n+i,r,-a+s]})}static createArrow(e=0,t=2.1,i=-15){return new $({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 xn().readFile(e,t);let s=r.materials;return r.geometries.map((n=>{let a=s[n.material]||{};return new $({name:n.object,vertices:n.data.vertices,normals:n.data.normals,texCoords:n.data.texCoords,ambient:a.ambient,diffuse:a.diffuse,specular:a.specular,shininess:a.shininess,color:a.color,colorTextureSrc:i?`${i}/${a.colorTexture}`:a.colorTexture,normalTextureSrc:i?`${i}/${a.normalTexture}`:a.normalTexture,metallicRoughnessTextureSrc:i?`${i}/${a.metallicRoughnessTexture}`:a.metallicRoughnessTexture})}))}static async loadObj(e){const t=await new xn().load(e);let i=t.materials;return t.geometries.map((r=>{let s=i[r.material]||{};return new $({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 $,r=t||e.length;for(let s=0;s<r;s++)i.merge(e[s]);return i}}const $l=new m(0,0,-1),bn=class al{constructor(e){var t,i;this._handlerIndex=-1,this._tag=e.tag||"tag_"+al.__counter__++,this._entity=null,this._position=Ge(e.position),this._rtcPositionHigh=new m,this._rtcPositionLow=new m,this._scale=Ge(e.scale,new m(1,1,1)),this._translate=Ge(e.translate,new m),this._localPosition=new m;const[r=.15,s=.15,n=.15,a=1]=(t=e.object3d)!=null&&t.color?Array.from(e.object3d.color):[];this._color=it(e.color,new te(r,s,n,a)),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 $),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(tt(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($l,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()}};bn.__counter__=0;let wn=bn;const li={RIGHT:0,LEFT:1,CENTER:2},Cn={left:li.LEFT,right:li.RIGHT,center:li.CENTER};class Tn extends pn{constructor(e={}){super(e),this._handler=null,this._text=e.text||"",this._face=js(e.face,"arial"),this._size=e.size||24,this._outline=e.outline!=null?e.outline:0,this._outlineColor=it(e.outlineColor,new te(0,0,0,1)),this._align=e.align&&Cn[e.align.trim().toLowerCase()]||li.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=Cn[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(tt(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 En=class ol{constructor(e={}){this.__id=ol.__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}}};En.__counter__=0;let Xl=En;const An=class Es{constructor(e={}){this.__id=Es.__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=gt(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?Er(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=Ge(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,a,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 C=x[0],E=x[1]||C;C instanceof Array&&(C=new m(C[0],C[1],C[2])),E instanceof Array&&(E=new m(E[0],E[1],E[2])),w=new m(C.x+C.x-E.x,C.y+C.y-E.y,C.z+C.z-E.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 B=F[0],D=F[1],A=F[2],I=F[3]!=null?F[3]:1;R>0&&f.push(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.push(1,-1,2,-2);for(let k=0,U=x.length;k<U;k++){var T=x[k];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[k]&&(F=y[k]),B=F[0],D=F[1],A=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(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.push(1,-1,2,-2),l.push(p++,p++,p++,p++)}var S;if(r)(S=x[0])instanceof Array&&(S=new m(S[0],S[1],S[2])),l.push(b,b+1,b+1,b+1);else{let k=x[x.length-1],U=x[x.length-2]||k;k instanceof Array&&(k=new m(k[0],k[1],k[2])),U instanceof Array&&(U=new m(U[0],U[1],U[2])),S=new m(k.x+k.x-U.x,k.y+k.y-U.y,k.z+k.z-U.z),l.push(p-1,p-1,p-1,p-1)}y&&y[x.length-1]&&(F=y[x.length-1]),B=F[0],D=F[1],A=F[2],I=F[3]!=null?F[3]:1,this.__doubleToTwoFloats(S,_,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(B,D,A,I,B,D,A,I,B,D,A,I,B,D,A,I),a.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,a,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],C=r[1],E=r[2],T=r[3]!=null?r[3]:1,L=i[e.length-1];if(L[w]?(L[w][0]=b,L[w][1]=C,L[w][2]=E,L[w][3]=T):L.push(r),w===1){var S;if(s)(S=y[w-1])instanceof Array&&(S=new m(S[0],S[1],S[2]));else{let k=y[0],U=y[1]||k;k instanceof Array&&(k=new m(k[0],k[1],k[2])),U instanceof Array&&(U=new m(U[0],U[1],U[2])),S=new m(k.x+k.x-U.x,k.y+k.y-U.y,k.z+k.z-U.z)}this.__doubleToTwoFloats(S,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,a[I]=_.x,a[I+1]=_.y,a[I+2]=_.z,a[I+3]=_.x,a[I+4]=_.y,a[I+5]=_.z,a[I+6]=_.x,a[I+7]=_.y,a[I+8]=_.z,a[I+9]=_.x,a[I+10]=_.y,a[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 B=n.length-12;n[B]=p.x,n[B+1]=p.y,n[B+2]=p.z,n[B+3]=p.x,n[B+4]=p.y,n[B+5]=p.z,n[B+6]=p.x,n[B+7]=p.y,n[B+8]=p.z,n[B+9]=p.x,n[B+10]=p.y,n[B+11]=p.z,a[B]=_.x,a[B+1]=_.y,a[B+2]=_.z,a[B+3]=_.x,a[B+4]=_.y,a[B+5]=_.z,a[B+6]=_.x,a[B+7]=_.y,a[B+8]=_.z,a[B+9]=_.x,a[B+10]=_.y,a[B+11]=_.z;let D=l.length-16;var A;if(l[D]=b,l[D+1]=C,l[D+2]=E,l[D+3]=T,l[D+4]=b,l[D+5]=C,l[D+6]=E,l[D+7]=T,l[D+8]=b,l[D+9]=C,l[D+10]=E,l[D+11]=T,l[D+12]=b,l[D+13]=C,l[D+14]=E,l[D+15]=T,c[v]=x++,c[v+1]=x++,c[v+2]=x++,c[v+3]=x++,s)A=y[0],c.push(R,R+1,R+1,R+1);else{let I=y[y.length-1],k=y[y.length-2]||I;A=new m(I.x+I.x-k.x,I.y+I.y-k.y,I.z+I.z-k.z),c.push(x-1,x-1,x-1,x-1)}this.__doubleToTwoFloats(A,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),a.push(_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z,_.x,_.y,_.z),l.push(b,C,E,T,b,C,E,T,b,C,E,T,b,C,E,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 a=s[p];a instanceof Array&&(a=new P(a[0],a[1],a[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,a,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,S=e.length;L<S;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 A=x[x.length-1];w=A instanceof Array?h.lonLatToCartesian(new P(A[0],A[1],A[2])):h.lonLatToCartesian(A)}else{let A,I,k=x[0];A=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),k=x[1],k||(k=x[0]),I=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),w=new m(A.x+A.x-I.x,A.y+A.y-I.y,A.z+A.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],B=R[2],D=R[3]!=null?R[3]:1;L>0&&f.push(z,F,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.push(1,-1,2,-2);for(let A=0,I=x.length;A<I;A++){var C=x[A];C instanceof Array&&(C=new P(C[0],C[1],C[2])),y&&y[A]&&(R=y[A]),z=R[0],F=R[1],B=R[2],D=R[3]!=null?R[3]:1;var E=h.lonLatToCartesian(C);c[L].push(E),d[L].push(C),u[L].push(C.forwardMercator()),this.__doubleToTwoFloats(E,_,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,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.push(1,-1,2,-2),l.push(p++,p++,p++,p++),C.lon<g.southWest.lon&&(g.southWest.lon=C.lon),C.lat<g.southWest.lat&&(g.southWest.lat=C.lat),C.lon>g.northEast.lon&&(g.northEast.lon=C.lon),C.lat>g.northEast.lat&&(g.northEast.lat=C.lat)}var T;if(r){let A=x[0];T=A instanceof Array?h.lonLatToCartesian(new P(A[0],A[1],A[2])):h.lonLatToCartesian(A),l.push(b,b+1,b+1,b+1)}else{let A,I,k=x[x.length-1];A=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),k=x[x.length-2],k||(k=x[0]),I=k instanceof Array?h.lonLatToCartesian(new P(k[0],k[1],k[2])):h.lonLatToCartesian(k),T=new m(A.x+A.x-I.x,A.y+A.y-I.y,A.z+A.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],B=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,B,D,z,F,B,D,z,F,B,D,z,F,B,D),a.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,a=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]=_,a[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,a=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(),a[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,a=s[d].lat;n>r.northEast.lon&&(r.northEast.lon=n),a>r.northEast.lat&&(r.northEast.lat=a),n<r.southWest.lon&&(r.southWest.lon=n),a<r.southWest.lat&&(r.southWest.lat=a)}}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,a=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 C=this._closedLine||b.length===1;var g;if((t===0||t===1)&&(g=C?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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.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 E=0;E<c.length;E++){var _=c[E];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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.z,t===b.length-1||t===b.length-2){var y;if(C)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,a),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]=a.x,h[u+1]=a.y,h[u+2]=a.z,h[u+3]=a.x,h[u+4]=a.y,h[u+5]=a.z,h[u+6]=a.x,h[u+7]=a.y,h[u+8]=a.z,h[u+9]=a.x,h[u+10]=a.y,h[u+11]=a.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 a=[].concat(this._pathColors);if(n.splice(t,0,e),i){let l=a[r];l||(l=new Array(n.length)),l.splice(t,0,i)}this.setPath3v(s,a)}else this.addPoint3v(e,r)}appendPoint3v(e,t,i){this._path3v.length!==0&&this._renderNode?(this._verticesHigh=Ht(this._verticesHigh),this._verticesLow=Ht(this._verticesLow),this._colors=Ht(this._colors),this._orders=Ht(this._orders),this._indexes=Ht(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),Es.setPathColors(this._pathLonLat,e,this._defaultColor,this._colors),this._changedBuffers[2]=!0)}setColorHTML(e){this._defaultColor=gt(e);let t=tt(e),i=this._pathColors;for(let s=0,n=i.length;s<n;s++){let a=i[s];for(let l=0,h=a.length;l<h;l++)a[l][0]=t.x,a[l][1]=t.y,a[l][2]=t.z,a[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,a=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,a.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*a._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,a=this._handler._entityCollection;t.activate(),r.disable(r.CULL_FACE),r.uniform1f(n.depthOffset,a.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*a.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=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}};An.__counter__=0;let Ln=An;const Pn=class ll{constructor(e={}){this.__id=ll.__counter__++,this._thickness=e.thickness||2,this._startPosition=Ge(e.startPosition),this._startPositionHigh=new m,this._startPositionLow=new m,m.doubleToTwoFloats(this._startPosition,this._startPositionHigh,this._startPositionLow),this._endPosition=Ge(e.endPosition),this._endPositionHigh=new m,this._endPositionLow=new m,m.doubleToTwoFloats(this._endPosition,this._endPositionHigh,this._endPositionLow),this._startColor=it(e.startColor),this._endColor=it(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=tt(e)),t&&(this._endColor=tt(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)}};Pn.__counter__=0;let Zl=Pn,me=new m,ve=new m;const Sn=class hl{constructor(e={}){if(this.__id=hl.__counter__++,this.visibility=e.visibility==null||e.visibility,this.color=new Float32Array([1,1,1,.5]),e.color){let t=it(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(tt(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,a=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 Ze(_,v).intersects(new Ze(w,b),c):c=b,u=d+f*h+x,m.doubleToTwoFloats(c,me,ve);let C=3*u;n[C]=me.x,n[C+1]=me.y,n[C+2]=me.z,a[C]=ve.x,a[C+1]=ve.y,a[C+2]=ve.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,a=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),C=e.lerp(t,w);f!==1?new Ze(v,x).intersects(new Ze(b,C),a):a=C,g=u+p*s+y,m.doubleToTwoFloats(a,me,ve);let E=3*g;l[E]=me.x,l[E+1]=me.y,l[E+2]=me.z,h[E]=ve.x,h[E+1]=ve.y,h[E+2]=ve.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 Ze(p,_).intersects(new Ze(y,w),a),c=g*s+v,m.doubleToTwoFloats(a,me,ve);let b=3*c;l[b]=me.x,l[b+1]=me.y,l[b+2]=me.z,h[b]=ve.x,h[b+1]=ve.y,h[b+2]=ve.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),C=d.lerp(t,x);for(let E=0;E<s;E++){let T=E/r,L=c.lerp(d,T),S=e.lerp(t,T);new Ze(y,C).intersects(new Ze(L,S),a);let R=v*s+E;_=p+R,m.doubleToTwoFloats(a,me,ve);let z=3*_;l[z]=me.x,l[z+1]=me.y,l[z+2]=me.z,h[z]=ve.x,h[z+1]=ve.y,h[z+2]=ve.z;let F=u.lerp(g,T);S=e.lerp(t,T),new Ze(b,w).intersects(new Ze(S,F),a),_=f+R,m.doubleToTwoFloats(a,me,ve),z=3*_,l[z]=me.x,l[z+1]=me.y,l[z+2]=me.z,h[z]=ve.x,h[z+1]=ve.y,h[z+2]=ve.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)}};Sn.__counter__=0;let Mn=Sn;const Rn=class cl{constructor(e={}){e.properties=e.properties||{},this.__id=cl.__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=Ge(e.cartesian),this._rootCartesian=new m,this._localPosition=Ge(e.localPosition),this._absoluteLocalPosition=new m,this._lonLat=Ui(e.lonlat),this._lonLatMerc=new P,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=Ge(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:[mn,this.setBillboard],label:[Tn,this.setLabel],polyline:[Ln,this.setPolyline],pointCloud:[Xl,this.setPointCloud],geometry:[yn,this.setGeometry],geoObject:[wn,this.setGeoObject],strip:[Mn,this.setStrip],ray:[Zl,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(){return this._layer&&this._layer.removeEntity(this),this._entityCollection&&this._entityCollection.removeEntity(this),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]*ki(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 P(t.lon,t.lat),new P(t.lon,t.lat)):new j(new P(180,90),new P(-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}};Rn.__counter__=0;let V=Rn;const Bn=class dl{constructor(e){this.__id=dl.__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}};Bn.__counter__=0;let Ql=Bn;class at extends Ql{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(o){this._visibility!=o&&(this._visibility=o,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(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-error"),e.innerHTML="error: "+o,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}logWrn(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.classList.add("ogConsole-warning"),e.innerHTML="warning: "+o,console.trace(e.innerHTML),this._container.appendChild(e),this.show()}log(o){let e=document.createElement("div");e.classList.add("ogConsole-text"),e.innerHTML=o,console.trace(o),this._container.appendChild(e),this.show()}};let hi=["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 o=0;o<hi.length;o++)ue[hi[o]]=o;const Nr={};for(let o=0;o<hi.length;o++)Nr[hi[o].toLowerCase()]=ue[hi[o]];const Me={u:[],a:[]};Me.u[ue.MAT4]=function(o,e){o.gl.uniformMatrix4fv(e._pName,!1,e.value)},Me.u[ue.MAT3]=function(o,e){o.gl.uniformMatrix3fv(e._pName,!1,e.value)},Me.u[ue.FLOAT]=function(o,e){o.gl.uniform1f(e._pName,e.value)},Me.u[ue.INT]=function(o,e){o.gl.uniform1i(e._pName,e.value)},Me.u[ue.VEC2]=function(o,e){o.gl.uniform2fv(e._pName,e.value)},Me.u[ue.VEC3]=function(o,e){o.gl.uniform3fv(e._pName,e.value)},Me.u[ue.VEC4]=function(o,e){o.gl.uniform4fv(e._pName,e.value)},Me.u[ue.SAMPLER2D]=function(o,e){let t=o.gl;t.activeTexture(t.TEXTURE0+o._textureID),t.bindTexture(t.TEXTURE_2D,e.value),t.uniform1i(e._pName,o._textureID),o._textureID++},Me.u[ue.SAMPLERCUBE]=function(o,e){let t=o.gl;t.activeTexture(t.TEXTURE0+o._textureID),t.bindTexture(t.TEXTURE_CUBE_MAP,e.value),t.uniform1i(e._pName,o._textureID),o._textureID++},Me.u[ue.SAMPLER2DARRAY]=function(o,e){let t=e.value,i=o.gl,r=t.length,s=new Int32Array(r);for(let n=0;n<r;n++)i.activeTexture(i.TEXTURE0+o._textureID+n),i.bindTexture(i.TEXTURE_2D,t[n]),s[n]=n;i.uniform1iv(e._pName,s)},Me.u[ue.INTXX]=function(o,e){o.gl.uniform1iv(e._pName,e.value)},Me.u[ue.FLOATXX]=function(o,e){o.gl.uniform1fv(e._pName,e.value)},Me.a[ue.FLOAT]=function(o,e){o.gl.vertexAttrib1f(e._pName,e.value)},Me.a[ue.VEC2]=function(o,e){o.gl.vertexAttrib2fv(e._pName,e.value)},Me.a[ue.VEC3]=function(o,e){o.gl.vertexAttrib3fv(e._pName,e.value)};const Kl=["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
  `),a=n.findIndex((l=>l.startsWith("#version")));return a!==-1?(n.splice(a+1,0,"#define WEBGL2"),n.join(`
94
94
  `)):r})(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,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 Qe.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(Kl.indexOf(n)==-1?(Qe.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 Qe.logErr(`Shader program "${this.name}": attribute '${r}' not exists.`),void e.deleteProgram(this._p);let a=this._attributes[r].type;typeof a=="string"&&(a=Nr[a.trim().toLowerCase()]);let l=this._attributes[r].divisor;if(a===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=Me.u[Nr[s.trim().toLowerCase()]]}else this._uniforms[r].func=Me.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 Qe.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 kn=class ul{constructor(e){this.__id=ul.__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
@@ -99,7 +99,7 @@ vec2 project(vec4 p,vec2 viewport){return(0.5*p.xyz/p.w+0.5).xy*viewport;}mat2 r
99
99
  #define RTL 1.0
100
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,a=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(s.depthOffset,a.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,a.scaleByDistance),n.uniform1f(s.opacity,a._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,a.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,a=this._entityCollection;n.disable(n.CULL_FACE),n.uniform1f(s.depthOffset,a.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,a.scaleByDistance),n.uniform1f(s.opacity,a._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,a.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=ce(this._rgbaArr,i,24),i=18*t,this._positionHighArr=ce(this._positionHighArr,i,18),this._positionLowArr=ce(this._positionLowArr,i,18),this._offsetArr=ce(this._offsetArr,i,18),this._pickingColorArr=ce(this._pickingColorArr,i,18),i=12*t,this._vertexArr=ce(this._vertexArr,i,12),this._sizeArr=ce(this._sizeArr,i,12),this._texCoordArr=ce(this._texCoordArr,i,12),i=6*t,this._rotationArr=ce(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,a=t.y,l=t.z;s[r]=n,s[r+1]=a,s[r+2]=l,s[r+3]=n,s[r+4]=a,s[r+5]=l,s[r+6]=n,s[r+7]=a,s[r+8]=l,s[r+9]=n,s[r+10]=a,s[r+11]=l,s[r+12]=n,s[r+13]=a,s[r+14]=l,s[r+15]=n,s[r+16]=a,s[r+17]=l,s=this._positionLowArr,n=i.x,a=i.y,l=i.z,s[r]=n,s[r+1]=a,s[r+2]=l,s[r+3]=n,s[r+4]=a,s[r+5]=l,s[r+6]=n,s[r+7]=a,s[r+8]=l,s[r+9]=n,s[r+10]=a,s[r+11]=l,s[r+12]=n,s[r+13]=a,s[r+14]=l,s[r+15]=n,s[r+16]=a,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,a=t.z/255;r[i]=s,r[i+1]=n,r[i+2]=a,r[i+3]=s,r[i+4]=n,r[i+5]=a,r[i+6]=s,r[i+7]=n,r[i+8]=a,r[i+9]=s,r[i+10]=n,r[i+11]=a,r[i+12]=s,r[i+13]=n,r[i+14]=a,r[i+15]=s,r[i+16]=n,r[i+17]=a,this._changedBuffers[0]=!0}setSizeArr(e,t,i){let r=12*e,s=this._sizeArr,n=t,a=i;s[r]=n,s[r+1]=a,s[r+2]=n,s[r+3]=a,s[r+4]=n,s[r+5]=a,s[r+6]=n,s[r+7]=a,s[r+8]=n,s[r+9]=a,s[r+10]=n,s[r+11]=a,this._changedBuffers[2]=!0}setOffsetArr(e,t){let i=18*e,r=this._offsetArr,s=t.x,n=t.y,a=t.z;r[i]=s,r[i+1]=n,r[i+2]=a,r[i+3]=s,r[i+4]=n,r[i+5]=a,r[i+6]=s,r[i+7]=n,r[i+8]=a,r[i+9]=s,r[i+10]=n,r[i+11]=a,r[i+12]=s,r[i+13]=n,r[i+14]=a,r[i+15]=s,r[i+16]=n,r[i+17]=a,this._changedBuffers[3]=!0}setRgbaArr(e,t){let i=24*e,r=this._rgbaArr,s=t.x,n=t.y,a=t.z,l=t.w;r[i]=s,r[i+1]=n,r[i+2]=a,r[i+3]=l,r[i+4]=s,r[i+5]=n,r[i+6]=a,r[i+7]=l,r[i+8]=s,r[i+9]=n,r[i+10]=a,r[i+11]=l,r[i+12]=s,r[i+13]=n,r[i+14]=a,r[i+15]=l,r[i+16]=s,r[i+17]=n,r[i+18]=a,r[i+19]=l,r[i+20]=s,r[i+21]=n,r[i+22]=a,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(){}};kn.__counter__=0;let In=kn;class Jl extends In{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 eh{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[Un]=this.createPickingColorBuffer,this._buffersUpdateCallbacks[On]=this.createNormalsBuffer,this._buffersUpdateCallbacks[Fn]=this.createRgbaBuffer,this._buffersUpdateCallbacks[Nn]=this.createIndicesBuffer,this._buffersUpdateCallbacks[zn]=this.createVertexBuffer,this._buffersUpdateCallbacks[Vn]=this.createSizeBuffer,this._buffersUpdateCallbacks[Gn]=this.createVisibleBuffer,this._buffersUpdateCallbacks[jn]=this.createTexCoordBuffer,this._buffersUpdateCallbacks[Hn]=this.createQRotBuffer,this._buffersUpdateCallbacks[qn]=this.createTranslateBuffer,this._buffersUpdateCallbacks[Dn]=this.createRTCPositionBuffer,this._buffersUpdateCallbacks[Yn]=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 Gi(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 Gi(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 Gi(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 zn=0,Dn=1,Fn=2,On=3,Nn=4,Hn=5,Vn=6,Un=7,Gn=8,jn=9,qn=10,Yn=11;function Se(o,e=0,t=0,i=1,...r){const s=e*t;for(let n=s,a=s+t;n<a;n++)o[n]=r[n%i];return o}const Wn=class _l{constructor(e){this.__id=_l.__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,$.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[zn]=!0),e.normals.length!==i._normalsArr.length&&(i._normalsArr=e.normals,i._changedBuffers[On]=!0),e.indices.length!==i._indicesArr.length&&(i._indicesArr=e.indices,i._changedBuffers[Nn]=!0),e.texCoords.length!==i._texCoordArr.length&&(i._texCoordArr=e.texCoords,i._changedBuffers[jn]=!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 eh(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=we(i._visibleArr,Se([],0,1,1,e.getVisibility()?1:0)),this.getRTCPosition(e.getPosition(),e._rtcPositionHigh,e._rtcPositionLow);let s,n=e._rtcPositionHigh.x,a=e._rtcPositionHigh.y,l=e._rtcPositionHigh.z;i._rtcPositionHighArr=we(i._rtcPositionHighArr,Se([],0,r,r,n,a,l)),n=e._rtcPositionLow.x,a=e._rtcPositionLow.y,l=e._rtcPositionLow.z,i._rtcPositionLowArr=we(i._rtcPositionLowArr,Se([],0,r,r,n,a,l)),n=e._entity._pickingColor.x/255,a=e._entity._pickingColor.y/255,l=e._entity._pickingColor.z/255,i._pickingColorArr=we(i._pickingColorArr,Se([],0,r,r,n,a,l)),r=4,n=e._qRot.x,a=e._qRot.y,l=e._qRot.z,s=e._qRot.w,i._qRotArr=we(i._qRotArr,Se([],0,r,r,n,a,l,s)),n=e._color.x,a=e._color.y,l=e._color.z,s=e._color.w,i._rgbaArr=we(i._rgbaArr,Se([],0,r,r,n,a,l,s)),r=3;let h=e.getScale();n=h.x,a=h.y,l=h.z,i._sizeArr=we(i._sizeArr,Se([],0,r,r,n,a,l));let c=e.getTranslate();n=c.x,a=c.y,l=c.z,i._translateArr=we(i._translateArr,Se([],0,r,r,n,a,l));let d=e.getLocalPosition();n=d.x,a=d.y,l=d.z,i._localPositionArr=we(i._localPositionArr,Se([],0,r,r,n,a,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,a=this._entityCollection,l=e.activeCamera;t.activate(),n.uniform3fv(r.uScaleByDistance,a.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,a=this._entityCollection;t.activate(),n.uniform3fv(r.uScaleByDistance,a.scaleByDistance),n.uniform3fv(r.pickingScale,a.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){Se(e._qRotArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Hn]=!0,this._updateTag(e)}setVisibility(e,t,i){Se(e._visibleArr,t,1,1,i?1:0),e._changedBuffers[Gn]=!0,this._updateTag(e)}setRTCPositionArr(e,t,i,r){Se(e._rtcPositionHighArr,t,3,3,i.x,i.y,i.z),Se(e._rtcPositionLowArr,t,3,3,r.x,r.y,r.z),e._changedBuffers[Dn]=!0,this._updateTag(e)}setRgbaArr(e,t,i){Se(e._rgbaArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Fn]=!0,this._updateTag(e)}setPickingColorArr(e,t,i){Se(e._pickingColorArr,t,3,3,i.x/255,i.y/255,i.z/255),e._changedBuffers[Un]=!0,this._updateTag(e)}setScaleArr(e,t,i){Se(e._sizeArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Vn]=!0,this._updateTag(e)}setTranslateArr(e,t,i){Se(e._translateArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[qn]=!0,this._updateTag(e)}setLocalPositionArr(e,t,i){Se(e._localPositionArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Yn]=!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,a=this._geoObjects.length;n<a;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,a=t.geoObjects.length;n<a;n++){let l=t.geoObjects[n];l._tagDataIndex=l._tagDataIndex-1}t._rgbaArr=Pe(t._rgbaArr,4*s,4),t._rtcPositionHighArr=Pe(t._rtcPositionHighArr,3*s,3),t._rtcPositionLowArr=Pe(t._rtcPositionLowArr,3*s,3),t._qRotArr=Pe(t._qRotArr,4*s,4),t._pickingColorArr=Pe(t._pickingColorArr,3*s,3),t._sizeArr=Pe(t._sizeArr,3*s,3),t._translateArr=Pe(t._translateArr,3*s,3),t._localPositionArr=Pe(t._localPositionArr,3*s,3),t._visibleArr=Pe(t._visibleArr,s,1),e._handlerIndex=-1,e._handler=null,e._tagDataIndex=-1,e._tagData=null,r||(t.refresh(),this._updateTag(t))}};Wn.__counter__=0;let th=Wn;class ih extends In{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,$.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[zn]=!0),e.normals.length!==i._normalsArr.length&&(i._normalsArr=e.normals,i._changedBuffers[On]=!0),e.indices.length!==i._indicesArr.length&&(i._indicesArr=e.indices,i._changedBuffers[Nn]=!0),e.texCoords.length!==i._texCoordArr.length&&(i._texCoordArr=e.texCoords,i._changedBuffers[jn]=!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 eh(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=we(i._visibleArr,Se([],0,1,1,e.getVisibility()?1:0)),this.getRTCPosition(e.getPosition(),e._rtcPositionHigh,e._rtcPositionLow);let s,n=e._rtcPositionHigh.x,a=e._rtcPositionHigh.y,l=e._rtcPositionHigh.z;i._rtcPositionHighArr=we(i._rtcPositionHighArr,Se([],0,r,r,n,a,l)),n=e._rtcPositionLow.x,a=e._rtcPositionLow.y,l=e._rtcPositionLow.z,i._rtcPositionLowArr=we(i._rtcPositionLowArr,Se([],0,r,r,n,a,l)),n=e._entity._pickingColor.x/255,a=e._entity._pickingColor.y/255,l=e._entity._pickingColor.z/255,i._pickingColorArr=we(i._pickingColorArr,Se([],0,r,r,n,a,l)),r=4,n=e._qRot.x,a=e._qRot.y,l=e._qRot.z,s=e._qRot.w,i._qRotArr=we(i._qRotArr,Se([],0,r,r,n,a,l,s)),n=e._color.x,a=e._color.y,l=e._color.z,s=e._color.w,i._rgbaArr=we(i._rgbaArr,Se([],0,r,r,n,a,l,s)),r=3;let h=e.getScale();n=h.x,a=h.y,l=h.z,i._sizeArr=we(i._sizeArr,Se([],0,r,r,n,a,l));let c=e.getTranslate();n=c.x,a=c.y,l=c.z,i._translateArr=we(i._translateArr,Se([],0,r,r,n,a,l));let d=e.getLocalPosition();n=d.x,a=d.y,l=d.z,i._localPositionArr=we(i._localPositionArr,Se([],0,r,r,n,a,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,a=this._entityCollection,l=e.activeCamera;t.activate(),n.uniform3fv(r.uScaleByDistance,a.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,a=this._entityCollection;t.activate(),n.uniform3fv(r.uScaleByDistance,a.scaleByDistance),n.uniform3fv(r.pickingScale,a.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){Se(e._qRotArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Hn]=!0,this._updateTag(e)}setVisibility(e,t,i){Se(e._visibleArr,t,1,1,i?1:0),e._changedBuffers[Gn]=!0,this._updateTag(e)}setRTCPositionArr(e,t,i,r){Se(e._rtcPositionHighArr,t,3,3,i.x,i.y,i.z),Se(e._rtcPositionLowArr,t,3,3,r.x,r.y,r.z),e._changedBuffers[Dn]=!0,this._updateTag(e)}setRgbaArr(e,t,i){Se(e._rgbaArr,t,4,4,i.x,i.y,i.z,i.w),e._changedBuffers[Fn]=!0,this._updateTag(e)}setPickingColorArr(e,t,i){Se(e._pickingColorArr,t,3,3,i.x/255,i.y/255,i.z/255),e._changedBuffers[Un]=!0,this._updateTag(e)}setScaleArr(e,t,i){Se(e._sizeArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Vn]=!0,this._updateTag(e)}setTranslateArr(e,t,i){Se(e._translateArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[qn]=!0,this._updateTag(e)}setLocalPositionArr(e,t,i){Se(e._localPositionArr,t,3,3,i.x,i.y,i.z),e._changedBuffers[Yn]=!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;if(t.numInstances===0){t.clear(),this._instanceDataMap.delete(i);for(let n=0;this._instanceDataMapValues.length;n++)if(this._instanceDataMapValues[n].numInstances===0){this._instanceDataMapValues.splice(n,1);break}this._clearDataTagQueue(),r=!0}this._geoObjects.splice(e._handlerIndex,1);for(let n=e._handlerIndex,a=this._geoObjects.length;n<a;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,a=t.geoObjects.length;n<a;n++){let l=t.geoObjects[n];l._tagDataIndex=l._tagDataIndex-1}t._rgbaArr=Pe(t._rgbaArr,4*s,4),t._rtcPositionHighArr=Pe(t._rtcPositionHighArr,3*s,3),t._rtcPositionLowArr=Pe(t._rtcPositionLowArr,3*s,3),t._qRotArr=Pe(t._qRotArr,4*s,4),t._pickingColorArr=Pe(t._pickingColorArr,3*s,3),t._sizeArr=Pe(t._sizeArr,3*s,3),t._translateArr=Pe(t._translateArr,3*s,3),t._localPositionArr=Pe(t._localPositionArr,3*s,3),t._visibleArr=Pe(t._visibleArr,s,1),e._handlerIndex=-1,e._handler=null,e._tagDataIndex=-1,e._tagData=null,r||(t.refresh(),this._updateTag(t))}};Wn.__counter__=0;let th=Wn;class ih extends In{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
@@ -143,7 +143,7 @@ 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=[]}};Qn.__counter__=0;let ah=Qn;const Kn=class vl{constructor(e={}){this._onChangeRelativeCenter=i=>{this.geoObjectHandler.setRelativeCenter(i),this.polylineHandler.setRelativeCenter(i)},this.__id=vl.__counter__++,this.renderNode=null,this._visibility=e.visibility==null||e.visibility,this.polygonOffsetUnits=e.polygonOffsetUnits!=null?e.polygonOffsetUnits:0,this.billboardHandler=new Jl(this),this.labelHandler=new ih(this,e.labelMaxLetters),this.polylineHandler=new sh(this),this.rayHandler=new nh(this),this.pointCloudHandler=new rh(this),this.stripHandler=new ah(this),this.geoObjectHandler=new th(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(oh,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||xt}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])}};Kn.__counter__=0;let _t=Kn;const oh=["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 ot(o,e){if(o>=0){let t=65536*Math.floor(o/65536);e[0]=Math.fround(t),e[1]=Math.fround(o-t)}else{let t=65536*Math.floor(-o/65536);e[0]=Math.fround(-t),e[1]=Math.fround(o+t)}return e}function Jn(o,e){if(o>=0){let t=65536*Math.floor(o/65536);e.x=Math.fround(t),e.y=Math.fround(o-t)}else{let t=65536*Math.floor(-o/65536);e.x=Math.fround(-t),e.y=Math.fround(o+t)}return e}function ea(o,e,t){t=t||2;var i,r,s,n,a,l,h,c=e&&e.length,d=c?e[0]*t:o.length,u=ta(o,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=ta(f,p[x]*v,x<y-1?p[x+1]*v:f.length,v,!1))===w.next&&(w.steiner=!0),b.push(fh(w));for(b.sort(uh),x=0;x<b.length;x++)_h(b[x],_),_=ci(_,_.next);return _})(o,e,u,t)),o.length>80*t){i=s=o[0],r=n=o[1];for(let f=t;f<d;f+=t)(a=o[f])<i&&(i=a),(l=o[f+1])<r&&(r=l),a>s&&(s=a),l>n&&(n=l);h=Math.max(s-i,n-r)}return di(u,g,t,i,r,h),g}function ta(o,e,t,i,r){var s,n;if(r===(function(a,l,h,c){var d=0;for(let u=l,g=h-c;u<h;u+=c)d+=(a[g]-a[u])*(a[u+1]+a[g+1]),g=u;return d})(o,e,t,i)>0)for(s=e;s<t;s+=i)n=sa(s,o[s],o[s+1],n);else for(s=t-i;s>=e;s-=i)n=sa(s,o[s],o[s+1],n);return n&&Ct(n,n.next)&&(_i(n),n=n.next),n}function ci(o,e){if(!o)return o;e||(e=o);var t,i=o;do if(t=!1,i.steiner||!Ct(i,i.next)&&ze(i.prev,i,i.next)!==0)i=i.next;else{if(_i(i),(i=e=i.prev)===i.next)return null;t=!0}while(t||i!==e);return e}function di(o,e,t,i,r,s,n){if(o){!n&&s&&(function(c,d,u,g){var f=c;do f.z===null&&(f.z=Hr(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,C,E,T=1;do{for(v=p,p=null,w=null,b=0;v;){for(b++,x=v,C=0,_=0;_<T&&(C++,x=x.nextZ);_++);for(E=T;C>0||E>0&&x;)C!==0&&(E===0||!x||v.z<=x.z)?(y=v,v=v.nextZ,C--):(y=x,x=x.nextZ,E--),w?w.nextZ=y:p=y,y.prevZ=w,w=y;v=x}w.nextZ=null,T*=2}while(b>1)})(f)})(o,i,r,s);for(var a,l,h=o;o.prev!==o.next;)if(a=o.prev,l=o.next,s?hh(o,i,r,s):lh(o))e.push(a.i/t),e.push(o.i/t),e.push(l.i/t),_i(o),o=l.next,h=l.next;else if((o=l)===h){n?n===1?di(o=ch(o,e,t),e,t,i,r,s,2):n===2&&dh(o,e,t,i,r,s):di(ci(o),e,t,i,r,s,1);break}}}function lh(o){var e=o.prev,t=o,i=o.next;if(ze(e,t,i)>=0)return!1;for(var r=o.next.next;r!==o.prev;){if(Xi(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&ze(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function hh(o,e,t,i){var r=o.prev,s=o,n=o.next;if(ze(r,s,n)>=0)return!1;for(var a=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=Hr(a,l,e,t,i),u=Hr(h,c,e,t,i),g=o.nextZ;g&&g.z<=u;){if(g!==o.prev&&g!==o.next&&Xi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(g=o.prevZ;g&&g.z>=d;){if(g!==o.prev&&g!==o.next&&Xi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}function ch(o,e,t){var i=o;do{var r=i.prev,s=i.next.next;!Ct(r,s)&&ia(r,i,i.next,s)&&ui(r,s)&&ui(s,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(s.i/t),_i(i),_i(i.next),i=o=s),i=i.next}while(i!==o);return i}function dh(o,e,t,i,r,s){var n=o;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&gh(n,a)){var l=ra(n,a);return n=ci(n,n.next),l=ci(l,l.next),di(n,e,t,i,r,s),void di(l,e,t,i,r,s)}a=a.next}n=n.next}while(n!==o)}function uh(o,e){return o.x-e.x}function _h(o,e){if(e=(function(i,r){var s,n=r,a=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<=a&&c>h){if(h=c,c===a){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(a===h)return s.prev;var d,u=s,g=s.x,f=s.y,p=1/0;for(n=s.next;n!==u;)a>=n.x&&n.x>=g&&a!==n.x&&Xi(l<f?a:h,l,g,f,l<f?h:a,l,n.x,n.y)&&((d=Math.abs(l-n.y)/(a-n.x))<p||d===p&&n.x>s.x)&&ui(n,i)&&(s=n,p=d),n=n.next;return s})(o,e)){var t=ra(e,o);ci(t,t.next)}}function Hr(o,e,t,i,r){return(o=1431655765&((o=858993459&((o=252645135&((o=16711935&((o=32767*(o-t)/r)|o<<8))|o<<4))|o<<2))|o<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function fh(o){var e=o,t=o;do e.x<t.x&&(t=e),e=e.next;while(e!==o);return t}function Xi(o,e,t,i,r,s,n,a){return(r-n)*(e-a)-(o-n)*(s-a)>=0&&(o-n)*(i-a)-(t-n)*(e-a)>=0&&(t-n)*(s-a)-(r-n)*(i-a)>=0}function gh(o,e){return o.next.i!==e.i&&o.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&&ia(r,r.next,t,i))return!0;r=r.next}while(r!==t);return!1})(o,e)&&ui(o,e)&&ui(e,o)&&(function(t,i){var r=t,s=!1,n=(t.x+i.x)/2,a=(t.y+i.y)/2;do r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next;while(r!==t);return s})(o,e)}function ze(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function Ct(o,e){return o.x===e.x&&o.y===e.y}function ia(o,e,t,i){return!!(Ct(o,e)&&Ct(t,i)||Ct(o,i)&&Ct(t,e))||ze(o,e,t)>0!=ze(o,e,i)>0&&ze(t,i,o)>0!=ze(t,i,e)>0}function ui(o,e){return ze(o.prev,o,o.next)<0?ze(o,e,o.next)>=0&&ze(o,o.prev,e)>=0:ze(o,e,o.prev)<0||ze(o,o.next,e)<0}function ra(o,e){var t=new Vr(o.i,o.x,o.y),i=new Vr(e.i,e.x,e.y),r=o.next,s=e.prev;return o.next=e,e.prev=o,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function sa(o,e,t,i){var r=new Vr(o,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 _i(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function Vr(o,e,t){this.i=o,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 na(o){var e=o[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0;for(let r=0;r<o.length;r++){for(let s=0;s<o[r].length;s++)for(let n=0;n<e;n++)t.vertices.push(o[r][s][n]);r>0&&(i+=o[r-1].length,t.holes.push(i))}return t}function Ur(o,e,t){let i=o[0],r=o[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,Gt=new N;const aa=class Kt{constructor(e){this.__id=Kt.__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,a,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],C=a,E=[n.x,n.y,n.z,n.w],T=[r.x,r.y,r.z,1];for(let S=0;S<e.length;S++){var L=e[S];if(L.length===0)continue;let R,z,F=y;if(t)R=L[L.length-1];else{let B=L[0],D=L[1];D||(D=B),R=[B[0]+B[0]-D[0],B[1]+B[1]-D[1]]}Ur(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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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 B=0;B<L.length;B++)Ur(L[B],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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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 B=L[L.length-1],D=L[L.length-2];D||(D=B),z=[B[0]+B[0]-D[0],B[1]+B[1]-D[1]],d.push(y-1,y-1,y-1,y-1)}Ur(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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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]),S<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===oi.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]=[ti(i[c][d][0]),ii(i[c][d][1])]}let s=na(r),n=ea(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 a=e._style.fillColor,l=[],h=[];for(let c=0;c<.5*s.vertices.length;c++)this._polyColors.push(a.x,a.y,a.z,a.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let c=0;c<s.vertices.length;c++)Jn(s.vertices[c],Gt),l[c]=Gt.x,h[c]=Gt.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,Kt.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===oi.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]=[ti(c[f][p][0]),ii(c[f][p][1])]}let u=na(d),g=ea(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),Kt.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,a=[],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++)Jn(r[h],Gt),a[h]=Gt.x,l[h]=Gt.y;e._polyVerticesHighMerc=a,e._polyVerticesLowMerc=l,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,a),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===oi.LINESTRING){let i=e._coordinates,r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=[ti(i[s][0]),ii(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,Kt.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===oi.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]=[ti(i[s][n][0]),ii(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,Kt.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 a=0;a<s;a++)i[n+a]=e._polyVerticesHighMerc[a]*t,r[n+a]=e._polyVerticesLowMerc[a]*t;i=this._lineVerticesHighMerc,r=this._lineVerticesLowMerc,s=e._lineVerticesLength,n=e._lineVerticesHandlerIndex;for(let a=0;a<s;a++)i[n+a]=e._lineVerticesHighMerc[a]*t,r[n+a]=e._lineVerticesLowMerc[a]*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))}}};aa.__counter__=0;let ph=aa;class fe extends qe{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(mh),this.isVector=!0,this._hasImageryTiles=!1,this.scaleByDistance=t.scaleByDistance||[xt,xt,xt],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 a=r[n];a.instanceName==="Entity"?s.push(a):s.push(new V(a))}return s})(t.entities||[]),this._labelMaxLetters=t.labelMaxLetters||24,this._stripEntityCollection=new _t({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._stripEntityCollection),this._polylineEntityCollection=new _t({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._polylineEntityCollection),this._geoObjectEntityCollection=new _t({pickingEnabled:this.pickingEnabled,useLighting:this._useLighting}),this._bindEventsDefault(this._geoObjectEntityCollection),this._geometryHandler=new ph(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,a=n.length,l=new m;for(;a--;){let h=n[a]._altitude||0,c=n[a].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 a=1/(2<<t.tileZoom-i.segment.tileZoom-1);return[t.tileX*a-i.segment.tileX,t.tileY*a-i.segment.tileY,a,a]}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 mh=["draw","entityadd","entityremove"],vh=["change","startpoint"],oa=$.createCylinder(1,1,2,20,1,!0,!1,0,-.5,0),De=200,fi=.3;class la extends at{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(vh),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:oa,...e.cornerStyle||{}},this._centerStyle={scale:.4,tag:"centers",color:"rgb(0, 350, 50)",object3d:oa,...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=fi,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 P(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(),a=r.getCartesian().sub(n),l=r.getCartesian().sub(s),h=a.length(),c=l.length();a.normalize(),l.normalize();let d=[],u=[];for(let y=0;y<=De;y++){let w=a.scaleTo(y*h/De).addA(n);d.push(w);let b=l.scaleTo(y*c/De).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=fi,this._outlineLayer.add(g);let f=this._centerLayer.getEntities(),p=f[f.length-1],_=a.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,a=s.length,l=s[n===0?a-1:n-1].getCartesian(),h=s[(n+1)%a].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 S=d.scaleTo(T*g/De).addA(h);p.push(S)}let _=this._outlineLayer.getEntities(),v=_[n].polyline,x=_[(n+1)%a].polyline;v?.setPath3v([f]),x?.setPath3v([p]);let y=this._centerLayer.getEntities(),w=y[n===0?a-1:n-1],b=y[n],C=c.scaleTo(.5*u).addA(l),E=d.scaleTo(.5*g).addA(h);w.setCartesian3v(C),this._checkTerrainCollision(w),b.setCartesian3v(E),this._checkTerrainCollision(b)}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let r=0,s=be;for(let S=0;S<i;S++){let R=t[S].getCartesian().distance(e);R<s&&(s=R,r=S)}let n=t[r].getCartesian(),a=t[(r+1)%i].getCartesian(),l=t[r===0?i-1:r-1].getCartesian().sub(n).normalize(),h=a.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 S=0;S<i;S++)if(new Ze(t[S].getCartesian(),t[(S+1)%i].getCartesian()).getNearestDistancePoint(e,f)){let R=f.distance(e);R<s&&(s=R,r=S)}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=[],C=[];for(let S=0;S<=De;S++){let R=v.scaleTo(S*y/De).addA(p);b.push(R);let z=x.scaleTo(S*w/De).addA(_);C.push(z)}let E=this._ghostOutlineLayer.getEntities(),T=E[0].polyline,L=E[1].polyline;T?.setPath3v([b]),L?.setPath3v([C])}}_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=fi}}class ha extends la{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),a=n.length();n.normalize();let l=[];for(let u=0;u<=De;u++){let g=n.scaleTo(u*a/De).addA(s);l.push(g)}let h=new V({polyline:{path3v:[l],isClosed:!1,...this._outlineStyle}});h.polyline.altitude=fi,this._outlineLayer.add(h);let c=n.scaleTo(.5*a).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),a=n.length();n.normalize();let l=[];for(let d=0;d<=De;d++){let u=n.scaleTo(d*a/De).addA(s);l.push(u)}let h=this._outlineLayer.getEntities()[t].polyline;h?.setPath3v([l]);let c=this._centerLayer.getEntities()[i];if(c){let d=n.scaleTo(.5*a).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),a=n.length();n.normalize();let l=[];for(let h=0;h<=De;h++){let c=n.scaleTo(h*a/De).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=fi}}class ca extends ee{constructor(e={}){super(e),this._drawingScene=new ha({name:`drawingScene:${this.__id}`,cornerStyle:e.cornerStyle||{},centerStyle:e.centerStyle||{},outlineStyle:e.outlineStyle||{},fillStyle:e.fillStyle||{}})}activatePolygonDrawing(){this.deactivate(),this._drawingScene=new la({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 ha({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 gi={ell:0,msl:1,gnd:2},Gr=.3048,yh=1/Gr,xh=1/3.6,da=.001*Gr,bh=1/da,wh=["m","km","ft","s","h","m/s","km/h","ft/s"],ua=[0,2,0,0,0,0,0,0];let ye=[];function _a(o,e,t){return ye[o][e](t)}function jr(o,e,t,i,r){return o?_a(e,t,i).toFixed(r||ua[t]):"--"}function fa(o){return wh[o]}ye[0]=[],ye[0][0]=o=>o,ye[0][1]=o=>.001*o,ye[0][2]=o=>o*yh,ye[2]=[],ye[2][0]=o=>o*Gr,ye[2][1]=o=>o*da,ye[2][2]=o=>o,ye[1]=[],ye[1][0]=o=>1e3*o,ye[1][1]=o=>o,ye[1][2]=o=>o*bh,ye[5]=[],ye[5][5]=o=>o,ye[5][6]=o=>3.6*o,ye[5][7]=o=>3.28084*o,ye[6]=[],ye[6][5]=o=>o*xh,ye[6][6]=o=>o;const ga=Object.freeze(Object.defineProperty({__proto__:null,ELL:0,GND:2,MSL:1,_tenth:ua,convert:_a,convertExt:jr,ft:2,fts:7,h:4,heightMode:gi,km:1,kmh:6,m:0,ms:5,s:3,toString:fa},Symbol.toStringTag,{value:"Module"})),Ch=[`<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=[]}};Qn.__counter__=0;let ah=Qn;const Kn=class vl{constructor(e={}){this._onChangeRelativeCenter=i=>{this.geoObjectHandler.setRelativeCenter(i),this.polylineHandler.setRelativeCenter(i)},this.__id=vl.__counter__++,this.renderNode=null,this._visibility=e.visibility==null||e.visibility,this.polygonOffsetUnits=e.polygonOffsetUnits!=null?e.polygonOffsetUnits:0,this.billboardHandler=new Jl(this),this.labelHandler=new ih(this,e.labelMaxLetters),this.polylineHandler=new sh(this),this.rayHandler=new nh(this),this.pointCloudHandler=new rh(this),this.stripHandler=new ah(this),this.geoObjectHandler=new th(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(oh,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||xt}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,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){if(e.parent){let t=e.parent.childEntities;for(let i=0,r=t.length;i<r;i++)if(t[i].isEqual(e)){t.splice(i,1);break}e.parent=null}else this._entities.splice(e._entityCollectionIndex,1),this.reindexEntitiesArray(e._entityCollectionIndex);this.renderNode&&this.renderNode.renderer&&(this.renderNode.renderer.clearPickingColor(e),e._pickingColor.clear()),this._removeRecursively(e)}removeEntity(e){this.belongs(e)&&(this._removeEntity(e),this.events.dispatch(this.events.entityremove,e))}_removeEntitySilent(e){this.belongs(e)&&this._removeEntity(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])}};Kn.__counter__=0;let _t=Kn;const oh=["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 ot(o,e){if(o>=0){let t=65536*Math.floor(o/65536);e[0]=Math.fround(t),e[1]=Math.fround(o-t)}else{let t=65536*Math.floor(-o/65536);e[0]=Math.fround(-t),e[1]=Math.fround(o+t)}return e}function Jn(o,e){if(o>=0){let t=65536*Math.floor(o/65536);e.x=Math.fround(t),e.y=Math.fround(o-t)}else{let t=65536*Math.floor(-o/65536);e.x=Math.fround(-t),e.y=Math.fround(o+t)}return e}function ea(o,e,t){t=t||2;var i,r,s,n,a,l,h,c=e&&e.length,d=c?e[0]*t:o.length,u=ta(o,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=ta(f,p[x]*v,x<y-1?p[x+1]*v:f.length,v,!1))===w.next&&(w.steiner=!0),b.push(fh(w));for(b.sort(uh),x=0;x<b.length;x++)_h(b[x],_),_=ci(_,_.next);return _})(o,e,u,t)),o.length>80*t){i=s=o[0],r=n=o[1];for(let f=t;f<d;f+=t)(a=o[f])<i&&(i=a),(l=o[f+1])<r&&(r=l),a>s&&(s=a),l>n&&(n=l);h=Math.max(s-i,n-r)}return di(u,g,t,i,r,h),g}function ta(o,e,t,i,r){var s,n;if(r===(function(a,l,h,c){var d=0;for(let u=l,g=h-c;u<h;u+=c)d+=(a[g]-a[u])*(a[u+1]+a[g+1]),g=u;return d})(o,e,t,i)>0)for(s=e;s<t;s+=i)n=sa(s,o[s],o[s+1],n);else for(s=t-i;s>=e;s-=i)n=sa(s,o[s],o[s+1],n);return n&&Ct(n,n.next)&&(_i(n),n=n.next),n}function ci(o,e){if(!o)return o;e||(e=o);var t,i=o;do if(t=!1,i.steiner||!Ct(i,i.next)&&ze(i.prev,i,i.next)!==0)i=i.next;else{if(_i(i),(i=e=i.prev)===i.next)return null;t=!0}while(t||i!==e);return e}function di(o,e,t,i,r,s,n){if(o){!n&&s&&(function(c,d,u,g){var f=c;do f.z===null&&(f.z=Hr(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,C,E,T=1;do{for(v=p,p=null,w=null,b=0;v;){for(b++,x=v,C=0,_=0;_<T&&(C++,x=x.nextZ);_++);for(E=T;C>0||E>0&&x;)C!==0&&(E===0||!x||v.z<=x.z)?(y=v,v=v.nextZ,C--):(y=x,x=x.nextZ,E--),w?w.nextZ=y:p=y,y.prevZ=w,w=y;v=x}w.nextZ=null,T*=2}while(b>1)})(f)})(o,i,r,s);for(var a,l,h=o;o.prev!==o.next;)if(a=o.prev,l=o.next,s?hh(o,i,r,s):lh(o))e.push(a.i/t),e.push(o.i/t),e.push(l.i/t),_i(o),o=l.next,h=l.next;else if((o=l)===h){n?n===1?di(o=ch(o,e,t),e,t,i,r,s,2):n===2&&dh(o,e,t,i,r,s):di(ci(o),e,t,i,r,s,1);break}}}function lh(o){var e=o.prev,t=o,i=o.next;if(ze(e,t,i)>=0)return!1;for(var r=o.next.next;r!==o.prev;){if(Xi(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&ze(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function hh(o,e,t,i){var r=o.prev,s=o,n=o.next;if(ze(r,s,n)>=0)return!1;for(var a=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=Hr(a,l,e,t,i),u=Hr(h,c,e,t,i),g=o.nextZ;g&&g.z<=u;){if(g!==o.prev&&g!==o.next&&Xi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(g=o.prevZ;g&&g.z>=d;){if(g!==o.prev&&g!==o.next&&Xi(r.x,r.y,s.x,s.y,n.x,n.y,g.x,g.y)&&ze(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}function ch(o,e,t){var i=o;do{var r=i.prev,s=i.next.next;!Ct(r,s)&&ia(r,i,i.next,s)&&ui(r,s)&&ui(s,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(s.i/t),_i(i),_i(i.next),i=o=s),i=i.next}while(i!==o);return i}function dh(o,e,t,i,r,s){var n=o;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&gh(n,a)){var l=ra(n,a);return n=ci(n,n.next),l=ci(l,l.next),di(n,e,t,i,r,s),void di(l,e,t,i,r,s)}a=a.next}n=n.next}while(n!==o)}function uh(o,e){return o.x-e.x}function _h(o,e){if(e=(function(i,r){var s,n=r,a=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<=a&&c>h){if(h=c,c===a){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(a===h)return s.prev;var d,u=s,g=s.x,f=s.y,p=1/0;for(n=s.next;n!==u;)a>=n.x&&n.x>=g&&a!==n.x&&Xi(l<f?a:h,l,g,f,l<f?h:a,l,n.x,n.y)&&((d=Math.abs(l-n.y)/(a-n.x))<p||d===p&&n.x>s.x)&&ui(n,i)&&(s=n,p=d),n=n.next;return s})(o,e)){var t=ra(e,o);ci(t,t.next)}}function Hr(o,e,t,i,r){return(o=1431655765&((o=858993459&((o=252645135&((o=16711935&((o=32767*(o-t)/r)|o<<8))|o<<4))|o<<2))|o<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function fh(o){var e=o,t=o;do e.x<t.x&&(t=e),e=e.next;while(e!==o);return t}function Xi(o,e,t,i,r,s,n,a){return(r-n)*(e-a)-(o-n)*(s-a)>=0&&(o-n)*(i-a)-(t-n)*(e-a)>=0&&(t-n)*(s-a)-(r-n)*(i-a)>=0}function gh(o,e){return o.next.i!==e.i&&o.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&&ia(r,r.next,t,i))return!0;r=r.next}while(r!==t);return!1})(o,e)&&ui(o,e)&&ui(e,o)&&(function(t,i){var r=t,s=!1,n=(t.x+i.x)/2,a=(t.y+i.y)/2;do r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next;while(r!==t);return s})(o,e)}function ze(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function Ct(o,e){return o.x===e.x&&o.y===e.y}function ia(o,e,t,i){return!!(Ct(o,e)&&Ct(t,i)||Ct(o,i)&&Ct(t,e))||ze(o,e,t)>0!=ze(o,e,i)>0&&ze(t,i,o)>0!=ze(t,i,e)>0}function ui(o,e){return ze(o.prev,o,o.next)<0?ze(o,e,o.next)>=0&&ze(o,o.prev,e)>=0:ze(o,e,o.prev)<0||ze(o,o.next,e)<0}function ra(o,e){var t=new Vr(o.i,o.x,o.y),i=new Vr(e.i,e.x,e.y),r=o.next,s=e.prev;return o.next=e,e.prev=o,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function sa(o,e,t,i){var r=new Vr(o,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 _i(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function Vr(o,e,t){this.i=o,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 na(o){var e=o[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0;for(let r=0;r<o.length;r++){for(let s=0;s<o[r].length;s++)for(let n=0;n<e;n++)t.vertices.push(o[r][s][n]);r>0&&(i+=o[r-1].length,t.holes.push(i))}return t}function Ur(o,e,t){let i=o[0],r=o[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,Gt=new N;const aa=class Kt{constructor(e){this.__id=Kt.__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,a,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],C=a,E=[n.x,n.y,n.z,n.w],T=[r.x,r.y,r.z,1];for(let S=0;S<e.length;S++){var L=e[S];if(L.length===0)continue;let R,z,F=y;if(t)R=L[L.length-1];else{let B=L[0],D=L[1];D||(D=B),R=[B[0]+B[0]-D[0],B[1]+B[1]-D[1]]}Ur(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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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 B=0;B<L.length;B++)Ur(L[B],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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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 B=L[L.length-1],D=L[L.length-2];D||(D=B),z=[B[0]+B[0]-D[0],B[1]+B[1]-D[1]],d.push(y-1,y-1,y-1,y-1)}Ur(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(C,C,C,C),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(E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[3],E[0],E[1],E[2],E[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]),S<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===oi.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]=[ti(i[c][d][0]),ii(i[c][d][1])]}let s=na(r),n=ea(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 a=e._style.fillColor,l=[],h=[];for(let c=0;c<.5*s.vertices.length;c++)this._polyColors.push(a.x,a.y,a.z,a.w),this._polyPickingColors.push(t.x,t.y,t.z,1);for(let c=0;c<s.vertices.length;c++)Jn(s.vertices[c],Gt),l[c]=Gt.x,h[c]=Gt.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,Kt.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===oi.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]=[ti(c[f][p][0]),ii(c[f][p][1])]}let u=na(d),g=ea(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),Kt.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,a=[],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++)Jn(r[h],Gt),a[h]=Gt.x,l[h]=Gt.y;e._polyVerticesHighMerc=a,e._polyVerticesLowMerc=l,this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc,a),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===oi.LINESTRING){let i=e._coordinates,r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=[ti(i[s][0]),ii(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,Kt.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===oi.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]=[ti(i[s][n][0]),ii(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,Kt.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 a=0;a<s;a++)i[n+a]=e._polyVerticesHighMerc[a]*t,r[n+a]=e._polyVerticesLowMerc[a]*t;i=this._lineVerticesHighMerc,r=this._lineVerticesLowMerc,s=e._lineVerticesLength,n=e._lineVerticesHandlerIndex;for(let a=0;a<s;a++)i[n+a]=e._lineVerticesHighMerc[a]*t,r[n+a]=e._lineVerticesLowMerc[a]*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))}}};aa.__counter__=0;let ph=aa;class fe extends qe{constructor(e,t={}){super(e,t),this.events=this.events.registerNames(mh),this.isVector=!0,this._hasImageryTiles=!1,this.scaleByDistance=t.scaleByDistance||[xt,xt,xt],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 a=r[n];a.instanceName==="Entity"?s.push(a):s.push(new V(a))}return s})(t.entities||[]),this._labelMaxLetters=t.labelMaxLetters||24,this._stripEntityCollection=new _t({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._stripEntityCollection),this._polylineEntityCollection=new _t({pickingEnabled:this.pickingEnabled}),this._bindEventsDefault(this._polylineEntityCollection),this._geoObjectEntityCollection=new _t({pickingEnabled:this.pickingEnabled,useLighting:this._useLighting}),this._bindEventsDefault(this._geoObjectEntityCollection),this._geometryHandler=new ph(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(e.parent||(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,a=n.length,l=new m;for(;a--;){let h=n[a]._altitude||0,c=n[a].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 a=1/(2<<t.tileZoom-i.segment.tileZoom-1);return[t.tileX*a-i.segment.tileX,t.tileY*a-i.segment.tileY,a,a]}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 mh=["draw","entityadd","entityremove"],vh=["change","startpoint"],oa=$.createCylinder(1,1,2,20,1,!0,!1,0,-.5,0),De=200,fi=.3;class la extends at{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(vh),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:oa,...e.cornerStyle||{}},this._centerStyle={scale:.4,tag:"centers",color:"rgb(0, 350, 50)",object3d:oa,...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=fi,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 P(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(),a=r.getCartesian().sub(n),l=r.getCartesian().sub(s),h=a.length(),c=l.length();a.normalize(),l.normalize();let d=[],u=[];for(let y=0;y<=De;y++){let w=a.scaleTo(y*h/De).addA(n);d.push(w);let b=l.scaleTo(y*c/De).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=fi,this._outlineLayer.add(g);let f=this._centerLayer.getEntities(),p=f[f.length-1],_=a.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,a=s.length,l=s[n===0?a-1:n-1].getCartesian(),h=s[(n+1)%a].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 S=d.scaleTo(T*g/De).addA(h);p.push(S)}let _=this._outlineLayer.getEntities(),v=_[n].polyline,x=_[(n+1)%a].polyline;v?.setPath3v([f]),x?.setPath3v([p]);let y=this._centerLayer.getEntities(),w=y[n===0?a-1:n-1],b=y[n],C=c.scaleTo(.5*u).addA(l),E=d.scaleTo(.5*g).addA(h);w.setCartesian3v(C),this._checkTerrainCollision(w),b.setCartesian3v(E),this._checkTerrainCollision(b)}}}_updateGhostOutlinePointer(e){let t=this._cornerLayer.getEntities(),i=t.length;if(i>0){let r=0,s=be;for(let S=0;S<i;S++){let R=t[S].getCartesian().distance(e);R<s&&(s=R,r=S)}let n=t[r].getCartesian(),a=t[(r+1)%i].getCartesian(),l=t[r===0?i-1:r-1].getCartesian().sub(n).normalize(),h=a.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 S=0;S<i;S++)if(new Ze(t[S].getCartesian(),t[(S+1)%i].getCartesian()).getNearestDistancePoint(e,f)){let R=f.distance(e);R<s&&(s=R,r=S)}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=[],C=[];for(let S=0;S<=De;S++){let R=v.scaleTo(S*y/De).addA(p);b.push(R);let z=x.scaleTo(S*w/De).addA(_);C.push(z)}let E=this._ghostOutlineLayer.getEntities(),T=E[0].polyline,L=E[1].polyline;T?.setPath3v([b]),L?.setPath3v([C])}}_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=fi}}class ha extends la{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),a=n.length();n.normalize();let l=[];for(let u=0;u<=De;u++){let g=n.scaleTo(u*a/De).addA(s);l.push(g)}let h=new V({polyline:{path3v:[l],isClosed:!1,...this._outlineStyle}});h.polyline.altitude=fi,this._outlineLayer.add(h);let c=n.scaleTo(.5*a).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),a=n.length();n.normalize();let l=[];for(let d=0;d<=De;d++){let u=n.scaleTo(d*a/De).addA(s);l.push(u)}let h=this._outlineLayer.getEntities()[t].polyline;h?.setPath3v([l]);let c=this._centerLayer.getEntities()[i];if(c){let d=n.scaleTo(.5*a).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),a=n.length();n.normalize();let l=[];for(let h=0;h<=De;h++){let c=n.scaleTo(h*a/De).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=fi}}class ca extends ee{constructor(e={}){super(e),this._drawingScene=new ha({name:`drawingScene:${this.__id}`,cornerStyle:e.cornerStyle||{},centerStyle:e.centerStyle||{},outlineStyle:e.outlineStyle||{},fillStyle:e.fillStyle||{}})}activatePolygonDrawing(){this.deactivate(),this._drawingScene=new la({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 ha({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 gi={ell:0,msl:1,gnd:2},Gr=.3048,yh=1/Gr,xh=1/3.6,da=.001*Gr,bh=1/da,wh=["m","km","ft","s","h","m/s","km/h","ft/s"],ua=[0,2,0,0,0,0,0,0];let ye=[];function _a(o,e,t){return ye[o][e](t)}function jr(o,e,t,i,r){return o?_a(e,t,i).toFixed(r||ua[t]):"--"}function fa(o){return wh[o]}ye[0]=[],ye[0][0]=o=>o,ye[0][1]=o=>.001*o,ye[0][2]=o=>o*yh,ye[2]=[],ye[2][0]=o=>o*Gr,ye[2][1]=o=>o*da,ye[2][2]=o=>o,ye[1]=[],ye[1][0]=o=>1e3*o,ye[1][1]=o=>o,ye[1][2]=o=>o*bh,ye[5]=[],ye[5][5]=o=>o,ye[5][6]=o=>3.6*o,ye[5][7]=o=>3.28084*o,ye[6]=[],ye[6][5]=o=>o*xh,ye[6][6]=o=>o;const ga=Object.freeze(Object.defineProperty({__proto__:null,ELL:0,GND:2,MSL:1,_tenth:ua,convert:_a,convertExt:jr,ft:2,fts:7,h:4,heightMode:gi,km:1,kmh:6,m:0,ms:5,s:3,toString:fa},Symbol.toStringTag,{value:"Module"})),Ch=[`<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>