@aibee/crc-bmap 0.0.62 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/main.ts +3 -2
- package/example/vite.config.ts +1 -1
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +31 -7
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +1 -1
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/config.d.ts +1 -0
- package/lib/src/elements/poi.d.ts +2 -0
- package/package.json +1 -1
package/lib/bmap.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var Qt=Object.defineProperty,Jt=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var wt=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var G=Math.pow,xt=(r,a,t)=>a in r?Qt(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t,C=(r,a)=>{for(var t in a||(a={}))ee.call(a,t)&&xt(r,t,a[t]);if(wt)for(var t of wt(a))ie.call(a,t)&&xt(r,t,a[t]);return r},bt=(r,a)=>Jt(r,te(a));var v=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(a,t)=>(typeof require!="undefined"?require:a)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var o=(r,a,t)=>(xt(r,typeof a!="symbol"?a+"":a,t),t);var T=(r,a,t)=>new Promise((e,i)=>{var n=h=>{try{c(t.next(h))}catch(l){i(l)}},s=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(n,s);c((t=t.apply(r,a)).next())});var Wt=v("three");var B=class{constructor(){o(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(a){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),a()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(a){this.tasks.requestAnimation.delete(a),window.cancelAnimationFrame(a)}setTimeout(a,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),a()},t);return this.tasks.timeout.add(e),e}clearTimeout(a){this.tasks.timeout.delete(a),window.clearTimeout(a)}setInterval(a,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),a()},t);return this.tasks.interval.add(e),e}clearInterval(a){this.tasks.interval.delete(a),window.clearInterval(a)}dispose(){this.tasks.requestAnimation.forEach(a=>{window.cancelAnimationFrame(a)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(a=>{window.clearTimeout(a)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(a=>{window.clearInterval(a)}),this.tasks.interval.clear()}};var x=v("three"),Ct=v("three/examples/jsm/controls/MapControls");function Lt(){let r=new x.Scene;return r.background=new x.Color(16777215),r}function Mt(){let r=new x.WebGLRenderer({antialias:!0});return r.autoClear=!0,r.setClearAlpha(1),r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=x.PCFSoftShadowMap,r}function Gt(r,a){let t=new x.OrthographicCamera(-r/2,r/2,a/2,-a/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Dt(){let r=new x.Group,a=new x.AmbientLight(16777215,2.6);return r.add(a),r}function St(r,a){let t=new Ct.MapControls(r,a);return t.enableDamping=!1,t.zoomSpeed=2,t}function At(r,a=[]){let t=new x.Shape(r.map(e=>new x.Vector2(...e)));return a.length&&a.forEach(e=>{var i=new x.Path(e.map(n=>new x.Vector2(...n)));t.holes.push(i)}),t}function Ot(r=16777215,a=1){let t=new x.DirectionalLight(r,a);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function I(r,a){var t;if(a&&r.children&&r.children.length&&r.children.forEach(e=>{I(e,a)}),r.isMesh){let e=r;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}r.isLight&&((t=r.dispose)==null||t.call(r))}function kt(r){return/[\u4E00-\u9FA5]+/g.test(r)}var V=v("three");var N=new Map;function ne(){let r=document.createElement("canvas");r.width=1024,r.height=64;let a=r.getContext("2d",{willReadFrequently:!0});return a.font="54px sans-serif",a.textBaseline="hanging",a.lineWidth=12,a.fillStyle="rgba(0,0,0,1)",a.strokeStyle="white",{canvas:r,ctx:a}}var Et,$;function oe(){if(!Et){let{canvas:r,ctx:a}=ne();Et=r,$=a}}function ye(r){if(N.has(r))return N.get(r);oe(),$.clearRect(0,0,1024,64);let a=kt(r)?4:8;$.strokeText(r,2,a),$.fillText(r,2,a);let t=Math.ceil($.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new V.DataTexture(Uint8Array.from(e.data),t,64,V.RGBAFormat);return i.flipY=!0,i.minFilter=V.LinearFilter,i.magFilter=V.LinearFilter,N.set(r,i),i}function zt(){N.clear()}function Rt(){$=null,Et=null}var j=v("@turf/turf");function E(r,a,t,e){let i=r.clone().project(a),n=t/2,s=e/2,c=Math.round(i.x*n+n),h=Math.round(-i.y*s+s);return{x:c,y:h}}function Pt(r){let a=(0,j.featureCollection)(r.map(e=>(0,j.point)(e)));return(0,j.center)(a).geometry.coordinates}function Q(r,a,t){return r.x>=a.x&&r.x<=t.x&&r.y>=a.y&&r.y<=t.y}function J(r,a){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let s=Reflect.get(t,e,n),c=Reflect.set(t,e,i,n);return s!==i&&a.dispatchEvent({type:`change-${e}`,value:i}),c}})}function W(r,a){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),a)})])}function tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ft(r,a){let t=tt("svg");return t.setAttribute("width",r),t.setAttribute("height",a),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Y(r="2",a){let t=tt("circle");return t.setAttribute("r",r),t.setAttribute("fill",a),t}function et(r){let a=tt("line");return a.setAttribute("stroke",r),a}function Z(r,a){let t=tt("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",a),t}function U(r,a,t){r.setAttribute("cx",`${a}`),r.setAttribute("cy",`${t}`)}function S(r,a,t){a&&(r.setAttribute("x1",`${a.x}`),r.setAttribute("y1",`${a.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function A(r,a,t,e,i){r.setAttribute("x",`${a}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function Tt(){return Promise.resolve()}function Ce(){return new Promise(r=>{requestAnimationFrame(r)})}function Me(r){return parseInt(r.replace("#","0x"),16)}function Ge(r,a){let t=parseInt(r.substring(1,3),16),e=parseInt(r.substring(3,5),16),i=parseInt(r.substring(5,7),16),n=Math.round(t*a),s=Math.round(e*a),c=Math.round(i*a);return`#${(1<<24|n<<16|s<<8|c).toString(16).slice(1)}`}var b=v("three"),K=v("@tweenjs/tween.js");var _t=v("three");var P=v("three");var re={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{}},O=class extends P.Object3D{constructor(t,e){super();this.context=t;o(this,"geometry");o(this,"material");o(this,"mesh");o(this,"line");o(this,"lineMaterial");o(this,"lineGeometry");o(this,"options");if(this.options=J(C(C({},re),e),this),this.options.geometry.type==="point"){let[i,n]=this.options.geometry.cds;return this.position.set(i,n,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var n;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(n=this.lineGeometry)==null||n.dispose())})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new P.Vector3,e=new P.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new P.Vector3(0,0,0);let t=new P.Box3,e=new P.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=At(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new P.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){let t=this.context.materialFactory.createMeshStandardMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});return this.material=t,t}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new P.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{cds:i,curveIndex:n}=this.options.geometry;for(let s=0;s<i.length;s++){let c=i[s];for(let h=0;h<c.length;h++){let l=c[h],p=h+1===c.length?c[0]:c[h+1];t.push(new P.Vector3(l[0],l[1],e)),t.push(new P.Vector3(p[0],p[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new P.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new P.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:n}=e[0];return{position:i,distance:n}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var D=v("three");var it=class extends D.Object3D{constructor(){super();o(this,"directionalLight");o(this,"plane");o(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Ot(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new D.Color(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new D.PlaneGeometry(t,e),n=new D.ShadowMaterial({transparent:!0,opacity:0,side:D.DoubleSide}),s=new D.Mesh(i,n);return s.receiveShadow=!0,s.position.z=-10,this.add(s),this.plane=s,s}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){I(this,!0)}};var ot=v("three");var _=v("three");var se={autoUpdate:!0},nt=class extends _.EventDispatcher{constructor(t,e={}){super();this.context=t;o(this,"div");o(this,"element");o(this,"position",new _.Vector3);o(this,"clientPos",{x:0,y:0});o(this,"visible",!0);o(this,"options");o(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:n,y:s}=E(t,this.context.camera,e,i);this.clientPos.x===n&&this.clientPos.y===s||(this.clientPos={x:n,y:s},this.options.autoUpdate?this.div.style.transform=`translate3d(${n}px, ${-i+s}px, 0)`:this.dispatchEvent({type:"update-position",x:n,y:s,width:e,height:i}))});this.options=C(C({},se),e),this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new _.Box3().setFromObject(this.element).getCenter(new _.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:n}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=n}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.div&&this.context.container.removeChild(this.div),this.div=null}};var ae={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:""},q=class extends ot.EventDispatcher{constructor(t,e){var i,n,s;super();this.context=t;o(this,"div");o(this,"textDiv");o(this,"img");o(this,"overlay");o(this,"options");o(this,"size",{width:0,height:0});o(this,"position",new ot.Vector3);o(this,"_changePosition",()=>{this.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=J(C(C({},ae),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((n=e.position)==null?void 0:n.y)||0,((s=e.position)==null?void 0:s.z)||0),this.overlay=new nt(this.context),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):this.div.appendChild(this.initIcon()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`,this.resetSize())}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return T(this,null,function*(){yield Tt();let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+4,height:e+4}})}renderHelperBox(){let t=document.createElement("div"),e=this.getBox();t.style.cssText=`position: absolute; top: ${e.top}px;left: ${e.left}px;width: ${e.right-e.left}px;height: ${e.bottom-e.top}px;border: 1px solid red;`,this.context.container.appendChild(t)}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this._changePosition(),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[n,s]of Object.entries(e.styles))i.style[n]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this._changePosition(),this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.overlay.visible&&(this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden")}getBox(){let{width:t,height:e}=this.size,{x:i,y:n}=this.overlay.clientPos;return{left:i-t/2,right:i+t/2,top:this.options.icon?n-e:n-e/2,bottom:this.options.icon?n:n+e/2}}isContain(t,e){if(!this.overlay.visible)return!1;let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var k=v("three");var st=v("three");var Bt=v("three");var X=class extends Bt.Object3D{constructor(t){super();this.context=t}dispose(){I(this),this.clear()}};var rt=class extends X{constructor(t){super(t);o(this,"graphicMap",new Map)}getCenter(){return new st.Box3().setFromObject(this).getCenter(new st.Vector3)}createGraphic(t){let e=new O(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((n,s)=>{if(s instanceof O){let c=s.raycast(t);if(c){let{distance:h}=c;if(h<n.distance)return{distance:n.distance,position:n.position,graphic:s}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Ht=v("lodash");var at=class extends X{constructor(t){super(t);o(this,"pois",[]);o(this,"debounceCollisionDetection");o(this,"timer",new B);o(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Ht.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new q(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(n=>n instanceof q&&n.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.withinDisplayRange).forEach((i,n)=>{let{left:s,right:c,top:h,bottom:l}=i.getBox();if(n===0){t.push({left:s,right:c,top:h,bottom:l});return}let p=t.some(m=>c<m.right&&c>m.left||s>m.left&&s<m.right||s===m.left&&c===m.right?l<=m.bottom&&l>m.top||h>=m.top&&h<m.bottom:!1);i.setVisible(!p),p||t.push({left:s,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var w=v("three"),It=v("@mars3d/heatmap.js"),H=v("@turf/turf");var ct=class extends w.Object3D{constructor(t){super();this.context=t;o(this,"heatmap");o(this,"div");o(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:n,center:s}=this.getBox(t);this.heatmap=(0,It.create)(C({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,n)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new w.PlaneGeometry(t,e),n=new w.Texture(this.div.firstChild);n.needsUpdate=!0;let s=new w.MeshBasicMaterial({transparent:!0,side:w.DoubleSide,map:n});s.needsUpdate=!0,this.plane=new w.Mesh(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new w.Matrix3().makeScale(1,-1).multiply(new w.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let c=new w.Vector2(s.x,s.y).applyMatrix3(i);return{x:c.x,y:c.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,H.featureCollection)(t.data.map(l=>(0,H.point)([l.x,l.y]))),i=(0,H.bbox)(e),n=i[2]-i[0],s=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,H.center)(e);return{width:n,height:s,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ht=class extends k.Object3D{constructor(t){super();this.context=t;o(this,"graphicLayer");o(this,"poiLayer");o(this,"grounds",new Set);o(this,"shadow",new it);o(this,"heatmap");o(this,"groundUpper",new k.Object3D);o(this,"groundMaxHeight",0);this.graphicLayer=new rt(this.context),this.poiLayer=new at(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}createGround(t){let e=new O(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new k.Box3().setFromObject(this.groundUpper).getCenter(new k.Vector3)}addShadow(){let t=new k.Box3().setFromObject(this.groundUpper),e=t.getCenter(new k.Vector3),i=t.getSize(new k.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new ct(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new k.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.clear()}};var lt=v("three");var F=class extends lt.EventDispatcher{constructor(t){super();this.context=t;o(this,"points",[]);o(this,"svg");o(this,"enable",!0);o(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Ft(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:n,offsetY:s}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=n/c*2-1,p=1-s/h*2;return new lt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return E(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var pt=class extends F{constructor(t){super(t);this.context=t;o(this,"circles");o(this,"line");o(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),S(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),S(this.line,void 0,t)}});o(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",S(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});o(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t,s=this.circles[this.points.length];U(s,i,n),this.points.length||S(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Y(e.radius,e.fill),Y(e.radius,e.fill)],this.line=et(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:n}]=this.points;return Math.sqrt(G(i-t,2)+G(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var mt=class extends F{constructor(t){super(t);o(this,"circles",[]);o(this,"lines",[]);o(this,"isClose",!1);o(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&S(this.lines[e-1],void 0,i),this.lines[e]&&S(this.lines[e],i)})});o(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",S(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});o(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t;this.checkAdsorb(i,n)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:s,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Y(c,s);U(l,i,n),this.addCircle(l)}if(this.lines.length&&S(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let l=et(h);S(l,{x:i,y:n},{x:i,y:n}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],n=+i.getAttribute("cx"),s=+i.getAttribute("cy");return Math.sqrt(G(t-n,2)+G(e-s,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(n=>[n.x,n.y]),e=0,i=t.length;for(let n=0;n<i;n++){let s=(n+1)%i;e+=t[n][0]*t[s][1]-t[s][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Vt=v("three");var $t=class extends F{constructor(t){super(t);this.context=t;o(this,"rect");o(this,"cornerRect",[]);o(this,"centerRect",[]);o(this,"graphic");o(this,"onUpdate",()=>{if(this.graphic){let t=new Vt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:s,max:c}=t,h=E(s,e,i,n),l=E(c,e,i,n);A(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:m}=h,{x:y,y:u}=l,d=5,L=[{x:p-d,y:u-d},{x:y-d,y:u-d},{x:p-d,y:m-d},{x:y-d,y:m-d}];for(let M=0;M<L.length;M++)A(this.cornerRect[M],L[M].x,L[M].y,d*2,d*2);let g=4,f=(p+y)/2,z=(m+u)/2,R=[{x:f-g,y:u-g},{x:p-g,y:z-g},{x:y-g,y:z-g},{x:f-g,y:m-g}];for(let M=0;M<R.length;M++)A(this.centerRect[M],R[M].x,R[M].y,g*2,g*2)}else{A(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)A(this.cornerRect[t],0,0,0,0),A(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Z(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Z(e.stroke,"#ffffff"),this.centerRect[i]=Z(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var Ut=v("three");var dt=class extends F{constructor(t){super(t);o(this,"startPoint");o(this,"endPoint");o(this,"rect");o(this,"frustum",new Ut.Frustum);o(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});o(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});o(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});o(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=C({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);A(this.rect,i.x,i.y,n,s)}else A(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Z(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),A(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:n}}}=this,s=E(this.startPoint,e,i,n),c=E(this.endPoint,e,i,n),h={x:Math.min(s.x,c.x),y:Math.min(s.y,c.y)},l={x:Math.max(s.x,c.x),y:Math.max(s.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(s=>s instanceof O&&this.searchChildInFrustum(s,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:s,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let u=t.getPosition();if(u){let d=E(u,n,s,c);return Q(d,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,m=E(l,n,s,c),y=E(p,n,s,c);return!(!Q(m,e,i)||!Q(y,e,i))}dispose(){this.unRegistryEvent()}};var ut=class extends _t.EventDispatcher{constructor(t){super();this.context=t;o(this,"_list",new Set);o(this,"boxSelection");o(this,"prevPanStatus");o(this,"prevRotateStatus");o(this,"downPoint",null);o(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});o(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:n,y:s}=this.downPoint;if(Math.sqrt(G(n-e,2)+G(s-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var m;if(!h.has(p.options.id)){let y=((m=this.context.currentFloor)==null?void 0:m.graphicLayer.graphicMap.get(p.options.id))||null;y&&(c.push(y),h.add(p.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});o(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)});o(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});o(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new dt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var Kt=v("three");var gt=class extends Kt.EventDispatcher{constructor(t){super();this.context=t;o(this,"curGraphics",new Set);o(this,"timer",new B);o(this,"graphicTimerMap",new Map);o(this,"onPointerMove",({graphics:t,pois:e})=>{let i=e.map(h=>{var l;return(l=this.context.currentFloor)==null?void 0:l.graphicLayer.graphicMap.get(h.options.id)});if(!t.length&&!i&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:n}=this.context.config.hover,s=new Set([...t,...i]);s.forEach(h=>{if(this.graphicTimerMap.get(h)||this.curGraphics.has(h))return;let l=this.timer.setTimeout(()=>{this.curGraphics.add(h),this.handleHoverGraphicsChange()},n);this.graphicTimerMap.set(h,l)}),this.graphicTimerMap.forEach((h,l)=>{s.has(l)||(this.timer.clearTimeout(h),this.graphicTimerMap.delete(l))});let c=this.curGraphics.size;this.curGraphics.forEach(h=>{s.has(h)||this.curGraphics.delete(h)}),c!==this.curGraphics.size&&this.handleHoverGraphicsChange()});o(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var vt=v("three");var ft=class{constructor(a){this.context=a;o(this,"lineMaterialMap",new Map);o(this,"meshStandardMaterialMap",new Map)}generateLineMaterialKey({color:a,opacity:t}){return`${a}-${t}`}createLineMaterial({color:a,opacity:t}){let e=this.generateLineMaterialKey({color:a,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new vt.LineBasicMaterial({color:a,transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:a,opacity:t}){let e=`${a}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new vt.MeshStandardMaterial({color:a,roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}dispose(){this.lineMaterialMap.forEach((a,t)=>{a.dispose()}),this.lineMaterialMap.clear()}};var yt=class extends b.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;o(this,"scene",Lt());o(this,"renderer",Mt());o(this,"camera");o(this,"control");o(this,"lights",Dt());o(this,"timer",new B);o(this,"tweenGroup",new K.Group);o(this,"currentFloor");o(this,"selection");o(this,"hoverHelper");o(this,"basicRatio");o(this,"materialFactory");o(this,"observe",null);o(this,"clientSize",{width:0,height:0});o(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:s}=t;n=Math.max(1,n),s=Math.max(1,s),e.left=-n/2,e.right=n/2,e.top=s/2,e.bottom=-s/2,e.updateProjectionMatrix(),i.setSize(n,s),this.resizeClientSize(n,s),this.dispatchEvent({type:"resize",width:n,height:s})});o(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);n.length&&this.dispatchEvent({type:"poi-click",pois:n})});o(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:n,position:i})});o(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:n,position:i})});o(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});o(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});o(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new ut(this),this.hoverHelper=new gt(this),this.materialFactory=new ft(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(t,e){this.clientSize={width:t||this.container.clientWidth,height:e||this.container.clientHeight}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=Gt(t,e),this.renderer.setSize(t,e),this.control=St(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var n;let i=this.control.getPolarAngle();(n=this.currentFloor)==null||n.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})})}getRatio(t=new b.Vector3(0,0,0),e=new b.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,s=E(t,this.camera,i,n),c=E(e,this.camera,i,n);return Math.ceil(Math.sqrt(G(c.x-s.x,2)+G(c.y-s.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof b.AmbientLight&&(e.color=new b.Color(t))})}switchFloor(t){this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=t.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new b.Vector2;i.x=t/this.clientSize.width*2-1,i.y=e/this.clientSize.height*-2+1;let n=new b.Raycaster;return n.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(n))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var n;return((n=this.currentFloor)==null?void 0:n.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return e===0?(this.control.maxPolarAngle=t,this.control.minPolarAngle=t,this.control.update(),this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,Promise.resolve()):W(new Promise(i=>{let n={polar:this.control.getPolarAngle()},s={polar:t},c=new K.Tween(n,this.tweenGroup).to(s,e).onUpdate(()=>{this.control.maxPolarAngle=n.polar,this.control.minPolarAngle=n.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}setAzimuthalAngle(t,e=500){if(e===0){this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0;return}return W(new Promise(i=>{let n={azimuthal:this.control.getAzimuthalAngle()},s={azimuthal:t},c=new K.Tween(n,this.tweenGroup).to(s,e).onUpdate(()=>{this.control.maxAzimuthAngle=n.azimuthal,this.control.minAzimuthAngle=n.azimuthal,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new b.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let n=this.getCameraLookAt(),s={zoom:this.camera.zoom,target:this.control.target.clone()};if(!i){this.camera.position.copy(e.clone().sub(n)),this.control.target.copy(e),this.camera.zoom=t,this.control.update();return}return W(new Promise(c=>{let h=new K.Tween(s,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(s.target.clone().sub(n)),this.control.target.copy(s.target),this.camera.zoom=s.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(h),this.control.enabled=!0,c(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[n,s,c,h]=e,{clientSize:{width:l,height:p}}=this,m=this.control.getPolarAngle();this.setPolarAngle(0,0);let y=new b.Box3().setFromObject(t);this.setPolarAngle(m,0);let{max:u,min:d}=y,L=E(u,this.camera,l,p),g=E(d,this.camera,l,p),z=new b.Box2().setFromPoints([new b.Vector2(L.x,L.y),new b.Vector2(g.x,g.y)]).getSize(new b.Vector2),R=(l-s-h)/z.x,M=(p-n-c)/z.y,qt=Math.min(R,M),Nt=new b.Vector3((u.x+d.x)/2,(u.y+d.y)/2,u.z);return this.setZoom(qt*this.camera.zoom,Nt,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return W(new Promise(i=>{let n=this.camera.position.clone(),s=this.getCameraLookAt(),c=new K.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(s))}).onComplete(()=>{this.tweenGroup.remove(c),this.camera.position.copy(n.clone().sub(s)),this.control.target.copy(t.clone()),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),this.materialFactory.dispose(),I(this.scene)}};var jt=v("lodash"),ce={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},resizeObserver:!1,heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#ffffff",opacity:1,height:3,stroke:!0,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#ecf0f7",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1}};function Zt(r){return(0,jt.merge)({},ce,r)}var Yt=v("lodash");var he=(t=>(t[t.D2=0]="D2",t[t.D3=.9]="D3",t))(he||{}),Xt=class extends Wt.EventDispatcher{constructor(t,e={}){super();this.container=t;o(this,"config");o(this,"context");o(this,"polarKeys",[]);o(this,"azimuthalKeys",[]);o(this,"svgLine");o(this,"svgPolygon");o(this,"basicZoom",1);o(this,"prevCameraZoom",1);o(this,"type","2d");o(this,"floorDataMap",new Map);o(this,"buildingGroundMap",new Map);o(this,"currentBuildGround",null);o(this,"observe",null);o(this,"onControlChange",()=>{let{camera:{zoom:t}}=this.context;t!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=t)});o(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});o(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});o(this,"resize",()=>{this.context.onWindowResize();let t=this.context.control.getAzimuthalAngle(),e=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0),this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.camera.zoom=e,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(t,0)});this.config=Zt(e),this.context=new yt(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(l){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}){let{apiDomain:p,apiPath:{floorGraphic:m},apiInfo:y}=this.config,u=`${p}${m}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${s}&ts=${c}&resource_type_list=${h}`;return yield fetch(u,y).then(L=>L.json()).then(L=>L.data).then(L=>((L||[]).map(g=>g.info=JSON.parse(g.info)),L||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(s){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:n});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:l},apiInfo:p}=this.config,m=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${n}`,y=yield fetch(m,p).then(u=>u.json()).then(u=>u.data).then(u=>{let d=(u||[])[0];return d&&(d.info=JSON.parse(d.info)),d});return this.buildingGroundMap.set(c,y),y})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${n}-${s}-${c}-${h}`}load(l){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h});if(this.floorDataMap.get(p))return;let[m,y]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(y){let g=Pt(y.info.geometry.cds[0]);m.forEach(f=>{if(f.info.geometry.type==="polygon")f.info.geometry.cds.map(z=>{Array.isArray(z)&&z.forEach(R=>{R[0]-=g[0],R[1]-=g[1]})});else{let[z,R]=f.info.geometry.cds;f.info.geometry.cds=[z-g[0],R-g[1]]}f.info.transformToBuildingGround=!0})}let{ground:u,markGraphic:d,graphic:L}=this.config;for(let g=0;g<m.length;g++){let f=m[g];f.info.deltaHeight=1e-5*(g+1),f.info.group==="ground"?(f.info.fillColor=u.color,f.info.fillOpacity=u.opacity,f.info.height=u.height,f.info.stroke=u.stroke,f.info.strokeColor=u.strokeColor,f.info.strokeOpacity=u.strokeOpacity):f.info.userData.mark?(f.info.height=d.height,f.info.fillColor=d.color,f.info.fillOpacity=d.opacity,f.info.stroke=d.stroke,f.info.strokeColor=d.strokeColor,f.info.strokeOpacity=d.strokeOpacity):f.info.fillOpacity=L.fillOpacity}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(p,m),m})}createFloor(t){let e=new ht(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=new Map,n=[];for(let s of t)if(s.info.group==="ground")e.createGround(s.info);else{let c=e.addGraphic(s.info);c.userData.data=s,i.set(s.legacy_id,c),n.push(c)}return e.addShadow(),e.userData.legacyToGraphicMap=i,{curFloor:e,graphics:n}}switchFloor({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:s,ts:c,resource_type_list:h}),p=this.floorDataMap.get(l);if(this.context.control.removeEventListener("change",this.onControlChange),p){let m=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(m)||null;let y=this.createFloor(p);y?(this.context.switchFloor(y.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0),this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange()):console.warn("[switchFloor error] ["+s+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof O))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.getCenter();return this.context.currentFloor.addPoi(bt(C({},e),{position:bt(C({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.getPosition();return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return E(e,this.context.camera,i,n)}changeMapType(t,e=500){return this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(.9,e)}resetView(t=300){return T(this,null,function*(){let e=t/3;yield this.context.setAzimuthalAngle(0,e),yield this.changeMapType(this.type,e),yield this.context.fitCameraToGround(void 0,e)})}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver){let t=new ResizeObserver((0,Yt.debounce)(this.resize,5));t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return T(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new pt(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:n})=>{t(n)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new mt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:n})=>{t(n)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=Pt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(s=>{s[0]-=i[0],s[1]-=i[1]})});else{let[n,s]=t.geometry.cds;t.geometry.cds=[n-i[0],s-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&(this.getPois().forEach(t=>t.dispose()),this.context.currentFloor.poiLayer.clear())}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),this.floorDataMap.clear(),this.buildingGroundMap.clear(),zt(),Rt(),this.unRegistryEvent()}};})();
|
|
1
|
+
"use strict";(()=>{var Qt=Object.defineProperty,Jt=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var wt=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var G=Math.pow,xt=(r,a,t)=>a in r?Qt(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t,C=(r,a)=>{for(var t in a||(a={}))ee.call(a,t)&&xt(r,t,a[t]);if(wt)for(var t of wt(a))ie.call(a,t)&&xt(r,t,a[t]);return r},bt=(r,a)=>Jt(r,te(a));var v=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(a,t)=>(typeof require!="undefined"?require:a)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var n=(r,a,t)=>(xt(r,typeof a!="symbol"?a+"":a,t),t);var R=(r,a,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},s=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,s);c((t=t.apply(r,a)).next())});var Wt=v("three");var B=class{constructor(){n(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(a){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),a()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(a){this.tasks.requestAnimation.delete(a),window.cancelAnimationFrame(a)}setTimeout(a,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),a()},t);return this.tasks.timeout.add(e),e}clearTimeout(a){this.tasks.timeout.delete(a),window.clearTimeout(a)}setInterval(a,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),a()},t);return this.tasks.interval.add(e),e}clearInterval(a){this.tasks.interval.delete(a),window.clearInterval(a)}dispose(){this.tasks.requestAnimation.forEach(a=>{window.cancelAnimationFrame(a)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(a=>{window.clearTimeout(a)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(a=>{window.clearInterval(a)}),this.tasks.interval.clear()}};var x=v("three"),Ct=v("three/examples/jsm/controls/MapControls");function Mt(){let r=new x.Scene;return r.background=new x.Color(16777215),r}function Lt(){let r=new x.WebGLRenderer({antialias:!0});return r.autoClear=!0,r.setClearAlpha(1),r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=x.PCFSoftShadowMap,r}function Gt(r,a){let t=new x.OrthographicCamera(-r/2,r/2,a/2,-a/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Dt(){let r=new x.Group,a=new x.AmbientLight(16777215,2.6);return r.add(a),r}function St(r,a){let t=new Ct.MapControls(r,a);return t.enableDamping=!1,t.zoomSpeed=2,t}function At(r,a=[]){let t=new x.Shape(r.map(e=>new x.Vector2(...e)));return a.length&&a.forEach(e=>{var i=new x.Path(e.map(o=>new x.Vector2(...o)));t.holes.push(i)}),t}function kt(r=16777215,a=1){let t=new x.DirectionalLight(r,a);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function I(r,a){var t;if(a&&r.children&&r.children.length&&r.children.forEach(e=>{I(e,a)}),r.isMesh){let e=r;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}r.isLight&&((t=r.dispose)==null||t.call(r))}function Ot(r){return/[\u4E00-\u9FA5]+/g.test(r)}var V=v("three");var N=new Map;function oe(){let r=document.createElement("canvas");r.width=1024,r.height=64;let a=r.getContext("2d",{willReadFrequently:!0});return a.font="54px sans-serif",a.textBaseline="hanging",a.lineWidth=12,a.fillStyle="rgba(0,0,0,1)",a.strokeStyle="white",{canvas:r,ctx:a}}var Et,$;function ne(){if(!Et){let{canvas:r,ctx:a}=oe();Et=r,$=a}}function ye(r){if(N.has(r))return N.get(r);ne(),$.clearRect(0,0,1024,64);let a=Ot(r)?4:8;$.strokeText(r,2,a),$.fillText(r,2,a);let t=Math.ceil($.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new V.DataTexture(Uint8Array.from(e.data),t,64,V.RGBAFormat);return i.flipY=!0,i.minFilter=V.LinearFilter,i.magFilter=V.LinearFilter,N.set(r,i),i}function zt(){N.clear()}function Ft(){$=null,Et=null}var j=v("@turf/turf");function E(r,a,t,e){let i=r.clone().project(a),o=t/2,s=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*s+s);return{x:c,y:h}}function Pt(r){let a=(0,j.featureCollection)(r.map(e=>(0,j.point)(e)));return(0,j.center)(a).geometry.coordinates}function Q(r,a,t){return r.x>=a.x&&r.x<=t.x&&r.y>=a.y&&r.y<=t.y}function J(r,a){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let s=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return s!==i&&a.dispatchEvent({type:`change-${e}`,value:i}),c}})}function W(r,a){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),a)})])}function tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Tt(r,a){let t=tt("svg");return t.setAttribute("width",r),t.setAttribute("height",a),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Y(r="2",a){let t=tt("circle");return t.setAttribute("r",r),t.setAttribute("fill",a),t}function et(r){let a=tt("line");return a.setAttribute("stroke",r),a}function Z(r,a){let t=tt("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",a),t}function U(r,a,t){r.setAttribute("cx",`${a}`),r.setAttribute("cy",`${t}`)}function S(r,a,t){a&&(r.setAttribute("x1",`${a.x}`),r.setAttribute("y1",`${a.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function A(r,a,t,e,i){r.setAttribute("x",`${a}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function Rt(){return Promise.resolve()}function Ce(){return new Promise(r=>{requestAnimationFrame(r)})}function Le(r){return parseInt(r.replace("#","0x"),16)}function Ge(r,a){let t=parseInt(r.substring(1,3),16),e=parseInt(r.substring(3,5),16),i=parseInt(r.substring(5,7),16),o=Math.round(t*a),s=Math.round(e*a),c=Math.round(i*a);return`#${(1<<24|o<<16|s<<8|c).toString(16).slice(1)}`}var b=v("three"),K=v("@tweenjs/tween.js");var _t=v("three");var P=v("three");var re={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{}},k=class extends P.Object3D{constructor(t,e){super();this.context=t;n(this,"geometry");n(this,"material");n(this,"mesh");n(this,"line");n(this,"lineMaterial");n(this,"lineGeometry");n(this,"options");if(this.options=J(C(C({},re),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.cds;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new P.Vector3,e=new P.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new P.Vector3(0,0,0);let t=new P.Box3,e=new P.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=At(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new P.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){let t=this.context.materialFactory.createMeshStandardMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});return this.material=t,t}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new P.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{cds:i,curveIndex:o}=this.options.geometry;for(let s=0;s<i.length;s++){let c=i[s];for(let h=0;h<c.length;h++){let l=c[h],p=h+1===c.length?c[0]:c[h+1];t.push(new P.Vector3(l[0],l[1],e)),t.push(new P.Vector3(p[0],p[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new P.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new P.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var D=v("three");var it=class extends D.Object3D{constructor(){super();n(this,"directionalLight");n(this,"plane");n(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=kt(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new D.Color(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new D.PlaneGeometry(t,e),o=new D.ShadowMaterial({transparent:!0,opacity:0,side:D.DoubleSide}),s=new D.Mesh(i,o);return s.receiveShadow=!0,s.position.z=-10,this.add(s),this.plane=s,s}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){I(this,!0)}};var nt=v("three");var _=v("three");var se={autoUpdate:!0},ot=class extends _.EventDispatcher{constructor(t,e={}){super();this.context=t;n(this,"div");n(this,"element");n(this,"position",new _.Vector3);n(this,"clientPos",{x:0,y:0});n(this,"visible",!0);n(this,"options");n(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:o,y:s}=E(t,this.context.camera,e,i);this.clientPos.x===o&&this.clientPos.y===s||(this.clientPos={x:o,y:s},this.options.autoUpdate?this.div.style.transform=`translate3d(${o}px, ${-i+s}px, 0)`:this.dispatchEvent({type:"update-position",x:o,y:s,width:e,height:i}))});this.options=C(C({},se),e),this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new _.Box3().setFromObject(this.element).getCenter(new _.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.div&&this.context.container.removeChild(this.div),this.div=null}};var ae={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:""},q=class extends nt.EventDispatcher{constructor(t,e){var i,o,s;super();this.context=t;n(this,"div");n(this,"textDiv");n(this,"img");n(this,"overlay");n(this,"options");n(this,"visible",!0);n(this,"size",{width:0,height:0});n(this,"position",new nt.Vector3);n(this,"_changePosition",()=>{});this.options=J(C(C({},ae),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((s=e.position)==null?void 0:s.z)||0),this.overlay=new ot(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):this.div.appendChild(this.initIcon()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`,this.resetSize())}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return R(this,null,function*(){yield Rt();let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+4,height:e+4}})}renderHelperBox(){let t=document.createElement("div"),e=this.getBox();t.style.cssText=`position: absolute; top: ${e.top}px;left: ${e.left}px;width: ${e.right-e.left}px;height: ${e.bottom-e.top}px;border: 1px solid red;`,this.context.container.appendChild(t)}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this._changePosition(),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,s]of Object.entries(e.styles))i.style[o]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this._changePosition(),this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,t||(this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden"))}parentSetVisible(t){this.visible&&t!==this.overlay.visible&&(this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden")}getBox(){let{width:t,height:e}=this.size,{x:i,y:o}=this.overlay.clientPos;return{left:i-t/2,right:i+t/2,top:this.options.icon?o-e:o-e/2,bottom:this.options.icon?o:o+e/2}}isContain(t,e){if(!this.overlay.visible)return!1;let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var O=v("three");var st=v("three");var Bt=v("three");var X=class extends Bt.Object3D{constructor(t){super();this.context=t}dispose(){I(this),this.clear()}};var rt=class extends X{constructor(t){super(t);n(this,"graphicMap",new Map)}getCenter(){return new st.Box3().setFromObject(this).getCenter(new st.Vector3)}createGraphic(t){let e=new k(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((o,s)=>{if(s instanceof k){let c=s.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:s}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Ht=v("lodash");var at=class extends X{constructor(t){super(t);n(this,"pois",[]);n(this,"debounceCollisionDetection");n(this,"timer",new B);n(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Ht.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois.forEach(t=>t.dispose()),this.pois=[],this}createPoi(t){let e=new q(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(o=>o instanceof q&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:s,right:c,top:h,bottom:l}=i.getBox();if(o===0){t.push({left:s,right:c,top:h,bottom:l});return}let p=t.some(m=>c<m.right&&c>m.left||s>m.left&&s<m.right||s===m.left&&c===m.right?l<=m.bottom&&l>m.top||h>=m.top&&h<m.bottom:!1);i.parentSetVisible(!p),p||t.push({left:s,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var w=v("three"),It=v("@mars3d/heatmap.js"),H=v("@turf/turf");var ct=class extends w.Object3D{constructor(t){super();this.context=t;n(this,"heatmap");n(this,"div");n(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:o,center:s}=this.getBox(t);this.heatmap=(0,It.create)(C({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new w.PlaneGeometry(t,e),o=new w.Texture(this.div.firstChild);o.needsUpdate=!0;let s=new w.MeshBasicMaterial({transparent:!0,side:w.DoubleSide,map:o});s.needsUpdate=!0,this.plane=new w.Mesh(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new w.Matrix3().makeScale(1,-1).multiply(new w.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let c=new w.Vector2(s.x,s.y).applyMatrix3(i);return{x:c.x,y:c.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,H.featureCollection)(t.data.map(l=>(0,H.point)([l.x,l.y]))),i=(0,H.bbox)(e),o=i[2]-i[0],s=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,H.center)(e);return{width:o,height:s,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ht=class extends O.Object3D{constructor(t){super();this.context=t;n(this,"graphicLayer");n(this,"poiLayer");n(this,"grounds",new Set);n(this,"shadow",new it);n(this,"heatmap");n(this,"groundUpper",new O.Object3D);n(this,"groundMaxHeight",0);this.graphicLayer=new rt(this.context),this.poiLayer=new at(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}createGround(t){let e=new k(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new O.Box3().setFromObject(this.groundUpper).getCenter(new O.Vector3)}addShadow(){let t=new O.Box3().setFromObject(this.groundUpper),e=t.getCenter(new O.Vector3),i=t.getSize(new O.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new ct(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new O.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.clear()}};var lt=v("three");var T=class extends lt.EventDispatcher{constructor(t){super();this.context=t;n(this,"points",[]);n(this,"svg");n(this,"enable",!0);n(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Tt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:o,offsetY:s}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-s/h*2;return new lt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return E(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var pt=class extends T{constructor(t){super(t);this.context=t;n(this,"circles");n(this,"line");n(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),S(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),S(this.line,void 0,t)}});n(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",S(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});n(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,s=this.circles[this.points.length];U(s,i,o),this.points.length||S(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Y(e.radius,e.fill),Y(e.radius,e.fill)],this.line=et(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:o}]=this.points;return Math.sqrt(G(i-t,2)+G(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var mt=class extends T{constructor(t){super(t);n(this,"circles",[]);n(this,"lines",[]);n(this,"isClose",!1);n(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&S(this.lines[e-1],void 0,i),this.lines[e]&&S(this.lines[e],i)})});n(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",S(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});n(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:s,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Y(c,s);U(l,i,o),this.addCircle(l)}if(this.lines.length&&S(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=et(h);S(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],o=+i.getAttribute("cx"),s=+i.getAttribute("cy");return Math.sqrt(G(t-o,2)+G(e-s,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let s=(o+1)%i;e+=t[o][0]*t[s][1]-t[s][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Vt=v("three");var $t=class extends T{constructor(t){super(t);this.context=t;n(this,"rect");n(this,"cornerRect",[]);n(this,"centerRect",[]);n(this,"graphic");n(this,"onUpdate",()=>{if(this.graphic){let t=new Vt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:s,max:c}=t,h=E(s,e,i,o),l=E(c,e,i,o);A(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:m}=h,{x:y,y:g}=l,d=5,M=[{x:p-d,y:g-d},{x:y-d,y:g-d},{x:p-d,y:m-d},{x:y-d,y:m-d}];for(let L=0;L<M.length;L++)A(this.cornerRect[L],M[L].x,M[L].y,d*2,d*2);let f=4,u=(p+y)/2,z=(m+g)/2,F=[{x:u-f,y:g-f},{x:p-f,y:z-f},{x:y-f,y:z-f},{x:u-f,y:m-f}];for(let L=0;L<F.length;L++)A(this.centerRect[L],F[L].x,F[L].y,f*2,f*2)}else{A(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)A(this.cornerRect[t],0,0,0,0),A(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Z(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Z(e.stroke,"#ffffff"),this.centerRect[i]=Z(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var Ut=v("three");var dt=class extends T{constructor(t){super(t);n(this,"startPoint");n(this,"endPoint");n(this,"rect");n(this,"frustum",new Ut.Frustum);n(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});n(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});n(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});n(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=C({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);A(this.rect,i.x,i.y,o,s)}else A(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Z(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),A(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:o}}}=this,s=E(this.startPoint,e,i,o),c=E(this.endPoint,e,i,o),h={x:Math.min(s.x,c.x),y:Math.min(s.y,c.y)},l={x:Math.max(s.x,c.x),y:Math.max(s.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(s=>s instanceof k&&this.searchChildInFrustum(s,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:s,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let g=t.getPosition();if(g){let d=E(g,o,s,c);return Q(d,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,m=E(l,o,s,c),y=E(p,o,s,c);return!(!Q(m,e,i)||!Q(y,e,i))}dispose(){this.unRegistryEvent()}};var ut=class extends _t.EventDispatcher{constructor(t){super();this.context=t;n(this,"_list",new Set);n(this,"boxSelection");n(this,"prevPanStatus");n(this,"prevRotateStatus");n(this,"downPoint",null);n(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});n(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:s}=this.downPoint;if(Math.sqrt(G(o-e,2)+G(s-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var m;if(!h.has(p.options.id)){let y=((m=this.context.currentFloor)==null?void 0:m.graphicLayer.graphicMap.get(p.options.id))||null;y&&(c.push(y),h.add(p.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});n(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)});n(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});n(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new dt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var Kt=v("three");var gt=class extends Kt.EventDispatcher{constructor(t){super();this.context=t;n(this,"curGraphics",new Set);n(this,"timer",new B);n(this,"graphicTimerMap",new Map);n(this,"onPointerMove",({graphics:t,pois:e})=>{let i=e.map(h=>{var l;return(l=this.context.currentFloor)==null?void 0:l.graphicLayer.graphicMap.get(h.options.id)});if(!t.length&&!i&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:o}=this.context.config.hover,s=new Set([...t,...i]);s.forEach(h=>{if(this.graphicTimerMap.get(h)||this.curGraphics.has(h))return;let l=this.timer.setTimeout(()=>{this.curGraphics.add(h),this.handleHoverGraphicsChange()},o);this.graphicTimerMap.set(h,l)}),this.graphicTimerMap.forEach((h,l)=>{s.has(l)||(this.timer.clearTimeout(h),this.graphicTimerMap.delete(l))});let c=this.curGraphics.size;this.curGraphics.forEach(h=>{s.has(h)||this.curGraphics.delete(h)}),c!==this.curGraphics.size&&this.handleHoverGraphicsChange()});n(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var vt=v("three");var ft=class{constructor(a){this.context=a;n(this,"lineMaterialMap",new Map);n(this,"meshStandardMaterialMap",new Map)}generateLineMaterialKey({color:a,opacity:t}){return`${a}-${t}`}createLineMaterial({color:a,opacity:t}){let e=this.generateLineMaterialKey({color:a,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new vt.LineBasicMaterial({color:a,transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:a,opacity:t}){let e=`${a}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new vt.MeshStandardMaterial({color:a,roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}dispose(){this.lineMaterialMap.forEach((a,t)=>{a.dispose()}),this.lineMaterialMap.clear()}};var yt=class extends b.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;n(this,"scene",Mt());n(this,"renderer",Lt());n(this,"camera");n(this,"control");n(this,"lights",Dt());n(this,"timer",new B);n(this,"tweenGroup",new K.Group);n(this,"currentFloor");n(this,"selection");n(this,"hoverHelper");n(this,"basicRatio");n(this,"materialFactory");n(this,"observe",null);n(this,"clientSize",{width:0,height:0});n(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:o,clientHeight:s}=t;o=Math.max(1,o),s=Math.max(1,s),e.left=-o/2,e.right=o/2,e.top=s/2,e.bottom=-s/2,e.updateProjectionMatrix(),i.setSize(o,s),this.resizeClientSize(o,s),this.dispatchEvent({type:"resize",width:o,height:s})});n(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);o.length&&this.dispatchEvent({type:"poi-click",pois:o})});n(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:o,position:i})});n(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:o,position:i})});n(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});n(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});n(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new ut(this),this.hoverHelper=new gt(this),this.materialFactory=new ft(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(t,e){this.clientSize={width:t||this.container.clientWidth,height:e||this.container.clientHeight}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=Gt(t,e),this.renderer.setSize(t,e),this.control=St(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var o;let i=this.control.getPolarAngle();(o=this.currentFloor)==null||o.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})})}getRatio(t=new b.Vector3(0,0,0),e=new b.Vector3(100,0,0)){let{clientWidth:i,clientHeight:o}=this.container,s=E(t,this.camera,i,o),c=E(e,this.camera,i,o);return Math.ceil(Math.sqrt(G(c.x-s.x,2)+G(c.y-s.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof b.AmbientLight&&(e.color=new b.Color(t))})}switchFloor(t){this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=t.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new b.Vector2;i.x=t/this.clientSize.width*2-1,i.y=e/this.clientSize.height*-2+1;let o=new b.Raycaster;return o.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(o))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var o;return((o=this.currentFloor)==null?void 0:o.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return e===0?(this.control.maxPolarAngle=t,this.control.minPolarAngle=t,this.control.update(),this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,Promise.resolve()):W(new Promise(i=>{let o={polar:this.control.getPolarAngle()},s={polar:t},c=new K.Tween(o,this.tweenGroup).to(s,e).onUpdate(()=>{this.control.maxPolarAngle=o.polar,this.control.minPolarAngle=o.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}setAzimuthalAngle(t,e=500){if(e===0){this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0;return}return W(new Promise(i=>{let o={azimuthal:this.control.getAzimuthalAngle()},s={azimuthal:t},c=new K.Tween(o,this.tweenGroup).to(s,e).onUpdate(()=>{this.control.maxAzimuthAngle=o.azimuthal,this.control.minAzimuthAngle=o.azimuthal,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new b.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let o=this.getCameraLookAt(),s={zoom:this.camera.zoom,target:this.control.target.clone()};if(!i){this.camera.position.copy(e.clone().sub(o)),this.control.target.copy(e),this.camera.zoom=t,this.control.update();return}return W(new Promise(c=>{let h=new K.Tween(s,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(s.target.clone().sub(o)),this.control.target.copy(s.target),this.camera.zoom=s.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(h),this.control.enabled=!0,c(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[o,s,c,h]=e,{clientSize:{width:l,height:p}}=this,m=this.control.getPolarAngle();this.setPolarAngle(0,0);let y=new b.Box3().setFromObject(t);this.setPolarAngle(m,0);let{max:g,min:d}=y,M=E(g,this.camera,l,p),f=E(d,this.camera,l,p),z=new b.Box2().setFromPoints([new b.Vector2(M.x,M.y),new b.Vector2(f.x,f.y)]).getSize(new b.Vector2),F=(l-s-h)/z.x,L=(p-o-c)/z.y,qt=Math.min(F,L),Nt=new b.Vector3((g.x+d.x)/2,(g.y+d.y)/2,g.z);return this.setZoom(qt*this.camera.zoom,Nt,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return W(new Promise(i=>{let o=this.camera.position.clone(),s=this.getCameraLookAt(),c=new K.Tween(o,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(o),this.control.target.copy(t.clone().add(s))}).onComplete(()=>{this.tweenGroup.remove(c),this.camera.position.copy(o.clone().sub(s)),this.control.target.copy(t.clone()),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),this.materialFactory.dispose(),I(this.scene)}};var jt=v("lodash"),ce={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},resizeObserver:!1,initTransToMark:!1,heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#FAFAFA",opacity:1,height:3,stroke:!0,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#EEF0F3",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1}};function Zt(r){return(0,jt.merge)({},ce,r)}var Yt=v("lodash");var he=(t=>(t[t.D2=0]="D2",t[t.D3=.9]="D3",t))(he||{}),Xt=class extends Wt.EventDispatcher{constructor(t,e={}){super();this.container=t;n(this,"config");n(this,"context");n(this,"polarKeys",[]);n(this,"azimuthalKeys",[]);n(this,"svgLine");n(this,"svgPolygon");n(this,"basicZoom",1);n(this,"prevCameraZoom",1);n(this,"type","2d");n(this,"floorDataMap",new Map);n(this,"buildingGroundMap",new Map);n(this,"currentBuildGround",null);n(this,"observe",null);n(this,"onControlChange",()=>{let{camera:{zoom:t}}=this.context;t!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=t)});n(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});n(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});n(this,"resize",()=>{this.context.onWindowResize();let t=this.context.control.getAzimuthalAngle(),e=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0),this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.camera.zoom=e,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(t,0)});this.config=Zt(e),this.context=new yt(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(l){return R(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}){let{apiDomain:p,apiPath:{floorGraphic:m},apiInfo:y}=this.config,g=`${p}${m}?brand=${t}&project=${e}&phase=${i}&building=${o}&floor=${s}&ts=${c}&resource_type_list=${h}`;return yield fetch(g,y).then(M=>M.json()).then(M=>M.data).then(M=>((M||[]).map(f=>f.info=JSON.parse(f.info)),M||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:o}){return`${t}-${e}-${i}-${o}`}loadBuildingGround(s){return R(this,arguments,function*({brand:t,project:e,phase:i,building:o}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:o});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:l},apiInfo:p}=this.config,m=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${o}`,y=yield fetch(m,p).then(g=>g.json()).then(g=>g.data).then(g=>{let d=(g||[])[0];return d&&(d.info=JSON.parse(d.info)),d});return this.buildingGroundMap.set(c,y),y})}getFloorKey({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${o}-${s}-${c}-${h}`}load(l){return R(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h});if(this.floorDataMap.get(p))return;let[m,y]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:o})]);if(y){let f=Pt(y.info.geometry.cds[0]);m.forEach(u=>{if(u.info.geometry.type==="polygon")u.info.geometry.cds.map(z=>{Array.isArray(z)&&z.forEach(F=>{F[0]-=f[0],F[1]-=f[1]})});else{let[z,F]=u.info.geometry.cds;u.info.geometry.cds=[z-f[0],F-f[1]]}u.info.transformToBuildingGround=!0})}let{ground:g,markGraphic:d,graphic:M}=this.config;for(let f=0;f<m.length;f++){let u=m[f];u.info.deltaHeight=1e-5*(f+1),u.info.group==="ground"?(u.info.fillColor=g.color,u.info.fillOpacity=g.opacity,u.info.height=g.height,u.info.stroke=g.stroke,u.info.strokeColor=g.strokeColor,u.info.strokeOpacity=g.strokeOpacity):u.info.userData.mark?(u.info.height=d.height,u.info.fillColor=d.color,u.info.fillOpacity=d.opacity,u.info.stroke=d.stroke,u.info.strokeColor=d.strokeColor,u.info.strokeOpacity=d.strokeOpacity):(u.info.fillOpacity=M.fillOpacity,this.config.initTransToMark&&(u.info.height=d.height,u.info.fillColor=d.color,u.info.stroke=d.stroke,u.info.strokeColor=d.strokeColor,u.info.strokeOpacity=d.strokeOpacity))}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(p,m),m})}createFloor(t){let e=new ht(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=new Map,o=[];for(let s of t)if(s.info.group==="ground")e.createGround(s.info);else{let c=e.addGraphic(s.info);c.userData.data=s,i.set(s.legacy_id,c),o.push(c)}return e.addShadow(),e.userData.legacyToGraphicMap=i,{curFloor:e,graphics:o}}switchFloor({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:s,ts:c,resource_type_list:h}),p=this.floorDataMap.get(l);if(this.context.control.removeEventListener("change",this.onControlChange),p){let m=this.getBuildingKey({brand:t,project:e,phase:i,building:o});this.currentBuildGround=this.buildingGroundMap.get(m)||null;let y=this.createFloor(p);y?(this.context.switchFloor(y.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0),this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange()):console.warn("[switchFloor error] ["+s+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof k))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.getCenter();return this.context.currentFloor.addPoi(bt(C({},e),{position:bt(C({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.getPosition();return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:o}=this.container;return E(e,this.context.camera,i,o)}changeMapType(t,e=500){return this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(.9,e)}resetView(t=300){return R(this,null,function*(){let e=t/3;yield this.context.setAzimuthalAngle(0,e),yield this.changeMapType(this.type,e),yield this.context.fitCameraToGround(void 0,e)})}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver){let t=new ResizeObserver((0,Yt.debounce)(this.resize,5));t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return R(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new pt(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:o})=>{t(o)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new mt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:o})=>{t(o)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=Pt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(o=>{Array.isArray(o)&&o.forEach(s=>{s[0]-=i[0],s[1]-=i[1]})});else{let[o,s]=t.geometry.cds;t.geometry.cds=[o-i[0],s-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&this.context.currentFloor.poiLayer.clear()}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),this.floorDataMap.clear(),this.buildingGroundMap.clear(),zt(),Ft(),this.unRegistryEvent()}};})();
|
|
2
2
|
//# sourceMappingURL=bmap.min.js.map
|