map-core-func 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("three")):"function"==typeof define&&define.amd?define(["exports","maptalks","three"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["map-core-func"]=t["map-core-func"]||{},t.maptalks,t.THREE)}(this,(function(t,e,n){function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var r=i(e),o=i(n);const s=parseInt(o.REVISION.replace("dev",""));function a(t,e,n){return s>109?t.setAttribute(e,n):t.addAttribute(e,n),t}function h(){var t;const e=null!==(t=null==o?void 0:o.VertexColors)&&void 0!==t&&t;return e||!0}console.log(`maptalks.three log: current three.js version is %c${s}`,"color:red;font-size: 16px;font-weight: bold;");class c extends o.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),a(this,"position",new o.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),a(this,"uv",new o.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix(t){var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(t.applyToBufferAttribute(e),t.applyToBufferAttribute(n),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var n=new o.InstancedInterleavedBuffer(e,6,1);return a(this,"instanceStart",new o.InterleavedBufferAttribute(n,3,0)),a(this,"instanceEnd",new o.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var n=new o.InstancedInterleavedBuffer(e,6,1);return a(this,"instanceColorStart",new o.InterleavedBufferAttribute(n,3,0)),a(this,"instanceColorEnd",new o.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new o.WireframeGeometry(t.geometry)),this}fromLineSegements(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}computeBoundingBox(){var t=new o.Box3;null===this.boundingBox&&(this.boundingBox=new o.Box3);var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;void 0!==e&&void 0!==n&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(n),this.boundingBox.union(t))}computeBoundingSphere(){var t=new o.Vector3;null===this.boundingSphere&&(this.boundingSphere=new o.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==e&&void 0!==n){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var r=0,s=0,a=e.count;s<a;s++)t.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(t)),t.fromBufferAttribute(n,s),r=Math.max(r,i.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}copy(t){return this}}const l={},u={};l.line={linewidth:{value:1},resolution:{value:new o.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.line={uniforms:o.UniformsUtils.merge([o.UniformsLib.common,o.UniformsLib.fog,l.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};class d extends o.ShaderMaterial{constructor(t){super({uniforms:o.UniformsUtils.clone(u.line.uniforms),vertexShader:u.line.vertexShader,fragmentShader:u.line.fragmentShader}),this.dashed=!0,this.isLineMaterial=!0,this.type="LineMaterial",Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)}}class f extends o.Mesh{constructor(t,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2",this.geometry=void 0!==t?t:new c,this.material=void 0!==e?e:new d({color:16777215*Math.random()})}computeLineDistances(){var t=new o.Vector3,e=new o.Vector3,n=this.geometry,i=n.attributes.instanceStart,r=n.attributes.instanceEnd;if(!i||!r)return this;for(var s=new Float32Array(2*i.data.count),h=0,c=0,l=i.data.count;h<l;h++,c+=2)t.fromBufferAttribute(i,h),e.fromBufferAttribute(r,h),s[c]=0===c?0:s[c-1],s[c+1]=s[c]+t.distanceTo(e);var u=new o.InstancedInterleavedBuffer(s,2,1);return a(n,"instanceDistanceStart",new o.InterleavedBufferAttribute(u,1,0)),a(n,"instanceDistanceEnd",new o.InterleavedBufferAttribute(u,1,1)),this}}class p extends c{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}fromLine(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}}class g extends f{constructor(t,e){super(t,e),this.isLine2=!0,this.type="Line2",this.geometry=void 0!==t?t:new p,this.material=void 0!==e?e:new d({color:16777215*Math.random()})}copy(t){return this}}const y={interactive:!0,altitude:0,minZoom:0,maxZoom:30,asynchronous:!1,bloom:!1,pickWeight:-1};function v(){}class x extends(r.Eventable(v)){constructor(t){super(),this.isAdd=!1,this._mouseover=!1,this._visible=!0,this._zoomVisible=!0,this.picked=!1,this.isBaseObject=!0,void 0===t&&(t=r.Util.GUID()),this.id=t}addTo(t){return t&&"ThreeLayer"===t.type?t.addMesh([this]):console.error("layer only support maptalks.ThreeLayer"),this}remove(){const t=this.getLayer();return t&&t.removeMesh([this]),this}getObject3d(){return this.object3d}getId(){return this.id}setId(t){const e=this.getId();return this.id=t,this._fire("idchange",{old:e,new:t,target:this}),this}getType(){return this.type}getOptions(){return this.options}getProperties(){return(this.options||{}).properties}setProperties(t){const e=Object.assign({},this.getProperties());return this.options.properties=t,this._fire("propertieschange",{old:e,new:t,target:this}),this}getLayer(){return this.options.layer}getMap(){const t=this.getLayer();if(t)return t.getMap()}getCenter(){const t=this.getOptions(),{coordinate:e,lineString:n,polygon:i}=t;if(e)return e instanceof r.Coordinate?e:new r.Coordinate(e);{const t=i||n;if(t&&t.getCenter)return t.getCenter()}}getAltitude(){return this.getOptions().altitude}setAltitude(t){if(r.Util.isNumber(t)){const e=this.getLayer().altitudeToVector3(t,t).x;if(this.getObject3d().position.z=e,this.options.altitude=t,this.pickObject3d&&(this.pickObject3d.position.z=e),this._baseObjects&&Array.isArray(this._baseObjects))for(let t=0,n=this._baseObjects.length;t<n;t++)this._baseObjects[t]&&(this._baseObjects[t].getObject3d().position.z=e)}return this}supportHeight(){return this.getOptions().heightEnable}getHeight(){const{height:t}=this.getOptions();return r.Util.isNumber(t)?t:0}setHeight(t){if(!r.Util.isNumber(t)||this._baseObjects||!this.supportHeight())return this;const e=this.getLayer();if(!e)return this;const{geometry:n}=this.getObject3d();if(n instanceof o.BufferGeometry){const{position:i}=n.attributes||{};if(!i)return this;const r=i.array;let o=1/0,s=-1/0;for(let t=0,e=r.length;t<e;t+=3){const e=r[t+2];o=Math.min(e,o),s=Math.max(e,s)}const a=(o+s)/2;let h=e.altitudeToVector3(t,t).x;h=Math.max(h,1e-6);for(let t=0,e=r.length;t<e;t+=3)r[t+2]>a&&(r[t+2]=h);n.attributes.position.needsUpdate=!0,n.computeBoundingBox(),n.computeBoundingSphere(),this.getOptions().height=t}return this}show(){return this._zoomVisible&&(this.getObject3d().visible=!0,this._fire("show")),this._visible=!0,this}hide(){return this.getObject3d().visible=!1,this._fire("hide"),this._visible=!1,this._hideUI(),this}isVisible(){return!!this.getObject3d().visible}getSymbol(){return this.getObject3d().material}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0,t.vertexColors=this.getObject3d().material.vertexColors;const e=this.getObject3d().material.clone();this.getObject3d().material=t,this._fire("symbolchange",{old:e,new:t,target:this})}return this}setInfoWindow(t){return this.removeInfoWindow(),this.infoWindow=new r.ui.InfoWindow(t),this.infoWindow.addTo(this),this}getInfoWindow(){return this.infoWindow}openInfoWindow(t){return(t=t||this.getCenter())instanceof r.Coordinate||(t=new r.Coordinate(t)),t&&this.infoWindow&&this.infoWindow.show(t),this}closeInfoWindow(){return this.infoWindow&&this.infoWindow.hide(),this}removeInfoWindow(){return this.infoWindow&&(this.infoWindow.remove(),delete this.infoWindow),this}setToolTip(t,e){return this.removeToolTip(),this.toolTip=new r.ui.ToolTip(t,e),this.toolTip.addTo(this),this}getToolTip(){return this.toolTip}openToolTip(t){return(t=t||this.getCenter())instanceof r.Coordinate||(t=new r.Coordinate(t)),t&&this.toolTip&&this.toolTip.show(t),this}closeToolTip(){return this.toolTip&&this.toolTip.hide(),this}removeToolTip(){return this.toolTip&&(this.toolTip.remove(),delete this.toolTip),this}_hideUI(){return this.closeInfoWindow(),this.closeToolTip(),this}animateShow(t={},e){this._showPlayer&&this._showPlayer.cancel(),r.Util.isFunction(t)&&(e=t={});const n=t.duration||1e3,i=t.easing||"out",o=this._showPlayer=r.animation.Animation.animate({scale:1},{duration:n,easing:i},(t=>{const n=t.styles.scale;n>0&&(this.getObject3d().scale.z=n),e&&e(t,n)}));return o.play(),o}getMinZoom(){return this.getOptions().minZoom}getMaxZoom(){return this.getOptions().maxZoom}isAsynchronous(){return this.getOptions().asynchronous}get bloom(){return this.getOptions().bloom}fire(t,e){return this._fire(t,e),this._vt&&this._vt.onSelectMesh&&this._vt.onSelectMesh(t,e),this}config(){return this}setPickObject3d(t){return this.pickObject3d=t,this.pickObject3d.__parent=this,this}_initOptions(t){return this.options=r.Util.extend({},y,t),this}_createMesh(t,e){return this.object3d=new o.Mesh(t,e),this.object3d.__parent=this,this}_createInstancedMesh(t,e,n){return this.object3d=new o.InstancedMesh(t,e,n),this.object3d.__parent=this,this}_createGroup(){return this.object3d=new o.Group,this.object3d.__parent=this,this}_createLine(t,e){return this.object3d=new o.Line(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_createLine2(t,e){return this.object3d=new g(t,e),this.object3d.computeLineDistances(),this.object3d.__parent=this,this}_createPoints(t,e){return this.object3d=new o.Points(t,e),this.object3d.__parent=this,this}_createLineSegments(t,e){return this.object3d=new o.LineSegments(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_computeLineDistances(t){const e=t.attributes.position.array,n=t.attributes.position.count,i=new Float32Array(n);i[0]=0;const r=new o.Vector3(0,0,0),s=new o.Vector3(0,0,0);for(let t=1;t<n;t++){const n=3*(t-1);r.x=e[n],r.y=e[n+1],r.z=e[n+2];const o=3*t;s.x=e[o],s.y=e[o+1],s.z=e[o+2];const a=s.distanceTo(r);i[t]=i[t-1]+a}a(t,"lineDistance",new o.BufferAttribute(i,1))}}const m=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];function b(t){return t.geometry?t.geometry.type:null}function _(t){const e=b(t);if(e)for(let t=0,n=m.length;t<n;t++)if(m[t]===e)return!0;return!1}function w(t){const e=b(t);return!(!e||e!==m[4]&&e!==m[5])}function M(t){const e=b(t);return!(!e||e!==m[2]&&e!==m[3])}function O(t){const e=b(t);return!(!e||e!==m[0]&&e!==m[1])}function A(t){const e=b(t);return!!(e&&e.indexOf("Multi")>-1)}function j(t){return t.geometry?t.geometry.coordinates:[]}function T(t,e){const n=b(t);if(!n||!t.geometry)return null;const i=t.geometry.coordinates;if(!i)return null;let o=0,s=0,a=0;switch(n){case"Point":o=i[0],s=i[1],a++;break;case"MultiPoint":case"LineString":for(let t=0,e=i.length;t<e;t++)o+=i[t][0],s+=i[t][1],a++;break;case"MultiLineString":case"Polygon":for(let t=0,e=i.length;t<e;t++)for(let e=0,n=i[t].length;e<n;e++)o+=i[t][e][0],s+=i[t][e][1],a++;break;case"MultiPolygon":for(let t=0,e=i.length;t<e;t++)for(let e=0,n=i[t].length;e<n;e++)for(let n=0,r=i[t][e].length;n<r;n++)o+=i[t][e][n][0],s+=i[t][e][n][1],a++}const h=o/a,c=s/a;return e?(e.x=h,e.y=c,e):new r.Coordinate(h,c)}function C(t){const e=b(t);if(!e||!t.geometry)return null;const n=t.geometry,i=t.properties||{},r=n.coordinates;if(!r)return null;const o=[];let s;switch(e){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}if(s)for(let t=0,e=r.length;t<e;t++)o.push({type:"Feature",geometry:{type:s,coordinates:r[t]},properties:i});else o.push(t);return o}
2
- /*!
3
- * poly-extrude v0.2.0
4
- */var S={exports:{}};function L(t,e,n){n=n||2;var i,r,o,s,a,h,c,l=e&&e.length,u=l?e[0]*n:t.length,d=k(t,0,u,n,!0),f=[];if(!d||d.next===d.prev)return f;if(l&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=k(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(G(s));for(a.sort(F),r=0;r<a.length;r++)n=V(a[r],n);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var p=n;p<u;p+=n)(a=t[p])<i&&(i=a),(h=t[p+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);c=0!==(c=Math.max(o-i,s-r))?32767/c:0}return I(d,f,n,i,r,c,0),f}function k(t,e,n,i,r){var o,s;if(r===et(t,e,n,i)>0)for(o=e;o<n;o+=i)s=X(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=X(o,t[o],t[o+1],s);return s&&W(s,s.next)&&(J(s),s=s.next),s}function P(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!W(i,i.next)&&0!==Q(i.prev,i,i.next))i=i.next;else{if(J(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function I(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=R(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(h=c;a>0||h>0&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,i,r,o);for(var a,h,c=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?E(t,i,r,o):B(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),J(t),t=h.next,c=h.next;else if((t=h)===c){s?1===s?I(t=U(P(t),e,n),e,n,i,r,o,2):2===s&&z(t,e,n,i,r,o):I(P(t),e,n,i,r,o,1);break}}}function B(t){var e=t.prev,n=t,i=t.next;if(Q(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,h=n.y,c=i.y,l=r<o?r<s?r:s:o<s?o:s,u=a<h?a<c?a:c:h<c?h:c,d=r>o?r>s?r:s:o>s?o:s,f=a>h?a>c?a:c:h>c?h:c,p=i.next;p!==e;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&D(r,a,o,h,s,c,p.x,p.y)&&Q(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function E(t,e,n,i){var r=t.prev,o=t,s=t.next;if(Q(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,c=s.x,l=r.y,u=o.y,d=s.y,f=a<h?a<c?a:c:h<c?h:c,p=l<u?l<d?l:d:u<d?u:d,g=a>h?a>c?a:c:h>c?h:c,y=l>u?l>d?l:d:u>d?u:d,v=R(f,p,e,n,i),x=R(g,y,e,n,i),m=t.prevZ,b=t.nextZ;m&&m.z>=v&&b&&b.z<=x;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==r&&m!==s&&D(a,l,h,u,c,d,m.x,m.y)&&Q(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&D(a,l,h,u,c,d,b.x,b.y)&&Q(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;m&&m.z>=v;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==r&&m!==s&&D(a,l,h,u,c,d,m.x,m.y)&&Q(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&D(a,l,h,u,c,d,b.x,b.y)&&Q(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function U(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!W(r,o)&&N(r,i,i.next,o)&&$(r,o)&&$(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),J(i),J(i.next),i=t=o),i=i.next}while(i!==t);return P(i)}function z(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&H(s,a)){var h=Y(s,a);return s=P(s,s.next),h=P(h,h.next),I(s,e,n,i,r,o,0),void I(h,e,n,i,r,o,0)}a=a.next}s=s.next}while(s!==t)}function F(t,e){return t.x-e.x}function V(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var h,c=n,l=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&D(o<u?r:s,o,l,u,o<u?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),$(i,t)&&(h<d||h===d&&(i.x>n.x||i.x===n.x&&Z(n,i)))&&(n=i,d=h)),i=i.next}while(i!==c);return n}(t,e);if(!n)return e;var i=Y(n,t);return P(i,i.next),P(n,n.next)}function Z(t,e){return Q(t.prev,t,e.prev)<0&&Q(e.next,t,t.next)<0}function R(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function G(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function D(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function H(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&N(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&($(t,e)&&$(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Q(t.prev,t,e.prev)||Q(t,e.prev,e))||W(t,e)&&Q(t.prev,t,t.next)>0&&Q(e.prev,e,e.next)>0)}function Q(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function W(t,e){return t.x===e.x&&t.y===e.y}function N(t,e,n,i){var r=q(Q(t,e,n)),o=q(Q(t,e,i)),s=q(Q(n,i,t)),a=q(Q(n,i,e));return r!==o&&s!==a||(!(0!==r||!K(t,n,e))||(!(0!==o||!K(t,i,e))||(!(0!==s||!K(n,t,i))||!(0!==a||!K(n,e,i)))))}function K(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function q(t){return t>0?1:t<0?-1:0}function $(t,e){return Q(t.prev,t,t.next)<0?Q(t,e,t.next)>=0&&Q(t,t.prev,e)>=0:Q(t,e,t.prev)<0||Q(t,t.next,e)<0}function Y(t,e){var n=new tt(t.i,t.x,t.y),i=new tt(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function X(t,e,n,i){var r=new tt(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function J(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function tt(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function et(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}S.exports=L,S.exports.default=L,L.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(et(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var c=e[a]*n,l=a<h-1?e[a+1]*n:t.length;s-=Math.abs(et(t,c,l,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,f=i[a+1]*n,p=i[a+2]*n;u+=Math.abs((t[d]-t[p])*(t[f+1]-t[d+1])-(t[d]-t[f])*(t[p+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},L.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n};var nt=S.exports;function it(t){for(var e,n,i=0,r=1,o=t.length;r<o;)e=n||t[0],i+=((n=t[r])[0]-e[0])*(n[1]+e[1]),r++;return i>0}function rt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function ot(t,e){var n=e[0],i=e[1],r=e[2],o=Math.sqrt(n*n+i*i+r*r)||1;return t[0]=n/o,t[1]=i/o,t[2]=r/o,t}function st(t,e){function n(t,e,n,i){t[0]=e,t[1]=n,t[2]=i}for(var i,r,o,s,a,h,c,l,u,d=[],f=[],p=[],g=[],y=[],v=[],x=t.length,m=new Float32Array(e.length),b=0;b<x;){var _=3*t[b],w=3*t[b+1],M=3*t[b+2];n(d,e[_],e[_+1],e[_+2]),n(f,e[w],e[w+1],e[w+2]),n(p,e[M],e[M+1],e[M+2]),rt(y,p,f),rt(g,d,f),i=v,o=g,s=void 0,a=void 0,h=void 0,c=void 0,l=void 0,u=void 0,s=(r=y)[0],a=r[1],h=r[2],c=o[0],l=o[1],u=o[2],i[0]=a*u-h*l,i[1]=h*c-s*u,i[2]=s*l-a*c;for(var O=0;O<3;O++)m[_+O]+=v[O],m[w+O]+=v[O],m[M+O]+=v[O];b+=3}for(var A=0,j=m.length;A<j;)n(v,m[A],m[A+1],m[A+2]),ot(v,v),m[A]=v[0]||0,m[A+1]=v[1]||0,m[A+2]=v[2]||0,A+=3;return m}function at(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var e=0,n=0,i=0,r=t.length;i<r;i++){var o=t[i],s=o.position,a=o.indices;e+=s.length,n+=a.length}for(var h={position:new Float32Array(e),normal:new Float32Array(e),uv:new Float32Array(e/3*2),indices:new Uint32Array(n),results:t},c=0,l=0,u=0,d=0,f=0,p=t.length;f<p;f++){var g=t[f],y=g.position,v=g.indices,x=g.normal,m=g.uv;h.position.set(y,c),h.normal.set(x,c),h.uv.set(m,d);for(var b=0,_=v.length;b<_;){var w=v[b]+l;h.indices[u]=w,u++,b++}d+=m.length,c+=y.length,l+=y.length/3}return h}function ht(t){return 180*t/Math.PI}function ct(t){return t/180*Math.PI}function lt(t,e,n,i,r,o){var s=3*n,a=3*i,h=3*r,c=3*o,l=e[s],u=e[s+1],d=e[s+2],f=e[a],p=e[a+1],g=e[a+2],y=e[h],v=e[h+1],x=e[h+2],m=e[c],b=e[c+1],_=e[c+2];Math.abs(u-p)<Math.abs(l-f)?(t.push(l,1-d),t.push(f,1-g),t.push(y,1-x),t.push(m,1-_)):(t.push(u,1-d),t.push(p,1-g),t.push(v,1-x),t.push(b,1-_))}function ut(t,e){e=Object.assign({},{depth:2},e);var n=t.map((function(t){for(var n=0,i=t.length;n<i;n++){var r=t[n];dt(r),0===n?it(r)||(t[n]=r.reverse()):it(r)&&(t[n]=r.reverse()),ft(r)&&r.splice(r.length-1,1)}var o=function(t,e){for(var n=function(t){var e=0,n=0,i=t.length;for(;n<i;)e+=t[n].length,n++;return e}(t),i=t.length,r=[],o=new Float32Array(2*n),s=[],a=[],h=3*n,c=2*n,l=e.depth,u=0,d=0,f=0,p=0;p<i;p++){var g=t[p];p>0&&r.push(u/2);for(var y=0,v=g.length;y<v;){var x=g[y],m=x[0],b=x[1];o[u++]=m,o[u++]=b,s[d]=m,s[d+1]=b,s[d+2]=l,s[h+d]=m,s[h+d+1]=b,s[h+d+2]=0,a[f]=m,a[f+1]=b,a[c+f]=m,a[c+f+1]=b,d+=3,f+=2,y++}}return{flatVertices:o,holes:r,points:s,count:n,uvs:a}}(t,e);return o.polygon=t,function(t,e){for(var n=[],i=t.count,r=0,o=e.length;r<o;r+=3){var s=e[r],a=e[r+1],h=e[r+2];n[r]=s,n[r+1]=a,n[r+2]=h;var c=o+r,l=i+s,u=i+a,d=i+h;n[c]=l,n[c+1]=u,n[c+2]=d}t.index=n}(o,nt(o.flatVertices,o.holes,2)),function(t,e){for(var n=t.points,i=t.index,r=t.polygon,o=t.uvs,s=e.depth,a=0,h=r.length;a<h;a++)for(var c=r[a],l=0,u=c.length;l<u;){var d=c[l],f=c[l+1];l===u-1&&(f=c[0]);var p=n.length/3,g=d[0],y=d[1],v=f[0],x=f[1];n.push(g,y,s,v,x,s,g,y,0,v,x,0);var m=p+2,b=p+3,_=p,w=p+1;i.push(m,_,b,_,w,b),lt(o,n,m,b,_,w),l++}}(o,e),o.position=new Float32Array(o.points),o.indices=new Uint32Array(o.index),o.uv=new Float32Array(o.uvs),o.normal=st(o.indices,o.position),o})),i=at(n);return i.polygons=t,i}function dt(t){ft(t)||t.push(t[0])}function ft(t){var e=t.length,n=t[0],i=n[0],r=n[1],o=t[e-1],s=o[0],a=o[1];return i===s&&r===a}function pt(t,e){e=Object.assign({},{depth:2,lineWidth:1},e);var n=t.map((function(t){var n=function(t,e){var n=0,i=e.lineWidth/2,r=[],o=[],s=[],a=t.length,h=0;for(;h<a-1;){var c=t[h],l=t[h+1],u=l[1]-c[1],d=l[0]-c[0],f=0,p=ht(Math.atan(u/d));if(n=p,0===h)f=p,f-=90;else{var g=t[h-1];gt.x=g[0]-c[0],gt.y=g[1]-c[1],yt.x=l[0]-c[0],yt.y=l[1]-c[1],f=p-xt(gt,yt)/2}var y=vt(ct(f),i,c),v=y[0],x=y[1];r.push(v,x),mt(v,c,l)?(o.push(v),s.push(x)):(o.push(x),s.push(v)),h++}var m=n,b=ct(m-=90),_=t[a-2],w=t[a-1],M=vt(b,i,w),O=M[0],A=M[1];r.push(O,A),mt(O,_,w)?(o.push(O),s.push(A)):(o.push(A),s.push(O));return{offsetPoints:r,leftPoints:o,rightPoints:s}}(t,e);return n.line=t,function(t,e){var n=e.depth,i=[],r=[],o=[],s=t.leftPoints,a=t.rightPoints,h=0,c=s.length;for(;h<c;){var l=3*h,u=s[h],d=u[0],f=u[1],p=u[2];i[l]=d,i[l+1]=f,i[l+2]=n+p;var g=a[h],y=g[0],v=g[1],x=g[2],m=3*c+l;i[m]=y,i[m+1]=v,i[m+2]=n+x;var b=2*c*3+l;i[b]=d,i[b+1]=f,i[b+2]=p;var _=2*c*3+3*c+l;i[_]=y,i[_+1]=v,i[_+2]=x,h++}h=0,c=i.length;for(;h<c;){var w=i[h],M=i[h+1];o.push(w,M),h+=3}h=0,c=s.length;for(;h<c-1;){var O=h,A=h+1,j=O+c,T=A+c;r.push(O,j,A),r.push(j,T,A);var C=h+2*c,S=C+1,L=C+c,k=S+c;r.push(C,L,S),r.push(L,k,S),h++}t.index=r,t.points=i,t.uvs=o}(n,e),function(t,e){var n=t.points,i=t.index,r=t.leftPoints,o=t.rightPoints,s=t.uvs,a=e.depth,h=[r,o];function c(t,e){var r=n.length/3;n.push(t[0],t[1],a+t[2],e[0],e[1],a+e[2],t[0],t[1],t[2],e[0],e[1],e[2]);var o=r+2,h=r+3,c=r,l=r+1;i.push(o,c,h,c,l,h),lt(s,n,o,h,c,l)}for(var l=0,u=h.length;l<u;l++){var d=h[l];l>0&&(d=(d=d.map((function(t){return t}))).reverse());for(var f=0,p=d.length-1;f<p;){c(d[f],d[f+1]),f++}}for(var g=r.length,y=[o[0],r[0],r[g-1],o[g-1]],v=0;v<y.length;v+=2){c(y[v],y[v+1])}}(n,e),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.index),n.uv=new Float32Array(n.uvs),n.normal=st(n.indices,n.position),n})),i=at(n);return i.lines=t,i}var gt={x:0,y:0},yt={x:0,y:0};function vt(t,e,n){var i=n[0],r=n[1],o=n[2]||0,s=[i+Math.cos(t)*e,r+Math.sin(t)*e,o],a=t+=Math.PI;return[s,[i+Math.cos(a)*e,r+Math.sin(a)*e,o]]}var xt=function(t,e){var n=t.x,i=t.y,r=e.x,o=e.y,s=n*r+i*o,a=n*o-i*r;return(Math.atan2(a,s)/Math.PI*180+360)%360};function mt(t,e,n){var i=e[0],r=e[1],o=n[0],s=n[1];return(r-s)*t[0]+(o-i)*t[1]+i*s-o*r>0}function bt(t,e,n={}){return void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]}function _t(t,e,n={}){return void 0===n[t]&&(n[t]=e.altitudeToVector3(t,t).x),n[t]}function wt(t=[]){let e=0,n=0;const i=t.length;for(let o=0;o<i;o++){const{coordinate:i,lnglat:s,lnglats:a,xy:h,xys:c}=t[o],l=i||s||a||h||c||t[o];let u,d;Array.isArray(l)?(u=l[0],d=l[1]):l instanceof r.Coordinate&&(u=l.x,d=l.y),e+=u,n+=d}return new r.Coordinate(e/i,n/i)}function Mt(t,e,n,i){if(void 0===e||"number"!=typeof e||0===e)return 0;let r;r=t instanceof o.BufferGeometry?t.attributes.position.array:Array.isArray(t)||t instanceof Float32Array?t:t.position;let s=0;if(r){i?(void 0===i[e]&&(i[e]=n.altitudeToVector3(e,e).x),s=i[e]):s=n.altitudeToVector3(e,e).x;const t=r.length;if(r[0]instanceof o.Vector3)for(let e=0;e<t;e++)r[e].z+=s;else for(let e=0;e<t;e+=3)r[e+2]+=s}return s}function Ot(t){const e=t.length;let n=0;for(let i=0;i<e;i++){const{count:e}=t[i].position;n+=e}return new Float32Array(3*n)}function At(t=[]){const e=t.length,n=new Float64Array(2*e);for(let i=0;i<e;i++){let e,r;const o=t[i];o.x?(e=o.x,r=o.y):(e=o[0],r=o[1]),n[2*i]=e,n[2*i+1]=r}return n.buffer}const jt=new o.Color("#fff"),Tt=new o.Color("#fff");function Ct(t,e,n,i,r,o){const s=Lt(t,n,i,r,!1);if(!s)return null;o?(null==o[e]&&(o[e]=n.altitudeToVector3(e,e).x),e=o[e]):e=n.altitudeToVector3(e,e).x;const{position:a,normal:h,uv:c,indices:l}=ut(s,{depth:e});return{position:a,normal:h,uv:c,indices:l}}function St(t,e,n,i){void 0===i&&(i=0);const r=t.attributes.position.array,s=r.length;let h;if(Tt.setStyle(e),jt.setStyle(n),Array.isArray(i)){let t=0;for(let e=0,n=i.length;e<n;e++){const{count:n}=i[e].position;t+=3*n}h=new Float32Array(t)}else h=new Float32Array(r.length);if(Array.isArray(i))for(let t=0,e=i.length;t<e;t++){const{middleZ:e,start:n,end:o}=i[t].position;for(let t=n;t<o;t+=3){r[t+2]>e?(h[t]=jt.r,h[t+1]=jt.g,h[t+2]=jt.b):(h[t]=Tt.r,h[t+1]=Tt.g,h[t+2]=Tt.b)}}else for(let t=0;t<s;t+=3){r[t+2]>i?(h[t]=jt.r,h[t+1]=jt.g,h[t+2]=jt.b):(h[t]=Tt.r,h[t+1]=Tt.g,h[t+2]=Tt.b)}return a(t,"color",new o.BufferAttribute(h,3,!0)),h}function Lt(t,e,n,i,o=!1){if(!t)return null;let s=[];if(t instanceof r.MultiPolygon)s=t.getGeometries().map((r=>kt(r,e,n||t.getCenter(),i,o)));else if(t instanceof r.Polygon){const r=kt(t,e,n||t.getCenter(),i,o);s.push(r)}else if(w(t))if(A(t)){const r=C(t);for(let a=0,h=r.length;a<h;a++)s.push(kt(r[a],e,n||T(t),i,o))}else{const r=kt(t,e,n||T(t),i,o);s.push(r)}return s}function kt(t,e,n,i,o=!1){let s,a,h;if(w(t)){const e=j(t);s=e[0],a=e.slice(1,e.length),n=n||T(t)}else t instanceof r.Polygon&&(s=t.getShell(),a=t.getHoles(),n=n||t.getCenter());i=i||e.coordinateToVector3(n),h=o?e.coordinatiesToGLFloatArray(s,i).positons2d:e.coordinatiesToGLArray(s,i);const c=[o?h.buffer:h];if(a&&a.length>0)for(let t=0,n=a.length;t<n;t++){let n;n=o?e.coordinatiesToGLFloatArray(a[t],i).positons2d:e.coordinatiesToGLArray(a[t],i),c.push(o?n.buffer:n)}return c}function Pt(t){if(!t)return null;let e=[];if(t instanceof r.MultiPolygon)e=t.getGeometries().map((t=>It(t,!1)));else if(t instanceof r.Polygon){const n=It(t,!1);e.push(n)}else if(w(t))if(A(t)){const n=C(t);for(let t=0,i=n.length;t<i;t++)e.push(It(n[t],!0))}else{const n=It(t,!0);e.push(n)}return e}function It(t,e){let n,i;if(e){const e=j(t);n=e[0],i=e.slice(1,e.length)}else t instanceof r.Polygon&&(n=t.getShell(),i=t.getHoles());const o=[At(n)];if(i&&i.length>0)for(let t=0,e=i.length;t<e;t++){const e=At(i[t]);o.push(e)}return o}function Bt(t,e,n,i=!0){let s,a,h=[];if(Array.isArray(t)&&t[0]instanceof o.Vector3)h=t;else{Array.isArray(t)&&(t=new r.LineString(t));const o=0;let c,l;_(t)?(c=j(t),n||(l=T(t))):t instanceof r.LineString&&(c=t.getCoordinates(),n||(l=t.getCenter()));const u=e.coordinateToVector3(n||l);if(i)for(let t=0,n=c.length;t<n;t++){const n=c[t],i=e.coordinateToVector3(n,o).sub(u);h.push(i)}else{const t=e.coordinatiesToGLFloatArray(c,u);s=t.positions,a=t.positons2d}}if(!i)return{positions:s,positionsV:h,positions2d:a,arrayBuffer:a.buffer};a=new Float32Array(2*h.length),s=new Float32Array(3*h.length);for(let t=0,e=h.length;t<e;t++){const e=3*t,n=h[t];s[e]=n.x,s[e+1]=n.y,s[e+2]=n.z;const i=2*t;a[i]=n.x,a[i+1]=n.y}return{positions:s,positionsV:h,positions2d:a,arrayBuffer:a.buffer}}function Et(t,e,n,i){const r=[],o=[],s=[];let a,h;for(let n=0,c=t.length;n<c;n++){const c=t[n];for(let t=0,n=c.length;t<n;t++){const n=c[t],l=n.join(",").toString();a?(l!==a&&(h=e.coordinateToVector3(n,0).sub(i),r.push(h.x,h.y,h.z),o.push(h),s.push(n)),a=l):(s.push(n),a=l,h=e.coordinateToVector3(n,0).sub(i),r.push(h.x,h.y,h.z),o.push(h))}}return{positions:r,positionsV:o,lnglats:s}}function Ut(t){let e;const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];for(let t=0,i=r.length;t<i;t++){const i=r[t],o=i.join(",").toString();e?(o!==e&&n.push(i),e=o):(n.push(i),e=o)}}return n}function zt(t,e=1,n=1,i,r){const o=Bt(t,i,r).positionsV,s=[];for(let t=0,e=o.length;t<e;t++){const e=o[t];s.push([e.x,e.y])}const{indices:a,position:h,normal:c,uv:l}=pt([s],{lineWidth:e,depth:n});return{position:h,normal:c,indices:a,uv:l}}function Ft(t){let e,n=[];return t instanceof r.MultiLineString?(n=t.getGeometries(),e=t.getCenter()):t instanceof r.LineString?(n.push(t),e=t.getCenter()):_(t)&&(e=T(t),A(t)?n=C(t):n.push(t)),{lineStrings:n,center:e}}function Vt(t){const e=new Float32Array(2*t.length-6);let n=0;for(let i=0,r=t.length/3;i<r;i++){const o=t[3*i],s=t[3*i+1],a=t[3*i+2];if(i>0&&i<r-1){const t=3*n;e[t]=o,e[t+1]=s,e[t+2]=a,n++}const h=3*n;e[h]=o,e[h+1]=s,e[h+2]=a,n++}return e}function Zt(t){let e=0;const n=t.length;if(1===n)return t[0];for(let i=0;i<n;i++)e+=t[i].length;const i=new Float32Array(e);let r=0;for(let e=0;e<n;e++)i.set(t[e],r),r+=t[e].length;return i}function Rt(t){return t instanceof r.LineString?At(t.getCoordinates()):M(t)?At(t.geometry.coordinates):void 0}let Gt;function Dt(){return Gt||(Gt=new o.BufferGeometry,a(Gt,"position",new o.BufferAttribute(new Float32Array(3),3))),Gt}const Ht="__maptalks.three__";let Qt;var Wt;function Nt(){return r.worker||console.error("maptalks.worker is not defined,You can't use ThreeVectorTileLayer"),!Wt&&Qt&&(Wt=new Qt(Ht)),Wt}function Kt(t,e,n={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]):0}function qt(t,e,n={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===n[t]&&(n[t]=e.altitudeToVector3(t,t).x),n[t]):0}function $t(t,e,n,i,r=[]){const o=n.isMercator();let s,a,h;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=n.coordinateToVector3(e));const c=[],l=[],u={},d={},f=t.length;for(let s=0;s<f;s++){const a=t[s],f=r[s]?r[s]:M(i[s])?i[s].properties:i[s].getProperties()||{};e||(h=n.coordinateToVector3(f.center));let p=f.width||1,g=f.height||1,y=f.bottomHeight||0;p=Kt(p,n,u),g=qt(g,n,d),y=qt(y,n,d);const v=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];let r;r=o?Rt(i):Bt(i,n,e,!1).arrayBuffer,l.push(r),v.push(r)}const x={id:f.id,data:v,height:g,width:p,bottomHeight:y};o&&(x.center=[h.x,h.y]),c.push(x)}return{datas:c,transfer:l,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function Yt(t,e,n,i,r=[]){const o=n.isMercator();let s,a,h;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=n.coordinateToVector3(e));const c=[],l=[],u={},d=t.length;for(let s=0;s<d;s++){const a=t[s],d=r[s]?r[s]:M(i[s])?i[s].properties:i[s].getProperties()||{};e||(h=n.coordinateToVector3(d.center));let f=d.bottomHeight||0;f=qt(f,n,u);const p=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];if(o){const t=Rt(i);p.push(t),p.push(t)}else{const t=Bt(i,n,e,!1).arrayBuffer;l.push(t),p.push(t)}}const g={id:d.id,data:p,bottomHeight:f};o&&(g.center=[h.x,h.y]),c.push(g)}return{datas:c,transfer:l,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function Xt(t){return t.map((t=>t.data))}function Jt(t){return t.map((t=>t.option||t.baseObject.getOptions()))}r.worker&&(Qt=class extends r.worker.Actor{test(t,e){this.send(t,null,e)}pushQueue(t={}){const{type:e,data:n,callback:i,layer:r,key:o,center:s,lineStrings:a,options:h,id:c}=t;let l;e.indexOf("ExtrudePolygon")>-1?l=function(t=[],e,n,i=[]){const r=n.isMercator();let o,s,a;if(r){const t=n.getMap();o=t.getGLRes(),s=t.getSpatialReference().getTransformation().matrix}e&&(a=n.coordinateToVector3(e));const h=t.length,c=[],l=[],u={};for(let o=0;o<h;o++){const s=t[o],h=s,d=i[o]?i[o]:w(h)?h.properties:h.getProperties()||{};let f;e||(a=n.coordinateToVector3(d.center)),f=r?Pt(s):Lt(s,n,d.center||e,a,!0);for(let t=0,e=f.length;t<e;t++){const e=f[t];for(let t=0,n=e.length;t<n;t++)l.push(e[t])}let p=d.height||1,g=d.bottomHeight||0;p=qt(p,n,u),g=qt(g,n,u);const y={id:d.id,data:f,height:p,bottomHeight:g};r&&(y.center=[a.x,a.y]),c.push(y),h._properties&&delete h._properties}return{datas:c,transfer:l,glRes:o,matrix:s,center:r?[a.x,a.y]:null}}(n,s,r,h):"ExtrudeLines"===e?l=$t(n,s,r,a):"Point"===e||("Line"===e||"FatLine"===e?l=Yt(n,s,r,a,h):"Lines"===e||"FatLines"===e?l=Yt(n,s,r,a):"ExtrudeLine"===e?l=$t(n,s,r,a,h):"Bar"!==e&&"Bars"!==e||(l=function(t){const e=t.length,n=new Float32Array(7*e);let i=0;for(let r=0;r<e;r++){let{center:e,radialSegments:o,radius:s,height:a,altitude:h,id:c}=t[r];e=e||[0,0],n[i]=e[0],n[i+1]=e[1],n[i+2]=o||6,n[i+3]=s||1,n[i+4]=a,n[i+5]=h||0,n[i+6]=c,i+=7}const r=n.buffer;return{datas:r,transfer:[r]}}(n))),l?this.send({type:e,datas:l.datas,glRes:l.glRes,matrix:l.matrix,center:l.center},l.transfer,(function(t,e){t&&console.error(t),e.key=o,e.id=c,i(e)})):console.error(`not support '${e}' worker`)}});class te{constructor(){this.queueMap={},this.tempQueue=[],this.time=this.getCurrentTime(),this.deQueueCount=5,this.resultQueue=[]}getActor(){return Nt()}getCurrentTime(){return r.Util.now()}loop(){this.deQueue()}push(t){return this.tempQueue.push(t),t.id&&(this.queueMap[t.id]=t),this}reset(){return this.time=this.getCurrentTime(),this.tempQueue=[],this}pushResult(t){if(t)return Array.isArray(t)||(t=[t]),t.forEach((t=>{this.resultQueue.push(t)})),this}deQueue(){if(!this.resultQueue.length)return this;const t=this.deQueueCount;return(this.resultQueue.slice(0,t)||[]).forEach((t=>{const{id:e}=t;if(this.queueMap[e]){const{baseObject:n}=this.queueMap[e];n&&n._workerLoad&&n._workerLoad(t),delete this.queueMap[e]}})),this.resultQueue.splice(0,t),this}}const ee=new class extends te{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Nt().pushQueue({type:"ExtrudePolygon",layer:this.tempQueue[0].layer,data:Xt(this.tempQueue),options:Jt(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},ne=new class extends te{loop(){if(this.tempQueue.length){const t=Nt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudePolygons",layer:e.layer,data:e.data,key:e.key,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ie=new class extends te{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Nt().pushQueue({type:"ExtrudeLine",layer:this.tempQueue[0].layer,data:Xt(this.tempQueue),options:Jt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},re=new class extends te{loop(){if(this.tempQueue.length){const t=Nt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudeLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},oe=new class extends te{constructor(){super(),this.deQueueCount=200}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Nt().pushQueue({type:"Line",layer:this.tempQueue[0].layer,data:Xt(this.tempQueue),options:Jt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},se=new class extends te{loop(){if(this.tempQueue.length){const t=Nt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Lines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ae=new class extends te{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Nt().pushQueue({type:"FatLine",layer:this.tempQueue[0].layer,data:Xt(this.tempQueue),options:Jt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},he=new class extends te{loop(){if(this.tempQueue.length){const t=Nt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"FatLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ce=new class extends te{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Nt().pushQueue({type:"Bar",layer:this.tempQueue[0].layer,data:Xt(this.tempQueue),options:Jt(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},le=new class extends te{constructor(){super(),this.deQueueCount=1}loop(){if(this.tempQueue.length){const t=Nt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Bars",layer:e.layer,data:e.data,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ue={isRunning:!1,tasks:[],addTask:t=>{t&&ue.tasks.push(t)},removeTask:t=>{ue.tasks.splice(ue.tasks.indexOf(t),1)},loop(){ee.loop(),ne.loop(),ie.loop(),re.loop(),oe.loop(),se.loop(),ae.loop(),he.loop(),ce.loop(),le.loop(),ue.tasks.forEach((t=>{t&&t.loop&&t.loop()})),r.Util.requestAnimFrame(ue.loop)},star(){ue.isRunning||(ue.isRunning=!0,ue.loop())}};function de(t){const{position:e,normal:n,uv:i,indices:r}=fe(t),s=new o.BufferGeometry,h=new Float32Array(e.length);return h.fill(1,0,e.length),a(s,"color",new o.BufferAttribute(h,3)),a(s,"normal",new o.BufferAttribute(n,3)),a(s,"position",new o.BufferAttribute(e,3)),i&&i.length&&a(s,"uv",new o.BufferAttribute(i,2)),s.setIndex(new o.BufferAttribute(r,1)),s}function fe(t){const e={},n={};for(let i=0;i<t.length;++i){const r=t[i];for(const t in r)void 0===e[t]&&(e[t]=[],n[t]=0),e[t].push(r[t]),n[t]+=r[t].length}const i={};let r=0;const o=new Uint32Array(n.indices);for(const t in e)if("indices"===t){const n=e[t];let i=0;for(let t=0,s=n.length;t<s;t++){const s=n[t];for(let t=0,e=s.length;t<e;t++)o[i]=s[t]+r,i++;r+=e.position[t].length/3}}else{const r=pe(e[t],n[t]);if(!r)return null;i[t]=r}return i.indices=o,i}function pe(t,e){const n=new Float32Array(e);let i=0;for(let e=0;e<t.length;++e)n.set(t[e],i),i+=t[e].length;return n}function ge(t){const{position:e,normal:n,uv:i,indices:r}=t,s=new o.BufferGeometry;return a(s,"normal",new o.BufferAttribute(new Float32Array(n),3)),a(s,"position",new o.BufferAttribute(new Float32Array(e),3)),a(s,"uv",new o.BufferAttribute(new Float32Array(i),2)),s.setIndex(new o.BufferAttribute(new Uint32Array(r),1)),s}function ye(t){const e=new o.BufferGeometry;return a(e,"normal",t.getAttribute("normal")),a(e,"position",t.getAttribute("position").clone()),e.setIndex(t.getIndex()),e}let ve;function xe(){if(!ve){const t=1e-6;ve=new o.BoxBufferGeometry(t,t,t)}return ve}xe();const me=new o.BoxBufferGeometry(1,1,1);me.translate(0,0,.5);const be=new o.Color("#fff"),_e=new o.Color("#fff");function we(t){const{position:e,normal:n,uv:i,indices:r}=function(t,e){void 0===e&&(e={}),e=Object.assign({},{radius:1,height:2,radialSegments:6},e);for(var n=Math.round(Math.max(4,e.radialSegments)),i=e,r=i.radius,o=i.height,s=360/n/360*Math.PI*2,a=n+1,h=new Float32Array(3*a*2),c=t[0],l=t[1],u=0,d=0,f=3*a,p=2*a,g=[],y=[],v=-1;v<n;v++){var x,m,b=s*v,_=Math.cos(b)*r+c,w=Math.sin(b)*r+l;h[u]=_,h[u+1]=w,h[u+2]=0,h[u+f]=_,h[u+1+f]=w,h[u+2+f]=o,x=.5+_/r/2,m=.5+w/r/2,y[d]=x,y[d+1]=m,y[d+p]=x,y[d+1+p]=m,u+=3,d+=2,v>1&&g.push(0,v-1,v)}h[u-=3]=h[0],h[u+1]=h[1],h[u+2]=h[2];var M=h.length;h[M-3]=h[0],h[M-2]=h[1],h[M-1]=o;for(var O=g.length,A=0;A<O;A++){var j=g[A];g.push(j+a)}var T=new Float32Array(2*(3*a*2-6)),C=-1;u=2*a,d=0;for(var S=0,L=h.length/2;S<L-3;S+=3){var k=h[S],P=h[S+1],I=h[S+3],B=h[S+4];T[++C]=k,T[++C]=P,T[++C]=o,T[++C]=I,T[++C]=B,T[++C]=o,T[++C]=k,T[++C]=P,T[++C]=0,T[++C]=I,T[++C]=B,T[++C]=0;var E=u+2,U=u+3,z=u,F=u+1;g.push(z,E,F,E,U,F),u+=4;var V=d/a,Z=(d+1)/a;y.push(V,o/r/2,Z,o/r/2,V,0,Z,0),d++}var R=new Float32Array(h.length+T.length);R.set(h,0),R.set(T,h.length);var G=st(g,R);return{points:h,indices:new Uint32Array(g),position:R,normal:G,uv:new Float32Array(y)}}(t.center||[0,0],t),s=new o.BufferGeometry;return a(s,"normal",new o.BufferAttribute(n,3)),a(s,"position",new o.BufferAttribute(e,3)),a(s,"uv",new o.BufferAttribute(i,2)),s.setIndex(new o.BufferAttribute(r,1)),s}function Me(t){const e=Object.assign({},t);return e._radius&&(e.radius=e._radius),we(e)}function Oe(t,e,n,i="y",r=0){let s=0;"y"===i?s=1:"z"===i&&(s=2);const h=t.attributes.position.array,c=h.length;_e.setStyle(e),be.setStyle(n);const l=new Float32Array(c);if(Array.isArray(r))for(let t=0,e=r.length;t<e;t++){const{middleZ:e,start:n,end:i}=r[t].position;for(let t=n;t<i;t+=3){h[t+2]>e?(l[t]=be.r,l[t+1]=be.g,l[t+2]=be.b):(l[t]=_e.r,l[t+1]=_e.g,l[t+2]=_e.b)}}else for(let t=0;t<c;t+=3){h[t+s]>r?(l[t]=be.r,l[t+1]=be.g,l[t+2]=be.b):(l[t]=_e.r,l[t+1]=_e.g,l[t+2]=_e.b)}return a(t,"color",new o.BufferAttribute(l,3,!0)),l}function Ae(t){const e=[],n=t.length;let i=0;for(let e=0;e<n;e++){const{color:n}=t[e].attributes;n&&(i+=n.array.length)}const r=new Float32Array(i);let s=0;for(let n=0,i=t.length;n<i;n++){const{color:i,normal:o,position:a,uv:h}=t[n].attributes,c=t[n].index;i&&(r.set(i.array,s),s+=i.array.length),e.push({normal:o.array,uv:h.array,position:a.array,indices:c.array})}const h=de(e);r.length&&a(h,"color",new o.BufferAttribute(r,3,!0));for(let e=0,n=t.length;e<n;e++)t[e].dispose();return h}function je(){return me}const Te={radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class Ce extends x{constructor(t,e,n,i){e=r.Util.extend({},Te,e,{layer:i,coordinate:t}),super(),this._initOptions(e);const{height:o,radius:s,topColor:a,bottomColor:c,altitude:l,asynchronous:u}=e;let d;if(e.height=i.altitudeToVector3(o,o).x,e.radius=i.distanceToVector3(s,s).x,u){d=xe();const t=r.Util.GUID();this.getOptions().id=t,ce.push({data:{radius:e.radius,height:e.height,radialSegments:e.radialSegments,id:t},layer:i,id:t,baseObject:this})}else d=Me(e),a&&(Oe(d,c,a,"z",e.height/2),n.vertexColors=h());this._createMesh(d,n);const f=i.altitudeToVector3(l,l).x,p=i.coordinateToVector3(t,f);this.getObject3d().position.copy(p),this.type="Bar"}_workerLoad(t){const e=ge(t),{topColor:n,bottomColor:i,height:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(n){Oe(e,i,n,"z",this.getLayer().altitudeToVector3(r,r).x/2),s.vertexColors=h()}o.geometry=e,o.material.needsUpdate=!0,this._fire("workerload",{target:this})}}function Se(t){const e=[];return t&&t.length&&t.forEach((t=>{t=t instanceof o.Color?t:new o.Color(t),e.push(t.r,t.g,t.b)})),e}const Le={altitude:0,bottomHeight:0,colors:null};class ke extends x{constructor(t,e,n,i){e=r.Util.extend({},Le,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{lineStrings:s,center:c}=Ft(t),{asynchronous:l}=e;let u;if(l){u=Dt();const n=r.Util.GUID();this.getOptions().id=n,this.getOptions().center=c,oe.push({id:n,data:s,layer:i,key:e.key,lineString:t,baseObject:this})}else{const t=[];for(let e=0,n=s.length;e<n;e++){const n=s[e],{positions:r}=Bt(n,i,c,!1);t.push(Vt(r))}const r=Zt(t);u=new o.BufferGeometry,a(u,"position",new o.BufferAttribute(r,3)),Mt(u,e.bottomHeight,i);const l=Se(e.colors);l&&l.length&&(a(u,"color",new o.Float32BufferAttribute(l,3)),n.vertexColors=h())}this._createLineSegments(u,n);const{altitude:d}=e,f=i.altitudeToVector3(d,d).x,p=i.coordinateToVector3(c,f);this.getObject3d().position.copy(p),this.type="Line"}_workerLoad(t){const e=new o.BufferGeometry;a(e,"position",new o.BufferAttribute(new Float32Array(t.position),3));const n=Se(this.getOptions().colors),i=this.getObject3d(),r=i.material;n&&n.length&&(a(e,"color",new o.Float32BufferAttribute(n,3)),r.vertexColors=h()),this._computeLineDistances(e),i.geometry=e,i.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Pe={bottomHeight:0,width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class Ie extends x{constructor(t,e,n,i){e=r.Util.extend({},Pe,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{height:o,width:s,bottomColor:a,topColor:c,bottomHeight:l,altitude:u,asynchronous:d}=e,f=i.altitudeToVector3(o,o).x,p=i.distanceToVector3(s,s).x,{lineStrings:g,center:y}=Ft(t);let v;if(d){v=xe();const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=y,ie.push({id:e,data:g,layer:i,center:y,lineString:t,baseObject:this})}else{const t=[];let e=0;const r={};for(let n=0,o=g.length;n<o;n++){const o=zt(g[n],p,f,i,y);e=Mt(o,l,i,r),t.push(o)}v=de(t),c&&(St(v,a,c,e+f/2),n.vertexColors=h())}this._createMesh(v,n);const x=i.altitudeToVector3(u,u).x,m=i.coordinateToVector3(y,x);this.getObject3d().position.copy(m),this.type="ExtrudeLine"}_workerLoad(t){const e=ge(t),{topColor:n,bottomColor:i,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(n){const t=this.getLayer();St(e,i,n,t.altitudeToVector3(r,r).x+t.altitudeToVector3(o,o).x/2),a.vertexColors=h()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Be={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class Ee extends x{constructor(t,e,n,i){e=r.Util.extend({},Be,e,{layer:i,polygon:t}),super(),this._initOptions(e);const{height:s,topColor:c,bottomColor:l,altitude:u,bottomHeight:d,asynchronous:f}=e;let p;const g=w(t)?T(t):t.getCenter();if(f){p=xe();const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=g,ee.push({data:t,layer:i,id:e,baseObject:this})}else{p=function(t,e,n,i){const{position:r,normal:s,uv:h,indices:c}=Ct(t,e,n,i),l=new Float32Array(r.length);l.fill(1,0,r.length);const u=new o.BufferGeometry;return a(u,"color",new o.BufferAttribute(l,3)),a(u,"normal",new o.BufferAttribute(s,3)),a(u,"position",new o.BufferAttribute(r,3)),a(u,"uv",new o.BufferAttribute(h,2)),u.setIndex(new o.BufferAttribute(c,1)),u}(t,s,i);const e=Mt(p,d,i);if(c){St(p,l,c,e+i.altitudeToVector3(s,s).x/2),n.vertexColors=h()}}this._createMesh(p,n);const y=i.altitudeToVector3(u,u).x,v=i.coordinateToVector3(g,y);this.getObject3d().position.copy(v),this.type="ExtrudePolygon"}_workerLoad(t){const e=ge(t),{topColor:n,bottomColor:i,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(n){const t=this.getLayer();St(e,i,n,t.altitudeToVector3(r,r).x+t.altitudeToVector3(o,o).x/2),a.vertexColors=h()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Ue={altitude:0,coordinate:null};class ze extends x{constructor(t,e={},n){e.coordinate||(console.warn("coordinate is null,it is important to locate the model"),e.coordinate=n.getMap().getCenter()),e=r.Util.extend({},Ue,e,{layer:n,model:t}),super(),this._initOptions(e),this._createGroup(),this.getObject3d().add(t);const{altitude:i,coordinate:o}=e,s=n.altitudeToVector3(i,i).x,a=n.coordinateToVector3(o,s);this.getObject3d().position.copy(a),this.type="Model"}}const Fe=Math.PI/180,Ve=6378137;function Ze(t){return t*Fe}function Re(t,e){if(!t||!e)return 0;Array.isArray(t)||(t=t.toArray()),Array.isArray(e)||(e=e.toArray());let n=Ze(t[1]);const i=Ze(e[1]),r=n-i,o=Ze(t[0])-Ze(e[0]);return n=2*Math.asin(Math.sqrt(Math.pow(Math.sin(r/2),2)+Math.cos(n)*Math.cos(i)*Math.pow(Math.sin(o/2),2))),n*=Ve,Math.round(1e5*n)/1e5}function Ge(t,e){const{len:n,c1:i,c2:r}=t,o=r[0]-i[0],s=r[1]-i[1],a=e/n;return[i[0]+a*o,i[1]+a*s]}const De=1e3;const He={trail:5,chunkLength:50,width:2,height:1,speed:1,altitude:0,interactive:!1,heightEnable:!0};class Qe extends x{constructor(t,e,n,i){e=r.Util.extend({},He,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{width:s,height:h,altitude:c,speed:l,chunkLength:u,trail:d}=e;let f,p;_(t)?(f=T(t),p=j(t)):(f=t.getCenter(),p=t);const g=function(t,e=10){e=Math.max(e,.1),Array.isArray(t)||(t=t.getCoordinates().map((t=>t.toArray())));const n=t.length;let i=[],r=0;for(let e=0;e<n-1;e++){const n=Re(t[e],t[e+1]),o=Math.floor(n);i.push({c1:t[e],len:o,c2:t[e+1]}),r+=o}if(r<=e)return i.map((t=>[t.c1,t.c2]));if(1===i.length&&i[0].len<=e)return[[i[0].c1,i[0].c2]];const o=i.length;let s,a=0,h=0;const c=[];let l=[i[0].c1];for(;a<o;){const{len:t,c2:n}=i[a];if(h+=t,h<e&&(l.push(n),a===o-1&&c.push(l),a++),h===e&&(l.push(n),h=0,c.push(l),l=[n],a++),h>e){const n=t-h+e;s=Ge(i[a],n),l.push(s),c.push(l),h=0,i[a].c1=s,i[a].len=t-n,l=[],l.push(s)}}return c}(p,u),y=i.coordinateToVector3(f),v=new o.BufferGeometry,x=new Float32Array(3e3),m=new Float32Array(3e3),b=new Uint16Array(De);a(v,"position",new o.BufferAttribute(x,3)),a(v,"normal",new o.BufferAttribute(m,3)),v.setIndex(new o.BufferAttribute(b,1));const w=i.distanceToVector3(s,s).x,M=i.altitudeToVector3(h,h).x;this._createMesh(v,n);const O=i.altitudeToVector3(c,c).x,A=i.coordinateToVector3(f,O);this.getObject3d().position.copy(A),this._params={index:0,chunkLines:g,geometries:[],layer:i,trail:Math.max(1,d),lineWidth:w,depth:M,speed:Math.min(1,l),idx:0,loaded:!0,center:f,centerPt:y,workerInitCount:0},this._init(this._params),this.type="ExtrudeLineTrail"}_init(t){const{layer:e,trail:n,lineWidth:i,depth:o,chunkLines:s,positionMap:a,centerPt:h,center:c}=t,l=s.length,u=[];if(this.options.asynchronous){t.loaded=!1;const i=r.Util.GUID();for(let t=0;t<l;t++){const o={type:"Feature",geometry:{type:"LineString",coordinates:Ut(s.slice(t,t+n))}},a=`${i}-${t}`,h=r.Util.extend({},this.options);h.id=a,h.center=c,ie.push({id:a,data:[o],layer:e,center:c,lineString:o,baseObject:this,option:h})}}else for(let t=0;t<l;t++){const r=Et(s.slice(t,t+n),e,0,h).positionsV;u.push(zt(r,i,o,e))}}_animation(){const{index:t,geometries:e,speed:n,idx:i,chunkLines:r,trail:o,lineWidth:s,depth:a,loaded:h,layer:c,positionMap:l,centerPt:u}=this._params;if(!h)return;const d=Math.round(t);if(d>i){this._params.idx++;let t=e[d];if(!t){t=zt(Et(r.slice(d,d+o),c,0,u).positionsV,s,a,c),e[d]=t}const n=this.getObject3d();!function(t,e,n,i){const r=e.length;t.attributes.normal.count=r,t.attributes.position.count=r;const o=t.attributes.position.array,s=t.attributes.normal.array;for(let t=0;t<r;t++)o[t]=e[t],s[t]=n[t];t.index.count=i.length;for(let e=0,n=i.length;e<n;e++)t.index.array[e]=i[e]}(n.geometry,t.position,t.normal,t.indices),n.geometry.attributes.position.needsUpdate=!0,n.geometry.attributes.normal.needsUpdate=!0,n.geometry.index.needsUpdate=!0}t>=r.length-1&&(this._params.index=-1,this._params.idx=-1),this._params.index+=n}_workerLoad(t){if(!t)return this;const{id:e,indices:n,position:i,normal:o,uv:s}=t;if(!(e&&n&&i&&o&&s))return;let a=e.split("-")[1];if(a=parseInt(a),r.Util.isNumber(a)){this._params.geometries[a]={indices:new Uint32Array(n),position:new Float32Array(i),uv:new Float32Array(s),normal:new Float32Array(o)},this._params.workerInitCount++}this._params.workerInitCount===this._params.chunkLines.length&&(this._params.loaded=!0,this._fire("workerload",{target:this}))}}const We=["click","mousemove","mousedown","mouseup","dblclick","contextmenu"].join(" ").toString(),Ne=new o.MeshBasicMaterial;Ne.vertexColors=h();const Ke=t=>class extends t{_initBaseObjectsEvent(t){if(t&&Array.isArray(t)&&t.length)for(let e=0,n=t.length;e<n;e++){const n=t[e];this._proxyEvent(n)}return this}_proxyEvent(t){t.on("add",(t=>{this._showGeometry(t.target,!0)})),t.on("remove",(t=>{this._showGeometry(t.target,!1)})),t.on("mouseout",(t=>{this._mouseover=!1,this.fire("mouseout",Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))})),t.on(We,(t=>{this.fire(t.type,Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))}))}_getHideGeometryIndex(t){const e=[];let n=0;for(let i=0,r=this._geometriesAttributes.length;i<r;i++)!0===this._geometriesAttributes[i].hide&&(e.push(i),n+=this._geometriesAttributes[i][t].count);return{indexs:e,count:n}}_updateAttribute(t,e){const{indexs:n}=this._getHideGeometryIndex(e),i=this._geometryCache.attributes[e].array,r=i.length;for(let e=0;e<r;e++)t.array[e]=i[e];let s=NaN;this.getObject3d()instanceof o.LineSegments&&(s=0);for(let i=0;i<n.length;i++){const r=n[i],{start:o,end:a}=this._geometriesAttributes[r][e];for(let e=o;e<a;e++)t.array[e]=s}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.position,"position"),r.attributes.position.needsUpdate=!0,this.isHide=e}return this}getSelectMesh(){const t=this._getIndex();if(null!=t)return{data:this._datas[t],baseObject:this._baseObjects[t]}}_getIndex(t){return null==t&&(t=this.faceIndex||this.index),t}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:n}=this,i=n.length,r=Ot(n);let s=0;for(let t=0;t<i;t++){const i=e.getColor(),o=i.getHex();this._colorMap[o]=t;const{count:a}=n[t].position;this._datas[t].colorIndex=o;for(let t=0;t<a;t++)r[s]=i.r,r[s+1]=i.g,r[s+2]=i.b,s+=3}a(t,"color",new o.BufferAttribute(r,3,!0));const h=e.getColor().getHex(),c=new o.Mesh(t,Ne);c.position.copy(this.getObject3d().position),c._colorIndex=h,this.setPickObject3d(c)}},qe={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61"},$e=new r.Coordinate(0,0);class Ye extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=t.length;0===o&&console.error("polygons is empty");let s=1/0,a=1/0,c=-1/0,l=-1/0;for(let e=0;e<o;e++){const n=t[e],i=n.getCenter?n.getCenter():T(n,$e);let o,h;Array.isArray(i)?(o=i[0],h=i[1]):i instanceof r.Coordinate&&(o=i.x,h=i.y),s=Math.min(s,o),a=Math.min(a,h),c=Math.max(c,o),l=Math.max(l,h)}const u=new r.Coordinate((s+c)/2,(a+l)/2);e=r.Util.extend({},qe,e,{layer:i,polygons:t,coordinate:u});const{topColor:d,bottomColor:f,altitude:p,asynchronous:g}=e;let y;const v=[],x=[];if(super(),g)y=xe(),ne.push({id:r.Util.GUID(),layer:i,key:e.key,center:u,data:t,baseObject:this});else{const e=i.coordinateToVector3(u),r=[];let s=0;const a={};for(let n=0;n<o;n++){const o=t[n],h=w(o)?o.properties:o.getProperties()||{},c=h.height||1,l=h.bottomHeight||0,d=Ct(o,c,i,u,e,a);r.push(d);const f=Mt(d,l,i,a),{position:p,normal:g,uv:y,indices:v}=d;v.length;const m=p.length/3;g.length,y.length,x[n]={position:{middleZ:f+a[c]/2,count:m,start:s,end:s+3*m},hide:!1},s+=3*m}y=de(r),d&&(St(y,f,d,x),n.vertexColors=h())}this._initOptions(e),this._createMesh(y,n);const m=i.altitudeToVector3(p,p).x,b=i.coordinateToVector3(u,m);this.getObject3d().position.copy(b),this._baseObjects=v,this._datas=t,this._geometriesAttributes=x,this.faceIndex=null,this._geometryCache=ye(y),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(v),g||(this._setPickObject3d(),this._init()),this.type="ExtrudePolygons"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,w(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new Ee(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ge(t);this._geometryCache=ye(n);const{topColor:i,bottomColor:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(i&&(St(n,r,i,e),s.vertexColors=h()),o.geometry=n,o.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}function Xe(t,e,n){const i=t.project(n),r=e.width/2,o=e.height/2;return{x:Math.round(i.x*r+r),y:Math.round(-i.y*o+o)}}const Je={altitude:0,height:0,color:null},tn=new o.Vector3;class en extends x{constructor(t,e,n,i){e=r.Util.extend({},Je,e,{layer:i,coordinate:t}),super();let{height:s,altitude:h,color:c,size:l}=e;const u=[],d=[];c&&(c=c instanceof o.Color?c:new o.Color(c),d.push(c.r,c.g,c.b));const f=i.altitudeToVector3(s,s).x,p=i.coordinateToVector3(t,f);u.push(0,0,p.z);const g=new o.BufferGeometry;a(g,"position",new o.Float32BufferAttribute(u,3,!0)),d.length&&a(g,"color",new o.Float32BufferAttribute(d,3,!0)),void 0!==l&&a(g,"size",new o.Float32BufferAttribute([l],1,!0)),e.positions=p,this._initOptions(e),this._createPoints(g,n);const y=i.altitudeToVector3(h,h).x,v=new o.Vector3(p.x,p.y,y);this.getObject3d().position.copy(v),this.type="Point"}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().positions,o=this.getOptions().altitude;let s=this.getObject3d().material.size;void 0===s&&(s=this.options.size||1);const a=this.getMap().coordToContainerPoint(t),h=e.altitudeToVector3(o,o).x;tn.x=r.x,tn.y=r.y,tn.z=r.z+h;const c=Xe(tn,n,i);return Math.sqrt(Math.pow(a.x-c.x,2)+Math.pow(a.y-c.y,2))<=s/2}}function nn(t,e){const{minx:n,miny:i,maxx:r,maxy:o}=t,[s,a]=e;return n<=s&&s<=r&&i<=a&&a<=o}class rn{constructor(t,e,n,i){this.minlng=t,this.minlat=e,this.maxlng=n,this.maxlat=i,this.minx=1/0,this.miny=1/0,this.maxx=-1/0,this.maxy=-1/0,this.coordinates=[],this.positions=[],this.indexs=[],this.key=null}updateBBoxPixel(t){let e=1/0,n=1/0,i=-1/0,o=-1/0;const{minlng:s,minlat:a,maxlng:h,maxlat:c}=this;return[[s,a],[s,c],[h,a],[h,c]].map((t=>new r.Coordinate(t))).map((e=>t.coordToContainerPoint(e))).forEach((t=>{e=Math.min(e,t.x),n=Math.min(n,t.y),i=Math.max(i,t.x),o=Math.max(o,t.y)})),this.minx=e,this.miny=n,this.maxx=i,this.maxy=o,this}containsCoordinate(t){let e,n;Array.isArray(t)?(e=t[0],n=t[1]):t instanceof r.Coordinate&&(e=t.x,n=t.y);const{minlng:i,minlat:o,maxlng:s,maxlat:a}=this;return i<=e&&e<=s&&o<=n&&n<=a}isRecCross(t,e){const{x:n,y:i}=t,r={minx:n-e/2,miny:i-e/2,maxx:n+e/2,maxy:i+e/2},{minx:o,miny:s,maxx:a,maxy:h}=r;return!!(nn(this,[o,s])||nn(this,[o,h])||nn(this,[a,s])||nn(this,[a,h])||nn(r,[this.minx,this.miny])||nn(r,[this.minx,this.maxy])||nn(r,[this.maxx,this.miny])||nn(r,[this.maxx,this.maxy]))}static initGrids(t,e,n,i){const r=[],o=(n-t)/30,s=(i-e)/30;let a=t,h=e;for(let n=0;n<30;n++){a=t+n*o;for(let t=0;t<30;t++){h=e+t*s;const i=new rn(a,h,a+o,h+s);i.key=t+"-"+n,r.push(i)}}return{grids:r,averageX:o,averageY:s,ROWS:30,COLS:30}}}const on={altitude:0},sn=new o.Vector3;function an(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}class hn extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]),e=r.Util.extend({},on,e,{layer:i,points:t});let s=1/0,h=1/0,c=-1/0,l=-1/0;for(let e=0,n=t.length;e<n;e++){const{coordinate:n}=t[e];let i,o;Array.isArray(n)?(i=n[0],o=n[1]):n instanceof r.Coordinate&&(i=n.x,o=n.y),t[e].coords=[i,o],s=Math.min(s,i),h=Math.min(h,o),c=Math.max(c,i),l=Math.max(l,o)}const u=i.coordinateToVector3([(s+c)/2,(h+l)/2]),{grids:d,averageX:f,averageY:p,ROWS:g,COLS:y}=rn.initGrids(s,h,c,l);d.length;const v=new Float32Array(3*t.length),x=[],m=new Float32Array(3*t.length),b=new Float32Array(t.length),_=[],w=[],M={};let O=0,A=!1,j=!1;const T=new o.Vector3(0,0,0);for(let e=0,n=t.length;e<n;e++){let{coordinate:n,height:r,color:a,size:c,coords:l}=t[e];const y=3*e;a&&(A=!0,a=a instanceof o.Color?a:new o.Color(a),m[y]=a.r,m[y+1]=a.g,m[y+2]=a.b),c&&(j=!0,b[e]=c,O=Math.max(O,c));const _=_t(r,i,M),C=i.coordinateToVector3(n,_);T.x=C.x,T.y=C.y,T.z=C.z,T.sub(u),v[y]=T.x,v[y+1]=T.y,v[y+2]=T.z,x.push(C),w[e]={position:{count:1,start:3*e,end:3*e+3},hide:!1};let S=an((l[1]-h)/p,4),L=an((l[0]-s)/f,4);S-=1,L-=1,S=Math.max(0,S),L=Math.max(0,L),S=Math.ceil(S),L=Math.ceil(L);const k=L*g+S;d[k]&&(d[k].positions.push(C),d[k].indexs.push(e))}const C=new o.BufferGeometry;a(C,"position",new o.BufferAttribute(v,3,!0)),A&&a(C,"color",new o.BufferAttribute(m,3,!0)),j&&a(C,"size",new o.BufferAttribute(b,1,!0)),e.positions=x,super(),this._initOptions(e),this._createPoints(C,n);const S=e.altitude,L=i.altitudeToVector3(S,S).x,k=u.clone();k.z=L,this.getObject3d().position.copy(k),this._baseObjects=_,this._datas=t,this.faceIndex=null,this._geometriesAttributes=w,this._geometryCache=C.clone(),this.isHide=!1,this._initBaseObjectsEvent(_),this._grids=d,this._bindMapEvents(),this.type="Points",this.maxSize=O}_bindMapEvents(){const t=this.getMap(),e="zoomstart zooming zoomend movestart moving moveend pitch rotate";this.on("add",(()=>{this._updateGrids(),t.on(e,this._updateGrids,this)})),this.on("remove",(()=>{t.off(e,this._updateGrids,this)}))}_updateGrids(){const t=this.getMap();this._grids.forEach((e=>{e.indexs.length&&e.updateBBoxPixel(t)}))}getSelectMesh(){const t=this.faceIndex;if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],{coordinate:n,height:i,color:r,size:o}=e;this._baseObjects[t]=new en(n,{height:i,index:t,color:r,size:o},this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().altitude,o=this.getMap(),s=e.altitudeToVector3(r,r).x;let a=this.getObject3d().material.size;const h=void 0===a,c=o.coordToContainerPoint(t),l=[];if(this._grids.forEach((t=>{t.indexs.length&&t.isRecCross(c,h?this.maxSize:a)&&l.push(t)})),l.length<1)return!1;for(let t=0,e=l.length;t<e;t++)for(let e=l[t].positions.length-1;e>=0;e--){h&&(a=this._datas[l[t].indexs[e]].size||1);const r=l[t].positions[e];sn.x=r.x,sn.y=r.y,sn.z=r.z+s;const o=Xe(sn,n,i);if(Math.sqrt(Math.pow(c.x-o.x,2)+Math.pow(c.y-o.y,2))<=a/2)return this.faceIndex=l[t].indexs[e],!0}return!1}}const cn={coordinate:"",radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61"};class ln extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const s=t.length,a=wt(t),c=i.coordinateToVector3(a),l=[],u=[],d=[];let f=0;const p={},g={};let y;super(),e=r.Util.extend({},{altitude:0,layer:i,points:t},cn,e),this._initOptions(e);const v=new o.Vector3;if(e.asynchronous){y=xe();const e=r.Util.GUID();this.getOptions().id=e;const n=[];for(let e=0;e<s;e++){const o=r.Util.extend({index:e},cn,t[e]),{radius:s,radialSegments:a,altitude:h,height:l,coordinate:u}=o,d=bt(s,i,p);t[e]._radius=d;const f=_t(l,i,g),y=_t(h,i,g),x=i.coordinateToVector3(u,0,v).sub(c);n.push({radialSegments:a,radius:d,height:f,center:[x.x,x.y],altitude:y})}le.push({id:e,data:n,layer:i,baseObject:this})}else{for(let e=0;e<s;e++){const o=r.Util.extend({index:e},cn,t[e]),{radius:s,radialSegments:a,altitude:y,topColor:x,bottomColor:m,height:b,coordinate:_}=o,w=bt(s,i,p),M=_t(b,i,g),O=_t(y,i,g),A=i.coordinateToVector3(_,0,v).sub(c),j=Me({radius:w,height:M,radialSegments:a,center:[A.x,A.y]});x&&(Oe(j,m,x,"z",M/2),n.vertexColors=h());const T=j.attributes.position.array;for(let t=0,e=T.length;t<e;t+=3)T[t+2]+=O;l.push(j);const C=new Ce(_,o,n,i);u.push(C),j.index.count;const S=j.attributes.position.count;j.attributes.normal.count,j.attributes.uv.count,d[e]={position:{count:S,start:f,end:f+3*S},hide:!1},f+=3*S}y=Ae(l)}this._createMesh(y,n);const x=e.altitude,m=i.altitudeToVector3(x,x).x,b=c.clone();b.z=m,this.getObject3d().position.copy(b),this._baseObjects=u,this._datas=t,this._geometriesAttributes=d,this.faceIndex=null,this._geometryCache=ye(y),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(u),e.asynchronous||(this._setPickObject3d(),this._init()),this.type="Bars"}identify(){return this.picked}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,e,{index:t,asynchronous:!1});this._baseObjects[t]=new Ce(e.coordinate,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ge(t);this._geometryCache=ye(n);const{topColor:i,bottomColor:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(i&&(Oe(n,r,i,"z",e),s.vertexColors=h()),o.geometry=n,o.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const un={width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61"};class dn extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=[],s=[],a=t.length;for(let e=0;e<a;e++){const n=Ft(t[e]);o.push(n.center),s.push(n.lineStrings)}const c=wt(o);e=r.Util.extend({},un,e,{layer:i,lineStrings:t,coordinate:c});const{altitude:l,topColor:u,bottomColor:d,asynchronous:f}=e;let p;const g=[],y=[];if(super(),f)p=xe(),re.push({id:r.Util.GUID(),layer:i,key:e.key,center:c,data:s,lineStrings:t,baseObject:this});else{const e=[];let o=0;const l={},f={};for(let n=0;n<a;n++){const a=t[n],h=r.Util.extend({},un,_(a)?a.properties:a.getProperties(),{index:n}),{height:u,width:d,bottomHeight:p}=h,g=bt(d,i,l),v=_t(u,i,f),x=s[n],m=[];let b=0;for(let t=0,e=x.length;t<e;t++){const e=zt(x[t],g,v,i,c);b=Mt(e,p,i,l),m.push(e)}const w=fe(m);e.push(w);const{position:M,normal:O,indices:A}=w;A.length;const j=M.length/3;O.length,y[n]={position:{middleZ:b+v/2,count:j,start:o,end:o+3*j},hide:!1},o+=3*j}p=de(e),u&&(St(p,d,u,y),n.vertexColors=h())}this._initOptions(e),this._createMesh(p,n);const v=i.altitudeToVector3(l,l).x,x=i.coordinateToVector3(c,v);this.getObject3d().position.copy(x),this._baseObjects=g,this._datas=t,this._geometriesAttributes=y,this.faceIndex=null,this._geometryCache=ye(p),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(g),f||(this._setPickObject3d(),this._init()),this.type="ExtrudeLines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,M(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new Ie(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ge(t);this._geometryCache=ye(n);const{topColor:i,bottomColor:r,bottomHeight:o,height:s}=this.getOptions(),a=this.getObject3d().material;if(i&&(St(n,r,i,e),a.vertexColors=h()),this.getObject3d().geometry=n,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const fn={altitude:0,colors:null};class pn extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const s=[],h=[],c=t.length;for(let e=0;e<c;e++){const n=Ft(t[e]);s.push(n.center),h.push(n.lineStrings)}const l=wt(s);e=r.Util.extend({},fn,e,{layer:i,lineStrings:t,coordinate:l}),super(),this._initOptions(e);const{asynchronous:u}=e;let d;const f=[],p={};let g=[],y=0,v=[];if(u)d=Dt(),se.push({id:r.Util.GUID(),layer:i,key:e.key,center:l,data:h,lineStrings:t,baseObject:this});else{for(let t=0;t<c;t++){const e=h[t];let n=0;for(let t=0,r=e.length;t<r;t++){const r=M(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=Bt(e[t],i,l,!1);Mt(o,r.bottomHeight,i,p),n+=o.length/3*2-2,v.push(Vt(o))}g[t]={position:{count:n,start:y,end:y+3*n},hide:!1},y+=3*n}const t=Zt(v);d=new o.BufferGeometry,a(d,"position",new o.BufferAttribute(t,3))}this._createLineSegments(d,n);const{altitude:x}=e,m=i.altitudeToVector3(x,x).x,b=i.coordinateToVector3(l,m);this.getObject3d().position.copy(b),this._baseObjects=f,this._datas=t,this._geometriesAttributes=g,this.faceIndex=null,this.index=null,this._geometryCache=d.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(f),u||(this._setPickObject3d(),this._init()),this.type="Lines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=r.Util.extend({},this.getOptions(),{index:t},M(e)?e.properties:e.getProperties());this._baseObjects[t]=new ke(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:n}=this,i=n.length,r=Ot(n);let s=0;for(let t=0;t<i;t++){const i=e.getColor(),o=i.getHex();this._colorMap[o]=t;const{count:a}=n[t].position;this._datas[t].colorIndex=o;for(let t=0;t<a;t++)r[s]=i.r,r[s+1]=i.g,r[s+2]=i.b,s+=3}a(t,"color",new o.BufferAttribute(r,3,!0));const c=this.getObject3d().material.clone();c.color.set("#fff"),c.vertexColors=h();const l=e.getColor().getHex(),u=new o.LineSegments(t,c);u.position.copy(this.getObject3d().position),u._colorIndex=l,this.setPickObject3d(u)}identify(t){return this.picked}_workerLoad(t){const{position:e,geometriesAttributes:n}=t;this._geometriesAttributes=n;const i=new o.BufferGeometry;if(a(i,"position",new o.BufferAttribute(new Float32Array(e),3)),this._computeLineDistances(i),this._geometryCache=i.clone(),this.getObject3d().geometry=i,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const gn=[],yn=[];function vn(){return{waitingQueue:gn,currentQueue:yn}}function xn(t,e){for(let n=0,i=t.length;n<i;n++){const i=t[n];if(i){const{key:r,callback:o}=i;if(e===r)return t.splice(n,1),o}}return null}const mn=document.createElement("canvas");let bn;function _n(t,e=!1){if(bn)return bn;const n=mn.getContext("2d");return n.clearRect(0,0,256,256),n.save(),bn=mn.toDataURL(),bn}function wn(t=1,e=1){let n;return"undefined"==typeof document||(n=document.createElement("canvas"),t&&(n.width=t),e&&(n.height=e)),n}mn.width=mn.height=256;class Mn extends r.TileLayer{constructor(t,e={}){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},e)),this._opts=null,this._layer=null,this.material=null,this.getMaterial=null,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime()}isAsynchronous(){return this._opts.worker}getBaseObjects(){const t=this._loadTiles,e=[];for(let n in t){const t=this._baseObjectKeys[n];if(t&&Array.isArray(t)&&t.length)for(let n=0,i=t.length;n<i;n++)e.push(t[n])}return e}onSelectMesh(t,e){}formatBaseObjects(t,e){return[]}loopMessage(t){}getTileData(t){const{key:e,url:n,callback:i,img:o}=t;r.Ajax.getJSON(n,{},(function(t,n){t?(console.error(t),i(e,null,o)):i(e,n,o)}))}_getCurentTileKeys(){const t=this.getTiles().tileGrids||[],e=[],n={};for(let i=0,r=t.length;i<r;i++){const r=t[i].tiles||[];for(let t=0,i=r.length;t<i;t++){const{id:i}=r[t];e.push(i),n[i]=!0}}return{keys:e,keysMap:n}}_isLoad(){const{keys:t}=this._getCurentTileKeys(),e=Object.keys(this._renderer.tilesInView);return t.length===e.length}_layerOnLoad(){const t=(new Date).getTime();if(t-this._layerLaodTime<20)return;this._layerLaodTime=t;const e=this._renderer.tilesInView,n=this._loadTiles,i=this._layer,r=this._baseObjectKeys,o=Object.keys(e).length,s=Object.keys(n).length,a=[];if(o&&s)for(let t in n)e[t]||r[t]&&(r[t]||[]).forEach((t=>{a.push(t)}));if(a.length&&i.removeMesh(a,!1),o&&s)for(let t in e)if(!n[t])if(r[t]){const e=r[t];i.addMesh(e)}else{const{x:e,y:n,z:i}=this._getXYZOfIndex(t);this.getTileUrl(e,n,i)}this._loadTiles=Object.assign({},e),this._diffCache()}_init(){}_workerLoad(t){const e=t.target._img;e.currentCount++,e.currentCount===e.needCount&&(e.src=_n(e._key,this._opts.debug))}_generateBaseObjects(t,e,n){if(e&&n){const{keysMap:i}=this._getCurentTileKeys();if(!i[t])return void(n.src=_n(0,this._opts.debug));const r=this.formatBaseObjects(t,e);if(r.length){n.needCount=r.length,n.currentCount=0;for(let e=0,i=r.length;e<i;e++){const i=r[e];i._img=n,i._vt=this,this.isVisible()||i.hide(),this._cachetile(t,i),i.isAsynchronous()||n.currentCount++}this._layer.addMesh(r,!1),n.needCount===n.currentCount&&(n.src=_n(0,this._opts.debug)),this.isAsynchronous()?r.filter((t=>t.isAsynchronous())).forEach((t=>{t.on("workerload",this._workerLoad,this)})):n.src=_n(0,this._opts.debug)}else n.src=_n(0,this._opts.debug);this._loadTiles[t]=!0}else n&&(n.src=_n(0,this._opts.debug))}_diffCache(){if(Object.keys(this._baseObjectKeys).length>this._renderer.tileCache.max){const t=this._renderer.tileCache.data,e=this._renderer.tilesInView,n=[];for(let i in this._baseObjectKeys)t[i]||e[i]||((this._baseObjectKeys[i]||[]).forEach((t=>{t.isAdd&&n.push(t)})),this._diposeBaseObject(i),delete this._baseObjectKeys[i]);n.length&&this._layer.removeMesh(n,!1)}}_diposeBaseObject(t){const e=this._baseObjectKeys[t];e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t._geometryCache&&t._geometryCache.dispose();const e=t._baseObjects;e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t=null})),t._datas=null,t._geometriesAttributes=null,t._faceMap=null,t._colorMap=null,t.pickObject3d&&t.pickObject3d.geometry.dispose(),t=null}))}_cachetile(t,e){this._baseObjectKeys[t]||(this._baseObjectKeys[t]=[]),this._baseObjectKeys[t].push(e)}_getXYZOfIndex(t){const e=t.indexOf("_")>-1?"_":"-";let[n,i,r]=t.split(e).slice(1,4);return{x:parseInt(i),y:parseInt(n),z:parseInt(r)}}_getTileExtent(t,e,n){const i=this.getMap()._getResolution(n);return this._getTileConfig().getTilePrjExtent(t,e,i)}_getTileLngLatExtent(t,e,n){const i=this._getTileExtent(t,e,n);let o=i.getMax(),s=i.getMin();const a=this.getMap().getProjection();return s=a.unproject(s),o=a.unproject(o),new r.Extent(s,o)}}const On={worker:!1};class An extends Mn{constructor(t,e={},n,i){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},On,e)),this._opts=e,this._layer=i,this.getMaterial=n,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime(),this._init()}formatBaseObjects(t,e){const n=this._opts,i=[],s=this.isAsynchronous();for(let a in e){const h=e[a]||{};let c;if(Array.isArray(h)?c=h:"FeatureCollection"===h.type&&(c=h.features),c&&c.length){const e=[],l=[],u=[];for(let t=0,n=c.length;t<n;t++){const n=c[t];if(w(n))e.push(n);else if(M(n)){const t=C(n);for(let e=0,n=t.length;e<n;e++)l.push(t[e])}else if(O(n)){const t=C(n);for(let e=0,n=t.length;e<n;e++)u.push(r.Util.extend({},t[e].properties,t[e],{coordinate:j(t[e])}))}}if(e.length){const o=this._getMaterial(a,e,t,h);if(o){const h=this._layer.toExtrudePolygons(e,r.Util.extend({},{topColor:"#fff",layerName:a,asynchronous:s,key:t},n),o);i.push(h)}}if(l.length){const e=this._getMaterial(a,l,t,h);if(e&&(e instanceof o.LineBasicMaterial||e instanceof o.LineDashedMaterial)){const t=this._layer.toLines(l,r.Util.extend({},{layerName:a,asynchronous:s},n),e);i.push(t)}}if(u.length){const e=this._getMaterial(a,u,t,h);if(e&&e instanceof o.PointsMaterial){const t=this._layer.toPoints(u,r.Util.extend({},{layerName:a,asynchronous:s},n),e);i.push(t)}}}}return i}loopMessage(t){const{currentQueue:e}=vn();e.length>0&&this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=function(t){if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;!function(t){const e=xn(gn,t);e&&e(t)}((t.info||{}).id)},t.renderer.loadTileImage=(t,e,n)=>{t._key=n,function(t,e,n,i,r){const o={key:t,url:e,callback:n,img:i,vt:r};yn.length<10?(yn.push(o),r.loopMessage(o)):gn.push(o)}(n,e,((t,e,n)=>{this._generateBaseObjects(t,e,n),function(t,e){if(xn(yn,t),gn.length){yn.push(gn[0]),gn.splice(0,1);const t=yn[yn.length-1];e.loopMessage(t)}}(t,this)}),t,this)}}))}_getMaterial(t,e,n,i){return this.getMaterial&&r.Util.isFunction(this.getMaterial)?this.getMaterial(t,e,n,i):null}}function jn(t,e,n,i){const{position:r,uv:s,normal:h,indexs:c}=function(t,e,n,i){const r=t/n,o=e/i,s=-t/2,a=e/2,h=-e/2,c=(n+1)*(i+1),l=new Float32Array(3*c),u=new Float32Array(2*c),d=new Float32Array(3*c),f=new Uint32Array(10*c);let p=0,g=0,y=0;for(let c=0;c<=i;c++)for(let v=0;v<=n;v++){const x=s+r*v,m=a-o*c;l[p]=x,l[p+1]=m,l[p+2]=0,d[p]=0,d[p+1]=0,d[p+2]=1;const b=(x-s)/t,_=(m-h)/e;if(u[g]=b,u[g+1]=_,p+=3,g+=2,v<n&&c<i){const t=c*(n+1)+v,e=t+1,i=(n+1)*(c+1)+v,r=i+1;f[y]=t,f[y+1]=i,f[y+2]=e,f[y+3]=i,f[y+4]=r,f[y+5]=e,y+=6}}const v=new Uint32Array(y);for(let t=0,e=v.length;t<e;t++)v[t]=f[t];return{position:l,uv:u,normal:d,indexs:v}}(t,e,n,i),l=new o.BufferGeometry;return a(l,"position",new o.BufferAttribute(r,3)),a(l,"normal",new o.BufferAttribute(h,3)),a(l,"uv",new o.BufferAttribute(s,2)),l.setIndex(new o.BufferAttribute(c,1)),l}const Tn=new o.TextureLoader,Cn=document.createElement("canvas"),Sn=256;function Ln(t){if(!t)return null;let e;return"string"==typeof t?(e=new Image,e.src=t):t instanceof HTMLCanvasElement?(e=new Image,e.src=t.toDataURL()):t instanceof Image&&(e=new Image,e.src=t.src,e.crossOrigin=t.crossOrigin),e&&!e.crossOrigin&&(e.crossOrigin="Anonymous"),e}const kn=new Map;function Pn(t,e,n,i){if(!e||!n)return;const{imageWidth:r,imageHeight:s}=i;let a;if(a=t instanceof Uint32Array||t instanceof Uint8ClampedArray?t:function(t,e=Sn,n=Sn){Cn.width=e,Cn.height=n;const i=Cn.getContext("2d");return i.drawImage(t,0,0,e,n),i.getImageData(0,0,e,n).data}(t,r,s),!a)return void console.error("image is error type data",t);let h=0,c=0,l=0;const u=new o.Vector3,d=kn;for(let t=0,i=a.length;t<i;t+=4){const i=.1*(256*a[t]*256+256*a[t+1]+a[t+2])-1e4;let o=0;if(0!==c&&c+1!==s&&0!==l&&l+1!==r){const t=d.get(i);void 0!==t?o=t:(o=n.altitudeToVector3(i,i,null,u).x,d.set(i,o))}e.attributes.position.array[3*h+2]=o,h++,l++,l===r&&(c++,l=0)}e.attributes.position.needsUpdate=!0}const In={interactive:!1,altitude:0,image:null,imageWidth:256,imageHeight:256,texture:null};class Bn extends x{constructor(t,e,n,i){e=r.Util.extend({},In,e,{layer:i,extent:t});const{texture:o,image:s,altitude:a,imageHeight:h,imageWidth:c}=e;t instanceof r.Extent||(t=new r.Extent(t));const{xmin:l,ymin:u,xmax:d,ymax:f}=t;let p=1/0,g=1/0,y=-1/0,v=-1/0;[[l,u],[l,f],[d,f],[d,u]].forEach((t=>{const e=i.coordinateToVector3(t),{x:n,y:r}=e;p=Math.min(n,p),g=Math.min(r,g),y=Math.max(n,y),v=Math.max(r,v)}));const x=(y-p)/c,m=(v-g)/h;p-=x,y+=x,g-=m,v+=m;const b=Math.abs(y-p),_=Math.abs(v-g),w=Ln(s),M=Ln(o),O=jn(b,_,c-1,h-1);super(),this._initOptions(e),this._createMesh(O,n);const A=i.altitudeToVector3(a,a).x,j=i.coordinateToVector3(t.getCenter(),A);this.getObject3d().position.copy(j),n.transparent=!0,w&&(w.onload=()=>{Pn(w,O,i,{imageWidth:c,imageHeight:h})},w.onerror=function(){console.error(`not load ${w.src}`)}),M?(n.opacity=0,Tn.load(M.src,(t=>{n.map=t,n.opacity=1,n.needsUpdate=!0}))):n.opacity=1,this.type="Terrain"}updateData(t){return Pn(t,this.getObject3d().geometry,this.getLayer(),this.getOptions()),this}}const En={scale:1,tileDivisor:4};class Un extends Mn{constructor(t,e={},n,i){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},En,e)),this._opts=e,this._layer=i,this.material=n,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._imgQueue={},this._layerLaodTime=(new Date).getTime(),this._init()}isAsynchronous(){return!1}formatBaseObjects(t,e){const n=this.options,i=[],{scale:r,tileDivisor:o}=n,{x:s,y:a,z:h}=this._getXYZOfIndex(t),c=this.getMap().getZoom(),l=this.getTileUrl(s,a,h),[u,d]=this.options.tileSize,f=this._getTileLngLatExtent(s,a,h),p=this.material.clone();if(h+1>=Math.round(c)){const t=new Bn(f,{image:e,imageWidth:u/o,imageHeight:d/o,texture:l},p,this._layer);t.getObject3d().scale.set(r,r,1),i.push(t)}return i}loopMessage(t){this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=t=>{if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;const e=t.info||{},n=this._imgQueue[e.id];n&&(n.src="",n.onload=null,n.onerror=null,delete this._imgQueue[e.id])},t.renderer.loadTileImage=(t,e,n)=>{t._key=n;const i=new Image;this._imgQueue[n]=i;const r={key:n,url:e,rgbImage:i,callback:(t,e,n)=>{this._generateBaseObjects(t,e,n)},img:t,vt:this};this.loopMessage(r)}}))}}
5
- /*!
6
- * Code from baidu mapv
7
- * License: BSD-3
8
- * https://github.com/huiyan-fe/mapv
9
- *
10
- */function zn(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function Fn(t,e,n){var i=Vn(n),r=function(t){var e=t.min||0;return e}(n),o=i-r,s=n.range||null,a=0,h=1024;s&&2===s.length&&(a=(s[0]-r)/o*1024),s&&2===s.length&&(h=(s[1]-r)/o*1024);for(var c,l=n.maxOpacity||.8,u=n.minOpacity||0,d=3,f=t.length;d<f;d+=4)c=4*t[d],t[d]/256>l&&(t[d]=256*l),t[d]/256<u&&(t[d]=256*u),c&&c>=a&&c<=h?(t[d-3]=e[c],t[d-2]=e[c+1],t[d-1]=e[c+2]):t[d]=0}function Vn(t){return t.max||100}function Zn(t,e,n){var i=Vn(n),r=
11
- /*!
12
- * Code from baidu mapv
13
- * License: BSD-3
14
- * https://github.com/huiyan-fe/mapv
15
- *
16
- */
17
- function(t){var e=t/2,n=t+e,i=1e4,r=wn(2*n,2*n),o=r.getContext("2d");return o.shadowBlur=e,o.shadowColor="black",o.shadowOffsetX=o.shadowOffsetY=i,o.beginPath(),o.arc(n-i,n-i,t,0,2*Math.PI,!0),o.closePath(),o.fill(),r}(n._size||n.size||13),o=r.width/2,s=r.height/2,a=e,h={};for(var c in a.forEach((function(t){var e=void 0===t.count?1:t.count,n=Math.min(1,e/i).toFixed(2);h[n]=h[n]||[],h[n].push(t)})),h)if(!isNaN(c)){var l=h[c];t.beginPath(),n.withoutAlpha||(t.globalAlpha=c),l.forEach((function(e){var n=e.coordinate,a=void 0===e.count?1:e.count;t.globalAlpha=a/i,t.drawImage(r,n[0]-o,n[1]-s)}))}}zn.prototype.setMax=function(t){this.max=t||100},zn.prototype.setMin=function(t){this.min=t||0},zn.prototype.setMaxSize=function(t){this.maxSize=t||35},zn.prototype.setMinSize=function(t){this.minSize=t||0},zn.prototype.initPalette=function(){var t=this.gradient,e=wn(256,1),n=this.paletteCtx=e.getContext("2d"),i=n.createLinearGradient(0,0,256,1);for(var r in t)i.addColorStop(parseFloat(r),t[r]);n.fillStyle=i,n.fillRect(0,0,256,1)},zn.prototype.getColor=function(t){var e=this.getImageData(t);return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]/256+")"},zn.prototype.getImageData=function(t){var e=this.paletteCtx.getImageData(0,0,256,1).data;if(void 0===t)return e;var n=this.max,i=this.min;t>n&&(t=n),t<i&&(t=i);var r=4*Math.floor((t-i)/(n-i)*255);return[e[r],e[r+1],e[r+2],e[r+3]]},zn.prototype.getSize=function(t){var e=this.max,n=this.min,i=this.maxSize,r=this.minSize;return t>e&&(t=e),t<n&&(t=n),e>n?r+(t-n)/(e-n)*(i-r):i},zn.prototype.getLegend=function(t){var e=this.gradient,n=t.width||20,i=t.height||180,r=wn(n,i),o=r.getContext("2d"),s=o.createLinearGradient(0,i,0,0);for(var a in e)s.addColorStop(parseFloat(a),e[a]);return o.fillStyle=s,o.fillRect(0,0,n,i),r};var Rn={draw:function(t,e,n){if(!(t.canvas.width<=0||t.canvas.height<=0)){var i=n.strength||.3;t.strokeStyle="rgba(0,0,0,"+i+")";var r=wn(t.canvas.width,t.canvas.height),o=r.getContext("2d");o.scale(devicePixelRatio,devicePixelRatio),n=n||{},t.save();var s=new zn({gradient:n.gradient});if(Zn(o,e,n),!n.absolute){var a=o.getImageData(0,0,t.canvas.width,t.canvas.height);Fn(a.data,s.getImageData(),n),t.putImageData(a,0,0),t.restore()}s=null,r=null}},drawGray:Zn,colorize:Fn};const Gn={altitude:0,interactive:!1,min:0,max:100,size:13,gradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},gridScale:.5},Dn=2048;class Hn extends x{constructor(t,e,n,i){Array.isArray(t)||(t=[t]);let s=1/0,c=1/0,l=-1/0,u=-1/0;const d=[];for(let e=0,n=t.length;e<n;e++){const{coordinate:n,lnglat:r,xy:o}=t[e],a=n||r||o;if(!a){console.warn("not find coordinate");continue}const h=i.coordinateToVector3(a);d.push(h);const{x:f,y:p}=h;s=Math.min(s,f),c=Math.min(c,p),l=Math.max(l,f),u=Math.max(u,p)}e=r.Util.extend({},Gn,e,{layer:i,points:t});let{gridScale:f,altitude:p}=e;const g=Math.abs(l-s),y=Math.abs(u-c),v=Math.max(g*f,y*f);if(v>Dn){console.warn(`gridScale: ${f} it's too big. I hope it's a smaller value,canvas max size is 2048* 2048`);f=Dn/(v/f)}const x=Math.ceil(g*f),m=Math.ceil(y*f),b=x/g,_=m/y,w=[];for(let e=0,n=d.length;e<n;e++){const n=d[e];n.x-=s,n.y-=c,n.x*=b,n.y*=_,n.y=m-n.y,w.push({coordinate:[n.x,n.y],count:t[e].count})}let M=wn(x,m),O=M.getContext("2d");Rn.drawGray(O,w,e);const A=O.getImageData(0,0,O.canvas.width,O.canvas.height);let j=-1/0;const T=new Float32Array(A.data.length/4),C=new Float32Array(A.data.length/4);for(let t=3,e=A.data.length,n=0;t<e;t+=4){const e=A.data[t];j=Math.max(j,e),C[n]=e,e<=0&&(T[n]=1),n++}const S=new zn({gradient:e.gradient});Rn.colorize(A.data,S.getImageData(),e),M=null,O=null;const L=jn(g,y,x-1,m-1),k=L.getIndex().array,P=L.attributes.position.array,I=new Float32Array(P.length),B=new Uint32Array(6*P.length),E=new o.Color;let U=0;for(let t=0,e=P.length,n=0,i=k.length,r=0,o=A.data.length,s=0;t<Math.max(e,i,o);t+=3){if(t<e){const e=C[s];e>0&&(P[t+2]=e/j)}if(n<i){const t=k[n],e=k[n+1],i=k[n+2];T[t]&&T[e]&&T[i]||(B[U]=t,B[U+1]=e,B[U+2]=i,U+=3)}if(r<o){const t=`rgb(${A.data[r]},${A.data[r+1]},${A.data[r+2]})`;E.setStyle(t),I[n]=E.r,I[n+1]=E.g,I[n+2]=E.b}n+=3,r+=4,s++}const z=new Uint32Array(U);for(let t=0;t<U;t++)z[t]=B[t];L.setIndex(new o.BufferAttribute(z,1)),a(L,"color",new o.BufferAttribute(I,3,!0)),n.vertexColors=h(),super(),this._initOptions(e),this._createMesh(L,n);const F=i.altitudeToVector3(p,p).x;this.getObject3d().position.copy(new o.Vector3((s+l)/2,(c+u)/2,F)),this.type="HeatMap"}}const Qn=new o.Color;let Wn=1;class Nn{constructor(t){this.object3ds=[],this.layer=t,this.camera=t.getCamera(),this.renderer=t.getThreeRenderer(),this.pickingTexture=new o.WebGLRenderTarget(1,1),this.pickingScene=new o.Scene}getColor(){return Qn.setHex(Wn),Wn++,Qn}add(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=t,this.pickingScene.add(t))}return this}remove(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=null,this.pickingScene.remove(t))}return this}isEmpty(){if(0===this.pickingScene.children.length)return!0;for(let t=0,e=this.pickingScene.children.length;t<e;t++){const e=this.pickingScene.children[t];if(e){const t=e.__parent;if(t&&!0===t.getOptions().interactive)return!1}}return!0}pick(t){if(!t)return;if(this.isEmpty())return;const{camera:e,renderer:n,pickingTexture:i,pickingScene:r,object3ds:o,layer:s}=this,a=this.pickingScene.children.length;for(let t=0;t<a;t++){const e=this.pickingScene.children[t];e&&e.__parent&&(e.__parent.picked=!1)}const{width:h,height:c}=s._getRenderer().canvas,l=i.width,u=i.height;h===l&&c===u||i.setSize(h,c),n.setRenderTarget(i),n.clear(),e&&e.layers&&this.camera.layers.set(0),n.render(r,e);const d=new Uint8Array(4),{x:f,y:p}=t;let g=window.devicePixelRatio;const y=s.getMap();y&&(g=y.getDevicePixelRatio?y.getDevicePixelRatio():y.options.devicePixelRatio);const v=f*g,x=i.height-p*g;n.readRenderTargetPixels(i,Math.round(v),Math.round(x),1,1,d);const m=d[0]<<16|d[1]<<8|d[2],b=o[m];if(b)b.__parent&&(o[m].__parent.picked=!0);else for(let t=0;t<a;t++){const e=this.pickingScene.children[t];if(e&&e.__parent){const t=e.__parent;if(t._colorMap&&null!=t._colorMap[m]){t.picked=!0,t.index=t._colorMap[m];break}}}n.setRenderTarget(null)}}const Kn={bottomHeight:0,altitude:0};class qn extends x{constructor(t,e,n,i){e=r.Util.extend({},Kn,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{asynchronous:o}=e,{lineStrings:s,center:a}=Ft(t),h=new p;let c;if(o){const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=a,ae.push({id:e,data:s,lineString:t,center:a,layer:i,baseObject:this})}else{const t=[],n={};for(let r=0,o=s.length;r<o;r++){const o=Bt(s[r],i,a,!1).positions;Mt(o,e.bottomHeight,i,n),t.push(Vt(o))}c=Zt(t),h.setPositions(c)}this._setMaterialRes(i,n),this._createLine2(h,n);const{altitude:l}=e,u=i.altitudeToVector3(l,l).x,d=i.coordinateToVector3(a,u);this.getObject3d().position.copy(d),o||(this._setPickObject3d(c,n.linewidth),this._init()),this.type="FatLine"}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){const n=new p;n.setPositions(t);const i=this.getLayer().getPick().getColor(),r=[];for(let e=0,n=t.length/3;e<n;e++)r.push(i.r,i.g,i.b);n.setColors(r);const o=new d({color:"#fff",linewidth:e,vertexColors:h()});this._setMaterialRes(this.getLayer(),o);const s=i.getHex(),a=new g(n,o);a.position.copy(this.getObject3d().position),a._colorIndex=s,this.setPickObject3d(a)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}_workerLoad(t){const e=new Float32Array(t.position),n=this.getObject3d();if(n.geometry.setPositions(e),n.computeLineDistances(),this._setPickObject3d(e,n.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const $n={altitude:0,colors:null};class Yn extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=[],s=[],a=t.length;for(let e=0;e<a;e++){const n=Ft(t[e]);o.push(n.center),s.push(n.lineStrings)}const h=wt(o);e=r.Util.extend({},$n,e,{layer:i,lineStrings:t,coordinate:h}),super(),this._initOptions(e);const{asynchronous:c}=e,l=new p,u=[],d={};let f,g,y=[],v=0,x=[];if(c)he.push({id:r.Util.GUID(),data:s,key:e.key,center:h,layer:i,baseObject:this,lineStrings:t});else{for(let t=0;t<a;t++){const e=s[t];let n=0;for(let t=0,r=e.length;t<r;t++){const r=M(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=Bt(e[t],i,h,!1);Mt(o,r.bottomHeight,i,d),n+=o.length/3*2-2,x.push(Vt(o))}y[t]={position:{count:n,start:v,end:v+3*n},instanceStart:{count:n,start:v,end:v+3*n},instanceEnd:{count:n,start:v,end:v+3*n},hide:!1},v+=3*n}f=Zt(x),l.setPositions(f)}this._setMaterialRes(i,n),this._createLine2(l,n);const{altitude:m}=e,b=i.altitudeToVector3(m,m).x,_=i.coordinateToVector3(h,b);this.getObject3d().position.copy(_),this._baseObjects=u,this._datas=t,this._geometriesAttributes=y,this.faceIndex=null,this.index=null,this._geometryCache=new p,c||(g=new Float32Array(f),this._geometryCache.setPositions(g)),this._colorMap={},this.isHide=!1,this._initBaseObjectsEvent(u),c||(this._setPickObject3d(g,n.linewidth),this._init()),this.type="FatLines"}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){if(!this._colorMap)return;const n=this._geometryCache||new p;n.setPositions(t);const i=this.getLayer().getPick(),{_geometriesAttributes:r}=this,o=Ot(r);let s=0;for(let t=0,e=r.length;t<e;t++){const e=i.getColor(),n=e.getHex();this._colorMap[n]=t;const{count:a}=r[t].position;this._datas[t].colorIndex=n;for(let t=0;t<a;t++)o[s]=e.r,o[s+1]=e.g,o[s+2]=e.b,s+=3}n.setColors(o);const a=new d({color:"#fff",linewidth:e,vertexColors:h()});this._setMaterialRes(this.getLayer(),a);const c=i.getColor().getHex(),l=new g(n,a);l.position.copy(this.getObject3d().position),l._colorIndex=c,this.setPickObject3d(l)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=r.Util.extend({},this.getOptions(),{index:t},M(e)?e.properties:e.getProperties());this._baseObjects[t]=new qn(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_updateAttribute(t,e){const{indexs:n}=this._getHideGeometryIndex(e),i=this._geometryCache.attributes[e].array,r=i.length;for(let e=0;e<r;e++)t.array[e]=i[e];for(let i=0;i<n.length;i++){const r=n[i],{start:o,end:s}=this._geometriesAttributes[r][e];for(let e=o;e<s;e++)t.array[e]=-1e5}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.instanceStart,"instanceStart"),this._updateAttribute(r.attributes.instanceEnd,"instanceEnd"),r.attributes.instanceStart.data.needsUpdate=!0,r.attributes.instanceEnd.data.needsUpdate=!0,this.isHide=e}return this}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=this.getObject3d(),i=new Float32Array(t.position),r=new Float32Array(i);if(n.geometry.setPositions(new Float32Array(i)),this._geometryCache.setPositions(r),this._setPickObject3d(r,n.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const Xn={radius:10,height:100,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class Jn extends x{constructor(t,e,n,i){e=r.Util.extend({},Xn,e,{layer:i,coordinate:t}),super(),this._initOptions(e);const{height:o,radius:s,topColor:a,bottomColor:c,altitude:l}=e,u=i.altitudeToVector3(o,o).x,d=i.distanceToVector3(s,s).x,f=je().clone();f.scale(2*d,2*d,u),a&&(Oe(f,c,a,"z",u/2),n.vertexColors=h()),this._createMesh(f,n);const p=i.altitudeToVector3(l,l).x,g=i.coordinateToVector3(t,p);this.getObject3d().position.copy(g),this.type="Box"}}const ti={radius:10,height:100,altitude:0,topColor:null,bottomColor:"#2d2f61"};class ei extends(Ke(x)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=t.length,s=wt(t),a=i.coordinateToVector3(s),c=[],l=[],u=[];let d=0;const f={},p={};for(let e=0;e<o;e++){const o=r.Util.extend({index:e},ti,t[e]),{radius:s,altitude:g,topColor:y,bottomColor:v,height:x,coordinate:m}=o,b=bt(s,i,f),_=_t(x,i,p),w=_t(g,i,p),M=je().clone();M.scale(2*b,2*b,_),y&&(Oe(M,v,y,"z",_/2),n.vertexColors=h());const O=i.coordinateToVector3(m).sub(a),A=M.attributes.position.array;for(let t=0,e=A.length;t<e;t+=3)A[t+2]+=w,A[t]+=O.x,A[t+1]+=O.y,A[t+2]+=O.z;c.push(M);const j=new Jn(m,o,n,i);l.push(j),M.index.count;const T=M.attributes.position.count;M.attributes.normal.count,M.attributes.uv.count,u[e]={position:{count:T,start:d,end:d+3*T},hide:!1},d+=3*T}super(),e=r.Util.extend({},{altitude:0,layer:i,points:t},e),this._initOptions(e);const g=Ae(c);this._createMesh(g,n);const y=e.altitude,v=i.altitudeToVector3(y,y).x,x=a.clone();x.z=v,this.getObject3d().position.copy(x),this._baseObjects=l,this._datas=t,this._geometriesAttributes=u,this.faceIndex=null,this._geometryCache=ye(g),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(l),this._setPickObject3d(),this._init(),this.type="Boxs"}identify(t){return this.picked}}var ni={exports:{}};function ii(t,e,n){n=n||2;var i,r,o,s,a,h,c,l=e&&e.length,u=l?e[0]*n:t.length,d=ri(t,0,u,n,!0),f=[];if(!d||d.next===d.prev)return f;if(l&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=ri(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(gi(s));for(a.sort(ui),r=0;r<a.length;r++)n=di(a[r],n);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var p=n;p<u;p+=n)(a=t[p])<i&&(i=a),(h=t[p+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);c=0!==(c=Math.max(o-i,s-r))?32767/c:0}return si(d,f,n,i,r,c,0),f}function ri(t,e,n,i,r){var o,s;if(r===Ci(t,e,n,i)>0)for(o=e;o<n;o+=i)s=Ai(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=Ai(o,t[o],t[o+1],s);return s&&mi(s,s.next)&&(ji(s),s=s.next),s}function oi(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!mi(i,i.next)&&0!==xi(i.prev,i,i.next))i=i.next;else{if(ji(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function si(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=pi(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(h=c;a>0||h>0&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,i,r,o);for(var a,h,c=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?hi(t,i,r,o):ai(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),ji(t),t=h.next,c=h.next;else if((t=h)===c){s?1===s?si(t=ci(oi(t),e,n),e,n,i,r,o,2):2===s&&li(t,e,n,i,r,o):si(oi(t),e,n,i,r,o,1);break}}}function ai(t){var e=t.prev,n=t,i=t.next;if(xi(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,h=n.y,c=i.y,l=r<o?r<s?r:s:o<s?o:s,u=a<h?a<c?a:c:h<c?h:c,d=r>o?r>s?r:s:o>s?o:s,f=a>h?a>c?a:c:h>c?h:c,p=i.next;p!==e;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&yi(r,a,o,h,s,c,p.x,p.y)&&xi(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function hi(t,e,n,i){var r=t.prev,o=t,s=t.next;if(xi(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,c=s.x,l=r.y,u=o.y,d=s.y,f=a<h?a<c?a:c:h<c?h:c,p=l<u?l<d?l:d:u<d?u:d,g=a>h?a>c?a:c:h>c?h:c,y=l>u?l>d?l:d:u>d?u:d,v=pi(f,p,e,n,i),x=pi(g,y,e,n,i),m=t.prevZ,b=t.nextZ;m&&m.z>=v&&b&&b.z<=x;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==r&&m!==s&&yi(a,l,h,u,c,d,m.x,m.y)&&xi(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&yi(a,l,h,u,c,d,b.x,b.y)&&xi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;m&&m.z>=v;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==r&&m!==s&&yi(a,l,h,u,c,d,m.x,m.y)&&xi(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&yi(a,l,h,u,c,d,b.x,b.y)&&xi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ci(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!mi(r,o)&&bi(r,i,i.next,o)&&Mi(r,o)&&Mi(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),ji(i),ji(i.next),i=t=o),i=i.next}while(i!==t);return oi(i)}function li(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&vi(s,a)){var h=Oi(s,a);return s=oi(s,s.next),h=oi(h,h.next),si(s,e,n,i,r,o,0),void si(h,e,n,i,r,o,0)}a=a.next}s=s.next}while(s!==t)}function ui(t,e){return t.x-e.x}function di(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var h,c=n,l=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&yi(o<u?r:s,o,l,u,o<u?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),Mi(i,t)&&(h<d||h===d&&(i.x>n.x||i.x===n.x&&fi(n,i)))&&(n=i,d=h)),i=i.next}while(i!==c);return n}(t,e);if(!n)return e;var i=Oi(n,t);return oi(i,i.next),oi(n,n.next)}function fi(t,e){return xi(t.prev,t,e.prev)<0&&xi(e.next,t,t.next)<0}function pi(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function gi(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function yi(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function vi(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&bi(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Mi(t,e)&&Mi(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(xi(t.prev,t,e.prev)||xi(t,e.prev,e))||mi(t,e)&&xi(t.prev,t,t.next)>0&&xi(e.prev,e,e.next)>0)}function xi(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function mi(t,e){return t.x===e.x&&t.y===e.y}function bi(t,e,n,i){var r=wi(xi(t,e,n)),o=wi(xi(t,e,i)),s=wi(xi(n,i,t)),a=wi(xi(n,i,e));return r!==o&&s!==a||(!(0!==r||!_i(t,n,e))||(!(0!==o||!_i(t,i,e))||(!(0!==s||!_i(n,t,i))||!(0!==a||!_i(n,e,i)))))}function _i(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function wi(t){return t>0?1:t<0?-1:0}function Mi(t,e){return xi(t.prev,t,t.next)<0?xi(t,e,t.next)>=0&&xi(t,t.prev,e)>=0:xi(t,e,t.prev)<0||xi(t,t.next,e)<0}function Oi(t,e){var n=new Ti(t.i,t.x,t.y),i=new Ti(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function Ai(t,e,n,i){var r=new Ti(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ji(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ti(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ci(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}ni.exports=ii,ni.exports.default=ii,ii.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(Ci(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var c=e[a]*n,l=a<h-1?e[a+1]*n:t.length;s-=Math.abs(Ci(t,c,l,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,f=i[a+1]*n,p=i[a+2]*n;u+=Math.abs((t[d]-t[p])*(t[f+1]-t[d+1])-(t[d]-t[f])*(t[p+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},ii.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n};const Si=Math.PI/180,Li=[[4e3,220],[2e3,100],[1e3,30],[500,15],[100,5],[50,2],[10,1],[5,.7],[2,.1],[1,.05],[.5,.02],[.4,.01],[.1,.005],[.05,.002],[.01,.001]],ki=["mouseout","mousemove","click","mousedown","mouseup","dblclick","contextmenu","touchstart","touchmove","touchend"],Pi=new r.Coordinate(0,0),Ii=new r.Point(0,0),Bi="__webglFramebuffer";class Ei extends r.CanvasLayer{constructor(t,e){super(t,e),this._animationBaseObjectMap={},this._needsUpdate=!0,this._mousemoveTimeOut=0,this._mousedownTime=0,this._baseObjects=[],this._delayMeshes=[],this.type="ThreeLayer"}isMercator(){const t=this.getMap();if(!t)return!1;const e=t.getSpatialReference(),n=e._projection,i=e._resolutions;return!!(n&&"EPSG:3857"===n.code&&i&&i.length&&156543===Math.floor(i[0])&&t.getGLRes)}isRendering(){const t=this.getMap();return!!t&&(t.isInteracting()||t.isAnimating())}prepareToDraw(...t){}draw(t,e,n,i,r,o){this.renderScene(o,this)}drawOnInteracting(t,e,n,i,r,o,s){this.renderScene(s,this)}coordinateToVector3(t,e=0,n){const i=this.getMap();if(!i)return null;const s=Array.isArray(t);s?(Pi.x=t[0],Pi.y=t[1]):t instanceof r.Coordinate||(t=new r.Coordinate(t));const a=Vi(i),h=Zi(i,s?Pi:t,a,Ii);return n&&(n.x=h.x,n.y=h.y,n.z=e),new o.Vector3(h.x,h.y,e)}coordinatiesToGLFloatArray(t,e){const n=this.getMap();if(!n)return null;const i=Vi(n),o=t.length,s=new Float32Array(2*o),a=new Float32Array(3*o);for(let h=0;h<o;h++){let o=t[h];const c=Array.isArray(o);c?(Pi.x=o[0],Pi.y=o[1]):o instanceof r.Coordinate||(o=new r.Coordinate(o));const l=Zi(n,c?Pi:o,i,Ii);l.x-=e.x,l.y-=e.y;const u=2*h;s[u]=l.x,s[u+1]=l.y;const d=3*h;a[d]=l.x,a[d+1]=l.y,a[d+2]=0}return{positions:a,positons2d:s}}coordinatiesToGLArray(t,e){const n=this.getMap();if(!n)return null;const i=Vi(n),o=t.length,s=new Array(o);for(let a=0;a<o;a++){let o=t[a];const h=Array.isArray(o);h?(Pi.x=o[0],Pi.y=o[1]):o instanceof r.Coordinate||(o=new r.Coordinate(o));const c=Zi(n,h?Pi:o,i,Ii);c.x-=e.x,c.y-=e.y,s[a]=[c.x,c.y]}return s}distanceToVector3(t,e,n){if(0===t&&0===e||!r.Util.isNumber(t)||!r.Util.isNumber(e))return new o.Vector3(0,0,0);const i=this.getMap(),s=Vi(i);let a=n||i.getCenter();a instanceof r.Coordinate||(a=new r.Coordinate(a));const h=i.locate(a,t,e),c=Zi(i,a,s),l=Zi(i,h,s),u=Math.abs(l.x-c.x)*r.Util.sign(t),d=Math.abs(l.y-c.y)*r.Util.sign(e);return new o.Vector3(u,d,0)}altitudeToVector3(t,e,n,i){if(0===t||!r.Util.isNumber(t))return new o.Vector3(0,0,0);const s=this.getMap();if(s.altitudeToPoint){const e=Vi(s);let n=s.altitudeToPoint(t,e);return t<0&&n>0&&(n=-n),i?(i.x=n,i.y=n,i.z=0,i):new o.Vector3(n,n,0)}return this.distanceToVector3(t,t,n)}toShape(t){if(!t)return null;if(t instanceof r.MultiPolygon)return t.getGeometries().map((t=>this.toShape(t)));const e=t.getCenter(),n=this.coordinateToVector3(e),i=t.getShell().map((t=>{const e=this.coordinateToVector3(t).sub(n);return new o.Vector2(e.x,e.y)})),s=new o.Shape(i),a=t.getHoles();return a&&a.length>0&&(s.holes=a.map((t=>{const e=t.map((t=>{const e=this.coordinateToVector3(t).sub(n);return new o.Vector2(e.x,e.y)}));return new o.Shape(e)}))),s}toExtrudeMesh(t,e,n,i){if(!t)return null;if(t instanceof r.MultiPolygon)return t.getGeometries().map((t=>this.toExtrudeMesh(t,e,n,i)));const s=t.getCoordinates();s.forEach((t=>{for(let e=t.length-1;e>=1;e--)t[e].equals(t[e-1])&&t.splice(e,1)})),t.setCoordinates(s);const a=this.toShape(t),h=this.coordinateToVector3(t.getCenter());i=r.Util.isNumber(i)?i:e,i=this.altitudeToVector3(i,i).x;const c=this.altitudeToVector3(e,e).x,l={bevelEnabled:!1,bevelSize:1};l[parseInt(o.REVISION)>=93?"depth":"amount"]=i;const u=new o.ExtrudeGeometry(a,l);let d=u;o.BufferGeometry.prototype.fromGeometry&&(d=new o.BufferGeometry,d.fromGeometry(u));const f=new o.Mesh(d,n);return f.position.set(h.x,h.y,c-i),f}toExtrudePolygon(t,e,n){return new Ee(t,e,n,this)}toBar(t,e,n){return new Ce(t,e,n,this)}toLine(t,e,n){return new ke(t,e,n,this)}toExtrudeLine(t,e,n){return new Ie(t,e,n,this)}toModel(t,e){return new ze(t,e,this)}toExtrudeLineTrail(t,e,n){return new Qe(t,e,n,this)}toExtrudePolygons(t,e,n){return new Ye(t,e,n,this)}toPoint(t,e,n){return new en(t,e,n,this)}toPoints(t,e,n){return new hn(t,e,n,this)}toBars(t,e,n){return new ln(t,e,n,this)}toExtrudeLines(t,e,n){return new dn(t,e,n,this)}toLines(t,e,n){return new pn(t,e,n,this)}toThreeVectorTileLayer(t,e,n){return new An(t,e,n,this)}toTerrain(t,e,n){return new Bn(t,e,n,this)}toTerrainVectorTileLayer(t,e,n){return new Un(t,e,n,this)}toHeatMap(t,e,n){return new Hn(t,e,n,this)}toFatLine(t,e,n){return new qn(t,e,n,this)}toFatLines(t,e,n){return new Yn(t,e,n,this)}toBox(t,e,n){return new Jn(t,e,n,this)}toBoxs(t,e,n){return new ei(t,e,n,this)}getBaseObjects(){return this.getMeshes().filter((t=>t instanceof x))}getMeshes(){const t=this.getScene();if(!t)return[];const e=[];for(let n=0,i=t.children.length;n<i;n++){const i=t.children[n];i instanceof o.Object3D&&!(i instanceof o.Camera)&&e.push(i.__parent||i)}return e}clear(){return this.clearMesh()}clearMesh(){const t=this.getScene();if(!t)return this;for(let e=t.children.length-1;e>=0;e--){const n=t.children[e];if(n instanceof o.Object3D&&!(n instanceof o.Camera)){t.remove(n);const e=n.__parent;e&&e instanceof x&&(e.isAdd=!1,e.options.layer=null,e._fire("remove",{target:e}),delete this._animationBaseObjectMap[n.uuid],e._hideUI())}}return this}lookAt(t){const e=this._getRenderer();return e&&e.context.lookAt(t),this}getCamera(){const t=this._getRenderer();return t?t.camera:null}getScene(){const t=this._getRenderer();return t?t.scene:null}renderScene(t,e){const n=this._getRenderer();return n&&(n.clearCanvas(),n.renderScene(t),e||n.setToRedraw()),this}loop(t=!1){const e=this._delayMeshes;if(!e.length)return;const n=this.getMap();if(!n||n.isAnimating()||n.isInteracting())return;const i=this.options.loopRenderCount||50,r=e.slice(0,i);r&&this.addMesh(r,t),e.splice(0,i)}renderPickScene(){const t=this._getRenderer();if(t){const e=t.pick;e&&e.pick(this._containerPoint)}return this}getThreeRenderer(){const t=this._getRenderer();return t?t.context:null}getPick(){const t=this._getRenderer();return t?t.pick:null}delayAddMesh(t){if(!t)return this;Array.isArray(t)||(t=[t]);for(let e=0,n=t.length;e<n;e++)this._delayMeshes.push(t[e]);return this}addMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const n=this.getScene();if(t.forEach((t=>{t instanceof x?(n.add(t.getObject3d()),t.isAdd||(t.isAdd=!0,t.options.layer=this,t._fire("add",{target:t})),t._animation&&r.Util.isFunction(t._animation)&&(this._animationBaseObjectMap[t.getObject3d().uuid]=t)):t instanceof o.Object3D&&n.add(t)})),this._zoomend(),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}removeMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const n=this.getScene();if(t.forEach((t=>{if(t instanceof x){n.remove(t.getObject3d()),t.isAdd&&(t.isAdd=!1,t.options.layer=null,t._fire("remove",{target:t}),t._hideUI()),t._animation&&r.Util.isFunction(t._animation)&&delete this._animationBaseObjectMap[t.getObject3d().uuid];const e=this._delayMeshes;if(e.length)for(let n=0,i=e.length;n<i;n++)if(e[n]===t){e.splice(n,1);break}}else t instanceof o.Object3D&&n.remove(t)})),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}_initRaycaster(){return this._raycaster||(this._raycaster=new o.Raycaster,this._mouse=new o.Vector2),this}getRaycaster(){return this._raycaster}identify(t,e){if(!t)return console.error("coordinate is null,it should be Coordinate"),[];if(Array.isArray(t)&&(t=new r.Coordinate(t)),!(t instanceof r.Coordinate))return console.error("coordinate type is error,it should be Coordinate"),[];const n=this.getMap().coordToContainerPoint(t);this._containerPoint=n;const{x:i,y:a}=n;this._initRaycaster(),this.fire("identify",{coordinate:t,options:e});const h=this._raycaster,c=this._mouse,l=this.getCamera(),u=this.getScene(),d=this.getMap().getSize();if(!u)return[];const f=d.width,p=d.height;c.x=i/f*2-1,c.y=-a/p*2+1,h.setFromCamera(c,l),h.layers&&h.layers.enableAll&&h.layers.enableAll(),function(t,e){s>113?t.params.Line.threshold=e:t.linePrecision=e}(h,this._getLinePrecision(this.getMap().getResolution()));const g=[],y=[];u.children.forEach((t=>{const e=t.__parent;if(e&&e.getOptions){const n=e;n.getOptions().interactive&&n.isVisible()&&(n.identify&&r.Util.isFunction(n.identify)?y.push(n):g.push(t))}else(t instanceof o.Mesh||t instanceof o.Group)&&g.push(t)}));let v=[];const m=h.intersectObjects(g,!0);m&&Array.isArray(m)&&m.length&&(v=m.map((t=>{let e=t.object;const n=t.instanceId;e=this._recursionMesh(e)||{};const i=e.__parent||e;return i.faceIndex=t.faceIndex,i.index=t.index,i.intersect=t,r.Util.isNumber(n)&&(i.instanceId=n),i}))),this.renderPickScene(),y.length&&y.forEach((e=>{e.identify(t)&&v.push(e)}));const b=v.length;for(let t=0;t<b;t++)if(v[t])for(let e=t+1;e<b;e++)v[t]===v[e]&&v.splice(e,1);let _=v.filter((t=>t instanceof x));_=_.sort(((t,e)=>t.options.pickWeight-e.options.pickWeight)),v.forEach((t=>{t instanceof x||_.push(t)}));const w=(e=r.Util.extend({},e)).count;return r.Util.isNumber(w)&&w>0?_.slice(0,w):v}_recursionMesh(t){for(;t&&t.parent!==this.getScene();)t=t.parent;return t}_getLinePrecision(t=10){for(let e=0,n=Li.length;e<n;e++){const[n,i]=Li[e];if(t>n)return i}return.01}_identifyBaseObjectEvents(t){if(!this.options.geometryEvents)return this;const e=this.map||this.getMap();if(e.isInteracting()||!e.options.geometryEvents||e._ignoreEvent(t))return this;const n=t.type,i=e._getEventParams?e._getEventParams(t):this._getEventParams(t);i.type=n;const{type:o,coordinate:s}=i,a=r.Util.now();if(this._mousemoveTimeOut&&"mousemove"===o&&a-this._mousemoveTimeOut<64)return this;this._mousemoveTimeOut=a,"mousedown"!==o&&"touchstart"!==o||(this._mousedownTime=r.Util.now());let h=!1;if("click"===o||"touchend"===o){const t=e.options.clickTimeThreshold||280;h=r.Util.now()-this._mousedownTime<t}if("click"===o&&!h)return this;const c=this.options.identifyCountOnEvent;let l=Math.max(0,r.Util.isNumber(c)?c:0);0===l&&(l=1/0);const u=t=>{const e=[];this._baseObjects&&this._baseObjects.forEach((n=>{let i=!0;t.forEach((t=>{n===t&&(i=!1)})),i&&e.push(n)})),e.forEach((t=>{t&&t instanceof x&&(t.getSelectMesh?t.isHide||(t._mouseover=!1,t.fire("mouseout",Object.assign({},i,{target:t,type:"mouseout",selectMesh:null})),t.closeToolTip()):(t._mouseover=!1,t.fire("mouseout",Object.assign({},i,{target:t,type:"mouseout"})),t.closeToolTip()))}))};if("mouseout"===o)return u([]),this._baseObjects=[],this;const d=this.identify(s,{count:l}),f=this.getScene();if(0===d.length&&f)for(let t=0,e=f.children.length;t<e;t++){const e=(f.children[t]||{}).__parent;e&&e.fire("empty",Object.assign({},i,{target:e}))}function p(t,e){e=e||o;const n=t.getInfoWindow();n&&!n._owner&&n.addTo(t);((n?n.options:{}).autoOpenOn||"click")===e&&(t.openInfoWindow(s),t.fire("showinfowindow",{infoWindow:n}))}if("mousemove"===o?(u(d),d.forEach((t=>{if(t instanceof x){t._mouseover||(t.fire("mouseover",Object.assign({},i,{target:t,type:"mouseover",selectMesh:t.getSelectMesh?t.getSelectMesh():null})),t._mouseover=!0,p(t,"mouseover")),t.fire(o,Object.assign({},i,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null}));const e=t.getToolTip();e&&!e._owner&&e.addTo(t),t.openToolTip(s),p(t)}})),this._baseObjects=d):d.forEach((t=>{t instanceof x&&(t.fire(o,Object.assign({},i,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),p(t))})),"touchend"===o&&h){const e=r.Util.extend({},i,{domEvent:t});d.forEach((t=>{t instanceof x&&(t.fire("click",Object.assign({},e,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),p(t,"click"))}))}return this}_getEventParams(t){const e=this.getMap(),n={domEvent:t};if(!e)return n;const i=t.touches&&t.touches.length>0?t.touches[0]:t.changedTouches&&t.changedTouches.length>0?t.changedTouches[0]:t;if(i){const t=(0,r.DomUtil.getEventContainerPoint)(i,e._containerDOM);n.coordinate=e.containerPointToCoordinate(t),n.containerPoint=t,n.viewPoint=e.containerPointToViewPoint(t),n.pont2d=e._containerPointToPoint(t)}return n}_zoomend(){const t=this.getScene();if(!t)return;const e=this.getMap().getZoom();t.children.forEach((t=>{const n=t.__parent;if(n&&n.getOptions){const t=n;t.zoomChange&&r.Util.isFunction(t.zoomChange)&&t.zoomChange(e);const i=t.getMinZoom(),o=t.getMaxZoom();e<i||e>o?(t.isVisible()&&(t.getObject3d().visible=!1),t._zoomVisible=!1):i<=e&&e<=o&&(t._visible&&(t.getObject3d().visible=!0),t._zoomVisible=!0)}}))}_getGeometryEventMapPanel(){const t=this.map||this.getMap();return t._panels.allLayers||t._containerDOM}onAdd(){super.onAdd();const t=this.map||this.getMap();if(!t)return this;const e=this._getGeometryEventMapPanel();return this._identifyBaseObjectEventsThis||(this._identifyBaseObjectEventsThis=this._identifyBaseObjectEvents.bind(this)),this._zoomendThis||(this._zoomendThis=this._zoomend.bind(this)),r.DomUtil.on(e,ki.join(" "),this._identifyBaseObjectEventsThis,this),this._needsUpdate=!0,this._animationBaseObjectMap||(this._animationBaseObjectMap={}),t.on("zooming zoomend",this._zoomendThis,this),this}onRemove(){super.onRemove();const t=this.map||this.getMap();if(!t)return this;const e=this._getGeometryEventMapPanel();return r.DomUtil.off(e,ki.join(" "),this._identifyBaseObjectEventsThis,this),t.off("zooming zoomend",this._zoomendThis,this),this.clear(),this}_callbackBaseObjectAnimation(){const t=this;if(t._animationBaseObjectMap)for(const e in t._animationBaseObjectMap){t._animationBaseObjectMap[e]._animation()}return this}_getFovRatio(){const t=this.getMap().getFov();return Math.tan(t/2*Si)}}Ei.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,geometryEvents:!0,identifyCountOnEvent:0,forceRenderOnZooming:!0,loopRenderCount:50});const Ui={bloom:!0};class zi extends r.renderer.CanvasLayerRenderer{constructor(){super(...arguments),this._renderTime=0,this._renderTarget=null}getPrepareParams(){return[this.scene,this.camera]}getDrawParams(){return[this.scene,this.camera]}_drawLayer(){super._drawLayer.apply(this,arguments)}hitDetect(){return!1}createCanvas(){super.createCanvas(),this.createContext()}createContext(){if(this.canvas.gl&&this.canvas.gl.wrap)this.gl=this.canvas.gl.wrap();else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,antialias:!0,stencil:!0,preserveDrawingBuffer:!1};t.preserveDrawingBuffer=!0,this.gl=this.gl||this._createGLContext(this.canvas,t)}this._initThreeRenderer(),this.layer.onCanvasCreate(this.context,this.scene,this.camera)}_initThreeRenderer(){this.matrix4=new o.Matrix4;const t=new o.WebGLRenderer({context:this.gl,alpha:!0});t.autoClear=!1,t.setClearColor(new o.Color(1,1,1),0),t.setSize(this.canvas.width,this.canvas.height),t.clear(),this.context=t;const e=this.scene=new o.Scene,n=this.layer.getMap(),i=n.getFov()*Math.PI/180,r=this.camera=new o.PerspectiveCamera(i,n.width/n.height,n.cameraNear,n.cameraFar);r.matrixAutoUpdate=!1,this._syncCamera(),e.add(r),this.pick=new Nn(this.layer),ue.star()}onCanvasCreate(){super.onCanvasCreate()}resizeCanvas(t){if(!this.canvas)return;let e,n=this.getMap();e=t||n.getSize();const i=n.getDevicePixelRatio?n.getDevicePixelRatio():r.Browser.retina?2:1,o=this.canvas,{width:s,height:a,cssWidth:h,cssHeight:c}=r.Util.calCanvasSize(e,i);if(!this.layer._canvas||o.style.width===h&&o.style.height===c||(o.style.width=h,o.style.height=c),o.width===s&&o.height===a)return this;o.width=s,o.height=a,this.context.setSize(o.width,o.height)}clearCanvas(){this.canvas&&this.context.clear()}prepareCanvas(){return this.canvas?this.clearCanvas():this.createCanvas(),this.layer.fire("renderstart",{context:this.context}),null}renderScene(t){if(this.layer._callbackBaseObjectAnimation(),this._syncCamera(),t&&t.renderTarget){const{width:e,height:n}=t.renderTarget.fbo;this._renderTarget?(this._renderTarget.viewport.set(0,0,e,n),this._renderTarget.scissor.set(0,0,e,n)):(this._renderTarget=new o.WebGLRenderTarget(e,n,{depthBuffer:!1}),this.context.setRenderTarget(this._renderTarget),this.context.render(this.scene,this.camera));const i=this.context.properties.get(this._renderTarget),r=i[Bi];i[Bi]=t.renderTarget.getFramebuffer(t.renderTarget.fbo),this.context.setRenderTarget(this._renderTarget);const s=1===t.bloom&&t.sceneFilter,a=this.scene.children||[];let h=!1;if(s){const e=t.sceneFilter;h=e(Ui);for(let t=0,n=a.length;t<n;t++){if(!a[t]||!a[t].layers)continue;const n=a[t].__parent;a[t].bloom=!1,n&&(a[t].bloom=n.bloom);let i=0;(a[t]&&e(a[t])||!n)&&h&&(i=1),a[t].__layer!==i&&(Fi(a[t],i),a[t].__layer=i)}}else for(let t=0,e=a.length;t<e;t++)a[t]&&a[t].layers&&0!==a[t].__layer&&(Fi(a[t],0),a[t].__layer=0);this.camera.layers.set(h?1:0),this.context.render(this.scene,this.camera),i[Bi]=r}else this.context.render(this.scene,this.camera);this.context.setRenderTarget(null),this.completeRender()}remove(){delete this._drawContext,this._renderTarget&&(this._renderTarget.dispose(),delete this._renderTarget),super.remove()}_syncCamera(){const t=this.getMap(),e=this.camera;e.matrix.elements=t.cameraWorldMatrix,e.projectionMatrix.elements=t.projMatrix,this.matrix4.invert?e.projectionMatrixInverse.elements=this.matrix4.copy(e.projectionMatrix).invert().elements:e.projectionMatrixInverse&&(e.projectionMatrixInverse.elements=this.matrix4.getInverse(e.projectionMatrix).elements)}_createGLContext(t,e){const n=["webgl2","webgl","experimental-webgl"];let i=null;for(let r=0;r<n.length;++r){try{i=t.getContext(n[r],e)}catch(t){}if(i)break}return i}}function Fi(t,e){if(!t)return;t.layers&&t.layers.set(e);const n=t.children;if(n&&n.length)for(let t=0,i=n.length;t<i;t++)Fi(n[t],e)}function Vi(t){return t.getGLRes?t.getGLRes():t.getGLZoom()}function Zi(t,e,n,i){return t.coordToPointAtRes?t.coordToPointAtRes(e,n,i):t.coordinateToPoint(e,n,i)}function Ri(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Gi(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=i.key,o=void 0,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(r,"string"))?o:String(o)),i)}var r,o}function Di(t,e,n){return e&&Gi(t.prototype,e),n&&Gi(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Hi(t){return Hi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Hi(t)}function Qi(t,e){return Qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qi(t,e)}function Wi(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Ni(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=Hi(t);if(e){var r=Hi(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Wi(this,n)}}function Ki(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function qi(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ki(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ki(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function $i(){var t="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}));return"iep".concat(t,"layer")}Ei.registerRenderer("gl",zi),r.registerWorkerAdapter&&(r.registerWorkerAdapter("__maptalks.three__",'(function(n){"use strict";\n/*!\n * poly-extrude v0.1.0\n */var t={exports:{}};function r(n,t,r){r=r||2;var i,o,u,v,s,l,x,c=t&&t.length,d=c?t[0]*r:n.length,g=e(n,0,d,r,!0),y=[];if(!g||g.next===g.prev)return y;if(c&&(g=function(n,t,r,i){var a,o,u,v=[];for(a=0,o=t.length;a<o;a++)(u=e(n,t[a]*i,a<o-1?t[a+1]*i:n.length,i,!1))===u.next&&(u.steiner=!0),v.push(p(u));for(v.sort(h),a=0;a<v.length;a++)r=f(v[a],r);return r}(n,t,g,r)),n.length>80*r){i=u=n[0],o=v=n[1];for(var m=r;m<d;m+=r)(s=n[m])<i&&(i=s),(l=n[m+1])<o&&(o=l),s>u&&(u=s),l>v&&(v=l);x=0!==(x=Math.max(u-i,v-o))?32767/x:0}return a(g,y,r,i,o,x,0),y}function e(n,t,r,e,i){var a,o;if(i===z(n,t,r,e)>0)for(a=t;a<r;a+=e)o=Z(a,n[a],n[a+1],o);else for(a=r-e;a>=t;a-=e)o=Z(a,n[a],n[a+1],o);return o&&y(o,o.next)&&(F(o),o=o.next),o}function i(n,t){if(!n)return n;t||(t=n);var r,e=n;do{if(r=!1,e.steiner||!y(e,e.next)&&0!==g(e.prev,e,e.next))e=e.next;else{if(F(e),(e=t=e.prev)===e.next)break;r=!0}}while(r||e!==t);return t}function a(n,t,r,e,h,f,l){if(n){!l&&f&&function(n,t,r,e){var i=n;do{0===i.z&&(i.z=x(i.x,i.y,t,r,e)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,function(n){var t,r,e,i,a,o,u,v,s=1;do{for(r=n,n=null,a=null,o=0;r;){for(o++,e=r,u=0,t=0;t<s&&(u++,e=e.nextZ);t++);for(v=s;u>0||v>0&&e;)0!==u&&(0===v||!e||r.z<=e.z)?(i=r,r=r.nextZ,u--):(i=e,e=e.nextZ,v--),a?a.nextZ=i:n=i,i.prevZ=a,a=i;r=e}a.nextZ=null,s*=2}while(o>1)}(i)}(n,e,h,f);for(var p,c,d=n;n.prev!==n.next;)if(p=n.prev,c=n.next,f?u(n,e,h,f):o(n))t.push(p.i/r|0),t.push(n.i/r|0),t.push(c.i/r|0),F(n),n=c.next,d=c.next;else if((n=c)===d){l?1===l?a(n=v(i(n),t,r),t,r,e,h,f,2):2===l&&s(n,t,r,e,h,f):a(i(n),t,r,e,h,f,1);break}}}function o(n){var t=n.prev,r=n,e=n.next;if(g(t,r,e)>=0)return!1;for(var i=t.x,a=r.x,o=e.x,u=t.y,v=r.y,s=e.y,h=i<a?i<o?i:o:a<o?a:o,f=u<v?u<s?u:s:v<s?v:s,l=i>a?i>o?i:o:a>o?a:o,x=u>v?u>s?u:s:v>s?v:s,p=e.next;p!==t;){if(p.x>=h&&p.x<=l&&p.y>=f&&p.y<=x&&c(i,u,a,v,o,s,p.x,p.y)&&g(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function u(n,t,r,e){var i=n.prev,a=n,o=n.next;if(g(i,a,o)>=0)return!1;for(var u=i.x,v=a.x,s=o.x,h=i.y,f=a.y,l=o.y,p=u<v?u<s?u:s:v<s?v:s,d=h<f?h<l?h:l:f<l?f:l,y=u>v?u>s?u:s:v>s?v:s,m=h>f?h>l?h:l:f>l?f:l,w=x(p,d,t,r,e),M=x(y,m,t,r,e),b=n.prevZ,A=n.nextZ;b&&b.z>=w&&A&&A.z<=M;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}for(;b&&b.z>=w;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=M;){if(A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function v(n,t,r){var e=n;do{var a=e.prev,o=e.next.next;!y(a,o)&&m(a,e,e.next,o)&&b(a,o)&&b(o,a)&&(t.push(a.i/r|0),t.push(e.i/r|0),t.push(o.i/r|0),F(e),F(e.next),e=n=o),e=e.next}while(e!==n);return i(e)}function s(n,t,r,e,o,u){var v=n;do{for(var s=v.next.next;s!==v.prev;){if(v.i!==s.i&&d(v,s)){var h=A(v,s);return v=i(v,v.next),h=i(h,h.next),a(v,t,r,e,o,u,0),void a(h,t,r,e,o,u,0)}s=s.next}v=v.next}while(v!==n)}function h(n,t){return n.x-t.x}function f(n,t){var r=function(n,t){var r,e=t,i=n.x,a=n.y,o=-1/0;do{if(a<=e.y&&a>=e.next.y&&e.next.y!==e.y){var u=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>o&&(o=u,r=e.x<e.next.x?e:e.next,u===i))return r}e=e.next}while(e!==t);if(!r)return null;var v,s=r,h=r.x,f=r.y,x=1/0;e=r;do{i>=e.x&&e.x>=h&&i!==e.x&&c(a<f?i:o,a,h,f,a<f?o:i,a,e.x,e.y)&&(v=Math.abs(a-e.y)/(i-e.x),b(e,n)&&(v<x||v===x&&(e.x>r.x||e.x===r.x&&l(r,e)))&&(r=e,x=v)),e=e.next}while(e!==s);return r}(n,t);if(!r)return t;var e=A(r,n);return i(e,e.next),i(r,r.next)}function l(n,t){return g(n.prev,n,t.prev)<0&&g(t.next,n,n.next)<0}function x(n,t,r,e,i){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(n){var t=n,r=n;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==n);return r}function c(n,t,r,e,i,a,o,u){return(i-o)*(t-u)>=(n-o)*(a-u)&&(n-o)*(e-u)>=(r-o)*(t-u)&&(r-o)*(a-u)>=(i-o)*(e-u)}function d(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!function(n,t){var r=n;do{if(r.i!==n.i&&r.next.i!==n.i&&r.i!==t.i&&r.next.i!==t.i&&m(r,r.next,n,t))return!0;r=r.next}while(r!==n);return!1}(n,t)&&(b(n,t)&&b(t,n)&&function(n,t){var r=n,e=!1,i=(n.x+t.x)/2,a=(n.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(e=!e),r=r.next}while(r!==n);return e}(n,t)&&(g(n.prev,n,t.prev)||g(n,t.prev,t))||y(n,t)&&g(n.prev,n,n.next)>0&&g(t.prev,t,t.next)>0)}function g(n,t,r){return(t.y-n.y)*(r.x-t.x)-(t.x-n.x)*(r.y-t.y)}function y(n,t){return n.x===t.x&&n.y===t.y}function m(n,t,r,e){var i=M(g(n,t,r)),a=M(g(n,t,e)),o=M(g(r,e,n)),u=M(g(r,e,t));return i!==a&&o!==u||(!(0!==i||!w(n,r,t))||(!(0!==a||!w(n,e,t))||(!(0!==o||!w(r,n,e))||!(0!==u||!w(r,t,e)))))}function w(n,t,r){return t.x<=Math.max(n.x,r.x)&&t.x>=Math.min(n.x,r.x)&&t.y<=Math.max(n.y,r.y)&&t.y>=Math.min(n.y,r.y)}function M(n){return n>0?1:n<0?-1:0}function b(n,t){return g(n.prev,n,n.next)<0?g(n,t,n.next)>=0&&g(n,n.prev,t)>=0:g(n,t,n.prev)<0||g(n,n.next,t)<0}function A(n,t){var r=new P(n.i,n.x,n.y),e=new P(t.i,t.x,t.y),i=n.next,a=t.prev;return n.next=t,t.prev=n,r.next=i,i.prev=r,e.next=r,r.prev=e,a.next=e,e.prev=a,e}function Z(n,t,r,e){var i=new P(n,t,r);return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function F(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function P(n,t,r){this.i=n,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function z(n,t,r,e){for(var i=0,a=t,o=r-e;a<r;a+=e)i+=(n[o]-n[a])*(n[a+1]+n[o+1]),o=a;return i}t.exports=r,t.exports.default=r,r.deviation=function(n,t,r,e){var i=t&&t.length,a=i?t[0]*r:n.length,o=Math.abs(z(n,0,a,r));if(i)for(var u=0,v=t.length;u<v;u++){var s=t[u]*r,h=u<v-1?t[u+1]*r:n.length;o-=Math.abs(z(n,s,h,r))}var f=0;for(u=0;u<e.length;u+=3){var l=e[u]*r,x=e[u+1]*r,p=e[u+2]*r;f+=Math.abs((n[l]-n[p])*(n[x+1]-n[l+1])-(n[l]-n[x])*(n[p+1]-n[l+1]))}return 0===o&&0===f?0:Math.abs((f-o)/o)},r.flatten=function(n){for(var t=n[0][0].length,r={vertices:[],holes:[],dimensions:t},e=0,i=0;i<n.length;i++){for(var a=0;a<n[i].length;a++)for(var o=0;o<t;o++)r.vertices.push(n[i][a][o]);i>0&&(e+=n[i-1].length,r.holes.push(e))}return r};var I=t.exports;function E(n){for(var t,r,e=0,i=1,a=n.length;i<a;)t=r||n[0],e+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return e>0}function L(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],n}function H(n,t){var r=t[0],e=t[1],i=t[2],a=Math.sqrt(r*r+e*e+i*i)||1;return n[0]=r/a,n[1]=e/a,n[2]=i/a,n}function U(n,t){function r(n,t,r,e){n[0]=t,n[1]=r,n[2]=e}for(var e,i,a,o,u,v,s,h,f,l=[],x=[],p=[],c=[],d=[],g=[],y=n.length,m=new Float32Array(t.length),w=0;w<y;){var M=3*n[w],b=3*n[w+1],A=3*n[w+2];r(l,t[M],t[M+1],t[M+2]),r(x,t[b],t[b+1],t[b+2]),r(p,t[A],t[A+1],t[A+2]),L(d,p,x),L(c,l,x),e=g,a=c,o=void 0,u=void 0,v=void 0,s=void 0,h=void 0,f=void 0,o=(i=d)[0],u=i[1],v=i[2],s=a[0],h=a[1],f=a[2],e[0]=u*f-v*h,e[1]=v*s-o*f,e[2]=o*h-u*s;for(var Z=0;Z<3;Z++)m[M+Z]+=g[Z],m[b+Z]+=g[Z],m[A+Z]+=g[Z];w+=3}for(var F=0,P=m.length;F<P;)r(g,m[F],m[F+1],m[F+2]),H(g,g),m[F]=g[0]||0,m[F+1]=g[1]||0,m[F+2]=g[2]||0,F+=3;return m}function j(n){if(1===n.length)return{position:n[0].position,normal:n[0].normal,uv:n[0].uv,indices:n[0].indices,results:n};for(var t=0,r=0,e=0,i=n.length;e<i;e++){var a=n[e],o=a.position,u=a.indices;t+=o.length,r+=u.length}for(var v={position:new Float32Array(t),normal:new Float32Array(t),uv:new Float32Array(t/3*2),indices:new Uint32Array(r),results:n},s=0,h=0,f=0,l=0,x=0,p=n.length;x<p;x++){var c=n[x],d=c.position,g=c.indices,y=c.normal,m=c.uv;v.position.set(d,s),v.normal.set(y,s),v.uv.set(m,l);for(var w=0,M=g.length;w<M;){var b=g[w]+h;v.indices[f]=b,f++,w++}l+=m.length,s+=d.length,h+=d.length/3}return v}function O(n){return 180*n/Math.PI}function S(n){return n/180*Math.PI}function W(n,t,r,e,i,a){var o=3*r,u=3*e,v=3*i,s=3*a,h=t[o],f=t[o+1],l=t[o+2],x=t[u],p=t[u+1],c=t[u+2],d=t[v],g=t[v+1],y=t[v+2],m=t[s],w=t[s+1],M=t[s+2];Math.abs(f-p)<Math.abs(h-x)?(n.push(h,1-l),n.push(x,1-c),n.push(d,1-y),n.push(m,1-M)):(n.push(f,1-l),n.push(p,1-c),n.push(g,1-y),n.push(w,1-M))}function k(n,t){t=Object.assign({},{depth:2},t);var r=n.map((function(n){for(var r=0,e=n.length;r<e;r++){var i=n[r];B(i),0===r?E(i)||(n[r]=i.reverse()):E(i)&&(n[r]=i.reverse()),V(i)&&i.splice(i.length-1,1)}var a=function(n,t){for(var r=function(n){var t=0,r=0,e=n.length;for(;r<e;)t+=n[r].length,r++;return t}(n),e=n.length,i=[],a=new Float32Array(2*r),o=[],u=[],v=3*r,s=2*r,h=t.depth,f=0,l=0,x=0,p=0;p<e;p++){var c=n[p];p>0&&i.push(f/2);for(var d=0,g=c.length;d<g;){var y=c[d],m=y[0],w=y[1];a[f++]=m,a[f++]=w,o[l]=m,o[l+1]=w,o[l+2]=h,o[v+l]=m,o[v+l+1]=w,o[v+l+2]=0,u[x]=m,u[x+1]=w,u[s+x]=m,u[s+x+1]=w,l+=3,x+=2,d++}}return{flatVertices:a,holes:i,points:o,count:r,uvs:u}}(n,t);return a.polygon=n,function(n,t){for(var r=[],e=n.count,i=0,a=t.length;i<a;i+=3){var o=t[i],u=t[i+1],v=t[i+2];r[i]=o,r[i+1]=u,r[i+2]=v;var s=a+i,h=e+o,f=e+u,l=e+v;r[s]=h,r[s+1]=f,r[s+2]=l}n.index=r}(a,I(a.flatVertices,a.holes,2)),function(n,t){for(var r=n.points,e=n.index,i=n.polygon,a=n.uvs,o=t.depth,u=0,v=i.length;u<v;u++)for(var s=i[u],h=0,f=s.length;h<f;){var l=s[h],x=s[h+1];h===f-1&&(x=s[0]);var p=r.length/3,c=l[0],d=l[1],g=x[0],y=x[1];r.push(c,d,o,g,y,o,c,d,0,g,y,0);var m=p+2,w=p+3,M=p,b=p+1;e.push(m,M,w,M,b,w),W(a,r,m,w,M,b),h++}}(a,t),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.index),a.uv=new Float32Array(a.uvs),a.normal=U(a.indices,a.position),a})),e=j(r);return e.polygons=n,e}function B(n){V(n)||n.push(n[0])}function V(n){var t=n.length,r=n[0],e=r[0],i=r[1],a=n[t-1],o=a[0],u=a[1];return e===o&&i===u}function _(n,t){t=Object.assign({},{depth:2,lineWidth:1},t);var r=n.map((function(n){var r=function(n,t){var r=0,e=t.lineWidth/2,i=[],a=[],o=[],u=n.length,v=0;for(;v<u-1;){var s=n[v],h=n[v+1],f=h[1]-s[1],l=h[0]-s[0],x=0,p=O(Math.atan(f/l));if(r=p,0===v)x=p,x-=90;else{var c=n[v-1];q.x=c[0]-s[0],q.y=c[1]-s[1],R.x=h[0]-s[0],R.y=h[1]-s[1],x=p-D(q,R)/2}var d=C(S(x),e,s),g=d[0],y=d[1];i.push(g,y),G(g,s,h)?(a.push(g),o.push(y)):(a.push(y),o.push(g)),v++}var m=r,w=S(m-=90),M=n[u-2],b=n[u-1],A=C(w,e,b),Z=A[0],F=A[1];i.push(Z,F),G(Z,M,b)?(a.push(Z),o.push(F)):(a.push(F),o.push(Z));return{offsetPoints:i,leftPoints:a,rightPoints:o}}(n,t);return r.line=n,function(n,t){var r=t.depth,e=[],i=[],a=[],o=n.leftPoints,u=n.rightPoints,v=0,s=o.length;for(;v<s;){var h=3*v,f=o[v],l=f[0],x=f[1];e[h]=l,e[h+1]=x,e[h+2]=r;var p=u[v],c=p[0],d=p[1],g=3*s+h;e[g]=c,e[g+1]=d,e[g+2]=r;var y=2*s*3+h;e[y]=l,e[y+1]=x,e[y+2]=0;var m=2*s*3+3*s+h;e[m]=c,e[m+1]=d,e[m+2]=0,v++}v=0,s=e.length;for(;v<s;){var w=e[v],M=e[v+1];a.push(w,M),v+=3}v=0,s=o.length;for(;v<s-1;){var b=v,A=v+1,Z=b+s,F=A+s;i.push(b,Z,A),i.push(Z,F,A);var P=v+2*s,z=P+1,I=P+s,E=z+s;i.push(P,I,z),i.push(I,E,z),v++}n.index=i,n.points=e,n.uvs=a}(r,t),function(n,t){var r=n.points,e=n.index,i=n.leftPoints,a=n.rightPoints,o=n.uvs,u=t.depth,v=[i,a];function s(n,t){var i=r.length/3;r.push(n[0],n[1],u,t[0],t[1],u,n[0],n[1],0,t[0],t[1],0);var a=i+2,v=i+3,s=i,h=i+1;e.push(a,s,v,s,h,v),W(o,r,a,v,s,h)}for(var h=0,f=v.length;h<f;h++){var l=v[h];h>0&&(l=(l=l.map((function(n){return n}))).reverse());for(var x=0,p=l.length-1;x<p;){s(l[x],l[x+1]),x++}}for(var c=i.length,d=[a[0],i[0],i[c-1],a[c-1]],g=0;g<d.length;g+=2){s(d[g],d[g+1])}}(r,t),r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.index),r.uv=new Float32Array(r.uvs),r.normal=U(r.indices,r.position),r})),e=j(r);return e.lines=n,e}var q={x:0,y:0},R={x:0,y:0};function C(n,t,r){var e=r[0],i=r[1],a=[e+Math.cos(n)*t,i+Math.sin(n)*t],o=n+=Math.PI;return[a,[e+Math.cos(o)*t,i+Math.sin(o)*t]]}var D=function(n,t){var r=n.x,e=n.y,i=t.x,a=t.y,o=r*i+e*a,u=r*a-e*i;return(Math.atan2(u,o)/Math.PI*180+360)%360};function G(n,t,r){var e=t[0],i=t[1],a=r[0],o=r[1];return(i-o)*n[0]+(a-e)*n[1]+e*o-a*i>0}function J(n,t){void 0===t&&(t={}),t=Object.assign({},{radius:1,height:2,radialSegments:6},t);for(var r=Math.round(Math.max(4,t.radialSegments)),e=t,i=e.radius,a=e.height,o=360/r/360*Math.PI*2,u=r+1,v=new Float32Array(3*u*2),s=n[0],h=n[1],f=0,l=0,x=3*u,p=2*u,c=[],d=[],g=-1;g<r;g++){var y=o*g,m=Math.cos(y)*i+s,w=Math.sin(y)*i+h;v[f]=m,v[f+1]=w,v[f+2]=0,v[f+x]=m,v[f+1+x]=w,v[f+2+x]=a;var M,b;M=.5+m/i/2,b=.5+w/i/2,d[l]=M,d[l+1]=b,d[l+p]=M,d[l+1+p]=b,f+=3,l+=2,g>1&&c.push(0,g-1,g)}v[f-=3]=v[0],v[f+1]=v[1],v[f+2]=v[2];var A=v.length;v[A-3]=v[0],v[A-2]=v[1],v[A-1]=a;for(var Z=c.length,F=0;F<Z;F++){var P=c[F];c.push(P+u)}var z=new Float32Array(2*(3*u*2-6)),I=-1;f=2*u,l=0;for(var E=0,L=v.length/2;E<L-3;E+=3){var H=v[E],j=v[E+1],O=v[E+3],S=v[E+4];z[++I]=H,z[++I]=j,z[++I]=a,z[++I]=O,z[++I]=S,z[++I]=a,z[++I]=H,z[++I]=j,z[++I]=0,z[++I]=O,z[++I]=S,z[++I]=0;var W=f+2,k=f+3,B=f,V=f+1;c.push(B,W,V,W,k,V),f+=4;var _=l/u,q=(l+1)/u;d.push(_,a/i/2,q,a/i/2,_,0,q,0),l++}var R=new Float32Array(v.length+z.length);R.set(v,0),R.set(z,v.length);var C=U(c,R);return{points:v,indices:new Uint32Array(c),position:R,normal:C,uv:new Float32Array(d)}}var K={x:0,y:0},N={x:0,y:0};function Q(n,t,r,e){for(var i=n.length,a=0;a<i;a++){var o=n[a].data;t=n[a].center||t;for(var u=0,v=o.length;u<v;u++)for(var s=o[u],h=0,f=s.length;h<f;h++)n[a].data[u][h]=T(s[h],t,r,e)}}function T(n,t,r,e){for(var i,a=[],o=0,u=(i=r?new Float64Array(n):new Float32Array(n)).length;o<u;o+=2){var v=i[o],s=i[o+1];if(t&&r&&e){K.x=v,K.y=s;var h=un(K,N);K.x=h.x,K.y=h.y,v=(h=vn(e,K,r,N)).x,s=h.y,v-=t[0],s-=t[1]}a.push([v,s])}return a}function X(n,t){void 0===t&&(t=!1);for(var r=n.length,e=[],i=[],a=0,o=0;o<r;o++){var u=t?$(n[o]):Y(n[o]),v=n[o].bottomHeight||0,s=u.position;i.push(u);var h=s.length/3;e[o]={position:{middleZ:v+(n[o].height||0)/2,count:h,start:a,end:a+3*h},hide:!1},a+=3*h}var f=tn(i),l=f.position,x=f.normal,p=f.uv,c=f.indices;return{position:l.buffer,normal:x.buffer,uv:p.buffer,indices:c.buffer,geometriesAttributes:e}}function Y(n){var t=n.data,r=n.height,e=n.bottomHeight,i=k(t,{depth:r}),a=i.position,o=i.normal,u=i.uv,v=i.indices;return rn(a,e),{position:a,normal:o,uv:u,indices:v}}function $(n){var t=n.data,r=n.height,e=n.width,i=n.bottomHeight,a=_(t,{lineWidth:e,depth:r}),o=a.position,u=a.normal,v=a.uv,s=a.indices;return rn(o,i),{position:o,normal:u,uv:v,indices:s}}function nn(n,t){for(var r=new Float32Array(t),e=0,i=0;i<n.length;++i)r.set(n[i],e),e+=n[i].length;return r}function tn(n){for(var t={},r={},e=0;e<n.length;++e){var i=n[e];for(var a in i)void 0===t[a]&&(t[a]=[],r[a]=0),t[a].push(i[a]),r[a]+=i[a].length}var o={},u=0,v=[];for(var s in t)if("indices"===s)for(var h=t[s],f=0,l=h.length;f<l;f++){for(var x=h[f],p=0,c=x.length;p<c;p++)v.push(x[p]+u);u+=t.position[f].length/3}else{var d=nn(t[s],r[s]);if(!d)return null;o[s]=d}return o.indices=new Uint32Array(v),o}function rn(n,t){if(void 0!==t&&"number"==typeof t&&0!==t)for(var r=0,e=n.length;r<e;r+=3)n[r+2]+=t}function en(n){for(var t=[],r=0,e=n.length;r<e;r+=7){var i=n[r],a=n[r+1],o=n[r+2],u=n[r+3],v=n[r+4],s=n[r+5];t.push({radialSegments:o,radius:u,height:v,altitude:s,center:[i,a]})}for(var h=t.length,f=[],l=[],x=0,p=0;p<h;p++){var c=J(t[p].center||[0,0],t[p]),d=c.position;if(t[p].altitude)for(var g=t[p].altitude,y=0,m=d.length;y<m;y+=3)c[y+2]+=g;l.push(c);var w=d.length/3;f[p]={position:{middleZ:t[p].height/2,count:w,start:x,end:x+3*w},hide:!1},x+=3*w}var M=tn(l),b=M.position,A=M.normal,Z=M.uv,F=M.indices;return{position:b.buffer,normal:A.buffer,uv:Z.buffer,indices:F.buffer,geometriesAttributes:f}}var an=Math.PI/180,on=6378137*Math.PI/180;function un(n,t){var r,e=85.0511287798,i=n.x,a=Math.max(Math.min(e,n.y),-e);r=0===a?0:Math.log(Math.tan((90+a)*an/2))/an;var o=i*on,u=r*on;return t?(t.x=o,t.y=u,t):{x:o,y:u}}function vn(n,t,r,e){var i=n[0]*(t.x-n[2])/r,a=-n[1]*(t.y-n[3])/r;return e?(e.x=i,e.y=a,e):{x:i,y:a}}function sn(n){void 0===n&&(n=[]);for(var t=n.length,r=new Float32Array(3*t),e=0;e<t;e++){var i=n[e],a=3*e;r[a]=i[0],r[a+1]=i[1]}return r}function hn(n){for(var t=new Float32Array(2*n.length-6),r=0,e=0,i=n.length/3;e<i;e++){var a=n[3*e],o=n[3*e+1],u=n[3*e+2];if(e>0&&e<i-1){var v=3*r;t[v]=a,t[v+1]=o,t[v+2]=u,r++}var s=3*r;t[s]=a,t[s+1]=o,t[s+2]=u,r++}return t}function fn(n){var t=0,r=n.length;if(1===r)return n[0];for(var e=0;e<r;e++)t+=n[e].length;for(var i=new Float32Array(t),a=0,o=0;o<r;o++)i.set(n[o],a),a+=n[o].length;return i}n.initialize=function(){},n.onmessage=function(n,t){var r=n.data,e=r.type,i=r.datas,a=r.glRes,o=r.matrix,u=r.center;if("ExtrudePolygons"===e){Q(i,u,a,o);var v=X(i);t(null,v,[v.position,v.normal,v.uv,v.indices])}else if("ExtrudeLines"===e){for(var s=0,h=i.length;s<h;s++)for(var f=0,l=i[s].data.length;f<l;f++)i[s].data[f]=T(i[s].data[f],i[s].center||u,a,o);var x=X(i,!0);t(null,x,[x.position,x.normal,x.uv,x.indices])}else if("ExtrudePolygon"===e){var p=[],c=[];i.forEach((function(n){var t=[n];Q(t,u,a,o);var r=X(t),e=r.position,i=r.normal,v=r.uv,s=r.indices;p.push({id:n.id,position:e,normal:i,uv:v,indices:s}),c.push(e,i,v,s)})),t(null,p,c)}else if("Line"===e||"FatLine"===e){for(var d=[],g=[],y=0,m=i.length;y<m;y++){for(var w=[],M=0,b=i[y].data.length;M<b;M++){i[y].data[M]=T(i[y].data[M],i[y].center||u,a,o);var A=sn(i[y].data[M]);w.push(hn(A))}var Z=fn(w);rn(Z,i[y].bottomHeight),d.push({id:i[y].id,position:Z.buffer}),g.push(Z.buffer)}t(null,d,g)}else if("Lines"===e||"FatLines"===e){for(var F=0,P=[],z=[],I=0,E=[],L=0,H=i.length;L<H;L++){for(var U=0,j=0,O=i[L].data.length;j<O;j++){i[L].data[j]=T(i[L].data[j],i[L].center||u,a,o);var S=sn(i[L].data[j]);rn(S,i[L].bottomHeight),U+=S.length/3*2-2,E.push(hn(S))}var W=U;P[L]=[F,F+W],F+=W,z[L]={position:{count:U,start:I,end:I+3*U},hide:!1},"FatLines"===e&&(z[L].instanceStart={count:U,start:I,end:I+3*U},z[L].instanceEnd={count:U,start:I,end:I+3*U}),I+=3*U}var k=fn(E);t(null,{id:i.id,position:k.buffer,geometriesAttributes:z,faceMap:P},[k.buffer])}else if("ExtrudeLine"===e){for(var B=0,V=i.length;B<V;B++)for(var _=0,q=i[B].data.length;_<q;_++)i[B].data[_]=T(i[B].data[_],i[B].center||u,a,o);var R=[],C=[];i.forEach((function(n){var t=X([n],!0),r=t.position,e=t.normal,i=t.uv,a=t.indices;R.push({id:n.id,position:r,normal:e,uv:i,indices:a}),C.push(r,e,i,a)})),t(null,R,C)}else if("Bar"===e){for(var D=[],G=[],J=(i=new Float32Array(i)).length/7,K=0;K<J;){var N=i.slice(7*K,7*(K+1)),Y=en(N),$=Y.position,nn=Y.normal,tn=Y.uv,an=Y.indices;D.push({id:parseInt(N[6]),position:$,normal:nn,uv:tn,indices:an}),G.push($,nn,tn,an),K++}t(null,D,G)}else if("Bars"===e){var on=en(i=new Float32Array(i));t(null,on,[on.position,on.normal,on.uv,on.indices])}},Object.defineProperty(n,"__esModule",{value:!0})})'),r.registerWorkerAdapter("__maptalks.three.fetchdata__",(function(t){const e=[],n=[],i=5;function r(t){t.abort?(n.splice(n.indexOf(t),1),e.length&&(n.push(e[0]),e.splice(0,1),o(n[n.length-1]))):n.length<i?(n.push(t),o(t)):e.push(t)}function o(t){fetch(t.url).then((t=>t.text())).then((e=>{new Blob([e],{type:"application/json"}).arrayBuffer().then((e=>{t.postResponse(null,e,[e]),t.abort=!0,r(t)}))})).catch((e=>{console.error(e),t.abort=!0,r(t)}))}t.initialize=function(){},t.onmessage=function(t,e){r({url:t.data,postResponse:e,abort:!1})}})));var Yi={altitude:0,imageWidth:512,imageHeight:512,texture:null},Xi=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Qi(t,e)}(n,t);var e=Ni(n);function n(t,i,s,a){var h;Ri(this,n);var c=i=r.Util.extend({},Yi,i),l=c.altitude;c.imageHeight,c.imageWidth,t instanceof r.Extent||(t=new r.Extent(t));var u=t,d=u.xmin,f=u.ymin,p=u.xmax,g=u.ymax,y=1/0,v=1/0,x=-1/0,m=-1/0;[[d,f],[d,g],[p,g],[p,f]].forEach((function(t){var e=a.coordinateToVector3(t),n=e.x,i=e.y;y=Math.min(n,y),v=Math.min(i,v),x=Math.max(n,x),m=Math.max(i,m)}));var b=Math.abs(x-y),_=Math.abs(m-v),w=new o.PlaneBufferGeometry(b,_);(h=e.call(this))._initOptions(i),h._createMesh(w,s);var M=a.distanceToVector3(l,l).x,O=a.coordinateToVector3(t.getCenter(),M);return h.getObject3d().position.copy(O),h.parent=null,h.type="Image",h}return Di(n)}(x),Ji=function(){function t(e,n,i,s,a){var h=this;Ri(this,t),this.threelayer=a,this.map=a.map,this.textureLoader=new o.TextureLoader;var c=e.split(","),l=n.split(","),u=parseFloat(c[0]),d=parseFloat(c[1]),f=parseFloat(l[0]),p=parseFloat(l[1]),g=s.maxZoom||11,y=s.renderOrder||0,v=s.opacity||1,x=s.minZoom||3,m=new r.Extent(u,d,f,p);this.xmin_g=u,this.ymin_g=d,this.xmax_g=f,this.ymax_g=p,this.textureLoader.load(i,(function(t){var e=new o.MeshBasicMaterial({map:t,transparent:!0,opacity:v}),n=new Xi(m,{imageWidth:512,imageHeight:512,maxZoom:g,minZoom:x,interactive:void 0!==s.interactive&&s.interactive},e,h.threelayer);n.object3d.renderOrder=y,h.imgMesh=n,h.imgMesh.parent=h,h.m=e,h.texture=t,h.threelayer.addMesh(h.imgMesh),s.opacityItems&&s.opacityItems.length>0&&!isNaN(s.opacityItems[0])&&!isNaN(s.opacityItems[1])&&s.opacityItems[0]>3&&s.opacityItems[0]<=18&&s.opacityItems[1]>=0&&s.opacityItems[1]<=1&&(h.opacityItems=s.opacityItems,h._bindMapEvents(),h._viewChange())}))}return Di(t,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(t,e){var n=this;if(e&&e.leftbottom&&e.righttop){var i=parseFloat(e.leftbottom[0]),s=parseFloat(e.leftbottom[1]),a=parseFloat(e.righttop[0]),h=parseFloat(e.righttop[1]);if(i!==this.xmin_g||s!==this.ymin_g||a!==this.xmax_g||h!==this.ymax_g){var c=new r.Extent(i,s,a,h),l=1/0,u=1/0,d=-1/0,f=-1/0;[[i,s],[i,h],[a,h],[a,s]].forEach((function(t){var e=n.threelayer.coordinateToVector3(t),i=e.x,r=e.y;l=Math.min(i,l),u=Math.min(r,u),d=Math.max(i,d),f=Math.max(r,f)}));for(var p=Math.abs(d-l),g=Math.abs(f-u),y=new o.PlaneBufferGeometry(p,g),v=y.attributes.position.array,x=this.imgMesh.object3d.geometry.attributes.position.array,m=0;m<x.length;m++)x[m]=v[m];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),y.dispose(),this.xmin_g=i,this.ymin_g=s,this.xmax_g=a,this.ymax_g=h}}this.textureLoader.load(t,(function(t){n.texture&&n.texture.dispose(),delete n.texture,t.magFilter=o.NearestFilter,t.minFilter=o.NearestFilter,n.imgMesh.object3d.material.map=t,n.imgMesh.object3d.material.map.needsUpdate=!0,n.texture=t,!1===n.imgMesh.isAdd&&(n.threelayer.addMesh(n.imgMesh),n.opacityItems&&n._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),t}(),tr=function(){function t(e,n){var i=this;Ri(this,t),this.map=n,this.animationId=null,this.updatables=[];var r=$i();this.threeLayer=new Ei(r,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new o.Clock;var s=function t(){var e,n;(i.threeLayer._needsUpdate=!i.threeLayer._needsUpdate,i.threeLayer._needsUpdate)&&(null===(e=i.threeLayer)||void 0===e||null===(n=e.getRenderer())||void 0===n||n.clearCanvas(),i.threeLayer.renderScene());var r,o=i.clock.getDelta(),s=qi(i.updatables);try{for(s.s();!(r=s.n()).done;){r.value.tick(o)}}catch(t){s.e(t)}finally{s.f()}i.animationId=requestAnimationFrame(t)};this.threeLayer.prepareToDraw=function(t,e,n){var i=new o.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),e.add(i),s()},this.threeLayer.addTo(n),this.layerId=r,this.layerName=e,this.dirty=!1,this.initFlag=!1}return Di(t,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var t=$i();this.threeLayer.setId(t),this.layerId=t}}},{key:"setVisible",value:function(t,e){this.threeLayer&&(!0===t?(this.threeLayer.show(),e&&e()):(this.threeLayer.hide(),e&&e()))}},{key:"prepareToDraw",value:function(){var t=this,e=function e(){var n,i;(t.threeLayer._needsUpdate=!t.threeLayer._needsUpdate,t.threeLayer._needsUpdate)&&(null===(n=t.threeLayer)||void 0===n||null===(i=n.getRenderer())||void 0===i||i.clearCanvas(),t.threeLayer.renderScene());var r,o=t.clock.getDelta(),s=qi(t.updatables);try{for(s.s();!(r=s.n()).done;){r.value.tick(o)}}catch(t){s.e(t)}finally{s.f()}t.animationId=requestAnimationFrame(e)};return new Promise((function(n){t.threeLayer.prepareToDraw=function(t,i,r){var s=new o.DirectionalLight(16777215);s.position.set(0,-10,10).normalize(),i.add(s),i.add(new o.AmbientLight(16777215)),e(),n()}}))}},{key:"drawImage",value:function(t,e,n,i){var r=this;return new Promise((function(o){if(r.threeLayer.getScene()){var s=new Ji(t,e,n,i,r.threeLayer);o(s)}else r.initFlag=!0,r.prepareToDraw().then((function(){var s=new Ji(t,e,n,i,r.threeLayer);o(s)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var t=this.threeLayer.getMeshes();this.threeLayer.clear(),t.forEach((function(t){}));var e=this.threeLayer.getCamera(),n=this.threeLayer.getScene(),i=this.threeLayer.getPick(),r=i.pickingTexture;i.pickingScene;var o=this.threeLayer.getRenderer();n.remove(e),e=null,n=null,r.dispose(),r=null,o.context.dispose(),o.context.forceContextLoss(),o.context=null,o.remove(),o=null,this.map.removeLayer(this.threeLayer)}}]),t}();t.BaseObject=x,t.ThreeLayer=Ei,t.imgClass=Ji,t.layerClass=tr}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("maptalks"),require("three"),require("maptalks.three")):"function"==typeof define&&define.amd?define(["exports","maptalks","three","maptalks.three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mapcore=e.mapcore||{},e.maptalks,e.THREE,e.maptalks)}(this,(function(e,t,r,i){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(t),o=n(r);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function h(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function f(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=u(e);if(t){var n=u(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return f(this,r)}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function p(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function d(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var g={altitude:0,imageWidth:512,imageHeight:512,texture:null},v=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(r,e);var t=m(r);function r(e,n,c,h){var u;s(this,r),console.log(i.BaseObject,"fffffffffffff");var l=n=a.Util.extend({},g,n),f=l.altitude;l.imageHeight,l.imageWidth,e instanceof a.Extent||(e=new a.Extent(e));var m=e,y=m.xmin,p=m.ymin,d=m.xmax,v=m.ymax,x=1/0,b=1/0,w=-1/0,M=-1/0;[[y,p],[y,v],[d,v],[d,p]].forEach((function(e){var t=h.coordinateToVector3(e),r=t.x,i=t.y;x=Math.min(r,x),b=Math.min(i,b),w=Math.max(r,w),M=Math.max(i,M)}));var L=Math.abs(w-x),_=Math.abs(M-b),j=new o.PlaneBufferGeometry(L,_);(u=t.call(this))._initOptions(n),u._createMesh(j,c);var I=h.distanceToVector3(f,f).x,O=h.coordinateToVector3(e.getCenter(),I);return u.getObject3d().position.copy(O),u.parent=null,u.type="Image",u}return h(r)}(i.BaseObject),x=function(){function e(t,r,i,n,c){var h=this;s(this,e),this.threelayer=c,this.map=c.map,this.textureLoader=new o.TextureLoader;var u=t.split(","),l=r.split(","),f=parseFloat(u[0]),m=parseFloat(u[1]),y=parseFloat(l[0]),p=parseFloat(l[1]),d=n.maxZoom||11,g=n.renderOrder||0,x=n.opacity||1,b=n.minZoom||3,w=new a.Extent(f,m,y,p);this.xmin_g=f,this.ymin_g=m,this.xmax_g=y,this.ymax_g=p,this.textureLoader.load(i,(function(e){var t=new o.MeshBasicMaterial({map:e,transparent:!0,opacity:x}),r=new v(w,{imageWidth:512,imageHeight:512,maxZoom:d,minZoom:b,interactive:void 0!==n.interactive&&n.interactive},t,h.threelayer);r.object3d.renderOrder=g,h.imgMesh=r,h.imgMesh.parent=h,h.m=t,h.texture=e,h.threelayer.addMesh(h.imgMesh),n.opacityItems&&n.opacityItems.length>0&&!isNaN(n.opacityItems[0])&&!isNaN(n.opacityItems[1])&&n.opacityItems[0]>3&&n.opacityItems[0]<=18&&n.opacityItems[1]>=0&&n.opacityItems[1]<=1&&(h.opacityItems=n.opacityItems,h._bindMapEvents(),h._viewChange())}))}return h(e,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),n=parseFloat(t.leftbottom[1]),s=parseFloat(t.righttop[0]),c=parseFloat(t.righttop[1]);if(i!==this.xmin_g||n!==this.ymin_g||s!==this.xmax_g||c!==this.ymax_g){var h=new a.Extent(i,n,s,c),u=1/0,l=1/0,f=-1/0,m=-1/0;[[i,n],[i,c],[s,c],[s,n]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,n=t.y;u=Math.min(i,u),l=Math.min(n,l),f=Math.max(i,f),m=Math.max(n,m)}));for(var y=Math.abs(f-u),p=Math.abs(m-l),d=new o.PlaneBufferGeometry(y,p),g=d.attributes.position.array,v=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<v.length;x++)v[x]=g[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(h.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),d.dispose(),this.xmin_g=i,this.ymin_g=n,this.xmax_g=s,this.ymax_g=c}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=o.NearestFilter,e.minFilter=o.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),e}(),b=function(){function e(t,r){var n=this;s(this,e),this.map=r,this.animationId=null,this.updatables=[];var a=d();this.threeLayer=new i.ThreeLayer(a,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new o.Clock;var c=function e(){var t,r;(n.threeLayer._needsUpdate=!n.threeLayer._needsUpdate,n.threeLayer._needsUpdate)&&(null===(t=n.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),n.threeLayer.renderScene());var i,a=n.clock.getDelta(),o=p(n.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(a)}}catch(e){o.e(e)}finally{o.f()}n.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new o.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),c()},this.threeLayer.addTo(r),this.layerId=a,this.layerName=t,this.dirty=!1,this.initFlag=!1}return h(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=d();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var n,a=e.clock.getDelta(),o=p(e.updatables);try{for(o.s();!(n=o.n()).done;){n.value.tick(a)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,n){var a=new o.DirectionalLight(16777215);a.position.set(0,-10,10).normalize(),i.add(a),i.add(new o.AmbientLight(16777215)),t(),r()}}))}},{key:"drawImage",value:function(e,t,r,i){var n=this;return new Promise((function(a){if(n.threeLayer.getScene()){var o=new x(e,t,r,i,n.threeLayer);a(o)}else n.initFlag=!0,n.prepareToDraw().then((function(){var o=new x(e,t,r,i,n.threeLayer);a(o)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),n=i.pickingTexture;i.pickingScene;var a=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,n.dispose(),n=null,a.context.dispose(),a.context.forceContextLoss(),a.context=null,a.remove(),a=null,this.map.removeLayer(this.threeLayer)}}]),e}();e.imgClass=x,e.layerClass=b}));