@aibee/crc-bmap 0.0.43 → 0.0.46
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/lib/bmap.cjs.min.js +2 -2
- package/lib/bmap.cjs.min.js.map +2 -2
- package/lib/bmap.esm.js +5 -2
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +2 -2
- package/lib/bmap.esm.min.js.map +2 -2
- package/lib/bmap.min.js +2 -2
- package/lib/bmap.min.js.map +2 -2
- package/package.json +1 -1
package/lib/bmap.cjs.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var pt=Object.defineProperty,re=Object.defineProperties,se=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertyNames,Rt=Object.getOwnPropertySymbols;var kt=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var C=Math.pow,yt=(r,s,t)=>s in r?pt(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t,k=(r,s)=>{for(var t in s||(s={}))kt.call(s,t)&&yt(r,t,s[t]);if(Rt)for(var t of Rt(s))he.call(s,t)&&yt(r,t,s[t]);return r},xt=(r,s)=>re(r,ae(s));var pe=(r,s)=>{for(var t in s)pt(r,t,{get:s[t],enumerable:!0})},le=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of ce(s))!kt.call(r,i)&&i!==t&&pt(r,i,{get:()=>s[i],enumerable:!(e=se(s,i))||e.enumerable});return r};var me=r=>le(pt({},"__esModule",{value:!0}),r);var o=(r,s,t)=>(yt(r,typeof s!="symbol"?s+"":s,t),t);var O=(r,s,t)=>new Promise((e,i)=>{var n=h=>{try{c(t.next(h))}catch(p){i(p)}},a=h=>{try{c(t.throw(h))}catch(p){i(p)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(n,a);c((t=t.apply(r,s)).next())});var ve={};pe(ve,{BMap:()=>Tt,BaseSvg:()=>A,Context:()=>ht,Floor:()=>ot,Graphic:()=>D,GraphicLayer:()=>et,HeatmapElement:()=>nt,HoverHelper:()=>ct,Layer:()=>$,MapTypePolar:()=>ie,Overlay:()=>tt,Poi:()=>X,PoiLayer:()=>it,SelectBox:()=>Ft,Selection:()=>at,Shadow:()=>J,SvgLine:()=>rt,SvgPolygon:()=>st,Timer:()=>F,clearCanvas:()=>At,clearTextTexture:()=>St,createCanvas:()=>It,createCircle:()=>_,createLine:()=>Q,createRect:()=>I,createSvg:()=>zt,createSvgElement:()=>N,defaultConfig:()=>te,dispose:()=>z,getCenter:()=>mt,getConfig:()=>Ot,getTextureByText:()=>de,hasChinese:()=>Mt,initCamera:()=>Et,initCanvas:()=>Ht,initControl:()=>Ct,initDirectionalLight:()=>Gt,initLight:()=>wt,initRenderer:()=>Pt,initScene:()=>bt,initShape:()=>Lt,isContain:()=>Y,proxyOptions:()=>q,setCirclePosition:()=>T,setLineStartEnd:()=>L,setRectPosition:()=>G,sleepOnePromise:()=>dt,strToNumber:()=>ue,timeoutPromise:()=>j,vector3ToDevice:()=>x});module.exports=me(ve);var ee=require("three");var F=class{constructor(){o(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var g=require("three"),Bt=require("three/examples/jsm/controls/MapControls");function bt(){let r=new g.Scene;return r.background=new g.Color(16777215),r}function Pt(){let r=new g.WebGLRenderer({antialias:!0});return r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=g.PCFSoftShadowMap,r}function Et(r,s){let t=new g.OrthographicCamera(-r/2,r/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function wt(){let r=new g.Group,s=new g.HemisphereLight(16777215,16777215,2);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),r.add(s);let t=new g.AmbientLight(16777215,1);return r.add(t),r}function Ct(r,s){let t=new Bt.MapControls(r,s);return t.enableDamping=!1,t.zoomSpeed=2,t}function Lt(r,s=[]){let t=new g.Shape(r.map(e=>new g.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new g.Path(e.map(n=>new g.Vector2(...n)));t.holes.push(i)}),t}function Gt(r=16777215,s=1){let t=new g.DirectionalLight(r,s);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(128,128),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function z(r,s){var t;if(s&&r.children&&r.children.length&&r.children.forEach(e=>{z(e,s)}),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 Mt(r){return/[\u4E00-\u9FA5]+/g.test(r)}var H=require("three");var lt=new Map;function Ht(){let r=document.createElement("canvas");r.width=1024,r.height=64;let s=r.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:r,ctx:s}}var Dt,B;function It(){if(!Dt){let{canvas:r,ctx:s}=Ht();Dt=r,B=s}}function de(r){if(lt.has(r))return lt.get(r);It(),B.clearRect(0,0,1024,64);let s=Mt(r)?4:8;B.strokeText(r,2,s),B.fillText(r,2,s);let t=Math.ceil(B.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=B.getImageData(0,0,t,64),i=new H.DataTexture(Uint8Array.from(e.data),t,64,H.RGBAFormat);return i.flipY=!0,i.minFilter=H.LinearFilter,i.magFilter=H.LinearFilter,lt.set(r,i),i}function St(){lt.clear()}function At(){B=null,Dt=null}var K=require("@turf/turf");function x(r,s,t,e){let i=r.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),h=Math.round(-i.y*a+a);return{x:c,y:h}}function mt(r){let s=(0,K.featureCollection)(r.map(e=>(0,K.point)(e)));return(0,K.center)(s).geometry.coordinates}function Y(r,s,t){return r.x>=s.x&&r.x<=t.x&&r.y>=s.y&&r.y<=t.y}function q(r,s){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function j(r,s){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function N(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function zt(r,s){let t=N("svg");return t.setAttribute("width",r),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(r="2",s){let t=N("circle");return t.setAttribute("r",r),t.setAttribute("fill",s),t}function Q(r){let s=N("line");return s.setAttribute("stroke",r),s}function I(r,s){let t=N("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",s),t}function T(r,s,t){r.setAttribute("cx",`${s}`),r.setAttribute("cy",`${t}`)}function L(r,s,t){s&&(r.setAttribute("x1",`${s.x}`),r.setAttribute("y1",`${s.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function G(r,s,t,e,i){r.setAttribute("x",`${s}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function dt(){return Promise.resolve()}function ue(r){return parseInt(r.replace("#","0x"),16)}var v=require("three"),U=require("@tweenjs/tween.js");var Nt=require("three");var b=require("three");var Vt=require("lodash"),$t=require("three/examples/jsm/lines/LineMaterial.js"),Ut=require("three/examples/jsm/lines/LineSegmentsGeometry.js"),Kt=require("three/examples/jsm/lines/LineSegments2.js");var ge={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},D=class extends b.Object3D{constructor(t,e){super();this.context=t;o(this,"geometry");o(this,"material");o(this,"mesh");o(this,"line");o(this,"options");if(this.options=q((0,Vt.merge)({},ge,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.material.color=new b.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new b.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-strokeWidth",({value:i})=>{this.line.material.linewidth=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){if(this.options.geometry.type==="point")return this.position;let t=new b.Vector3,e=new b.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new b.Vector3(0,0,0);let t=new b.Box3,e=new b.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.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=Lt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new b.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new b.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){let t=new $t.LineMaterial({color:new b.Color(this.options.strokeColor).getHex(),opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0,linewidth:this.options.strokeWidth,wireframe:!1,dashed:!1}),{clientSize:{width:e,height:i}}=this.context;return t.resolution.set(e,i),t}initMesh(){return new b.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new b.EdgesGeometry(this.geometry),i=new Ut.LineSegmentsGeometry;i.fromEdgesGeometry(e);let n=new Kt.LineSegments2(i,t);return n.position.z=this.options.airHeight,n}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(){z(this),this.clear()}};var M=require("three");var J=class extends M.Object3D{constructor(){super();o(this,"directionalLight");o(this,"plane");o(this,"basicOpacity",.15);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Gt(16777215,1);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 M.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 M.PlaneGeometry(t,e),n=new M.ShadowMaterial({transparent:!0,opacity:0,side:M.DoubleSide}),a=new M.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-10,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){z(this,!0)}};var jt=require("three"),_t=require("lodash");var V=require("three");var tt=class extends V.EventDispatcher{constructor(t){super();this.context=t;o(this,"div");o(this,"element");o(this,"position",new V.Vector3);o(this,"clientPos",{x:0,y:0});o(this,"visible",!0);o(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:n,y:a}=x(t,this.context.camera,e,i);this.clientPos.x===n&&this.clientPos.y===a||(this.clientPos={x:n,y:a},this.div.style.left=`${n}px`,this.div.style.top=`${a}px`)});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 V.Box3().setFromObject(this.element).getCenter(new V.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.context.container.removeChild(this.div),this.div=null}};var fe={text:"",level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0}},X=class extends jt.Object3D{constructor(t,e){var i,n,a;super();this.context=t;o(this,"textDiv");o(this,"img");o(this,"overlay");o(this,"options");o(this,"size",{width:0,height:0});o(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=q((0,_t.merge)({},fe,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((n=e.position)==null?void 0:n.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new tt(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.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0,this.resetSize())}),this.addEventListener("change-text",({value:c})=>{this.overlay.div.removeChild(this.textDiv),this.overlay.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())})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return O(this,null,function*(){let t=this.overlay.visible;this.setVisible(!0),yield dt();let{width:e,height:i}=this.overlay.div.getBoundingClientRect();this.size={width:e,height:i},yield dt(),this._changePosition(),this.setVisible(t)})}get clientPos(){return this.overlay.clientPos}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",this.overlay.setOpacity(this.options.opacity),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.background="rgba(255, 255, 255, .7)",t.style.padding="2px",t.style.borderRadius="4px",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.text.split(`\r
|
|
2
|
-
`).forEach(e=>{let i=document.createElement("div");i.style.whiteSpace="nowrap",i.textContent=e,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.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){this.overlay.setVisible(t,"flex")}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.textDiv=null,this.img=void 0,this.overlay.dispose()}};var S=require("three");var ut=require("three");var Xt=require("three");var $=class extends Xt.Object3D{constructor(t){super();this.context=t}dispose(){z(this),this.clear()}};var et=class extends ${constructor(t){super(t);o(this,"graphicMap",new Map)}getCenter(){return new ut.Box3().setFromObject(this).getCenter(new ut.Vector3)}createGraphic(t){let e=new D(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,a)=>{if(a instanceof D){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Wt=require("lodash");var it=class extends ${constructor(t){super(t);o(this,"pois",[]);o(this,"debounceCollisionDetection");o(this,"timer",new F);o(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Wt.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new X(this.context,t);return this.add(e),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),this.remove(t),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.children.filter(n=>n instanceof X&&n.isContain(t,e))}collisionDetection(){let{clientSize:{width:t,height:e}}=this.context,i=[];this.pois.filter(a=>a.withinDisplayRange).forEach((a,c)=>{let{left:h,right:p,top:l,bottom:u}=a.getBox();if(c===0){i.push({left:h,right:p,top:l,bottom:u});return}let f=i.some(m=>p<m.right&&p>m.left||h>m.left&&h<m.right||h===m.left&&p===m.right?u<=m.bottom&&u>m.top||l>=m.top&&l<m.bottom:!1);a.setVisible(!f),i.push({left:h,right:p,top:l,bottom:u})})}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 E=require("three"),Zt=require("@mars3d/heatmap.js"),R=require("@turf/turf");var nt=class extends E.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:a}=this.getBox(t);this.heatmap=(0,Zt.create)(k({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(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new E.PlaneGeometry(t,e),n=new E.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new E.MeshBasicMaterial({transparent:!0,side:E.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new E.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new E.Matrix3().makeScale(1,-1).multiply(new E.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new E.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,R.featureCollection)(t.data.map(p=>(0,R.point)([p.x,p.y]))),i=(0,R.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,R.center)(e);return{width:n,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ot=class extends S.Object3D{constructor(t){super();this.context=t;o(this,"graphicLayer");o(this,"poiLayer");o(this,"grounds",new Set);o(this,"shadow",new J);o(this,"heatmap");o(this,"groundUpper",new S.Object3D);o(this,"groundMaxHeight",0);this.graphicLayer=new et(this.context),this.poiLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.options.height+=e.options.zIndex/1e5,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)):0,this.graphicLayer.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new S.Box3().setFromObject(this.groundUpper).getCenter(new S.Vector3)}addShadow(){let t=new S.Box3().setFromObject(this.groundUpper),e=t.getCenter(new S.Vector3),i=t.getSize(new S.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return t.height+=(t.height||0)/1e5,this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new nt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new S.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 gt=require("three");var A=class extends gt.EventDispatcher{constructor(t){super();this.context=t;o(this,"points",[]);o(this,"svg");o(this,"enable",!0);this.svg=zt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}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:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,p=n/c*2-1,l=1-a/h*2;return new gt.Vector3(p,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return x(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var rt=class extends A{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]);T(this.circles[0],t.x,t.y),L(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),L(this.line,void 0,t)}});o(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",L(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,a=this.circles[this.points.length];T(a,i,n),this.points.length||L(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=Q(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(C(i-t,2)+C(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var st=class extends A{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]&&T(this.circles[e],i.x,i.y),e!==0&&L(this.lines[e-1],void 0,i),this.lines[e]&&L(this.lines[e],i)})});o(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",L(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:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let p=_(c,a);T(p,i,n),this.addCircle(p)}if(this.lines.length&&L(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let p=Q(h);L(p,{x:i,y:n},{x:i,y:n}),this.addLine(p)}}});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"),a=+i.getAttribute("cy");return Math.sqrt(C(t-n,2)+C(e-a,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 a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Yt=require("three");var Ft=class extends A{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 Yt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,h=x(a,e,i,n),p=x(c,e,i,n);G(this.rect,h.x,p.y,Math.abs(p.x-h.x),Math.abs(p.y-h.y));let{x:l,y:u}=h,{x:f,y:m}=p,d=5,P=[{x:l-d,y:m-d},{x:f-d,y:m-d},{x:l-d,y:u-d},{x:f-d,y:u-d}];for(let w=0;w<P.length;w++)G(this.cornerRect[w],P[w].x,P[w].y,d*2,d*2);let y=4,vt=(l+f)/2,W=(u+m)/2,Z=[{x:vt-y,y:m-y},{x:l-y,y:W-y},{x:f-y,y:W-y},{x:vt-y,y:u-y}];for(let w=0;w<Z.length;w++)G(this.centerRect[w],Z[w].x,Z[w].y,y*2,y*2)}else{G(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)G(this.cornerRect[t],0,0,0,0),G(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=I(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=I(e.stroke,"#ffffff"),this.centerRect[i]=I(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 qt=require("three");var ft=class extends A{constructor(t){super(t);o(this,"startPoint");o(this,"endPoint");o(this,"rect");o(this,"frustum",new qt.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=k({},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),a=Math.abs(e.y-t.y);G(this.rect,i.x,i.y,n,a)}else G(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=I(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),G(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,a=x(this.startPoint,e,i,n),c=x(this.endPoint,e,i,n),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},p={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(h,p);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof D&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let m=t.getPosition();if(m){let d=x(m,n,a,c);return Y(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:p,max:l}=h,u=x(p,n,a,c),f=x(l,n,a,c);return!(!Y(u,e,i)||!Y(f,e,i))}dispose(){this.unRegistryEvent()}};var at=class extends Nt.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:a}=this.downPoint;if(Math.sqrt(C(n-e,2)+C(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(l=>l.options.id));this.context.getPoisByDeviceXy(e,i).forEach(l=>{var u;if(!h.has(l.options.id)){let f=((u=this.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(l.options.id))||null;f&&(c.push(f),h.add(l.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(l=>this._list.add(l)),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 ft(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 Qt=require("three");var ct=class extends Qt.EventDispatcher{constructor(t){super();this.context=t;o(this,"curGraphics",new Set);o(this,"timer",new F);o(this,"graphicTimerMap",new Map);o(this,"onPointerMove",({graphics:t,pois:e})=>{let i=e.map(h=>{var p;return(p=this.context.currentFloor)==null?void 0:p.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,a=new Set([...t,...i]);a.forEach(h=>{if(this.graphicTimerMap.get(h)||this.curGraphics.has(h))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(h),this.handleHoverGraphicsChange()},n);this.graphicTimerMap.set(h,p)}),this.graphicTimerMap.forEach((h,p)=>{a.has(p)||(this.timer.clearTimeout(h),this.graphicTimerMap.delete(p))});let c=this.curGraphics.size;this.curGraphics.forEach(h=>{a.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 ht=class extends v.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;o(this,"scene",bt());o(this,"renderer",Pt());o(this,"camera");o(this,"control");o(this,"lights",wt());o(this,"timer",new F);o(this,"tweenGroup",new U.Group);o(this,"currentFloor");o(this,"selection");o(this,"hoverHelper");o(this,"basicRatio");o(this,"clientSize",{width:0,height:0});o(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(n,a),this.resizeClientSize(n,a)});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 at(this),this.hoverHelper=new ct(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=Et(t,e),this.renderer.setSize(t,e),this.control=Ct(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 v.Vector3(0,0,0),e=new v.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=x(t,this.camera,i,n),c=x(e,this.camera,i,n);return Math.ceil(Math.sqrt(C(c.x-a.x,2)+C(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof v.AmbientLight&&(e.color=new v.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 v.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new v.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()):j(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new U.Tween(n,this.tweenGroup).to(a,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){return e===0&&(this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0),j(new Promise(i=>{let n={azimuthal:this.control.getAzimuthalAngle()},a={azimuthal:t},c=new U.Tween(n,this.tweenGroup).to(a,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 v.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let n=this.getCameraLookAt(),a={zoom:this.camera.zoom,target:this.control.target.clone()};return i||(this.camera.position.copy(a.target.clone().sub(n)),this.control.target.copy(a.target),this.camera.zoom=a.zoom),j(new Promise(c=>{let h=new U.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(n)),this.control.target.copy(a.target),this.camera.zoom=a.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,a,c,h]=e,{clientSize:{width:p,height:l}}=this,u=this.control.getPolarAngle();this.setPolarAngle(0,0);let f=new v.Box3().setFromObject(t);this.setPolarAngle(u,0);let{max:m,min:d}=f,P=x(m,this.camera,p,l),y=x(d,this.camera,p,l),W=new v.Box2().setFromPoints([new v.Vector2(P.x,P.y),new v.Vector2(y.x,y.y)]).getSize(new v.Vector2),Z=(p-a-h)/W.x,w=(l-n-c)/W.y,ne=Math.min(Z,w),oe=new v.Vector3((m.x+d.x)/2,(m.y+d.y)/2,m.z);return this.setZoom(ne*this.camera.zoom,oe,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 j(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new U.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),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()),z(this.scene)}};var Jt=require("lodash"),te={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Ot(r){return(0,Jt.merge)({},te,r)}var ie=(t=>(t[t.D2=0]="D2",t[t.D3=.9]="D3",t))(ie||{}),Tt=class extends ee.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,"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}});this.config=Ot(e),this.context=new ht(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(p){return O(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let{apiDomain:l,apiPath:{floorGraphic:u},apiInfo:f}=this.config,m=`${l}${u}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(m,f).then(P=>P.json()).then(P=>P.data).then(P=>((P||[]).map(y=>y.info=JSON.parse(y.info)),P||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return O(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:p},apiInfo:l}=this.config,u=`${h}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`,f=yield fetch(u,l).then(m=>m.json()).then(m=>m.data).then(m=>{let d=(m||[])[0];return d&&(d.info=JSON.parse(d.info)),d});return this.buildingGroundMap.set(c,f),f})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${n}-${a}-${c}-${h}`}load(p){return O(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(l))return;let[u,f]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(f){let m=mt(f.info.geometry.cds[0]);u.forEach(d=>{if(d.info.geometry.type==="polygon")d.info.geometry.cds.map(P=>{Array.isArray(P)&&P.forEach(y=>{y[0]-=m[0],y[1]-=m[1]})});else{let[P,y]=d.info.geometry.cds;d.info.geometry.cds=[P-m[0],y-m[1]]}d.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(l,u),u})}createFloor(t){let e=new ot(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=t.filter(p=>p.info.group==="ground");i.forEach(p=>{p.info.fillColor="#F5F7F9",p.info.fillOpacity=1,p.info.strokeOpacity=0,p.info.height=5});let n=i.map(p=>new D(this.context,p.info));e.addGrounds(n);let a=t.filter(p=>p.info.group!=="ground");a.forEach((p,l)=>{p.info.height=5});let c=new Map,h=a.map(p=>{let l=e.addGraphic(p.info);return l.userData.data=p,c.set(p.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:h}}switchFloor({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),l=this.floorDataMap.get(p);if(this.context.control.removeEventListener("change",this.onControlChange),l){let u=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(u)||null;let f=this.createFloor(l);f?(this.context.switchFloor(f.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,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] ["+a+"] \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 D))||[]}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(xt(k({},e),{position:xt(k({},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.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return x(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 O(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(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}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 O(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new rt(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 st(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=mt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-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(),St(),At(),this.unRegistryEvent()}};
|
|
1
|
+
"use strict";var pt=Object.defineProperty,re=Object.defineProperties,se=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertyNames,Rt=Object.getOwnPropertySymbols;var kt=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var C=Math.pow,yt=(r,s,t)=>s in r?pt(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t,k=(r,s)=>{for(var t in s||(s={}))kt.call(s,t)&&yt(r,t,s[t]);if(Rt)for(var t of Rt(s))he.call(s,t)&&yt(r,t,s[t]);return r},xt=(r,s)=>re(r,ae(s));var pe=(r,s)=>{for(var t in s)pt(r,t,{get:s[t],enumerable:!0})},le=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of ce(s))!kt.call(r,i)&&i!==t&&pt(r,i,{get:()=>s[i],enumerable:!(e=se(s,i))||e.enumerable});return r};var me=r=>le(pt({},"__esModule",{value:!0}),r);var o=(r,s,t)=>(yt(r,typeof s!="symbol"?s+"":s,t),t);var O=(r,s,t)=>new Promise((e,i)=>{var n=h=>{try{c(t.next(h))}catch(p){i(p)}},a=h=>{try{c(t.throw(h))}catch(p){i(p)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(n,a);c((t=t.apply(r,s)).next())});var ve={};pe(ve,{BMap:()=>Tt,BaseSvg:()=>A,Context:()=>ht,Floor:()=>ot,Graphic:()=>D,GraphicLayer:()=>et,HeatmapElement:()=>nt,HoverHelper:()=>ct,Layer:()=>$,MapTypePolar:()=>ie,Overlay:()=>tt,Poi:()=>X,PoiLayer:()=>it,SelectBox:()=>Ft,Selection:()=>at,Shadow:()=>J,SvgLine:()=>rt,SvgPolygon:()=>st,Timer:()=>F,clearCanvas:()=>At,clearTextTexture:()=>St,createCanvas:()=>It,createCircle:()=>_,createLine:()=>Q,createRect:()=>I,createSvg:()=>zt,createSvgElement:()=>N,defaultConfig:()=>te,dispose:()=>z,getCenter:()=>mt,getConfig:()=>Ot,getTextureByText:()=>de,hasChinese:()=>Mt,initCamera:()=>Et,initCanvas:()=>Ht,initControl:()=>Ct,initDirectionalLight:()=>Gt,initLight:()=>wt,initRenderer:()=>Pt,initScene:()=>bt,initShape:()=>Lt,isContain:()=>Y,proxyOptions:()=>q,setCirclePosition:()=>T,setLineStartEnd:()=>L,setRectPosition:()=>G,sleepOnePromise:()=>dt,strToNumber:()=>ue,timeoutPromise:()=>j,vector3ToDevice:()=>x});module.exports=me(ve);var ee=require("three");var F=class{constructor(){o(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var f=require("three"),Bt=require("three/examples/jsm/controls/MapControls");function bt(){let r=new f.Scene;return r.background=new f.Color(16777215),r}function Pt(){let r=new f.WebGLRenderer({antialias:!0});return r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=f.PCFSoftShadowMap,r}function Et(r,s){let t=new f.OrthographicCamera(-r/2,r/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function wt(){let r=new f.Group,s=new f.HemisphereLight(16777215,16777215,2);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),r.add(s);let t=new f.AmbientLight(16777215,1);return r.add(t),r}function Ct(r,s){let t=new Bt.MapControls(r,s);return t.enableDamping=!1,t.zoomSpeed=2,t}function Lt(r,s=[]){let t=new f.Shape(r.map(e=>new f.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new f.Path(e.map(n=>new f.Vector2(...n)));t.holes.push(i)}),t}function Gt(r=16777215,s=1){let t=new f.DirectionalLight(r,s);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(128,128),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function z(r,s){var t;if(s&&r.children&&r.children.length&&r.children.forEach(e=>{z(e,s)}),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 Mt(r){return/[\u4E00-\u9FA5]+/g.test(r)}var H=require("three");var lt=new Map;function Ht(){let r=document.createElement("canvas");r.width=1024,r.height=64;let s=r.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:r,ctx:s}}var Dt,B;function It(){if(!Dt){let{canvas:r,ctx:s}=Ht();Dt=r,B=s}}function de(r){if(lt.has(r))return lt.get(r);It(),B.clearRect(0,0,1024,64);let s=Mt(r)?4:8;B.strokeText(r,2,s),B.fillText(r,2,s);let t=Math.ceil(B.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=B.getImageData(0,0,t,64),i=new H.DataTexture(Uint8Array.from(e.data),t,64,H.RGBAFormat);return i.flipY=!0,i.minFilter=H.LinearFilter,i.magFilter=H.LinearFilter,lt.set(r,i),i}function St(){lt.clear()}function At(){B=null,Dt=null}var K=require("@turf/turf");function x(r,s,t,e){let i=r.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),h=Math.round(-i.y*a+a);return{x:c,y:h}}function mt(r){let s=(0,K.featureCollection)(r.map(e=>(0,K.point)(e)));return(0,K.center)(s).geometry.coordinates}function Y(r,s,t){return r.x>=s.x&&r.x<=t.x&&r.y>=s.y&&r.y<=t.y}function q(r,s){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function j(r,s){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function N(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function zt(r,s){let t=N("svg");return t.setAttribute("width",r),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(r="2",s){let t=N("circle");return t.setAttribute("r",r),t.setAttribute("fill",s),t}function Q(r){let s=N("line");return s.setAttribute("stroke",r),s}function I(r,s){let t=N("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",s),t}function T(r,s,t){r.setAttribute("cx",`${s}`),r.setAttribute("cy",`${t}`)}function L(r,s,t){s&&(r.setAttribute("x1",`${s.x}`),r.setAttribute("y1",`${s.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function G(r,s,t,e,i){r.setAttribute("x",`${s}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function dt(){return Promise.resolve()}function ue(r){return parseInt(r.replace("#","0x"),16)}var v=require("three"),U=require("@tweenjs/tween.js");var Nt=require("three");var b=require("three");var Vt=require("lodash"),$t=require("three/examples/jsm/lines/LineMaterial.js"),Ut=require("three/examples/jsm/lines/LineSegmentsGeometry.js"),Kt=require("three/examples/jsm/lines/LineSegments2.js");var ge={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},D=class extends b.Object3D{constructor(t,e){super();this.context=t;o(this,"geometry");o(this,"material");o(this,"mesh");o(this,"line");o(this,"options");if(this.options=q((0,Vt.merge)({},ge,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.material.color=new b.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new b.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-strokeWidth",({value:i})=>{this.line.material.linewidth=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new b.Vector3,e=new b.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new b.Vector3(0,0,0);let t=new b.Box3,e=new b.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.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=Lt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new b.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new b.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){let t=new $t.LineMaterial({color:new b.Color(this.options.strokeColor).getHex(),opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0,linewidth:this.options.strokeWidth,wireframe:!1,dashed:!1}),{clientSize:{width:e,height:i}}=this.context;return t.resolution.set(e,i),t}initMesh(){return new b.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new b.EdgesGeometry(this.geometry),i=new Ut.LineSegmentsGeometry;i.fromEdgesGeometry(e);let n=new Kt.LineSegments2(i,t);return n.position.z=this.options.airHeight,n}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(){z(this),this.clear()}};var M=require("three");var J=class extends M.Object3D{constructor(){super();o(this,"directionalLight");o(this,"plane");o(this,"basicOpacity",.15);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Gt(16777215,1);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 M.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 M.PlaneGeometry(t,e),n=new M.ShadowMaterial({transparent:!0,opacity:0,side:M.DoubleSide}),a=new M.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-10,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){z(this,!0)}};var jt=require("three"),_t=require("lodash");var V=require("three");var tt=class extends V.EventDispatcher{constructor(t){super();this.context=t;o(this,"div");o(this,"element");o(this,"position",new V.Vector3);o(this,"clientPos",{x:0,y:0});o(this,"visible",!0);o(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:n,y:a}=x(t,this.context.camera,e,i);this.clientPos.x===n&&this.clientPos.y===a||(this.clientPos={x:n,y:a},this.div.style.left=`${n}px`,this.div.style.top=`${a}px`)});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 V.Box3().setFromObject(this.element).getCenter(new V.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.context.container.removeChild(this.div),this.div=null}};var fe={text:"",level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0}},X=class extends jt.Object3D{constructor(t,e){var i,n,a;super();this.context=t;o(this,"textDiv");o(this,"img");o(this,"overlay");o(this,"options");o(this,"size",{width:0,height:0});o(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=q((0,_t.merge)({},fe,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((n=e.position)==null?void 0:n.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new tt(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.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0,this.resetSize())}),this.addEventListener("change-text",({value:c})=>{this.overlay.div.removeChild(this.textDiv),this.overlay.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())})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return O(this,null,function*(){let t=this.overlay.visible;this.setVisible(!0),yield dt();let{width:e,height:i}=this.overlay.div.getBoundingClientRect();this.size={width:e,height:i},yield dt(),this._changePosition(),this.setVisible(t)})}get clientPos(){return this.overlay.clientPos}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",t.style.userSelect="none",this.overlay.setOpacity(this.options.opacity),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.background="rgba(255, 255, 255, .7)",t.style.padding="2px",t.style.borderRadius="4px",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.text.split(`\r
|
|
2
|
+
`).forEach(e=>{let i=document.createElement("div");i.style.whiteSpace="nowrap",i.textContent=e,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.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){this.overlay.setVisible(t,"flex")}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.textDiv=null,this.img=void 0,this.overlay.dispose()}};var S=require("three");var ut=require("three");var Xt=require("three");var $=class extends Xt.Object3D{constructor(t){super();this.context=t}dispose(){z(this),this.clear()}};var et=class extends ${constructor(t){super(t);o(this,"graphicMap",new Map)}getCenter(){return new ut.Box3().setFromObject(this).getCenter(new ut.Vector3)}createGraphic(t){let e=new D(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,a)=>{if(a instanceof D){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Wt=require("lodash");var it=class extends ${constructor(t){super(t);o(this,"pois",[]);o(this,"debounceCollisionDetection");o(this,"timer",new F);o(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Wt.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new X(this.context,t);return this.add(e),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),this.remove(t),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.children.filter(n=>n instanceof X&&n.isContain(t,e))}collisionDetection(){let{clientSize:{width:t,height:e}}=this.context,i=[];this.pois.filter(a=>a.withinDisplayRange).forEach((a,c)=>{let{left:h,right:p,top:l,bottom:u}=a.getBox();if(c===0){i.push({left:h,right:p,top:l,bottom:u});return}let g=i.some(m=>p<m.right&&p>m.left||h>m.left&&h<m.right||h===m.left&&p===m.right?u<=m.bottom&&u>m.top||l>=m.top&&l<m.bottom:!1);a.setVisible(!g),g||i.push({left:h,right:p,top:l,bottom:u})})}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 E=require("three"),Zt=require("@mars3d/heatmap.js"),R=require("@turf/turf");var nt=class extends E.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:a}=this.getBox(t);this.heatmap=(0,Zt.create)(k({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(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new E.PlaneGeometry(t,e),n=new E.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new E.MeshBasicMaterial({transparent:!0,side:E.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new E.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new E.Matrix3().makeScale(1,-1).multiply(new E.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new E.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,R.featureCollection)(t.data.map(p=>(0,R.point)([p.x,p.y]))),i=(0,R.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,R.center)(e);return{width:n,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ot=class extends S.Object3D{constructor(t){super();this.context=t;o(this,"graphicLayer");o(this,"poiLayer");o(this,"grounds",new Set);o(this,"shadow",new J);o(this,"heatmap");o(this,"groundUpper",new S.Object3D);o(this,"groundMaxHeight",0);this.graphicLayer=new et(this.context),this.poiLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.options.height+=e.options.zIndex/1e5,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)):0,this.graphicLayer.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new S.Box3().setFromObject(this.groundUpper).getCenter(new S.Vector3)}addShadow(){let t=new S.Box3().setFromObject(this.groundUpper),e=t.getCenter(new S.Vector3),i=t.getSize(new S.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return t.height+=(t.height||0)/1e5,this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new nt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new S.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 gt=require("three");var A=class extends gt.EventDispatcher{constructor(t){super();this.context=t;o(this,"points",[]);o(this,"svg");o(this,"enable",!0);this.svg=zt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}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:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,p=n/c*2-1,l=1-a/h*2;return new gt.Vector3(p,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return x(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var rt=class extends A{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]);T(this.circles[0],t.x,t.y),L(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),L(this.line,void 0,t)}});o(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",L(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,a=this.circles[this.points.length];T(a,i,n),this.points.length||L(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=Q(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(C(i-t,2)+C(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var st=class extends A{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]&&T(this.circles[e],i.x,i.y),e!==0&&L(this.lines[e-1],void 0,i),this.lines[e]&&L(this.lines[e],i)})});o(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",L(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:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let p=_(c,a);T(p,i,n),this.addCircle(p)}if(this.lines.length&&L(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let p=Q(h);L(p,{x:i,y:n},{x:i,y:n}),this.addLine(p)}}});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"),a=+i.getAttribute("cy");return Math.sqrt(C(t-n,2)+C(e-a,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 a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Yt=require("three");var Ft=class extends A{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 Yt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,h=x(a,e,i,n),p=x(c,e,i,n);G(this.rect,h.x,p.y,Math.abs(p.x-h.x),Math.abs(p.y-h.y));let{x:l,y:u}=h,{x:g,y:m}=p,d=5,P=[{x:l-d,y:m-d},{x:g-d,y:m-d},{x:l-d,y:u-d},{x:g-d,y:u-d}];for(let w=0;w<P.length;w++)G(this.cornerRect[w],P[w].x,P[w].y,d*2,d*2);let y=4,vt=(l+g)/2,W=(u+m)/2,Z=[{x:vt-y,y:m-y},{x:l-y,y:W-y},{x:g-y,y:W-y},{x:vt-y,y:u-y}];for(let w=0;w<Z.length;w++)G(this.centerRect[w],Z[w].x,Z[w].y,y*2,y*2)}else{G(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)G(this.cornerRect[t],0,0,0,0),G(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=I(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=I(e.stroke,"#ffffff"),this.centerRect[i]=I(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 qt=require("three");var ft=class extends A{constructor(t){super(t);o(this,"startPoint");o(this,"endPoint");o(this,"rect");o(this,"frustum",new qt.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=k({},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),a=Math.abs(e.y-t.y);G(this.rect,i.x,i.y,n,a)}else G(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=I(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),G(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,a=x(this.startPoint,e,i,n),c=x(this.endPoint,e,i,n),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},p={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(h,p);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof D&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let m=t.getPosition();if(m){let d=x(m,n,a,c);return Y(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:p,max:l}=h,u=x(p,n,a,c),g=x(l,n,a,c);return!(!Y(u,e,i)||!Y(g,e,i))}dispose(){this.unRegistryEvent()}};var at=class extends Nt.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:a}=this.downPoint;if(Math.sqrt(C(n-e,2)+C(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(l=>l.options.id));this.context.getPoisByDeviceXy(e,i).forEach(l=>{var u;if(!h.has(l.options.id)){let g=((u=this.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(l.options.id))||null;g&&(c.push(g),h.add(l.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(l=>this._list.add(l)),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 ft(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 Qt=require("three");var ct=class extends Qt.EventDispatcher{constructor(t){super();this.context=t;o(this,"curGraphics",new Set);o(this,"timer",new F);o(this,"graphicTimerMap",new Map);o(this,"onPointerMove",({graphics:t,pois:e})=>{let i=e.map(h=>{var p;return(p=this.context.currentFloor)==null?void 0:p.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,a=new Set([...t,...i]);a.forEach(h=>{if(this.graphicTimerMap.get(h)||this.curGraphics.has(h))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(h),this.handleHoverGraphicsChange()},n);this.graphicTimerMap.set(h,p)}),this.graphicTimerMap.forEach((h,p)=>{a.has(p)||(this.timer.clearTimeout(h),this.graphicTimerMap.delete(p))});let c=this.curGraphics.size;this.curGraphics.forEach(h=>{a.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 ht=class extends v.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;o(this,"scene",bt());o(this,"renderer",Pt());o(this,"camera");o(this,"control");o(this,"lights",wt());o(this,"timer",new F);o(this,"tweenGroup",new U.Group);o(this,"currentFloor");o(this,"selection");o(this,"hoverHelper");o(this,"basicRatio");o(this,"clientSize",{width:0,height:0});o(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(n,a),this.resizeClientSize(n,a)});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 at(this),this.hoverHelper=new ct(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=Et(t,e),this.renderer.setSize(t,e),this.control=Ct(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 v.Vector3(0,0,0),e=new v.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=x(t,this.camera,i,n),c=x(e,this.camera,i,n);return Math.ceil(Math.sqrt(C(c.x-a.x,2)+C(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof v.AmbientLight&&(e.color=new v.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 v.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new v.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()):j(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new U.Tween(n,this.tweenGroup).to(a,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){return e===0&&(this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0),j(new Promise(i=>{let n={azimuthal:this.control.getAzimuthalAngle()},a={azimuthal:t},c=new U.Tween(n,this.tweenGroup).to(a,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 v.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let n=this.getCameraLookAt(),a={zoom:this.camera.zoom,target:this.control.target.clone()};return i||(this.camera.position.copy(a.target.clone().sub(n)),this.control.target.copy(a.target),this.camera.zoom=a.zoom),j(new Promise(c=>{let h=new U.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(n)),this.control.target.copy(a.target),this.camera.zoom=a.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,a,c,h]=e,{clientSize:{width:p,height:l}}=this,u=this.control.getPolarAngle();this.setPolarAngle(0,0);let g=new v.Box3().setFromObject(t);this.setPolarAngle(u,0);let{max:m,min:d}=g,P=x(m,this.camera,p,l),y=x(d,this.camera,p,l),W=new v.Box2().setFromPoints([new v.Vector2(P.x,P.y),new v.Vector2(y.x,y.y)]).getSize(new v.Vector2),Z=(p-a-h)/W.x,w=(l-n-c)/W.y,ne=Math.min(Z,w),oe=new v.Vector3((m.x+d.x)/2,(m.y+d.y)/2,m.z);return this.setZoom(ne*this.camera.zoom,oe,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 j(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new U.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),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()),z(this.scene)}};var Jt=require("lodash"),te={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Ot(r){return(0,Jt.merge)({},te,r)}var ie=(t=>(t[t.D2=0]="D2",t[t.D3=.9]="D3",t))(ie||{}),Tt=class extends ee.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,"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}});this.config=Ot(e),this.context=new ht(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(p){return O(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let{apiDomain:l,apiPath:{floorGraphic:u},apiInfo:g}=this.config,m=`${l}${u}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(m,g).then(P=>P.json()).then(P=>P.data).then(P=>((P||[]).map(y=>y.info=JSON.parse(y.info)),P||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return O(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:p},apiInfo:l}=this.config,u=`${h}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`,g=yield fetch(u,l).then(m=>m.json()).then(m=>m.data).then(m=>{let d=(m||[])[0];return d&&(d.info=JSON.parse(d.info)),d});return this.buildingGroundMap.set(c,g),g})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${n}-${a}-${c}-${h}`}load(p){return O(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(l))return;let[u,g]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(g){let m=mt(g.info.geometry.cds[0]);u.forEach(d=>{if(d.info.geometry.type==="polygon")d.info.geometry.cds.map(P=>{Array.isArray(P)&&P.forEach(y=>{y[0]-=m[0],y[1]-=m[1]})});else{let[P,y]=d.info.geometry.cds;d.info.geometry.cds=[P-m[0],y-m[1]]}d.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(l,u),u})}createFloor(t){let e=new ot(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=t.filter(p=>p.info.group==="ground");i.forEach(p=>{p.info.fillColor="#F5F7F9",p.info.fillOpacity=1,p.info.strokeOpacity=0,p.info.height=5});let n=i.map(p=>new D(this.context,p.info));e.addGrounds(n);let a=t.filter(p=>p.info.group!=="ground");a.forEach((p,l)=>{p.info.height=5});let c=new Map,h=a.map(p=>{let l=e.addGraphic(p.info);return l.userData.data=p,c.set(p.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:h}}switchFloor({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),l=this.floorDataMap.get(p);if(this.context.control.removeEventListener("change",this.onControlChange),l){let u=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(u)||null;let g=this.createFloor(l);g?(this.context.switchFloor(g.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,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] ["+a+"] \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 D))||[]}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(xt(k({},e),{position:xt(k({},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.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return x(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 O(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(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}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 O(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new rt(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 st(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=mt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-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(),St(),At(),this.unRegistryEvent()}};
|
|
3
3
|
//# sourceMappingURL=bmap.cjs.min.js.map
|